hw_uart.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. //*****************************************************************************
  2. //
  3. // hw_uart.h - Macros and defines used when accessing the UART hardware
  4. //
  5. // Copyright (c) 2005-2009 Luminary Micro, Inc. All rights reserved.
  6. // Software License Agreement
  7. //
  8. // Luminary Micro, Inc. (LMI) is supplying this software for use solely and
  9. // exclusively on LMI's microcontroller products.
  10. //
  11. // The software is owned by LMI and/or its suppliers, and is protected under
  12. // applicable copyright laws. All rights are reserved. You may not combine
  13. // this software with "viral" open-source software in order to form a larger
  14. // program. Any use in violation of the foregoing restrictions may subject
  15. // the user to criminal sanctions under applicable laws, as well as to civil
  16. // liability for the breach of the terms and conditions of this license.
  17. //
  18. // THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
  19. // OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
  20. // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
  21. // LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
  22. // CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
  23. //
  24. // This is part of revision 4694 of the Stellaris Firmware Development Package.
  25. //
  26. //*****************************************************************************
  27. #ifndef __HW_UART_H__
  28. #define __HW_UART_H__
  29. //*****************************************************************************
  30. //
  31. // The following are defines for the UART Register offsets.
  32. //
  33. //*****************************************************************************
  34. #define UART_O_DR 0x00000000 // Data Register
  35. #define UART_O_RSR 0x00000004 // Receive Status Register (read)
  36. #define UART_O_ECR 0x00000004 // Error Clear Register (write)
  37. #define UART_O_FR 0x00000018 // Flag Register (read only)
  38. #define UART_O_ILPR 0x00000020 // UART IrDA Low-Power Register
  39. #define UART_O_IBRD 0x00000024 // Integer Baud Rate Divisor Reg
  40. #define UART_O_FBRD 0x00000028 // Fractional Baud Rate Divisor Reg
  41. #define UART_O_LCRH 0x0000002C // UART Line Control
  42. #define UART_O_CTL 0x00000030 // Control Register
  43. #define UART_O_IFLS 0x00000034 // Interrupt FIFO Level Select Reg
  44. #define UART_O_IM 0x00000038 // Interrupt Mask Set/Clear Reg
  45. #define UART_O_RIS 0x0000003C // Raw Interrupt Status Register
  46. #define UART_O_MIS 0x00000040 // Masked Interrupt Status Register
  47. #define UART_O_ICR 0x00000044 // Interrupt Clear Register
  48. #define UART_O_DMACTL 0x00000048 // UART DMA Control
  49. #define UART_O_LCTL 0x00000090 // UART LIN Control
  50. #define UART_O_LSS 0x00000094 // UART LIN Snap Shot
  51. #define UART_O_LTIM 0x00000098 // UART LIN Timer
  52. //*****************************************************************************
  53. //
  54. // The following are defines for the Data Register bits
  55. //
  56. //*****************************************************************************
  57. #define UART_DR_OE 0x00000800 // Overrun Error
  58. #define UART_DR_BE 0x00000400 // Break Error
  59. #define UART_DR_PE 0x00000200 // Parity Error
  60. #define UART_DR_FE 0x00000100 // Framing Error
  61. #define UART_DR_DATA_M 0x000000FF // Data Transmitted or Received.
  62. #define UART_DR_DATA_S 0
  63. //*****************************************************************************
  64. //
  65. // The following are defines for the Receive Status Register bits
  66. //
  67. //*****************************************************************************
  68. #define UART_RSR_OE 0x00000008 // Overrun Error
  69. #define UART_RSR_BE 0x00000004 // Break Error
  70. #define UART_RSR_PE 0x00000002 // Parity Error
  71. #define UART_RSR_FE 0x00000001 // Framing Error
  72. //*****************************************************************************
  73. //
  74. // The following are defines for the Flag Register bits
  75. //
  76. //*****************************************************************************
  77. #define UART_FR_RI 0x00000100 // Ring Indicator.
  78. #define UART_FR_TXFE 0x00000080 // TX FIFO Empty
  79. #define UART_FR_RXFF 0x00000040 // RX FIFO Full
  80. #define UART_FR_TXFF 0x00000020 // TX FIFO Full
  81. #define UART_FR_RXFE 0x00000010 // RX FIFO Empty
  82. #define UART_FR_BUSY 0x00000008 // UART Busy
  83. #define UART_FR_DCD 0x00000004 // Data Carrier Detect.
  84. #define UART_FR_DSR 0x00000002 // Data Set Ready.
  85. #define UART_FR_CTS 0x00000001 // Clear To Send.
  86. //*****************************************************************************
  87. //
  88. // The following are defines for the Integer baud-rate divisor
  89. //
  90. //*****************************************************************************
  91. #define UART_IBRD_DIVINT_M 0x0000FFFF // Integer Baud-Rate Divisor.
  92. #define UART_IBRD_DIVINT_S 0
  93. //*****************************************************************************
  94. //
  95. // The following are defines for the Fractional baud-rate divisor
  96. //
  97. //*****************************************************************************
  98. #define UART_FBRD_DIVFRAC_M 0x0000003F // Fractional Baud-Rate Divisor.
  99. #define UART_FBRD_DIVFRAC_S 0
  100. //*****************************************************************************
  101. //
  102. // The following are defines for the Control Register bits
  103. //
  104. //*****************************************************************************
  105. #define UART_CTL_CTSEN 0x00008000 // Enable Clear To Send.
  106. #define UART_CTL_RTSEN 0x00004000 // Enable Request to Send.
  107. #define UART_CTL_RTS 0x00000800 // Request to Send.
  108. #define UART_CTL_DTR 0x00000400 // Data Terminal Ready.
  109. #define UART_CTL_RXE 0x00000200 // Receive Enable
  110. #define UART_CTL_TXE 0x00000100 // Transmit Enable
  111. #define UART_CTL_LBE 0x00000080 // Loopback Enable
  112. #define UART_CTL_LIN 0x00000040 // LIN Mode Enable.
  113. #define UART_CTL_HSE 0x00000020 // High-Speed Enable.
  114. #define UART_CTL_EOT 0x00000010 // End of Transmission.
  115. #define UART_CTL_SMART 0x00000008 // ISO 7816 Smart Card Support.
  116. #define UART_CTL_SIRLP 0x00000004 // SIR (IrDA) Low Power Enable
  117. #define UART_CTL_SIREN 0x00000002 // SIR (IrDA) Enable
  118. #define UART_CTL_UARTEN 0x00000001 // UART Enable
  119. //*****************************************************************************
  120. //
  121. // The following are defines for the Interrupt FIFO Level Select Register bits
  122. //
  123. //*****************************************************************************
  124. #define UART_IFLS_RX_M 0x00000038 // RX FIFO Level Interrupt Mask
  125. #define UART_IFLS_RX1_8 0x00000000 // 1/8 Full
  126. #define UART_IFLS_RX2_8 0x00000008 // 1/4 Full
  127. #define UART_IFLS_RX4_8 0x00000010 // 1/2 Full
  128. #define UART_IFLS_RX6_8 0x00000018 // 3/4 Full
  129. #define UART_IFLS_RX7_8 0x00000020 // 7/8 Full
  130. #define UART_IFLS_TX_M 0x00000007 // TX FIFO Level Interrupt Mask
  131. #define UART_IFLS_TX1_8 0x00000000 // 1/8 Full
  132. #define UART_IFLS_TX2_8 0x00000001 // 1/4 Full
  133. #define UART_IFLS_TX4_8 0x00000002 // 1/2 Full
  134. #define UART_IFLS_TX6_8 0x00000003 // 3/4 Full
  135. #define UART_IFLS_TX7_8 0x00000004 // 7/8 Full
  136. //*****************************************************************************
  137. //
  138. // The following are defines for the Interrupt Mask Set/Clear Register bits
  139. //
  140. //*****************************************************************************
  141. #define UART_IM_LME5IM 0x00008000 // LIN Mode Edge 5 Interrupt Mask.
  142. #define UART_IM_LME1IM 0x00004000 // LIN Mode Edge 1 Interrupt Mask.
  143. #define UART_IM_LMSBIM 0x00002000 // LIN Mode Sync Break Interrupt
  144. // Mask.
  145. #define UART_IM_OEIM 0x00000400 // Overrun Error Interrupt Mask
  146. #define UART_IM_BEIM 0x00000200 // Break Error Interrupt Mask
  147. #define UART_IM_PEIM 0x00000100 // Parity Error Interrupt Mask
  148. #define UART_IM_FEIM 0x00000080 // Framing Error Interrupt Mask
  149. #define UART_IM_RTIM 0x00000040 // Receive Timeout Interrupt Mask
  150. #define UART_IM_TXIM 0x00000020 // Transmit Interrupt Mask
  151. #define UART_IM_RXIM 0x00000010 // Receive Interrupt Mask
  152. #define UART_IM_DSRMIM 0x00000008 // UART Data Set Ready Modem
  153. // Interrupt Mask.
  154. #define UART_IM_DCDMIM 0x00000004 // UART Data Carrier Detect Modem
  155. // Interrupt Mask.
  156. #define UART_IM_CTSMIM 0x00000002 // UART Clear to Send Modem
  157. // Interrupt Mask.
  158. #define UART_IM_RIMIM 0x00000001 // UART Ring Indicator Modem
  159. // Interrupt Mask.
  160. //*****************************************************************************
  161. //
  162. // The following are defines for the Raw Interrupt Status Register
  163. //
  164. //*****************************************************************************
  165. #define UART_RIS_LME5RIS 0x00008000 // LIN Mode Edge 5 Raw Interrupt
  166. // Status.
  167. #define UART_RIS_LME1RIS 0x00004000 // LIN Mode Edge 1 Raw Interrupt
  168. // Status.
  169. #define UART_RIS_LMSBRIS 0x00002000 // LIN Mode Sync Break Raw
  170. // Interrupt Status.
  171. #define UART_RIS_OERIS 0x00000400 // Overrun Error Interrupt Status
  172. #define UART_RIS_BERIS 0x00000200 // Break Error Interrupt Status
  173. #define UART_RIS_PERIS 0x00000100 // Parity Error Interrupt Status
  174. #define UART_RIS_FERIS 0x00000080 // Framing Error Interrupt Status
  175. #define UART_RIS_RTRIS 0x00000040 // Receive Timeout Interrupt Status
  176. #define UART_RIS_TXRIS 0x00000020 // Transmit Interrupt Status
  177. #define UART_RIS_RXRIS 0x00000010 // Receive Interrupt Status
  178. #define UART_RIS_DSRRIS 0x00000008 // UART Data Set Ready Modem Raw
  179. // Interrupt Status.
  180. #define UART_RIS_DCDRIS 0x00000004 // UART Data Carrier Detect odem
  181. // Raw Interrupt Status.
  182. #define UART_RIS_CTSRIS 0x00000002 // UART Clear to Send Modem Raw
  183. // Interrupt Status.
  184. #define UART_RIS_RIRIS 0x00000001 // UART Ring Indicator Modem Raw
  185. // Interrupt Status.
  186. //*****************************************************************************
  187. //
  188. // The following are defines for the Masked Interrupt Status Register
  189. //
  190. //*****************************************************************************
  191. #define UART_MIS_LME5MIS 0x00008000 // LIN Mode Edge 5 Masked Interrupt
  192. // Status.
  193. #define UART_MIS_LME1MIS 0x00004000 // LIN Mode Edge 1 Masked Interrupt
  194. // Status.
  195. #define UART_MIS_LMSBMIS 0x00002000 // LIN Mode Sync Break Masked
  196. // Interrupt Status.
  197. #define UART_MIS_OEMIS 0x00000400 // Overrun Error Interrupt Status
  198. #define UART_MIS_BEMIS 0x00000200 // Break Error Interrupt Status
  199. #define UART_MIS_PEMIS 0x00000100 // Parity Error Interrupt Status
  200. #define UART_MIS_FEMIS 0x00000080 // Framing Error Interrupt Status
  201. #define UART_MIS_RTMIS 0x00000040 // Receive Timeout Interrupt Status
  202. #define UART_MIS_TXMIS 0x00000020 // Transmit Interrupt Status
  203. #define UART_MIS_RXMIS 0x00000010 // Receive Interrupt Status
  204. #define UART_MIS_DSRMIS 0x00000008 // UART Data Set Ready Modem Masked
  205. // Interrupt Status.
  206. #define UART_MIS_DCDMIS 0x00000004 // UART Data Carrier Detect odem
  207. // Masked Interrupt Status.
  208. #define UART_MIS_CTSMIS 0x00000002 // UART Clear to Send Modem Masked
  209. // Interrupt Status.
  210. #define UART_MIS_RIMIS 0x00000001 // UART Ring Indicator Modem Masked
  211. // Interrupt Status.
  212. //*****************************************************************************
  213. //
  214. // The following are defines for the Interrupt Clear Register bits
  215. //
  216. //*****************************************************************************
  217. #define UART_ICR_LME5MIC 0x00008000 // LIN Mode Edge 5 Interrupt Clear.
  218. #define UART_ICR_LME1MIC 0x00004000 // LIN Mode Edge 1 Interrupt Clear.
  219. #define UART_ICR_LMSBMIC 0x00002000 // LIN Mode Sync Break Interrupt
  220. // Clear.
  221. #define UART_ICR_OEIC 0x00000400 // Overrun Error Interrupt Clear
  222. #define UART_ICR_BEIC 0x00000200 // Break Error Interrupt Clear
  223. #define UART_ICR_PEIC 0x00000100 // Parity Error Interrupt Clear
  224. #define UART_ICR_FEIC 0x00000080 // Framing Error Interrupt Clear
  225. #define UART_ICR_RTIC 0x00000040 // Receive Timeout Interrupt Clear
  226. #define UART_ICR_TXIC 0x00000020 // Transmit Interrupt Clear
  227. #define UART_ICR_RXIC 0x00000010 // Receive Interrupt Clear
  228. #define UART_ICR_DSRMIC 0x00000008 // UART Data Set Ready Modem
  229. // Interrupt Clear.
  230. #define UART_ICR_DCDMIC 0x00000004 // UART Data Carrier Detect odem
  231. // Interrupt Clear.
  232. #define UART_ICR_CTSMIC 0x00000002 // UART Clear to Send Modem
  233. // Interrupt Clear.
  234. #define UART_ICR_RIMIC 0x00000001 // UART Ring Indicator Modem
  235. // Interrupt Clear.
  236. //*****************************************************************************
  237. //
  238. // The following are defines for the bit fields in the UART_O_ECR register.
  239. //
  240. //*****************************************************************************
  241. #define UART_ECR_DATA_M 0x000000FF // Error Clear.
  242. #define UART_ECR_DATA_S 0
  243. //*****************************************************************************
  244. //
  245. // The following are defines for the bit fields in the UART_O_LCRH register.
  246. //
  247. //*****************************************************************************
  248. #define UART_LCRH_SPS 0x00000080 // UART Stick Parity Select.
  249. #define UART_LCRH_WLEN_M 0x00000060 // UART Word Length.
  250. #define UART_LCRH_WLEN_5 0x00000000 // 5 bits (default)
  251. #define UART_LCRH_WLEN_6 0x00000020 // 6 bits
  252. #define UART_LCRH_WLEN_7 0x00000040 // 7 bits
  253. #define UART_LCRH_WLEN_8 0x00000060 // 8 bits
  254. #define UART_LCRH_FEN 0x00000010 // UART Enable FIFOs.
  255. #define UART_LCRH_STP2 0x00000008 // UART Two Stop Bits Select.
  256. #define UART_LCRH_EPS 0x00000004 // UART Even Parity Select.
  257. #define UART_LCRH_PEN 0x00000002 // UART Parity Enable.
  258. #define UART_LCRH_BRK 0x00000001 // UART Send Break.
  259. //*****************************************************************************
  260. //
  261. // The following are defines for the bit fields in the UART_O_ILPR register.
  262. //
  263. //*****************************************************************************
  264. #define UART_ILPR_ILPDVSR_M 0x000000FF // IrDA Low-Power Divisor.
  265. #define UART_ILPR_ILPDVSR_S 0
  266. //*****************************************************************************
  267. //
  268. // The following are defines for the bit fields in the UART_O_DMACTL register.
  269. //
  270. //*****************************************************************************
  271. #define UART_DMACTL_DMAERR 0x00000004 // DMA on Error.
  272. #define UART_DMACTL_TXDMAE 0x00000002 // Transmit DMA Enable.
  273. #define UART_DMACTL_RXDMAE 0x00000001 // Receive DMA Enable.
  274. //*****************************************************************************
  275. //
  276. // The following are defines for the bit fields in the UART_O_LCTL register.
  277. //
  278. //*****************************************************************************
  279. #define UART_LCTL_BLEN_M 0x00000030 // Sync Break Length.
  280. #define UART_LCTL_BLEN_13T 0x00000000 // Sync break length is 13T bits
  281. // (default)
  282. #define UART_LCTL_BLEN_14T 0x00000010 // Sync break length is 14T bits
  283. #define UART_LCTL_BLEN_15T 0x00000020 // Sync break length is 15T bits
  284. #define UART_LCTL_BLEN_16T 0x00000030 // Sync break length is 16T bits
  285. #define UART_LCTL_MASTER 0x00000001 // LIN Master Enable.
  286. //*****************************************************************************
  287. //
  288. // The following are defines for the bit fields in the UART_O_LSS register.
  289. //
  290. //*****************************************************************************
  291. #define UART_LSS_TSS_M 0x0000FFFF // Timer Snap Shot.
  292. #define UART_LSS_TSS_S 0
  293. //*****************************************************************************
  294. //
  295. // The following are defines for the bit fields in the UART_O_LTIM register.
  296. //
  297. //*****************************************************************************
  298. #define UART_LTIM_TIMER_M 0x0000FFFF // Timer Value.
  299. #define UART_LTIM_TIMER_S 0
  300. //*****************************************************************************
  301. //
  302. // The following definitions are deprecated.
  303. //
  304. //*****************************************************************************
  305. #ifndef DEPRECATED
  306. //*****************************************************************************
  307. //
  308. // The following are deprecated defines for the UART Register offsets.
  309. //
  310. //*****************************************************************************
  311. #define UART_O_LCR_H 0x0000002C // Line Control Register, HIGH byte
  312. #define UART_O_PeriphID4 0x00000FD0
  313. #define UART_O_PeriphID5 0x00000FD4
  314. #define UART_O_PeriphID6 0x00000FD8
  315. #define UART_O_PeriphID7 0x00000FDC
  316. #define UART_O_PeriphID0 0x00000FE0
  317. #define UART_O_PeriphID1 0x00000FE4
  318. #define UART_O_PeriphID2 0x00000FE8
  319. #define UART_O_PeriphID3 0x00000FEC
  320. #define UART_O_PCellID0 0x00000FF0
  321. #define UART_O_PCellID1 0x00000FF4
  322. #define UART_O_PCellID2 0x00000FF8
  323. #define UART_O_PCellID3 0x00000FFC
  324. //*****************************************************************************
  325. //
  326. // The following are deprecated defines for the Data Register bits
  327. //
  328. //*****************************************************************************
  329. #define UART_DR_DATA_MASK 0x000000FF // UART data
  330. //*****************************************************************************
  331. //
  332. // The following are deprecated defines for the Integer baud-rate divisor
  333. //
  334. //*****************************************************************************
  335. #define UART_IBRD_DIVINT_MASK 0x0000FFFF // Integer baud-rate divisor
  336. //*****************************************************************************
  337. //
  338. // The following are deprecated defines for the Fractional baud-rate divisor
  339. //
  340. //*****************************************************************************
  341. #define UART_FBRD_DIVFRAC_MASK 0x0000003F // Fractional baud-rate divisor
  342. //*****************************************************************************
  343. //
  344. // The following are deprecated defines for the Line Control Register High bits
  345. //
  346. //*****************************************************************************
  347. #define UART_LCR_H_SPS 0x00000080 // Stick Parity Select
  348. #define UART_LCR_H_WLEN 0x00000060 // Word length
  349. #define UART_LCR_H_WLEN_5 0x00000000 // 5 bit data
  350. #define UART_LCR_H_WLEN_6 0x00000020 // 6 bit data
  351. #define UART_LCR_H_WLEN_7 0x00000040 // 7 bit data
  352. #define UART_LCR_H_WLEN_8 0x00000060 // 8 bit data
  353. #define UART_LCR_H_FEN 0x00000010 // Enable FIFO
  354. #define UART_LCR_H_STP2 0x00000008 // Two Stop Bits Select
  355. #define UART_LCR_H_EPS 0x00000004 // Even Parity Select
  356. #define UART_LCR_H_PEN 0x00000002 // Parity Enable
  357. #define UART_LCR_H_BRK 0x00000001 // Send Break
  358. //*****************************************************************************
  359. //
  360. // The following are deprecated defines for the Interrupt FIFO Level Select
  361. // Register bits
  362. //
  363. //*****************************************************************************
  364. #define UART_IFLS_RX_MASK 0x00000038 // RX FIFO level mask
  365. #define UART_IFLS_TX_MASK 0x00000007 // TX FIFO level mask
  366. //*****************************************************************************
  367. //
  368. // The following are deprecated defines for the Interrupt Clear Register bits
  369. //
  370. //*****************************************************************************
  371. #define UART_RSR_ANY (UART_RSR_OE | UART_RSR_BE | UART_RSR_PE | \
  372. UART_RSR_FE)
  373. //*****************************************************************************
  374. //
  375. // The following are deprecated defines for the Reset Values for UART
  376. // Registers.
  377. //
  378. //*****************************************************************************
  379. #define UART_RV_CTL 0x00000300
  380. #define UART_RV_PCellID1 0x000000F0
  381. #define UART_RV_PCellID3 0x000000B1
  382. #define UART_RV_FR 0x00000090
  383. #define UART_RV_PeriphID2 0x00000018
  384. #define UART_RV_IFLS 0x00000012
  385. #define UART_RV_PeriphID0 0x00000011
  386. #define UART_RV_PCellID0 0x0000000D
  387. #define UART_RV_PCellID2 0x00000005
  388. #define UART_RV_PeriphID3 0x00000001
  389. #define UART_RV_PeriphID4 0x00000000
  390. #define UART_RV_LCR_H 0x00000000
  391. #define UART_RV_PeriphID6 0x00000000
  392. #define UART_RV_DR 0x00000000
  393. #define UART_RV_RSR 0x00000000
  394. #define UART_RV_ECR 0x00000000
  395. #define UART_RV_PeriphID5 0x00000000
  396. #define UART_RV_RIS 0x00000000
  397. #define UART_RV_FBRD 0x00000000
  398. #define UART_RV_IM 0x00000000
  399. #define UART_RV_MIS 0x00000000
  400. #define UART_RV_ICR 0x00000000
  401. #define UART_RV_PeriphID1 0x00000000
  402. #define UART_RV_PeriphID7 0x00000000
  403. #define UART_RV_IBRD 0x00000000
  404. #endif
  405. #endif // __HW_UART_H__