28
28
static u8 lastIf = CDC_ACM_INTERFACE + CDC_INTERFACE_COUNT;
29
29
static u8 lastEp = CDC_FIRST_ENDPOINT + CDC_ENPOINT_COUNT;
30
30
31
- class PUSBListNode {
32
- public:
33
- PUSBListNode *next = NULL ;
34
- PUSBCallbacks cb;
35
- };
36
-
37
31
extern u8 _initEndpoints[];
38
32
39
33
// PUSBCallbacks cbs[MAX_MODULES];
@@ -47,7 +41,7 @@ int8_t PUSB_GetInterface(u8* interfaceNum)
47
41
int8_t ret = 0 ;
48
42
PUSBListNode* node = rootNode;
49
43
for (u8 i=0 ; i<modules_count; i++) {
50
- ret = node->cb . getInterface (interfaceNum);
44
+ ret = node->cb -> getInterface (interfaceNum);
51
45
node = node->next ;
52
46
}
53
47
return ret;
@@ -58,7 +52,7 @@ int8_t PUSB_GetDescriptor(int8_t t)
58
52
int8_t ret = 0 ;
59
53
PUSBListNode* node = rootNode;
60
54
for (u8 i=0 ; i<modules_count && ret == 0 ; i++) {
61
- ret = node->cb . getDescriptor (t);
55
+ ret = node->cb -> getDescriptor (t);
62
56
node = node->next ;
63
57
}
64
58
return ret;
@@ -69,24 +63,18 @@ bool PUSB_Setup(Setup& setup, u8 j)
69
63
bool ret = false ;
70
64
PUSBListNode* node = rootNode;
71
65
for (u8 i=0 ; i<modules_count && ret == false ; i++) {
72
- ret = node->cb . setup (setup, j);
66
+ ret = node->cb -> setup (setup, j);
73
67
node = node->next ;
74
68
}
75
69
return ret;
76
70
}
77
71
78
- int8_t PUSB_AddFunction (PUSBCallbacks *cb , u8 * interface)
72
+ int8_t PUSB_AddFunction (PUSBListNode *node , u8 * interface)
79
73
{
80
74
if (modules_count >= MAX_MODULES) {
81
75
return 0 ;
82
76
}
83
77
84
- PUSBListNode *node = new PUSBListNode;
85
-
86
- node->cb .setup = cb->setup ;
87
- node->cb .getInterface = cb->getInterface ;
88
- node->cb .getDescriptor = cb->getDescriptor ;
89
-
90
78
if (modules_count == 0 ) {
91
79
rootNode = node;
92
80
lastNode = node;
@@ -95,13 +83,13 @@ int8_t PUSB_AddFunction(PUSBCallbacks *cb, u8* interface)
95
83
}
96
84
97
85
*interface = lastIf;
98
- lastIf += cb->numInterfaces ;
99
- for ( u8 i = 0 ; i< cb->numEndpoints ; i++) {
100
- _initEndpoints[lastEp] = cb->endpointType [i];
86
+ lastIf += node-> cb ->numInterfaces ;
87
+ for ( u8 i = 0 ; i< node-> cb ->numEndpoints ; i++) {
88
+ _initEndpoints[lastEp] = node-> cb ->endpointType [i];
101
89
lastEp++;
102
90
}
103
91
modules_count++;
104
- return lastEp - cb->numEndpoints ;
92
+ return lastEp - node-> cb ->numEndpoints ;
105
93
// restart USB layer???
106
94
}
107
95
0 commit comments