diff --git a/emb/uart.cpp b/emb/uart.cpp index 0308b8b1a6817e3af5c32a47a968a8ff373893b0..003d68225e649e9a86340101f65498137999e3c9 100644 --- a/emb/uart.cpp +++ b/emb/uart.cpp @@ -12,7 +12,6 @@ void initUart() UCSR0A = (1 << U2X0); // double transmission speed UCSR0B = (1 << RXCIE0) // enable RX complete interrupt - | (1 << UDRIE0) // enable data register empty interrupt | (1 << RXEN0) // enable receiver | (1 << TXEN0); // enable transmitter UCSR0C = (0 << UMSEL01) | (0 << UMSEL00) // asynchronous USART @@ -25,12 +24,14 @@ void initUart() sei(); } -ISR(USART_RX_vect) +void writeUart(uint8_t value) { - uart_add_ch(UDR0); + while (!(UCSR0A & (1 << UDRE0))); + + UDR0 = value; } -ISR(USART_UDRE_vect) +ISR(USART_RX_vect) { - // nothing to do right now + uart_add_ch(UDR0); } diff --git a/emb/uart.hpp b/emb/uart.hpp index 2a10f18db8adc083d80ede632b613e43860e8635..b391efd1f2bc0db680fe2e5aa45fd19e7dbff10c 100644 --- a/emb/uart.hpp +++ b/emb/uart.hpp @@ -1,9 +1,16 @@ #ifndef UART_H #define UART_H +#include <stdint.h> + /** * Initialises the UART logic. */ void initUart(); +/** + * Writes a character to the UART port. + */ +void writeUart(uint8_t value); + #endif /* UART_H */