USB_HID_STACK/USBDescriptor.h@1:4d08e0ebf5dd, 2011-10-21 (annotated)
- Committer:
- chris
- Date:
- Fri Oct 21 23:02:16 2011 +0000
- Revision:
- 1:4d08e0ebf5dd
- Parent:
- 0:e98d1c2b16c6
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chris | 0:e98d1c2b16c6 | 1 | /* USBDescriptor.h */ |
chris | 0:e98d1c2b16c6 | 2 | /* Definitions and macros for constructing USB descriptors */ |
chris | 0:e98d1c2b16c6 | 3 | /* Copyright (c) 2011 ARM Limited. All rights reserved. */ |
chris | 0:e98d1c2b16c6 | 4 | |
chris | 0:e98d1c2b16c6 | 5 | /* Standard descriptor types */ |
chris | 0:e98d1c2b16c6 | 6 | #define DEVICE_DESCRIPTOR (1) |
chris | 0:e98d1c2b16c6 | 7 | #define CONFIGURATION_DESCRIPTOR (2) |
chris | 0:e98d1c2b16c6 | 8 | #define STRING_DESCRIPTOR (3) |
chris | 0:e98d1c2b16c6 | 9 | #define INTERFACE_DESCRIPTOR (4) |
chris | 0:e98d1c2b16c6 | 10 | #define ENDPOINT_DESCRIPTOR (5) |
chris | 0:e98d1c2b16c6 | 11 | |
chris | 0:e98d1c2b16c6 | 12 | /* Standard descriptor lengths */ |
chris | 0:e98d1c2b16c6 | 13 | #define DEVICE_DESCRIPTOR_LENGTH (0x12) |
chris | 0:e98d1c2b16c6 | 14 | #define CONFIGURATION_DESCRIPTOR_LENGTH (0x09) |
chris | 0:e98d1c2b16c6 | 15 | #define INTERFACE_DESCRIPTOR_LENGTH (0x09) |
chris | 0:e98d1c2b16c6 | 16 | #define ENDPOINT_DESCRIPTOR_LENGTH (0x07) |
chris | 0:e98d1c2b16c6 | 17 | |
chris | 0:e98d1c2b16c6 | 18 | |
chris | 0:e98d1c2b16c6 | 19 | /*string offset*/ |
chris | 0:e98d1c2b16c6 | 20 | #define STRING_OFFSET_LANGID (0) |
chris | 0:e98d1c2b16c6 | 21 | #define STRING_OFFSET_IMANUFACTURER (1) |
chris | 0:e98d1c2b16c6 | 22 | #define STRING_OFFSET_IPRODUCT (2) |
chris | 0:e98d1c2b16c6 | 23 | #define STRING_OFFSET_ISERIAL (3) |
chris | 0:e98d1c2b16c6 | 24 | #define STRING_OFFSET_ICONFIGURATION (4) |
chris | 0:e98d1c2b16c6 | 25 | #define STRING_OFFSET_IINTERFACE (5) |
chris | 0:e98d1c2b16c6 | 26 | |
chris | 0:e98d1c2b16c6 | 27 | /* USB Specification Release Number */ |
chris | 0:e98d1c2b16c6 | 28 | #define USB_VERSION_2_0 (0x0200) |
chris | 0:e98d1c2b16c6 | 29 | |
chris | 0:e98d1c2b16c6 | 30 | /* Least/Most significant byte of short integer */ |
chris | 0:e98d1c2b16c6 | 31 | #define LSB(n) ((n)&0xff) |
chris | 0:e98d1c2b16c6 | 32 | #define MSB(n) (((n)&0xff00)>>8) |
chris | 0:e98d1c2b16c6 | 33 | |
chris | 0:e98d1c2b16c6 | 34 | /* Convert physical endpoint number to descriptor endpoint number */ |
chris | 0:e98d1c2b16c6 | 35 | #define PHY_TO_DESC(endpoint) (((endpoint)>>1) | (((endpoint) & 1) ? 0x80:0)) |
chris | 0:e98d1c2b16c6 | 36 | |
chris | 0:e98d1c2b16c6 | 37 | /* bmAttributes in configuration descriptor */ |
chris | 0:e98d1c2b16c6 | 38 | /* C_RESERVED must always be set */ |
chris | 0:e98d1c2b16c6 | 39 | #define C_RESERVED (1U<<7) |
chris | 0:e98d1c2b16c6 | 40 | #define C_SELF_POWERED (1U<<6) |
chris | 0:e98d1c2b16c6 | 41 | #define C_REMOTE_WAKEUP (1U<<5) |
chris | 0:e98d1c2b16c6 | 42 | |
chris | 0:e98d1c2b16c6 | 43 | /* bMaxPower in configuration descriptor */ |
chris | 0:e98d1c2b16c6 | 44 | #define C_POWER(mA) ((mA)/2) |
chris | 0:e98d1c2b16c6 | 45 | |
chris | 0:e98d1c2b16c6 | 46 | /* bmAttributes in endpoint descriptor */ |
chris | 0:e98d1c2b16c6 | 47 | #define E_CONTROL (0x00) |
chris | 0:e98d1c2b16c6 | 48 | #define E_ISOCHRONOUS (0x01) |
chris | 0:e98d1c2b16c6 | 49 | #define E_BULK (0x02) |
chris | 0:e98d1c2b16c6 | 50 | #define E_INTERRUPT (0x03) |
chris | 0:e98d1c2b16c6 | 51 | |
chris | 0:e98d1c2b16c6 | 52 | /* For isochronous endpoints only: */ |
chris | 0:e98d1c2b16c6 | 53 | #define E_NO_SYNCHRONIZATION (0x00) |
chris | 0:e98d1c2b16c6 | 54 | #define E_ASYNCHRONOUS (0x04) |
chris | 0:e98d1c2b16c6 | 55 | #define E_ADAPTIVE (0x08) |
chris | 0:e98d1c2b16c6 | 56 | #define E_SYNCHRONOUS (0x0C) |
chris | 0:e98d1c2b16c6 | 57 | #define E_DATA (0x00) |
chris | 0:e98d1c2b16c6 | 58 | #define E_FEEDBACK (0x10) |
chris | 0:e98d1c2b16c6 | 59 | #define E_IMPLICIT_FEEDBACK (0x20) |