Skip to content

[PluggableUSB] rename two class #3960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions hardware/arduino/avr/cores/arduino/PluggableUSB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ extern uint8_t _initEndpoints[];
int PluggableUSB_::getInterface(uint8_t* interfaceCount)
{
int sent = 0;
PUSBListNode* node;
PluggableUSBModule* node;
for (node = rootNode; node; node = node->next) {
int res = node->getInterface(interfaceCount);
if (res < 0)
Expand All @@ -40,7 +40,7 @@ int PluggableUSB_::getInterface(uint8_t* interfaceCount)

int PluggableUSB_::getDescriptor(USBSetup& setup)
{
PUSBListNode* node;
PluggableUSBModule* node;
for (node = rootNode; node; node = node->next) {
int ret = node->getDescriptor(setup);
// ret!=0 -> request has been processed
Expand All @@ -52,7 +52,7 @@ int PluggableUSB_::getDescriptor(USBSetup& setup)

bool PluggableUSB_::setup(USBSetup& setup)
{
PUSBListNode* node;
PluggableUSBModule* node;
for (node = rootNode; node; node = node->next) {
if (node->setup(setup)) {
return true;
Expand All @@ -61,7 +61,7 @@ bool PluggableUSB_::setup(USBSetup& setup)
return false;
}

bool PluggableUSB_::plug(PUSBListNode *node)
bool PluggableUSB_::plug(PluggableUSBModule *node)
{
if ((lastEp + node->numEndpoints) > USB_ENDPOINTS) {
return false;
Expand All @@ -70,7 +70,7 @@ bool PluggableUSB_::plug(PUSBListNode *node)
if (!rootNode) {
rootNode = node;
} else {
PUSBListNode *current = rootNode;
PluggableUSBModule *current = rootNode;
while (current->next) {
current = current->next;
}
Expand Down
10 changes: 5 additions & 5 deletions hardware/arduino/avr/cores/arduino/PluggableUSB.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

#if defined(USBCON)

class PUSBListNode {
class PluggableUSBModule {
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)
{ }

Expand All @@ -43,23 +43,23 @@ class PUSBListNode {
const uint8_t numInterfaces;
const uint8_t *endpointType;

PUSBListNode *next = NULL;
PluggableUSBModule *next = NULL;

friend class PluggableUSB_;
};

class PluggableUSB_ {
public:
PluggableUSB_();
bool plug(PUSBListNode *node);
bool plug(PluggableUSBModule *node);
int getInterface(uint8_t* interfaceCount);
int getDescriptor(USBSetup& setup);
bool setup(USBSetup& setup);

private:
uint8_t lastIf;
uint8_t lastEp;
PUSBListNode* rootNode;
PluggableUSBModule* rootNode;
};

// Replacement for global singleton.
Expand Down
8 changes: 4 additions & 4 deletions hardware/arduino/avr/libraries/HID/HID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int HID_::getDescriptor(USBSetup& setup)
if (setup.wIndex != pluggedInterface) { return 0; }

int total = 0;
HIDDescriptorListNode* node;
HIDSubDescriptor* node;
for (node = rootNode; node; node = node->next) {
int res = USB_SendControl(TRANSFER_PGM, node->data, node->length);
if (res == -1)
Expand All @@ -57,12 +57,12 @@ int HID_::getDescriptor(USBSetup& setup)
return total;
}

void HID_::AppendDescriptor(HIDDescriptorListNode *node)
void HID_::AppendDescriptor(HIDSubDescriptor *node)
{
if (!rootNode) {
rootNode = node;
} else {
HIDDescriptorListNode *current = rootNode;
HIDSubDescriptor *current = rootNode;
while (current->next) {
current = current->next;
}
Expand Down Expand Up @@ -128,7 +128,7 @@ bool HID_::setup(USBSetup& setup)
return false;
}

HID_::HID_(void) : PUSBListNode(1, 1, epType),
HID_::HID_(void) : PluggableUSBModule(1, 1, epType),
rootNode(NULL), descriptorSize(0),
protocol(1), idle(1)
{
Expand Down
14 changes: 7 additions & 7 deletions hardware/arduino/avr/libraries/HID/HID.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,33 +74,33 @@ typedef struct
EndpointDescriptor in;
} HIDDescriptor;

class HIDDescriptorListNode {
class HIDSubDescriptor {
public:
HIDDescriptorListNode *next = NULL;
HIDDescriptorListNode(const void *d, const uint16_t l) : data(d), length(l) { }
HIDSubDescriptor *next = NULL;
HIDSubDescriptor(const void *d, const uint16_t l) : data(d), length(l) { }

const void* data;
const uint16_t length;
};

class HID_ : public PUSBListNode
class HID_ : public PluggableUSBModule
{
public:
HID_(void);
int begin(void);
void SendReport(uint8_t id, const void* data, int len);
void AppendDescriptor(HIDDescriptorListNode* node);
void AppendDescriptor(HIDSubDescriptor* node);

protected:
// Implementation of the PUSBListNode
// Implementation of the PluggableUSBModule
int getInterface(uint8_t* interfaceCount);
int getDescriptor(USBSetup& setup);
bool setup(USBSetup& setup);

private:
uint8_t epType[1];

HIDDescriptorListNode* rootNode;
HIDSubDescriptor* rootNode;
uint16_t descriptorSize;

uint8_t protocol;
Expand Down
2 changes: 1 addition & 1 deletion libraries/Keyboard/src/Keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static const uint8_t _hidReportDescriptor[] PROGMEM = {

Keyboard_::Keyboard_(void)
{
static HIDDescriptorListNode node(_hidReportDescriptor, sizeof(_hidReportDescriptor));
static HIDSubDescriptor node(_hidReportDescriptor, sizeof(_hidReportDescriptor));
HID().AppendDescriptor(&node);
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/Mouse/src/Mouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static const uint8_t _hidReportDescriptor[] PROGMEM = {

Mouse_::Mouse_(void) : _buttons(0)
{
static HIDDescriptorListNode node(_hidReportDescriptor, sizeof(_hidReportDescriptor));
static HIDSubDescriptor node(_hidReportDescriptor, sizeof(_hidReportDescriptor));
HID().AppendDescriptor(&node);
}

Expand Down