From 34a75d94163b385d20b37f5cffd2ffe241c6dd7d Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Tue, 29 Sep 2015 17:59:54 +0200 Subject: [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 --- cores/arduino/PluggableUSB.cpp | 11 ++++++----- cores/arduino/PluggableUSB.h | 11 ++++++++++- 2 files changed, 16 insertions(+), 6 deletions(-) (limited to 'cores') diff --git a/cores/arduino/PluggableUSB.cpp b/cores/arduino/PluggableUSB.cpp index 9dc334e..b27146b 100644 --- a/cores/arduino/PluggableUSB.cpp +++ b/cores/arduino/PluggableUSB.cpp @@ -68,10 +68,10 @@ bool PluggableUSB_::setup(USBSetup& setup, u8 j) return ret; } -int8_t PluggableUSB_::addFunction(PUSBListNode *node, u8* interface) +bool PluggableUSB_::plug(PUSBListNode *node) { if (modules_count >= MAX_MODULES) { - return 0; + return false; } if (modules_count == 0) { @@ -84,14 +84,15 @@ int8_t PluggableUSB_::addFunction(PUSBListNode *node, u8* interface) current->next = node; } - *interface = lastIf; + node->pluggedInterface = lastIf; + node->pluggedEndpoint = lastEp; lastIf += node->numInterfaces; - for ( u8 i = 0; i< node->numEndpoints; i++) { + for (uint8_t i=0; inumEndpoints; i++) { _initEndpoints[lastEp] = node->endpointType[i]; lastEp++; } modules_count++; - return lastEp - node->numEndpoints; + return true; // restart USB layer??? } diff --git a/cores/arduino/PluggableUSB.h b/cores/arduino/PluggableUSB.h index dcd9e25..275a444 100644 --- a/cores/arduino/PluggableUSB.h +++ b/cores/arduino/PluggableUSB.h @@ -35,13 +35,22 @@ public: int8_t numInterfaces; uint8_t *endpointType; + inline uint8_t interface() const { return pluggedInterface; } + inline int8_t endpoint() const { return pluggedEndpoint; } + +protected: + uint8_t pluggedInterface; + int8_t pluggedEndpoint; + public: PUSBListNode *next = NULL; + + friend class PluggableUSB_; }; class PluggableUSB_ { public: - static int8_t addFunction(PUSBListNode *node, u8 *interface); + static bool plug(PUSBListNode *node); static int getInterface(u8* interfaceNum); static int getDescriptor(int8_t t); static bool setup(USBSetup& setup, u8 i); -- cgit v1.2.3-18-g5258