sometimes __HAL_RCC_GET_FLAG return more than 1flag,take away else would be a better result.
eResetSource Get_Reset_Source(void)
{
eResetSource rst = RST_UNKNOWN;
#if defined(STM32L4)
if (__HAL_RCC_GET_FLAG(RCC_FLAG_FWRST)) { rst = RST_FW; }
#elif defined(STM32G0)
if (__HAL_RCC_GET_FLAG(RCC_FLAG_PWRRST)) { rst = RST_POR; }
#else
if (__HAL_RCC_GET_FLAG(RCC_FLAG_PORRST)) { rst = RST_POR; xprintf("\nRST_POR");}
#endif
if (__HAL_RCC_GET_FLAG(RCC_FLAG_BORRST)) { rst = RST_PIN; xprintf("\nBORRST");}
if (__HAL_RCC_GET_FLAG(RCC_FLAG_PINRST)) { rst = RST_PIN; xprintf("\nRST_PIN");}
if (__HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST)) { rst = RST_SW; xprintf("\nRST_SW");}
if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST)) { rst = RST_IWDG; xprintf("\nRST_IWDG");}
if (__HAL_RCC_GET_FLAG(RCC_FLAG_WWDGRST)) { rst = RST_WWDG; xprintf("\nRST_WWDG");}
if (__HAL_RCC_GET_FLAG(RCC_FLAG_LPWRRST)) { rst = RST_LPWR; xprintf("\nRST_LPWR");}
#if defined(STM32F3) || defined(STM32L4)
else if (__HAL_RCC_GET_FLAG(RCC_FLAG_OBLRST)) { rst = RST_OBL; }
#if defined(STM32F301x8) || \
defined(STM32F302x8) || defined(STM32F302xC) || defined(STM32F302xE) || \
defined(STM32F303x8) || defined(STM32F303xC) || defined(STM32F303xE) || \
defined(STM32F334x8) || defined(STM32F358xx) || defined(STM32F373xC)
else if (__HAL_RCC_GET_FLAG(RCC_FLAG_V18PWRRST)) { rst = RST_V18PWR; }
#endif
#endif
__HAL_RCC_CLEAR_RESET_FLAGS(); // Clear reset flags
return rst;
}
sometimes __HAL_RCC_GET_FLAG return more than 1flag,take away else would be a better result.
eResetSource Get_Reset_Source(void)
{
eResetSource rst = RST_UNKNOWN;
}