/** * @brief Comparator IRQ Handler * @param hcomp: COMP handle * @retval HAL status */ void HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp) { uint32_t extiline = __HAL_COMP_GET_EXTI_LINE(hcomp->Instance); /* Check COMP Exti flag */ if(__HAL_COMP_EXTI_GET_FLAG(extiline) != RESET) { /* Clear COMP Exti pending bit */ __HAL_COMP_EXTI_CLEAR_FLAG(extiline); /* COMP trigger user callback */ HAL_COMP_TriggerCallback(hcomp); } }
/** * @brief Enables the interrupt and starts the comparator * @param hcomp: COMP handle * @retval HAL status. */ HAL_StatusTypeDef HAL_COMP_Start_IT(COMP_HandleTypeDef *hcomp) { HAL_StatusTypeDef status = HAL_OK; uint32_t extiline = 0; status = HAL_COMP_Start(hcomp); if(status == HAL_OK) { /* Check the parameter */ assert_param(IS_COMP_TRIGGERMODE(hcomp->Init.TriggerMode)); /* Get the Exti Line output configuration */ extiline = __HAL_COMP_GET_EXTI_LINE(hcomp->Instance); /* Configure the rising edge */ /* COMP TriggerMode set to COMP_TRIGGERMODE_IT_RISING or */ /* COMP_TRIGGERMODE_IT_RISING_FALLING. */ if((hcomp->Init.TriggerMode & COMP_TRIGGERMODE_IT_RISING) != RESET) { __HAL_COMP_EXTI_RISING_IT_ENABLE(extiline); } else { __HAL_COMP_EXTI_RISING_IT_DISABLE(extiline); } /* Configure the falling edge */ /* COMP TriggerMode set to COMP_TRIGGERMODE_IT_FALLING or */ /* COMP_TRIGGERMODE_IT_RISING_FALLING. */ if((hcomp->Init.TriggerMode & COMP_TRIGGERMODE_IT_FALLING) != RESET) { __HAL_COMP_EXTI_FALLING_IT_ENABLE(extiline); } else { __HAL_COMP_EXTI_FALLING_IT_DISABLE(extiline); } /* Enable Exti interrupt mode */ __HAL_COMP_EXTI_ENABLE_IT(extiline); /* Clear COMP Exti pending bit */ __HAL_COMP_EXTI_CLEAR_FLAG(extiline); } return status; }