/******************************************************************************* * Function Name : PWR_EnterSLEEPMode * Description : Enters SLEEP mode. * Input : - SysCtrl_Set: Select the Sleep mode entry mechanism,. * This parameter can be one of the following values: * - 0: MCU enters Sleep mode as soon as WFI or WFE instruction is executed. * - 1: MCU enters Sleep mode as soon as it exits the lowest priority ISR. * * - PWR_STOPEntry: specifies if SLEEP mode in entered with WFI or WFE instruction. * This parameter can be one of the following values: * - PWR_SLEEPEntry_WFI: enter STOP mode with WFI instruction * - PWR_SLEEPEntry_WFE: enter STOP mode with WFE instruction * Output : None * Return : None *******************************************************************************/ void PWR_EnterSLEEPMode(u32 SysCtrl_Set, u8 PWR_SLEEPEntry) { if (SysCtrl_Set) *(vu32 *) SCB_SysCtrl |= SysCtrl_SLEEPONEXIT_Set; // Set SLEEPONEXIT else *(vu32 *) SCB_SysCtrl &= ~SysCtrl_SLEEPONEXIT_Set;// Reset SLEEPONEXIT
*(vu32 *) SCB_SysCtrl &= ~SysCtrl_SLEEPDEEP_Set; // Clear SLEEPDEEP bit if(PWR_SLEEPEntry == PWR_SLEEPEntry_WFI) // Select SLEEP mode entry __WFI(); // Request Wait For Interrupt else __WFE(); // Request Wait For Event }
任何中断和事件都能将STM32唤醒。 |