mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-01 12:24:14 +01:00
Fix loops in the SAM banzai() reset function
The code used to say: while (EFC0->EEFC_FSR & EEFC_FSR_FRDY == 0); This triggered a compiler warning, which is why I looked at this line more closely: warning: suggest parentheses around comparison in operand of '&' As the warning indicates, because the == operator has higher precedence than the & operator, the compiler is interpreting this line as: while (EFC0->EEFC_FSR & (EEFC_FSR_FRDY == 0)); Since EEFC_FSR_FRDY is defined as 1, (EEFC_FSR_FRDY == 0) is always false (== 0) and this reduces to: while (EFC0->EEFC_FSR & 0); Which reduces to: while (0); So effectively this line is a no-op. This commit adds parenthesis to restore the intended behaviour.
This commit is contained in:
parent
ce65ecec06
commit
8120558af5
@ -31,12 +31,12 @@ void banzai() {
|
||||
// Set bootflag to run SAM-BA bootloader at restart
|
||||
const int EEFC_FCMD_CGPB = 0x0C;
|
||||
const int EEFC_KEY = 0x5A;
|
||||
while (EFC0->EEFC_FSR & EEFC_FSR_FRDY == 0);
|
||||
while ((EFC0->EEFC_FSR & EEFC_FSR_FRDY) == 0);
|
||||
EFC0->EEFC_FCR =
|
||||
EEFC_FCR_FCMD(EEFC_FCMD_CGPB) |
|
||||
EEFC_FCR_FARG(1) |
|
||||
EEFC_FCR_FKEY(EEFC_KEY);
|
||||
while (EFC0->EEFC_FSR & EEFC_FSR_FRDY == 0);
|
||||
while ((EFC0->EEFC_FSR & EEFC_FSR_FRDY) == 0);
|
||||
|
||||
// From here flash memory is no more available.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user