drv_uart.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2020-04-16 bigmagic first version
  9. */
  10. #ifndef DRV_UART_H__
  11. #define DRV_UART_H__
  12. // register's bit
  13. #define PL011_FR_RI (1 << 8)
  14. #define PL011_FR_TXFE (1 << 7)
  15. #define PL011_FR_RXFF (1 << 6)
  16. #define PL011_FR_TXFF (1 << 5)
  17. #define PL011_FR_RXFE (1 << 4)
  18. #define PL011_FR_BUSY (1 << 3)
  19. #define PL011_FR_DCD (1 << 2)
  20. #define PL011_FR_DSR (1 << 1)
  21. #define PL011_FR_CTS (1 << 0)
  22. #define PL011_LCRH_SPS (1 << 7)
  23. #define PL011_LCRH_WLEN_8 (3 << 5)
  24. #define PL011_LCRH_WLEN_7 (2 << 5)
  25. #define PL011_LCRH_WLEN_6 (1 << 5)
  26. #define PL011_LCRH_WLEN_5 (0 << 5)
  27. #define PL011_LCRH_FEN (1 << 4)
  28. #define PL011_LCRH_STP2 (1 << 3)
  29. #define PL011_LCRH_EPS (1 << 2)
  30. #define PL011_LCRH_PEN (1 << 1)
  31. #define PL011_LCRH_BRK (1 << 0)
  32. #define PL011_CR_CTSEN (1 << 15)
  33. #define PL011_CR_RTSEN (1 << 14)
  34. #define PL011_CR_RTS (1 << 11)
  35. #define PL011_CR_DTR (1 << 10)
  36. #define PL011_CR_RXE (1 << 9)
  37. #define PL011_CR_TXE (1 << 8)
  38. #define PL011_CR_LBE (1 << 7)
  39. #define PL011_CR_SIRLP (1 << 2)
  40. #define PL011_CR_SIREN (1 << 1)
  41. #define PL011_CR_UARTEN (1 << 0)
  42. #define PL011_IMSC_TXIM (1 << 5)
  43. #define PL011_IMSC_RXIM (1 << 4)
  44. #define PL011_INTERRUPT_OVERRUN_ERROR (1 << 10)
  45. #define PL011_INTERRUPT_BREAK_ERROR (1 << 9)
  46. #define PL011_INTERRUPT_PARITY_ERROR (1 << 8)
  47. #define PL011_INTERRUPT_FRAMING_ERROR (1 << 7)
  48. #define PL011_INTERRUPT_RECEIVE_TIMEOUT (1 << 6)
  49. #define PL011_INTERRUPT_TRANSMIT (1 << 5)
  50. #define PL011_INTERRUPT_RECEIVE (1 << 4)
  51. #define PL011_INTERRUPT_nUARTCTS (1 << 1)
  52. #define PL011_REG_DR(BASE) HWREG32(BASE + 0x00)
  53. #define PL011_REG_RSRECR(BASE) HWREG32(BASE + 0x04)
  54. #define PL011_REG_RESERVED0(BASE) HWREG32(BASE + 0x08)
  55. #define PL011_REG_FR(BASE) HWREG32(BASE + 0x18)
  56. #define PL011_REG_RESERVED1(BASE) HWREG32(BASE + 0x1C)
  57. #define PL011_REG_ILPR(BASE) HWREG32(BASE + 0x20)
  58. #define PL011_REG_IBRD(BASE) HWREG32(BASE + 0x24)
  59. #define PL011_REG_FBRD(BASE) HWREG32(BASE + 0x28)
  60. #define PL011_REG_LCRH(BASE) HWREG32(BASE + 0x2C)
  61. #define PL011_REG_CR(BASE) HWREG32(BASE + 0x30)
  62. #define PL011_REG_IFLS(BASE) HWREG32(BASE + 0x34)
  63. #define PL011_REG_IMSC(BASE) HWREG32(BASE + 0x38)
  64. #define PL011_REG_RIS(BASE) HWREG32(BASE + 0x3C)
  65. #define PL011_REG_MIS(BASE) HWREG32(BASE + 0x40)
  66. #define PL011_REG_ICR(BASE) HWREG32(BASE + 0x44)
  67. #define PL011_REG_DMACR(BASE) HWREG32(BASE + 0x48)
  68. #define PL011_REG_RESERVED2(BASE) HWREG32(BASE + 0x4C)
  69. #define PL011_REG_ITCR(BASE) HWREG32(BASE + 0x80)
  70. #define PL011_REG_ITIP(BASE) HWREG32(BASE + 0x84)
  71. #define PL011_REG_ITOP(BASE) HWREG32(BASE + 0x88)
  72. #define PL011_REG_TDR(BASE) HWREG32(BASE + 0x8C)
  73. int rt_hw_uart_init(void);
  74. #endif /* DRV_UART_H__ */