Skip to content

Commit ed03da4

Browse files
committed
Added new Pluggable USB structure
This commit was required to test an IDE bug
1 parent 435fc32 commit ed03da4

File tree

4 files changed

+69
-1
lines changed

4 files changed

+69
-1
lines changed

hardware/arduino/avr/cores/arduino/PluggableUSB.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@
2525

2626
#define MAX_MODULES 6
2727

28+
#include "PluggableUSB.h"
29+
#include "USBDevice.h"
30+
31+
PUSB_ PUSB;
32+
33+
PUSB_::PUSB_(void)
34+
{
35+
36+
}
37+
2838
static u8 lastIf = CDC_ACM_INTERFACE + CDC_INTERFACE_COUNT;
2939
static u8 lastEp = CDC_FIRST_ENDPOINT + CDC_ENPOINT_COUNT;
3040

@@ -97,4 +107,4 @@ int8_t PUSB_AddFunction(PUSBListNode *node, u8* interface)
97107

98108
#endif
99109

100-
#endif /* if defined(USBCON) */
110+
#endif /* if defined(USBCON) */

hardware/arduino/avr/cores/arduino/PluggableUSB.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,21 @@ class PUSBListNode {
4848
PUSBListNode(PUSBCallbacks *ncb) {cb = ncb;}
4949
};
5050

51+
class USBDevice;
52+
53+
class PUSB_
54+
{
55+
public:
56+
PUSB_(void);
57+
58+
// Only access this class via the USBDevice
59+
private:
60+
friend USBDevice;
61+
void AppendDescriptor(USBDevice* device);
62+
63+
// TODO add root device, search functions etc
64+
};
65+
5166
int8_t PUSB_AddFunction(PUSBListNode *node, u8 *interface);
5267

5368
int PUSB_GetInterface(u8* interfaceNum);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
#include "USBDevice.h"
3+
#include "PluggableUSB.h"
4+
5+
#if defined(USBCON)
6+
#ifdef PLUGGABLE_USB_ENABLED
7+
8+
USBDevice::USBDevice(void)
9+
{
10+
//PUSB.AppendDescriptor(this);
11+
}
12+
13+
14+
#endif
15+
16+
#endif /* if defined(USBCON) */
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Include guard
2+
#pragma once
3+
4+
#define HID_h
5+
6+
#include <stdint.h>
7+
#include <Arduino.h>
8+
9+
//http://stackoverflow.com/questions/1837165/can-two-classes-see-each-other-using-c
10+
11+
class PUSB_;
12+
extern PUSB_ PUSB;
13+
14+
class USBDevice
15+
{
16+
public:
17+
USBDevice(void);
18+
19+
// Needs to be public for static PUSB_ function access
20+
// Inherit this device private and everything should be fine
21+
//private:
22+
USBDevice* next = NULL;
23+
24+
25+
protected:
26+
27+
};

0 commit comments

Comments
 (0)