Skip to content

Commit

Permalink
Check for incoming UART data in ledBlink.
Browse files Browse the repository at this point in the history
Improves reliability, especially with larger LED_START_FLASHES values.
  • Loading branch information
WestfW committed Jul 25, 2018
1 parent 808d685 commit b109eb2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions optiboot/bootloaders/optiboot/optiboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,20 @@ void flash_led(uint8_t count) {
LED_PIN |= _BV(LED);
#endif
watchdogReset();
#ifndef SOFT_UART
/*
* While in theory, the STK500 initial commands would be buffered
* by the UART hardware, avrdude sends several attempts in rather
* quick succession, some of which will be lost and cause us to
* get out of sync. So if we see any data; stop blinking.
*/
if (UART_SRA & _BV(RXC0))
break;
#else
// This doesn't seem to work?
// if ((UART_PIN & (1<<UART_RX_BIT)) == 0)
// break; // detect start bit on soft uart too.
#endif
} while (--count);
}
#endif
Expand Down

0 comments on commit b109eb2

Please sign in to comment.