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 
11 #ifndef __DRV_USART_V2_H__
12 #define __DRV_USART_V2_H__
13 
14 #include <rthw.h>
15 #include <rtthread.h>
16 #include <rtdevice.h>
17 #include <board.h>
18 #include "drv_dma.h"
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 
25 /* GD32 uart driver */
26 struct gd32_uart
27 {
28     char *device_name;
29     uint32_t periph;
30     IRQn_Type irqn;
31     rcu_periph_enum per_clk;
32     rcu_periph_enum tx_gpio_clk;
33     rcu_periph_enum rx_gpio_clk;
34     uint32_t tx_port;
35 #if defined SOC_SERIES_GD32F4xx || defined SOC_SERIES_GD32E23x
36     uint16_t tx_af;
37 #endif
38     uint16_t tx_pin;
39     uint32_t rx_port;
40 #if defined SOC_SERIES_GD32F4xx || defined SOC_SERIES_GD32E23x
41     uint16_t rx_af;
42 #endif
43     uint16_t rx_pin;
44 
45     struct rt_serial_device serial;
46 
47 #ifdef RT_SERIAL_USING_DMA
48     struct
49     {
50         struct dma_config rx;
51         struct dma_config tx;
52         rt_size_t last_index;
53         rt_sem_t sem_ftf;
54     } dma;
55 #endif
56     rt_uint16_t uart_dma_flag;
57 };
58 
59 int rt_hw_usart_init(void);
60 
61 #ifdef __cplusplus
62 }
63 #endif
64 
65 #endif /* __DRV_USART_V2_H__ */
66 
67