Lines Matching refs:hcomp

232 HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp)  in HAL_COMP_Init()  argument
241 if (hcomp == NULL) in HAL_COMP_Init()
245 else if (__HAL_COMP_IS_LOCKED(hcomp)) in HAL_COMP_Init()
252 assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); in HAL_COMP_Init()
253 assert_param(IS_COMP_INPUT_PLUS(hcomp->Instance, hcomp->Init.InputPlus)); in HAL_COMP_Init()
254 assert_param(IS_COMP_INPUT_MINUS(hcomp->Instance, hcomp->Init.InputMinus)); in HAL_COMP_Init()
255 assert_param(IS_COMP_OUTPUTPOL(hcomp->Init.OutputPol)); in HAL_COMP_Init()
256 assert_param(IS_COMP_POWERMODE(hcomp->Init.Mode)); in HAL_COMP_Init()
257 assert_param(IS_COMP_HYSTERESIS(hcomp->Init.Hysteresis)); in HAL_COMP_Init()
258 assert_param(IS_COMP_BLANKINGSRCE(hcomp->Init.BlankingSrce)); in HAL_COMP_Init()
259 assert_param(IS_COMP_TRIGGERMODE(hcomp->Init.TriggerMode)); in HAL_COMP_Init()
261 if (hcomp->State == HAL_COMP_STATE_RESET) in HAL_COMP_Init()
264 hcomp->Lock = HAL_UNLOCKED; in HAL_COMP_Init()
267 COMP_CLEAR_ERRORCODE(hcomp); in HAL_COMP_Init()
269 hcomp->InterruptAutoRearm = 0; in HAL_COMP_Init()
273 hcomp->TriggerCallback = HAL_COMP_TriggerCallback; /* Legacy weak callback */ in HAL_COMP_Init()
275 if (hcomp->MspInitCallback == NULL) in HAL_COMP_Init()
277 hcomp->MspInitCallback = HAL_COMP_MspInit; /* Legacy weak MspInit */ in HAL_COMP_Init()
281 hcomp->MspInitCallback(hcomp); in HAL_COMP_Init()
284 HAL_COMP_MspInit(hcomp); in HAL_COMP_Init()
289 comp_voltage_scaler_initialized = READ_BIT(hcomp->Instance->CFGR1, COMP_CFGR1_SCALEN); in HAL_COMP_Init()
292 tmp_csr = (hcomp->Init.InputMinus in HAL_COMP_Init()
293 | hcomp->Init.InputPlus in HAL_COMP_Init()
294 | hcomp->Init.BlankingSrce in HAL_COMP_Init()
295 | hcomp->Init.Hysteresis in HAL_COMP_Init()
296 | hcomp->Init.OutputPol in HAL_COMP_Init()
297 | hcomp->Init.Mode); in HAL_COMP_Init()
301 MODIFY_REG(hcomp->Instance->CFGR1, in HAL_COMP_Init()
308 if (hcomp->Init.InputPlus == COMP_INPUT_PLUS_IO2) in HAL_COMP_Init()
310 MODIFY_REG(hcomp->Instance->CFGR2, COMP_CFGR2_INPSEL0, COMP_CFGR2_INPSEL0); in HAL_COMP_Init()
315 if ((READ_BIT(hcomp->Instance->CFGR1, COMP_CFGR1_SCALEN) != 0UL) && in HAL_COMP_Init()
330 exti_line = COMP_GET_EXTI_LINE(hcomp->Instance); in HAL_COMP_Init()
333 if ((hcomp->Init.TriggerMode & COMP_EXTI_IT) != 0UL) in HAL_COMP_Init()
346 if (hcomp->State == HAL_COMP_STATE_RESET) in HAL_COMP_Init()
348 hcomp->State = HAL_COMP_STATE_READY; in HAL_COMP_Init()
362 HAL_StatusTypeDef HAL_COMP_DeInit(COMP_HandleTypeDef *hcomp) in HAL_COMP_DeInit() argument
367 if (hcomp == NULL) in HAL_COMP_DeInit()
371 else if (__HAL_COMP_IS_LOCKED(hcomp)) in HAL_COMP_DeInit()
378 assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); in HAL_COMP_DeInit()
381 WRITE_REG(hcomp->Instance->CFGR1, 0x00000000UL); in HAL_COMP_DeInit()
384 if (hcomp->MspDeInitCallback == NULL) in HAL_COMP_DeInit()
386 hcomp->MspDeInitCallback = HAL_COMP_MspDeInit; /* Legacy weak MspDeInit */ in HAL_COMP_DeInit()
390 hcomp->MspDeInitCallback(hcomp); in HAL_COMP_DeInit()
393 HAL_COMP_MspDeInit(hcomp); in HAL_COMP_DeInit()
397 hcomp->State = HAL_COMP_STATE_RESET; in HAL_COMP_DeInit()
400 __HAL_UNLOCK(hcomp); in HAL_COMP_DeInit()
411 __weak void HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp) in HAL_COMP_MspInit() argument
414 UNUSED(hcomp); in HAL_COMP_MspInit()
426 __weak void HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp) in HAL_COMP_MspDeInit() argument
429 UNUSED(hcomp); in HAL_COMP_MspDeInit()
450 HAL_StatusTypeDef HAL_COMP_RegisterCallback(COMP_HandleTypeDef *hcomp, HAL_COMP_CallbackIDTypeDef C… in HAL_COMP_RegisterCallback() argument
458 hcomp->ErrorCode |= HAL_COMP_ERROR_INVALID_CALLBACK; in HAL_COMP_RegisterCallback()
463 if (HAL_COMP_STATE_READY == hcomp->State) in HAL_COMP_RegisterCallback()
468 hcomp->TriggerCallback = pCallback; in HAL_COMP_RegisterCallback()
472 hcomp->MspInitCallback = pCallback; in HAL_COMP_RegisterCallback()
476 hcomp->MspDeInitCallback = pCallback; in HAL_COMP_RegisterCallback()
481 hcomp->ErrorCode |= HAL_COMP_ERROR_INVALID_CALLBACK; in HAL_COMP_RegisterCallback()
488 else if (HAL_COMP_STATE_RESET == hcomp->State) in HAL_COMP_RegisterCallback()
493 hcomp->MspInitCallback = pCallback; in HAL_COMP_RegisterCallback()
497 hcomp->MspDeInitCallback = pCallback; in HAL_COMP_RegisterCallback()
502 hcomp->ErrorCode |= HAL_COMP_ERROR_INVALID_CALLBACK; in HAL_COMP_RegisterCallback()
512 hcomp->ErrorCode |= HAL_COMP_ERROR_INVALID_CALLBACK; in HAL_COMP_RegisterCallback()
533 HAL_StatusTypeDef HAL_COMP_UnRegisterCallback(COMP_HandleTypeDef *hcomp, HAL_COMP_CallbackIDTypeDef… in HAL_COMP_UnRegisterCallback() argument
537 if (HAL_COMP_STATE_READY == hcomp->State) in HAL_COMP_UnRegisterCallback()
542 hcomp->TriggerCallback = HAL_COMP_TriggerCallback; /* Legacy weak callback */ in HAL_COMP_UnRegisterCallback()
546 hcomp->MspInitCallback = HAL_COMP_MspInit; /* Legacy weak MspInit */ in HAL_COMP_UnRegisterCallback()
550 hcomp->MspDeInitCallback = HAL_COMP_MspDeInit; /* Legacy weak MspDeInit */ in HAL_COMP_UnRegisterCallback()
555 hcomp->ErrorCode |= HAL_COMP_ERROR_INVALID_CALLBACK; in HAL_COMP_UnRegisterCallback()
562 else if (HAL_COMP_STATE_RESET == hcomp->State) in HAL_COMP_UnRegisterCallback()
567 hcomp->MspInitCallback = HAL_COMP_MspInit; /* Legacy weak MspInit */ in HAL_COMP_UnRegisterCallback()
571 hcomp->MspDeInitCallback = HAL_COMP_MspDeInit; /* Legacy weak MspDeInit */ in HAL_COMP_UnRegisterCallback()
576 hcomp->ErrorCode |= HAL_COMP_ERROR_INVALID_CALLBACK; in HAL_COMP_UnRegisterCallback()
586 hcomp->ErrorCode |= HAL_COMP_ERROR_INVALID_CALLBACK; in HAL_COMP_UnRegisterCallback()
621 HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp) in HAL_COMP_Start() argument
628 if (hcomp == NULL) in HAL_COMP_Start()
632 else if (__HAL_COMP_IS_LOCKED(hcomp)) in HAL_COMP_Start()
639 assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); in HAL_COMP_Start()
641 if ((hcomp->Init.TriggerMode & COMP_EXTI_IT) != 0UL) in HAL_COMP_Start()
645 status = HAL_COMP_Start_IT_AutoRearm(hcomp); in HAL_COMP_Start()
649 if (hcomp->State == HAL_COMP_STATE_READY) in HAL_COMP_Start()
652 SET_BIT(hcomp->Instance->CFGR1, COMP_CFGR1_EN); in HAL_COMP_Start()
655 hcomp->State = HAL_COMP_STATE_BUSY; in HAL_COMP_Start()
683 HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp) in HAL_COMP_Stop() argument
688 if (hcomp == NULL) in HAL_COMP_Stop()
692 else if (__HAL_COMP_IS_LOCKED(hcomp)) in HAL_COMP_Stop()
699 assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); in HAL_COMP_Stop()
703 if (hcomp->State != HAL_COMP_STATE_RESET) in HAL_COMP_Stop()
706 CLEAR_BIT(hcomp->Instance->CFGR1, COMP_CFGR1_EN); in HAL_COMP_Stop()
709 hcomp->State = HAL_COMP_STATE_READY; in HAL_COMP_Stop()
729 HAL_StatusTypeDef HAL_COMP_Start_IT_OneShot(COMP_HandleTypeDef *hcomp) in HAL_COMP_Start_IT_OneShot() argument
736 if (hcomp == NULL) in HAL_COMP_Start_IT_OneShot()
740 else if (__HAL_COMP_IS_LOCKED(hcomp)) in HAL_COMP_Start_IT_OneShot()
747 assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); in HAL_COMP_Start_IT_OneShot()
749 if (hcomp->State == HAL_COMP_STATE_READY) in HAL_COMP_Start_IT_OneShot()
752 SET_BIT(hcomp->Instance->CFGR1, COMP_CFGR1_EN); in HAL_COMP_Start_IT_OneShot()
755 hcomp->State = HAL_COMP_STATE_BUSY; in HAL_COMP_Start_IT_OneShot()
769 if (hcomp->Init.TriggerMode == COMP_EXTI_FALLING) in HAL_COMP_Start_IT_OneShot()
771 if (HAL_COMP_GetOutputLevel(hcomp) != COMP_OUTPUT_LEVEL_HIGH) in HAL_COMP_Start_IT_OneShot()
778 if (HAL_COMP_GetOutputLevel(hcomp) != COMP_OUTPUT_LEVEL_LOW) in HAL_COMP_Start_IT_OneShot()
787 if (READ_BIT(hcomp->Instance->CFGR1, COMP_CFGR1_POLARITY) == 0UL) in HAL_COMP_Start_IT_OneShot()
789 SET_BIT(hcomp->Instance->CFGR1, COMP_CFGR1_POLARITY); in HAL_COMP_Start_IT_OneShot()
793 CLEAR_BIT(hcomp->Instance->CFGR1, COMP_CFGR1_POLARITY); in HAL_COMP_Start_IT_OneShot()
798 hcomp->InterruptAutoRearm = 0U; in HAL_COMP_Start_IT_OneShot()
800 SET_BIT(hcomp->Instance->CFGR1, COMP_CFGR1_ITEN); in HAL_COMP_Start_IT_OneShot()
820 HAL_StatusTypeDef HAL_COMP_Start_IT_AutoRearm(COMP_HandleTypeDef *hcomp) in HAL_COMP_Start_IT_AutoRearm() argument
827 if (hcomp == NULL) in HAL_COMP_Start_IT_AutoRearm()
831 else if (__HAL_COMP_IS_LOCKED(hcomp)) in HAL_COMP_Start_IT_AutoRearm()
838 assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); in HAL_COMP_Start_IT_AutoRearm()
840 if (hcomp->State == HAL_COMP_STATE_READY) in HAL_COMP_Start_IT_AutoRearm()
843 SET_BIT(hcomp->Instance->CFGR1, COMP_CFGR1_EN); in HAL_COMP_Start_IT_AutoRearm()
846 hcomp->State = HAL_COMP_STATE_BUSY; in HAL_COMP_Start_IT_AutoRearm()
860 if (hcomp->Init.TriggerMode == COMP_EXTI_FALLING) in HAL_COMP_Start_IT_AutoRearm()
862 if (HAL_COMP_GetOutputLevel(hcomp) != COMP_OUTPUT_LEVEL_HIGH) in HAL_COMP_Start_IT_AutoRearm()
869 if (HAL_COMP_GetOutputLevel(hcomp) != COMP_OUTPUT_LEVEL_LOW) in HAL_COMP_Start_IT_AutoRearm()
878 if (READ_BIT(hcomp->Instance->CFGR1, COMP_CFGR1_POLARITY) == 0UL) in HAL_COMP_Start_IT_AutoRearm()
880 SET_BIT(hcomp->Instance->CFGR1, COMP_CFGR1_POLARITY); in HAL_COMP_Start_IT_AutoRearm()
884 CLEAR_BIT(hcomp->Instance->CFGR1, COMP_CFGR1_POLARITY); in HAL_COMP_Start_IT_AutoRearm()
889 hcomp->InterruptAutoRearm = 1U; in HAL_COMP_Start_IT_AutoRearm()
891 SET_BIT(hcomp->Instance->CFGR1, COMP_CFGR1_ITEN); in HAL_COMP_Start_IT_AutoRearm()
907 HAL_StatusTypeDef HAL_COMP_Stop_IT(COMP_HandleTypeDef *hcomp) in HAL_COMP_Stop_IT() argument
912 if (hcomp == NULL) in HAL_COMP_Stop_IT()
916 else if (__HAL_COMP_IS_LOCKED(hcomp)) in HAL_COMP_Stop_IT()
923 assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); in HAL_COMP_Stop_IT()
927 if (hcomp->State != HAL_COMP_STATE_RESET) in HAL_COMP_Stop_IT()
930 CLEAR_BIT(hcomp->Instance->CFGR1, COMP_CFGR1_EN); in HAL_COMP_Stop_IT()
933 CLEAR_BIT(EXTI->IMR1, COMP_GET_EXTI_LINE(hcomp->Instance)); in HAL_COMP_Stop_IT()
936 CLEAR_BIT(hcomp->Instance->CFGR1, COMP_CFGR1_ITEN); in HAL_COMP_Stop_IT()
939 hcomp->State = HAL_COMP_STATE_READY; in HAL_COMP_Stop_IT()
955 void HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp) in HAL_COMP_IRQHandler() argument
961 __HAL_COMP_DISABLE_IT(hcomp, COMP_IT_EN); in HAL_COMP_IRQHandler()
969 hcomp->TriggerCallback(hcomp); in HAL_COMP_IRQHandler()
971 HAL_COMP_TriggerCallback(hcomp); in HAL_COMP_IRQHandler()
974 if (hcomp->InterruptAutoRearm == 1U) in HAL_COMP_IRQHandler()
977 if (hcomp->Init.TriggerMode == COMP_EXTI_FALLING) in HAL_COMP_IRQHandler()
979 if (HAL_COMP_GetOutputLevel(hcomp) != COMP_OUTPUT_LEVEL_HIGH) in HAL_COMP_IRQHandler()
986 if (HAL_COMP_GetOutputLevel(hcomp) != COMP_OUTPUT_LEVEL_LOW) in HAL_COMP_IRQHandler()
995 if (READ_BIT(hcomp->Instance->CFGR1, COMP_CFGR1_POLARITY) == 0UL) in HAL_COMP_IRQHandler()
997 SET_BIT(hcomp->Instance->CFGR1, COMP_CFGR1_POLARITY); in HAL_COMP_IRQHandler()
1001 CLEAR_BIT(hcomp->Instance->CFGR1, COMP_CFGR1_POLARITY); in HAL_COMP_IRQHandler()
1006 __HAL_COMP_ENABLE_IT(hcomp, COMP_IT_EN); in HAL_COMP_IRQHandler()
1011 hcomp->State = HAL_COMP_STATE_READY; in HAL_COMP_IRQHandler()
1039 HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp) in HAL_COMP_Lock() argument
1044 if (hcomp == NULL) in HAL_COMP_Lock()
1048 else if (__HAL_COMP_IS_LOCKED(hcomp)) in HAL_COMP_Lock()
1055 assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); in HAL_COMP_Lock()
1058 switch (hcomp->State) in HAL_COMP_Lock()
1061 hcomp->State = HAL_COMP_STATE_RESET_LOCKED; in HAL_COMP_Lock()
1064 hcomp->State = HAL_COMP_STATE_READY_LOCKED; in HAL_COMP_Lock()
1067 hcomp->State = HAL_COMP_STATE_BUSY_LOCKED; in HAL_COMP_Lock()
1072 __HAL_COMP_LOCK(hcomp); in HAL_COMP_Lock()
1099 uint32_t HAL_COMP_GetOutputLevel(const COMP_HandleTypeDef *hcomp) in HAL_COMP_GetOutputLevel() argument
1102 assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); in HAL_COMP_GetOutputLevel()
1112 __weak void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp) in HAL_COMP_TriggerCallback() argument
1115 UNUSED(hcomp); in HAL_COMP_TriggerCallback()
1146 HAL_COMP_StateTypeDef HAL_COMP_GetState(const COMP_HandleTypeDef *hcomp) in HAL_COMP_GetState() argument
1149 if (hcomp == NULL) in HAL_COMP_GetState()
1155 assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); in HAL_COMP_GetState()
1158 return hcomp->State; in HAL_COMP_GetState()
1166 uint32_t HAL_COMP_GetError(const COMP_HandleTypeDef *hcomp) in HAL_COMP_GetError() argument
1169 assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); in HAL_COMP_GetError()
1171 return hcomp->ErrorCode; in HAL_COMP_GetError()