drv_usart_v2.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (c) 2006-2025, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2024-03-19 Evlers first implementation
  9. */
  10. #ifndef __DRV_USART_V2_H__
  11. #define __DRV_USART_V2_H__
  12. #include <rthw.h>
  13. #include <rtthread.h>
  14. #include <rtdevice.h>
  15. #include <board.h>
  16. #include "drv_dma.h"
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. /* GD32 uart driver */
  21. struct gd32_uart
  22. {
  23. char *device_name;
  24. uint32_t periph;
  25. IRQn_Type irqn;
  26. rcu_periph_enum per_clk;
  27. rcu_periph_enum tx_gpio_clk;
  28. rcu_periph_enum rx_gpio_clk;
  29. uint32_t tx_port;
  30. #if defined SOC_SERIES_GD32F4xx || defined SOC_SERIES_GD32E23x
  31. uint16_t tx_af;
  32. #endif
  33. uint16_t tx_pin;
  34. uint32_t rx_port;
  35. #if defined SOC_SERIES_GD32F4xx || defined SOC_SERIES_GD32E23x
  36. uint16_t rx_af;
  37. #endif
  38. uint16_t rx_pin;
  39. struct rt_serial_device serial;
  40. #ifdef RT_SERIAL_USING_DMA
  41. struct
  42. {
  43. struct dma_config rx;
  44. struct dma_config tx;
  45. rt_size_t last_index;
  46. rt_sem_t sem_ftf;
  47. } dma;
  48. #endif
  49. rt_uint16_t uart_dma_flag;
  50. };
  51. int rt_hw_usart_init(void);
  52. #ifdef __cplusplus
  53. }
  54. #endif
  55. #endif /* __DRV_USART_V2_H__ */