Move SerialHead declaration outside of loops

This commit is contained in:
Alex Voinea 2021-03-03 14:35:37 +02:00
parent 026145b78b
commit 8ced0579d6
No known key found for this signature in database
GPG key ID: F5034E7CFCF2F973

View file

@ -126,6 +126,7 @@ uint8_t optiboot_w25x20cl_enter()
}
selectedSerialPort = 0; //switch to Serial0
MYSERIAL.flush(); //clear RX buffer
int SerialHead = rx_buffer.head;
// Send the initial magic string.
while (ptr != end)
putch(pgm_read_byte(ptr ++));
@ -143,7 +144,6 @@ uint8_t optiboot_w25x20cl_enter()
// With the volatile keyword the compiler generates exactly the same code as without it with only one difference:
// the last brne instruction jumps onto the (*rx_head == SerialHead) check and NOT onto the wdr instruction bypassing the check.
volatile int *rx_head = &rx_buffer.head;
int SerialHead = rx_buffer.head;
while (*rx_head == SerialHead) {
wdt_reset();
if ( --boot_timer == 0) {