Fork of the official USBDevice library

Fork of USBDevice by mbed official

Committer:
screamer
Date:
Fri Apr 28 17:01:10 2017 +0000
Branch:
device-files
Revision:
76:f0fd8d911b24
Parent:
73:8d28a0cb7b43
Changed the layout of USBDevice implementation for various targets to match mbed-os/targets. This also reduces the amount of files being compiled as USBDevice code for other targets is not compiled.

Who changed what in which revision?

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