Merge pull request #3960 from cmaglie/pusb-rename

[PluggableUSB] rename two class
This commit is contained in:
Martino Facchin 2015-10-12 12:25:56 +02:00
commit 865ac2f245
6 changed files with 23 additions and 23 deletions

View File

@ -28,7 +28,7 @@ extern uint8_t _initEndpoints[];
int PluggableUSB_::getInterface(uint8_t* interfaceCount) int PluggableUSB_::getInterface(uint8_t* interfaceCount)
{ {
int sent = 0; int sent = 0;
PUSBListNode* node; PluggableUSBModule* node;
for (node = rootNode; node; node = node->next) { for (node = rootNode; node; node = node->next) {
int res = node->getInterface(interfaceCount); int res = node->getInterface(interfaceCount);
if (res < 0) if (res < 0)
@ -40,7 +40,7 @@ int PluggableUSB_::getInterface(uint8_t* interfaceCount)
int PluggableUSB_::getDescriptor(USBSetup& setup) int PluggableUSB_::getDescriptor(USBSetup& setup)
{ {
PUSBListNode* node; PluggableUSBModule* node;
for (node = rootNode; node; node = node->next) { for (node = rootNode; node; node = node->next) {
int ret = node->getDescriptor(setup); int ret = node->getDescriptor(setup);
// ret!=0 -> request has been processed // ret!=0 -> request has been processed
@ -52,7 +52,7 @@ int PluggableUSB_::getDescriptor(USBSetup& setup)
bool PluggableUSB_::setup(USBSetup& setup) bool PluggableUSB_::setup(USBSetup& setup)
{ {
PUSBListNode* node; PluggableUSBModule* node;
for (node = rootNode; node; node = node->next) { for (node = rootNode; node; node = node->next) {
if (node->setup(setup)) { if (node->setup(setup)) {
return true; return true;
@ -61,7 +61,7 @@ bool PluggableUSB_::setup(USBSetup& setup)
return false; return false;
} }
bool PluggableUSB_::plug(PUSBListNode *node) bool PluggableUSB_::plug(PluggableUSBModule *node)
{ {
if ((lastEp + node->numEndpoints) > USB_ENDPOINTS) { if ((lastEp + node->numEndpoints) > USB_ENDPOINTS) {
return false; return false;
@ -70,7 +70,7 @@ bool PluggableUSB_::plug(PUSBListNode *node)
if (!rootNode) { if (!rootNode) {
rootNode = node; rootNode = node;
} else { } else {
PUSBListNode *current = rootNode; PluggableUSBModule *current = rootNode;
while (current->next) { while (current->next) {
current = current->next; current = current->next;
} }

View File

@ -25,9 +25,9 @@
#if defined(USBCON) #if defined(USBCON)
class PUSBListNode { class PluggableUSBModule {
public: public:
PUSBListNode(uint8_t numEps, uint8_t numIfs, uint8_t *epType) : PluggableUSBModule(uint8_t numEps, uint8_t numIfs, uint8_t *epType) :
numEndpoints(numEps), numInterfaces(numIfs), endpointType(epType) numEndpoints(numEps), numInterfaces(numIfs), endpointType(epType)
{ } { }
@ -43,7 +43,7 @@ protected:
const uint8_t numInterfaces; const uint8_t numInterfaces;
const uint8_t *endpointType; const uint8_t *endpointType;
PUSBListNode *next = NULL; PluggableUSBModule *next = NULL;
friend class PluggableUSB_; friend class PluggableUSB_;
}; };
@ -51,7 +51,7 @@ protected:
class PluggableUSB_ { class PluggableUSB_ {
public: public:
PluggableUSB_(); PluggableUSB_();
bool plug(PUSBListNode *node); bool plug(PluggableUSBModule *node);
int getInterface(uint8_t* interfaceCount); int getInterface(uint8_t* interfaceCount);
int getDescriptor(USBSetup& setup); int getDescriptor(USBSetup& setup);
bool setup(USBSetup& setup); bool setup(USBSetup& setup);
@ -59,7 +59,7 @@ public:
private: private:
uint8_t lastIf; uint8_t lastIf;
uint8_t lastEp; uint8_t lastEp;
PUSBListNode* rootNode; PluggableUSBModule* rootNode;
}; };
// Replacement for global singleton. // Replacement for global singleton.

View File

@ -47,7 +47,7 @@ int HID_::getDescriptor(USBSetup& setup)
if (setup.wIndex != pluggedInterface) { return 0; } if (setup.wIndex != pluggedInterface) { return 0; }
int total = 0; int total = 0;
HIDDescriptorListNode* node; HIDSubDescriptor* node;
for (node = rootNode; node; node = node->next) { for (node = rootNode; node; node = node->next) {
int res = USB_SendControl(TRANSFER_PGM, node->data, node->length); int res = USB_SendControl(TRANSFER_PGM, node->data, node->length);
if (res == -1) if (res == -1)
@ -57,12 +57,12 @@ int HID_::getDescriptor(USBSetup& setup)
return total; return total;
} }
void HID_::AppendDescriptor(HIDDescriptorListNode *node) void HID_::AppendDescriptor(HIDSubDescriptor *node)
{ {
if (!rootNode) { if (!rootNode) {
rootNode = node; rootNode = node;
} else { } else {
HIDDescriptorListNode *current = rootNode; HIDSubDescriptor *current = rootNode;
while (current->next) { while (current->next) {
current = current->next; current = current->next;
} }
@ -128,7 +128,7 @@ bool HID_::setup(USBSetup& setup)
return false; return false;
} }
HID_::HID_(void) : PUSBListNode(1, 1, epType), HID_::HID_(void) : PluggableUSBModule(1, 1, epType),
rootNode(NULL), descriptorSize(0), rootNode(NULL), descriptorSize(0),
protocol(1), idle(1) protocol(1), idle(1)
{ {

View File

@ -74,25 +74,25 @@ typedef struct
EndpointDescriptor in; EndpointDescriptor in;
} HIDDescriptor; } HIDDescriptor;
class HIDDescriptorListNode { class HIDSubDescriptor {
public: public:
HIDDescriptorListNode *next = NULL; HIDSubDescriptor *next = NULL;
HIDDescriptorListNode(const void *d, const uint16_t l) : data(d), length(l) { } HIDSubDescriptor(const void *d, const uint16_t l) : data(d), length(l) { }
const void* data; const void* data;
const uint16_t length; const uint16_t length;
}; };
class HID_ : public PUSBListNode class HID_ : public PluggableUSBModule
{ {
public: public:
HID_(void); HID_(void);
int begin(void); int begin(void);
void SendReport(uint8_t id, const void* data, int len); void SendReport(uint8_t id, const void* data, int len);
void AppendDescriptor(HIDDescriptorListNode* node); void AppendDescriptor(HIDSubDescriptor* node);
protected: protected:
// Implementation of the PUSBListNode // Implementation of the PluggableUSBModule
int getInterface(uint8_t* interfaceCount); int getInterface(uint8_t* interfaceCount);
int getDescriptor(USBSetup& setup); int getDescriptor(USBSetup& setup);
bool setup(USBSetup& setup); bool setup(USBSetup& setup);
@ -100,7 +100,7 @@ protected:
private: private:
uint8_t epType[1]; uint8_t epType[1];
HIDDescriptorListNode* rootNode; HIDSubDescriptor* rootNode;
uint16_t descriptorSize; uint16_t descriptorSize;
uint8_t protocol; uint8_t protocol;

View File

@ -62,7 +62,7 @@ static const uint8_t _hidReportDescriptor[] PROGMEM = {
Keyboard_::Keyboard_(void) Keyboard_::Keyboard_(void)
{ {
static HIDDescriptorListNode node(_hidReportDescriptor, sizeof(_hidReportDescriptor)); static HIDSubDescriptor node(_hidReportDescriptor, sizeof(_hidReportDescriptor));
HID().AppendDescriptor(&node); HID().AppendDescriptor(&node);
} }

View File

@ -62,7 +62,7 @@ static const uint8_t _hidReportDescriptor[] PROGMEM = {
Mouse_::Mouse_(void) : _buttons(0) Mouse_::Mouse_(void) : _buttons(0)
{ {
static HIDDescriptorListNode node(_hidReportDescriptor, sizeof(_hidReportDescriptor)); static HIDSubDescriptor node(_hidReportDescriptor, sizeof(_hidReportDescriptor));
HID().AppendDescriptor(&node); HID().AppendDescriptor(&node);
} }