diff --git a/src/bus/usart.c b/src/bus/usart.c index 9b08d16..9b7dd1e 100644 --- a/src/bus/usart.c +++ b/src/bus/usart.c @@ -48,6 +48,7 @@ void USART_Putc(char ch) { short head; + // Wrap around if end of buffer reached head = (txhead + 1) & USART_TXBUF_MASK; while (head == txtail); // Wait for space @@ -62,16 +63,18 @@ void USART_Putc(char ch) ISR(USART_RXC_vect) { short head; + byte data; - // Next byte ready to read from serial + data = UDR; // Next byte ready + + // Wrap around if end of buffer reached head = (rxhead + 1) & USART_RXBUF_MASK; + // Free space in RX buffer? + // Otherwise discard overflow if (head != rxtail) { - // Copy from register - rxbuf[head] = UDR; + rxbuf[head] = data; rxhead = head; - } else { - // XXX: Discard overflow } } diff --git a/src/main.c b/src/main.c index be70ec0..b542ef1 100644 --- a/src/main.c +++ b/src/main.c @@ -7,7 +7,6 @@ #include // TODO: Config header for chip specifics like EEPROM size. -// TODO: Fix huge serial command input triggering watchdog. // TODO: Only update EEPROM if value differs from previous. // TODO: Check thermistor conversion results /w thermometer. // TODO: Implement primary state machine for update loop.