Re #2681 and #2626: Power off refactoring, the 9XE RTC reset prevention code now active

This commit is contained in:
Damjan Adamic
2015-08-25 20:36:51 +02:00
parent e83b7c3a69
commit 77d3eae4d6
6 changed files with 78 additions and 55 deletions
+1
View File
@@ -377,6 +377,7 @@ void eepromReadBlock (uint8_t * pointer_ram, uint32_t address, uint32_t size);
#define wdt_enable(...) sleep(1/*ms*/)
#define wdt_reset() sleep(1/*ms*/)
#define boardInit()
#define boardOff()
#define OS_MutexID pthread_mutex_t
extern OS_MutexID audioMutex;
+20 -1
View File
@@ -187,7 +187,7 @@ void boardInit()
lcdRefreshWait();
}
if (duration < PWR_PRESS_DURATION_MIN || duration >= PWR_PRESS_DURATION_MAX) {
pwrOff();
boardOff();
}
}
else {
@@ -198,8 +198,27 @@ void boardInit()
backlightInit();
#endif
}
void boardOff()
{
BACKLIGHT_OFF();
#if defined(REV9E)
topLcdOff();
#endif
#if defined(REV9E)
while (pwrPressed()) {
wdt_reset();
}
#endif
lcdOff();
SysTick->CTRL = 0; // turn off systick
pwrOff();
}
#endif // #if !defined(SIMU)
#if defined(USB_JOYSTICK) && !defined(SIMU)
extern USB_OTG_CORE_HANDLE USB_OTG_dev;
+23 -16
View File
@@ -37,9 +37,6 @@
#include "board_taranis.h"
#include "../../pwr.h"
extern volatile uint32_t g_tmr10ms;
#define get_tmr10ms() g_tmr10ms
void pwrInit()
{
// if any changes are done to the PWR PIN or pwrOn() function
@@ -87,23 +84,33 @@ void pwrOff()
{
GPIO_ResetBits(PWR_GPIO, PWR_GPIO_PIN_ON);
// disable interrupts
__disable_irq();
#if defined(REV9E)
// 9E needs watchdog reset because CPU is still running while the power
// key is held pressed by the user
while (1) {
// 9E needs watchdog reset because CPU is still running while
// the power key is held pressed by the user.
// The power key should be released by now, but we must make sure
while (pwrPressed()) {
wdt_reset();
#if 0
// It doesn't work correctly, if we press long on the pwr button, the radio restarts when the button is released
PWR->CR |= PWR_CR_CWUF;
/* Select STANDBY mode */
PWR->CR |= PWR_CR_PDDS;
/* Set SLEEPDEEP bit of Cortex System Control Register */
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
/* Request Wait For Event */
__WFE();
#endif
}
// Put the CPU into sleep to reduce the consumption,
// it might help with the RTC reset issue
PWR->CR |= PWR_CR_CWUF;
/* Select STANDBY mode */
PWR->CR |= PWR_CR_PDDS;
/* Set SLEEPDEEP bit of Cortex System Control Register */
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
/* Request Wait For Event */
__WFE();
#endif
while(1) {
wdt_reset();
}
//this function must not return!
}
#if defined(REV9E)