uart.h 2.9 KB

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