COMP (CTB Opamps)

group group_hal_comp_ctb

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.

Return

The status of the init request

Parameters
  • [out] obj: Pointer to a Comparator object. The caller must allocate the memory for this object but the init function will initialize its contents.

  • [in] vin_p: Non-inverting input pin

  • [in] vin_m: Inverting input pin

  • [in] output: Comparator output pin. May be NC.

  • [in] cfg: Configuration structure

void _cyhal_comp_ctb_free(cyhal_comp_t *obj)

Deinitialize the Comparator peripheral for a CTB-based comparator.

Parameters
  • [in] obj: Comparator object

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.

Return

The status of the set power request

Parameters
  • [in] obj: Comparator object

  • [in] power: The power level to set

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.

Return

The status of the configure request

Parameters
  • [in] obj: Comparator object

  • [in] cfg: New configuration to apply

bool _cyhal_comp_ctb_read(cyhal_comp_t *obj)

Reads the Comparator state for a CTB-based comparator.

Return

The Comparator state. True if the non-inverting pin voltage is greater than the inverting pin voltage, false otherwise.

Parameters
  • [in] obj: Comparator object

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] obj: Comparator object

  • [in] event: Comparator event

  • [in] intr_priority: Priority for NVIC interrupt events

  • [in] enable: True to turn on event, False to turn off