|
@@ -115,8 +115,6 @@ uint8_t optiboot_w25x20cl_enter()
|
|
|
|
|
|
{
|
|
|
wdt_reset();
|
|
|
- unsigned long boot_timeout = 2000000;
|
|
|
- unsigned long boot_timer = 0;
|
|
|
const char *ptr = entry_magic_send;
|
|
|
const char *end = strlen_P(entry_magic_send) + ptr;
|
|
|
const uint8_t selectedSerialPort_bak = selectedSerialPort;
|
|
@@ -138,11 +136,17 @@ uint8_t optiboot_w25x20cl_enter()
|
|
|
ptr = entry_magic_receive;
|
|
|
end = strlen_P(entry_magic_receive) + ptr;
|
|
|
while (ptr != end) {
|
|
|
- while (rx_buffer.head == SerialHead) {
|
|
|
+ unsigned long boot_timer = 2000000;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ volatile int *rx_head = &rx_buffer.head;
|
|
|
+ while (*rx_head == SerialHead) {
|
|
|
wdt_reset();
|
|
|
- delayMicroseconds(1);
|
|
|
- if (++ boot_timer > boot_timeout)
|
|
|
- {
|
|
|
+ if ( --boot_timer == 0) {
|
|
|
|
|
|
selectedSerialPort = selectedSerialPort_bak;
|
|
|
return 0;
|
|
@@ -161,6 +165,7 @@ uint8_t optiboot_w25x20cl_enter()
|
|
|
cbi(UCSR0B, RXCIE0);
|
|
|
|
|
|
ptr = entry_magic_cfm;
|
|
|
+ end = strlen_P(entry_magic_cfm) + ptr;
|
|
|
while (ptr != end)
|
|
|
putch(pgm_read_byte(ptr ++));
|
|
|
}
|