1
0

uart.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. #define UART0_BASE 0xBFE40000
  18. #define UART0_1_BASE 0xBFE41000
  19. #define UART0_2_BASE 0xBFE42000
  20. #define UART0_3_BASE 0xBFE43000
  21. #define UART1_BASE 0xBFE44000
  22. #define UART1_1_BASE 0xBFE45000
  23. #define UART1_2_BASE 0xBFE46000
  24. #define UART1_3_BASE 0xBFE47000
  25. #define UART2_BASE 0xBFE48000
  26. #define UART3_BASE 0xBFE4C000
  27. #define UART4_BASE 0xBFE6C000
  28. #define UART5_BASE 0xBFE7C000
  29. /* UART registers */
  30. #define UART_DAT(base) __REG8(base + 0x00)
  31. #define UART_IER(base) __REG8(base + 0x01)
  32. #define UART_IIR(base) __REG8(base + 0x02)
  33. #define UART_FCR(base) __REG8(base + 0x02)
  34. #define UART_LCR(base) __REG8(base + 0x03)
  35. #define UART_MCR(base) __REG8(base + 0x04)
  36. #define UART_LSR(base) __REG8(base + 0x05)
  37. #define UART_MSR(base) __REG8(base + 0x06)
  38. #define UART_LSB(base) __REG8(base + 0x00)
  39. #define UART_MSB(base) __REG8(base + 0x01)
  40. /* UART0 registers */
  41. #define UART0_DAT __REG8(UART0_BASE + 0x00)
  42. #define UART0_IER __REG8(UART0_BASE + 0x01)
  43. #define UART0_IIR __REG8(UART0_BASE + 0x02)
  44. #define UART0_FCR __REG8(UART0_BASE + 0x02)
  45. #define UART0_LCR __REG8(UART0_BASE + 0x03)
  46. #define UART0_MCR __REG8(UART0_BASE + 0x04)
  47. #define UART0_LSR __REG8(UART0_BASE + 0x05)
  48. #define UART0_MSR __REG8(UART0_BASE + 0x06)
  49. #define UART0_LSB __REG8(UART0_BASE + 0x00)
  50. #define UART0_MSB __REG8(UART0_BASE + 0x01)
  51. /* UART1 registers */
  52. #define UART1_DAT __REG8(UART1_BASE + 0x00)
  53. #define UART1_IER __REG8(UART1_BASE + 0x01)
  54. #define UART1_IIR __REG8(UART1_BASE + 0x02)
  55. #define UART1_FCR __REG8(UART1_BASE + 0x02)
  56. #define UART1_LCR __REG8(UART1_BASE + 0x03)
  57. #define UART1_MCR __REG8(UART1_BASE + 0x04)
  58. #define UART1_LSR __REG8(UART1_BASE + 0x05)
  59. #define UART1_MSR __REG8(UART1_BASE + 0x06)
  60. #define UART1_LSB __REG8(UART1_BASE + 0x00)
  61. #define UART1_MSB __REG8(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