Fix possible race condition and ensure proper reset flag detection

This commit is contained in:
2024-09-20 23:51:44 +02:00
parent 208aadf3a3
commit a423144599
3 changed files with 6 additions and 3 deletions

View File

@@ -192,6 +192,8 @@ static void WriteRaw(int addr, byte data)
static byte ReadRaw(int addr)
{
byte data;
// The EEPROM Read Enable Signal EERE is the read
// strobe to the EEPROM. When the correct address
// is set up in the EEAR Register, the EERE bit
@@ -214,7 +216,8 @@ static byte ReadRaw(int addr)
// Read from address
EECR |= BIT(EERE);
data = EEDR;
}
return EEDR;
return data;
}

View File

@@ -75,7 +75,7 @@ bool WDT_HasTriggered(void)
// JTD ISC2 JTRF WDRF BORF EXTRF PORF
// Is watchdog reset flag set?
isreset = ((MCUCSR & BIT(3)) == 1);
isreset = ((MCUCSR & BIT(WDRF)) != 0);
// XXX: Reset flag detection should be a separate
// module to handle the different types.