Select one of the symbols to view example projects that use it.
 
Outline
#define USBH_DEF_H
#include "usbh_conf.h"
#define NULL
#define FALSE
#define TRUE
#define USBH_DEV_RESET_TIMEOUT
#define ValBit
#define SetBit
#define ClrBit
#define MIN
#define MAX
#define LE16S
#define LE24S
#define LE32S
#define LE64S
#define USBH_MAX_DATA_BUFFER
#define USBH_MAX_EP_PACKET_SIZE
#define USB_LEN_DESC_HDR
#define USB_LEN_DEV_DESC
#define USB_LEN_CFG_DESC
#define USB_LEN_IF_DESC
#define USB_LEN_EP_DESC
#define USB_LEN_OTG_DESC
#define USB_LEN_SETUP_PKT
#define USB_REQ_DIR_MASK
#define USB_H2D
#define USB_D2H
#define USB_REQ_TYPE_STANDARD
#define USB_REQ_TYPE_CLASS
#define USB_REQ_TYPE_VENDOR
#define USB_REQ_TYPE_RESERVED
#define USB_REQ_RECIPIENT_DEVICE
#define USB_REQ_RECIPIENT_INTERFACE
#define USB_REQ_RECIPIENT_ENDPOINT
#define USB_REQ_RECIPIENT_OTHER
#define USB_REQ_GET_STATUS
#define USB_REQ_CLEAR_FEATURE
#define USB_REQ_SET_FEATURE
#define USB_REQ_SET_ADDRESS
#define USB_REQ_GET_DESCRIPTOR
#define USB_REQ_SET_DESCRIPTOR
#define USB_REQ_GET_CONFIGURATION
#define USB_REQ_SET_CONFIGURATION
#define USB_REQ_GET_INTERFACE
#define USB_REQ_SET_INTERFACE
#define USB_REQ_SYNCH_FRAME
#define USB_DESC_TYPE_DEVICE
#define USB_DESC_TYPE_CONFIGURATION
#define USB_DESC_TYPE_STRING
#define USB_DESC_TYPE_INTERFACE
#define USB_DESC_TYPE_ENDPOINT
#define USB_DESC_TYPE_DEVICE_QUALIFIER
#define USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION
#define USB_DESC_TYPE_INTERFACE_POWER
#define USB_DESC_TYPE_HID
#define USB_DESC_TYPE_HID_REPORT
#define USB_DEVICE_DESC_SIZE
#define USB_CONFIGURATION_DESC_SIZE
#define USB_HID_DESC_SIZE
#define USB_INTERFACE_DESC_SIZE
#define USB_ENDPOINT_DESC_SIZE
#define USB_DESC_DEVICE
#define USB_DESC_CONFIGURATION
#define USB_DESC_STRING
#define USB_DESC_INTERFACE
#define USB_DESC_ENDPOINT
#define USB_DESC_DEVICE_QUALIFIER
#define USB_DESC_OTHER_SPEED_CONFIGURATION
#define USB_DESC_INTERFACE_POWER
#define USB_DESC_HID_REPORT
#define USB_DESC_HID
#define USB_EP_TYPE_CTRL
#define USB_EP_TYPE_ISOC
#define USB_EP_TYPE_BULK
#define USB_EP_TYPE_INTR
#define USB_EP_DIR_OUT
#define USB_EP_DIR_IN
#define USB_EP_DIR_MSK
#define USBH_MAX_PIPES_NBR
#define USBH_DEVICE_ADDRESS_DEFAULT
#define USBH_DEVICE_ADDRESS
#define USBH_MAX_ERROR_COUNT
#define MSGQUEUE_OBJECTS
uint16_t_uint8_t
_USB_Setup
_DescHeader
_DeviceDescriptor
_EndpointDescriptor
_InterfaceDescriptor
_ConfigurationDescriptor
USBH_StatusTypeDef
USBH_SpeedTypeDef
HOST_StateTypeDef
ENUM_StateTypeDef
CTRL_StateTypeDef
CMD_StateTypeDef
USBH_URBStateTypeDef
USBH_OSEventTypeDef
USBH_CtrlTypeDef
USBH_DeviceTypeDef
_USBH_HandleTypeDef
USBH_ClassTypeDef
_USBH_HandleTypeDef
#define __weak
#define __packed
Files
loading...
CodeScopeSTM32 Libraries and SamplesSTM32_USB_Host_LibraryCore/Inc/usbh_def.h
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** ****************************************************************************** * @file usbh_def.h * @author MCD Application Team * @brief Definitions used in the USB host library ****************************************************************************** * @attention * * Copyright (c) 2015 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** *//* ... */ /* Define to prevent recursive ----------------------------------------------*/ #ifndef USBH_DEF_H #define USBH_DEF_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "usbh_conf.h" /** @addtogroup USBH_LIB * @{ *//* ... */ /** @addtogroup USBH_LIB_CORE * @{ *//* ... */ /** @defgroup USBH_DEF * @brief This file is includes USB descriptors * @{ *//* ... */ #ifndef NULL #define NULL 0U #endif #ifndef FALSE #define FALSE 0U #endif #ifndef TRUE #define TRUE 1U #endif #ifndef USBH_DEV_RESET_TIMEOUT #define USBH_DEV_RESET_TIMEOUT 1000U #endif #define ValBit(VAR,POS) (VAR & (1 << POS)) #define SetBit(VAR,POS) (VAR |= (1 << POS)) #define ClrBit(VAR,POS) (VAR &= ((1 << POS)^255)) #ifndef MIN #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #endif #ifndef MAX #define MAX(a, b) (((a) > (b)) ? (a) : (b)) #endif #define LE16(addr) (((uint16_t)(addr)[0]) | \ ((uint16_t)(((uint32_t)(addr)[1]) << 8)))... #define LE24(addr) (((uint32_t)(addr)[0]) | \ (((uint32_t)(addr)[1]) << 8) | \ (((uint32_t)(addr)[2]) << 16))... #define LE32(addr) (((uint32_t)(addr)[0]) | \ (((uint32_t)(addr)[1]) << 8) | \ (((uint32_t)(addr)[2]) << 16) | \ (((uint32_t)(addr)[3]) << 24))... #define LE64(addr) (((uint64_t)(addr)[0]) | \ (((uint64_t)(addr)[1]) << 8) | \ (((uint64_t)(addr)[2]) << 16) | \ (((uint64_t)(addr)[3]) << 24) | \ (((uint64_t)(addr)[4]) << 32) | \ (((uint64_t)(addr)[5]) << 40) | \ (((uint64_t)(addr)[6]) << 48) | \ (((uint64_t)(addr)[7]) << 56))... #define LE16S(addr) ((int16_t)(LE16((addr)))) #define LE24S(addr) ((int32_t)(LE24((addr)))) #define LE32S(addr) ((int32_t)(LE32((addr)))) #define LE64S(addr) ((int64_t)(LE64((addr)))) 8 defines #ifndef USBH_MAX_DATA_BUFFER #define USBH_MAX_DATA_BUFFER 0x400U #endif #define USBH_MAX_EP_PACKET_SIZE 0x400U #define USB_LEN_DESC_HDR 0x02U #define USB_LEN_DEV_DESC 0x12U #define USB_LEN_CFG_DESC 0x09U #define USB_LEN_IF_DESC 0x09U #define USB_LEN_EP_DESC 0x07U #define USB_LEN_OTG_DESC 0x03U #define USB_LEN_SETUP_PKT 0x08U /* bmRequestType :D7 Data Phase Transfer Direction */ #define USB_REQ_DIR_MASK 0x80U #define USB_H2D 0x00U #define USB_D2H 0x80U /* bmRequestType D6..5 Type */ #define USB_REQ_TYPE_STANDARD 0x00U #define USB_REQ_TYPE_CLASS 0x20U #define USB_REQ_TYPE_VENDOR 0x40U #define USB_REQ_TYPE_RESERVED 0x60U /* bmRequestType D4..0 Recipient */ #define USB_REQ_RECIPIENT_DEVICE 0x00U #define USB_REQ_RECIPIENT_INTERFACE 0x01U #define USB_REQ_RECIPIENT_ENDPOINT 0x02U #define USB_REQ_RECIPIENT_OTHER 0x03U /* Table 9-4. Standard Request Codes */ /* bRequest , Value */ #define USB_REQ_GET_STATUS 0x00U #define USB_REQ_CLEAR_FEATURE 0x01U #define USB_REQ_SET_FEATURE 0x03U #define USB_REQ_SET_ADDRESS 0x05U #define USB_REQ_GET_DESCRIPTOR 0x06U #define USB_REQ_SET_DESCRIPTOR 0x07U #define USB_REQ_GET_CONFIGURATION 0x08U #define USB_REQ_SET_CONFIGURATION 0x09U #define USB_REQ_GET_INTERFACE 0x0AU #define USB_REQ_SET_INTERFACE 0x0BU #define USB_REQ_SYNCH_FRAME 0x0CU /* Table 9-5. Descriptor Types of USB Specifications */ #define USB_DESC_TYPE_DEVICE 0x01U #define USB_DESC_TYPE_CONFIGURATION 0x02U #define USB_DESC_TYPE_STRING 0x03U #define USB_DESC_TYPE_INTERFACE 0x04U #define USB_DESC_TYPE_ENDPOINT 0x05U #define USB_DESC_TYPE_DEVICE_QUALIFIER 0x06U #define USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION 0x07U #define USB_DESC_TYPE_INTERFACE_POWER 0x08U #define USB_DESC_TYPE_HID 0x21U #define USB_DESC_TYPE_HID_REPORT 0x22U #define USB_DEVICE_DESC_SIZE 0x12U #define USB_CONFIGURATION_DESC_SIZE 0x09U #define USB_HID_DESC_SIZE 0x09U #define USB_INTERFACE_DESC_SIZE 0x09U #define USB_ENDPOINT_DESC_SIZE 0x07U /* Descriptor Type and Descriptor Index */ /* Use the following values when calling the function USBH_GetDescriptor */ #define USB_DESC_DEVICE ((USB_DESC_TYPE_DEVICE << 8) & 0xFF00U) #define USB_DESC_CONFIGURATION ((USB_DESC_TYPE_CONFIGURATION << 8) & 0xFF00U) #define USB_DESC_STRING ((USB_DESC_TYPE_STRING << 8) & 0xFF00U) #define USB_DESC_INTERFACE ((USB_DESC_TYPE_INTERFACE << 8) & 0xFF00U) #define USB_DESC_ENDPOINT ((USB_DESC_TYPE_INTERFACE << 8) & 0xFF00U) #define USB_DESC_DEVICE_QUALIFIER ((USB_DESC_TYPE_DEVICE_QUALIFIER << 8) & 0xFF00U) #define USB_DESC_OTHER_SPEED_CONFIGURATION ((USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION << 8) & 0xFF00U) #define USB_DESC_INTERFACE_POWER ((USB_DESC_TYPE_INTERFACE_POWER << 8) & 0xFF00U) #define USB_DESC_HID_REPORT ((USB_DESC_TYPE_HID_REPORT << 8) & 0xFF00U) #define USB_DESC_HID ((USB_DESC_TYPE_HID << 8) & 0xFF00U) #define USB_EP_TYPE_CTRL 0x00U #define USB_EP_TYPE_ISOC 0x01U #define USB_EP_TYPE_BULK 0x02U #define USB_EP_TYPE_INTR 0x03U #define USB_EP_DIR_OUT 0x00U #define USB_EP_DIR_IN 0x80U #define USB_EP_DIR_MSK 0x80U 62 defines #ifndef USBH_MAX_PIPES_NBR #define USBH_MAX_PIPES_NBR 16U #endif /* USBH_MAX_PIPES_NBR */ #define USBH_DEVICE_ADDRESS_DEFAULT 0x00U #define USBH_DEVICE_ADDRESS 0x01U #define USBH_MAX_ERROR_COUNT 0x02U #if (USBH_USE_OS == 1U) #define MSGQUEUE_OBJECTS 0x10U #endif /** * @} *//* ... */ #define USBH_CONFIGURATION_DESCRIPTOR_SIZE (USB_CONFIGURATION_DESC_SIZE \ + USB_INTERFACE_DESC_SIZE\ + (USBH_MAX_NUM_ENDPOINTS * USB_ENDPOINT_DESC_SIZE))... #define CONFIG_DESC_wTOTAL_LENGTH (ConfigurationDescriptorData.ConfigDescfield.\ ConfigurationDescriptor.wTotalLength)... typedef union { uint16_t w; struct BW { uint8_t msb; uint8_t lsb; ...} bw; ...} uint16_t_uint8_t; typedef union _USB_Setup { uint32_t d8[2]; struct _SetupPkt_Struc { uint8_t bmRequestType; uint8_t bRequest; uint16_t_uint8_t wValue; uint16_t_uint8_t wIndex; uint16_t_uint8_t wLength; ...} b; ...} USB_Setup_TypeDef; typedef struct _DescHeader { uint8_t bLength; uint8_t bDescriptorType; ...} USBH_DescHeader_t; typedef struct _DeviceDescriptor { uint8_t bLength; uint8_t bDescriptorType; uint16_t bcdUSB; /* USB Specification Number which device complies too */ uint8_t bDeviceClass; uint8_t bDeviceSubClass; uint8_t bDeviceProtocol; /* If equal to Zero, each interface specifies its own class code if equal to 0xFF, the class code is vendor specified. Otherwise field is valid Class Code.*//* ... */ uint8_t bMaxPacketSize; uint16_t idVendor; /* Vendor ID (Assigned by USB Org) */ uint16_t idProduct; /* Product ID (Assigned by Manufacturer) */ uint16_t bcdDevice; /* Device Release Number */ uint8_t iManufacturer; /* Index of Manufacturer String Descriptor */ uint8_t iProduct; /* Index of Product String Descriptor */ uint8_t iSerialNumber; /* Index of Serial Number String Descriptor */ uint8_t bNumConfigurations; /* Number of Possible Configurations */ ...} USBH_DevDescTypeDef; typedef struct _EndpointDescriptor { uint8_t bLength; uint8_t bDescriptorType; uint8_t bEndpointAddress; /* indicates what endpoint this descriptor is describing */ uint8_t bmAttributes; /* specifies the transfer type. */ uint16_t wMaxPacketSize; /* Maximum Packet Size this endpoint is capable of sending or receiving */ uint8_t bInterval; /* is used to specify the polling interval of certain transfers. */ ...} USBH_EpDescTypeDef; typedef struct _InterfaceDescriptor { uint8_t bLength; uint8_t bDescriptorType; uint8_t bInterfaceNumber; uint8_t bAlternateSetting; /* Value used to select alternative setting */ uint8_t bNumEndpoints; /* Number of Endpoints used for this interface */ uint8_t bInterfaceClass; /* Class Code (Assigned by USB Org) */ uint8_t bInterfaceSubClass; /* Subclass Code (Assigned by USB Org) */ uint8_t bInterfaceProtocol; /* Protocol Code */ uint8_t iInterface; /* Index of String Descriptor Describing this interface */ USBH_EpDescTypeDef Ep_Desc[USBH_MAX_NUM_ENDPOINTS]; ...} USBH_InterfaceDescTypeDef; typedef struct _ConfigurationDescriptor { uint8_t bLength; uint8_t bDescriptorType; uint16_t wTotalLength; /* Total Length of Data Returned */ uint8_t bNumInterfaces; /* Number of Interfaces */ uint8_t bConfigurationValue; /* Value to use as an argument to select this configuration*/ uint8_t iConfiguration; /* Index of String Descriptor Describing this configuration */ uint8_t bmAttributes; /* D7 Bus Powered , D6 Self Powered, D5 Remote Wakeup , D4..0 Reserved (0)*/ uint8_t bMaxPower; /* Maximum Power Consumption */ USBH_InterfaceDescTypeDef Itf_Desc[USBH_MAX_NUM_INTERFACES]; ...} USBH_CfgDescTypeDef; /* Following USB Host status */ typedef enum { USBH_OK = 0, USBH_BUSY, USBH_FAIL, USBH_NOT_SUPPORTED, USBH_UNRECOVERED_ERROR, USBH_ERROR_SPEED_UNKNOWN, ...} USBH_StatusTypeDef; /** @defgroup USBH_CORE_Exported_Types * @{ *//* ... */ typedef enum { USBH_SPEED_HIGH = 0U, USBH_SPEED_FULL = 1U, USBH_SPEED_LOW = 2U, ...} USBH_SpeedTypeDef; /* Following states are used for gState */ typedef enum { HOST_IDLE = 0U, HOST_DEV_WAIT_FOR_ATTACHMENT, HOST_DEV_ATTACHED, HOST_DEV_DISCONNECTED, HOST_DETECT_DEVICE_SPEED, HOST_ENUMERATION, HOST_CLASS_REQUEST, HOST_INPUT, HOST_SET_CONFIGURATION, HOST_SET_WAKEUP_FEATURE, HOST_CHECK_CLASS, HOST_CLASS, HOST_SUSPENDED, HOST_ABORT_STATE, ...} HOST_StateTypeDef; /* Following states are used for EnumerationState */ typedef enum { ENUM_IDLE = 0U, ENUM_GET_FULL_DEV_DESC, ENUM_SET_ADDR, ENUM_GET_CFG_DESC, ENUM_GET_FULL_CFG_DESC, ENUM_GET_MFC_STRING_DESC, ENUM_GET_PRODUCT_STRING_DESC, ENUM_GET_SERIALNUM_STRING_DESC, ...} ENUM_StateTypeDef; /* Following states are used for CtrlXferStateMachine */ typedef enum { CTRL_IDLE = 0U, CTRL_SETUP, CTRL_SETUP_WAIT, CTRL_DATA_IN, CTRL_DATA_IN_WAIT, CTRL_DATA_OUT, CTRL_DATA_OUT_WAIT, CTRL_STATUS_IN, CTRL_STATUS_IN_WAIT, CTRL_STATUS_OUT, CTRL_STATUS_OUT_WAIT, CTRL_ERROR, CTRL_STALLED, CTRL_COMPLETE ...} CTRL_StateTypeDef; /* Following states are used for RequestState */ typedef enum { CMD_IDLE = 0U, CMD_SEND, CMD_WAIT ...} CMD_StateTypeDef; typedef enum { USBH_URB_IDLE = 0U, USBH_URB_DONE, USBH_URB_NOTREADY, USBH_URB_NYET, USBH_URB_ERROR, USBH_URB_STALL ...} USBH_URBStateTypeDef; typedef enum { USBH_PORT_EVENT = 1U, USBH_URB_EVENT, USBH_CONTROL_EVENT, USBH_CLASS_EVENT, USBH_STATE_CHANGED_EVENT, ...} USBH_OSEventTypeDef; /* Control request structure */ typedef struct { uint8_t pipe_in; uint8_t pipe_out; uint8_t pipe_size; uint8_t *buff; uint16_t length; uint16_t timer; USB_Setup_TypeDef setup; CTRL_StateTypeDef state; uint8_t errorcount; ...} USBH_CtrlTypeDef; /* Attached device structure */ typedef struct { uint8_t CfgDesc_Raw[USBH_MAX_SIZE_CONFIGURATION]; uint8_t Data[USBH_MAX_DATA_BUFFER]; uint8_t address; uint8_t speed; uint8_t EnumCnt; uint8_t RstCnt; __IO uint8_t is_connected; __IO uint8_t is_disconnected; __IO uint8_t is_ReEnumerated; uint8_t PortEnabled; uint8_t current_interface; USBH_DevDescTypeDef DevDesc; USBH_CfgDescTypeDef CfgDesc; ...} USBH_DeviceTypeDef; struct _USBH_HandleTypeDef; /* USB Host Class structure */ typedef struct { const char *Name; uint8_t ClassCode; USBH_StatusTypeDef(*Init)(struct _USBH_HandleTypeDef *phost); USBH_StatusTypeDef(*DeInit)(struct _USBH_HandleTypeDef *phost); USBH_StatusTypeDef(*Requests)(struct _USBH_HandleTypeDef *phost); USBH_StatusTypeDef(*BgndProcess)(struct _USBH_HandleTypeDef *phost); USBH_StatusTypeDef(*SOFProcess)(struct _USBH_HandleTypeDef *phost); void *pData; ...} USBH_ClassTypeDef; /* USB Host handle structure */ typedef struct _USBH_HandleTypeDef { __IO HOST_StateTypeDef gState; /* Host State Machine Value */ ENUM_StateTypeDef EnumState; /* Enumeration state Machine */ CMD_StateTypeDef RequestState; USBH_CtrlTypeDef Control; USBH_DeviceTypeDef device; USBH_ClassTypeDef *pClass[USBH_MAX_NUM_SUPPORTED_CLASS]; USBH_ClassTypeDef *pActiveClass; uint32_t ClassNumber; uint32_t Pipes[16]; __IO uint32_t Timer; uint32_t Timeout; uint8_t id; void *pData; void (* pUser)(struct _USBH_HandleTypeDef *pHandle, uint8_t id); #if (USBH_USE_OS == 1U) #if osCMSIS < 0x20000 osMessageQId os_event; osThreadId thread;/* ... */ #else osMessageQueueId_t os_event; osThreadId_t thread;/* ... */ #endif uint32_t os_msg;/* ... */ #endif ...} USBH_HandleTypeDef; #if defined ( __GNUC__ ) #ifndef __weak #define __weak __attribute__((weak)) #endif /* __weak */ #ifndef __packed #define __packed __attribute__((__packed__)) #endif /* __packed *//* ... */ #endif /* __GNUC__ */ #ifdef __cplusplus }extern "C" { ... } #endif /* ... */ #endif /* USBH_DEF_H */