[NANO130] Fix CLK_Idle incorrectly enters into deep sleep mode

This can happen with CLK_PowerDown() called first and then CLK_Idle() called.
pull/7029/head
ccli8 2018-05-25 10:44:21 +08:00
parent 3f861425da
commit 12792fde27
1 changed files with 6 additions and 1 deletions

View File

@ -70,7 +70,9 @@ void CLK_EnableCKO(uint32_t u32ClkSrc, uint32_t u32ClkDiv)
*/
void CLK_PowerDown(void)
{
SCB->SCR = SCB_SCR_SLEEPDEEP_Msk;
/* Set the processor uses deep sleep as its low power mode */
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
CLK->PWRCTL |= (CLK_PWRCTL_PD_EN_Msk | CLK_PWRCTL_WK_DLY_Msk );
__WFI();
}
@ -81,6 +83,9 @@ void CLK_PowerDown(void)
*/
void CLK_Idle(void)
{
/* Set the processor uses sleep as its low power mode */
SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk;
CLK->PWRCTL &= ~(CLK_PWRCTL_PD_EN_Msk );
__WFI();
}