Hardware Abstraction Layer (HAL)
All Data Structures Functions Variables Typedefs Enumerations Enumerator Modules Pages

General Description

Implementation of the analog comparator (COMP) driver on top of the CTB opamps.

Functions

cy_rslt_t _cyhal_comp_ctb_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 CTB-based comparator. More...
 
void _cyhal_comp_ctb_free (cyhal_comp_t *obj)
 Deinitialize the Comparator peripheral for a CTB-based comparator. More...
 
cy_rslt_t _cyhal_comp_ctb_set_power (cyhal_comp_t *obj, cyhal_power_level_t power)
 Changes the current operating power level of the comparator for a CTB-based comparator. More...
 
cy_rslt_t _cyhal_comp_ctb_configure (cyhal_comp_t *obj, cyhal_comp_config_t *cfg)
 Reconfigure the Comparator for a CTB-based comparator. More...
 
bool _cyhal_comp_ctb_read (cyhal_comp_t *obj)
 Reads the Comparator state for a CTB-based comparator. More...
 
void _cyhal_comp_ctb_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 CTB-based comparator. More...
 

Function Documentation

◆ _cyhal_comp_ctb_init()

cy_rslt_t _cyhal_comp_ctb_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 CTB-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_ctb_free()

void _cyhal_comp_ctb_free ( cyhal_comp_t obj)

Deinitialize the Comparator peripheral for a CTB-based comparator.

Parameters
[in]objComparator object

◆ _cyhal_comp_ctb_set_power()

cy_rslt_t _cyhal_comp_ctb_set_power ( cyhal_comp_t obj,
cyhal_power_level_t  power 
)

Changes the current operating power level of the comparator for a CTB-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_ctb_configure()

cy_rslt_t _cyhal_comp_ctb_configure ( cyhal_comp_t obj,
cyhal_comp_config_t cfg 
)

Reconfigure the Comparator for a CTB-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_ctb_read()

bool _cyhal_comp_ctb_read ( cyhal_comp_t obj)

Reads the Comparator state for a CTB-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_ctb_enable_event()

void _cyhal_comp_ctb_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 CTB-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