/** output one character */
void uart_putc(uint8_t data)
{
+#if UART_TX_ENABLED
/* store data */
fifo_enqueue((fifo_t *)&global_uart.tx, data);
/* enable interrupt */
_UCSRB_UART0 |= _BV(_UDRIE_UART0);
+#endif
}
/** init the hardware uart */
/* set mode */
_UCSRC_UART0 = UART_UCSRC;
+#if UART_TX_ENABLED
/* enable transmitter, receiver and receiver complete interrupt */
_UCSRB_UART0 = _BV(_TXEN_UART0) | _BV(_RXEN_UART0) | _BV(_RXCIE_UART0);
+ /* init tx fifo */
+ fifo_init((fifo_t *)&global_uart.tx);
+#else
+ /* enable receiver and receiver complete interrupt */
+ _UCSRB_UART0 = _BV(_RXEN_UART0) | _BV(_RXCIE_UART0);
+#endif
- /* init fifos */
+ /* init rx fifo */
fifo_init((fifo_t *)&global_uart.rx);
- fifo_init((fifo_t *)&global_uart.tx);
}
}
+#if UART_TX_ENABLED
/** uart data register empty interrupt */
ISR(_SIG_UART_DATA_UART0)
{
-
/* load next byte to transfer */
_UDR_UART0 = fifo_dequeue((fifo_t *)&global_uart.tx);
/* disable this interrupt */
_UCSRB_UART0 &= ~_BV(_UDRIE_UART0);
}
-
}
+#endif
#endif