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);
}
char elt = 0;
uint8_t flags;
- IRQ_LOCK(flags);
- if( !CIRBUF_IS_EMPTY(&g_rx_fifo[num]) ) {
- elt = cirbuf_get_tail(&g_rx_fifo[num]);
- cirbuf_del_tail(&g_rx_fifo[num]);
+ /* 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(num);
+ }
+ /* else check the fifo */
+ else {
+ IRQ_LOCK(flags);
+ if( !CIRBUF_IS_EMPTY(&g_rx_fifo[num]) ) {
+ elt = cirbuf_get_tail(&g_rx_fifo[num]);
+ cirbuf_del_tail(&g_rx_fifo[num]);
+ IRQ_UNLOCK(flags);
+ return (int)elt;
+ }
IRQ_UNLOCK(flags);
- return (int)elt;
+ return -1;
}
- IRQ_UNLOCK(flags);
- return (-1);
}