#ifndef __DRV_USART_H__
#define __DRV_USART_H__

#include <rtthread.h>
#include <rtservice.h>
#include "gd32f4xx.h"
#include "gd32f4xx_usart.h"

// 串口配置结构体
struct gd32_usart_config {
    const char *name;
    uint32_t usart_periph;
    uint32_t rcu_periph_clock;
    uint32_t gpio_port;
    uint32_t rcu_gpio_clock;
    uint32_t tx_pin;
    uint32_t rx_pin;
    uint32_t baud_rate;
    uint8_t irq_type;
};

// 函数声明
void gd32_usart_init(void);
void gd32_usart_configure(struct gd32_usart_config *config);
void gd32_usart_putchar(struct gd32_usart_config *config, char ch);
void gd32_usart_puts(struct gd32_usart_config *config, const char *str);
struct gd32_usart_config *gd32_usart_get_config(const char *name);

#endif /* __DRV_USART_H__ */