mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-18 07:52:14 +01:00
SAM: add iSerial USB field
This commit is contained in:
parent
b945df9220
commit
775c82bbed
@ -52,6 +52,15 @@ int PluggableUSB_::getDescriptor(USBSetup& setup)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PluggableUSB_::getShortName(char *iSerialNum)
|
||||
{
|
||||
PluggableUSBModule* node;
|
||||
for (node = rootNode; node; node = node->next) {
|
||||
iSerialNum += node->getShortName(iSerialNum);
|
||||
}
|
||||
*iSerialNum = 0;
|
||||
}
|
||||
|
||||
bool PluggableUSB_::setup(USBSetup& setup)
|
||||
{
|
||||
PluggableUSBModule* node;
|
||||
|
@ -35,6 +35,7 @@ protected:
|
||||
virtual bool setup(USBSetup& setup) = 0;
|
||||
virtual int getInterface(uint8_t* interfaceCount) = 0;
|
||||
virtual int getDescriptor(USBSetup& setup) = 0;
|
||||
virtual uint8_t getShortName(char *name) { name[0] = 'A'+pluggedInterface; return 1; }
|
||||
|
||||
uint8_t pluggedInterface;
|
||||
uint8_t pluggedEndpoint;
|
||||
@ -55,6 +56,7 @@ public:
|
||||
int getInterface(uint8_t* interfaceCount);
|
||||
int getDescriptor(USBSetup& setup);
|
||||
bool setup(USBSetup& setup);
|
||||
void getShortName(char *iSerialNum);
|
||||
|
||||
private:
|
||||
uint8_t lastIf;
|
||||
|
@ -96,10 +96,10 @@ const uint8_t STRING_MANUFACTURER[12] = USB_MANUFACTURER;
|
||||
|
||||
// DEVICE DESCRIPTOR
|
||||
const DeviceDescriptor USB_DeviceDescriptor =
|
||||
D_DEVICE(0x00,0x00,0x00,64,USB_VID,USB_PID,0x100,IMANUFACTURER,IPRODUCT,0,1);
|
||||
D_DEVICE(0x00,0x00,0x00,64,USB_VID,USB_PID,0x100,IMANUFACTURER,IPRODUCT,ISERIAL,1);
|
||||
|
||||
const DeviceDescriptor USB_DeviceDescriptorA =
|
||||
D_DEVICE(0xEF,0x02,0x01,64,USB_VID,USB_PID,0x100,IMANUFACTURER,IPRODUCT,0,1);
|
||||
D_DEVICE(0xEF,0x02,0x01,64,USB_VID,USB_PID,0x100,IMANUFACTURER,IPRODUCT,ISERIAL,1);
|
||||
|
||||
const QualifierDescriptor USB_DeviceQualifier =
|
||||
D_QUALIFIER(0x00,0x00,0x00,64,1);
|
||||
@ -429,6 +429,13 @@ static bool USBD_SendDescriptor(USBSetup& setup)
|
||||
else if (setup.wValueL == IMANUFACTURER) {
|
||||
return USB_SendStringDescriptor(STRING_MANUFACTURER, setup.wLength);
|
||||
}
|
||||
else if (setup.wValueL == ISERIAL) {
|
||||
#ifdef PLUGGABLE_USB_ENABLED
|
||||
char name[ISERIAL_MAX_LEN];
|
||||
PluggableUSB().getShortName(name);
|
||||
return USB_SendStringDescriptor((uint8_t*)name, setup.wLength);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
@ -42,7 +42,10 @@
|
||||
#define CDC_TX CDC_ENDPOINT_IN
|
||||
#endif
|
||||
|
||||
#define ISERIAL_MAX_LEN 20
|
||||
|
||||
#define IMANUFACTURER 1
|
||||
#define IPRODUCT 2
|
||||
#define ISERIAL 3
|
||||
|
||||
#endif /* __USBDESC_H__ */
|
||||
|
@ -57,6 +57,16 @@ int HID_::getDescriptor(USBSetup& setup)
|
||||
return total;
|
||||
}
|
||||
|
||||
uint8_t HID_::getShortName(char *name)
|
||||
{
|
||||
name[0] = 'H';
|
||||
name[1] = 'I';
|
||||
name[2] = 'D';
|
||||
name[3] = 'A' + (descriptorSize & 0x0F);
|
||||
name[4] = 'A' + ((descriptorSize >> 4) & 0x0F);
|
||||
return 5;
|
||||
}
|
||||
|
||||
void HID_::AppendDescriptor(HIDSubDescriptor *node)
|
||||
{
|
||||
if (!rootNode) {
|
||||
|
@ -96,6 +96,7 @@ protected:
|
||||
int getInterface(uint8_t* interfaceCount);
|
||||
int getDescriptor(USBSetup& setup);
|
||||
bool setup(USBSetup& setup);
|
||||
uint8_t getShortName(char* name);
|
||||
|
||||
private:
|
||||
uint32_t epType[1];
|
||||
|
Loading…
x
Reference in New Issue
Block a user