1 /*
2  * Copyright (c) 2006-2023, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author       Notes
8  * 2012-10-01     Yi Qiu       first version
9  * 2013-04-26     aozima       add DEVICEQUALIFIER support.
10  * 2017-11-15     ZYH          fix ep0 transform error
11  */
12 
13 #ifndef __USB_COMMON_H__
14 #define __USB_COMMON_H__
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 #include <rtthread.h>
21 
22 #define RT_DEBUG_USB                    0x00
23 #define USB_DYNAMIC                     0x00
24 
25 #define USB_CLASS_DEVICE                0x00
26 #define USB_CLASS_AUDIO                 0x01
27 #define USB_CLASS_CDC                   0x02
28 #define USB_CLASS_HID                   0x03
29 #define USB_CLASS_PHYSICAL              0x05
30 #define USB_CLASS_IMAGE                 0x06
31 #define USB_CLASS_PRINTER               0x07
32 #define USB_CLASS_MASS_STORAGE          0x08
33 #define USB_CLASS_HUB                   0x09
34 #define USB_CLASS_CDC_DATA              0x0a
35 #define USB_CLASS_SMART_CARD            0x0b
36 #define USB_CLASS_SECURITY              0x0d
37 #define USB_CLASS_VIDEO                 0x0e
38 #define USB_CLASS_HEALTHCARE            0x0f
39 #define USB_CLASS_DIAG_DEVICE           0xdc
40 #define USB_CLASS_WIRELESS              0xe0
41 #define USB_CLASS_MISC                  0xef
42 #define USB_CLASS_APP_SPECIFIC          0xfe
43 #define USB_CLASS_VEND_SPECIFIC         0xff
44 
45 #define USB_DESC_TYPE_DEVICE            0x01
46 #define USB_DESC_TYPE_CONFIGURATION     0x02
47 #define USB_DESC_TYPE_STRING            0x03
48 #define USB_DESC_TYPE_INTERFACE         0x04
49 #define USB_DESC_TYPE_ENDPOINT          0x05
50 #define USB_DESC_TYPE_DEVICEQUALIFIER   0x06
51 #define USB_DESC_TYPE_OTHERSPEED        0x07
52 #define USB_DESC_TYPE_IAD               0x0b
53 #define USB_DESC_TYPE_HID               0x21
54 #define USB_DESC_TYPE_REPORT            0x22
55 #define USB_DESC_TYPE_PHYSICAL          0x23
56 #define USB_DESC_TYPE_HUB               0x29
57 
58 #define USB_DESC_LENGTH_DEVICE          0x12
59 #define USB_DESC_LENGTH_CONFIG          0x9
60 #define USB_DESC_LENGTH_IAD             0x8
61 #define USB_DESC_LENGTH_STRING          0x4
62 #define USB_DESC_LENGTH_INTERFACE       0x9
63 #define USB_DESC_LENGTH_ENDPOINT        0x7
64 
65 #define USB_REQ_TYPE_STANDARD           0x00
66 #define USB_REQ_TYPE_CLASS              0x20
67 #define USB_REQ_TYPE_VENDOR             0x40
68 #define USB_REQ_TYPE_MASK               0x60
69 
70 #define USB_REQ_TYPE_DIR_OUT            0x00
71 #define USB_REQ_TYPE_DIR_IN             0x80
72 
73 #define USB_REQ_TYPE_DEVICE             0x00
74 #define USB_REQ_TYPE_INTERFACE          0x01
75 #define USB_REQ_TYPE_ENDPOINT           0x02
76 #define USB_REQ_TYPE_OTHER              0x03
77 #define USB_REQ_TYPE_RECIPIENT_MASK     0x1f
78 
79 #define USB_FEATURE_ENDPOINT_HALT       0x00
80 #define USB_FEATURE_DEV_REMOTE_WAKEUP   0x01
81 #define USB_FEATURE_TEST_MODE           0x02
82 
83 #define USB_REQ_GET_STATUS              0x00
84 #define USB_REQ_CLEAR_FEATURE           0x01
85 #define USB_REQ_SET_FEATURE             0x03
86 #define USB_REQ_SET_ADDRESS             0x05
87 #define USB_REQ_GET_DESCRIPTOR          0x06
88 #define USB_REQ_SET_DESCRIPTOR          0x07
89 #define USB_REQ_GET_CONFIGURATION       0x08
90 #define USB_REQ_SET_CONFIGURATION       0x09
91 #define USB_REQ_GET_INTERFACE           0x0A
92 #define USB_REQ_SET_INTERFACE           0x0B
93 #define USB_REQ_SYNCH_FRAME             0x0C
94 #define USB_REQ_SET_ENCRYPTION          0x0D
95 #define USB_REQ_GET_ENCRYPTION          0x0E
96 #define USB_REQ_RPIPE_ABORT             0x0E
97 #define USB_REQ_SET_HANDSHAKE           0x0F
98 #define USB_REQ_RPIPE_RESET             0x0F
99 #define USB_REQ_GET_HANDSHAKE           0x10
100 #define USB_REQ_SET_CONNECTION          0x11
101 #define USB_REQ_SET_SECURITY_DATA       0x12
102 #define USB_REQ_GET_SECURITY_DATA       0x13
103 #define USB_REQ_SET_WUSB_DATA           0x14
104 #define USB_REQ_LOOPBACK_DATA_WRITE     0x15
105 #define USB_REQ_LOOPBACK_DATA_READ      0x16
106 #define USB_REQ_SET_INTERFACE_DS        0x17
107 
108 #define USB_STRING_LANGID_INDEX         0x00
109 #define USB_STRING_MANU_INDEX           0x01
110 #define USB_STRING_PRODUCT_INDEX        0x02
111 #define USB_STRING_SERIAL_INDEX         0x03
112 #define USB_STRING_CONFIG_INDEX         0x04
113 #define USB_STRING_INTERFACE_INDEX      0x05
114 #define USB_STRING_OS_INDEX             0x06
115 #define USB_STRING_MAX                  0xff
116 
117 #define USB_STRING_OS                   "MSFT100A"
118 
119 #define USB_PID_OUT                     0x01
120 #define USB_PID_ACK                     0x02
121 #define USB_PID_DATA0                   0x03
122 #define USB_PID_SOF                     0x05
123 #define USB_PID_IN                      0x09
124 #define USB_PID_NACK                    0x0A
125 #define USB_PID_DATA1                   0x0B
126 #define USB_PID_PRE                     0x0C
127 #define USB_PID_SETUP                   0x0D
128 #define USB_PID_STALL                   0x0E
129 
130 #define USB_EP_DESC_OUT                 0x00
131 #define USB_EP_DESC_IN                  0x80
132 #define USB_EP_DESC_NUM_MASK            0x0f
133 
134 #define USB_EP_ATTR_CONTROL             0x00
135 #define USB_EP_ATTR_ISOC                0x01
136 #define USB_EP_ATTR_BULK                0x02
137 #define USB_EP_ATTR_INT                 0x03
138 #define USB_EP_ATTR_TYPE_MASK           0x03
139 
140 #define USB_EPNO_MASK                   0x7f
141 #define USB_DIR_OUT                     0x00
142 #define USB_DIR_IN                      0x80
143 #define USB_DIR_INOUT                   0x40
144 #define USB_DIR_MASK                    0x80
145 
146 #define ID_UNASSIGNED                   0
147 #define ID_ASSIGNED                     1
148 
149 #define RH_GET_PORT_STATUS              0
150 #define RH_SET_PORT_STATUS              1
151 #define RH_CLEAR_PORT_FEATURE           2
152 #define RH_SET_PORT_FEATURE             3
153 
154 #define USB_BUS_POWERED                 0
155 #define USB_SELF_POWERED                1
156 #define USB_REMOTE_WAKEUP               1
157 #define USB_EP_HALT                     0
158 
159 /*
160  * Port feature numbers
161  */
162 #define PORT_FEAT_CONNECTION            0
163 #define PORT_FEAT_ENABLE                1
164 #define PORT_FEAT_SUSPEND               2
165 #define PORT_FEAT_OVER_CURRENT          3
166 #define PORT_FEAT_RESET                 4
167 #define PORT_FEAT_POWER                 8
168 #define PORT_FEAT_LOWSPEED              9
169 #define PORT_FEAT_HIGHSPEED             10
170 #define PORT_FEAT_C_CONNECTION          16
171 #define PORT_FEAT_C_ENABLE              17
172 #define PORT_FEAT_C_SUSPEND             18
173 #define PORT_FEAT_C_OVER_CURRENT        19
174 #define PORT_FEAT_C_RESET               20
175 
176 /*
177     The HcRhPortStatus[1:NDP] register is used to control and report port events on a per-port
178     basis. NumberDownstreamPorts represents the number of HcRhPortStatus registers that are
179     implemented in hardware.  The lower word is used to reflect the port status, whereas the upper
180     word reflects the status change bits.  Some status bits are implemented with special write behavior
181     (see below).  If a transaction (token through handshake) is in progress when a write to change
182     port status occurs, the resulting port status change must be postponed until the transaction
183     completes.  Reserved bits should always be written '0'.
184 */
185 #define PORT_CCS                        0x00000001UL    /* R:CurrentConnectStatus - W:ClearPortEnable    */
186 #define PORT_PES                        0x00000002UL    /* R:PortEnableStatus - W:SetPortEnable             */
187 #define PORT_PSS                        0x00000004UL    /* R:PortSuspendStatus - W:SetPortSuspend        */
188 #define PORT_POCI                       0x00000008UL    /* R:PortOverCurrentIndicator - W:ClearSuspendStatus    */
189 #define PORT_PRS                        0x00000010UL    /* R:PortResetStatus - W: SetPortReset            */
190 #define PORT_PPS                        0x00000100UL    /* R:PortPowerStatus - W: SetPortPower            */
191 #define PORT_LSDA                       0x00000200UL    /* R:LowSpeedDeviceAttached - W:ClearPortPower    */
192 #define PORT_CCSC                       0x00010000UL
193 #define PORT_PESC                       0x00020000UL
194 #define PORT_PSSC                       0x00040000UL
195 #define PORT_POCIC                      0x00080000UL
196 #define PORT_PRSC                       0x00100000UL
197 
198 /*
199  *Hub Status & Hub Change bit masks
200  */
201 #define HUB_STATUS_LOCAL_POWER          0x0001
202 #define HUB_STATUS_OVERCURRENT          0x0002
203 
204 #define HUB_CHANGE_LOCAL_POWER          0x0001
205 #define HUB_CHANGE_OVERCURRENT          0x0002
206 
207 #define USB_EP_ATTR(attr)               (attr & USB_EP_ATTR_TYPE_MASK)
208 #define USB_EP_DESC_NUM(addr)           (addr & USB_EP_DESC_NUM_MASK)
209 #define USB_EP_DIR(addr)                ((addr & USB_DIR_MASK)>>7)
210 
211 #define HID_REPORT_ID_KEYBOARD1         1
212 #define HID_REPORT_ID_KEYBOARD2         2
213 #define HID_REPORT_ID_KEYBOARD3         3
214 #define HID_REPORT_ID_KEYBOARD4         7
215 #define HID_REPORT_ID_MEDIA             4
216 #define HID_REPORT_ID_GENERAL           5
217 #define HID_REPORT_ID_MOUSE             6
218 
219 /*
220  * Time of usb timeout
221  */
222 #ifndef USB_TIMEOUT_BASIC
223 #define USB_TIMEOUT_BASIC               (RT_TICK_PER_SECOND)        /* 1s */
224 #endif
225 #ifndef USB_TIMEOUT_LONG
226 #define USB_TIMEOUT_LONG                (RT_TICK_PER_SECOND * 5)    /* 5s */
227 #endif
228 #ifndef USB_DEBOUNCE_TIME
229 #define USB_DEBOUNCE_TIME               (RT_TICK_PER_SECOND / 5)    /* 0.2s */
230 #endif
231 
232 #define uswap_32(x) \
233     ((((x) & 0xff000000) >> 24) | \
234      (((x) & 0x00ff0000) >>  8) | \
235      (((x) & 0x0000ff00) <<  8) | \
236      (((x) & 0x000000ff) << 24))
237 
238 #define  uswap_8(x) \
239     (((rt_uint16_t)(*((rt_uint8_t *)(x)))) + \
240     (((rt_uint16_t)(*(((rt_uint8_t *)(x)) + 1))) << 8))
241 
242 typedef void (*func_callback)(void *context);
243 typedef enum
244 {
245     USB_STATE_NOTATTACHED = 0,
246     USB_STATE_ATTACHED,
247     USB_STATE_POWERED,
248     USB_STATE_RECONNECTING,
249     USB_STATE_UNAUTHENTICATED,
250     USB_STATE_DEFAULT,
251     USB_STATE_ADDRESS,
252     USB_STATE_CONFIGURED,
253     USB_STATE_SUSPENDED
254 }udevice_state_t;
255 
256 typedef enum
257 {
258     STAGE_IDLE,
259     STAGE_SETUP,
260     STAGE_STATUS_IN,
261     STAGE_STATUS_OUT,
262     STAGE_DIN,
263     STAGE_DOUT
264 } uep0_stage_t;
265 
266 #pragma pack(1)
267 
268 struct usb_descriptor
269 {
270     rt_uint8_t bLength;
271     rt_uint8_t type;
272 };
273 typedef struct usb_descriptor* udesc_t;
274 
275 struct udevice_descriptor
276 {
277     rt_uint8_t bLength;
278     rt_uint8_t type;
279     rt_uint16_t bcdUSB;
280     rt_uint8_t bDeviceClass;
281     rt_uint8_t bDeviceSubClass;
282     rt_uint8_t bDeviceProtocol;
283     rt_uint8_t bMaxPacketSize0;
284     rt_uint16_t idVendor;
285     rt_uint16_t idProduct;
286     rt_uint16_t bcdDevice;
287     rt_uint8_t iManufacturer;
288     rt_uint8_t iProduct;
289     rt_uint8_t iSerialNumber;
290     rt_uint8_t bNumConfigurations;
291 };
292 typedef struct udevice_descriptor* udev_desc_t;
293 
294 struct uconfig_descriptor
295 {
296     rt_uint8_t bLength;
297     rt_uint8_t type;
298     rt_uint16_t wTotalLength;
299     rt_uint8_t bNumInterfaces;
300     rt_uint8_t bConfigurationValue;
301     rt_uint8_t iConfiguration;
302     rt_uint8_t bmAttributes;
303     rt_uint8_t MaxPower;
304     rt_uint8_t data[2048];
305 };
306 typedef struct uconfig_descriptor* ucfg_desc_t;
307 
308 struct uinterface_descriptor
309 {
310     rt_uint8_t bLength;
311     rt_uint8_t type;
312     rt_uint8_t bInterfaceNumber;
313     rt_uint8_t bAlternateSetting;
314     rt_uint8_t bNumEndpoints;
315     rt_uint8_t bInterfaceClass;
316     rt_uint8_t bInterfaceSubClass;
317     rt_uint8_t bInterfaceProtocol;
318     rt_uint8_t iInterface;
319 };
320 typedef struct uinterface_descriptor* uintf_desc_t;
321 
322 /* Interface Association Descriptor (IAD) */
323 struct uiad_descriptor
324 {
325     rt_uint8_t bLength;
326     rt_uint8_t bDescriptorType;
327     rt_uint8_t bFirstInterface;
328     rt_uint8_t bInterfaceCount;
329     rt_uint8_t bFunctionClass;
330     rt_uint8_t bFunctionSubClass;
331     rt_uint8_t bFunctionProtocol;
332     rt_uint8_t iFunction;
333 };
334 typedef struct uiad_descriptor* uiad_desc_t;
335 
336 struct uendpoint_descriptor
337 {
338     rt_uint8_t  bLength;
339     rt_uint8_t  type;
340     rt_uint8_t  bEndpointAddress;
341     rt_uint8_t  bmAttributes;
342     rt_uint16_t wMaxPacketSize;
343     rt_uint8_t  bInterval;
344 };
345 typedef struct uendpoint_descriptor* uep_desc_t;
346 
347 struct ustring_descriptor
348 {
349     rt_uint8_t bLength;
350     rt_uint8_t type;
351     rt_uint8_t String[64];
352 };
353 typedef struct ustring_descriptor* ustr_desc_t;
354 
355 struct uhub_descriptor
356 {
357     rt_uint8_t length;
358     rt_uint8_t type;
359     rt_uint8_t num_ports;
360     rt_uint16_t characteristics;
361     rt_uint8_t pwron_to_good;        /* power on to power good */
362     rt_uint8_t current;
363     rt_uint8_t removable[8];
364     rt_uint8_t pwr_ctl[8];
365 };
366 typedef struct uhub_descriptor* uhub_desc_t;
367 
368 /* USB_DESC_TYPE_DEVICEQUALIFIER: Device Qualifier descriptor */
369 struct usb_qualifier_descriptor
370 {
371     rt_uint8_t  bLength;
372     rt_uint8_t  bDescriptorType;
373 
374     rt_uint16_t bcdUSB; // TODO: big-endian.
375     rt_uint8_t  bDeviceClass;
376     rt_uint8_t  bDeviceSubClass;
377     rt_uint8_t  bDeviceProtocol;
378     rt_uint8_t  bMaxPacketSize0;
379     rt_uint8_t  bNumConfigurations;
380     rt_uint8_t  bRESERVED;
381 } __attribute__ ((packed));
382 
383 struct usb_os_header_comp_id_descriptor
384 {
385     rt_uint32_t dwLength;
386     rt_uint16_t bcdVersion;
387     rt_uint16_t wIndex;
388     rt_uint8_t  bCount;
389     rt_uint8_t  reserved[7];
390 };
391 typedef struct usb_os_header_comp_id_descriptor * usb_os_header_desc_t;
392 
393 struct usb_os_property_header
394 {
395     rt_uint32_t dwLength;
396     rt_uint16_t bcdVersion;
397     rt_uint16_t wIndex;
398     rt_uint16_t wCount;
399 };
400 typedef struct usb_os_property_header * usb_os_property_header_t;
401 struct usb_os_proerty
402 {
403     rt_uint32_t dwSize;
404     rt_uint32_t dwPropertyDataType;
405     rt_uint16_t wPropertyNameLength;
406     const char * bPropertyName;
407     rt_uint32_t dwPropertyDataLength;
408     const char * bPropertyData;
409 };
410 typedef struct usb_os_proerty * usb_os_proerty_t;
411 
412 // Value    Description
413 //  1       A NULL-terminated Unicode String (REG_SZ)
414 //  2       A NULL-terminated Unicode String that includes environment variables (REG_EXPAND_SZ)
415 //  3       Free-form binary (REG_BINARY)
416 //  4       A little-endian 32-bit integer (REG_DWORD_LITTLE_ENDIAN)
417 //  5       A big-endian 32-bit integer (REG_DWORD_BIG_ENDIAN)
418 //  6       A NULL-terminated Unicode string that contains a symbolic link (REG_LINK)
419 //  7       Multiple NULL-terminated Unicode strings (REG_MULTI_SZ)
420 #define USB_OS_PROPERTY_TYPE_REG_SZ                      0x01UL
421 #define USB_OS_PROPERTY_TYPE_REG_EXPAND_SZ               0x02UL
422 #define USB_OS_PROPERTY_TYPE_REG_BINARY                  0x03UL
423 #define USB_OS_PROPERTY_TYPE_REG_DWORD_LITTLE_ENDIAN     0x04UL
424 #define USB_OS_PROPERTY_TYPE_REG_DWORD_BIG_ENDIAN        0x05UL
425 #define USB_OS_PROPERTY_TYPE_REG_LINK                    0x06UL
426 #define USB_OS_PROPERTY_TYPE_REG_MULTI_SZ                0x07UL
427 
428 #define USB_OS_PROPERTY_DESC(PropertyDataType,PropertyName,PropertyData) \
429 {\
430     .dwSize                 = sizeof(struct usb_os_proerty)-sizeof(const char *)*2\
431                             +sizeof(PropertyName)*2+sizeof(PropertyData)*2,\
432     .dwPropertyDataType     = PropertyDataType,\
433     .wPropertyNameLength    = sizeof(PropertyName)*2,\
434     .bPropertyName          = PropertyName,\
435     .dwPropertyDataLength   = sizeof(PropertyData)*2,\
436     .bPropertyData          = PropertyData\
437 }
438 
439 
440 #ifndef HID_SUB_DESCRIPTOR_MAX
441 #define  HID_SUB_DESCRIPTOR_MAX        1
442 #endif
443 
444 struct uhid_descriptor
445 {
446     rt_uint8_t  bLength;
447     rt_uint8_t  type;
448     rt_uint16_t bcdHID;
449     rt_uint8_t  bCountryCode;
450     rt_uint8_t  bNumDescriptors;
451     struct hid_descriptor_list
452     {
453         rt_uint8_t type;
454         rt_uint16_t wLength;
455     }Descriptor[HID_SUB_DESCRIPTOR_MAX];
456 };
457 typedef struct uhid_descriptor* uhid_desc_t;
458 
459 struct hid_report
460 {
461     rt_uint8_t report_id;
462     rt_uint8_t report[63];
463     rt_uint8_t size;
464 };
465 typedef struct hid_report* hid_report_t;
466 extern void HID_Report_Received(hid_report_t report);
467 
468 struct urequest
469 {
470     rt_uint8_t  request_type;
471     rt_uint8_t  bRequest;
472     rt_uint16_t wValue;
473     rt_uint16_t wIndex;
474     rt_uint16_t wLength;
475 };
476 typedef struct urequest* ureq_t;
477 
478 #ifndef MIN
479 #define MIN(a, b) (a < b ? a : b)
480 #endif
481 #ifndef MAX
482 #define MAX(a, b) (a > b ? a : b)
483 #endif
484 
485 /*
486  * the define related to mass storage
487  */
488 #define USBREQ_GET_MAX_LUN              0xfe
489 #define USBREQ_MASS_STORAGE_RESET       0xff
490 
491 #define SIZEOF_CSW                      0x0d
492 #define SIZEOF_CBW                      0x1f
493 #define SIZEOF_INQUIRY_CMD              0x24
494 #define SIZEOF_MODE_SENSE_6             0x4
495 #define SIZEOF_READ_CAPACITIES          0xc
496 #define SIZEOF_READ_CAPACITY            0x8
497 #define SIZEOF_REQUEST_SENSE            0x12
498 
499 #define CBWFLAGS_DIR_M                  0x80
500 #define CBWFLAGS_DIR_IN                 0x80
501 #define CBWFLAGS_DIR_OUT                0x00
502 
503 #define SCSI_TEST_UNIT_READY            0x00
504 #define SCSI_REQUEST_SENSE              0x03
505 #define SCSI_INQUIRY_CMD                0x12
506 #define SCSI_ALLOW_REMOVAL              0x1e
507 #define SCSI_MODE_SENSE_6               0x1a
508 #define SCSI_START_STOP                 0x1b
509 #define SCSI_READ_CAPACITIES            0x23
510 #define SCSI_READ_CAPACITY              0x25
511 #define SCSI_READ_10                    0x28
512 #define SCSI_WRITE_10                   0x2a
513 #define SCSI_VERIFY_10                  0x2f
514 
515 #define CBW_SIGNATURE                   0x43425355
516 #define CSW_SIGNATURE                   0x53425355
517 #define CBW_TAG_VALUE                   0x12345678
518 
519 struct ustorage_cbw
520 {
521     rt_uint32_t signature;
522     rt_uint32_t tag;
523     rt_uint32_t xfer_len;
524     rt_uint8_t dflags;
525     rt_uint8_t lun;
526     rt_uint8_t cb_len;
527     rt_uint8_t cb[16];
528 };
529 typedef struct ustorage_cbw* ustorage_cbw_t;
530 
531 struct ustorage_csw
532 {
533     rt_uint32_t signature;
534     rt_uint32_t tag;
535     rt_int32_t data_reside;
536     rt_uint8_t  status;
537 };
538 typedef struct ustorage_csw* ustorage_csw_t;
539 
540 #pragma pack()
541 
542 struct usb_os_comp_id_descriptor
543 {
544     struct usb_os_header_comp_id_descriptor head_desc;
545     rt_list_t func_desc;
546 };
547 typedef struct usb_os_comp_id_descriptor * usb_os_comp_id_desc_t;
548 
549 struct usb_os_function_comp_id_descriptor
550 {
551     rt_list_t list;
552     rt_uint8_t bFirstInterfaceNumber;
553     rt_uint8_t reserved1;
554     rt_uint8_t compatibleID[8];
555     rt_uint8_t subCompatibleID[8];
556     rt_uint8_t reserved2[6];
557 };
558 typedef struct usb_os_function_comp_id_descriptor * usb_os_func_comp_id_desc_t;
559 
560 /*
561  * USB device event loop thread configurations
562  */
563 /* the stack size of USB thread */
564 #ifndef RT_USBD_THREAD_STACK_SZ
565 #define RT_USBD_THREAD_STACK_SZ 512
566 #endif
567 
568 /* the priority of USB thread */
569 #ifndef RT_USBD_THREAD_PRIO
570 #define RT_USBD_THREAD_PRIO 8
571 #endif
572 
573 
574 #ifdef __cplusplus
575 }
576 #endif
577 
578 #endif
579