进入sleep stop standby mode操作步骤
/** * @brief Enters Stop mode. * @NOTE In Stop mode, all I/O pins keep the same state as in Run mode. * @note When exiting Stop mode by issuing an interrupt or a wakeup event, * MSI or HSI16 RCoscillator is selected as system clock depending * the bit STOPWUCK in the RCC_CFGR register. * @note When the voltage regulator operates in low power mode, an additional * startup delay is incurred when waking up from Stop mode. * By keeping the internal regulator ON during Stop mode, the consumption * is higher although the startup time is reduced. * @note Before entering in this function, it is important to ensure that the WUF * wakeup flag is cleared. To perform this action, it is possible to call the * following macro : __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU) * * @param Regulator: Specifies the regulator state in Stop mode. * This parameter can be one of the following values: * @ARG PWR_MAINREGULATOR_ON: Stop mode with regulator ON * @arg PWR_LOWPOWERREGULATOR_ON: Stop mode with low power regulator ON * @param STOPEntry: Specifies if Stop mode in entered with WFI or WFE instruction. * This parameter can be one of the following values: * @arg PWR_STOPENTRY_WFI: Enter Stop mode with WFI instruction * @arg PWR_STOPENTRY_WFE: Enter Stop mode with WFE instruction * @retval None */ void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry) { uint32_t tmpreg = 0U; /* Check the parameters */ assert_param(IS_PWR_REGULATOR(Regulator)); assert_param(IS_PWR_STOP_ENTRY(STOPEntry)); /* Select the regulator state in Stop mode ---------------------------------*/ tmpreg = PWR->CR; /* Clear PDDS and LPDS bits */ CLEAR_BIT(tmpreg, (PWR_CR_PDDS | PWR_CR_LPSDSR)); /* Set LPSDSR bit according to PWR_Regulator value */ SET_BIT(tmpreg, Regulator); /* Store the new value */ PWR->CR = tmpreg; /* Set SLEEPDEEP bit of Cortex System Control Register */ SET_BIT(SCB->SCR, SCB_SCR_SLEEPDEEP_Msk); /* Select Stop mode entry --------------------------------------------------*/ if(STOPEntry == PWR_STOPENTRY_WFI) { /* Request Wait For Interrupt */ __WFI(); } else { /* Request Wait For Event */ __SEV(); __WFE(); __WFE(); } /* Reset SLEEPDEEP bit of Cortex System Control Register */ CLEAR_BIT(SCB->SCR, SCB_SCR_SLEEPDEEP_Msk); }
|