summaryrefslogtreecommitdiff
path: root/ucoo/hal/uart/uart.stm32.cc
diff options
context:
space:
mode:
authorNicolas Schodet2015-10-31 14:40:04 +0100
committerNicolas Schodet2019-10-07 00:44:57 +0200
commit4fd623cd267ecfb1663be4e7c8b56c55201c3c82 (patch)
treef2169aa7b2420495c5dd9f55662a7e6d8d0e2921 /ucoo/hal/uart/uart.stm32.cc
parent2cda37290deeed9ace58dc59ea1f169643f6cbd0 (diff)
ucoo/hal/uart: add event handler
Diffstat (limited to 'ucoo/hal/uart/uart.stm32.cc')
-rw-r--r--ucoo/hal/uart/uart.stm32.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/ucoo/hal/uart/uart.stm32.cc b/ucoo/hal/uart/uart.stm32.cc
index 96e726d..9fdeee9 100644
--- a/ucoo/hal/uart/uart.stm32.cc
+++ b/ucoo/hal/uart/uart.stm32.cc
@@ -198,14 +198,22 @@ Uart::isr (int n)
if (sr & USART_SR_RXNE)
{
if (!uart.rx_fifo_.full ())
+ {
+ bool was_empty = uart.rx_fifo_.empty ();
uart.rx_fifo_.push (dr);
+ if (was_empty && uart.handler_)
+ uart.handler_ (true);
+ }
}
if (sr & USART_SR_TXE)
{
+ bool was_full = uart.tx_fifo_.full ();
if (!uart.tx_fifo_.empty ())
USART_DR (base) = static_cast<uint8_t> (uart.tx_fifo_.pop ());
if (uart.tx_fifo_.empty ())
USART_CR1 (base) &= ~USART_CR1_TXEIE;
+ if (was_full && uart.handler_)
+ uart.handler_ (false);
}
}