High level interface for interacting with an analog Comparator.
The analog comparator measures one input voltage from the non-inverting pin against a second voltage provided on the inverting pin. The result of this comparison can be used in two ways:
These abilities can be used in any combination.
Call mtb_hal_comp_setup to initialize the HAL for a peripheral instance. The peripheral must] have already been initialized and configured using the PDL.
Use mtb_hal_comp_read to read the comparator state from firmware.
The following snippet reads the current comparator value into a variable
API Reference | |
Comparator HAL Results | |
Comparator specific return codes. | |
Functions | |
cy_rslt_t | mtb_hal_comp_setup (mtb_hal_comp_t *obj, const mtb_hal_comp_configurator_t *config) |
Sets up a HAL instance to use the specified hardware resource. More... | |
bool | mtb_hal_comp_read (mtb_hal_comp_t *obj) |
Reads the Comparator state. More... | |
cy_rslt_t | mtb_hal_comp_set_ref (mtb_hal_comp_t *obj, uint16_t ref_mv) |
Sets the reference voltage value. More... | |
cy_rslt_t mtb_hal_comp_setup | ( | mtb_hal_comp_t * | obj, |
const mtb_hal_comp_configurator_t * | config | ||
) |
Sets up a HAL instance to use the specified hardware resource.
This hardware resource must have already been configured via the PDL.
[out] | obj | The HAL driver instance object. The caller must allocate the memory for this object, but the HAL will initialize its contents |
[in] | config | The configurator-generated HAL config structure for this peripheral instance |
bool mtb_hal_comp_read | ( | mtb_hal_comp_t * | obj | ) |
Reads the Comparator state.
[in] | obj | Comparator object |
cy_rslt_t mtb_hal_comp_set_ref | ( | mtb_hal_comp_t * | obj, |
uint16_t | ref_mv | ||
) |
Sets the reference voltage value.
[in] | obj | Comparator object |
[in] | ref_mv | Reference voltage in millivolts |