Sensor reporting over USB CDC

Dependencies:   MAG3110 MMA8451Q SLCD- TSI USBDevice mbed

Committer:
wue
Date:
Wed Apr 16 12:20:12 2014 +0000
Revision:
0:7b58cdacf811
Sensor reporting over USB CDC

Who changed what in which revision?

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