Skip to content

Commit ccc0d3a

Browse files
committed
fix pluggableUSB linked list
1 parent 95b1550 commit ccc0d3a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ extern u8 _initEndpoints[];
3333
static u8 modules_count = 0;
3434

3535
static PUSBListNode* rootNode = NULL;
36-
static PUSBListNode* lastNode = NULL;
3736

3837
int PUSB_GetInterface(u8* interfaceNum)
3938
{
@@ -76,9 +75,12 @@ int8_t PUSB_AddFunction(PUSBListNode *node, u8* interface)
7675

7776
if (modules_count == 0) {
7877
rootNode = node;
79-
lastNode = node;
8078
} else {
81-
lastNode->next = node;
79+
PUSBListNode *current = rootNode;
80+
while(current->next != NULL) {
81+
current = current->next;
82+
}
83+
current->next = node;
8284
}
8385

8486
*interface = lastIf;

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

Lines changed: 1 addition & 1 deletion
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)