STM32L4xx_HAL_Driver  1.14.0
Peripheral Control functions

Management functions. More...

Functions

HAL_StatusTypeDef HAL_COMP_Lock (COMP_HandleTypeDef *hcomp)
 Lock the selected comparator configuration. More...
 
uint32_t HAL_COMP_GetOutputLevel (COMP_HandleTypeDef *hcomp)
 Return the output level (high or low) of the selected comparator. The output level depends on the selected polarity. If the polarity is not inverted: More...
 
void HAL_COMP_TriggerCallback (COMP_HandleTypeDef *hcomp)
 Comparator trigger callback. More...
 

Detailed Description

Management functions.

 ===============================================================================
                      ##### Peripheral Control functions #####
 ===============================================================================
    [..]
    This subsection provides a set of functions allowing to control the comparators.

Function Documentation

◆ HAL_COMP_GetOutputLevel()

uint32_t HAL_COMP_GetOutputLevel ( COMP_HandleTypeDef hcomp)

Return the output level (high or low) of the selected comparator. The output level depends on the selected polarity. If the polarity is not inverted:

  • Comparator output is low when the input plus is at a lower voltage than the input minus
  • Comparator output is high when the input plus is at a higher voltage than the input minus If the polarity is inverted:
  • Comparator output is high when the input plus is at a lower voltage than the input minus
  • Comparator output is low when the input plus is at a higher voltage than the input minus
    Parameters
    hcompCOMP handle
    Return values
    Returnsthe selected comparator output level:
    • COMP_OUTPUT_LEVEL_LOW
    • COMP_OUTPUT_LEVEL_HIGH

Definition at line 956 of file stm32l4xx_hal_comp.c.

957 {
958  /* Check the parameter */
959  assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance));
960 
961  return (uint32_t)(READ_BIT(hcomp->Instance->CSR, COMP_CSR_VALUE)
962  >> COMP_OUTPUT_LEVEL_BITOFFSET_POS);
963 }
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_COMP_Lock()

HAL_StatusTypeDef HAL_COMP_Lock ( COMP_HandleTypeDef hcomp)

Lock the selected comparator configuration.

Note
A system reset is required to unlock the comparator configuration.
Locking the comparator from reset state is possible if __HAL_RCC_SYSCFG_CLK_ENABLE() is being called before.
Parameters
hcompCOMP handle
Return values
HALstatus

Definition at line 895 of file stm32l4xx_hal_comp.c.

896 {
897  HAL_StatusTypeDef status = HAL_OK;
898 
899  /* Check the COMP handle allocation and lock status */
900  if(hcomp == NULL)
901  {
902  status = HAL_ERROR;
903  }
904  else if(__HAL_COMP_IS_LOCKED(hcomp))
905  {
906  status = HAL_ERROR;
907  }
908  else
909  {
910  /* Check the parameter */
911  assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance));
912 
913  /* Set HAL COMP handle state */
914  switch(hcomp->State)
915  {
917  hcomp->State = HAL_COMP_STATE_RESET_LOCKED;
918  break;
920  hcomp->State = HAL_COMP_STATE_READY_LOCKED;
921  break;
922  default: /* HAL_COMP_STATE_BUSY */
923  hcomp->State = HAL_COMP_STATE_BUSY_LOCKED;
924  break;
925  }
926  }
927 
928  if(status == HAL_OK)
929  {
930  /* Set the lock bit corresponding to selected comparator */
931  __HAL_COMP_LOCK(hcomp);
932  }
933 
934  return status;
935 }
return HAL_OK
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_COMP_TriggerCallback()

__weak void HAL_COMP_TriggerCallback ( COMP_HandleTypeDef hcomp)

Comparator trigger callback.

Parameters
hcompCOMP handle
Return values
None

Definition at line 970 of file stm32l4xx_hal_comp.c.

971 {
972  /* Prevent unused argument(s) compilation warning */
973  UNUSED(hcomp);
974 
975  /* NOTE : This function should not be modified, when the callback is needed,
976  the HAL_COMP_TriggerCallback should be implemented in the user file
977  */
978 }