template<UART_HandleTypeDef * Handle,
UartType TxType = UartType::IT,
UartType RxType = UartType::IT>
class stm32rcos::peripheral::Uart< Handle, TxType, RxType >
デフォルトでTx, Rxともに割り込みを使用します。
#include <cstdio>
extern UART_HandleTypeDef huart2;
extern "C" void main_thread(void *) {
while (true) {
uint8_t data[] = {'h', 'e', 'l', 'l', 'o', '\r', '\n'};
uart2.
transmit(data,
sizeof(data), osWaitForever);
char c;
if (uart2.
receive((uint8_t *)&c, 1, osWaitForever)) {
printf("入力した文字: %c\r\n", c);
}
osDelay(10);
}
}
bool transmit(const uint8_t *data, size_t size, uint32_t timeout)
Definition uart.hpp:68
Uart(size_t rx_buf_size=64)
Definition uart.hpp:66
bool receive(uint8_t *data, size_t size, uint32_t timeout)
Definition uart.hpp:72
bool enable_stdout(UartBase &uart)