Skip to content

Commit 98f331b

Browse files
committed
Moved interface check to pluggable USB
1 parent 7fdb0ef commit 98f331b

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

Diff for: hardware/arduino/avr/cores/arduino/PluggableUSB.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,16 @@ int PluggableUSB_::getDescriptor(int8_t type)
5050
return 0;
5151
}
5252

53-
bool PluggableUSB_::setup(USBSetup& setup, uint8_t j)
53+
bool PluggableUSB_::setup(USBSetup& setup, uint8_t interfaceNum)
5454
{
5555
PUSBListNode* node;
5656
for (node = rootNode; node; node = node->next) {
57-
if (node->setup(setup, j)) {
57+
// Only execute the desired interface.
58+
// This also prevents calling interfaces with -1
59+
// When all endpoints are full.
60+
if(node->interface() == interfaceNum){
61+
// TODO return value currently ignored?
62+
node->setup(setup);
5863
return true;
5964
}
6065
}

Diff for: hardware/arduino/avr/cores/arduino/PluggableUSB.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class PUSBListNode {
3535
inline int8_t endpoint() const { return pluggedEndpoint; }
3636

3737
protected:
38-
virtual bool setup(USBSetup& setup, uint8_t i) = 0;
38+
virtual bool setup(USBSetup& setup) = 0;
3939
virtual int getInterface(uint8_t* interfaceNum) = 0;
4040
virtual int getDescriptor(int8_t t) = 0;
4141

@@ -56,8 +56,8 @@ class PluggableUSB_ {
5656
PluggableUSB_();
5757
bool plug(PUSBListNode *node);
5858
int getInterface(uint8_t* interfaceNum);
59-
int getDescriptor(int8_t t);
60-
bool setup(USBSetup& setup, uint8_t i);
59+
int getDescriptor(int8_t type);
60+
bool setup(USBSetup& setup, uint8_t interfaceNum);
6161

6262
private:
6363
uint8_t lastIf;

Diff for: hardware/arduino/avr/libraries/HID/HID.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,8 @@ void HID_::SendReport(uint8_t id, const void* data, int len)
7676
USB_Send(endpoint() | TRANSFER_RELEASE, data, len);
7777
}
7878

79-
bool HID_::setup(USBSetup& setup, uint8_t interfaceNum)
79+
bool HID_::setup(USBSetup& setup)
8080
{
81-
if (interface() != interfaceNum) {
82-
return false;
83-
}
84-
8581
uint8_t request = setup.bRequest;
8682
uint8_t requestType = setup.bmRequestType;
8783

Diff for: hardware/arduino/avr/libraries/HID/HID.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class HID_ : public PUSBListNode
8181
// Implementation of the PUSBListNode
8282
int getInterface(uint8_t* interfaceNum);
8383
int getDescriptor(int8_t type);
84-
bool setup(USBSetup& setup, uint8_t interfaceNum);
84+
bool setup(USBSetup& setup);
8585

8686
private:
8787
uint8_t epType[1];

0 commit comments

Comments
 (0)