diff options
author | Keith Packard <keithp@keithp.com> | 2013-08-17 17:45:06 +0200 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2013-08-25 16:22:48 -0700 |
commit | aa2948803d33dbee6f1eab30370178252df2b56d (patch) | |
tree | aae638e5b6092c7c356f881214e8bdb6797fdcfa | |
parent | 10f88c46df9a266f62452dc25275c79a3bb0653d (diff) |
altos: Wake up on LPC usart ISR only once
Instead of waking up after every character, wait until the FIFO is
empty to reduce overhead
Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r-- | src/lpc/ao_serial_lpc.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/lpc/ao_serial_lpc.c b/src/lpc/ao_serial_lpc.c index c0424699..b34de704 100644 --- a/src/lpc/ao_serial_lpc.c +++ b/src/lpc/ao_serial_lpc.c @@ -49,21 +49,25 @@ _ao_serial_tx_start(void) void lpc_usart_isr(void) { + uint8_t wake_input = 0; (void) lpc_usart.iir_fcr; while (lpc_usart.lsr & (1 << LPC_USART_LSR_RDR)) { char c = lpc_usart.rbr_thr; if (!ao_fifo_full(ao_usart_rx_fifo)) ao_fifo_insert(ao_usart_rx_fifo, c); - ao_wakeup(&ao_usart_rx_fifo); - if (stdin) - ao_wakeup(&ao_stdin_ready); + wake_input = 1; } if (lpc_usart.lsr & (1 << LPC_USART_LSR_THRE)) { ao_usart_tx_avail = LPC_USART_TX_FIFO_SIZE; _ao_serial_tx_start(); ao_wakeup(&ao_usart_tx_fifo); } + if (wake_input) { + ao_wakeup(&ao_usart_rx_fifo); + if (stdin) + ao_wakeup(&ao_stdin_ready); + } } int |