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