1. Configure UART messages to have 2 stop bits.

2. Move mirroring of received characters to ISR.
This commit is contained in:
Marco 2022-05-30 06:11:50 +02:00
parent 927276afb5
commit 754fc2bc92

View File

@ -4,6 +4,7 @@
#include "include/uart.h" #include "include/uart.h"
#include "include/commands.h" #include "include/commands.h"
/* Make uart_printf be called whenever printf() is invoked */
static FILE stream = FDEV_SETUP_STREAM(uart_printf, NULL, _FDEV_SETUP_WRITE); static FILE stream = FDEV_SETUP_STREAM(uart_printf, NULL, _FDEV_SETUP_WRITE);
void uart_init(unsigned int baud) void uart_init(unsigned int baud)
@ -22,7 +23,7 @@ void uart_init(unsigned int baud)
/* Set frame format */ /* Set frame format */
UCSR1C |= (3<<UCSZ10); // 8 data bits UCSR1C |= (3<<UCSZ10); // 8 data bits
// UCSR1C &= ~(1<<USBS1); // 1 stop bit UCSR1C |= (1<<USBS1); // 2 stop bits
} }
void uart_sendByte(uint8_t byte) void uart_sendByte(uint8_t byte)
@ -44,8 +45,8 @@ int uart_printf(char var, FILE *stream)
ISR(USART1_RX_vect) ISR(USART1_RX_vect)
{ {
char u; char c = UDR1;
u = UDR1;
cmd_collect_char(u); cmd_collect_char(c);
uart_sendByte(c);
} }