rename flag, send nak

This commit is contained in:
Matthew Kennedy 2020-12-10 17:30:41 -08:00
parent 2c7679e526
commit a418c9903f
1 changed files with 8 additions and 4 deletions

View File

@ -57,7 +57,6 @@ void EraseAppPages()
} }
} }
bool holdBoot = false;
void WaitForBootloaderCmd() void WaitForBootloaderCmd()
{ {
@ -97,6 +96,8 @@ void sendNak()
// TODO: implement // TODO: implement
} }
bool bootloaderBusy = false;
void RunBootloaderLoop() void RunBootloaderLoop()
{ {
// First ack that the bootloader is alive // First ack that the bootloader is alive
@ -155,9 +156,12 @@ void RunBootloaderLoop()
break; break;
case 0x03: // opcode 3 is "boot app" case 0x03: // opcode 3 is "boot app"
// Clear the flag // Clear the flag
holdBoot = false; bootloaderBusy = false;
// Kill this thread // Kill this thread
return; return;
default:
sendNak();
break;
} }
} }
} }
@ -170,7 +174,7 @@ THD_FUNCTION(BootloaderThread, arg)
WaitForBootloaderCmd(); WaitForBootloaderCmd();
// We've rx'd a BL command, don't load the app! // We've rx'd a BL command, don't load the app!
holdBoot = true; bootloaderBusy = true;
RunBootloaderLoop(); RunBootloaderLoop();
} }
@ -198,7 +202,7 @@ int main(void) {
} }
// Block until booting the app is allowed // Block until booting the app is allowed
while (holdBoot) while (bootloaderBusy)
{ {
palTogglePad(GPIOB, 5); palTogglePad(GPIOB, 5);
palTogglePad(GPIOB, 6); palTogglePad(GPIOB, 6);