ch32v30x_usb.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834
  1. /********************************** (C) COPYRIGHT *******************************
  2. * File Name : system_ch32v30x.h
  3. * Author : WCH
  4. * Version : V1.0.0
  5. * Date : 2024/05/22
  6. * Description : CH32V30x Device Peripheral Access Layer System Header File.
  7. *********************************************************************************
  8. * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
  9. * Attention: This software (modified or not) and binary are used for
  10. * microcontroller manufactured by Nanjing Qinheng Microelectronics.
  11. *******************************************************************************/
  12. #ifndef __CH32V30x_USB_H
  13. #define __CH32V30x_USB_H
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. /*******************************************************************************/
  18. /* Header File */
  19. #include "stdint.h"
  20. /*******************************************************************************/
  21. /* USB Communication Related Macro Definition */
  22. /* USB Endpoint0 Size */
  23. #ifndef DEFAULT_ENDP0_SIZE
  24. #define DEFAULT_ENDP0_SIZE 8 // default maximum packet size for endpoint 0
  25. #endif
  26. #ifndef MAX_PACKET_SIZE
  27. #define MAX_PACKET_SIZE 64 // maximum packet size
  28. #endif
  29. /* USB PID */
  30. #ifndef USB_PID_SETUP
  31. #define USB_PID_NULL 0x00
  32. #define USB_PID_SOF 0x05
  33. #define USB_PID_SETUP 0x0D
  34. #define USB_PID_IN 0x09
  35. #define USB_PID_OUT 0x01
  36. #define USB_PID_NYET 0x06
  37. #define USB_PID_ACK 0x02
  38. #define USB_PID_NAK 0x0A
  39. #define USB_PID_STALL 0x0E
  40. #define USB_PID_DATA0 0x03
  41. #define USB_PID_DATA1 0x0B
  42. #define USB_PID_DATA2 0x07
  43. #define USB_PID_MDATA 0x0F
  44. #define USB_PID_PRE 0x0C
  45. #endif
  46. /* USB standard device request code */
  47. #ifndef USB_GET_DESCRIPTOR
  48. #define USB_GET_STATUS 0x00
  49. #define USB_CLEAR_FEATURE 0x01
  50. #define USB_SET_FEATURE 0x03
  51. #define USB_SET_ADDRESS 0x05
  52. #define USB_GET_DESCRIPTOR 0x06
  53. #define USB_SET_DESCRIPTOR 0x07
  54. #define USB_GET_CONFIGURATION 0x08
  55. #define USB_SET_CONFIGURATION 0x09
  56. #define USB_GET_INTERFACE 0x0A
  57. #define USB_SET_INTERFACE 0x0B
  58. #define USB_SYNCH_FRAME 0x0C
  59. #endif
  60. #define DEF_STRING_DESC_LANG 0x00
  61. #define DEF_STRING_DESC_MANU 0x01
  62. #define DEF_STRING_DESC_PROD 0x02
  63. #define DEF_STRING_DESC_SERN 0x03
  64. /* USB hub class request code */
  65. #ifndef HUB_GET_DESCRIPTOR
  66. #define HUB_GET_STATUS 0x00
  67. #define HUB_CLEAR_FEATURE 0x01
  68. #define HUB_GET_STATE 0x02
  69. #define HUB_SET_FEATURE 0x03
  70. #define HUB_GET_DESCRIPTOR 0x06
  71. #define HUB_SET_DESCRIPTOR 0x07
  72. #endif
  73. /* USB HID class request code */
  74. #ifndef HID_GET_REPORT
  75. #define HID_GET_REPORT 0x01
  76. #define HID_GET_IDLE 0x02
  77. #define HID_GET_PROTOCOL 0x03
  78. #define HID_SET_REPORT 0x09
  79. #define HID_SET_IDLE 0x0A
  80. #define HID_SET_PROTOCOL 0x0B
  81. #endif
  82. /* USB CDC Class request code */
  83. #ifndef CDC_GET_LINE_CODING
  84. #define CDC_GET_LINE_CODING 0x21 /* This request allows the host to find out the currently configured line coding */
  85. #define CDC_SET_LINE_CODING 0x20 /* Configures DTE rate, stop-bits, parity, and number-of-character */
  86. #define CDC_SET_LINE_CTLSTE 0x22 /* This request generates RS-232/V.24 style control signals */
  87. #define CDC_SEND_BREAK 0x23 /* Sends special carrier modulation used to specify RS-232 style break */
  88. #endif
  89. /* Bit Define for USB Request Type */
  90. #ifndef USB_REQ_TYP_MASK
  91. #define USB_REQ_TYP_IN 0x80
  92. #define USB_REQ_TYP_OUT 0x00
  93. #define USB_REQ_TYP_READ 0x80
  94. #define USB_REQ_TYP_WRITE 0x00
  95. #define USB_REQ_TYP_MASK 0x60
  96. #define USB_REQ_TYP_STANDARD 0x00
  97. #define USB_REQ_TYP_CLASS 0x20
  98. #define USB_REQ_TYP_VENDOR 0x40
  99. #define USB_REQ_TYP_RESERVED 0x60
  100. #define USB_REQ_RECIP_MASK 0x1F
  101. #define USB_REQ_RECIP_DEVICE 0x00
  102. #define USB_REQ_RECIP_INTERF 0x01
  103. #define USB_REQ_RECIP_ENDP 0x02
  104. #define USB_REQ_RECIP_OTHER 0x03
  105. #define USB_REQ_FEAT_REMOTE_WAKEUP 0x01
  106. #define USB_REQ_FEAT_ENDP_HALT 0x00
  107. #endif
  108. /* USB Descriptor Type */
  109. #ifndef USB_DESCR_TYP_DEVICE
  110. #define USB_DESCR_TYP_DEVICE 0x01
  111. #define USB_DESCR_TYP_CONFIG 0x02
  112. #define USB_DESCR_TYP_STRING 0x03
  113. #define USB_DESCR_TYP_INTERF 0x04
  114. #define USB_DESCR_TYP_ENDP 0x05
  115. #define USB_DESCR_TYP_QUALIF 0x06
  116. #define USB_DESCR_TYP_SPEED 0x07
  117. #define USB_DESCR_TYP_OTG 0x09
  118. #define USB_DESCR_TYP_BOS 0X0F
  119. #define USB_DESCR_TYP_HID 0x21
  120. #define USB_DESCR_TYP_REPORT 0x22
  121. #define USB_DESCR_TYP_PHYSIC 0x23
  122. #define USB_DESCR_TYP_CS_INTF 0x24
  123. #define USB_DESCR_TYP_CS_ENDP 0x25
  124. #define USB_DESCR_TYP_HUB 0x29
  125. #endif
  126. /* USB Device Class */
  127. #ifndef USB_DEV_CLASS_HUB
  128. #define USB_DEV_CLASS_RESERVED 0x00
  129. #define USB_DEV_CLASS_AUDIO 0x01
  130. #define USB_DEV_CLASS_COMMUNIC 0x02
  131. #define USB_DEV_CLASS_HID 0x03
  132. #define USB_DEV_CLASS_MONITOR 0x04
  133. #define USB_DEV_CLASS_PHYSIC_IF 0x05
  134. #define USB_DEV_CLASS_POWER 0x06
  135. #define USB_DEV_CLASS_IMAGE 0x06
  136. #define USB_DEV_CLASS_PRINTER 0x07
  137. #define USB_DEV_CLASS_STORAGE 0x08
  138. #define USB_DEV_CLASS_HUB 0x09
  139. #define USB_DEV_CLASS_VEN_SPEC 0xFF
  140. #endif
  141. /* USB Hub Class Request */
  142. #ifndef HUB_GET_HUB_DESCRIPTOR
  143. #define HUB_CLEAR_HUB_FEATURE 0x20
  144. #define HUB_CLEAR_PORT_FEATURE 0x23
  145. #define HUB_GET_BUS_STATE 0xA3
  146. #define HUB_GET_HUB_DESCRIPTOR 0xA0
  147. #define HUB_GET_HUB_STATUS 0xA0
  148. #define HUB_GET_PORT_STATUS 0xA3
  149. #define HUB_SET_HUB_DESCRIPTOR 0x20
  150. #define HUB_SET_HUB_FEATURE 0x20
  151. #define HUB_SET_PORT_FEATURE 0x23
  152. #endif
  153. /* Hub Class Feature Selectors */
  154. #ifndef HUB_PORT_RESET
  155. #define HUB_C_HUB_LOCAL_POWER 0
  156. #define HUB_C_HUB_OVER_CURRENT 1
  157. #define HUB_PORT_CONNECTION 0
  158. #define HUB_PORT_ENABLE 1
  159. #define HUB_PORT_SUSPEND 2
  160. #define HUB_PORT_OVER_CURRENT 3
  161. #define HUB_PORT_RESET 4
  162. #define HUB_PORT_POWER 8
  163. #define HUB_PORT_LOW_SPEED 9
  164. #define HUB_C_PORT_CONNECTION 16
  165. #define HUB_C_PORT_ENABLE 17
  166. #define HUB_C_PORT_SUSPEND 18
  167. #define HUB_C_PORT_OVER_CURRENT 19
  168. #define HUB_C_PORT_RESET 20
  169. #endif
  170. /* USB UDisk */
  171. #ifndef USB_BO_CBW_SIZE
  172. #define USB_BO_CBW_SIZE 0x1F
  173. #define USB_BO_CSW_SIZE 0x0D
  174. #endif
  175. #ifndef USB_BO_CBW_SIG0
  176. #define USB_BO_CBW_SIG0 0x55
  177. #define USB_BO_CBW_SIG1 0x53
  178. #define USB_BO_CBW_SIG2 0x42
  179. #define USB_BO_CBW_SIG3 0x43
  180. #define USB_BO_CSW_SIG0 0x55
  181. #define USB_BO_CSW_SIG1 0x53
  182. #define USB_BO_CSW_SIG2 0x42
  183. #define USB_BO_CSW_SIG3 0x53
  184. #endif
  185. /******************************************************************************/
  186. /* USBHS Clock Configuration Related Macro Definition */
  187. #define USB_CLK_SRC 0x80000000
  188. #define USBHS_PLL_ALIVE 0x40000000
  189. #define USBHS_PLL_CKREF_MASK 0x30000000
  190. #define USBHS_PLL_CKREF_3M 0x00000000
  191. #define USBHS_PLL_CKREF_4M 0x10000000
  192. #define USBHS_PLL_CKREF_8M 0x20000000
  193. #define USBHS_PLL_CKREF_5M 0x30000000
  194. #define USBHS_PLL_SRC 0x08000000
  195. #define USBHS_PLL_SRC_PRE_MASK 0x07000000
  196. #define USBHS_PLL_SRC_PRE_DIV1 0x00000000
  197. #define USBHS_PLL_SRC_PRE_DIV2 0x01000000
  198. #define USBHS_PLL_SRC_PRE_DIV3 0x02000000
  199. #define USBHS_PLL_SRC_PRE_DIV4 0x03000000
  200. #define USBHS_PLL_SRC_PRE_DIV5 0x04000000
  201. #define USBHS_PLL_SRC_PRE_DIV6 0x05000000
  202. #define USBHS_PLL_SRC_PRE_DIV7 0x06000000
  203. #define USBHS_PLL_SRC_PRE_DIV8 0x07000000
  204. /*******************************************************************************/
  205. /* USBHS Related Register Macro Definition */
  206. /* R8_USB_CTRL */
  207. #define USBHS_UC_HOST_MODE 0x80
  208. #define USBHS_UC_SPEED_TYPE 0x60
  209. #define USBHS_UC_SPEED_LOW 0x40
  210. #define USBHS_UC_SPEED_FULL 0x00
  211. #define USBHS_UC_SPEED_HIGH 0x20
  212. #define USBHS_UC_DEV_PU_EN 0x10
  213. #define USBHS_UC_INT_BUSY 0x08
  214. #define USBHS_UC_RESET_SIE 0x04
  215. #define USBHS_UC_CLR_ALL 0x02
  216. #define USBHS_UC_DMA_EN 0x01
  217. /* R8_USB_INT_EN */
  218. #define USBHS_UIE_DEV_NAK 0x80
  219. #define USBHS_UIE_ISO_ACT 0x40
  220. #define USBHS_UIE_SETUP_ACT 0x20
  221. #define USBHS_UIE_FIFO_OV 0x10
  222. #define USBHS_UIE_SOF_ACT 0x08
  223. #define USBHS_UIE_SUSPEND 0x04
  224. #define USBHS_UIE_TRANSFER 0x02
  225. #define USBHS_UIE_DETECT 0x01
  226. #define USBHS_UIE_BUS_RST 0x01
  227. /* R16_USB_DEV_AD */
  228. #define USBHS_MASK_USB_ADDR 0x7F
  229. /* R16_USB_FRAME_NO */
  230. #define USBHS_MICRO_FRAME_NUM 0xE000
  231. #define USBHS_SOF_FRAME_NUM 0x07FF
  232. /* R8_USB_SUSPEND */
  233. #define USBHS_USB_LINESTATE 0x30
  234. #define USBHS_USB_WAKEUP_ST 0x04
  235. #define USBHS_USB_SYS_MOD 0x03
  236. /* R8_USB_SPEED_TYPE */
  237. #define USBHS_USB_SPEED_TYPE 0x03
  238. #define USBHS_USB_SPEED_LOW 0x02
  239. #define USBHS_USB_SPEED_FULL 0x00
  240. #define USBHS_USB_SPEED_HIGH 0x01
  241. /* R8_USB_MIS_ST */
  242. #define USBHS_UMS_SOF_PRES 0x80
  243. #define USBHS_UMS_SOF_ACT 0x40
  244. #define USBHS_UMS_SIE_FREE 0x20
  245. #define USBHS_UMS_R_FIFO_RDY 0x10
  246. #define USBHS_UMS_BUS_RESET 0x08
  247. #define USBHS_UMS_SUSPEND 0x04
  248. #define USBHS_UMS_DEV_ATTACH 0x02
  249. #define USBHS_UMS_SPLIT_CAN 0x01
  250. /* R8_USB_INT_FG */
  251. #define USBHS_UIF_ISO_ACT 0x40
  252. #define USBHS_UIF_SETUP_ACT 0x20
  253. #define USBHS_UIF_FIFO_OV 0x10
  254. #define USBHS_UIF_HST_SOF 0x08
  255. #define USBHS_UIF_SUSPEND 0x04
  256. #define USBHS_UIF_TRANSFER 0x02
  257. #define USBHS_UIF_DETECT 0x01
  258. #define USBHS_UIF_BUS_RST 0x01
  259. /* R8_USB_INT_ST */
  260. #define USBHS_UIS_IS_NAK 0x80
  261. #define USBHS_UIS_TOG_OK 0x40
  262. #define USBHS_UIS_TOKEN_MASK 0x30
  263. #define USBHS_UIS_TOKEN_OUT 0x00
  264. #define USBHS_UIS_TOKEN_SOF 0x10
  265. #define USBHS_UIS_TOKEN_IN 0x20
  266. #define USBHS_UIS_TOKEN_SETUP 0x30
  267. #define USBHS_UIS_ENDP_MASK 0x0F
  268. #define USBHS_UIS_H_RES_MASK 0x0F
  269. /* R16_USB_RX_LEN */
  270. #define USBHS_USB_RX_LEN 0xFFFF
  271. /* R32_UEP_CONFIG */
  272. #define USBHS_UEP15_R_EN 0x80000000
  273. #define USBHS_UEP14_R_EN 0x40000000
  274. #define USBHS_UEP13_R_EN 0x20000000
  275. #define USBHS_UEP12_R_EN 0x10000000
  276. #define USBHS_UEP11_R_EN 0x08000000
  277. #define USBHS_UEP10_R_EN 0x04000000
  278. #define USBHS_UEP9_R_EN 0x02000000
  279. #define USBHS_UEP8_R_EN 0x01000000
  280. #define USBHS_UEP7_R_EN 0x00800000
  281. #define USBHS_UEP6_R_EN 0x00400000
  282. #define USBHS_UEP5_R_EN 0x00200000
  283. #define USBHS_UEP4_R_EN 0x00100000
  284. #define USBHS_UEP3_R_EN 0x00080000
  285. #define USBHS_UEP2_R_EN 0x00040000
  286. #define USBHS_UEP1_R_EN 0x00020000
  287. #define USBHS_UEP0_R_EN 0x00010000
  288. #define USBHS_UEP15_T_EN 0x00008000
  289. #define USBHS_UEP14_T_EN 0x00004000
  290. #define USBHS_UEP13_T_EN 0x00002000
  291. #define USBHS_UEP12_T_EN 0x00001000
  292. #define USBHS_UEP11_T_EN 0x00000800
  293. #define USBHS_UEP10_T_EN 0x00000400
  294. #define USBHS_UEP9_T_EN 0x00000200
  295. #define USBHS_UEP8_T_EN 0x00000100
  296. #define USBHS_UEP7_T_EN 0x00000080
  297. #define USBHS_UEP6_T_EN 0x00000040
  298. #define USBHS_UEP5_T_EN 0x00000020
  299. #define USBHS_UEP4_T_EN 0x00000010
  300. #define USBHS_UEP3_T_EN 0x00000008
  301. #define USBHS_UEP2_T_EN 0x00000004
  302. #define USBHS_UEP1_T_EN 0x00000002
  303. #define USBHS_UEP0_T_EN 0x00000001
  304. /* R32_UEP_TYPE */
  305. #define USBHS_UEP15_R_TYPE 0x80000000
  306. #define USBHS_UEP14_R_TYPE 0x40000000
  307. #define USBHS_UEP13_R_TYPE 0x20000000
  308. #define USBHS_UEP12_R_TYPE 0x10000000
  309. #define USBHS_UEP11_R_TYPE 0x08000000
  310. #define USBHS_UEP10_R_TYPE 0x04000000
  311. #define USBHS_UEP9_R_TYPE 0x02000000
  312. #define USBHS_UEP8_R_TYPE 0x01000000
  313. #define USBHS_UEP7_R_TYPE 0x00800000
  314. #define USBHS_UEP6_R_TYPE 0x00400000
  315. #define USBHS_UEP5_R_TYPE 0x00200000
  316. #define USBHS_UEP4_R_TYPE 0x00100000
  317. #define USBHS_UEP3_R_TYPE 0x00080000
  318. #define USBHS_UEP2_R_TYPE 0x00040000
  319. #define USBHS_UEP1_R_TYPE 0x00020000
  320. #define USBHS_UEP0_R_TYPE 0x00010000
  321. #define USBHS_UEP15_T_TYPE 0x00008000
  322. #define USBHS_UEP14_T_TYPE 0x00004000
  323. #define USBHS_UEP13_T_TYPE 0x00002000
  324. #define USBHS_UEP12_T_TYPE 0x00001000
  325. #define USBHS_UEP11_T_TYPE 0x00000800
  326. #define USBHS_UEP10_T_TYPE 0x00000400
  327. #define USBHS_UEP9_T_TYPE 0x00000200
  328. #define USBHS_UEP8_T_TYPE 0x00000100
  329. #define USBHS_UEP7_T_TYPE 0x00000080
  330. #define USBHS_UEP6_T_TYPE 0x00000040
  331. #define USBHS_UEP5_T_TYPE 0x00000020
  332. #define USBHS_UEP4_T_TYPE 0x00000010
  333. #define USBHS_UEP3_T_TYPE 0x00000008
  334. #define USBHS_UEP2_T_TYPE 0x00000004
  335. #define USBHS_UEP1_T_TYPE 0x00000002
  336. #define USBHS_UEP0_T_TYPE 0x00000001
  337. /* R32_UEP_BUF_MOD */
  338. #define USBHS_UEP15_ISO_BUF_MOD 0x80000000
  339. #define USBHS_UEP14_ISO_BUF_MOD 0x40000000
  340. #define USBHS_UEP13_ISO_BUF_MOD 0x20000000
  341. #define USBHS_UEP12_ISO_BUF_MOD 0x10000000
  342. #define USBHS_UEP11_ISO_BUF_MOD 0x08000000
  343. #define USBHS_UEP10_ISO_BUF_MOD 0x04000000
  344. #define USBHS_UEP9_ISO_BUF_MOD 0x02000000
  345. #define USBHS_UEP8_ISO_BUF_MOD 0x01000000
  346. #define USBHS_UEP7_ISO_BUF_MOD 0x00800000
  347. #define USBHS_UEP6_ISO_BUF_MOD 0x00400000
  348. #define USBHS_UEP5_ISO_BUF_MOD 0x00200000
  349. #define USBHS_UEP4_ISO_BUF_MOD 0x00100000
  350. #define USBHS_UEP3_ISO_BUF_MOD 0x00080000
  351. #define USBHS_UEP2_ISO_BUF_MOD 0x00040000
  352. #define USBHS_UEP1_ISO_BUF_MOD 0x00020000
  353. #define USBHS_UEP0_ISO_BUF_MOD 0x00010000
  354. #define USBHS_UEP15_BUF_MOD 0x00008000
  355. #define USBHS_UEP14_BUF_MOD 0x00004000
  356. #define USBHS_UEP13_BUF_MOD 0x00002000
  357. #define USBHS_UEP12_BUF_MOD 0x00001000
  358. #define USBHS_UEP11_BUF_MOD 0x00000800
  359. #define USBHS_UEP10_BUF_MOD 0x00000400
  360. #define USBHS_UEP9_BUF_MOD 0x00000200
  361. #define USBHS_UEP8_BUF_MOD 0x00000100
  362. #define USBHS_UEP7_BUF_MOD 0x00000080
  363. #define USBHS_UEP6_BUF_MOD 0x00000040
  364. #define USBHS_UEP5_BUF_MOD 0x00000020
  365. #define USBHS_UEP4_BUF_MOD 0x00000010
  366. #define USBHS_UEP3_BUF_MOD 0x00000008
  367. #define USBHS_UEP2_BUF_MOD 0x00000004
  368. #define USBHS_UEP1_BUF_MOD 0x00000002
  369. #define USBHS_UEP0_BUF_MOD 0x00000001
  370. /* R32_UEP0_DMA */
  371. #define USBHS_UEP0_DMA 0x0000FFFF
  372. /* R32_UEPn_TX_DMA, n=1-15 */
  373. #define USBHS_UEPn_TX_DMA 0x0000FFFF
  374. /* R32_UEPn_RX_DMA, n=1-15 */
  375. #define USBHS_UEPn_RX_DMA 0x0000FFFF
  376. /* R16_UEPn_MAX_LEN, n=0-15 */
  377. #define USBHS_UEPn_MAX_LEN 0x07FF
  378. /* R16_UEPn_T_LEN, n=0-15 */
  379. #define USBHS_UEPn_T_LEN 0x07FF
  380. /* R8_UEPn_TX_CTRL, n=0-15 */
  381. #define USBHS_UEP_T_TOG_AUTO 0x20
  382. #define USBHS_UEP_T_TOG_MASK 0x18
  383. #define USBHS_UEP_T_TOG_DATA0 0x00
  384. #define USBHS_UEP_T_TOG_DATA1 0x08
  385. #define USBHS_UEP_T_TOG_DATA2 0x10
  386. #define USBHS_UEP_T_TOG_MDATA 0x18
  387. #define USBHS_UEP_T_RES_MASK 0x03
  388. #define USBHS_UEP_T_RES_ACK 0x00
  389. #define USBHS_UEP_T_RES_NYET 0x01
  390. #define USBHS_UEP_T_RES_NAK 0x02
  391. #define USBHS_UEP_T_RES_STALL 0x03
  392. /* R8_UEPn_TX_CTRL, n=0-15 */
  393. #define USBHS_UEP_R_TOG_AUTO 0x20
  394. #define USBHS_UEP_R_TOG_MASK 0x18
  395. #define USBHS_UEP_R_TOG_DATA0 0x00
  396. #define USBHS_UEP_R_TOG_DATA1 0x08
  397. #define USBHS_UEP_R_TOG_DATA2 0x10
  398. #define USBHS_UEP_R_TOG_MDATA 0x18
  399. #define USBHS_UEP_R_RES_MASK 0x03
  400. #define USBHS_UEP_R_RES_ACK 0x00
  401. #define USBHS_UEP_R_RES_NYET 0x01
  402. #define USBHS_UEP_R_RES_NAK 0x02
  403. #define USBHS_UEP_R_RES_STALL 0x03
  404. /* R8_UHOST_CTRL */
  405. #define USBHS_UH_SOF_EN 0x80
  406. #define USBHS_UH_SOF_FREE 0x40
  407. #define USBHS_UH_PHY_SUSPENDM 0x10
  408. #define USBHS_UH_REMOTE_WKUP 0x08
  409. #define USBHS_UH_TX_BUS_RESUME 0x04
  410. #define USBHS_UH_TX_BUS_SUSPEND 0x02
  411. #define USBHS_UH_TX_BUS_RESET 0x01
  412. /* R32_UH_CONFIG */
  413. #define USBHS_UH_EP_RX_EN 0x00040000
  414. #define USBHS_UH_EP_TX_EN 0x00000008
  415. /* R32_UH_EP_TYPE */
  416. #define USBHS_UH_EP_RX_TYPE 0x00040000
  417. #define USBHS_UH_EP_TX_TYPE 0x00000008
  418. /* R32_UH_RX_DMA */
  419. #define USBHS_UH_RX_DMA 0x0000FFFC
  420. /* R32_UH_TX_DMA */
  421. #define USBHS_UH_TX_DMA 0x0000FFFF
  422. /* R16_UH_RX_MAX_LEN */
  423. #define USBHS_UH_RX_MAX_LEN 0x07FF
  424. /* R8_UH_EP_PID */
  425. #define USBHS_UH_TOKEN_MASK 0xF0
  426. #define USBHS_UH_ENDP_MASK 0x0F
  427. /* R8_UH_RX_CTRL */
  428. #define USBHS_UH_R_DATA_NO 0x40
  429. #define USBHS_UH_R_TOG_AUTO 0x20
  430. #define USBHS_UH_R_TOG_MASK 0x18
  431. #define USBHS_UH_R_TOG_DATA0 0x00
  432. #define USBHS_UH_R_TOG_DATA1 0x08
  433. #define USBHS_UH_R_TOG_DATA2 0x10
  434. #define USBHS_UH_R_TOG_MDATA 0x18
  435. #define USBHS_UH_R_RES_NO 0x04
  436. #define USBHS_UH_R_RES_MASK 0x03
  437. #define USBHS_UH_R_RES_ACK 0x00
  438. #define USBHS_UH_R_RES_NYET 0x01
  439. #define USBHS_UH_R_RES_NAK 0x02
  440. #define USBHS_UH_R_RES_STALL 0x03
  441. /* R16_UH_TX_LEN */
  442. #define USBHS_UH_TX_LEN 0x07FF
  443. /* R8_UH_TX_CTRL */
  444. #define USBHS_UH_T_DATA_NO 0x40
  445. #define USBHS_UH_T_AUTO_TOG 0x20
  446. #define USBHS_UH_T_TOG_MASK 0x18
  447. #define USBHS_UH_T_TOG_DATA0 0x00
  448. #define USBHS_UH_T_TOG_DATA1 0x08
  449. #define USBHS_UH_T_TOG_DATA2 0x10
  450. #define USBHS_UH_T_TOG_MDATA 0x18
  451. #define USBHS_UH_T_RES_NO 0x04
  452. #define USBHS_UH_T_RES_MASK 0x03
  453. #define USBHS_UH_T_RES_ACK 0x00
  454. #define USBHS_UH_T_RES_NYET 0x01
  455. #define USBHS_UH_T_RES_NAK 0x02
  456. #define USBHS_UH_T_RES_STALL 0x03
  457. /* R16_UH_SPLIT_DATA */
  458. #define USBHS_UH_SPLIT_DATA 0x0FFF
  459. /*******************************************************************************/
  460. /* USBFS Related Register Macro Definition */
  461. /* R8_USB_CTRL */
  462. #define USBFS_UC_HOST_MODE 0x80
  463. #define USBFS_UC_LOW_SPEED 0x40
  464. #define USBFS_UC_DEV_PU_EN 0x20
  465. #define USBFS_UC_SYS_CTRL_MASK 0x30
  466. #define USBFS_UC_SYS_CTRL0 0x00
  467. #define USBFS_UC_SYS_CTRL1 0x10
  468. #define USBFS_UC_SYS_CTRL2 0x20
  469. #define USBFS_UC_SYS_CTRL3 0x30
  470. #define USBFS_UC_INT_BUSY 0x08
  471. #define USBFS_UC_RESET_SIE 0x04
  472. #define USBFS_UC_CLR_ALL 0x02
  473. #define USBFS_UC_DMA_EN 0x01
  474. /* R8_USB_INT_EN */
  475. #define USBFS_UIE_DEV_SOF 0x80
  476. #define USBFS_UIE_DEV_NAK 0x40
  477. #define USBFS_1WIRE_MODE 0x20
  478. #define USBFS_UIE_FIFO_OV 0x10
  479. #define USBFS_UIE_HST_SOF 0x08
  480. #define USBFS_UIE_SUSPEND 0x04
  481. #define USBFS_UIE_TRANSFER 0x02
  482. #define USBFS_UIE_DETECT 0x01
  483. #define USBFS_UIE_BUS_RST 0x01
  484. /* R8_USB_DEV_AD */
  485. #define USBFS_UDA_GP_BIT 0x80
  486. #define USBFS_USB_ADDR_MASK 0x7F
  487. /* R8_USB_MIS_ST */
  488. #define USBFS_UMS_SOF_PRES 0x80
  489. #define USBFS_UMS_SOF_ACT 0x40
  490. #define USBFS_UMS_SIE_FREE 0x20
  491. #define USBFS_UMS_R_FIFO_RDY 0x10
  492. #define USBFS_UMS_BUS_RESET 0x08
  493. #define USBFS_UMS_SUSPEND 0x04
  494. #define USBFS_UMS_DM_LEVEL 0x02
  495. #define USBFS_UMS_DEV_ATTACH 0x01
  496. /* R8_USB_INT_FG */
  497. #define USBFS_U_IS_NAK 0x80 // RO, indicate current USB transfer is NAK received
  498. #define USBFS_U_TOG_OK 0x40 // RO, indicate current USB transfer toggle is OK
  499. #define USBFS_U_SIE_FREE 0x20 // RO, indicate USB SIE free status
  500. #define USBFS_UIF_FIFO_OV 0x10 // FIFO overflow interrupt flag for USB, direct bit address clear or write 1 to clear
  501. #define USBFS_UIF_HST_SOF 0x08 // host SOF timer interrupt flag for USB host, direct bit address clear or write 1 to clear
  502. #define USBFS_UIF_SUSPEND 0x04 // USB suspend or resume event interrupt flag, direct bit address clear or write 1 to clear
  503. #define USBFS_UIF_TRANSFER 0x02 // USB transfer completion interrupt flag, direct bit address clear or write 1 to clear
  504. #define USBFS_UIF_DETECT 0x01 // device detected event interrupt flag for USB host mode, direct bit address clear or write 1 to clear
  505. #define USBFS_UIF_BUS_RST 0x01 // bus reset event interrupt flag for USB device mode, direct bit address clear or write 1 to clear
  506. /* R8_USB_INT_ST */
  507. #define USBFS_UIS_IS_NAK 0x80 // RO, indicate current USB transfer is NAK received for USB device mode
  508. #define USBFS_UIS_TOG_OK 0x40 // RO, indicate current USB transfer toggle is OK
  509. #define USBFS_UIS_TOKEN_MASK 0x30 // RO, bit mask of current token PID code received for USB device mode
  510. #define USBFS_UIS_TOKEN_OUT 0x00
  511. #define USBFS_UIS_TOKEN_SOF 0x10
  512. #define USBFS_UIS_TOKEN_IN 0x20
  513. #define USBFS_UIS_TOKEN_SETUP 0x30
  514. // bUIS_TOKEN1 & bUIS_TOKEN0: current token PID code received for USB device mode
  515. // 00: OUT token PID received
  516. // 01: SOF token PID received
  517. // 10: IN token PID received
  518. // 11: SETUP token PID received
  519. #define USBFS_UIS_ENDP_MASK 0x0F // RO, bit mask of current transfer endpoint number for USB device mode
  520. #define USBFS_UIS_H_RES_MASK 0x0F // RO, bit mask of current transfer handshake response for USB host mode: 0000=no response, time out from device, others=handshake response PID received
  521. /* R32_USB_OTG_CR */
  522. #define USBFS_CR_SESS_VTH 0x20
  523. #define USBFS_CR_VBUS_VTH 0x10
  524. #define USBFS_CR_OTG_EN 0x08
  525. #define USBFS_CR_IDPU 0x04
  526. #define USBFS_CR_CHARGE_VBUS 0x02
  527. #define USBFS_CR_DISCHAR_VBUS 0x01
  528. /* R32_USB_OTG_SR */
  529. #define USBFS_SR_ID_DIG 0x08
  530. #define USBFS_SR_SESS_END 0x04
  531. #define USBFS_SR_SESS_VLD 0x02
  532. #define USBFS_SR_VBUS_VLD 0x01
  533. /* R8_UDEV_CTRL */
  534. #define USBFS_UD_PD_DIS 0x80 // disable USB UDP/UDM pulldown resistance: 0=enable pulldown, 1=disable
  535. #define USBFS_UD_DP_PIN 0x20 // ReadOnly: indicate current UDP pin level
  536. #define USBFS_UD_DM_PIN 0x10 // ReadOnly: indicate current UDM pin level
  537. #define USBFS_UD_LOW_SPEED 0x04 // enable USB physical port low speed: 0=full speed, 1=low speed
  538. #define USBFS_UD_GP_BIT 0x02 // general purpose bit
  539. #define USBFS_UD_PORT_EN 0x01 // enable USB physical port I/O: 0=disable, 1=enable
  540. /* R8_UEP4_1_MOD */
  541. #define USBFS_UEP1_RX_EN 0x80 // enable USB endpoint 1 receiving (OUT)
  542. #define USBFS_UEP1_TX_EN 0x40 // enable USB endpoint 1 transmittal (IN)
  543. #define USBFS_UEP1_BUF_MOD 0x10 // buffer mode of USB endpoint 1
  544. #define USBFS_UEP4_RX_EN 0x08 // enable USB endpoint 4 receiving (OUT)
  545. #define USBFS_UEP4_TX_EN 0x04 // enable USB endpoint 4 transmittal (IN)
  546. #define USBFS_UEP4_BUF_MOD 0x01
  547. /* R8_UEP2_3_MOD */
  548. #define USBFS_UEP3_RX_EN 0x80 // enable USB endpoint 3 receiving (OUT)
  549. #define USBFS_UEP3_TX_EN 0x40 // enable USB endpoint 3 transmittal (IN)
  550. #define USBFS_UEP3_BUF_MOD 0x10 // buffer mode of USB endpoint 3
  551. #define USBFS_UEP2_RX_EN 0x08 // enable USB endpoint 2 receiving (OUT)
  552. #define USBFS_UEP2_TX_EN 0x04 // enable USB endpoint 2 transmittal (IN)
  553. #define USBFS_UEP2_BUF_MOD 0x01 // buffer mode of USB endpoint 2
  554. /* R8_UEP5_6_MOD */
  555. #define USBFS_UEP6_RX_EN 0x80 // enable USB endpoint 6 receiving (OUT)
  556. #define USBFS_UEP6_TX_EN 0x40 // enable USB endpoint 6 transmittal (IN)
  557. #define USBFS_UEP6_BUF_MOD 0x10 // buffer mode of USB endpoint 6
  558. #define USBFS_UEP5_RX_EN 0x08 // enable USB endpoint 5 receiving (OUT)
  559. #define USBFS_UEP5_TX_EN 0x04 // enable USB endpoint 5 transmittal (IN)
  560. #define USBFS_UEP5_BUF_MOD 0x01 // buffer mode of USB endpoint 5
  561. /* R8_UEP7_MOD */
  562. #define USBFS_UEP7_RX_EN 0x08 // enable USB endpoint 7 receiving (OUT)
  563. #define USBFS_UEP7_TX_EN 0x04 // enable USB endpoint 7 transmittal (IN)
  564. #define USBFS_UEP7_BUF_MOD 0x01 // buffer mode of USB endpoint 7
  565. /* R8_UEPn_TX_CTRL */
  566. #define USBFS_UEP_T_AUTO_TOG 0x08 // enable automatic toggle after successful transfer completion on endpoint 1/2/3: 0=manual toggle, 1=automatic toggle
  567. #define USBFS_UEP_T_TOG 0x04 // prepared data toggle flag of USB endpoint X transmittal (IN): 0=DATA0, 1=DATA1
  568. #define USBFS_UEP_T_RES_MASK 0x03 // bit mask of handshake response type for USB endpoint X transmittal (IN)
  569. #define USBFS_UEP_T_RES_ACK 0x00
  570. #define USBFS_UEP_T_RES_NONE 0x01
  571. #define USBFS_UEP_T_RES_NAK 0x02
  572. #define USBFS_UEP_T_RES_STALL 0x03
  573. // bUEP_T_RES1 & bUEP_T_RES0: handshake response type for USB endpoint X transmittal (IN)
  574. // 00: DATA0 or DATA1 then expecting ACK (ready)
  575. // 01: DATA0 or DATA1 then expecting no response, time out from host, for non-zero endpoint isochronous transactions
  576. // 10: NAK (busy)
  577. // 11: STALL (error)
  578. // host aux setup
  579. /* R8_UEPn_RX_CTRL, n=0-7 */
  580. #define USBFS_UEP_R_AUTO_TOG 0x08 // enable automatic toggle after successful transfer completion on endpoint 1/2/3: 0=manual toggle, 1=automatic toggle
  581. #define USBFS_UEP_R_TOG 0x04 // expected data toggle flag of USB endpoint X receiving (OUT): 0=DATA0, 1=DATA1
  582. #define USBFS_UEP_R_RES_MASK 0x03 // bit mask of handshake response type for USB endpoint X receiving (OUT)
  583. #define USBFS_UEP_R_RES_ACK 0x00
  584. #define USBFS_UEP_R_RES_NONE 0x01
  585. #define USBFS_UEP_R_RES_NAK 0x02
  586. #define USBFS_UEP_R_RES_STALL 0x03
  587. // RB_UEP_R_RES1 & RB_UEP_R_RES0: handshake response type for USB endpoint X receiving (OUT)
  588. // 00: ACK (ready)
  589. // 01: no response, time out to host, for non-zero endpoint isochronous transactions
  590. // 10: NAK (busy)
  591. // 11: STALL (error)
  592. /* R8_UHOST_CTRL */
  593. #define USBFS_UH_PD_DIS 0x80 // disable USB UDP/UDM pulldown resistance: 0=enable pulldown, 1=disable
  594. #define USBFS_UH_DP_PIN 0x20 // ReadOnly: indicate current UDP pin level
  595. #define USBFS_UH_DM_PIN 0x10 // ReadOnly: indicate current UDM pin level
  596. #define USBFS_UH_LOW_SPEED 0x04 // enable USB port low speed: 0=full speed, 1=low speed
  597. #define USBFS_UH_BUS_RESET 0x02 // control USB bus reset: 0=normal, 1=force bus reset
  598. #define USBFS_UH_PORT_EN 0x01 // enable USB port: 0=disable, 1=enable port, automatic disabled if USB device detached
  599. /* R32_UH_EP_MOD */
  600. #define USBFS_UH_EP_TX_EN 0x40 // enable USB host OUT endpoint transmittal
  601. #define USBFS_UH_EP_TBUF_MOD 0x10 // buffer mode of USB host OUT endpoint
  602. // bUH_EP_TX_EN & bUH_EP_TBUF_MOD: USB host OUT endpoint buffer mode, buffer start address is UH_TX_DMA
  603. // 0 x: disable endpoint and disable buffer
  604. // 1 0: 64 bytes buffer for transmittal (OUT endpoint)
  605. // 1 1: dual 64 bytes buffer by toggle bit bUH_T_TOG selection for transmittal (OUT endpoint), total=128bytes
  606. #define USBFS_UH_EP_RX_EN 0x08 // enable USB host IN endpoint receiving
  607. #define USBFS_UH_EP_RBUF_MOD 0x01 // buffer mode of USB host IN endpoint
  608. // bUH_EP_RX_EN & bUH_EP_RBUF_MOD: USB host IN endpoint buffer mode, buffer start address is UH_RX_DMA
  609. // 0 x: disable endpoint and disable buffer
  610. // 1 0: 64 bytes buffer for receiving (IN endpoint)
  611. // 1 1: dual 64 bytes buffer by toggle bit bUH_R_TOG selection for receiving (IN endpoint), total=128bytes
  612. /* R16_UH_SETUP */
  613. #define USBFS_UH_PRE_PID_EN 0x0400 // USB host PRE PID enable for low speed device via hub
  614. #define USBFS_UH_SOF_EN 0x0004 // USB host automatic SOF enable
  615. /* R8_UH_EP_PID */
  616. #define USBFS_UH_TOKEN_MASK 0xF0 // bit mask of token PID for USB host transfer
  617. #define USBFS_UH_ENDP_MASK 0x0F // bit mask of endpoint number for USB host transfer
  618. /* R8_UH_RX_CTRL */
  619. #define USBFS_UH_R_AUTO_TOG 0x08 // enable automatic toggle after successful transfer completion: 0=manual toggle, 1=automatic toggle
  620. #define USBFS_UH_R_TOG 0x04 // expected data toggle flag of host receiving (IN): 0=DATA0, 1=DATA1
  621. #define USBFS_UH_R_RES 0x01 // prepared handshake response type for host receiving (IN): 0=ACK (ready), 1=no response, time out to device, for isochronous transactions
  622. /* R8_UH_TX_CTRL */
  623. #define USBFS_UH_T_AUTO_TOG 0x08 // enable automatic toggle after successful transfer completion: 0=manual toggle, 1=automatic toggle
  624. #define USBFS_UH_T_TOG 0x04 // prepared data toggle flag of host transmittal (SETUP/OUT): 0=DATA0, 1=DATA1
  625. #define USBFS_UH_T_RES 0x01 // expected handshake response type for host transmittal (SETUP/OUT): 0=ACK (ready), 1=no response, time out from device, for isochronous transactions
  626. /*******************************************************************************/
  627. /* Struct Definition */
  628. /* USB Setup Request */
  629. typedef struct __attribute__((packed)) _USB_SETUP_REQ
  630. {
  631. uint8_t bRequestType;
  632. uint8_t bRequest;
  633. uint16_t wValue;
  634. uint16_t wIndex;
  635. uint16_t wLength;
  636. } USB_SETUP_REQ, *PUSB_SETUP_REQ;
  637. /* USB Device Descriptor */
  638. typedef struct __attribute__((packed)) _USB_DEVICE_DESCR
  639. {
  640. uint8_t bLength;
  641. uint8_t bDescriptorType;
  642. uint16_t bcdUSB;
  643. uint8_t bDeviceClass;
  644. uint8_t bDeviceSubClass;
  645. uint8_t bDeviceProtocol;
  646. uint8_t bMaxPacketSize0;
  647. uint16_t idVendor;
  648. uint16_t idProduct;
  649. uint16_t bcdDevice;
  650. uint8_t iManufacturer;
  651. uint8_t iProduct;
  652. uint8_t iSerialNumber;
  653. uint8_t bNumConfigurations;
  654. } USB_DEV_DESCR, *PUSB_DEV_DESCR;
  655. /* USB Configuration Descriptor */
  656. typedef struct __attribute__((packed)) _USB_CONFIG_DESCR
  657. {
  658. uint8_t bLength;
  659. uint8_t bDescriptorType;
  660. uint16_t wTotalLength;
  661. uint8_t bNumInterfaces;
  662. uint8_t bConfigurationValue;
  663. uint8_t iConfiguration;
  664. uint8_t bmAttributes;
  665. uint8_t MaxPower;
  666. } USB_CFG_DESCR, *PUSB_CFG_DESCR;
  667. /* USB Interface Descriptor */
  668. typedef struct __attribute__((packed)) _USB_INTERF_DESCR
  669. {
  670. uint8_t bLength;
  671. uint8_t bDescriptorType;
  672. uint8_t bInterfaceNumber;
  673. uint8_t bAlternateSetting;
  674. uint8_t bNumEndpoints;
  675. uint8_t bInterfaceClass;
  676. uint8_t bInterfaceSubClass;
  677. uint8_t bInterfaceProtocol;
  678. uint8_t iInterface;
  679. } USB_ITF_DESCR, *PUSB_ITF_DESCR;
  680. /* USB Endpoint Descriptor */
  681. typedef struct __attribute__((packed)) _USB_ENDPOINT_DESCR
  682. {
  683. uint8_t bLength;
  684. uint8_t bDescriptorType;
  685. uint8_t bEndpointAddress;
  686. uint8_t bmAttributes;
  687. uint8_t wMaxPacketSizeL;
  688. uint8_t wMaxPacketSizeH;
  689. uint8_t bInterval;
  690. } USB_ENDP_DESCR, *PUSB_ENDP_DESCR;
  691. /* USB Configuration Descriptor Set */
  692. typedef struct __attribute__((packed)) _USB_CONFIG_DESCR_LONG
  693. {
  694. USB_CFG_DESCR cfg_descr;
  695. USB_ITF_DESCR itf_descr;
  696. USB_ENDP_DESCR endp_descr[ 1 ];
  697. } USB_CFG_DESCR_LONG, *PUSB_CFG_DESCR_LONG;
  698. /* USB HUB Descriptor */
  699. typedef struct __attribute__((packed)) _USB_HUB_DESCR
  700. {
  701. uint8_t bDescLength;
  702. uint8_t bDescriptorType;
  703. uint8_t bNbrPorts;
  704. uint8_t wHubCharacteristicsL;
  705. uint8_t wHubCharacteristicsH;
  706. uint8_t bPwrOn2PwrGood;
  707. uint8_t bHubContrCurrent;
  708. uint8_t DeviceRemovable;
  709. uint8_t PortPwrCtrlMask;
  710. } USB_HUB_DESCR, *PUSB_HUB_DESCR;
  711. /* USB HID Descriptor */
  712. typedef struct __attribute__((packed)) _USB_HID_DESCR
  713. {
  714. uint8_t bLength;
  715. uint8_t bDescriptorType;
  716. uint16_t bcdHID;
  717. uint8_t bCountryCode;
  718. uint8_t bNumDescriptors;
  719. uint8_t bDescriptorTypeX;
  720. uint8_t wDescriptorLengthL;
  721. uint8_t wDescriptorLengthH;
  722. } USB_HID_DESCR, *PUSB_HID_DESCR;
  723. /* USB UDisk */
  724. typedef struct __attribute__((packed)) _UDISK_BOC_CBW
  725. {
  726. uint32_t mCBW_Sig;
  727. uint32_t mCBW_Tag;
  728. uint32_t mCBW_DataLen;
  729. uint8_t mCBW_Flag;
  730. uint8_t mCBW_LUN;
  731. uint8_t mCBW_CB_Len;
  732. uint8_t mCBW_CB_Buf[ 16 ];
  733. } UDISK_BOC_CBW, *PXUDISK_BOC_CBW;
  734. /* USB UDisk */
  735. typedef struct __attribute__((packed)) _UDISK_BOC_CSW
  736. {
  737. uint32_t mCBW_Sig;
  738. uint32_t mCBW_Tag;
  739. uint32_t mCSW_Residue;
  740. uint8_t mCSW_Status;
  741. } UDISK_BOC_CSW, *PXUDISK_BOC_CSW;
  742. #ifdef __cplusplus
  743. }
  744. #endif
  745. #endif /* __CH32V30x_USB_H */