works!

Dependencies:   mbed

Committer:
kchhouk
Date:
Fri Feb 21 21:03:41 2020 +0000
Revision:
2:5e5cdc3504fe
Parent:
1:6e512faaa17c
Added the functionality of scanf

Who changed what in which revision?

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