From 16cc3ea9f9f2b7775e2b1681cce525acbf117e79 Mon Sep 17 00:00:00 2001 From: sowgro Date: Sat, 4 Oct 2025 20:10:39 -0400 Subject: complete homework 4 --- project/Core/Src/Devices/UART.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'project/Core/Src/Devices') diff --git a/project/Core/Src/Devices/UART.c b/project/Core/Src/Devices/UART.c index b1eb30c..7c11e30 100644 --- a/project/Core/Src/Devices/UART.c +++ b/project/Core/Src/Devices/UART.c @@ -108,6 +108,13 @@ uint8_t USART_Read (USART_TypeDef * USARTx) { // Reading USART_DR automatically clears the RXNE flag } +uint8_t USART_Read_Nonblocking (USART_TypeDef * USARTx) { + if (!(USARTx->ISR & USART_ISR_RXNE)) + return 0; + + return ((uint8_t)(USARTx->RDR & 0xFF)); +} + void USART_Write(USART_TypeDef * USARTx, uint8_t *buffer, uint32_t nBytes) { int i; // TXE is cleared by a write to the USART_DR register. -- cgit v1.2.3