[simu] Refactor simu startup and shutdown handling (for 2.3 branch):

* Use pwrCheck() as primary control point for shutdown, centralizes thread control in simpgmspace module;
 * Remove main_thread_running in favor of separate variables for startup mode and shutdown flag;
 * Don't start a thread for ARM startup, just run simuMain() directly (the thread just exits anyway);
 * Refactor SIMU_SLEEP() macro, and remove all unnecessary uses of it, also remove SIMU_SLEEP_NORET;
 * Add startType param to opentxStart() to control splash and startup checks;
 * Fixes backlight never turning off in simulator with "SWITCH" power button type (pwrPressed() was always true);
 * Fixes simu shutdown when model checklist is displayed at startup;
 * Adds stubs to possibly simulate a "soft" power button in the future.
This commit is contained in:
Max Paperno
2018-09-08 22:04:37 -04:00
parent 942ae1847d
commit a2006940db
12 changed files with 97 additions and 70 deletions
+3 -7
View File
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -63,16 +63,12 @@ uint8_t eepromWriteBuffer[EEPROM_BUFFER_SIZE] __DMA;
void eepromWaitReadStatus()
{
while (eepromReadStatus() == 0) {
SIMU_SLEEP(5/*ms*/);
}
while (eepromReadStatus() == 0 && SIMU_SLEEP(5/*ms*/)) { }
}
void eepromWaitTransferComplete()
{
while (!eepromIsTransferComplete()) {
SIMU_SLEEP(5/*ms*/);
}
while (!eepromIsTransferComplete() && SIMU_SLEEP(5/*ms*/)) { }
}
void eepromEraseBlock(uint32_t address, bool blocking=true)