generated from hulk/gd32e23x_template
33 lines
557 B
C
33 lines
557 B
C
//
|
|
// Created by yelv1 on 24-12-30.
|
|
//
|
|
|
|
#ifndef USART_H
|
|
#define USART_H
|
|
|
|
#include "gd32e23x.h"
|
|
#include "board_config.h"
|
|
|
|
#define RX_BUFFER_SIZE 64
|
|
|
|
typedef struct
|
|
{
|
|
unsigned char buffer[RX_BUFFER_SIZE];
|
|
volatile unsigned int head;
|
|
volatile unsigned int tail;
|
|
}ring_buffer_t;
|
|
|
|
static ring_buffer_t rx_buffer = {{0}, 0, 0}; // ring buffer for USART0
|
|
|
|
void usart_config(void);
|
|
|
|
void rs485_config(void);
|
|
|
|
void store_char(unsigned char data, ring_buffer_t *rx_buf);
|
|
|
|
uint16_t uart_available(void);
|
|
|
|
int uart_read(void);
|
|
|
|
#endif //USART_H
|