5#ifdef HAL_UART_MODULE_ENABLED
13#ifdef HAL_UART_MODULE_ENABLED
15template <UART_HandleTypeDef *Handle, UartType TxType>
class UartTx;
17template <UART_HandleTypeDef *Handle>
class UartTx<Handle,
UartType::
POLL> {
19 bool transmit(
const uint8_t *data,
size_t size, uint32_t timeout) {
20 return tx_.transmit(data, size, timeout);
24 UartTxPoll<Handle> tx_;
27template <UART_HandleTypeDef *Handle>
class UartTx<Handle,
UartType::
IT> {
29 bool transmit(
const uint8_t *data,
size_t size, uint32_t timeout) {
30 return tx_.transmit(data, size, timeout);
37template <UART_HandleTypeDef *Handle>
class UartTx<Handle,
UartType::
DMA> {
39 bool transmit(
const uint8_t *data,
size_t size, uint32_t timeout) {
40 return tx_.transmit(data, size, timeout);
44 UartTxDma<Handle> tx_;
47template <UART_HandleTypeDef *Handle, UartType RxType>
class UartRx;
49template <UART_HandleTypeDef *Handle>
class UartRx<Handle,
UartType::
POLL> {
51 UartRx(
size_t buf_size) : rx_{buf_size} {}
52 bool receive(uint8_t *data,
size_t size, uint32_t timeout) {
53 return rx_.receive(data, size, timeout);
55 void flush() { rx_.flush(); }
56 size_t available()
const {
return rx_.available(); }
59 UartRxPoll<Handle> rx_;
62template <UART_HandleTypeDef *Handle>
class UartRx<Handle,
UartType::
IT> {
64 UartRx(
size_t buf_size) : rx_{buf_size} {}
65 bool receive(uint8_t *data,
size_t size, uint32_t timeout) {
66 return rx_.receive(data, size, timeout);
68 void flush() { rx_.flush(); }
69 size_t available()
const {
return rx_.available(); }
75template <UART_HandleTypeDef *Handle>
class UartRx<Handle,
UartType::
DMA> {
77 UartRx(
size_t buf_size) : rx_{buf_size} {}
78 bool receive(uint8_t *data,
size_t size, uint32_t timeout) {
79 return rx_.receive(data, size, timeout);
81 void flush() { rx_.flush(); }
82 size_t available()
const {
return rx_.available(); }
85 UartRxDma<Handle> rx_;
92 Uart(
size_t rx_buf_size = 64) : rx_{rx_buf_size} {}
93 bool transmit(
const uint8_t *data,
size_t size, uint32_t timeout) {
94 return tx_.transmit(data, size, timeout);
96 bool receive(uint8_t *data,
size_t size, uint32_t timeout) {
97 return rx_.receive(data, size, timeout);
99 void flush() { rx_.flush(); }
100 size_t available()
const {
return rx_.available(); }
103 UartTx<Handle, TxType> tx_;
104 UartRx<Handle, RxType> rx_;
UartType
Definition common.hpp:8
@ DMA
Definition common.hpp:11
@ POLL
Definition common.hpp:9
@ IT
Definition common.hpp:10