Skip to content

Commit b0bdb47

Browse files
facchinmcmaglie
authored andcommitted
fix pluggableUSB linked list
1 parent 862febf commit b0bdb47

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

cores/arduino/PluggableUSB.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ extern u8 _initEndpoints[];
3434
static u8 modules_count = 0;
3535

3636
static PUSBListNode* rootNode = NULL;
37-
static PUSBListNode* lastNode = NULL;
3837

3938
int PUSB_GetInterface(u8* interfaceNum)
4039
{
@@ -77,9 +76,12 @@ int8_t PUSB_AddFunction(PUSBListNode *node, u8* interface)
7776

7877
if (modules_count == 0) {
7978
rootNode = node;
80-
lastNode = node;
8179
} else {
82-
lastNode->next = node;
80+
PUSBListNode *current = rootNode;
81+
while(current->next != NULL) {
82+
current = current->next;
83+
}
84+
current->next = node;
8385
}
8486

8587
*interface = lastIf;

cores/arduino/PluggableUSB.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
#if defined(USBCON)
2727

28-
typedef struct
28+
typedef struct __attribute__((packed))
2929
{
3030
bool (*setup)(USBSetup& setup, u8 i);
3131
int (*getInterface)(u8* interfaceNum);

0 commit comments

Comments
 (0)