From 56a334b8934597f8ebbcb3cabb00570e21497ad5 Mon Sep 17 00:00:00 2001 From: Karl Palsson Date: Mon, 31 Jan 2022 22:01:02 +0000 Subject: stm32_uart: add write_blocking helper A nice easy basic helper for "I just wannna wite a char now!" --- uart/stm32_uart.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/uart/stm32_uart.h b/uart/stm32_uart.h index 08f93d1..c4ba582 100644 --- a/uart/stm32_uart.h +++ b/uart/stm32_uart.h @@ -44,4 +44,10 @@ template class STM32_UART_t : public mmio_ptr { public: using mmio_ptr::ptr; + + void write_blocking(uint8_t data) const { + // wait for TXE/TXFNF + while (!(ptr()->ISR & (1<<7))); + ptr()->TDR = data; + } }; -- cgit v1.2.3