Files
DCU_APP/GD32E508_DCU_APP/device/usart0.h
T

30 lines
691 B
C++
Raw Normal View History

#ifndef DEVICE_USART0_H
#define DEVICE_USART0_H
#include <stdint.h>
#include <stdio.h>
/**
* @brief USART0 串口模块。
* @note 负责 GPIO 初始化、串口配置、TX 环形缓冲与中断驱动发送。
*/
class Usart0 {
public:
static void configurePins();
static void init();
static int putChar(int ch, FILE *f);
static void onInterrupt();
private:
static uint16_t nextIndex(uint16_t idx);
static bool isBufferFull();
static bool isBufferEmpty();
static constexpr uint16_t kTxBufSize = 256U;
static uint8_t s_txBuf[kTxBufSize];
static volatile uint16_t s_txHead;
static volatile uint16_t s_txTail;
};
#endif /* DEVICE_USART0_H */