Hardware Abstraction Layer (HAL)
COMP (LP Comparator block)

General Description

Implementation of the analog comparator (COMP) driver on top of the LP (low power) comparator.

Functions

cy_rslt_t _cyhal_comp_lp_init (cyhal_comp_t *obj, cyhal_gpio_t vin_p, cyhal_gpio_t vin_m, cyhal_gpio_t output, cyhal_comp_config_t *cfg)
 Initialize the Comparator peripheral for a LP-based comparator. More...
 
void _cyhal_comp_lp_free (cyhal_comp_t *obj)
 Deinitialize the Comparator peripheral for a LP-based comparator. More...
 
cy_rslt_t _cyhal_comp_lp_set_power (cyhal_comp_t *obj, cyhal_power_level_t power)
 Changes the current operating power level of the comparator for a LP-based comparator. More...
 
cy_rslt_t _cyhal_comp_lp_configure (cyhal_comp_t *obj, cyhal_comp_config_t *cfg)
 Reconfigure the Comparator for a LP-based comparator. More...
 
bool _cyhal_comp_lp_read (cyhal_comp_t *obj)
 Reads the Comparator state for a LP-based comparator. More...
 
void _cyhal_comp_lp_enable_event (cyhal_comp_t *obj, cyhal_comp_event_t event, uint8_t intr_priority, bool enable)
 Enable or Disable a Comparator event for a LP-based comparator. More...
 

Function Documentation

◆ _cyhal_comp_lp_init()

cy_rslt_t _cyhal_comp_lp_init ( cyhal_comp_t obj,
cyhal_gpio_t  vin_p,
cyhal_gpio_t  vin_m,
cyhal_gpio_t  output,
cyhal_comp_config_t cfg 
)

Initialize the Comparator peripheral for a LP-based comparator.

Parameters
[out]objPointer to a Comparator object. The caller must allocate the memory for this object but the init function will initialize its contents.
[in]vin_pNon-inverting input pin
[in]vin_mInverting input pin
[in]outputComparator output pin. May be NC.
[in]cfgConfiguration structure
Returns
The status of the init request

◆ _cyhal_comp_lp_free()

void _cyhal_comp_lp_free ( cyhal_comp_t obj)

Deinitialize the Comparator peripheral for a LP-based comparator.

Parameters
[in]objComparator object

◆ _cyhal_comp_lp_set_power()

cy_rslt_t _cyhal_comp_lp_set_power ( cyhal_comp_t obj,
cyhal_power_level_t  power 
)

Changes the current operating power level of the comparator for a LP-based comparator.

If the power level is set to CYHAL_POWER_LEVEL_OFF, the comparator will be powered-off but it will retain its configuration, so it is not necessary to reconfigure it when changing the power level from CYHAL_POWER_LEVEL_OFF to any other value.

Parameters
[in]objComparator object
[in]powerThe power level to set
Returns
The status of the set power request

◆ _cyhal_comp_lp_configure()

cy_rslt_t _cyhal_comp_lp_configure ( cyhal_comp_t obj,
cyhal_comp_config_t cfg 
)

Reconfigure the Comparator for a LP-based comparator.

This retains the powered state of the comparator. Depending on the implementation, it may be necessary to temporarily deconfigure and/or power off the comparator in order to apply the new configuration. However, if the comparator is powered-off when this function is called, it will remain powered-off after it returns. Likewise, if the comparator is powered-on when this function is called, it will remain powered-on after it returns.

Parameters
[in]objComparator object
[in]cfgNew configuration to apply
Returns
The status of the configure request

◆ _cyhal_comp_lp_read()

bool _cyhal_comp_lp_read ( cyhal_comp_t obj)

Reads the Comparator state for a LP-based comparator.

Parameters
[in]objComparator object
Returns
The Comparator state. True if the non-inverting pin voltage is greater than the inverting pin voltage, false otherwise.

◆ _cyhal_comp_lp_enable_event()

void _cyhal_comp_lp_enable_event ( cyhal_comp_t obj,
cyhal_comp_event_t  event,
uint8_t  intr_priority,
bool  enable 
)

Enable or Disable a Comparator event for a LP-based comparator.

When an enabled event occurs, the function specified by cyhal_comp_register_callback will be called.

Parameters
[in]objComparator object
[in]eventComparator event
[in]intr_priorityPriority for NVIC interrupt events
[in]enableTrue to turn on event, False to turn off