drv_usart.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. * Copyright (c) 2022, Xiaohua Semiconductor Co., Ltd.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0
  6. *
  7. * Change Logs:
  8. * Date Author Notes
  9. * 2022-04-28 CDT first version
  10. */
  11. #ifndef __DRV_USART_H__
  12. #define __DRV_USART_H__
  13. /*******************************************************************************
  14. * Include files
  15. ******************************************************************************/
  16. #include <rtthread.h>
  17. #include "rtdevice.h"
  18. #include "drv_irq.h"
  19. #include "drv_dma.h"
  20. /* C binding of definitions if building with C++ compiler */
  21. #ifdef __cplusplus
  22. extern "C"
  23. {
  24. #endif
  25. /*******************************************************************************
  26. * Global type definitions ('typedef')
  27. ******************************************************************************/
  28. struct hc32_uart_irq_config
  29. {
  30. struct hc32_irq_config irq_config;
  31. func_ptr_t irq_callback;
  32. };
  33. /* HC32 config Rx timeout */
  34. struct hc32_uart_rxto
  35. {
  36. CM_TMR0_TypeDef *TMR0_Instance;
  37. rt_uint32_t channel;
  38. rt_uint32_t clock;
  39. rt_size_t timeout_bits;
  40. struct hc32_irq_config irq_config;
  41. func_ptr_t irq_callback;
  42. };
  43. /* HC32 config uart class */
  44. struct hc32_uart_config
  45. {
  46. const char *name;
  47. CM_USART_TypeDef *Instance;
  48. rt_uint32_t clock;
  49. struct hc32_uart_irq_config rxerr_irq;
  50. struct hc32_uart_irq_config rx_irq;
  51. struct hc32_uart_irq_config tx_irq;
  52. #ifdef RT_SERIAL_USING_DMA
  53. struct hc32_uart_rxto *rx_timeout;
  54. stc_dma_llp_descriptor_t llp_desc;
  55. struct dma_config *dma_rx;
  56. struct hc32_uart_irq_config *tc_irq;
  57. struct dma_config *dma_tx;
  58. #endif
  59. };
  60. /* HC32 uart dirver class */
  61. struct hc32_uart
  62. {
  63. struct hc32_uart_config *config;
  64. #ifdef RT_SERIAL_USING_DMA
  65. rt_size_t dma_rx_last_index;
  66. #endif
  67. rt_uint16_t uart_dma_flag;
  68. struct rt_serial_device serial;
  69. };
  70. /*******************************************************************************
  71. * Global pre-processor symbols/macros ('#define')
  72. ******************************************************************************/
  73. /*******************************************************************************
  74. * Global variable definitions ('extern')
  75. ******************************************************************************/
  76. /*******************************************************************************
  77. * Global function prototypes (definition in C source)
  78. ******************************************************************************/
  79. #ifdef __cplusplus
  80. }
  81. #endif
  82. #endif /* __DRV_USART_H__ */
  83. /*******************************************************************************
  84. * EOF (not truncated)
  85. ******************************************************************************/