usb device

Committer:
ppo
Date:
Sat May 14 17:24:10 2022 +0000
Revision:
0:c1e89c49eae5
commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ppo 0:c1e89c49eae5 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
ppo 0:c1e89c49eae5 2 *
ppo 0:c1e89c49eae5 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
ppo 0:c1e89c49eae5 4 * and associated documentation files (the "Software"), to deal in the Software without
ppo 0:c1e89c49eae5 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
ppo 0:c1e89c49eae5 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
ppo 0:c1e89c49eae5 7 * Software is furnished to do so, subject to the following conditions:
ppo 0:c1e89c49eae5 8 *
ppo 0:c1e89c49eae5 9 * The above copyright notice and this permission notice shall be included in all copies or
ppo 0:c1e89c49eae5 10 * substantial portions of the Software.
ppo 0:c1e89c49eae5 11 *
ppo 0:c1e89c49eae5 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
ppo 0:c1e89c49eae5 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
ppo 0:c1e89c49eae5 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
ppo 0:c1e89c49eae5 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
ppo 0:c1e89c49eae5 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
ppo 0:c1e89c49eae5 17 */
ppo 0:c1e89c49eae5 18
ppo 0:c1e89c49eae5 19 /* Standard descriptor types */
ppo 0:c1e89c49eae5 20 #define DEVICE_DESCRIPTOR (1)
ppo 0:c1e89c49eae5 21 #define CONFIGURATION_DESCRIPTOR (2)
ppo 0:c1e89c49eae5 22 #define STRING_DESCRIPTOR (3)
ppo 0:c1e89c49eae5 23 #define INTERFACE_DESCRIPTOR (4)
ppo 0:c1e89c49eae5 24 #define ENDPOINT_DESCRIPTOR (5)
ppo 0:c1e89c49eae5 25 #define QUALIFIER_DESCRIPTOR (6)
ppo 0:c1e89c49eae5 26
ppo 0:c1e89c49eae5 27 /* Standard descriptor lengths */
ppo 0:c1e89c49eae5 28 #define DEVICE_DESCRIPTOR_LENGTH (0x12)
ppo 0:c1e89c49eae5 29 #define CONFIGURATION_DESCRIPTOR_LENGTH (0x09)
ppo 0:c1e89c49eae5 30 #define INTERFACE_DESCRIPTOR_LENGTH (0x09)
ppo 0:c1e89c49eae5 31 #define ENDPOINT_DESCRIPTOR_LENGTH (0x07)
ppo 0:c1e89c49eae5 32
ppo 0:c1e89c49eae5 33
ppo 0:c1e89c49eae5 34 /*string offset*/
ppo 0:c1e89c49eae5 35 #define STRING_OFFSET_LANGID (0)
ppo 0:c1e89c49eae5 36 #define STRING_OFFSET_IMANUFACTURER (1)
ppo 0:c1e89c49eae5 37 #define STRING_OFFSET_IPRODUCT (2)
ppo 0:c1e89c49eae5 38 #define STRING_OFFSET_ISERIAL (3)
ppo 0:c1e89c49eae5 39 #define STRING_OFFSET_ICONFIGURATION (4)
ppo 0:c1e89c49eae5 40 #define STRING_OFFSET_IINTERFACE (5)
ppo 0:c1e89c49eae5 41
ppo 0:c1e89c49eae5 42 /* USB Specification Release Number */
ppo 0:c1e89c49eae5 43 #define USB_VERSION_2_0 (0x0200)
ppo 0:c1e89c49eae5 44
ppo 0:c1e89c49eae5 45 /* Least/Most significant byte of short integer */
ppo 0:c1e89c49eae5 46 #define LSB(n) ((n)&0xff)
ppo 0:c1e89c49eae5 47 #define MSB(n) (((n)&0xff00)>>8)
ppo 0:c1e89c49eae5 48
ppo 0:c1e89c49eae5 49 /* Convert physical endpoint number to descriptor endpoint number */
ppo 0:c1e89c49eae5 50 #define PHY_TO_DESC(endpoint) (((endpoint)>>1) | (((endpoint) & 1) ? 0x80:0))
ppo 0:c1e89c49eae5 51
ppo 0:c1e89c49eae5 52 /* bmAttributes in configuration descriptor */
ppo 0:c1e89c49eae5 53 /* C_RESERVED must always be set */
ppo 0:c1e89c49eae5 54 #define C_RESERVED (1U<<7)
ppo 0:c1e89c49eae5 55 #define C_SELF_POWERED (1U<<6)
ppo 0:c1e89c49eae5 56 #define C_REMOTE_WAKEUP (1U<<5)
ppo 0:c1e89c49eae5 57
ppo 0:c1e89c49eae5 58 /* bMaxPower in configuration descriptor */
ppo 0:c1e89c49eae5 59 #define C_POWER(mA) ((mA)/2)
ppo 0:c1e89c49eae5 60
ppo 0:c1e89c49eae5 61 /* bmAttributes in endpoint descriptor */
ppo 0:c1e89c49eae5 62 #define E_CONTROL (0x00)
ppo 0:c1e89c49eae5 63 #define E_ISOCHRONOUS (0x01)
ppo 0:c1e89c49eae5 64 #define E_BULK (0x02)
ppo 0:c1e89c49eae5 65 #define E_INTERRUPT (0x03)
ppo 0:c1e89c49eae5 66
ppo 0:c1e89c49eae5 67 /* For isochronous endpoints only: */
ppo 0:c1e89c49eae5 68 #define E_NO_SYNCHRONIZATION (0x00)
ppo 0:c1e89c49eae5 69 #define E_ASYNCHRONOUS (0x04)
ppo 0:c1e89c49eae5 70 #define E_ADAPTIVE (0x08)
ppo 0:c1e89c49eae5 71 #define E_SYNCHRONOUS (0x0C)
ppo 0:c1e89c49eae5 72 #define E_DATA (0x00)
ppo 0:c1e89c49eae5 73 #define E_FEEDBACK (0x10)
ppo 0:c1e89c49eae5 74 #define E_IMPLICIT_FEEDBACK (0x20)