USBDevice for STM support

Dependents:   Nucleo_Usb_JoyMouse Nucleo_usbmouse ELEC350_1-referral-2018-usb-hid USBJoystick_HelloWorld2_wip ... more

This library contains all mbed usb device library (mbed-os\features\unsupported\USBDevice).

Committer:
frq08711@LMECWL0871.LME.ST.COM
Date:
Thu Dec 15 17:40:59 2016 +0100
Revision:
1:2a3ae13b45ef
copy of git hub directory unsupported/USBDevice

Who changed what in which revision?

UserRevisionLine numberNew contents of line
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 2 *
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 4 * and associated documentation files (the "Software"), to deal in the Software without
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 7 * Software is furnished to do so, subject to the following conditions:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 8 *
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 9 * The above copyright notice and this permission notice shall be included in all copies or
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 10 * substantial portions of the Software.
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 11 *
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 17 */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 18
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 19 #ifndef USBDEVICE_TYPES_H
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 20 #define USBDEVICE_TYPES_H
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 21
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 22 /* Standard requests */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 23 #define GET_STATUS (0)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 24 #define CLEAR_FEATURE (1)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 25 #define SET_FEATURE (3)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 26 #define SET_ADDRESS (5)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 27 #define GET_DESCRIPTOR (6)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 28 #define SET_DESCRIPTOR (7)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 29 #define GET_CONFIGURATION (8)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 30 #define SET_CONFIGURATION (9)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 31 #define GET_INTERFACE (10)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 32 #define SET_INTERFACE (11)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 33
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 34 /* bmRequestType.dataTransferDirection */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 35 #define HOST_TO_DEVICE (0)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 36 #define DEVICE_TO_HOST (1)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 37
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 38 /* bmRequestType.Type*/
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 39 #define STANDARD_TYPE (0)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 40 #define CLASS_TYPE (1)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 41 #define VENDOR_TYPE (2)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 42 #define RESERVED_TYPE (3)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 43
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 44 /* bmRequestType.Recipient */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 45 #define DEVICE_RECIPIENT (0)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 46 #define INTERFACE_RECIPIENT (1)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 47 #define ENDPOINT_RECIPIENT (2)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 48 #define OTHER_RECIPIENT (3)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 49
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 50 /* Descriptors */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 51 #define DESCRIPTOR_TYPE(wValue) (wValue >> 8)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 52 #define DESCRIPTOR_INDEX(wValue) (wValue & 0xff)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 53
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 54 typedef struct {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 55 struct {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 56 uint8_t dataTransferDirection;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 57 uint8_t Type;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 58 uint8_t Recipient;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 59 } bmRequestType;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 60 uint8_t bRequest;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 61 uint16_t wValue;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 62 uint16_t wIndex;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 63 uint16_t wLength;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 64 } SETUP_PACKET;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 65
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 66 typedef struct {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 67 SETUP_PACKET setup;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 68 uint8_t *ptr;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 69 uint32_t remaining;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 70 uint8_t direction;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 71 bool zlp;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 72 bool notify;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 73 } CONTROL_TRANSFER;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 74
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 75 typedef enum {ATTACHED, POWERED, DEFAULT, ADDRESS, CONFIGURED} DEVICE_STATE;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 76
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 77 typedef struct {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 78 volatile DEVICE_STATE state;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 79 uint8_t configuration;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 80 bool suspended;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 81 } USB_DEVICE;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 82
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 83 #endif