diff --git a/drivers/uart.c b/drivers/uart.c new file mode 100644 index 0000000..16ab1ea --- /dev/null +++ b/drivers/uart.c @@ -0,0 +1,10 @@ +#include "uart.h" +#include + +#define BAUD_PRESCALE (((F_CPU/(BAUDRATE*8UL)))-1) + +void __attribute__ ((naked)) __attribute__ ((section (".init5"))) uart_init() { + UCSR0A = (1< +#include + +void __attribute__ ((naked)) __attribute__ ((section (".init6"))) uart_rx_async_init() { + UCSR0B = (1< + +extern void uart_process(uint8_t c); diff --git a/uart-relaycard.c b/uart-relaycard.c index 78deee6..c6bacf4 100644 --- a/uart-relaycard.c +++ b/uart-relaycard.c @@ -1,9 +1,7 @@ #include #include #include -#include - -#define BAUD_PRESCALE (((F_CPU/(BAUDRATE*8UL)))-1) +#include "drivers/uart_rx_async.h" /* Button matrix between PB3-PB4, PC0-PC3 * PC0-PC3 are inputs, default pull-up @@ -70,8 +68,7 @@ void setrelay(uint8_t n, uint8_t s) { } char umode = 't'; -ISR(USART_RX_vect) { - uint8_t c = UDR0; +void uart_process(uint8_t c) { if (c == 't' || c == 'e' || c == 'd') { umode = c; } else if (c >= '0' && c <= '7') { @@ -99,15 +96,6 @@ int main() { PORTD |= 0b11111100; PORTB |= 0b00000011; - // Init uart - UCSR0A = (1<