Skip to content

Commit a7e4882

Browse files
committed
[PUSB] Selected interface and endpoint are now part of PUSBListNode
The method int8_t PluggableUSB::addFunction(PUSBListNode *, uint8_t *) has been changed to bool PluggableUSB::plug(PUSBListNode *node) since both EP and Interfaces are now saved directly into node
1 parent c549366 commit a7e4882

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ bool PluggableUSB_::setup(USBSetup& setup, u8 j)
6868
return ret;
6969
}
7070

71-
int8_t PluggableUSB_::addFunction(PUSBListNode *node, u8* interface)
71+
bool PluggableUSB_::plug(PUSBListNode *node)
7272
{
7373
if (modules_count >= MAX_MODULES) {
74-
return 0;
74+
return false;
7575
}
7676

7777
if (modules_count == 0) {
@@ -84,14 +84,15 @@ int8_t PluggableUSB_::addFunction(PUSBListNode *node, u8* interface)
8484
current->next = node;
8585
}
8686

87-
*interface = lastIf;
87+
node->pluggedInterface = lastIf;
88+
node->pluggedEndpoint = lastEp;
8889
lastIf += node->numInterfaces;
89-
for ( u8 i = 0; i< node->numEndpoints; i++) {
90+
for (uint8_t i=0; i<node->numEndpoints; i++) {
9091
_initEndpoints[lastEp] = node->endpointType[i];
9192
lastEp++;
9293
}
9394
modules_count++;
94-
return lastEp - node->numEndpoints;
95+
return true;
9596
// restart USB layer???
9697
}
9798

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,22 @@ class PUSBListNode {
3535
int8_t numInterfaces;
3636
uint8_t *endpointType;
3737

38+
inline uint8_t interface() const { return pluggedInterface; }
39+
inline int8_t endpoint() const { return pluggedEndpoint; }
40+
41+
protected:
42+
uint8_t pluggedInterface;
43+
int8_t pluggedEndpoint;
44+
3845
public:
3946
PUSBListNode *next = NULL;
47+
48+
friend class PluggableUSB_;
4049
};
4150

4251
class PluggableUSB_ {
4352
public:
44-
static int8_t addFunction(PUSBListNode *node, u8 *interface);
53+
static bool plug(PUSBListNode *node);
4554
static int getInterface(u8* interfaceNum);
4655
static int getDescriptor(int8_t t);
4756
static bool setup(USBSetup& setup, u8 i);

0 commit comments

Comments
 (0)