模拟看门狗中断服务程序/**
* @brief Analog watchdog callback in non blocking mode.
* @param hadc: ADC handle
* @retval None
*/
void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef* hadc)
{
/* Set variable to report analog watchdog out of window status to main */
/* program. */
ubAnalogWatchdogStatus = SET;
}
当模拟看门狗检测到电压高于上限或者低于下限时将会产生看门狗中断,中断服务程序触发后,可以做出一些应对措施。 这
里置了 ubAnalogWatchdogStatus 标志,然后由主程序去根据标志的值去执行相应处理程序。
/* Infinite loop */
while (1)
{
/* Turn-on/off LED1 in function of ADC conversion result */
/* - Turn-off if voltage is into AWD window */
/* - Turn-on if voltage is out of AWD window */
/* Variable of analog watchdog status is set into analog watchdog */
/* interrupt callback */
if (ubAnalogWatchdogStatus == RESET)
{
BSP_LED_Off(LED1);
}
else
{
BSP_LED_On(LED1);
/* Reset analog watchdog status for next loop iteration */
ubAnalogWatchdogStatus = RESET;
} }
|