[PUSB] No more static fields in PluggableUSB class
This commit is contained in:
parent
dbaec17c03
commit
c0f9296ae5
|
@ -25,21 +25,17 @@
|
||||||
|
|
||||||
#define MAX_MODULES 6
|
#define MAX_MODULES 6
|
||||||
|
|
||||||
static uint8_t lastIf = CDC_ACM_INTERFACE + CDC_INTERFACE_COUNT;
|
|
||||||
static uint8_t lastEp = CDC_FIRST_ENDPOINT + CDC_ENPOINT_COUNT;
|
|
||||||
|
|
||||||
extern uint8_t _initEndpoints[];
|
extern uint8_t _initEndpoints[];
|
||||||
|
|
||||||
//PUSBCallbacks cbs[MAX_MODULES];
|
//PUSBCallbacks cbs[MAX_MODULES];
|
||||||
static uint8_t modules_count = 0;
|
|
||||||
|
|
||||||
static PUSBListNode* rootNode = NULL;
|
PluggableUSB_ PluggableUSB;
|
||||||
|
|
||||||
int PluggableUSB_::getInterface(uint8_t* interfaceNum)
|
int PluggableUSB_::getInterface(uint8_t* interfaceNum)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
PUSBListNode* node = rootNode;
|
PUSBListNode* node = rootNode;
|
||||||
for (uint8_t i=0; i<modules_count; i++) {
|
for (uint8_t i=0; i<modulesCount; i++) {
|
||||||
ret = node->getInterface(interfaceNum);
|
ret = node->getInterface(interfaceNum);
|
||||||
node = node->next;
|
node = node->next;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +46,7 @@ int PluggableUSB_::getDescriptor(int8_t t)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
PUSBListNode* node = rootNode;
|
PUSBListNode* node = rootNode;
|
||||||
for (uint8_t i=0; i<modules_count && ret == 0; i++) {
|
for (uint8_t i=0; i<modulesCount && ret == 0; i++) {
|
||||||
ret = node->getDescriptor(t);
|
ret = node->getDescriptor(t);
|
||||||
node = node->next;
|
node = node->next;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +57,7 @@ bool PluggableUSB_::setup(USBSetup& setup, uint8_t j)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
PUSBListNode* node = rootNode;
|
PUSBListNode* node = rootNode;
|
||||||
for (uint8_t i=0; i<modules_count && ret == false; i++) {
|
for (uint8_t i=0; i<modulesCount && ret == false; i++) {
|
||||||
ret = node->setup(setup, j);
|
ret = node->setup(setup, j);
|
||||||
node = node->next;
|
node = node->next;
|
||||||
}
|
}
|
||||||
|
@ -70,11 +66,11 @@ bool PluggableUSB_::setup(USBSetup& setup, uint8_t j)
|
||||||
|
|
||||||
bool PluggableUSB_::plug(PUSBListNode *node)
|
bool PluggableUSB_::plug(PUSBListNode *node)
|
||||||
{
|
{
|
||||||
if (modules_count >= MAX_MODULES) {
|
if (modulesCount >= MAX_MODULES) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modules_count == 0) {
|
if (modulesCount == 0) {
|
||||||
rootNode = node;
|
rootNode = node;
|
||||||
} else {
|
} else {
|
||||||
PUSBListNode *current = rootNode;
|
PUSBListNode *current = rootNode;
|
||||||
|
@ -91,11 +87,18 @@ bool PluggableUSB_::plug(PUSBListNode *node)
|
||||||
_initEndpoints[lastEp] = node->endpointType[i];
|
_initEndpoints[lastEp] = node->endpointType[i];
|
||||||
lastEp++;
|
lastEp++;
|
||||||
}
|
}
|
||||||
modules_count++;
|
modulesCount++;
|
||||||
return true;
|
return true;
|
||||||
// restart USB layer???
|
// restart USB layer???
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PluggableUSB_::PluggableUSB_() : lastIf(CDC_ACM_INTERFACE + CDC_INTERFACE_COUNT),
|
||||||
|
lastEp(CDC_FIRST_ENDPOINT + CDC_ENPOINT_COUNT),
|
||||||
|
modulesCount(0), rootNode(NULL)
|
||||||
|
{
|
||||||
|
// Empty
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* if defined(USBCON) */
|
#endif /* if defined(USBCON) */
|
||||||
|
|
|
@ -54,10 +54,17 @@ public:
|
||||||
|
|
||||||
class PluggableUSB_ {
|
class PluggableUSB_ {
|
||||||
public:
|
public:
|
||||||
static bool plug(PUSBListNode *node);
|
PluggableUSB_();
|
||||||
static int getInterface(uint8_t* interfaceNum);
|
bool plug(PUSBListNode *node);
|
||||||
static int getDescriptor(int8_t t);
|
int getInterface(uint8_t* interfaceNum);
|
||||||
static bool setup(USBSetup& setup, uint8_t i);
|
int getDescriptor(int8_t t);
|
||||||
|
bool setup(USBSetup& setup, uint8_t i);
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint8_t lastIf;
|
||||||
|
uint8_t lastEp;
|
||||||
|
uint8_t modulesCount;
|
||||||
|
PUSBListNode* rootNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern PluggableUSB_ PluggableUSB;
|
extern PluggableUSB_ PluggableUSB;
|
||||||
|
|
Loading…
Reference in New Issue