drv_uart.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Copyright (c) 2006-2018, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2018-05-08 zhuangwei the first version
  9. */
  10. #ifndef __DRV_UART_H__
  11. #define __DRV_UART_H__
  12. #include "ls1c.h"
  13. #include <rthw.h>
  14. #define DEV_CLK 252000000 // 252MHz
  15. #define UART_BAUDRATE 115200
  16. #define UART0_BASE 0xBFE40000
  17. //#define UART0_1_BASE 0xBFE41000
  18. #define UART1_BASE 0xBFE44000
  19. #define UART2_BASE 0xBFE48000
  20. #define UART3_BASE 0xBFE4C000
  21. #define UART4_BASE 0xBFE4C400
  22. #define UART5_BASE 0xBFE4C500
  23. #define UART6_BASE 0xBFE4C600
  24. #define UART7_BASE 0xBFE4C700
  25. #define UART8_BASE 0xBFE4C800
  26. #define UART9_BASE 0xBFE4C900
  27. #define UART10_BASE 0xBFE4Ca00
  28. #define UART11_BASE 0xBFE4Cb00
  29. /* UART registers */
  30. #define UART_DAT(base) HWREG8(base + 0x00)
  31. #define UART_IER(base) HWREG8(base + 0x01)
  32. #define UART_IIR(base) HWREG8(base + 0x02)
  33. #define UART_FCR(base) HWREG8(base + 0x02)
  34. #define UART_LCR(base) HWREG8(base + 0x03)
  35. #define UART_MCR(base) HWREG8(base + 0x04)
  36. #define UART_LSR(base) HWREG8(base + 0x05)
  37. #define UART_MSR(base) HWREG8(base + 0x06)
  38. #define UART_LSB(base) HWREG8(base + 0x00)
  39. #define UART_MSB(base) HWREG8(base + 0x01)
  40. /* UART0 registers */
  41. #define UART0_DAT HWREG8(UART0_BASE + 0x00)
  42. #define UART0_IER HWREG8(UART0_BASE + 0x01)
  43. #define UART0_IIR HWREG8(UART0_BASE + 0x02)
  44. #define UART0_FCR HWREG8(UART0_BASE + 0x02)
  45. #define UART0_LCR HWREG8(UART0_BASE + 0x03)
  46. #define UART0_MCR HWREG8(UART0_BASE + 0x04)
  47. #define UART0_LSR HWREG8(UART0_BASE + 0x05)
  48. #define UART0_MSR HWREG8(UART0_BASE + 0x06)
  49. #define UART0_LSB HWREG8(UART0_BASE + 0x00)
  50. #define UART0_MSB HWREG8(UART0_BASE + 0x01)
  51. /* UART1 registers */
  52. #define UART1_DAT HWREG8(UART1_BASE + 0x00)
  53. #define UART1_IER HWREG8(UART1_BASE + 0x01)
  54. #define UART1_IIR HWREG8(UART1_BASE + 0x02)
  55. #define UART1_FCR HWREG8(UART1_BASE + 0x02)
  56. #define UART1_LCR HWREG8(UART1_BASE + 0x03)
  57. #define UART1_MCR HWREG8(UART1_BASE + 0x04)
  58. #define UART1_LSR HWREG8(UART1_BASE + 0x05)
  59. #define UART1_MSR HWREG8(UART1_BASE + 0x06)
  60. #define UART1_LSB HWREG8(UART1_BASE + 0x00)
  61. #define UART1_MSB HWREG8(UART1_BASE + 0x01)
  62. /* UART interrupt enable register value */
  63. #define UARTIER_IME (1 << 3)
  64. #define UARTIER_ILE (1 << 2)
  65. #define UARTIER_ITXE (1 << 1)
  66. #define UARTIER_IRXE (1 << 0)
  67. /* UART line control register value */
  68. #define UARTLCR_DLAB (1 << 7)
  69. #define UARTLCR_BCB (1 << 6)
  70. #define UARTLCR_SPB (1 << 5)
  71. #define UARTLCR_EPS (1 << 4)
  72. #define UARTLCR_PE (1 << 3)
  73. #define UARTLCR_SB (1 << 2)
  74. /* UART line status register value */
  75. #define UARTLSR_ERROR (1 << 7)
  76. #define UARTLSR_TE (1 << 6)
  77. #define UARTLSR_TFE (1 << 5)
  78. #define UARTLSR_BI (1 << 4)
  79. #define UARTLSR_FE (1 << 3)
  80. #define UARTLSR_PE (1 << 2)
  81. #define UARTLSR_OE (1 << 1)
  82. #define UARTLSR_DR (1 << 0)
  83. void rt_hw_uart_init(void);
  84. #endif