Prevent race condition in main

This commit is contained in:
d0k3 2017-07-29 15:30:46 +02:00
parent e121e72f1c
commit 45fef040ff
3 changed files with 12 additions and 5 deletions

View File

@ -1,6 +1,13 @@
#include "power.h" #include "power.h"
#include "i2c.h" #include "i2c.h"
#include "cache.h" #include "cache.h"
#include "timer.h"
void ScreenOn() {
wait_msec(3); // wait 3ms (cause profi200 said so)
flushDCacheRange((u8*)0x23FFFE00, sizeof(u8*)*3); // this assumes CakeHax framebuffers, see ui.h
I2C_writeReg(I2C_DEV_MCU, 0x22, 0x2A); // poweron LCD
}
void Reboot() { void Reboot() {
I2C_writeReg(I2C_DEV_MCU, 0x22, 1 << 0); // poweroff LCD to prevent MCU hangs I2C_writeReg(I2C_DEV_MCU, 0x22, 1 << 0); // poweroff LCD to prevent MCU hangs

View File

@ -2,5 +2,6 @@
#include "common.h" #include "common.h"
void ScreenOn();
void Reboot(); void Reboot();
void PowerOff(); void PowerOff();

View File

@ -1,6 +1,4 @@
#include "common.h"
#include "godmode.h" #include "godmode.h"
#include "i2c.h"
#include "power.h" #include "power.h"
void main(int argc, char** argv) void main(int argc, char** argv)
@ -8,9 +6,10 @@ void main(int argc, char** argv)
(void) argc; // unused for now (void) argc; // unused for now
(void) argv; // unused for now (void) argv; // unused for now
// Turn on backlight // Screen on
I2C_writeReg(I2C_DEV_MCU, 0x22, 0x2A); ScreenOn();
// Run the main program // Run the main program
(GodMode() == GODMODE_EXIT_REBOOT) ? Reboot() : PowerOff(); if (GodMode() == GODMODE_EXIT_REBOOT) Reboot();
else PowerOff();
} }