drv_uart.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * File : drv_uart.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2017, 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-02-08 RT-Thread the first version
  23. */
  24. #ifndef __DRV_UART_H__
  25. #define __DRV_UART_H__
  26. #define UART0_BASE_ADDR (0x01C25000)
  27. #define UART1_BASE_ADDR (0x01C25400)
  28. #define UART2_BASE_ADDR (0x01C25800)
  29. #define UART_THR (0X00)
  30. #define UART_RHB (0X00)
  31. #define UART_DLL (0X00)
  32. #define UART_DLH (0X04)
  33. #define UART_IER (0X04)
  34. #define UART_IIR (0X08)
  35. #define UART_FCR (0X08)
  36. #define UART_LCR (0X0C)
  37. #define UART_MCR (0X10)
  38. #define UART_LSR (0X14)
  39. #define UART_MSR (0X18)
  40. #define UART_SCH (0X1C)
  41. #define UART_USR (0X7C)
  42. #define UART_TFL (0X80)
  43. #define UART_RFL (0X84)
  44. #define UART_HSK (0X88)
  45. #define UART_HALT (0XA4)
  46. #define UART_DBG_DLL (0XB0)
  47. #define UART_DBG_DLH (0XB4)
  48. struct tina_uart
  49. {
  50. volatile rt_uint32_t rx_tx_dll; /* 0x00 */
  51. volatile rt_uint32_t dlh_ier; /* 0x04 */
  52. volatile rt_uint32_t iir_fcr; /* 0x08 */
  53. volatile rt_uint32_t lcr; /* 0x0C */
  54. volatile rt_uint32_t mcr; /* 0x10 */
  55. volatile rt_uint32_t lsr; /* 0x14 */
  56. volatile rt_uint32_t msr; /* 0x18 */
  57. volatile rt_uint32_t sch; /* 0x1C */
  58. volatile rt_uint32_t reserved0[23];
  59. volatile rt_uint32_t usr; /* 0x7c */
  60. volatile rt_uint32_t tfl; /* 0x80 */
  61. volatile rt_uint32_t rfl; /* 0x84 */
  62. volatile rt_uint32_t hsk; /* 0x88 */
  63. volatile rt_uint32_t reserved1[6];
  64. volatile rt_uint32_t halt; /* 0xa4 */
  65. volatile rt_uint32_t reserved2[2];
  66. volatile rt_uint32_t dbg_dll; /* 0xb0 */
  67. volatile rt_uint32_t dbg_dlh; /* 0xb4 */
  68. };
  69. typedef struct tina_uart *tina_uart_t;
  70. #define UART0 ((tina_uart_t)UART0_BASE_ADDR)
  71. #define UART1 ((tina_uart_t)UART1_BASE_ADDR)
  72. #define UART2 ((tina_uart_t)UART2_BASE_ADDR)
  73. int rt_hw_uart_init(void);
  74. #endif /* __DRV_UART_H__ */