altos: Wake up on LPC usart ISR only once
authorKeith Packard <keithp@keithp.com>
Sat, 17 Aug 2013 15:45:06 +0000 (17:45 +0200)
committerKeith Packard <keithp@keithp.com>
Sat, 17 Aug 2013 15:45:06 +0000 (17:45 +0200)
Instead of waking up after every character, wait until the FIFO is
empty to reduce overhead

Signed-off-by: Keith Packard <keithp@keithp.com>
src/lpc/ao_serial_lpc.c

index d6b0082a093c400498b1013230efcc03854db3d4..431ae98a784e61aca1ca09590a8b29b334b77957 100644 (file)
@@ -49,21 +49,25 @@ _ao_serial_tx_start(void)
 void
 lpc_usart_isr(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);
        (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 (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
 }
 
 int