Browse Source

Move SerialHead declaration outside of loops

Alex Voinea 3 years ago
parent
commit
8ced0579d6
1 changed files with 1 additions and 1 deletions
  1. 1 1
      Firmware/optiboot_w25x20cl.cpp

+ 1 - 1
Firmware/optiboot_w25x20cl.cpp

@@ -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) {