X-Git-Url: http://git.droids-corp.org/?p=aversive.git;a=blobdiff_plain;f=modules%2Fcomm%2Fuart%2Fuart_recv9_nowait.c;h=3cded5c8f9d6fed0189058a2ede4fc96bb979d1e;hp=8c626a2394c00d168f41811f8b962ac5de1faacd;hb=6d8949fd4fc3a1e65ff060cfbdb5e405efe15c6c;hpb=ccc6954bb046671b9e28c5806db5121c1eef49c0 diff --git a/modules/comm/uart/uart_recv9_nowait.c b/modules/comm/uart/uart_recv9_nowait.c index 8c626a2..3cded5c 100644 --- a/modules/comm/uart/uart_recv9_nowait.c +++ b/modules/comm/uart/uart_recv9_nowait.c @@ -31,13 +31,23 @@ int uart_9bits_recv_nowait(uint8_t num) char elt = 0; uint8_t flags; - IRQ_LOCK(flags); - if( CIRBUF_GET_LEN(&g_rx_fifo[num]) >= 2) { - cirbuf_get_buf_tail(&g_rx_fifo[num], (char *)&elt, 2); - cirbuf_del_buf_tail(&g_rx_fifo[num], 2); + /* if interrupt mode is off, we have to check the status + * register */ + if (!(*uart_regs[num].ucsrb & (1 << RXCIE))) { + if ( !(*uart_regs[num].ucsra & (1 << RXC)) ) + return -1; + return uart_get_udr_9bits(num); + } + /* else check the fifo */ + else { + IRQ_LOCK(flags); + if( CIRBUF_GET_LEN(&g_rx_fifo[num]) >= 2) { + cirbuf_get_buf_tail(&g_rx_fifo[num], (char *)&elt, 2); + cirbuf_del_buf_tail(&g_rx_fifo[num], 2); + IRQ_UNLOCK(flags); + return (int)elt; + } IRQ_UNLOCK(flags); - return (int)elt; + return -1; } - IRQ_UNLOCK(flags); - return (-1); }