mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-17 11:54:33 +01:00
Merge remote-tracking branch 'nico/plugfix3'
This commit is contained in:
commit
3390a10921
@ -38,11 +38,11 @@ int PluggableUSB_::getInterface(uint8_t* interfaceCount)
|
||||
return sent;
|
||||
}
|
||||
|
||||
int PluggableUSB_::getDescriptor(int8_t type)
|
||||
int PluggableUSB_::getDescriptor(USBSetup& setup)
|
||||
{
|
||||
PUSBListNode* node;
|
||||
for (node = rootNode; node; node = node->next) {
|
||||
int ret = node->getDescriptor(type);
|
||||
int ret = node->getDescriptor(setup);
|
||||
// ret!=0 -> request has been processed
|
||||
if (ret)
|
||||
return ret;
|
||||
@ -50,11 +50,11 @@ int PluggableUSB_::getDescriptor(int8_t type)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool PluggableUSB_::setup(USBSetup& setup, uint8_t interfaceNum)
|
||||
bool PluggableUSB_::setup(USBSetup& setup)
|
||||
{
|
||||
PUSBListNode* node;
|
||||
for (node = rootNode; node; node = node->next) {
|
||||
if (node->setup(setup, interfaceNum)) {
|
||||
if (node->setup(setup)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -27,23 +27,20 @@
|
||||
|
||||
class PUSBListNode {
|
||||
public:
|
||||
PUSBListNode(int8_t numEps, int8_t numIfs, uint8_t *epType) :
|
||||
PUSBListNode(uint8_t numEps, uint8_t numIfs, uint8_t *epType) :
|
||||
numEndpoints(numEps), numInterfaces(numIfs), endpointType(epType)
|
||||
{ }
|
||||
|
||||
inline uint8_t interface() const { return pluggedInterface; }
|
||||
inline int8_t endpoint() const { return pluggedEndpoint; }
|
||||
|
||||
protected:
|
||||
virtual bool setup(USBSetup& setup, uint8_t interfaceNum) = 0;
|
||||
virtual bool setup(USBSetup& setup) = 0;
|
||||
virtual int getInterface(uint8_t* interfaceCount) = 0;
|
||||
virtual int getDescriptor(int8_t t) = 0;
|
||||
virtual int getDescriptor(USBSetup& setup) = 0;
|
||||
|
||||
uint8_t pluggedInterface;
|
||||
int8_t pluggedEndpoint;
|
||||
uint8_t pluggedEndpoint;
|
||||
|
||||
const int8_t numEndpoints;
|
||||
const int8_t numInterfaces;
|
||||
const uint8_t numEndpoints;
|
||||
const uint8_t numInterfaces;
|
||||
const uint8_t *endpointType;
|
||||
|
||||
PUSBListNode *next = NULL;
|
||||
@ -56,8 +53,8 @@ public:
|
||||
PluggableUSB_();
|
||||
bool plug(PUSBListNode *node);
|
||||
int getInterface(uint8_t* interfaceCount);
|
||||
int getDescriptor(int8_t type);
|
||||
bool setup(USBSetup& setup, uint8_t interfaceNum);
|
||||
int getDescriptor(USBSetup& setup);
|
||||
bool setup(USBSetup& setup);
|
||||
|
||||
private:
|
||||
uint8_t lastIf;
|
||||
|
@ -362,7 +362,7 @@ bool ClassInterfaceRequest(USBSetup& setup)
|
||||
return CDC_Setup(setup);
|
||||
|
||||
#ifdef PLUGGABLE_USB_ENABLED
|
||||
return PluggableUSB().setup(setup, i);
|
||||
return PluggableUSB().setup(setup);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
@ -476,7 +476,7 @@ bool SendDescriptor(USBSetup& setup)
|
||||
|
||||
InitControl(setup.wLength);
|
||||
#ifdef PLUGGABLE_USB_ENABLED
|
||||
ret = PluggableUSB().getDescriptor(t);
|
||||
ret = PluggableUSB().getDescriptor(setup);
|
||||
if (ret != 0) {
|
||||
return (ret > 0 ? true : false);
|
||||
}
|
||||
|
@ -31,29 +31,28 @@ int HID_::getInterface(uint8_t* interfaceCount)
|
||||
{
|
||||
*interfaceCount += 1; // uses 1
|
||||
HIDDescriptor hidInterface = {
|
||||
D_INTERFACE(interface(), 1, 3, 0, 0),
|
||||
D_INTERFACE(pluggedInterface, 1, 3, 0, 0),
|
||||
D_HIDREPORT(descriptorSize),
|
||||
D_ENDPOINT(USB_ENDPOINT_IN(endpoint()), USB_ENDPOINT_TYPE_INTERRUPT, USB_EP_SIZE, 0x01)
|
||||
D_ENDPOINT(USB_ENDPOINT_IN(pluggedEndpoint), USB_ENDPOINT_TYPE_INTERRUPT, USB_EP_SIZE, 0x01)
|
||||
};
|
||||
return USB_SendControl(0, &hidInterface, sizeof(hidInterface));
|
||||
}
|
||||
|
||||
int HID_::getDescriptor(int8_t type)
|
||||
int HID_::getDescriptor(USBSetup& setup)
|
||||
{
|
||||
if (HID_REPORT_DESCRIPTOR_TYPE == type) {
|
||||
int total = 0;
|
||||
HIDDescriptorListNode* node;
|
||||
for (node = rootNode; node; node = node->next) {
|
||||
int res = USB_SendControl(TRANSFER_PGM, node->data, node->length);
|
||||
if (res == -1)
|
||||
return -1;
|
||||
total += res;
|
||||
}
|
||||
return total;
|
||||
if (pluggedInterface != setup.wIndex) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Ignored
|
||||
return 0;
|
||||
int total = 0;
|
||||
HIDDescriptorListNode* node;
|
||||
for (node = rootNode; node; node = node->next) {
|
||||
int res = USB_SendControl(TRANSFER_PGM, node->data, node->length);
|
||||
if (res == -1)
|
||||
return -1;
|
||||
total += res;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
void HID_::AppendDescriptor(HIDDescriptorListNode *node)
|
||||
@ -72,13 +71,13 @@ void HID_::AppendDescriptor(HIDDescriptorListNode *node)
|
||||
|
||||
void HID_::SendReport(uint8_t id, const void* data, int len)
|
||||
{
|
||||
USB_Send(endpoint(), &id, 1);
|
||||
USB_Send(endpoint() | TRANSFER_RELEASE, data, len);
|
||||
USB_Send(pluggedEndpoint, &id, 1);
|
||||
USB_Send(pluggedEndpoint | TRANSFER_RELEASE, data, len);
|
||||
}
|
||||
|
||||
bool HID_::setup(USBSetup& setup, uint8_t interfaceNum)
|
||||
bool HID_::setup(USBSetup& setup)
|
||||
{
|
||||
if (interface() != interfaceNum) {
|
||||
if (pluggedInterface != setup.wIndex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -107,6 +106,9 @@ bool HID_::setup(USBSetup& setup, uint8_t interfaceNum)
|
||||
idle = setup.wValueL;
|
||||
return true;
|
||||
}
|
||||
if (request == HID_SET_REPORT)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -80,8 +80,8 @@ public:
|
||||
protected:
|
||||
// Implementation of the PUSBListNode
|
||||
int getInterface(uint8_t* interfaceCount);
|
||||
int getDescriptor(int8_t type);
|
||||
bool setup(USBSetup& setup, uint8_t interfaceNum);
|
||||
int getDescriptor(USBSetup& setup);
|
||||
bool setup(USBSetup& setup);
|
||||
|
||||
private:
|
||||
uint8_t epType[1];
|
||||
|
Loading…
x
Reference in New Issue
Block a user