diff options
| author | sowgro <tpoke.ferrari@gmail.com> | 2025-10-04 20:10:39 -0400 |
|---|---|---|
| committer | sowgro <tpoke.ferrari@gmail.com> | 2025-10-04 20:10:39 -0400 |
| commit | 16cc3ea9f9f2b7775e2b1681cce525acbf117e79 (patch) | |
| tree | 4ba4b95bf5d2d41463458acbb448b8280e79bd4e /project/Core/Src/Devices | |
| parent | 80c01675b3aa51d774eba7db61c6addea9d02f9a (diff) | |
| download | 340-repo-Sowgro-16cc3ea9f9f2b7775e2b1681cce525acbf117e79.tar.gz 340-repo-Sowgro-16cc3ea9f9f2b7775e2b1681cce525acbf117e79.tar.bz2 340-repo-Sowgro-16cc3ea9f9f2b7775e2b1681cce525acbf117e79.zip | |
complete homework 4
Diffstat (limited to 'project/Core/Src/Devices')
| -rw-r--r-- | project/Core/Src/Devices/UART.c | 7 |
1 files changed, 7 insertions, 0 deletions
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. |
