fearly_uart.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright : (C) 2022 Phytium Information Technology, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is OPEN SOURCE software: you can redistribute it and/or modify it
  6. * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
  7. * either version 1.0 of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
  10. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. * See the Phytium Public License for more details.
  12. *
  13. *
  14. * FilePath: fearly_uart.h
  15. * Date: 2022-02-11 13:33:28
  16. * LastEditTime: 2022-02-17 18:00:16
  17. * Description:  This file is for
  18. *
  19. * Modify History:
  20. * Ver   Who        Date         Changes
  21. * ----- ------     --------    --------------------------------------
  22. * 1.0 rtos 2022/6/25 init commit
  23. */
  24. #ifndef BOARD_COMMON_EARLY_UART_H
  25. #define BOARD_COMMON_EARLY_UART_H
  26. #ifdef __cplusplus
  27. extern "C"
  28. {
  29. #endif
  30. /***************************** Include Files *********************************/
  31. #include "ftypes.h"
  32. #include "fio.h"
  33. #include "fparameters.h"
  34. #include "sdkconfig.h"
  35. /**************************** Type Definitions *******************************/
  36. /************************** Constant Definitions *****************************/
  37. #if defined(CONFIG_DEFAULT_DEBUG_PRINT_UART2)
  38. #define EARLY_UART_BASE FUART2_BASE_ADDR
  39. #define EARLY_UART_IRQ_NUM FUART2_IRQ_NUM
  40. #elif defined(CONFIG_DEFAULT_DEBUG_PRINT_UART0)
  41. #define EARLY_UART_BASE FUART0_BASE_ADDR
  42. #define EARLY_UART_IRQ_NUM FUART0_IRQ_NUM
  43. #else
  44. #define EARLY_UART_BASE FUART1_BASE_ADDR
  45. #define EARLY_UART_IRQ_NUM FUART1_IRQ_NUM
  46. #endif
  47. #define EARLY_UART_UARTDR (EARLY_UART_BASE + 0x0) /* UART 数据寄存器地址 */
  48. #define EARLY_UART_UARTFR (EARLY_UART_BASE + 0x18) /* UART 状态寄存器地址 */
  49. #define EARLY_UART_UARTCR (EARLY_UART_BASE + 0x30)
  50. #define EARLY_UART_UARTCR_UARTEN BIT(0)
  51. #define EARLY_UART_UARTCR_TXE BIT(8)
  52. #define EARLY_UART_UARTCR_RXE BIT(9)
  53. #define EARLY_UART_UARTCR_INIT (EARLY_UART_UARTCR_UARTEN | EARLY_UART_UARTCR_TXE | \
  54. EARLY_UART_UARTCR_RXE)
  55. #define EARLY_UART_UARTIMSC (EARLY_UART_BASE + 0x38)
  56. #define EARLY_UART_UARTIMSC_RXIM BIT(4)
  57. #define EARLY_UART_UARTIMSC_RTIM BIT(6)
  58. #define EARLY_UART_UARTMIS (EARLY_UART_BASE + 0x40)
  59. #define EARLY_UART_UARTICR (EARLY_UART_BASE + 0x44)
  60. #define EARLY_UART_TXFF BIT(5) /* 发送 FIFO 已满标志位 */
  61. #define EARLY_UART_RXFE BIT(4) /* 接收 FIFO 为空标志位 */
  62. #define EARLY_UART_DATA_MASK GENMASK(7, 0)
  63. #define EARLY_UART_RXI_MASK BIT(4)
  64. #define STDOUT_BASEADDRESS
  65. /************************** Variable Definitions *****************************/
  66. /***************** Macros (Inline Functions) Definitions *********************/
  67. /*****************************************************************************/
  68. void OutByte(s8 byte);
  69. char GetByte(void);
  70. #ifdef __cplusplus
  71. }
  72. #endif
  73. #endif