1
0

hw_uart.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. //*****************************************************************************
  2. //
  3. // hw_uart.h - Macros and defines used when accessing the UART hardware.
  4. //
  5. // Copyright (c) 2005-2014 Texas Instruments Incorporated. All rights reserved.
  6. // Software License Agreement
  7. //
  8. // Redistribution and use in source and binary forms, with or without
  9. // modification, are permitted provided that the following conditions
  10. // are met:
  11. //
  12. // Redistributions of source code must retain the above copyright
  13. // notice, this list of conditions and the following disclaimer.
  14. //
  15. // Redistributions in binary form must reproduce the above copyright
  16. // notice, this list of conditions and the following disclaimer in the
  17. // documentation and/or other materials provided with the
  18. // 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. // This is part of revision 2.1.0.12573 of the Tiva Firmware Development Package.
  37. //
  38. //*****************************************************************************
  39. #ifndef __HW_UART_H__
  40. #define __HW_UART_H__
  41. //*****************************************************************************
  42. //
  43. // The following are defines for the UART register offsets.
  44. //
  45. //*****************************************************************************
  46. #define UART_O_DR 0x00000000 // UART Data
  47. #define UART_O_RSR 0x00000004 // UART Receive Status/Error Clear
  48. #define UART_O_ECR 0x00000004 // UART Receive Status/Error Clear
  49. #define UART_O_FR 0x00000018 // UART Flag
  50. #define UART_O_ILPR 0x00000020 // UART IrDA Low-Power Register
  51. #define UART_O_IBRD 0x00000024 // UART Integer Baud-Rate Divisor
  52. #define UART_O_FBRD 0x00000028 // UART Fractional Baud-Rate
  53. // Divisor
  54. #define UART_O_LCRH 0x0000002C // UART Line Control
  55. #define UART_O_CTL 0x00000030 // UART Control
  56. #define UART_O_IFLS 0x00000034 // UART Interrupt FIFO Level Select
  57. #define UART_O_IM 0x00000038 // UART Interrupt Mask
  58. #define UART_O_RIS 0x0000003C // UART Raw Interrupt Status
  59. #define UART_O_MIS 0x00000040 // UART Masked Interrupt Status
  60. #define UART_O_ICR 0x00000044 // UART Interrupt Clear
  61. #define UART_O_DMACTL 0x00000048 // UART DMA Control
  62. #define UART_O_9BITADDR 0x000000A4 // UART 9-Bit Self Address
  63. #define UART_O_9BITAMASK 0x000000A8 // UART 9-Bit Self Address Mask
  64. #define UART_O_PP 0x00000FC0 // UART Peripheral Properties
  65. #define UART_O_CC 0x00000FC8 // UART Clock Configuration
  66. //*****************************************************************************
  67. //
  68. // The following are defines for the bit fields in the UART_O_DR register.
  69. //
  70. //*****************************************************************************
  71. #define UART_DR_OE 0x00000800 // UART Overrun Error
  72. #define UART_DR_BE 0x00000400 // UART Break Error
  73. #define UART_DR_PE 0x00000200 // UART Parity Error
  74. #define UART_DR_FE 0x00000100 // UART Framing Error
  75. #define UART_DR_DATA_M 0x000000FF // Data Transmitted or Received
  76. #define UART_DR_DATA_S 0
  77. //*****************************************************************************
  78. //
  79. // The following are defines for the bit fields in the UART_O_RSR register.
  80. //
  81. //*****************************************************************************
  82. #define UART_RSR_OE 0x00000008 // UART Overrun Error
  83. #define UART_RSR_BE 0x00000004 // UART Break Error
  84. #define UART_RSR_PE 0x00000002 // UART Parity Error
  85. #define UART_RSR_FE 0x00000001 // UART Framing Error
  86. //*****************************************************************************
  87. //
  88. // The following are defines for the bit fields in the UART_O_ECR register.
  89. //
  90. //*****************************************************************************
  91. #define UART_ECR_DATA_M 0x000000FF // Error Clear
  92. #define UART_ECR_DATA_S 0
  93. //*****************************************************************************
  94. //
  95. // The following are defines for the bit fields in the UART_O_FR register.
  96. //
  97. //*****************************************************************************
  98. #define UART_FR_RI 0x00000100 // Ring Indicator
  99. #define UART_FR_TXFE 0x00000080 // UART Transmit FIFO Empty
  100. #define UART_FR_RXFF 0x00000040 // UART Receive FIFO Full
  101. #define UART_FR_TXFF 0x00000020 // UART Transmit FIFO Full
  102. #define UART_FR_RXFE 0x00000010 // UART Receive FIFO Empty
  103. #define UART_FR_BUSY 0x00000008 // UART Busy
  104. #define UART_FR_DCD 0x00000004 // Data Carrier Detect
  105. #define UART_FR_DSR 0x00000002 // Data Set Ready
  106. #define UART_FR_CTS 0x00000001 // Clear To Send
  107. //*****************************************************************************
  108. //
  109. // The following are defines for the bit fields in the UART_O_ILPR register.
  110. //
  111. //*****************************************************************************
  112. #define UART_ILPR_ILPDVSR_M 0x000000FF // IrDA Low-Power Divisor
  113. #define UART_ILPR_ILPDVSR_S 0
  114. //*****************************************************************************
  115. //
  116. // The following are defines for the bit fields in the UART_O_IBRD register.
  117. //
  118. //*****************************************************************************
  119. #define UART_IBRD_DIVINT_M 0x0000FFFF // Integer Baud-Rate Divisor
  120. #define UART_IBRD_DIVINT_S 0
  121. //*****************************************************************************
  122. //
  123. // The following are defines for the bit fields in the UART_O_FBRD register.
  124. //
  125. //*****************************************************************************
  126. #define UART_FBRD_DIVFRAC_M 0x0000003F // Fractional Baud-Rate Divisor
  127. #define UART_FBRD_DIVFRAC_S 0
  128. //*****************************************************************************
  129. //
  130. // The following are defines for the bit fields in the UART_O_LCRH register.
  131. //
  132. //*****************************************************************************
  133. #define UART_LCRH_SPS 0x00000080 // UART Stick Parity Select
  134. #define UART_LCRH_WLEN_M 0x00000060 // UART Word Length
  135. #define UART_LCRH_WLEN_5 0x00000000 // 5 bits (default)
  136. #define UART_LCRH_WLEN_6 0x00000020 // 6 bits
  137. #define UART_LCRH_WLEN_7 0x00000040 // 7 bits
  138. #define UART_LCRH_WLEN_8 0x00000060 // 8 bits
  139. #define UART_LCRH_FEN 0x00000010 // UART Enable FIFOs
  140. #define UART_LCRH_STP2 0x00000008 // UART Two Stop Bits Select
  141. #define UART_LCRH_EPS 0x00000004 // UART Even Parity Select
  142. #define UART_LCRH_PEN 0x00000002 // UART Parity Enable
  143. #define UART_LCRH_BRK 0x00000001 // UART Send Break
  144. //*****************************************************************************
  145. //
  146. // The following are defines for the bit fields in the UART_O_CTL register.
  147. //
  148. //*****************************************************************************
  149. #define UART_CTL_CTSEN 0x00008000 // Enable Clear To Send
  150. #define UART_CTL_RTSEN 0x00004000 // Enable Request to Send
  151. #define UART_CTL_RTS 0x00000800 // Request to Send
  152. #define UART_CTL_DTR 0x00000400 // Data Terminal Ready
  153. #define UART_CTL_RXE 0x00000200 // UART Receive Enable
  154. #define UART_CTL_TXE 0x00000100 // UART Transmit Enable
  155. #define UART_CTL_LBE 0x00000080 // UART Loop Back Enable
  156. #define UART_CTL_HSE 0x00000020 // High-Speed Enable
  157. #define UART_CTL_EOT 0x00000010 // End of Transmission
  158. #define UART_CTL_SMART 0x00000008 // ISO 7816 Smart Card Support
  159. #define UART_CTL_SIRLP 0x00000004 // UART SIR Low-Power Mode
  160. #define UART_CTL_SIREN 0x00000002 // UART SIR Enable
  161. #define UART_CTL_UARTEN 0x00000001 // UART Enable
  162. //*****************************************************************************
  163. //
  164. // The following are defines for the bit fields in the UART_O_IFLS register.
  165. //
  166. //*****************************************************************************
  167. #define UART_IFLS_RX_M 0x00000038 // UART Receive Interrupt FIFO
  168. // Level Select
  169. #define UART_IFLS_RX1_8 0x00000000 // RX FIFO >= 1/8 full
  170. #define UART_IFLS_RX2_8 0x00000008 // RX FIFO >= 1/4 full
  171. #define UART_IFLS_RX4_8 0x00000010 // RX FIFO >= 1/2 full (default)
  172. #define UART_IFLS_RX6_8 0x00000018 // RX FIFO >= 3/4 full
  173. #define UART_IFLS_RX7_8 0x00000020 // RX FIFO >= 7/8 full
  174. #define UART_IFLS_TX_M 0x00000007 // UART Transmit Interrupt FIFO
  175. // Level Select
  176. #define UART_IFLS_TX1_8 0x00000000 // TX FIFO <= 1/8 full
  177. #define UART_IFLS_TX2_8 0x00000001 // TX FIFO <= 1/4 full
  178. #define UART_IFLS_TX4_8 0x00000002 // TX FIFO <= 1/2 full (default)
  179. #define UART_IFLS_TX6_8 0x00000003 // TX FIFO <= 3/4 full
  180. #define UART_IFLS_TX7_8 0x00000004 // TX FIFO <= 7/8 full
  181. //*****************************************************************************
  182. //
  183. // The following are defines for the bit fields in the UART_O_IM register.
  184. //
  185. //*****************************************************************************
  186. #define UART_IM_DMATXIM 0x00020000 // Transmit DMA Interrupt Mask
  187. #define UART_IM_DMARXIM 0x00010000 // Receive DMA Interrupt Mask
  188. #define UART_IM_9BITIM 0x00001000 // 9-Bit Mode Interrupt Mask
  189. #define UART_IM_EOTIM 0x00000800 // End of Transmission Interrupt
  190. // Mask
  191. #define UART_IM_OEIM 0x00000400 // UART Overrun Error Interrupt
  192. // Mask
  193. #define UART_IM_BEIM 0x00000200 // UART Break Error Interrupt Mask
  194. #define UART_IM_PEIM 0x00000100 // UART Parity Error Interrupt Mask
  195. #define UART_IM_FEIM 0x00000080 // UART Framing Error Interrupt
  196. // Mask
  197. #define UART_IM_RTIM 0x00000040 // UART Receive Time-Out Interrupt
  198. // Mask
  199. #define UART_IM_TXIM 0x00000020 // UART Transmit Interrupt Mask
  200. #define UART_IM_RXIM 0x00000010 // UART Receive Interrupt Mask
  201. #define UART_IM_DSRMIM 0x00000008 // UART Data Set Ready Modem
  202. // Interrupt Mask
  203. #define UART_IM_DCDMIM 0x00000004 // UART Data Carrier Detect Modem
  204. // Interrupt Mask
  205. #define UART_IM_CTSMIM 0x00000002 // UART Clear to Send Modem
  206. // Interrupt Mask
  207. #define UART_IM_RIMIM 0x00000001 // UART Ring Indicator Modem
  208. // Interrupt Mask
  209. //*****************************************************************************
  210. //
  211. // The following are defines for the bit fields in the UART_O_RIS register.
  212. //
  213. //*****************************************************************************
  214. #define UART_RIS_DMATXRIS 0x00020000 // Transmit DMA Raw Interrupt
  215. // Status
  216. #define UART_RIS_DMARXRIS 0x00010000 // Receive DMA Raw Interrupt Status
  217. #define UART_RIS_9BITRIS 0x00001000 // 9-Bit Mode Raw Interrupt Status
  218. #define UART_RIS_EOTRIS 0x00000800 // End of Transmission Raw
  219. // Interrupt Status
  220. #define UART_RIS_OERIS 0x00000400 // UART Overrun Error Raw Interrupt
  221. // Status
  222. #define UART_RIS_BERIS 0x00000200 // UART Break Error Raw Interrupt
  223. // Status
  224. #define UART_RIS_PERIS 0x00000100 // UART Parity Error Raw Interrupt
  225. // Status
  226. #define UART_RIS_FERIS 0x00000080 // UART Framing Error Raw Interrupt
  227. // Status
  228. #define UART_RIS_RTRIS 0x00000040 // UART Receive Time-Out Raw
  229. // Interrupt Status
  230. #define UART_RIS_TXRIS 0x00000020 // UART Transmit Raw Interrupt
  231. // Status
  232. #define UART_RIS_RXRIS 0x00000010 // UART Receive Raw Interrupt
  233. // Status
  234. #define UART_RIS_DSRRIS 0x00000008 // UART Data Set Ready Modem Raw
  235. // Interrupt Status
  236. #define UART_RIS_DCDRIS 0x00000004 // UART Data Carrier Detect Modem
  237. // Raw Interrupt Status
  238. #define UART_RIS_CTSRIS 0x00000002 // UART Clear to Send Modem Raw
  239. // Interrupt Status
  240. #define UART_RIS_RIRIS 0x00000001 // UART Ring Indicator Modem Raw
  241. // Interrupt Status
  242. //*****************************************************************************
  243. //
  244. // The following are defines for the bit fields in the UART_O_MIS register.
  245. //
  246. //*****************************************************************************
  247. #define UART_MIS_DMATXMIS 0x00020000 // Transmit DMA Masked Interrupt
  248. // Status
  249. #define UART_MIS_DMARXMIS 0x00010000 // Receive DMA Masked Interrupt
  250. // Status
  251. #define UART_MIS_9BITMIS 0x00001000 // 9-Bit Mode Masked Interrupt
  252. // Status
  253. #define UART_MIS_EOTMIS 0x00000800 // End of Transmission Masked
  254. // Interrupt Status
  255. #define UART_MIS_OEMIS 0x00000400 // UART Overrun Error Masked
  256. // Interrupt Status
  257. #define UART_MIS_BEMIS 0x00000200 // UART Break Error Masked
  258. // Interrupt Status
  259. #define UART_MIS_PEMIS 0x00000100 // UART Parity Error Masked
  260. // Interrupt Status
  261. #define UART_MIS_FEMIS 0x00000080 // UART Framing Error Masked
  262. // Interrupt Status
  263. #define UART_MIS_RTMIS 0x00000040 // UART Receive Time-Out Masked
  264. // Interrupt Status
  265. #define UART_MIS_TXMIS 0x00000020 // UART Transmit Masked Interrupt
  266. // Status
  267. #define UART_MIS_RXMIS 0x00000010 // UART Receive Masked Interrupt
  268. // Status
  269. #define UART_MIS_DSRMIS 0x00000008 // UART Data Set Ready Modem Masked
  270. // Interrupt Status
  271. #define UART_MIS_DCDMIS 0x00000004 // UART Data Carrier Detect Modem
  272. // Masked Interrupt Status
  273. #define UART_MIS_CTSMIS 0x00000002 // UART Clear to Send Modem Masked
  274. // Interrupt Status
  275. #define UART_MIS_RIMIS 0x00000001 // UART Ring Indicator Modem Masked
  276. // Interrupt Status
  277. //*****************************************************************************
  278. //
  279. // The following are defines for the bit fields in the UART_O_ICR register.
  280. //
  281. //*****************************************************************************
  282. #define UART_ICR_DMATXIC 0x00020000 // Transmit DMA Interrupt Clear
  283. #define UART_ICR_DMARXIC 0x00010000 // Receive DMA Interrupt Clear
  284. #define UART_ICR_9BITIC 0x00001000 // 9-Bit Mode Interrupt Clear
  285. #define UART_ICR_EOTIC 0x00000800 // End of Transmission Interrupt
  286. // Clear
  287. #define UART_ICR_OEIC 0x00000400 // Overrun Error Interrupt Clear
  288. #define UART_ICR_BEIC 0x00000200 // Break Error Interrupt Clear
  289. #define UART_ICR_PEIC 0x00000100 // Parity Error Interrupt Clear
  290. #define UART_ICR_FEIC 0x00000080 // Framing Error Interrupt Clear
  291. #define UART_ICR_RTIC 0x00000040 // Receive Time-Out Interrupt Clear
  292. #define UART_ICR_TXIC 0x00000020 // Transmit Interrupt Clear
  293. #define UART_ICR_RXIC 0x00000010 // Receive Interrupt Clear
  294. #define UART_ICR_DSRMIC 0x00000008 // UART Data Set Ready Modem
  295. // Interrupt Clear
  296. #define UART_ICR_DCDMIC 0x00000004 // UART Data Carrier Detect Modem
  297. // Interrupt Clear
  298. #define UART_ICR_CTSMIC 0x00000002 // UART Clear to Send Modem
  299. // Interrupt Clear
  300. #define UART_ICR_RIMIC 0x00000001 // UART Ring Indicator Modem
  301. // Interrupt Clear
  302. //*****************************************************************************
  303. //
  304. // The following are defines for the bit fields in the UART_O_DMACTL register.
  305. //
  306. //*****************************************************************************
  307. #define UART_DMACTL_DMAERR 0x00000004 // DMA on Error
  308. #define UART_DMACTL_TXDMAE 0x00000002 // Transmit DMA Enable
  309. #define UART_DMACTL_RXDMAE 0x00000001 // Receive DMA Enable
  310. //*****************************************************************************
  311. //
  312. // The following are defines for the bit fields in the UART_O_9BITADDR
  313. // register.
  314. //
  315. //*****************************************************************************
  316. #define UART_9BITADDR_9BITEN 0x00008000 // Enable 9-Bit Mode
  317. #define UART_9BITADDR_ADDR_M 0x000000FF // Self Address for 9-Bit Mode
  318. #define UART_9BITADDR_ADDR_S 0
  319. //*****************************************************************************
  320. //
  321. // The following are defines for the bit fields in the UART_O_9BITAMASK
  322. // register.
  323. //
  324. //*****************************************************************************
  325. #define UART_9BITAMASK_MASK_M 0x000000FF // Self Address Mask for 9-Bit Mode
  326. #define UART_9BITAMASK_MASK_S 0
  327. //*****************************************************************************
  328. //
  329. // The following are defines for the bit fields in the UART_O_PP register.
  330. //
  331. //*****************************************************************************
  332. #define UART_PP_MSE 0x00000008 // Modem Support Extended
  333. #define UART_PP_MS 0x00000004 // Modem Support
  334. #define UART_PP_NB 0x00000002 // 9-Bit Support
  335. #define UART_PP_SC 0x00000001 // Smart Card Support
  336. //*****************************************************************************
  337. //
  338. // The following are defines for the bit fields in the UART_O_CC register.
  339. //
  340. //*****************************************************************************
  341. #define UART_CC_CS_M 0x0000000F // UART Baud Clock Source
  342. #define UART_CC_CS_SYSCLK 0x00000000 // System clock (based on clock
  343. // source and divisor factor)
  344. #define UART_CC_CS_PIOSC 0x00000005 // PIOSC
  345. #endif // __HW_UART_H__