High level interface for interacting with the Operational Amplifier (Opamp).
Each opamp can operate in one of two modes:
In both modes, the output is driven off chip via another pin.
Call cyhal_opamp_init to initialize an opamp instance by providing the opamp object (obj), non-inverting input pin (vin_p), inverting input pin (vin_m), and output pin (vout). If follower mode is desired, pass NC
for vin_m.
Use cyhal_opamp_set_power to configure the opamp power.
The following snippet initializes a bare opamp. Note that any passive components (e.g. resistive feedback) must be implemented off-chip.
The following snippet initializes an opamp as a follower.
The following snippet demonstrates temporarily powering-off the opamp without freeing it.
API Reference | |
Opamp HAL Results | |
Opamp specific return codes. | |
Functions | |
cy_rslt_t | cyhal_opamp_init (cyhal_opamp_t *obj, cyhal_gpio_t vin_p, cyhal_gpio_t vin_m, cyhal_gpio_t vout) |
Initialize the opamp peripheral. More... | |
void | cyhal_opamp_free (cyhal_opamp_t *obj) |
Deinitialize the opamp peripheral and free associated resources. More... | |
cy_rslt_t | cyhal_opamp_set_power (cyhal_opamp_t *obj, cyhal_power_level_t power) |
Changes the current operating power level of the opamp. More... | |
cy_rslt_t cyhal_opamp_init | ( | cyhal_opamp_t * | obj, |
cyhal_gpio_t | vin_p, | ||
cyhal_gpio_t | vin_m, | ||
cyhal_gpio_t | vout | ||
) |
Initialize the opamp peripheral.
If vin_m is NC, the opamp will be initialized in follower mode (unity gain).
The opamp will be initialized but not powered-on until cyhal_opamp_set_power is called.
[out] | obj | Pointer to an opamp object. The caller must allocate the memory for this object but the init function will initialize its contents. |
[in] | vin_p | Non-inverting input |
[in] | vin_m | Inverting input |
[in] | vout | opamp output |
void cyhal_opamp_free | ( | cyhal_opamp_t * | obj | ) |
Deinitialize the opamp peripheral and free associated resources.
This will disconnect all inputs and outputs, including internal feedback.
[in] | obj | The opamp object |
cy_rslt_t cyhal_opamp_set_power | ( | cyhal_opamp_t * | obj, |
cyhal_power_level_t | power | ||
) |
Changes the current operating power level of the opamp.
If the power level is set to CYHAL_POWER_LEVEL_OFF, the opamp 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.
[in] | obj | Opamp object |
[in] | power | The power level to set |