18struct UART_HandleTypeDef;
39 explicit StmUart(UART_HandleTypeDef* huart,
57 hf_u32_t timeout_ms = 0) noexcept override;
59 hf_u32_t timeout_ms = 0) noexcept override;
63 int Printf(const
char* format, ...) noexcept override;
Abstract base class for UART driver implementations in the HardFOC system.
hf_uart_err_t
Definition BaseUart.h:84
uint32_t hf_u32_t
Platform-agnostic 32-bit unsigned integer type.
Definition HardwareTypes.h:52
uint8_t hf_u8_t
Platform-agnostic 8-bit unsigned integer type.
Definition HardwareTypes.h:40
hf_u32_t hf_port_num_t
Platform-agnostic port/controller identifier type.
Definition HardwareTypes.h:120
uint16_t hf_u16_t
Platform-agnostic 16-bit unsigned integer type.
Definition HardwareTypes.h:46
STM32 platform-specific type definitions for hardware abstraction.
Abstract base class for UART driver implementations.
Definition BaseUart.h:191
STM32 UART implementation.
Definition StmUart.h:31
void EnableRxBuffer(hf_u8_t *buffer, hf_u16_t size) noexcept
Enable a software RX ring buffer.
Definition StmUart.cpp:194
hf_uart_err_t FlushTx() noexcept override
Flush the transmit buffer.
Definition StmUart.cpp:160
~StmUart() noexcept override
Definition StmUart.cpp:59
hf_uart_err_t FlushRx() noexcept override
Flush the receive buffer.
Definition StmUart.cpp:166
StmUart(const StmUart &)=delete
bool Initialize() noexcept override
Initialize the UART driver.
Definition StmUart.cpp:67
hf_u16_t BytesAvailable() noexcept override
Get the number of bytes available to read.
Definition StmUart.cpp:152
hf_uart_err_t Write(const hf_u8_t *data, hf_u16_t length, hf_u32_t timeout_ms=0) noexcept override
Write data to the UART.
Definition StmUart.cpp:92
hf_u8_t * rx_buf_
Definition StmUart.h:95
UART_HandleTypeDef * huart_
Definition StmUart.h:91
StmUart(UART_HandleTypeDef *huart, hf_port_num_t port=0) noexcept
Construct from HAL UART handle.
Definition StmUart.cpp:37
StmUart & operator=(const StmUart &)=delete
hf_u16_t rx_buf_size_
Definition StmUart.h:96
void FeedRxBlock(const hf_u8_t *data, hf_u16_t length) noexcept
Feed a block of bytes into the RX ring buffer (call from ISR/DMA).
Definition StmUart.cpp:213
volatile hf_u16_t rx_tail_
Read index (user reads)
Definition StmUart.h:98
UART_HandleTypeDef * GetHalHandle() const noexcept
Definition StmUart.h:66
volatile hf_u16_t rx_head_
Write index (ISR writes)
Definition StmUart.h:97
int Printf(const char *format,...) noexcept override
Printf-style formatted output.
Definition StmUart.cpp:173
hf_u32_t default_timeout_ms_
Definition StmUart.h:92
void FeedRxByte(hf_u8_t byte) noexcept
Feed a byte into the RX ring buffer (call from ISR).
Definition StmUart.cpp:201
hf_uart_err_t Read(hf_u8_t *data, hf_u16_t length, hf_u32_t timeout_ms=0) noexcept override
Read data from the UART.
Definition StmUart.cpp:115
bool Deinitialize() noexcept override
Deinitialize the UART driver.
Definition StmUart.cpp:81
Platform-agnostic UART configuration for STM32.
Definition StmTypes.h:342