From: Keith Packard Date: Sat, 17 Aug 2013 15:45:06 +0000 (+0200) Subject: altos: Wake up on LPC usart ISR only once X-Git-Tag: 1.2.9.4~137 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=0dd55f66d79f54b450fd8122aecd84d68b810bf4;ds=sidebyside 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 --- diff --git a/src/lpc/ao_serial_lpc.c b/src/lpc/ao_serial_lpc.c index d6b0082a..431ae98a 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