Merge pull request #10436 from OpenNuvoton/nuvoton_nuc472_fix_power-down

NUC472: Workaround for unknown error with power-down
pull/10503/head
Anna Bridge 2019-04-26 13:34:12 +01:00 committed by GitHub
commit 4020c6d19d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -40,7 +40,14 @@ void hal_sleep(void)
/**
* Enter power-down mode, in which HXT/HIRC are halted.
*
* \note On NUC472, on wake-up from power-down mode, we may meet hard fault or
* some other unknown error. Before its cause is found, we enter idle mode
* instead for a workaround. To simulate power-down mode with idle mode, we
* also disable us_ticker during power-down period.
*/
#include "nu_modutil.h"
const struct nu_modinit_s *nu_us_ticker_modinit(void);
void hal_deepsleep(void)
{
#if DEVICE_SERIAL
@ -49,9 +56,11 @@ void hal_deepsleep(void)
}
#endif
CLK_DisableModuleClock(nu_us_ticker_modinit()->clkidx);
SYS_UnlockReg();
CLK_PowerDown();
CLK_Idle();
SYS_LockReg();
CLK_EnableModuleClock(nu_us_ticker_modinit()->clkidx);
}
#endif

View File

@ -38,6 +38,13 @@ static void tmr0_vec(void);
static const struct nu_modinit_s timer0_modinit = {TIMER_0, TMR0_MODULE, CLK_CLKSEL1_TMR0SEL_PCLK, 0, TMR0_RST, TMR0_IRQn, (void *) tmr0_vec};
/* Externalize this function for hal_deepsleep() to get around unknown error
* with power-down. */
const struct nu_modinit_s *nu_us_ticker_modinit(void)
{
return &timer0_modinit;
}
#define TIMER_MODINIT timer0_modinit
/* Track ticker status */