hw_usb.h 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  1. /******************************************************************************
  2. * Filename: hw_usb.h
  3. * Revised: $Date: 2013-04-30 17:13:44 +0200 (Tue, 30 Apr 2013) $
  4. * Revision: $Revision: 9943 $
  5. *
  6. * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
  7. *
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions
  11. * are met:
  12. *
  13. * Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. *
  16. * Redistributions in binary form must reproduce the above copyright
  17. * notice, this list of conditions and the following disclaimer in the
  18. * documentation and/or other materials provided with the distribution.
  19. *
  20. * Neither the name of Texas Instruments Incorporated nor the names of
  21. * its contributors may be used to endorse or promote products derived
  22. * from this software without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  25. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  26. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  27. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  28. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  29. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  30. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  31. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  32. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  33. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  34. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. *
  36. ******************************************************************************/
  37. #ifndef __HW_USB_H__
  38. #define __HW_USB_H__
  39. //*****************************************************************************
  40. //
  41. // The following are defines for the USB register offsets.
  42. //
  43. //*****************************************************************************
  44. #define USB_ADDR 0x40089000 // Function address
  45. #define USB_POW 0x40089004 // Power management and control
  46. // register
  47. #define USB_IIF 0x40089008 // Interrupt flags for endpoint 0
  48. // and IN endpoints 1-5
  49. #define USB_OIF 0x40089010 // Interrupt flags for OUT
  50. // endpoints 1-5
  51. #define USB_CIF 0x40089018 // Common USB interrupt flags
  52. #define USB_IIE 0x4008901C // Interrupt enable mask for IN
  53. // endpoints 1-5 and endpoint 0
  54. #define USB_OIE 0x40089024 // Interrupt enable mask for OUT
  55. // endpoints 1-5
  56. #define USB_CIE 0x4008902C // Common USB interrupt enable
  57. // mask
  58. #define USB_FRML 0x40089030 // Frame number (low byte)
  59. #define USB_FRMH 0x40089034 // Frame number (high byte)
  60. #define USB_INDEX 0x40089038 // Index register for selecting
  61. // the endpoint status and control
  62. // registers
  63. #define USB_CTRL 0x4008903C // USB peripheral control register
  64. #define USB_MAXI 0x40089040 // Indexed register: For USB_INDEX
  65. // = 1-5: Maximum packet size for
  66. // IN endpoint {1-5}
  67. #define USB_CS0_CSIL 0x40089044 // Indexed register: For USB_INDEX
  68. // = 0: Endpoint 0 control and
  69. // status For USB_INDEX = 1-5: IN
  70. // endpoint {1-5} control and
  71. // status (low byte)
  72. #define USB_CSIH 0x40089048 // Indexed register: For USB_INDEX
  73. // = 1-5: IN endpoint {1-5} control
  74. // and status (high byte)
  75. #define USB_MAXO 0x4008904C // Indexed register: For USB_INDEX
  76. // = 1-5: Maximum packet size for
  77. // OUT endpoint {1-5}
  78. #define USB_CSOL 0x40089050 // Indexed register: For USB_INDEX
  79. // = 1-5: OUT endpoint {1-5}
  80. // control and status (low byte)
  81. #define USB_CSOH 0x40089054 // Indexed register: For USB_INDEX
  82. // = 1-5: OUT endpoint {1-5}
  83. // control and status (high byte)
  84. #define USB_CNT0_CNTL 0x40089058 // Indexed register: For USB_INDEX
  85. // = 0: Number of received bytes in
  86. // the endpoint 0 FIFO For
  87. // USB_INDEX = 1-5: Number of
  88. // received bytes in the OUT
  89. // endpoint {1-5} FIFO (low byte)
  90. #define USB_CNTH 0x4008905C // Indexed register: For USB_INDEX
  91. // = 1-5: Number of received in the
  92. // OUT endpoint {1-5} FIFO (high
  93. // byte)
  94. #define USB_F0 0x40089080 // Endpoint 0 FIFO
  95. #define USB_F1 0x40089088 // IN/OUT endpoint 1 FIFO
  96. #define USB_F2 0x40089090 // IN/OUT endpoint 2 FIFO
  97. #define USB_F3 0x40089098 // IN/OUT endpoint 3 FIFO
  98. #define USB_F4 0x400890A0 // IN/OUT endpoint 4 FIFO
  99. #define USB_F5 0x400890A8 // IN/OUT endpoint 5 FIFO
  100. //*****************************************************************************
  101. //
  102. // The following are defines for the bit fields in the USB_ADDR register.
  103. //
  104. //*****************************************************************************
  105. #define USB_ADDR_UPDATE 0x00000080 // This bit is set by hardware
  106. // when writing to this register,
  107. // and is cleared by hardware when
  108. // the new address becomes
  109. // effective.
  110. #define USB_ADDR_UPDATE_M 0x00000080
  111. #define USB_ADDR_UPDATE_S 7
  112. #define USB_ADDR_USBADDR_M 0x0000007F // Device address. The address
  113. // shall be updated upon successful
  114. // completion of the status stage
  115. // of the SET_ADDRESS request.
  116. #define USB_ADDR_USBADDR_S 0
  117. //*****************************************************************************
  118. //
  119. // The following are defines for the bit fields in the USB_POW register.
  120. //
  121. //*****************************************************************************
  122. #define USB_POW_ISOWAITSOF 0x00000080 // For isochronous mode IN
  123. // endpoints: When set, the USB
  124. // controller will wait for an SOF
  125. // token from the time
  126. // USB_CSIL.INPKTRDY is set before
  127. // sending the packet. If an IN
  128. // token is received before an SOF
  129. // token, then a zero length data
  130. // packet will be sent.
  131. #define USB_POW_ISOWAITSOF_M 0x00000080
  132. #define USB_POW_ISOWAITSOF_S 7
  133. #define USB_POW_RST 0x00000008 // Indicates that reset signaling
  134. // is present on the bus
  135. #define USB_POW_RST_M 0x00000008
  136. #define USB_POW_RST_S 3
  137. #define USB_POW_RESUME 0x00000004 // Drives resume signaling for
  138. // remote wakeup According to the
  139. // USB Specification, the resume
  140. // signal must be held active for
  141. // at least 1 ms and no more than
  142. // 15 ms. It is recommended to keep
  143. // this bit set for approximately
  144. // 10 ms.
  145. #define USB_POW_RESUME_M 0x00000004
  146. #define USB_POW_RESUME_S 2
  147. #define USB_POW_SUSPEND 0x00000002 // Indicates entry into suspend
  148. // mode Suspend mode must be
  149. // enabled by setting
  150. // USB_POW.SUSPENDEN Software
  151. // clears this bit by reading the
  152. // USB_CIF register or by asserting
  153. // USB_POW.RESUME
  154. #define USB_POW_SUSPEND_M 0x00000002
  155. #define USB_POW_SUSPEND_S 1
  156. #define USB_POW_SUSPENDEN 0x00000001 // Enables detection of and entry
  157. // into suspend mode.
  158. #define USB_POW_SUSPENDEN_M 0x00000001
  159. #define USB_POW_SUSPENDEN_S 0
  160. //*****************************************************************************
  161. //
  162. // The following are defines for the bit fields in the USB_IIF register.
  163. //
  164. //*****************************************************************************
  165. #define USB_IIF_INEP5IF 0x00000020 // Interrupt flag for IN endpoint
  166. // 5 Cleared by hardware when read
  167. #define USB_IIF_INEP5IF_M 0x00000020
  168. #define USB_IIF_INEP5IF_S 5
  169. #define USB_IIF_INEP4IF 0x00000010 // Interrupt flag for IN endpoint
  170. // 4 Cleared by hardware when read
  171. #define USB_IIF_INEP4IF_M 0x00000010
  172. #define USB_IIF_INEP4IF_S 4
  173. #define USB_IIF_INEP3IF 0x00000008 // Interrupt flag for IN endpoint
  174. // 3 Cleared by hardware when read
  175. #define USB_IIF_INEP3IF_M 0x00000008
  176. #define USB_IIF_INEP3IF_S 3
  177. #define USB_IIF_INEP2IF 0x00000004 // Interrupt flag for IN endpoint
  178. // 2 Cleared by hardware when read
  179. #define USB_IIF_INEP2IF_M 0x00000004
  180. #define USB_IIF_INEP2IF_S 2
  181. #define USB_IIF_INEP1IF 0x00000002 // Interrupt flag for IN endpoint
  182. // 1 Cleared by hardware when read
  183. #define USB_IIF_INEP1IF_M 0x00000002
  184. #define USB_IIF_INEP1IF_S 1
  185. #define USB_IIF_EP0IF 0x00000001 // Interrupt flag for endpoint 0
  186. // Cleared by hardware when read
  187. #define USB_IIF_EP0IF_M 0x00000001
  188. #define USB_IIF_EP0IF_S 0
  189. //*****************************************************************************
  190. //
  191. // The following are defines for the bit fields in the USB_OIF register.
  192. //
  193. //*****************************************************************************
  194. #define USB_OIF_OUTEP5IF 0x00000020 // Interrupt flag for OUT endpoint
  195. // 5 Cleared by hardware when read
  196. #define USB_OIF_OUTEP5IF_M 0x00000020
  197. #define USB_OIF_OUTEP5IF_S 5
  198. #define USB_OIF_OUTEP4IF 0x00000010 // Interrupt flag for OUT endpoint
  199. // 4 Cleared by hardware when read
  200. #define USB_OIF_OUTEP4IF_M 0x00000010
  201. #define USB_OIF_OUTEP4IF_S 4
  202. #define USB_OIF_OUTEP3IF 0x00000008 // Interrupt flag for OUT endpoint
  203. // 3 Cleared by hardware when read
  204. #define USB_OIF_OUTEP3IF_M 0x00000008
  205. #define USB_OIF_OUTEP3IF_S 3
  206. #define USB_OIF_OUTEP2IF 0x00000004 // Interrupt flag for OUT endpoint
  207. // 2 Cleared by hardware when read
  208. #define USB_OIF_OUTEP2IF_M 0x00000004
  209. #define USB_OIF_OUTEP2IF_S 2
  210. #define USB_OIF_OUTEP1IF 0x00000002 // Interrupt flag for OUT endpoint
  211. // 1 Cleared by hardware when read
  212. #define USB_OIF_OUTEP1IF_M 0x00000002
  213. #define USB_OIF_OUTEP1IF_S 1
  214. //*****************************************************************************
  215. //
  216. // The following are defines for the bit fields in the USB_CIF register.
  217. //
  218. //*****************************************************************************
  219. #define USB_CIF_SOFIF 0x00000008 // Start-of-frame interrupt flag
  220. // Cleared by hardware when read
  221. #define USB_CIF_SOFIF_M 0x00000008
  222. #define USB_CIF_SOFIF_S 3
  223. #define USB_CIF_RSTIF 0x00000004 // Reset interrupt flag Cleared by
  224. // hardware when read
  225. #define USB_CIF_RSTIF_M 0x00000004
  226. #define USB_CIF_RSTIF_S 2
  227. #define USB_CIF_RESUMEIF 0x00000002 // Resume interrupt flag Cleared
  228. // by hardware when read
  229. #define USB_CIF_RESUMEIF_M 0x00000002
  230. #define USB_CIF_RESUMEIF_S 1
  231. #define USB_CIF_SUSPENDIF 0x00000001 // Suspend interrupt flag Cleared
  232. // by hardware when read
  233. #define USB_CIF_SUSPENDIF_M 0x00000001
  234. #define USB_CIF_SUSPENDIF_S 0
  235. //*****************************************************************************
  236. //
  237. // The following are defines for the bit fields in the USB_IIE register.
  238. //
  239. //*****************************************************************************
  240. #define USB_IIE_INEP5IE 0x00000020 // Interrupt enable for IN
  241. // endpoint 5 0: Interrupt disabled
  242. // 1: Interrupt enabled
  243. #define USB_IIE_INEP5IE_M 0x00000020
  244. #define USB_IIE_INEP5IE_S 5
  245. #define USB_IIE_INEP4IE 0x00000010 // Interrupt enable for IN
  246. // endpoint 4 0: Interrupt disabled
  247. // 1: Interrupt enabled
  248. #define USB_IIE_INEP4IE_M 0x00000010
  249. #define USB_IIE_INEP4IE_S 4
  250. #define USB_IIE_INEP3IE 0x00000008 // Interrupt enable for IN
  251. // endpoint 3 0: Interrupt disabled
  252. // 1: Interrupt enabled
  253. #define USB_IIE_INEP3IE_M 0x00000008
  254. #define USB_IIE_INEP3IE_S 3
  255. #define USB_IIE_INEP2IE 0x00000004 // Interrupt enable for IN
  256. // endpoint 2 0: Interrupt disabled
  257. // 1: Interrupt enabled
  258. #define USB_IIE_INEP2IE_M 0x00000004
  259. #define USB_IIE_INEP2IE_S 2
  260. #define USB_IIE_INEP1IE 0x00000002 // Interrupt enable for IN
  261. // endpoint 1 0: Interrupt disabled
  262. // 1: Interrupt enabled
  263. #define USB_IIE_INEP1IE_M 0x00000002
  264. #define USB_IIE_INEP1IE_S 1
  265. #define USB_IIE_EP0IE 0x00000001 // Interrupt enable for endpoint 0
  266. // 0: Interrupt disabled 1:
  267. // Interrupt enabled
  268. #define USB_IIE_EP0IE_M 0x00000001
  269. #define USB_IIE_EP0IE_S 0
  270. //*****************************************************************************
  271. //
  272. // The following are defines for the bit fields in the USB_OIE register.
  273. //
  274. //*****************************************************************************
  275. #define USB_OIE_reserved8_M 0x000000C0 // Reserved
  276. #define USB_OIE_reserved8_S 6
  277. #define USB_OIE_OUTEP5IE 0x00000020 // Interrupt enable for OUT
  278. // endpoint 5 0: Interrupt disabled
  279. // 1: Interrupt enabled
  280. #define USB_OIE_OUTEP5IE_M 0x00000020
  281. #define USB_OIE_OUTEP5IE_S 5
  282. #define USB_OIE_OUTEP4IE 0x00000010 // Interrupt enable for OUT
  283. // endpoint 4 0: Interrupt disabled
  284. // 1: Interrupt enabled
  285. #define USB_OIE_OUTEP4IE_M 0x00000010
  286. #define USB_OIE_OUTEP4IE_S 4
  287. #define USB_OIE_OUTEP3IE 0x00000008 // Interrupt enable for OUT
  288. // endpoint 3 0: Interrupt disabled
  289. // 1: Interrupt enabled
  290. #define USB_OIE_OUTEP3IE_M 0x00000008
  291. #define USB_OIE_OUTEP3IE_S 3
  292. #define USB_OIE_OUTEP2IE 0x00000004 // Interrupt enable for OUT
  293. // endpoint 2 0: Interrupt disabled
  294. // 1: Interrupt enabled
  295. #define USB_OIE_OUTEP2IE_M 0x00000004
  296. #define USB_OIE_OUTEP2IE_S 2
  297. #define USB_OIE_OUTEP1IE 0x00000002 // Interrupt enable for OUT
  298. // endpoint 1 0: Interrupt disabled
  299. // 1: Interrupt enabled
  300. #define USB_OIE_OUTEP1IE_M 0x00000002
  301. #define USB_OIE_OUTEP1IE_S 1
  302. //*****************************************************************************
  303. //
  304. // The following are defines for the bit fields in the USB_CIE register.
  305. //
  306. //*****************************************************************************
  307. #define USB_CIE_SOFIE 0x00000008 // Start-of-frame interrupt enable
  308. // 0: Interrupt disabled 1:
  309. // Interrupt enabled
  310. #define USB_CIE_SOFIE_M 0x00000008
  311. #define USB_CIE_SOFIE_S 3
  312. #define USB_CIE_RSTIE 0x00000004 // Reset interrupt enable 0:
  313. // Interrupt disabled 1: Interrupt
  314. // enabled
  315. #define USB_CIE_RSTIE_M 0x00000004
  316. #define USB_CIE_RSTIE_S 2
  317. #define USB_CIE_RESUMEIE 0x00000002 // Resume interrupt enable 0:
  318. // Interrupt disabled 1: Interrupt
  319. // enabled
  320. #define USB_CIE_RESUMEIE_M 0x00000002
  321. #define USB_CIE_RESUMEIE_S 1
  322. #define USB_CIE_SUSPENDIE 0x00000001 // Suspend interrupt enable 0:
  323. // Interrupt disabled 1: Interrupt
  324. // enabled
  325. #define USB_CIE_SUSPENDIE_M 0x00000001
  326. #define USB_CIE_SUSPENDIE_S 0
  327. //*****************************************************************************
  328. //
  329. // The following are defines for the bit fields in the USB_FRML register.
  330. //
  331. //*****************************************************************************
  332. #define USB_FRML_FRAMEL_M 0x000000FF // Bits 7:0 of the 11-bit frame
  333. // number The frame number is only
  334. // updated upon successful
  335. // reception of SOF tokens
  336. #define USB_FRML_FRAMEL_S 0
  337. //*****************************************************************************
  338. //
  339. // The following are defines for the bit fields in the USB_FRMH register.
  340. //
  341. //*****************************************************************************
  342. #define USB_FRMH_FRAMEH_M 0x00000007 // Bits 10:8 of the 11-bit frame
  343. // number The frame number is only
  344. // updated upon successful
  345. // reception of SOF tokens
  346. #define USB_FRMH_FRAMEH_S 0
  347. //*****************************************************************************
  348. //
  349. // The following are defines for the bit fields in the USB_INDEX register.
  350. //
  351. //*****************************************************************************
  352. #define USB_INDEX_USBINDEX_M 0x0000000F // Index of the currently selected
  353. // endpoint The index is set to 0
  354. // to enable access to endpoint 0
  355. // control and status registers The
  356. // index is set to 1, 2, 3, 4 or 5
  357. // to enable access to IN/OUT
  358. // endpoint 1, 2, 3, 4 or 5 control
  359. // and status registers,
  360. // respectively
  361. #define USB_INDEX_USBINDEX_S 0
  362. //*****************************************************************************
  363. //
  364. // The following are defines for the bit fields in the USB_CTRL register.
  365. //
  366. //*****************************************************************************
  367. #define USB_CTRL_PLLLOCKED 0x00000080 // PLL lock status. The PLL is
  368. // locked when USB_CTRL.PLLLOCKED
  369. // is 1.
  370. #define USB_CTRL_PLLLOCKED_M 0x00000080
  371. #define USB_CTRL_PLLLOCKED_S 7
  372. #define USB_CTRL_PLLEN 0x00000002 // 48 MHz USB PLL enable When this
  373. // bit is set, the 48 MHz PLL is
  374. // started. Software must avoid
  375. // access to other USB registers
  376. // before the PLL has locked; that
  377. // is, USB_CTRL.PLLLOCKED is 1.
  378. // This bit can be set only when
  379. // USB_CTRL.USBEN is 1. The PLL
  380. // must be disabled before entering
  381. // PM1 when suspended, and must be
  382. // re-enabled when resuming
  383. // operation.
  384. #define USB_CTRL_PLLEN_M 0x00000002
  385. #define USB_CTRL_PLLEN_S 1
  386. #define USB_CTRL_USBEN 0x00000001 // USB enable The USB controller
  387. // is reset when this bit is
  388. // cleared
  389. #define USB_CTRL_USBEN_M 0x00000001
  390. #define USB_CTRL_USBEN_S 0
  391. //*****************************************************************************
  392. //
  393. // The following are defines for the bit fields in the USB_MAXI register.
  394. //
  395. //*****************************************************************************
  396. #define USB_MAXI_USBMAXI_M 0x000000FF // Maximum packet size, in units
  397. // of 8 bytes, for the selected IN
  398. // endpoint The value of this
  399. // register should match the
  400. // wMaxPacketSize field in the
  401. // standard endpoint descriptor for
  402. // the endpoint. The value must not
  403. // exceed the available memory.
  404. #define USB_MAXI_USBMAXI_S 0
  405. //*****************************************************************************
  406. //
  407. // The following are defines for the bit fields in the USB_CS0_CSIL register.
  408. //
  409. //*****************************************************************************
  410. #define USB_CS0_CSIL_CLROUTPKTRDY_or_CLRDATATOG \
  411. 0x00000040 // USB_CS0.CLROUTPKTRDY [RW]:
  412. // Software sets this bit to clear
  413. // the USB_CS0.OUTPKTRDY bit. It is
  414. // cleared automatically.
  415. // USB_CSIL.CLRDATATOG [RW]:
  416. // Software sets this bit to reset
  417. // the IN endpoint data toggle to
  418. // 0.
  419. #define USB_CS0_CSIL_CLROUTPKTRDY_or_CLRDATATOG_M \
  420. 0x00000040
  421. #define USB_CS0_CSIL_CLROUTPKTRDY_or_CLRDATATOG_S 6
  422. #define USB_CS0_CSIL_SENDSTALL_or_SENTSTALL \
  423. 0x00000020 // USB_CS0.SENDSTALL [RW]:
  424. // Software sets this bit to
  425. // terminate the current
  426. // transaction with a STALL
  427. // handshake. The bit is cleared
  428. // automatically when the STALL
  429. // handshake has been transmitted.
  430. // USB_CSIL.SENTSTALL [RW]: For
  431. // bulk/interrupt mode IN
  432. // endpoints: This bit is set when
  433. // a STALL handshake is
  434. // transmitted. The FIFO is flushed
  435. // and the USB_CSIL.INPKTRDY bit
  436. // cleared. Software should clear
  437. // this bit.
  438. #define USB_CS0_CSIL_SENDSTALL_or_SENTSTALL_M \
  439. 0x00000020
  440. #define USB_CS0_CSIL_SENDSTALL_or_SENTSTALL_S 5
  441. #define USB_CS0_CSIL_SETUPEND_or_SENDSTALL \
  442. 0x00000010 // USB_CS0.SETUPEND [RO]: This bit
  443. // is set when a control
  444. // transaction ends before the
  445. // USB_CS0.DATAEND bit has been
  446. // set. An interrupt is generated
  447. // and the FIFO flushed at this
  448. // time. Software clears this bit
  449. // by setting USB_CS0.CLRSETUPEND.
  450. // CSIL.SENDSTALL [RW]: For
  451. // bulk/interrupt mode IN
  452. // endpoints: Software sets this
  453. // bit to issue a STALL handshake.
  454. // Software clears this bit to
  455. // terminate the stall condition.
  456. #define USB_CS0_CSIL_SETUPEND_or_SENDSTALL_M \
  457. 0x00000010
  458. #define USB_CS0_CSIL_SETUPEND_or_SENDSTALL_S 4
  459. #define USB_CS0_CSIL_DATAEND_or_FLUSHPACKET \
  460. 0x00000008 // USB_CS0.DATAEND [RW]: This bit
  461. // is used to signal the end of the
  462. // data stage, and must be set: 1.
  463. // When the last data packet is
  464. // loaded and USB_CS0.INPKTRDY is
  465. // set. 2. When the last data
  466. // packet is unloaded and
  467. // USB_CS0.CLROUTPKTRDY is set. 3.
  468. // When USB_CS0.INPKTRDY is set to
  469. // send a zero-length packet. The
  470. // USB controller clears this bit
  471. // automatically.
  472. // USB_CSIL.FLUSHPACKET [RW]:
  473. // Software sets this bit to flush
  474. // the next packet to be
  475. // transmitted from the IN endpoint
  476. // FIFO. The FIFO pointer is reset
  477. // and the USB_CSIL.INPKTRDY bit is
  478. // cleared. Note: If the FIFO
  479. // contains two packets,
  480. // USB_CSIL.FLUSHPACKET will need
  481. // to be set twice to completely
  482. // clear the FIFO.
  483. #define USB_CS0_CSIL_DATAEND_or_FLUSHPACKET_M \
  484. 0x00000008
  485. #define USB_CS0_CSIL_DATAEND_or_FLUSHPACKET_S 3
  486. #define USB_CS0_CSIL_SENTSTALL_or_UNDERRUN \
  487. 0x00000004 // USB_CS0.SENTSTALL [RW]: This
  488. // bit is set when a STALL
  489. // handshake is sent. An interrupt
  490. // is generated is generated when
  491. // this bit is set. Software must
  492. // clear this bit.
  493. // USB_CSIL.UNDERRUN [RW]: In
  494. // isochronous mode, this bit is
  495. // set when a zero length data
  496. // packet is sent after receiving
  497. // an IN token with
  498. // USB_CSIL.INPKTRDY not set. In
  499. // bulk/interrupt mode, this bit is
  500. // set when a NAK is returned in
  501. // response to an IN token.
  502. // Software should clear this bit.
  503. #define USB_CS0_CSIL_SENTSTALL_or_UNDERRUN_M \
  504. 0x00000004
  505. #define USB_CS0_CSIL_SENTSTALL_or_UNDERRUN_S 2
  506. #define USB_CS0_CSIL_INPKTRDY_or_PKTPRESENT \
  507. 0x00000002 // USB_CS0. INPKTRDY [RW]:
  508. // Software sets this bit after
  509. // loading a data packet into the
  510. // endpoint 0 FIFO. It is cleared
  511. // automatically when the data
  512. // packet has been transmitted. An
  513. // interrupt is generated when the
  514. // bit is cleared.
  515. // USB_CSIL.PKTPRESENT [RO]: This
  516. // bit is set when there is at
  517. // least one packet in the IN
  518. // endpoint FIFO.
  519. #define USB_CS0_CSIL_INPKTRDY_or_PKTPRESENT_M \
  520. 0x00000002
  521. #define USB_CS0_CSIL_INPKTRDY_or_PKTPRESENT_S 1
  522. #define USB_CS0_CSIL_OUTPKTRDY_or_INPKTRDY \
  523. 0x00000001 // USB_CS0.OUTPKTRDY [RO]:
  524. // Endpoint 0 data packet received
  525. // An interrupt request (EP0) is
  526. // generated if the interrupt is
  527. // enabled. Software must read the
  528. // endpoint 0 FIFO empty, and clear
  529. // this bit by setting
  530. // USB_CS0.CLROUTPKTRDY
  531. // USB_CSIL.INPKTRDY [RW]: IN
  532. // endpoint {1-5} packet transfer
  533. // pending Software sets this bit
  534. // after loading a data packet into
  535. // the FIFO. It is cleared
  536. // automatically when a data packet
  537. // has been transmitted. An
  538. // interrupt is generated (if
  539. // enabled) when the bit is
  540. // cleared. When using
  541. // double-buffering, the bit is
  542. // cleared immediately if the other
  543. // FIFO is empty.
  544. #define USB_CS0_CSIL_OUTPKTRDY_or_INPKTRDY_M \
  545. 0x00000001
  546. #define USB_CS0_CSIL_OUTPKTRDY_or_INPKTRDY_S 0
  547. //*****************************************************************************
  548. //
  549. // The following are defines for the bit fields in the USB_CSIH register.
  550. //
  551. //*****************************************************************************
  552. #define USB_CSIH_AUTISET 0x00000080 // If set by software, the
  553. // USB_CSIL.INPKTRDY bit is
  554. // automatically set when a data
  555. // packet of maximum size
  556. // (specified by USBMAXI) is loaded
  557. // into the IN endpoint FIFO. If a
  558. // packet of less than the maximum
  559. // packet size is loaded, then
  560. // USB_CSIL.INPKTRDY will have to
  561. // be set manually.
  562. #define USB_CSIH_AUTISET_M 0x00000080
  563. #define USB_CSIH_AUTISET_S 7
  564. #define USB_CSIH_ISO 0x00000040 // Selects IN endpoint type: 0:
  565. // Bulk/interrupt 1: Isochronous
  566. #define USB_CSIH_ISO_M 0x00000040
  567. #define USB_CSIH_ISO_S 6
  568. #define USB_CSIH_FORCEDATATOG 0x00000008 // Software sets this bit to force
  569. // the IN endpoint's data toggle to
  570. // switch after each data packet is
  571. // sent regardless of whether an
  572. // ACK was received. This can be
  573. // used by interrupt IN endpoints
  574. // which are used to communicate
  575. // rate feedback for isochronous
  576. // endpoints.
  577. #define USB_CSIH_FORCEDATATOG_M 0x00000008
  578. #define USB_CSIH_FORCEDATATOG_S 3
  579. #define USB_CSIH_INDBLBUF 0x00000001 // IN endpoint FIFO
  580. // double-buffering enable: 0:
  581. // Double buffering disabled 1:
  582. // Double buffering enabled
  583. #define USB_CSIH_INDBLBUF_M 0x00000001
  584. #define USB_CSIH_INDBLBUF_S 0
  585. //*****************************************************************************
  586. //
  587. // The following are defines for the bit fields in the USB_MAXO register.
  588. //
  589. //*****************************************************************************
  590. #define USB_MAXO_USBMAXO_M 0x000000FF // Maximum packet size, in units
  591. // of 8 bytes, for the selected OUT
  592. // endpoint The value of this
  593. // register should match the
  594. // wMaxPacketSize field in the
  595. // standard endpoint descriptor for
  596. // the endpoint. The value must not
  597. // exceed the available memory.
  598. #define USB_MAXO_USBMAXO_S 0
  599. //*****************************************************************************
  600. //
  601. // The following are defines for the bit fields in the USB_CSOL register.
  602. //
  603. //*****************************************************************************
  604. #define USB_CSOL_CLRDATATOG 0x00000080 // Software sets this bit to reset
  605. // the endpoint data toggle to 0.
  606. #define USB_CSOL_CLRDATATOG_M 0x00000080
  607. #define USB_CSOL_CLRDATATOG_S 7
  608. #define USB_CSOL_SENTSTALL 0x00000040 // This bit is set when a STALL
  609. // handshake is transmitted. An
  610. // interrupt is generated when this
  611. // bit is set. Software should
  612. // clear this bit.
  613. #define USB_CSOL_SENTSTALL_M 0x00000040
  614. #define USB_CSOL_SENTSTALL_S 6
  615. #define USB_CSOL_SENDSTALL 0x00000020 // For bulk/interrupt mode OUT
  616. // endpoints: Software sets this
  617. // bit to issue a STALL handshake.
  618. // Software clears this bit to
  619. // terminate the stall condition.
  620. #define USB_CSOL_SENDSTALL_M 0x00000020
  621. #define USB_CSOL_SENDSTALL_S 5
  622. #define USB_CSOL_FLUSHPACKET 0x00000010 // Software sets this bit to flush
  623. // the next packet to be read from
  624. // the endpoint OUT FIFO. Note: If
  625. // the FIFO contains two packets,
  626. // USB_CSOL.FLUSHPACKET will need
  627. // to be set twice to completely
  628. // clear the FIFO.
  629. #define USB_CSOL_FLUSHPACKET_M 0x00000010
  630. #define USB_CSOL_FLUSHPACKET_S 4
  631. #define USB_CSOL_DATAERROR 0x00000008 // For isochronous mode OUT
  632. // endpoints: This bit is set when
  633. // USB_CSOL.OUTPKTRDY is set if the
  634. // data packet has a CRC or
  635. // bit-stuff error. It is cleared
  636. // automatically when
  637. // USB_CSOL.OUTPKTRDY is cleared.
  638. #define USB_CSOL_DATAERROR_M 0x00000008
  639. #define USB_CSOL_DATAERROR_S 3
  640. #define USB_CSOL_OVERRUN 0x00000004 // For isochronous mode OUT
  641. // endpoints: This bit is set when
  642. // an OUT packet cannot be loaded
  643. // into the OUT endpoint FIFO.
  644. // Firmware should clear this bit.
  645. #define USB_CSOL_OVERRUN_M 0x00000004
  646. #define USB_CSOL_OVERRUN_S 2
  647. #define USB_CSOL_FIFOFULL 0x00000002 // This bit is set when no more
  648. // packets can be loaded into the
  649. // OUT endpoint FIFO.
  650. #define USB_CSOL_FIFOFULL_M 0x00000002
  651. #define USB_CSOL_FIFOFULL_S 1
  652. #define USB_CSOL_OUTPKTRDY 0x00000001 // This bit is set when a data
  653. // packet has been received.
  654. // Software should clear this bit
  655. // when the packet has been
  656. // unloaded from the OUT endpoint
  657. // FIFO. An interrupt is generated
  658. // when the bit is set.
  659. #define USB_CSOL_OUTPKTRDY_M 0x00000001
  660. #define USB_CSOL_OUTPKTRDY_S 0
  661. //*****************************************************************************
  662. //
  663. // The following are defines for the bit fields in the USB_CSOH register.
  664. //
  665. //*****************************************************************************
  666. #define USB_CSOH_AUTOCLEAR 0x00000080 // If software sets this bit, the
  667. // USB_CSOL.OUTPKTRDY bit will be
  668. // automatically cleared when a
  669. // packet of maximum size
  670. // (specified by USB_MAXO) has been
  671. // unloaded from the OUT FIFO. When
  672. // packets of less than the maximum
  673. // packet size are unloaded,
  674. // USB_CSOL.OUTPKTRDY will have to
  675. // be cleared manually.
  676. #define USB_CSOH_AUTOCLEAR_M 0x00000080
  677. #define USB_CSOH_AUTOCLEAR_S 7
  678. #define USB_CSOH_ISO 0x00000040 // Selects OUT endpoint type: 0:
  679. // Bulk/interrupt 1: Isochronous
  680. #define USB_CSOH_ISO_M 0x00000040
  681. #define USB_CSOH_ISO_S 6
  682. #define USB_CSOH_OUTDBLBUF 0x00000001 // OUT endpoint FIFO
  683. // double-buffering enable: 0:
  684. // Double buffering disabled 1:
  685. // Double buffering enabled
  686. #define USB_CSOH_OUTDBLBUF_M 0x00000001
  687. #define USB_CSOH_OUTDBLBUF_S 0
  688. //*****************************************************************************
  689. //
  690. // The following are defines for the bit fields in the
  691. // USB_CNT0_CNTL register.
  692. //
  693. //*****************************************************************************
  694. #define USB_CNT0_CNTL_FIFOCNT_or_FIFOCNTL_M \
  695. 0x000000FF // USB_CS0.FIFOCNT (USBINDEX = 0)
  696. // [RO]: Number of bytes received
  697. // in the packet in the endpoint 0
  698. // FIFO Valid only when
  699. // USB_CS0.OUTPKTRDY is set
  700. // USB_CSIL.FIFOCNTL (USBINDEX = 1
  701. // to 5) [RW]: Bits 7:0 of the of
  702. // the number of bytes received in
  703. // the packet in the OUT endpoint
  704. // {1-5} FIFO Valid only when
  705. // USB_CSOL.OUTPKTRDY is set
  706. #define USB_CNT0_CNTL_FIFOCNT_or_FIFOCNTL_S 0
  707. //*****************************************************************************
  708. //
  709. // The following are defines for the bit fields in the USB_CNTH register.
  710. //
  711. //*****************************************************************************
  712. #define USB_CNTH_FIFOCNTH_M 0x00000007 // Bits 10:8 of the of the number
  713. // of bytes received in the packet
  714. // in the OUT endpoint {1-5} FIFO
  715. // Valid only when
  716. // USB_CSOL.OUTPKTRDY is set
  717. #define USB_CNTH_FIFOCNTH_S 0
  718. //*****************************************************************************
  719. //
  720. // The following are defines for the bit fields in the USB_F0 register.
  721. //
  722. //*****************************************************************************
  723. #define USB_F0_USBF0_M 0x000000FF // Endpoint 0 FIFO Reading this
  724. // register unloads one byte from
  725. // the endpoint 0 FIFO. Writing to
  726. // this register loads one byte
  727. // into the endpoint 0 FIFO. The
  728. // FIFO memory for EP0 is used for
  729. // incoming and outgoing data
  730. // packets.
  731. #define USB_F0_USBF0_S 0
  732. //*****************************************************************************
  733. //
  734. // The following are defines for the bit fields in the USB_F1 register.
  735. //
  736. //*****************************************************************************
  737. #define USB_F1_USBF1_M 0x000000FF // Endpoint 1 FIFO register
  738. // Reading this register unloads
  739. // one byte from the EP1 OUT FIFO.
  740. // Writing to this register loads
  741. // one byte into the EP1 IN FIFO.
  742. #define USB_F1_USBF1_S 0
  743. //*****************************************************************************
  744. //
  745. // The following are defines for the bit fields in the USB_F2 register.
  746. //
  747. //*****************************************************************************
  748. #define USB_F2_USBF2_M 0x000000FF // Endpoint 2 FIFO register
  749. // Reading this register unloads
  750. // one byte from the EP2 OUT FIFO.
  751. // Writing to this register loads
  752. // one byte into the EP2 IN FIFO.
  753. #define USB_F2_USBF2_S 0
  754. //*****************************************************************************
  755. //
  756. // The following are defines for the bit fields in the USB_F3 register.
  757. //
  758. //*****************************************************************************
  759. #define USB_F3_USBF3_M 0x000000FF // Endpoint 3 FIFO register
  760. // Reading this register unloads
  761. // one byte from the EP3 OUT FIFO.
  762. // Writing to this register loads
  763. // one byte into the EP3 IN FIFO.
  764. #define USB_F3_USBF3_S 0
  765. //*****************************************************************************
  766. //
  767. // The following are defines for the bit fields in the USB_F4 register.
  768. //
  769. //*****************************************************************************
  770. #define USB_F4_USBF4_M 0x000000FF // Endpoint 4 FIFO register
  771. // Reading this register unloads
  772. // one byte from the EP4 OUT FIFO.
  773. // Writing to this register loads
  774. // one byte into the EP4 IN FIFO.
  775. #define USB_F4_USBF4_S 0
  776. //*****************************************************************************
  777. //
  778. // The following are defines for the bit fields in the USB_F5 register.
  779. //
  780. //*****************************************************************************
  781. #define USB_F5_USBF5_M 0x000000FF // Endpoint 5 FIFO register
  782. // Reading this register unloads
  783. // one byte from the EP5 OUT FIFO.
  784. // Writing to this register loads
  785. // one byte into the EP5 IN FIFO.
  786. #define USB_F5_USBF5_S 0
  787. #endif // __HW_USB_H__