Skip to content

Commit c07f988

Browse files
committed
[PUSB] Global functions PUSB_* are now methods of PluggableUSB class
1 parent 7302965 commit c07f988

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

cores/arduino/PluggableUSB.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static u8 modules_count = 0;
3535

3636
static PUSBListNode* rootNode = NULL;
3737

38-
int PUSB_GetInterface(u8* interfaceNum)
38+
int PluggableUSB_::getInterface(u8* interfaceNum)
3939
{
4040
int ret = 0;
4141
PUSBListNode* node = rootNode;
@@ -46,7 +46,7 @@ int PUSB_GetInterface(u8* interfaceNum)
4646
return ret;
4747
}
4848

49-
int PUSB_GetDescriptor(int8_t t)
49+
int PluggableUSB_::getDescriptor(int8_t t)
5050
{
5151
int ret = 0;
5252
PUSBListNode* node = rootNode;
@@ -57,7 +57,7 @@ int PUSB_GetDescriptor(int8_t t)
5757
return ret;
5858
}
5959

60-
bool PUSB_Setup(USBSetup& setup, u8 j)
60+
bool PluggableUSB_::setup(USBSetup& setup, u8 j)
6161
{
6262
bool ret = false;
6363
PUSBListNode* node = rootNode;
@@ -68,7 +68,7 @@ bool PUSB_Setup(USBSetup& setup, u8 j)
6868
return ret;
6969
}
7070

71-
int8_t PUSB_AddFunction(PUSBListNode *node, u8* interface)
71+
int8_t PluggableUSB_::addFunction(PUSBListNode *node, u8* interface)
7272
{
7373
if (modules_count >= MAX_MODULES) {
7474
return 0;

cores/arduino/PluggableUSB.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,15 @@ class PUSBListNode {
3939
PUSBListNode *next = NULL;
4040
};
4141

42-
int8_t PUSB_AddFunction(PUSBListNode *node, u8 *interface);
43-
44-
int PUSB_GetInterface(u8* interfaceNum);
45-
46-
int PUSB_GetDescriptor(int8_t t);
42+
class PluggableUSB_ {
43+
public:
44+
static int8_t addFunction(PUSBListNode *node, u8 *interface);
45+
static int getInterface(u8* interfaceNum);
46+
static int getDescriptor(int8_t t);
47+
static bool setup(USBSetup& setup, u8 i);
48+
};
4749

48-
bool PUSB_Setup(USBSetup& setup, u8 i);
50+
extern PluggableUSB_ PluggableUSB;
4951

5052
#endif
5153

cores/arduino/USBCore.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ bool ClassInterfaceRequest(USBSetup& setup)
367367
return CDC_Setup(setup);
368368

369369
#ifdef PLUGGABLE_USB_ENABLED
370-
return PUSB_Setup(setup, i);
370+
return PluggableUSB.setup(setup, i);
371371
#endif
372372
return false;
373373
}
@@ -445,7 +445,7 @@ static u8 SendInterfaces()
445445
CDC_GetInterface(&interfaces);
446446

447447
#ifdef PLUGGABLE_USB_ENABLED
448-
PUSB_GetInterface(&interfaces);
448+
PluggableUSB.getInterface(&interfaces);
449449
#endif
450450

451451
return interfaces;
@@ -481,7 +481,7 @@ bool SendDescriptor(USBSetup& setup)
481481

482482
InitControl(setup.wLength);
483483
#ifdef PLUGGABLE_USB_ENABLED
484-
ret = PUSB_GetDescriptor(t);
484+
ret = PluggableUSB.getDescriptor(t);
485485
if (ret != 0) {
486486
return (ret > 0 ? true : false);
487487
}

libraries/HID/HID.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ HID_::HID_(void)
143143
node.numInterfaces = 1,
144144
node.endpointType = endpointType,
145145

146-
HID_ENDPOINT_INT = PUSB_AddFunction(&node, &HID_INTERFACE);
146+
HID_ENDPOINT_INT = PluggableUSB.addFunction(&node, &HID_INTERFACE);
147147
}
148148

149149
int HID_::begin(void)

0 commit comments

Comments
 (0)