Fix X10 power loop (fix #5270) (#5391)

* Fix X10 power loop (fix #5270)

* "EMERGENCY MODE" text wasn't visible anymore since d4a00dec3b
This commit is contained in:
Andre Bernet
2017-11-21 07:25:38 +01:00
committed by Bertrand Songis
parent 6fc40cb7cb
commit 39ea315c97
3 changed files with 17 additions and 12 deletions
+1 -1
View File
@@ -264,7 +264,7 @@ class DefaultTheme: public Theme
virtual void update() const
{
uint32_t color = g_eeGeneral.themeData.options[1].unsignedValue;
uint32_t bg_color = g_eeGeneral.themeData.options[0].unsignedValue;
uint32_t bg_color = UNEXPECTED_SHUTDOWN() ? WHITE : g_eeGeneral.themeData.options[0].unsignedValue;
lcdColorTable[TEXT_BGCOLOR_INDEX] = bg_color;
lcdColorTable[TEXT_INVERTED_BGCOLOR_INDEX] = color;
+1 -1
View File
@@ -421,7 +421,7 @@ uint32_t pwrPressedDuration(void);
#if defined(SIMU) || defined(NO_UNEXPECTED_SHUTDOWN)
#define UNEXPECTED_SHUTDOWN() (false)
#else
#define UNEXPECTED_SHUTDOWN() (powerupReason == DIRTY_SHUTDOWN)
#define UNEXPECTED_SHUTDOWN() ((powerupReason == DIRTY_SHUTDOWN) || WAS_RESET_BY_WATCHDOG_OR_SOFTWARE())
#endif
// Led driver
+15 -10
View File
@@ -70,7 +70,16 @@ void pwrInit()
void pwrOn()
{
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = PWR_ON_GPIO_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(PWR_GPIO, &GPIO_InitStructure);
GPIO_SetBits(PWR_GPIO, PWR_ON_GPIO_PIN);
shutdownRequest = NO_SHUTDOWN_REQUEST;
shutdownReason = DIRTY_SHUTDOWN;
}
@@ -131,20 +140,16 @@ void pwrResetHandler()
// powerupReason is there to cater for that, and is what is used in the firmware to decide whether we have to enter emergency mode.
// This variable needs to be in a RAM section that is not initialized or zeroed, since once we exit this pwrResetHandler() function the
// C runtime would otherwise overwrite it during program init.
// Only for X12, X10 power circuit causes inability to shut down on some samples.
if (shutdownRequest != SHUTDOWN_REQUEST) {
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = PWR_ON_GPIO_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(PWR_GPIO, &GPIO_InitStructure);
#if defined(PCBX12S)
if (shutdownRequest != SHUTDOWN_REQUEST || WAS_RESET_BY_WATCHDOG_OR_SOFTWARE()) {
if (shutdownReason == DIRTY_SHUTDOWN) {
powerupReason = DIRTY_SHUTDOWN;
}
#else
if (WAS_RESET_BY_WATCHDOG_OR_SOFTWARE()) {
#endif
pwrOn();
}
}