Fix large serial command input triggering watchdog
This commit is contained in:
@@ -48,6 +48,7 @@ void USART_Putc(char ch)
|
|||||||
{
|
{
|
||||||
short head;
|
short head;
|
||||||
|
|
||||||
|
// Wrap around if end of buffer reached
|
||||||
head = (txhead + 1) & USART_TXBUF_MASK;
|
head = (txhead + 1) & USART_TXBUF_MASK;
|
||||||
while (head == txtail); // Wait for space
|
while (head == txtail); // Wait for space
|
||||||
|
|
||||||
@@ -62,16 +63,18 @@ void USART_Putc(char ch)
|
|||||||
ISR(USART_RXC_vect)
|
ISR(USART_RXC_vect)
|
||||||
{
|
{
|
||||||
short head;
|
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;
|
head = (rxhead + 1) & USART_RXBUF_MASK;
|
||||||
|
|
||||||
// Free space in RX buffer?
|
// Free space in RX buffer?
|
||||||
|
// Otherwise discard overflow
|
||||||
if (head != rxtail) {
|
if (head != rxtail) {
|
||||||
// Copy from register
|
rxbuf[head] = data;
|
||||||
rxbuf[head] = UDR;
|
|
||||||
rxhead = head;
|
rxhead = head;
|
||||||
} else {
|
|
||||||
// XXX: Discard overflow
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
|
|
||||||
// TODO: Config header for chip specifics like EEPROM size.
|
// 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: Only update EEPROM if value differs from previous.
|
||||||
// TODO: Check thermistor conversion results /w thermometer.
|
// TODO: Check thermistor conversion results /w thermometer.
|
||||||
// TODO: Implement primary state machine for update loop.
|
// TODO: Implement primary state machine for update loop.
|
||||||
|
|||||||
Reference in New Issue
Block a user