1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-02-26 20:54:22 +01:00

[PUSB] Global functions PUSB_* are now methods of PluggableUSB class

This commit is contained in:
Cristian Maglie 2015-09-29 16:46:11 +02:00
parent 3fe6272feb
commit 5aeff8ec25
4 changed files with 16 additions and 14 deletions

View File

@ -35,7 +35,7 @@ static u8 modules_count = 0;
static PUSBListNode* rootNode = NULL; static PUSBListNode* rootNode = NULL;
int PUSB_GetInterface(u8* interfaceNum) int PluggableUSB_::getInterface(u8* interfaceNum)
{ {
int ret = 0; int ret = 0;
PUSBListNode* node = rootNode; PUSBListNode* node = rootNode;
@ -46,7 +46,7 @@ int PUSB_GetInterface(u8* interfaceNum)
return ret; return ret;
} }
int PUSB_GetDescriptor(int8_t t) int PluggableUSB_::getDescriptor(int8_t t)
{ {
int ret = 0; int ret = 0;
PUSBListNode* node = rootNode; PUSBListNode* node = rootNode;
@ -57,7 +57,7 @@ int PUSB_GetDescriptor(int8_t t)
return ret; return ret;
} }
bool PUSB_Setup(USBSetup& setup, u8 j) bool PluggableUSB_::setup(USBSetup& setup, u8 j)
{ {
bool ret = false; bool ret = false;
PUSBListNode* node = rootNode; PUSBListNode* node = rootNode;
@ -68,7 +68,7 @@ bool PUSB_Setup(USBSetup& setup, u8 j)
return ret; return ret;
} }
int8_t PUSB_AddFunction(PUSBListNode *node, u8* interface) int8_t PluggableUSB_::addFunction(PUSBListNode *node, u8* interface)
{ {
if (modules_count >= MAX_MODULES) { if (modules_count >= MAX_MODULES) {
return 0; return 0;

View File

@ -39,13 +39,15 @@ public:
PUSBListNode *next = NULL; PUSBListNode *next = NULL;
}; };
int8_t PUSB_AddFunction(PUSBListNode *node, u8 *interface); class PluggableUSB_ {
public:
static int8_t addFunction(PUSBListNode *node, u8 *interface);
static int getInterface(u8* interfaceNum);
static int getDescriptor(int8_t t);
static bool setup(USBSetup& setup, u8 i);
};
int PUSB_GetInterface(u8* interfaceNum); extern PluggableUSB_ PluggableUSB;
int PUSB_GetDescriptor(int8_t t);
bool PUSB_Setup(USBSetup& setup, u8 i);
#endif #endif

View File

@ -367,7 +367,7 @@ bool ClassInterfaceRequest(USBSetup& setup)
return CDC_Setup(setup); return CDC_Setup(setup);
#ifdef PLUGGABLE_USB_ENABLED #ifdef PLUGGABLE_USB_ENABLED
return PUSB_Setup(setup, i); return PluggableUSB.setup(setup, i);
#endif #endif
return false; return false;
} }
@ -445,7 +445,7 @@ static u8 SendInterfaces()
CDC_GetInterface(&interfaces); CDC_GetInterface(&interfaces);
#ifdef PLUGGABLE_USB_ENABLED #ifdef PLUGGABLE_USB_ENABLED
PUSB_GetInterface(&interfaces); PluggableUSB.getInterface(&interfaces);
#endif #endif
return interfaces; return interfaces;
@ -481,7 +481,7 @@ bool SendDescriptor(USBSetup& setup)
InitControl(setup.wLength); InitControl(setup.wLength);
#ifdef PLUGGABLE_USB_ENABLED #ifdef PLUGGABLE_USB_ENABLED
ret = PUSB_GetDescriptor(t); ret = PluggableUSB.getDescriptor(t);
if (ret != 0) { if (ret != 0) {
return (ret > 0 ? true : false); return (ret > 0 ? true : false);
} }

View File

@ -143,7 +143,7 @@ HID_::HID_(void)
node.numInterfaces = 1, node.numInterfaces = 1,
node.endpointType = endpointType, node.endpointType = endpointType,
HID_ENDPOINT_INT = PUSB_AddFunction(&node, &HID_INTERFACE); HID_ENDPOINT_INT = PluggableUSB.addFunction(&node, &HID_INTERFACE);
} }
int HID_::begin(void) int HID_::begin(void)