Skip to content

Commit

Permalink
Fix hard reboot request issue, probably caused by calling delay() fro…
Browse files Browse the repository at this point in the history
…m within a interrupt service routine
  • Loading branch information
stefan-b-jakobsson committed Jan 17, 2024
1 parent 35e98b8 commit 81dafb4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions x16-smc.ino
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ SmcButton RES_BUT(RESET_BUTTON_PIN);
#if defined(ENABLE_NMI_BUT)
SmcButton NMI_BUT(NMI_BUTTON_PIN);
#endif
bool hardRebootRequest = false;

// I2C
SmcWire smcWire;
Expand Down Expand Up @@ -209,6 +210,12 @@ void loop() {
//error handling?
}

// Process Hard Reboot Request
if (hardRebootRequest) {
hardRebootRequest = false;
HardReboot();
}

// Process Reset and NMI Requests
if (Keyboard.getResetRequest()) {
DoReset();
Expand Down Expand Up @@ -346,9 +353,11 @@ void I2C_Receive(int) {
switch (I2C_Data[0]) {
case CMD_POW_OFF:
switch (I2C_Data[1]) {
case 0: PowerOffSeq();
case 0:
PowerOffSeq();
break;
case 1: HardReboot();
case 1:
hardRebootRequest = true;
break;
}
break;
Expand Down

0 comments on commit 81dafb4

Please sign in to comment.