#ifndef DEVICE_USART0_H #define DEVICE_USART0_H #include #include /** * @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 */