usbd_reg.h 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. /**************************************************************************//**
  2. * @file usbd_reg.h
  3. * @version V1.00
  4. * @brief USBD register definition header file
  5. *
  6. * SPDX-License-Identifier: Apache-2.0
  7. * @copyright (C) 2018 Nuvoton Technology Corp. All rights reserved.
  8. *****************************************************************************/
  9. #ifndef __USBD_REG_H__
  10. #define __USBD_REG_H__
  11. #if defined ( __CC_ARM )
  12. #pragma anon_unions
  13. #endif
  14. /**
  15. @addtogroup REGISTER Control Register
  16. @{
  17. */
  18. /**
  19. @addtogroup USBD USB Device Controller(USBD)
  20. Memory Mapped Structure for USBD Controller
  21. @{ */
  22. typedef struct
  23. {
  24. /**
  25. * @var USBD_EP_T::BUFSEG
  26. * Offset: 0x500/0x510/0x520/0x530/0x540/0x550/0x560/0x570 Endpoint Buffer Segmentation Register
  27. * ---------------------------------------------------------------------------------------------------
  28. * |Bits |Field |Descriptions
  29. * | :----: | :----: | :---- |
  30. * |[8:3] |BUFSEG |Endpoint Buffer Segmentation
  31. * | | |It is used to indicate the offset address for each endpoint with the USB SRAM starting address The effective starting address of the endpoint is
  32. * | | |USBD_SRAM address + { BUFSEG[8:3], 3'b000}
  33. * | | |Where the USBD_SRAM address = USBD_BA+0x100h.
  34. * | | |Refer to the section 6.17.5.76.21.5.7 for the endpoint SRAM structure and its description.
  35. * @var USBD_EP_T::MXPLD
  36. * Offset: 0x504/0x514/0x524/0x534/0x544/0x554/0x564/0x574 Endpoint Maximal Payload Register
  37. * ---------------------------------------------------------------------------------------------------
  38. * |Bits |Field |Descriptions
  39. * | :----: | :----: | :---- |
  40. * |[8:0] |MXPLD |Maximal Payload
  41. * | | |Define the data length which is transmitted to host (IN token) or the actual data length which is received from the host (OUT token)
  42. * | | |It also used to indicate that the endpoint is ready to be transmitted in IN token or received in OUT token.
  43. * | | |(1) When the register is written by CPU,
  44. * | | |For IN token, the value of MXPLD is used to define the data length to be transmitted and indicate the data buffer is ready.
  45. * | | |For OUT token, it means that the controller is ready to receive data from the host and the value of MXPLD is the maximal data length comes from host.
  46. * | | |(2) When the register is read by CPU,
  47. * | | |For IN token, the value of MXPLD is indicated by the data length be transmitted to host
  48. * | | |For OUT token, the value of MXPLD is indicated the actual data length receiving from host.
  49. * | | |Note: Once MXPLD is written, the data packets will be transmitted/received immediately after IN/OUT token arrived.
  50. * @var USBD_EP_T::CFG
  51. * Offset: 0x508/0x518/0x528/0x538/0x548/0x558/0x568/0x578 Endpoint Configuration Register
  52. * ---------------------------------------------------------------------------------------------------
  53. * |Bits |Field |Descriptions
  54. * | :----: | :----: | :---- |
  55. * |[3:0] |EPNUM |Endpoint Number
  56. * | | |These bits are used to define the endpoint number of the current endpoint.
  57. * |[4] |ISOCH |Isochronous Endpoint
  58. * | | |This bit is used to set the endpoint as Isochronous endpoint, no handshake.
  59. * | | |0 = No Isochronous endpoint.
  60. * | | |1 = Isochronous endpoint.
  61. * |[6:5] |STATE |Endpoint STATE
  62. * | | |00 = Endpoint is Disabled.
  63. * | | |01 = Out endpoint.
  64. * | | |10 = IN endpoint.
  65. * | | |11 = Undefined.
  66. * |[7] |DSQSYNC |Data Sequence Synchronization
  67. * | | |0 = DATA0 PID.
  68. * | | |1 = DATA1 PID.
  69. * | | |Note: It is used to specify the DATA0 or DATA1 PID in the following IN token transaction.
  70. * | | |Hardware will toggle automatically in IN token base on the bit.
  71. * |[9] |CSTALL |Clear STALL Response
  72. * | | |0 = Disable the device to clear the STALL handshake in setup stage.
  73. * | | |1 = Clear the device to response STALL handshake in setup stage.
  74. * @var USBD_EP_T::CFGP
  75. * Offset: 0x50C/0x51C/0x52C/0x53C/0x54C/0x55C/0x56C/0x57C Endpoint Set Stall and Clear In/Out Ready Control Register
  76. * ---------------------------------------------------------------------------------------------------
  77. * |Bits |Field |Descriptions
  78. * | :----: | :----: | :---- |
  79. * |[0] |CLRRDY |Clear Ready
  80. * | | |When the USBD_MXPLDx register is set by user, it means that the endpoint is ready to transmit or receive data.
  81. * | | |If the user wants to disable this transaction before the transaction start, users can set this bit to 1 to disable it and it is auto clear to 0.
  82. * | | |For IN token, write '1' to clear the IN token had ready to transmit the data to USB.
  83. * | | |For OUT token, write '1' to clear the OUT token had ready to receive the data from USB.
  84. * | | |This bit is write 1 only and is always 0 when it is read back.
  85. * |[1] |SSTALL |Set STALL
  86. * | | |0 = Disable the device to response STALL.
  87. * | | |1 = Set the device to respond STALL automatically.
  88. */
  89. __IO uint32_t BUFSEG; /*!< [0x0000] Endpoint Buffer Segmentation Register */
  90. __IO uint32_t MXPLD; /*!< [0x0004] Endpoint Maximal Payload Register */
  91. __IO uint32_t CFG; /*!< [0x0008] Endpoint Configuration Register */
  92. __IO uint32_t CFGP; /*!< [0x000c] Endpoint Set Stall and Clear In/Out Ready Control Register */
  93. } USBD_EP_T;
  94. typedef struct
  95. {
  96. /**
  97. * @var USBD_T::INTEN
  98. * Offset: 0x00 USB Device Interrupt Enable Register
  99. * ---------------------------------------------------------------------------------------------------
  100. * |Bits |Field |Descriptions
  101. * | :----: | :----: | :---- |
  102. * |[0] |BUSIEN |Bus Event Interrupt Enable Bit
  103. * | | |0 = BUS event interrupt Disabled.
  104. * | | |1 = BUS event interrupt Enabled.
  105. * |[1] |USBIEN |USB Event Interrupt Enable Bit
  106. * | | |0 = USB event interrupt Disabled.
  107. * | | |1 = USB event interrupt Enabled.
  108. * |[2] |VBDETIEN |VBUS Detection Interrupt Enable Bit
  109. * | | |0 = VBUS detection Interrupt Disabled.
  110. * | | |1 = VBUS detection Interrupt Enabled.
  111. * |[3] |NEVWKIEN |USB No-event-wake-up Interrupt Enable Bit
  112. * | | |0 = No-event-wake-up Interrupt Disabled.
  113. * | | |1 = No-event-wake-up Interrupt Enabled.
  114. * |[4] |SOFIEN |Start of Frame Interrupt Enable Bit
  115. * | | |0 = SOF Interrupt Disabled.
  116. * | | |1 = SOF Interrupt Enabled.
  117. * |[8] |WKEN |Wake-up Function Enable Bit
  118. * | | |0 = USB wake-up function Disabled.
  119. * | | |1 = USB wake-up function Enabled.
  120. * |[15] |INNAKEN |Active NAK Function and Its Status in IN Token
  121. * | | |0 = When device responds NAK after receiving IN token, IN NAK status will not be updated to USBD_EPSTS0 register, so that the USB interrupt event will not be asserted.
  122. * | | |1 = IN NAK status will be updated to USBD_EPSTS0 register and the USB interrupt event will be asserted, when the device responds NAK after receiving IN token.
  123. * @var USBD_T::INTSTS
  124. * Offset: 0x04 USB Device Interrupt Event Status Register
  125. * ---------------------------------------------------------------------------------------------------
  126. * |Bits |Field |Descriptions
  127. * | :----: | :----: | :---- |
  128. * |[0] |BUSIF |BUS Interrupt Status
  129. * | | |The BUS event means that there is one of the suspense or the resume function in the bus.
  130. * | | |0 = No BUS event occurred.
  131. * | | |1 = Bus event occurred; check USBD_ATTR[3:0] to know which kind of bus event was occurred, cleared by write 1 to USBD_INTSTS[0].
  132. * |[1] |USBIF |USB Event Interrupt Status
  133. * | | |The USB event includes the SETUP Token, IN Token, OUT ACK, ISO IN, or ISO OUT events in the bus.
  134. * | | |0 = No USB event occurred.
  135. * | | |1 = USB event occurred, check EPSTS0~5[2:0] to know which kind of USB event was occurred, cleared by write 1 to USBD_INTSTS[1] or EPSTS0~11 and SETUP (USBD_INTSTS[31]).
  136. * |[2] |VBDETIF |VBUS Detection Interrupt Status
  137. * | | |0 = There is not attached/detached event in the USB.
  138. * | | |1 = There is attached/detached event in the USB bus and it is cleared by write 1 to USBD_INTSTS[2].
  139. * |[3] |NEVWKIF |No-event-wake-up Interrupt Status
  140. * | | |0 = NEVWK event does not occur.
  141. * | | |1 = No-event-wake-up event occurred, cleared by write 1 to USBD_INTSTS[3].
  142. * |[4] |SOFIF |Start of Frame Interrupt Status
  143. * | | |0 = SOF event does not occur.
  144. * | | |1 = SOF event occurred, cleared by write 1 to USBD_INTSTS[4].
  145. * |[16] |EPEVT0 |Endpoint 0's USB Event Status
  146. * | | |0 = No event occurred in endpoint 0.
  147. * | | |1 = USB event occurred on Endpoint 0, check USBD_EPSTS0[3:0] to know which kind of USB event was occurred, cleared by write 1 to USBD_INTSTS[16] or USBD_INTSTS[1].
  148. * |[17] |EPEVT1 |Endpoint 1's USB Event Status
  149. * | | |0 = No event occurred in endpoint 1.
  150. * | | |1 = USB event occurred on Endpoint 1, check USBD_EPSTS0[7:4] to know which kind of USB event was occurred, cleared by write 1 to USBD_INTSTS[17] or USBD_INTSTS[1].
  151. * |[18] |EPEVT2 |Endpoint 2's USB Event Status
  152. * | | |0 = No event occurred in endpoint 2.
  153. * | | |1 = USB event occurred on Endpoint 2, check USBD_EPSTS0[11:8] to know which kind of USB event was occurred, cleared by write 1 to USBD_INTSTS[18] or USBD_INTSTS[1].
  154. * |[19] |EPEVT3 |Endpoint 3's USB Event Status
  155. * | | |0 = No event occurred in endpoint 3.
  156. * | | |1 = USB event occurred on Endpoint 3, check USBD_EPSTS0[15:12] to know which kind of USB event was occurred, cleared by write 1 to USBD_INTSTS[19] or USBD_INTSTS[1].
  157. * |[20] |EPEVT4 |Endpoint 4's USB Event Status
  158. * | | |0 = No event occurred in endpoint 4.
  159. * | | |1 = USB event occurred on Endpoint 4, check USBD_EPSTS0[19:16] to know which kind of USB event was occurred, cleared by write 1 to USBD_INTSTS[20] or USBD_INTSTS[1].
  160. * |[21] |EPEVT5 |Endpoint 5's USB Event Status
  161. * | | |0 = No event occurred in endpoint 5.
  162. * | | |1 = USB event occurred on Endpoint 5, check USBD_EPSTS0[23:20] to know which kind of USB event was occurred, cleared by write 1 to USBD_INTSTS[21] or USBD_INTSTS[1].
  163. * |[22] |EPEVT6 |Endpoint 6's USB Event Status
  164. * | | |0 = No event occurred in endpoint 6.
  165. * | | |1 = USB event occurred on Endpoint 6, check USBD_EPSTS0[27:24] to know which kind of USB event was occurred, cleared by write 1 to USBD_INTSTS[22] or USBD_INTSTS[1].
  166. * |[23] |EPEVT7 |Endpoint 7's USB Event Status
  167. * | | |0 = No event occurred in endpoint 7.
  168. * | | |1 = USB event occurred on Endpoint 7, check USBD_EPSTS0[31:28] to know which kind of USB event was occurred, cleared by write 1 to USBD_INTSTS[23] or USBD_INTSTS[1].
  169. * |[31] |SETUP |Setup Event Status
  170. * | | |0 = No Setup event.
  171. * | | |1 = Setup event occurred, cleared by write 1 to USBD_INTSTS[31].
  172. * @var USBD_T::FADDR
  173. * Offset: 0x08 USB Device Function Address Register
  174. * ---------------------------------------------------------------------------------------------------
  175. * |Bits |Field |Descriptions
  176. * | :----: | :----: | :---- |
  177. * |[6:0] |FADDR |USB Device Function Address
  178. * @var USBD_T::EPSTS
  179. * Offset: 0x0C USB Device Endpoint Status Register
  180. * ---------------------------------------------------------------------------------------------------
  181. * |Bits |Field |Descriptions
  182. * | :----: | :----: | :---- |
  183. * |[7] |OV |Overrun
  184. * | | |It indicates that the received data is over the maximum payload number or not.
  185. * | | |if received data is over the maximum payload number, the extra data will be ignored.
  186. * | | |0 = No overrun.
  187. * | | |1 = Out Data is more than the Max Payload in MXPLD register or the Setup Data is more than 8 Bytes.
  188. * @var USBD_T::ATTR
  189. * Offset: 0x10 USB Device Bus Status and Attribution Register
  190. * ---------------------------------------------------------------------------------------------------
  191. * |Bits |Field |Descriptions
  192. * | :----: | :----: | :---- |
  193. * |[0] |USBRST |USB Reset Status (Read Only)
  194. * | | |0 = Bus no reset.
  195. * | | |1 = Bus reset when SE0 (single-ended 0) more than 2.5us.
  196. * |[1] |SUSPEND |Suspend Status (Read Only)
  197. * | | |0 = Bus no suspend.
  198. * | | |1 = Bus idle more than 3ms, either cable is plugged off or host is sleeping.
  199. * |[2] |RESUME |Resume Status (Read Only)
  200. * | | |0 = No bus resume.
  201. * | | |1 = Resume from suspend.
  202. * |[3] |TOUT |Time-out Status (Read Only)
  203. * | | |When USB Device controller after received setup token or out token, USB controller stay J state to wait data package.
  204. * | | |If the waiting time exceeds 18-bit length timing, TOUT flag will be generated.
  205. * | | |0 = No time-out.
  206. * | | |1 = No Bus response more than 18 bits time.
  207. * |[4] |PHYEN |PHY Transceiver Function Enable Bit
  208. * | | |0 = PHY transceiver function Disabled.
  209. * | | |1 = PHY transceiver function Enabled.
  210. * |[5] |RWAKEUP |Remote Wake-up
  211. * | | |0 = Release the USB bus from K state.
  212. * | | |1 = Force USB bus to K (USB_D+ low, USB_D-: high) state, used for remote wake-up.
  213. * |[7] |USBEN |USB Controller Enable Bit
  214. * | | |0 = USB Controller Disabled.
  215. * | | |1 = USB Controller Enabled.
  216. * |[8] |DPPUEN |Pull-up Resistor on USB_DP Enable Bit
  217. * | | |0 = Pull-up resistor in USB_D+ bus Disabled.
  218. * | | |1 = Pull-up resistor in USB_D+ bus Active.
  219. * |[10] |BYTEM |CPU Access USB SRAM Size Mode Selection
  220. * | | |0 = Word mode: The size of the transfer from CPU to USB SRAM can be Word only.
  221. * | | |1 = Byte mode: The size of the transfer from CPU to USB SRAM can be Byte only.
  222. * |[11] |LPMACK |LPM Token Acknowledge Enable Bit
  223. * | | |The NYET/ACK will be returned only on a successful LPM transaction if no errors in both the EXT token and the LPM token and a valid bLinkState = 0001 (L1) is received, else ERROR and STALL will be returned automatically, respectively.
  224. * | | |0= the valid LPM Token will be NYET.
  225. * | | |1= the valid LPM Token will be ACK.
  226. * |[12] |L1SUSPEND |LPM L1 Suspend (Read Only)
  227. * | | |0 = Bus no L1 state suspend.
  228. * | | |1 = This bit is set by the hardware when LPM command to enter the L1 state is successfully received and acknowledged.
  229. * |[13] |L1RESUME |LPM L1 Resume (Read Only)
  230. * | | |0 = Bus no LPM L1 state resume.
  231. * | | |1 = LPM L1 state Resume from LPM L1 state suspend.
  232. * @var USBD_T::VBUSDET
  233. * Offset: 0x14 USB Device VBUS Detection Register
  234. * ---------------------------------------------------------------------------------------------------
  235. * |Bits |Field |Descriptions
  236. * | :----: | :----: | :---- |
  237. * |[0] |VBUSDET |Device VBUS Detection
  238. * | | |0 = Controller is not attached to the USB host.
  239. * | | |1 = Controller is attached to the USB host.
  240. * @var USBD_T::STBUFSEG
  241. * Offset: 0x18 SETUP Token Buffer Segmentation Register
  242. * ---------------------------------------------------------------------------------------------------
  243. * |Bits |Field |Descriptions
  244. * | :----: | :----: | :---- |
  245. * |[8:3] |STBUFSEG |SETUP Token Buffer Segmentation
  246. * | | |It is used to indicate the offset address for the SETUP token with the USB Device SRAM starting address The effective starting address is
  247. * | | |USBD_SRAM address + {STBUFSEG, 3'b000}
  248. * | | |Where the USBD_SRAM address = USBD_BA+0x100h.
  249. * | | |Note: It is used for SETUP token only.
  250. * @var USBD_T::EPSTS0
  251. * Offset: 0x20 USB Device Endpoint Status Register 0
  252. * ---------------------------------------------------------------------------------------------------
  253. * |Bits |Field |Descriptions
  254. * | :----: | :----: | :---- |
  255. * |[3:0] |EPSTS0 |Endpoint 0 Status
  256. * | | |These bits are used to indicate the current status of this endpoint.
  257. * | | |0000 = In ACK.
  258. * | | |0001 = In NAK.
  259. * | | |0010 = Out Packet Data0 ACK.
  260. * | | |0011 = Setup ACK.
  261. * | | |0110 = Out Packet Data1 ACK.
  262. * | | |0111 = Isochronous transfer end.
  263. * |[7:4] |EPSTS1 |Endpoint 1 Status
  264. * | | |These bits are used to indicate the current status of this endpoint.
  265. * | | |0000 = In ACK.
  266. * | | |0001 = In NAK.
  267. * | | |0010 = Out Packet Data0 ACK.
  268. * | | |0011 = Setup ACK.
  269. * | | |0110 = Out Packet Data1 ACK.
  270. * | | |0111 = Isochronous transfer end.
  271. * |[11:8] |EPSTS2 |Endpoint 2 Status
  272. * | | |These bits are used to indicate the current status of this endpoint.
  273. * | | |0000 = In ACK.
  274. * | | |0001 = In NAK.
  275. * | | |0010 = Out Packet Data0 ACK.
  276. * | | |0011 = Setup ACK.
  277. * | | |0110 = Out Packet Data1 ACK.
  278. * | | |0111 = Isochronous transfer end.
  279. * |[15:12] |EPSTS3 |Endpoint 3 Status
  280. * | | |These bits are used to indicate the current status of this endpoint.
  281. * | | |0000 = In ACK.
  282. * | | |0001 = In NAK.
  283. * | | |0010 = Out Packet Data0 ACK.
  284. * | | |0011 = Setup ACK.
  285. * | | |0110 = Out Packet Data1 ACK.
  286. * | | |0111 = Isochronous transfer end.
  287. * |[19:16] |EPSTS4 |Endpoint 4 Status
  288. * | | |These bits are used to indicate the current status of this endpoint.
  289. * | | |0000 = In ACK.
  290. * | | |0001 = In NAK.
  291. * | | |0010 = Out Packet Data0 ACK.
  292. * | | |0011 = Setup ACK.
  293. * | | |0110 = Out Packet Data1 ACK.
  294. * | | |0111 = Isochronous transfer end.
  295. * |[23:20] |EPSTS5 |Endpoint 5 Status
  296. * | | |These bits are used to indicate the current status of this endpoint.
  297. * | | |0000 = In ACK.
  298. * | | |0001 = In NAK.
  299. * | | |0010 = Out Packet Data0 ACK.
  300. * | | |0011 = Setup ACK.
  301. * | | |0110 = Out Packet Data1 ACK.
  302. * | | |0111 = Isochronous transfer end.
  303. * |[27:24] |EPSTS6 |Endpoint 6 Status
  304. * | | |These bits are used to indicate the current status of this endpoint.
  305. * | | |0000 = In ACK.
  306. * | | |0001 = In NAK.
  307. * | | |0010 = Out Packet Data0 ACK.
  308. * | | |0011 = Setup ACK.
  309. * | | |0110 = Out Packet Data1 ACK.
  310. * | | |0111 = Isochronous transfer end.
  311. * |[31:28] |EPSTS7 |Endpoint 7 Status
  312. * | | |These bits are used to indicate the current status of this endpoint.
  313. * | | |0000 = In ACK.
  314. * | | |0001 = In NAK.
  315. * | | |0010 = Out Packet Data0 ACK.
  316. * | | |0011 = Setup ACK.
  317. * | | |0110 = Out Packet Data1 ACK.
  318. * | | |0111 = Isochronous transfer end.
  319. * @var USBD_T::LPMATTR
  320. * Offset: 0x88 USB LPM Attribution Register
  321. * ---------------------------------------------------------------------------------------------------
  322. * |Bits |Field |Descriptions
  323. * | :----: | :----: | :---- |
  324. * |[3:0] |LPMLINKSTS|LPM Link State
  325. * | | |These bits contain the bLinkState received with last ACK LPM Token.
  326. * |[7:4] |LPMBESL |LPM Best Effort Service Latency
  327. * | | |These bits contain the BESL value received with last ACK LPM Token.
  328. * |[8] |LPMRWAKUP |LPM Remote Wakeup
  329. * | | |This bit contains the bRemoteWake value received with last ACK LPM Token.
  330. * @var USBD_T::FN
  331. * Offset: 0x8C USB Frame Number Register
  332. * ---------------------------------------------------------------------------------------------------
  333. * |Bits |Field |Descriptions
  334. * | :----: | :----: | :---- |
  335. * |[10:0] |FN |Frame Number
  336. * | | |These bits contain the 11-bits frame number in the last received SOF packet.
  337. * @var USBD_T::SE0
  338. * Offset: 0x90 USB Device Drive SE0 Control Register
  339. * ---------------------------------------------------------------------------------------------------
  340. * |Bits |Field |Descriptions
  341. * | :----: | :----: | :---- |
  342. * |[0] |SE0 |Drive Single Ended Zero in USB Bus
  343. * | | |The Single Ended Zero (SE0) is when both lines (USB_D+ and USB_D-) are being pulled low.
  344. * | | |0 = Normal operation.
  345. * | | |1 = Force USB PHY transceiver to drive SE0.
  346. */
  347. __IO uint32_t INTEN; /*!< [0x0000] USB Device Interrupt Enable Register */
  348. __IO uint32_t INTSTS; /*!< [0x0004] USB Device Interrupt Event Status Register */
  349. __IO uint32_t FADDR; /*!< [0x0008] USB Device Function Address Register */
  350. __I uint32_t EPSTS; /*!< [0x000c] USB Device Endpoint Status Register */
  351. __IO uint32_t ATTR; /*!< [0x0010] USB Device Bus Status and Attribution Register */
  352. __I uint32_t VBUSDET; /*!< [0x0014] USB Device VBUS Detection Register */
  353. __IO uint32_t STBUFSEG; /*!< [0x0018] SETUP Token Buffer Segmentation Register */
  354. /// @cond HIDDEN_SYMBOLS
  355. __I uint32_t RESERVE0[1];
  356. /// @endcond //HIDDEN_SYMBOLS
  357. __I uint32_t EPSTS0; /*!< [0x0020] USB Device Endpoint Status Register 0 */
  358. /// @cond HIDDEN_SYMBOLS
  359. __I uint32_t RESERVE1[25];
  360. /// @endcond //HIDDEN_SYMBOLS
  361. __I uint32_t LPMATTR; /*!< [0x0088] USB LPM Attribution Register */
  362. __I uint32_t FN; /*!< [0x008c] USB Frame number Register */
  363. __IO uint32_t SE0; /*!< [0x0090] USB Device Drive SE0 Control Register */
  364. /// @cond HIDDEN_SYMBOLS
  365. __I uint32_t RESERVE2[283];
  366. /// @endcond //HIDDEN_SYMBOLS
  367. USBD_EP_T EP[8]; /*!< [0x0500~0x5BC] USB Device Endpoints(0~7) */
  368. } USBD_T;
  369. /**
  370. @addtogroup USBD_CONST USBD Bit Field Definition
  371. Constant Definitions for USBD Controller
  372. @{ */
  373. #define USBD_INTEN_BUSIEN_Pos (0) /*!< USBD_T::INTEN: BUSIEN Position */
  374. #define USBD_INTEN_BUSIEN_Msk (0x1ul << USBD_INTEN_BUSIEN_Pos) /*!< USBD_T::INTEN: BUSIEN Mask */
  375. #define USBD_INTEN_USBIEN_Pos (1) /*!< USBD_T::INTEN: USBIEN Position */
  376. #define USBD_INTEN_USBIEN_Msk (0x1ul << USBD_INTEN_USBIEN_Pos) /*!< USBD_T::INTEN: USBIEN Mask */
  377. #define USBD_INTEN_VBDETIEN_Pos (2) /*!< USBD_T::INTEN: VBDETIEN Position */
  378. #define USBD_INTEN_VBDETIEN_Msk (0x1ul << USBD_INTEN_VBDETIEN_Pos) /*!< USBD_T::INTEN: VBDETIEN Mask */
  379. #define USBD_INTEN_NEVWKIEN_Pos (3) /*!< USBD_T::INTEN: NEVWKIEN Position */
  380. #define USBD_INTEN_NEVWKIEN_Msk (0x1ul << USBD_INTEN_NEVWKIEN_Pos) /*!< USBD_T::INTEN: NEVWKIEN Mask */
  381. #define USBD_INTEN_SOFIEN_Pos (4) /*!< USBD_T::INTEN: SOFIEN Position */
  382. #define USBD_INTEN_SOFIEN_Msk (0x1ul << USBD_INTEN_SOFIEN_Pos) /*!< USBD_T::INTEN: SOFIEN Mask */
  383. #define USBD_INTEN_WKEN_Pos (8) /*!< USBD_T::INTEN: WKEN Position */
  384. #define USBD_INTEN_WKEN_Msk (0x1ul << USBD_INTEN_WKEN_Pos) /*!< USBD_T::INTEN: WKEN Mask */
  385. #define USBD_INTEN_INNAKEN_Pos (15) /*!< USBD_T::INTEN: INNAKEN Position */
  386. #define USBD_INTEN_INNAKEN_Msk (0x1ul << USBD_INTEN_INNAKEN_Pos) /*!< USBD_T::INTEN: INNAKEN Mask */
  387. #define USBD_INTSTS_BUSIF_Pos (0) /*!< USBD_T::INTSTS: BUSIF Position */
  388. #define USBD_INTSTS_BUSIF_Msk (0x1ul << USBD_INTSTS_BUSIF_Pos) /*!< USBD_T::INTSTS: BUSIF Mask */
  389. #define USBD_INTSTS_USBIF_Pos (1) /*!< USBD_T::INTSTS: USBIF Position */
  390. #define USBD_INTSTS_USBIF_Msk (0x1ul << USBD_INTSTS_USBIF_Pos) /*!< USBD_T::INTSTS: USBIF Mask */
  391. #define USBD_INTSTS_VBDETIF_Pos (2) /*!< USBD_T::INTSTS: VBDETIF Position */
  392. #define USBD_INTSTS_VBDETIF_Msk (0x1ul << USBD_INTSTS_VBDETIF_Pos) /*!< USBD_T::INTSTS: VBDETIF Mask */
  393. #define USBD_INTSTS_NEVWKIF_Pos (3) /*!< USBD_T::INTSTS: NEVWKIF Position */
  394. #define USBD_INTSTS_NEVWKIF_Msk (0x1ul << USBD_INTSTS_NEVWKIF_Pos) /*!< USBD_T::INTSTS: NEVWKIF Mask */
  395. #define USBD_INTSTS_SOFIF_Pos (4) /*!< USBD_T::INTSTS: SOFIF Position */
  396. #define USBD_INTSTS_SOFIF_Msk (0x1ul << USBD_INTSTS_SOFIF_Pos) /*!< USBD_T::INTSTS: SOFIF Mask */
  397. #define USBD_INTSTS_EPEVT0_Pos (16) /*!< USBD_T::INTSTS: EPEVT0 Position */
  398. #define USBD_INTSTS_EPEVT0_Msk (0x1ul << USBD_INTSTS_EPEVT0_Pos) /*!< USBD_T::INTSTS: EPEVT0 Mask */
  399. #define USBD_INTSTS_EPEVT1_Pos (17) /*!< USBD_T::INTSTS: EPEVT1 Position */
  400. #define USBD_INTSTS_EPEVT1_Msk (0x1ul << USBD_INTSTS_EPEVT1_Pos) /*!< USBD_T::INTSTS: EPEVT1 Mask */
  401. #define USBD_INTSTS_EPEVT2_Pos (18) /*!< USBD_T::INTSTS: EPEVT2 Position */
  402. #define USBD_INTSTS_EPEVT2_Msk (0x1ul << USBD_INTSTS_EPEVT2_Pos) /*!< USBD_T::INTSTS: EPEVT2 Mask */
  403. #define USBD_INTSTS_EPEVT3_Pos (19) /*!< USBD_T::INTSTS: EPEVT3 Position */
  404. #define USBD_INTSTS_EPEVT3_Msk (0x1ul << USBD_INTSTS_EPEVT3_Pos) /*!< USBD_T::INTSTS: EPEVT3 Mask */
  405. #define USBD_INTSTS_EPEVT4_Pos (20) /*!< USBD_T::INTSTS: EPEVT4 Position */
  406. #define USBD_INTSTS_EPEVT4_Msk (0x1ul << USBD_INTSTS_EPEVT4_Pos) /*!< USBD_T::INTSTS: EPEVT4 Mask */
  407. #define USBD_INTSTS_EPEVT5_Pos (21) /*!< USBD_T::INTSTS: EPEVT5 Position */
  408. #define USBD_INTSTS_EPEVT5_Msk (0x1ul << USBD_INTSTS_EPEVT5_Pos) /*!< USBD_T::INTSTS: EPEVT5 Mask */
  409. #define USBD_INTSTS_EPEVT6_Pos (22) /*!< USBD_T::INTSTS: EPEVT6 Position */
  410. #define USBD_INTSTS_EPEVT6_Msk (0x1ul << USBD_INTSTS_EPEVT6_Pos) /*!< USBD_T::INTSTS: EPEVT6 Mask */
  411. #define USBD_INTSTS_EPEVT7_Pos (23) /*!< USBD_T::INTSTS: EPEVT7 Position */
  412. #define USBD_INTSTS_EPEVT7_Msk (0x1ul << USBD_INTSTS_EPEVT7_Pos) /*!< USBD_T::INTSTS: EPEVT7 Mask */
  413. #define USBD_INTSTS_SETUP_Pos (31) /*!< USBD_T::INTSTS: SETUP Position */
  414. #define USBD_INTSTS_SETUP_Msk (0x1ul << USBD_INTSTS_SETUP_Pos) /*!< USBD_T::INTSTS: SETUP Mask */
  415. #define USBD_FADDR_FADDR_Pos (0) /*!< USBD_T::FADDR: FADDR Position */
  416. #define USBD_FADDR_FADDR_Msk (0x7ful << USBD_FADDR_FADDR_Pos) /*!< USBD_T::FADDR: FADDR Mask */
  417. #define USBD_EPSTS_OV_Pos (7) /*!< USBD_T::EPSTS: OV Position */
  418. #define USBD_EPSTS_OV_Msk (0x1ul << USBD_EPSTS_OV_Pos) /*!< USBD_T::EPSTS: OV Mask */
  419. #define USBD_ATTR_USBRST_Pos (0) /*!< USBD_T::ATTR: USBRST Position */
  420. #define USBD_ATTR_USBRST_Msk (0x1ul << USBD_ATTR_USBRST_Pos) /*!< USBD_T::ATTR: USBRST Mask */
  421. #define USBD_ATTR_SUSPEND_Pos (1) /*!< USBD_T::ATTR: SUSPEND Position */
  422. #define USBD_ATTR_SUSPEND_Msk (0x1ul << USBD_ATTR_SUSPEND_Pos) /*!< USBD_T::ATTR: SUSPEND Mask */
  423. #define USBD_ATTR_RESUME_Pos (2) /*!< USBD_T::ATTR: RESUME Position */
  424. #define USBD_ATTR_RESUME_Msk (0x1ul << USBD_ATTR_RESUME_Pos) /*!< USBD_T::ATTR: RESUME Mask */
  425. #define USBD_ATTR_TOUT_Pos (3) /*!< USBD_T::ATTR: TOUT Position */
  426. #define USBD_ATTR_TOUT_Msk (0x1ul << USBD_ATTR_TOUT_Pos) /*!< USBD_T::ATTR: TOUT Mask */
  427. #define USBD_ATTR_PHYEN_Pos (4) /*!< USBD_T::ATTR: PHYEN Position */
  428. #define USBD_ATTR_PHYEN_Msk (0x1ul << USBD_ATTR_PHYEN_Pos) /*!< USBD_T::ATTR: PHYEN Mask */
  429. #define USBD_ATTR_RWAKEUP_Pos (5) /*!< USBD_T::ATTR: RWAKEUP Position */
  430. #define USBD_ATTR_RWAKEUP_Msk (0x1ul << USBD_ATTR_RWAKEUP_Pos) /*!< USBD_T::ATTR: RWAKEUP Mask */
  431. #define USBD_ATTR_USBEN_Pos (7) /*!< USBD_T::ATTR: USBEN Position */
  432. #define USBD_ATTR_USBEN_Msk (0x1ul << USBD_ATTR_USBEN_Pos) /*!< USBD_T::ATTR: USBEN Mask */
  433. #define USBD_ATTR_DPPUEN_Pos (8) /*!< USBD_T::ATTR: DPPUEN Position */
  434. #define USBD_ATTR_DPPUEN_Msk (0x1ul << USBD_ATTR_DPPUEN_Pos) /*!< USBD_T::ATTR: DPPUEN Mask */
  435. #define USBD_ATTR_BYTEM_Pos (10) /*!< USBD_T::ATTR: BYTEM Position */
  436. #define USBD_ATTR_BYTEM_Msk (0x1ul << USBD_ATTR_BYTEM_Pos) /*!< USBD_T::ATTR: BYTEM Mask */
  437. #define USBD_ATTR_LPMACK_Pos (11) /*!< USBD_T::ATTR: LPMACK Position */
  438. #define USBD_ATTR_LPMACK_Msk (0x1ul << USBD_ATTR_LPMACK_Pos) /*!< USBD_T::ATTR: LPMACK Mask */
  439. #define USBD_ATTR_L1SUSPEND_Pos (12) /*!< USBD_T::ATTR: L1SUSPEND Position */
  440. #define USBD_ATTR_L1SUSPEND_Msk (0x1ul << USBD_ATTR_L1SUSPEND_Pos) /*!< USBD_T::ATTR: L1SUSPEND Mask */
  441. #define USBD_ATTR_L1RESUME_Pos (13) /*!< USBD_T::ATTR: L1RESUME Position */
  442. #define USBD_ATTR_L1RESUME_Msk (0x1ul << USBD_ATTR_L1RESUME_Pos) /*!< USBD_T::ATTR: L1RESUME Mask */
  443. #define USBD_VBUSDET_VBUSDET_Pos (0) /*!< USBD_T::VBUSDET: VBUSDET Position */
  444. #define USBD_VBUSDET_VBUSDET_Msk (0x1ul << USBD_VBUSDET_VBUSDET_Pos) /*!< USBD_T::VBUSDET: VBUSDET Mask */
  445. #define USBD_STBUFSEG_STBUFSEG_Pos (3) /*!< USBD_T::STBUFSEG: STBUFSEG Position */
  446. #define USBD_STBUFSEG_STBUFSEG_Msk (0x3ful << USBD_STBUFSEG_STBUFSEG_Pos) /*!< USBD_T::STBUFSEG: STBUFSEG Mask */
  447. #define USBD_EPSTS0_EPSTS0_Pos (0) /*!< USBD_T::EPSTS0: EPSTS0 Position */
  448. #define USBD_EPSTS0_EPSTS0_Msk (0xful << USBD_EPSTS0_EPSTS0_Pos) /*!< USBD_T::EPSTS0: EPSTS0 Mask */
  449. #define USBD_EPSTS0_EPSTS1_Pos (4) /*!< USBD_T::EPSTS0: EPSTS1 Position */
  450. #define USBD_EPSTS0_EPSTS1_Msk (0xful << USBD_EPSTS0_EPSTS1_Pos) /*!< USBD_T::EPSTS0: EPSTS1 Mask */
  451. #define USBD_EPSTS0_EPSTS2_Pos (8) /*!< USBD_T::EPSTS0: EPSTS2 Position */
  452. #define USBD_EPSTS0_EPSTS2_Msk (0xful << USBD_EPSTS0_EPSTS2_Pos) /*!< USBD_T::EPSTS0: EPSTS2 Mask */
  453. #define USBD_EPSTS0_EPSTS3_Pos (12) /*!< USBD_T::EPSTS0: EPSTS3 Position */
  454. #define USBD_EPSTS0_EPSTS3_Msk (0xful << USBD_EPSTS0_EPSTS3_Pos) /*!< USBD_T::EPSTS0: EPSTS3 Mask */
  455. #define USBD_EPSTS0_EPSTS4_Pos (16) /*!< USBD_T::EPSTS0: EPSTS4 Position */
  456. #define USBD_EPSTS0_EPSTS4_Msk (0xful << USBD_EPSTS0_EPSTS4_Pos) /*!< USBD_T::EPSTS0: EPSTS4 Mask */
  457. #define USBD_EPSTS0_EPSTS5_Pos (20) /*!< USBD_T::EPSTS0: EPSTS5 Position */
  458. #define USBD_EPSTS0_EPSTS5_Msk (0xful << USBD_EPSTS0_EPSTS5_Pos) /*!< USBD_T::EPSTS0: EPSTS5 Mask */
  459. #define USBD_EPSTS0_EPSTS6_Pos (24) /*!< USBD_T::EPSTS0: EPSTS6 Position */
  460. #define USBD_EPSTS0_EPSTS6_Msk (0xful << USBD_EPSTS0_EPSTS6_Pos) /*!< USBD_T::EPSTS0: EPSTS6 Mask */
  461. #define USBD_EPSTS0_EPSTS7_Pos (28) /*!< USBD_T::EPSTS0: EPSTS7 Position */
  462. #define USBD_EPSTS0_EPSTS7_Msk (0xful << USBD_EPSTS0_EPSTS7_Pos) /*!< USBD_T::EPSTS0: EPSTS7 Mask */
  463. #define USBD_LPMATTR_LPMLINKSTS_Pos (0) /*!< USBD_T::LPMATTR: LPMLINKSTS Position */
  464. #define USBD_LPMATTR_LPMLINKSTS_Msk (0xful << USBD_LPMATTR_LPMLINKSTS_Pos) /*!< USBD_T::LPMATTR: LPMLINKSTS Mask */
  465. #define USBD_LPMATTR_LPMBESL_Pos (4) /*!< USBD_T::LPMATTR: LPMBESL Position */
  466. #define USBD_LPMATTR_LPMBESL_Msk (0xful << USBD_LPMATTR_LPMBESL_Pos) /*!< USBD_T::LPMATTR: LPMBESL Mask */
  467. #define USBD_LPMATTR_LPMRWAKUP_Pos (8) /*!< USBD_T::LPMATTR: LPMRWAKUP Position */
  468. #define USBD_LPMATTR_LPMRWAKUP_Msk (0x1ul << USBD_LPMATTR_LPMRWAKUP_Pos) /*!< USBD_T::LPMATTR: LPMRWAKUP Mask */
  469. #define USBD_FN_FN_Pos (0) /*!< USBD_T::FN: FN Position */
  470. #define USBD_FN_FN_Msk (0x7fful << USBD_FN_FN_Pos) /*!< USBD_T::FN: FN Mask */
  471. #define USBD_SE0_SE0_Pos (0) /*!< USBD_T::SE0: SE0 Position */
  472. #define USBD_SE0_SE0_Msk (0x1ul << USBD_SE0_SE0_Pos) /*!< USBD_T::SE0: SE0 Mask */
  473. #define USBD_BUFSEG_BUFSEG_Pos (3) /*!< USBD_EP_T::BUFSEG: BUFSEG Position */
  474. #define USBD_BUFSEG_BUFSEG_Msk (0x3ful << USBD_BUFSEG_BUFSEG_Pos) /*!< USBD_EP_T::BUFSEG: BUFSEG Mask */
  475. #define USBD_MXPLD_MXPLD_Pos (0) /*!< USBD_EP_T::MXPLD: MXPLD Position */
  476. #define USBD_MXPLD_MXPLD_Msk (0x1fful << USBD_MXPLD_MXPLD_Pos) /*!< USBD_EP_T::MXPLD: MXPLD Mask */
  477. #define USBD_CFG_EPNUM_Pos (0) /*!< USBD_EP_T::CFG: EPNUM Position */
  478. #define USBD_CFG_EPNUM_Msk (0xful << USBD_CFG_EPNUM_Pos) /*!< USBD_EP_T::CFG: EPNUM Mask */
  479. #define USBD_CFG_ISOCH_Pos (4) /*!< USBD_EP_T::CFG: ISOCH Position */
  480. #define USBD_CFG_ISOCH_Msk (0x1ul << USBD_CFG_ISOCH_Pos) /*!< USBD_EP_T::CFG: ISOCH Mask */
  481. #define USBD_CFG_STATE_Pos (5) /*!< USBD_EP_T::CFG: STATE Position */
  482. #define USBD_CFG_STATE_Msk (0x3ul << USBD_CFG_STATE_Pos) /*!< USBD_EP_T::CFG: STATE Mask */
  483. #define USBD_CFG_DSQSYNC_Pos (7) /*!< USBD_EP_T::CFG: DSQSYNC Position */
  484. #define USBD_CFG_DSQSYNC_Msk (0x1ul << USBD_CFG_DSQSYNC_Pos) /*!< USBD_EP_T::CFG: DSQSYNC Mask */
  485. #define USBD_CFG_CSTALL_Pos (9) /*!< USBD_EP_T::CFG: CSTALL Position */
  486. #define USBD_CFG_CSTALL_Msk (0x1ul << USBD_CFG_CSTALL_Pos) /*!< USBD_EP_T::CFG: CSTALL Mask */
  487. #define USBD_CFGP_CLRRDY_Pos (0) /*!< USBD_EP_T::CFGP: CLRRDY Position */
  488. #define USBD_CFGP_CLRRDY_Msk (0x1ul << USBD_CFGP_CLRRDY_Pos) /*!< USBD_EP_T::CFGP: CLRRDY Mask */
  489. #define USBD_CFGP_SSTALL_Pos (1) /*!< USBD_EP_T::CFGP: SSTALL Position */
  490. #define USBD_CFGP_SSTALL_Msk (0x1ul << USBD_CFGP_SSTALL_Pos) /*!< USBD_EP_T::CFGP: SSTALL Mask */
  491. /**@}*/ /* USBD_CONST */
  492. /**@}*/ /* end of USBD register group */
  493. /**@}*/ /* end of REGISTER group */
  494. #if defined ( __CC_ARM )
  495. #pragma no_anon_unions
  496. #endif
  497. #endif /* __USBD_REG_H__ */