MG32F10x Standard Peripherals Firmware Library

usb_def.h
浏览该文件的文档.
1
17 /* Define to prevent recursive inclusion -------------------------------------*/
18 #ifndef __USB_DEF_H
19 #define __USB_DEF_H
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
25 /* Includes ------------------------------------------------------------------*/
26 #include "mg32f10x.h"
27
28 /* Exported types ------------------------------------------------------------*/
29
30 /* ======================================== Start of section using anonymous unions ======================================== */
31 #if defined (__CC_ARM)
32 #pragma push
33 #pragma anon_unions
34 #elif defined (__ICCARM__)
35 #pragma language=extended
36 #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
37 #pragma clang diagnostic push
38 #pragma clang diagnostic ignored "-Wc11-extensions"
39 #pragma clang diagnostic ignored "-Wreserved-id-macro"
40 #elif defined (__GNUC__)
41 /* anonymous unions are enabled by default */
42 #elif defined (__TMS470__)
43 /* anonymous unions are enabled by default */
44 #elif defined (__TASKING__)
45 #pragma warning 586
46 #elif defined (__CSMC__)
47 /* anonymous unions are enabled by default */
48 #else
49 #warning Not supported compiler type
50 #endif
51
53 typedef __PACKED_STRUCT _USB_SETUP_PACKET {
54 uint8_t bmRequestType; /* bmRequestType */
55 uint8_t bRequest; /* bRequest */
56 __PACKED_UNION {
57 uint16_t wValue; /* wValue */
58 __PACKED_STRUCT {
59 uint8_t wValueL;
60 uint8_t wValueH;
61 };
62 };
63 __PACKED_UNION {
64 uint16_t wIndex; /* wIndex */
65 __PACKED_STRUCT {
66 uint8_t wIndexL;
67 uint8_t wIndexH;
68 };
69 };
70 uint16_t wLength; /* wLength */
71 } USB_SETUP_PACKET;
72
73
74 /* ========================================= End of section using anonymous unions ========================================= */
75 #if defined (__CC_ARM)
76 #pragma pop
77 #elif defined (__ICCARM__)
78 /* leave anonymous unions enabled */
79 #elif (__ARMCC_VERSION >= 6010050)
80 #pragma clang diagnostic pop
81 #elif defined (__GNUC__)
82 /* anonymous unions are enabled by default */
83 #elif defined (__TMS470__)
84 /* anonymous unions are enabled by default */
85 #elif defined (__TASKING__)
86 #pragma warning restore
87 #elif defined (__CSMC__)
88 /* anonymous unions are enabled by default */
89 #else
90 #warning Not supported compiler type
91 #endif
92
93 /* Exported constants --------------------------------------------------------*/
94 /* bmRequestType.Direction */
95 #define USB_REQUEST_DIRECTION_HOST_TO_DEVICE 0x00U
96 #define USB_REQUEST_DIRECTION_DEVICE_TO_HOST 0x80U
97 #define USB_REQUEST_DIRECTION_Msk 0x80U
98
99 /* bmRequestType.Type */
100 #define USB_REQUEST_TYPE_STANDARD 0x00U
101 #define USB_REQUEST_TYPE_CLASS 0x20U
102 #define USB_REQUEST_TYPE_VENDOR 0x40U
103 #define USB_REQUEST_TYPE_Msk 0x60U
104
105 /* bmRequestType.Recipient */
106 #define USB_REQUEST_RECIPIENT_DEVICE 0x00U
107 #define USB_REQUEST_RECIPIENT_INTERFACE 0x01U
108 #define USB_REQUEST_RECIPIENT_ENDPOINT 0x02U
109 #define USB_REQUEST_RECIPIENT_Msk 0x1FU
110
111 /* USB Standard Request Codes */
112 #define USB_REQUEST_GET_STATUS 0x00U
113 #define USB_REQUEST_CLEAR_FEATURE 0x01U
114 #define USB_REQUEST_SET_FEATURE 0x03U
115 #define USB_REQUEST_SET_ADDRESS 0x05U
116 #define USB_REQUEST_GET_DESCRIPTOR 0x06U
117 #define USB_REQUEST_SET_DESCRIPTOR 0x07U
118 #define USB_REQUEST_GET_CONFIGURATION 0x08U
119 #define USB_REQUEST_SET_CONFIGURATION 0x09U
120 #define USB_REQUEST_GET_INTERFACE 0x0AU
121 #define USB_REQUEST_SET_INTERFACE 0x0BU
122 #define USB_REQUEST_SYNCH_FRAME 0x0CU
123
124 /* USB Standard Feature selectors */
125 #define USB_FEATURE_ENDPOINT_STALL 0U
126 #define USB_FEATURE_REMOTE_WAKEUP 1U
127
128 /* USB Descriptor Types */
129 #define USB_DESC_TYPE_DEVICE 1U
130 #define USB_DESC_TYPE_CONFIGURATION 2U
131 #define USB_DESC_TYPE_STRING 3U
132 #define USB_DESC_TYPE_INTERFACE 4U
133 #define USB_DESC_TYPE_ENDPOINT 5U
134 #define USB_DESC_TYPE_DEVICE_QUALIFIER 6U
135 #define USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION 7U
136 #define USB_DESC_TYPE_INTERFACE_POWER 8U
137
138
139 /* bmAttributes in Configuration Descriptor */
140 #define USB_CONFIG_POWERED_MASK 0x40U
141 #define USB_CONFIG_BUS_POWERED 0x80U
142 #define USB_CONFIG_SELF_POWERED 0xC0U
143 #define USB_CONFIG_REMOTE_WAKEUP 0x20U
144
145 /* bMaxPower in Configuration Descriptor */
146 #define USB_CONFIG_POWER_MA(mA) ((mA)/2)
147
148 /* bEndpointAddress in Endpoint Descriptor */
149 #define USB_ENDPOINT_DIRECTION_MASK 0x80U
150 #define USB_ENDPOINT_OUT(addr) (addr)
151 #define USB_ENDPOINT_IN(addr) ((addr) | 0x80U)
152
153 /* bmAttributes in Endpoint Descriptor */
154 #define USB_ENDPOINT_TYPE_MASK 0x03U
155 #define USB_ENDPOINT_TYPE_CONTROL 0x00U
156 #define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01U
157 #define USB_ENDPOINT_TYPE_BULK 0x02U
158 #define USB_ENDPOINT_TYPE_INTERRUPT 0x03U
159 #define USB_ENDPOINT_SYNC_MASK 0x0CU
160 #define USB_ENDPOINT_SYNC_NO_SYNCHRONIZATION 0x00U
161 #define USB_ENDPOINT_SYNC_ASYNCHRONOUS 0x04U
162 #define USB_ENDPOINT_SYNC_ADAPTIVE 0x08U
163 #define USB_ENDPOINT_SYNC_SYNCHRONOUS 0x0CU
164 #define USB_ENDPOINT_USAGE_MASK 0x30U
165 #define USB_ENDPOINT_USAGE_DATA 0x00U
166 #define USB_ENDPOINT_USAGE_FEEDBACK 0x10U
167 #define USB_ENDPOINT_USAGE_IMPLICIT_FEEDBACK 0x20U
168 #define USB_ENDPOINT_USAGE_RESERVED 0x30U
169
170 /* Device States */
171 #define USBD_STATE_DEFAULT 0
172 #define USBD_STATE_ADDRESSED 1
173 #define USBD_STATE_CONFIGURED 2
174 #define USBD_STATE_SUSPENDED 3
175
176 /* Exported macro ------------------------------------------------------------*/
177 /* Exported functions --------------------------------------------------------*/
178
179
180 #ifdef __cplusplus
181 }
182 #endif
183
184 #endif /* __USB_DEF_H */
_USB_SETUP_PACKET
__PACKED_STRUCT _USB_SETUP_PACKET
USB Default Control Pipe Setup Packet
Definition: usb_def.h:53