void PMC_Init(PMC_Type *pPMC, PMC_ConfigType *pPMC_Config)
{
pPMC->SPMSC1 = pPMC_Config->sCtrlstatus.byte;
pPMC->SPMSC2 = pPMC_Config->sDetectVoltSelect.byte;
}
void PMC_SetMode(PMC_Type *pPMC,uint8_t u8PmcMode)
{
switch(u8PmcMode & 0x3)
{
case PmcModeRun:
break;
case PmcModeWait:
/* Clear the SLEEPDEEP bit to make sure we go into WAIT (sleep) mode instead
* of deep sleep.
*/
SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk;
/* Not using KEIL's uVision, so use the standard assembly command */
asm("WFI");
break;
case PmcModeStop4:
/* enable LVD in stop mode */
pPMC->SPMSC1 |= (PMC_SPMSC1_LVDE_MASK | PMC_SPMSC1_LVDSE_MASK);
/* Set the SLEEPDEEP bit to enable deep sleep mode (STOP) */
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
/* Not using KEIL's uVision, so use the standard assembly command */
asm("WFI");
break;
case PmcModeStop3:
/* disable LVD in stop mode */
pPMC->SPMSC1 &= ~(PMC_SPMSC1_LVDE_MASK | PMC_SPMSC1_LVDRE_MASK | PMC_SPMSC1_LVDSE_MASK);
/* Set the SLEEPDEEP bit to enable deep sleep mode (STOP) */
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
/* Not using KEIL's uVision, so use the standard assembly command */
asm("WFI");
break;
default:
break;
}
}
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------