A copy of the mbed USBDevice with USBSerial library

Dependents:   STM32L0_LoRa Smartage STM32L0_LoRa Turtle_RadioShuttle

Committer:
Helmut Tschemernjak
Date:
Sun Feb 24 14:52:33 2019 +0100
Revision:
8:961423d1da74
Parent:
0:a3ea811f80f2
Added sleep manager support to avoids sleeps while a USB CDC
connection is active

Who changed what in which revision?

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