drv_uart.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * File : drv_uart.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2018-05-08 zhuangwei the first version
  23. */
  24. #ifndef __DRV_UART_H__
  25. #define __DRV_UART_H__
  26. #include "ls1c.h"
  27. #define DEV_CLK 252000000 // 252MHz
  28. #define UART_BAUDRATE 115200
  29. #define UART0_BASE 0xBFE40000
  30. //#define UART0_1_BASE 0xBFE41000
  31. #define UART1_BASE 0xBFE44000
  32. #define UART2_BASE 0xBFE48000
  33. #define UART3_BASE 0xBFE4C000
  34. #define UART4_BASE 0xBFE4C400
  35. #define UART5_BASE 0xBFE4C500
  36. #define UART6_BASE 0xBFE4C600
  37. #define UART7_BASE 0xBFE4C700
  38. #define UART8_BASE 0xBFE4C800
  39. #define UART9_BASE 0xBFE4C900
  40. #define UART10_BASE 0xBFE4Ca00
  41. #define UART11_BASE 0xBFE4Cb00
  42. /* UART registers */
  43. #define UART_DAT(base) __REG8(base + 0x00)
  44. #define UART_IER(base) __REG8(base + 0x01)
  45. #define UART_IIR(base) __REG8(base + 0x02)
  46. #define UART_FCR(base) __REG8(base + 0x02)
  47. #define UART_LCR(base) __REG8(base + 0x03)
  48. #define UART_MCR(base) __REG8(base + 0x04)
  49. #define UART_LSR(base) __REG8(base + 0x05)
  50. #define UART_MSR(base) __REG8(base + 0x06)
  51. #define UART_LSB(base) __REG8(base + 0x00)
  52. #define UART_MSB(base) __REG8(base + 0x01)
  53. /* UART0 registers */
  54. #define UART0_DAT __REG8(UART0_BASE + 0x00)
  55. #define UART0_IER __REG8(UART0_BASE + 0x01)
  56. #define UART0_IIR __REG8(UART0_BASE + 0x02)
  57. #define UART0_FCR __REG8(UART0_BASE + 0x02)
  58. #define UART0_LCR __REG8(UART0_BASE + 0x03)
  59. #define UART0_MCR __REG8(UART0_BASE + 0x04)
  60. #define UART0_LSR __REG8(UART0_BASE + 0x05)
  61. #define UART0_MSR __REG8(UART0_BASE + 0x06)
  62. #define UART0_LSB __REG8(UART0_BASE + 0x00)
  63. #define UART0_MSB __REG8(UART0_BASE + 0x01)
  64. /* UART1 registers */
  65. #define UART1_DAT __REG8(UART1_BASE + 0x00)
  66. #define UART1_IER __REG8(UART1_BASE + 0x01)
  67. #define UART1_IIR __REG8(UART1_BASE + 0x02)
  68. #define UART1_FCR __REG8(UART1_BASE + 0x02)
  69. #define UART1_LCR __REG8(UART1_BASE + 0x03)
  70. #define UART1_MCR __REG8(UART1_BASE + 0x04)
  71. #define UART1_LSR __REG8(UART1_BASE + 0x05)
  72. #define UART1_MSR __REG8(UART1_BASE + 0x06)
  73. #define UART1_LSB __REG8(UART1_BASE + 0x00)
  74. #define UART1_MSB __REG8(UART1_BASE + 0x01)
  75. /* UART interrupt enable register value */
  76. #define UARTIER_IME (1 << 3)
  77. #define UARTIER_ILE (1 << 2)
  78. #define UARTIER_ITXE (1 << 1)
  79. #define UARTIER_IRXE (1 << 0)
  80. /* UART line control register value */
  81. #define UARTLCR_DLAB (1 << 7)
  82. #define UARTLCR_BCB (1 << 6)
  83. #define UARTLCR_SPB (1 << 5)
  84. #define UARTLCR_EPS (1 << 4)
  85. #define UARTLCR_PE (1 << 3)
  86. #define UARTLCR_SB (1 << 2)
  87. /* UART line status register value */
  88. #define UARTLSR_ERROR (1 << 7)
  89. #define UARTLSR_TE (1 << 6)
  90. #define UARTLSR_TFE (1 << 5)
  91. #define UARTLSR_BI (1 << 4)
  92. #define UARTLSR_FE (1 << 3)
  93. #define UARTLSR_PE (1 << 2)
  94. #define UARTLSR_OE (1 << 1)
  95. #define UARTLSR_DR (1 << 0)
  96. void rt_hw_uart_init(void);
  97. #endif