uart.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2011-08-08 lgnq first version for LS1B
  9. */
  10. #ifndef __UART_H__
  11. #define __UART_H__
  12. #include "ls1b.h"
  13. #define UART0_BASE 0xBFE40000
  14. #define UART0_1_BASE 0xBFE41000
  15. #define UART0_2_BASE 0xBFE42000
  16. #define UART0_3_BASE 0xBFE43000
  17. #define UART1_BASE 0xBFE44000
  18. #define UART1_1_BASE 0xBFE45000
  19. #define UART1_2_BASE 0xBFE46000
  20. #define UART1_3_BASE 0xBFE47000
  21. #define UART2_BASE 0xBFE48000
  22. #define UART3_BASE 0xBFE4C000
  23. #define UART4_BASE 0xBFE6C000
  24. #define UART5_BASE 0xBFE7C000
  25. /* UART registers */
  26. #define UART_DAT(base) __REG8(base + 0x00)
  27. #define UART_IER(base) __REG8(base + 0x01)
  28. #define UART_IIR(base) __REG8(base + 0x02)
  29. #define UART_FCR(base) __REG8(base + 0x02)
  30. #define UART_LCR(base) __REG8(base + 0x03)
  31. #define UART_MCR(base) __REG8(base + 0x04)
  32. #define UART_LSR(base) __REG8(base + 0x05)
  33. #define UART_MSR(base) __REG8(base + 0x06)
  34. #define UART_LSB(base) __REG8(base + 0x00)
  35. #define UART_MSB(base) __REG8(base + 0x01)
  36. /* UART0 registers */
  37. #define UART0_DAT __REG8(UART0_BASE + 0x00)
  38. #define UART0_IER __REG8(UART0_BASE + 0x01)
  39. #define UART0_IIR __REG8(UART0_BASE + 0x02)
  40. #define UART0_FCR __REG8(UART0_BASE + 0x02)
  41. #define UART0_LCR __REG8(UART0_BASE + 0x03)
  42. #define UART0_MCR __REG8(UART0_BASE + 0x04)
  43. #define UART0_LSR __REG8(UART0_BASE + 0x05)
  44. #define UART0_MSR __REG8(UART0_BASE + 0x06)
  45. #define UART0_LSB __REG8(UART0_BASE + 0x00)
  46. #define UART0_MSB __REG8(UART0_BASE + 0x01)
  47. /* UART1 registers */
  48. #define UART1_DAT __REG8(UART1_BASE + 0x00)
  49. #define UART1_IER __REG8(UART1_BASE + 0x01)
  50. #define UART1_IIR __REG8(UART1_BASE + 0x02)
  51. #define UART1_FCR __REG8(UART1_BASE + 0x02)
  52. #define UART1_LCR __REG8(UART1_BASE + 0x03)
  53. #define UART1_MCR __REG8(UART1_BASE + 0x04)
  54. #define UART1_LSR __REG8(UART1_BASE + 0x05)
  55. #define UART1_MSR __REG8(UART1_BASE + 0x06)
  56. #define UART1_LSB __REG8(UART1_BASE + 0x00)
  57. #define UART1_MSB __REG8(UART1_BASE + 0x01)
  58. /* UART interrupt enable register value */
  59. #define UARTIER_IME (1 << 3)
  60. #define UARTIER_ILE (1 << 2)
  61. #define UARTIER_ITXE (1 << 1)
  62. #define UARTIER_IRXE (1 << 0)
  63. /* UART line control register value */
  64. #define UARTLCR_DLAB (1 << 7)
  65. #define UARTLCR_BCB (1 << 6)
  66. #define UARTLCR_SPB (1 << 5)
  67. #define UARTLCR_EPS (1 << 4)
  68. #define UARTLCR_PE (1 << 3)
  69. #define UARTLCR_SB (1 << 2)
  70. /* UART line status register value */
  71. #define UARTLSR_ERROR (1 << 7)
  72. #define UARTLSR_TE (1 << 6)
  73. #define UARTLSR_TFE (1 << 5)
  74. #define UARTLSR_BI (1 << 4)
  75. #define UARTLSR_FE (1 << 3)
  76. #define UARTLSR_PE (1 << 2)
  77. #define UARTLSR_OE (1 << 1)
  78. #define UARTLSR_DR (1 << 0)
  79. void rt_hw_uart_init(void);
  80. #endif