2018-02-04 03:15 AM
Hello friends
How can Determine STM32 reset source with HAL ?
STM32F407ZET6
Thanks
2018-02-04 06:05 AM
/* Enable Power Clock */
__HAL_RCC_PWR_CLK_ENABLE();/* Check and Clear the Wakeup flag */
if(__HAL_PWR_GET_FLAG(PWR_FLAG_WU) != RESET) { __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); }/* Check if the system was resumed from StandBy mode */
if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET) { /* Clear StandBy flag */ __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);}
{
/* Check if the Power On Reset flag is set */ if (__HAL_RCC_GET_FLAG(RCC_FLAG_PORRST) != RESET) { /* Turn on LED1: Power on reset occurred */ BSP_LED_On(LED1); } /* Check if Pin Reset flag is set */ if (__HAL_RCC_GET_FLAG(RCC_FLAG_PINRST) != RESET) { /* Turn on LED1: External reset occurred */ BSP_LED_On(LED1); } /* Clear source Reset Flag */ __HAL_RCC_CLEAR_RESET_FLAGS(); }2018-02-04 06:07 AM
Find the information in stm32f4xx_hal_rcc.h at line 1227ff
/** @brief Check RCC flag is set or not.
* @param __FLAG__ specifies the flag to check. * This parameter can be one of the following values: * @arg RCC_FLAG_HSIRDY: HSI oscillator clock ready. * @arg RCC_FLAG_HSERDY: HSE oscillator clock ready. * @arg RCC_FLAG_PLLRDY: Main PLL clock ready. * @arg RCC_FLAG_PLLI2SRDY: PLLI2S clock ready. * @arg RCC_FLAG_LSERDY: LSE oscillator clock ready. * @arg RCC_FLAG_LSIRDY: LSI oscillator clock ready. * @arg RCC_FLAG_BORRST: POR/PDR or BOR reset. * @arg RCC_FLAG_PINRST: Pin reset. * @arg RCC_FLAG_PORRST: POR/PDR reset. * @arg RCC_FLAG_SFTRST: Software reset. * @arg RCC_FLAG_IWDGRST: Independent Watchdog reset. * @arg RCC_FLAG_WWDGRST: Window Watchdog reset. * @arg RCC_FLAG_LPWRRST: Low Power reset. * @retval The new state of __FLAG__ (TRUE or FALSE). */#define RCC_FLAG_MASK ((uint8_t)0x1FU)#define __HAL_RCC_GET_FLAG(__FLAG__) (((((((__FLAG__) >> 5U) == 1U)? RCC->CR :((((__FLAG__) >> 5U) == 2U) ? RCC->BDCR :((((__FLAG__) >> 5U) == 3U)? RCC->CSR :RCC->CIR))) & (1U << ((__FLAG__) & RCC_FLAG_MASK)))!= 0U)? 1U : 0U)