/** * @brief MCU Pre Sleep process. * @param ulExpectedIdleTime: Not used * @retval None */ void PreSleepProcessing(uint32_t* ulExpectedIdleTime) { /* Called by the kernel before it places the MCU into a sleep mode because configPRE_SLEEP_PROCESSING() is #defined to PreSleepProcessing(). NOTE: Additional actions can be taken here to get the power consumption even lower. For example, peripherals can be turned off here, and then back on again in the post sleep processing function. For maximum power saving ensure all unused pins are in their lowest power state. */ /* Avoid compiler warnings about the unused parameter. */ (void) ulExpectedIdleTime; /* Disable the peripheral clock during Low Power (Sleep) mode.*/ __HAL_RCC_GPIOG_CLK_SLEEP_DISABLE(); }
/** * @brief Pre Sleep Processing * @param ulExpectedIdleTime: Expected time in idle state * @retval None */ void PreSleepProcessing(uint32_t * ulExpectedIdleTime) { /* Called by the kernel before it places the MCU into a sleep mode because configPRE_SLEEP_PROCESSING() is #defined to PreSleepProcessing(). NOTE: Additional actions can be taken here to get the power consumption even lower. For example, peripherals can be turned off here, and then back on again in the post sleep processing function. For maximum power saving ensure all unused pins are in their lowest power state. */ /* Disable the peripheral clock during Low Power (Sleep) mode.*/ __HAL_RCC_GPIOG_CLK_SLEEP_DISABLE(); /* (*ulExpectedIdleTime) is set to 0 to indicate that PreSleepProcessing contains its own wait for interrupt or wait for event instruction and so the kernel vPortSuppressTicksAndSleep function does not need to execute the wfi instruction */ *ulExpectedIdleTime = 0; /*Enter to sleep Mode using the HAL function HAL_PWR_EnterSLEEPMode with WFI instruction*/ HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI); }