25
25
26
26
#define MAX_MODULES 6
27
27
28
- static uint8_t lastIf = CDC_ACM_INTERFACE + CDC_INTERFACE_COUNT;
29
- static uint8_t lastEp = CDC_FIRST_ENDPOINT + CDC_ENPOINT_COUNT;
30
-
31
28
extern uint8_t _initEndpoints[];
32
29
33
30
// PUSBCallbacks cbs[MAX_MODULES];
34
- static uint8_t modules_count = 0 ;
35
31
36
- static PUSBListNode* rootNode = NULL ;
32
+ PluggableUSB_ PluggableUSB ;
37
33
38
34
int PluggableUSB_::getInterface (uint8_t * interfaceNum)
39
35
{
40
36
int ret = 0 ;
41
37
PUSBListNode* node = rootNode;
42
- for (uint8_t i=0 ; i<modules_count ; i++) {
38
+ for (uint8_t i=0 ; i<modulesCount ; i++) {
43
39
ret = node->getInterface (interfaceNum);
44
40
node = node->next ;
45
41
}
@@ -50,7 +46,7 @@ int PluggableUSB_::getDescriptor(int8_t t)
50
46
{
51
47
int ret = 0 ;
52
48
PUSBListNode* node = rootNode;
53
- for (uint8_t i=0 ; i<modules_count && ret == 0 ; i++) {
49
+ for (uint8_t i=0 ; i<modulesCount && ret == 0 ; i++) {
54
50
ret = node->getDescriptor (t);
55
51
node = node->next ;
56
52
}
@@ -61,7 +57,7 @@ bool PluggableUSB_::setup(USBSetup& setup, uint8_t j)
61
57
{
62
58
bool ret = false ;
63
59
PUSBListNode* node = rootNode;
64
- for (uint8_t i=0 ; i<modules_count && ret == false ; i++) {
60
+ for (uint8_t i=0 ; i<modulesCount && ret == false ; i++) {
65
61
ret = node->setup (setup, j);
66
62
node = node->next ;
67
63
}
@@ -70,11 +66,11 @@ bool PluggableUSB_::setup(USBSetup& setup, uint8_t j)
70
66
71
67
bool PluggableUSB_::plug (PUSBListNode *node)
72
68
{
73
- if (modules_count >= MAX_MODULES) {
69
+ if (modulesCount >= MAX_MODULES) {
74
70
return false ;
75
71
}
76
72
77
- if (modules_count == 0 ) {
73
+ if (modulesCount == 0 ) {
78
74
rootNode = node;
79
75
} else {
80
76
PUSBListNode *current = rootNode;
@@ -91,11 +87,18 @@ bool PluggableUSB_::plug(PUSBListNode *node)
91
87
_initEndpoints[lastEp] = node->endpointType [i];
92
88
lastEp++;
93
89
}
94
- modules_count ++;
90
+ modulesCount ++;
95
91
return true ;
96
92
// restart USB layer???
97
93
}
98
94
95
+ PluggableUSB_::PluggableUSB_ () : lastIf(CDC_ACM_INTERFACE + CDC_INTERFACE_COUNT),
96
+ lastEp(CDC_FIRST_ENDPOINT + CDC_ENPOINT_COUNT),
97
+ modulesCount(0 ), rootNode(NULL )
98
+ {
99
+ // Empty
100
+ }
101
+
99
102
#endif
100
103
101
104
#endif /* if defined(USBCON) */
0 commit comments