/** * @brief Enter in stop mode and exit by an alarm * @param None * @note This example enter in stop mode. * @retval None */ void LowPowerStopRTCAlarm(void) { kWindow_Popup("STOP Alarme", LCD_COLOR_WHITE, LCD_COLOR_BLUE,\ "\nset delay time\n", \ LCD_COLOR_BLUE, LCD_COLOR_WHITE ); /* set the alarm */ LowPowerHandleAlarm(); kWindow_Popup("STOP Alarm", LCD_COLOR_WHITE, LCD_COLOR_BLUE, \ "\n\nstop mode\nstarted\nwait alarm\nto exit\n", \ LCD_COLOR_BLUE, LCD_COLOR_WHITE ); BSP_JOY_Init(JOY_MODE_GPIO); /* Enter Stop Mode */ HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFE); /* Restore the clock configuration */ SystemClock_STOPExit(); HAL_RTC_DeactivateAlarm(&RtcHandle, RTC_ALARM_A); /* Clear the Alarm interrupt pending bit */ __HAL_RTC_ALARM_CLEAR_FLAG(&RtcHandle,RTC_FLAG_ALRAF); /* Clear the EXTI's line Flag for RTC Alarm */ __HAL_RTC_EXTI_CLEAR_FLAG(RTC_EXTI_LINE_ALARM_EVENT); BSP_JOY_Init(JOY_MODE_EXTI); }
/** * @brief This function handles Wake Up Timer interrupt request. * @param hrtc: RTC handle * @retval None */ void HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc) { if(__HAL_RTC_WAKEUPTIMER_GET_IT(hrtc, RTC_IT_WUT)) { /* Get the status of the Interrupt */ if((uint32_t)(hrtc->Instance->CR & RTC_IT_WUT) != (uint32_t)RESET) { /* WAKEUPTIMER callback */ HAL_RTCEx_WakeUpTimerEventCallback(hrtc); /* Clear the WAKEUPTIMER interrupt pending bit */ __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(hrtc, RTC_FLAG_WUTF); } } /* Clear the EXTI's line Flag for RTC WakeUpTimer */ __HAL_RTC_EXTI_CLEAR_FLAG(RTC_EXTI_LINE_WAKEUPTIMER_EVENT); /* Change RTC state */ hrtc->State = HAL_RTC_STATE_READY; }
/** * @brief This function handles TimeStamp interrupt request. * @param hrtc: RTC handle * @retval None */ void HAL_RTCEx_TamperTimeStampIRQHandler(RTC_HandleTypeDef *hrtc) { if(__HAL_RTC_TIMESTAMP_GET_IT(hrtc, RTC_IT_TS)) { /* Get the status of the Interrupt */ if((uint32_t)(hrtc->Instance->CR & RTC_IT_TS) != (uint32_t)RESET) { /* TIMESTAMP callback */ HAL_RTCEx_TimeStampEventCallback(hrtc); /* Clear the TIMESTAMP interrupt pending bit */ __HAL_RTC_TIMESTAMP_CLEAR_FLAG(hrtc,RTC_FLAG_TSF); } } /* Get the status of the Interrupt */ if(__HAL_RTC_TAMPER_GET_IT(hrtc,RTC_IT_TAMP1)) { /* Get the TAMPER Interrupt enable bit and pending bit */ if(((hrtc->Instance->TAFCR & (RTC_TAFCR_TAMPIE))) != (uint32_t)RESET) { /* Tamper callback */ HAL_RTCEx_Tamper1EventCallback(hrtc); /* Clear the Tamper interrupt pending bit */ __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc,RTC_FLAG_TAMP1F); } } /* Get the status of the Interrupt */ if(__HAL_RTC_TAMPER_GET_IT(hrtc, RTC_IT_TAMP2)) { /* Get the TAMPER Interrupt enable bit and pending bit */ if(((hrtc->Instance->TAFCR & RTC_TAFCR_TAMPIE)) != (uint32_t)RESET) { /* Tamper callback */ HAL_RTCEx_Tamper2EventCallback(hrtc); /* Clear the Tamper interrupt pending bit */ __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc, RTC_FLAG_TAMP2F); } } #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F091xC) || defined(STM32F098xx) /* Get the status of the Interrupt */ if(__HAL_RTC_TAMPER_GET_IT(hrtc, RTC_IT_TAMP3)) { /* Get the TAMPER Interrupt enable bit and pending bit */ if(((hrtc->Instance->TAFCR & RTC_TAFCR_TAMPIE)) != (uint32_t)RESET) { /* Tamper callback */ HAL_RTCEx_Tamper3EventCallback(hrtc); /* Clear the Tamper interrupt pending bit */ __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc, RTC_FLAG_TAMP3F); } } #endif /* Clear the EXTI's Flag for RTC TimeStamp and Tamper */ __HAL_RTC_EXTI_CLEAR_FLAG(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT); /* Change RTC state */ hrtc->State = HAL_RTC_STATE_READY; }