CAT2 Peripheral Driver Library

Modules

 Low Power Callback
 The driver supports SysPm callback for Deep Sleep transition.
 

Functions

cy_en_lpcomp_status_t Cy_LPComp_Init (LPCOMP_Type *base, cy_en_lpcomp_channel_t channel, const cy_stc_lpcomp_config_t *config, cy_stc_lpcomp_context_t *context)
 Initializes the low-power comparator. More...
 
void Cy_LPComp_Enable (LPCOMP_Type *base, cy_en_lpcomp_channel_t channel, cy_stc_lpcomp_context_t *context)
 Enables the low-power comparator and sets the interrupt mode. More...
 
void Cy_LPComp_Disable (LPCOMP_Type *base, cy_en_lpcomp_channel_t channel, cy_stc_lpcomp_context_t *context)
 Disables the low-power comparator and sets the interrupt mode to disabled. More...
 
__STATIC_INLINE uint32_t Cy_LPComp_GetCompare (LPCOMP_Type const *base, cy_en_lpcomp_channel_t channel)
 Returns a non-zero value when the voltage connected to the positive input is greater than the negative input voltage. More...
 
void Cy_LPComp_SetPower (LPCOMP_Type *base, cy_en_lpcomp_channel_t channel, cy_en_lpcomp_pwr_t power)
 Sets Drive power mode and speed configuration. More...
 
void Cy_LPComp_SetHysteresis (LPCOMP_Type *base, cy_en_lpcomp_channel_t channel, cy_en_lpcomp_hyst_t hysteresis)
 Configures the 10 mV hysteresis level. More...
 
void Cy_LPComp_SetOutputMode (LPCOMP_Type *base, cy_en_lpcomp_channel_t channel, cy_en_lpcomp_out_t outType)
 Sets the comparator Output mode. More...
 
void Cy_LPComp_SetInterruptTriggerMode (LPCOMP_Type *base, cy_en_lpcomp_channel_t channel, cy_en_lpcomp_int_t intType, cy_stc_lpcomp_context_t *context)
 Sets the interrupt Edge-detect mode. More...
 
uint32_t Cy_LPComp_ZeroCal (LPCOMP_Type const *base, cy_en_lpcomp_channel_t channel)
 Performs custom calibration of the input offset to minimize the error for a specific set of conditions: the comparator reference voltage, supply voltage, and operating temperature. More...
 
void Cy_LPComp_LoadTrim (LPCOMP_Type const *base, cy_en_lpcomp_channel_t channel, uint32_t trimVal)
 Writes a value into the comparator offset trim register. More...
 
__STATIC_INLINE uint32_t Cy_LPComp_GetInterruptStatus (LPCOMP_Type const *base)
 Returns the status of 2 different LPCOMP interrupt requests. More...
 
__STATIC_INLINE void Cy_LPComp_ClearInterrupt (LPCOMP_Type *base, uint32_t interrupt)
 Clears LPCOMP interrupts by setting each bit. More...
 
__STATIC_INLINE void Cy_LPComp_SetInterrupt (LPCOMP_Type *base, uint32_t interrupt)
 Sets a software interrupt request. More...
 
__STATIC_INLINE uint32_t Cy_LPComp_GetInterruptMask (LPCOMP_Type const *base)
 Returns an interrupt mask. More...
 
__STATIC_INLINE void Cy_LPComp_SetInterruptMask (LPCOMP_Type *base, uint32_t interrupt)
 Configures which bits of the interrupt request register trigger an interrupt event. More...
 
__STATIC_INLINE uint32_t Cy_LPComp_GetInterruptStatusMasked (LPCOMP_Type const *base)
 Returns an interrupt request register masked by an interrupt mask. More...
 

Detailed Description

Function Documentation

◆ Cy_LPComp_Init()

cy_en_lpcomp_status_t Cy_LPComp_Init ( LPCOMP_Type *  base,
cy_en_lpcomp_channel_t  channel,
const cy_stc_lpcomp_config_t config,
cy_stc_lpcomp_context_t context 
)

Initializes the low-power comparator.

Note
The interrupt mode configuration is not written to the register during the execution of the function. This can result in unexpected interrupts when the comparator is enabled. Instead the configuration is saved to the context and applied in the Cy_LPComp_Enable() function.
Parameters
*baseThe low-power comparator registers structure-pointer.
channelThe low-power comparator channel number.
*configThe pointer to the configuration structure.
*contextThe pointer to the context structure cy_stc_lpcomp_context_t allocated by the user. The structure is used during the low-power comparator operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
cy_en_lpcomp_status_t

◆ Cy_LPComp_Enable()

void Cy_LPComp_Enable ( LPCOMP_Type *  base,
cy_en_lpcomp_channel_t  channel,
cy_stc_lpcomp_context_t context 
)

Enables the low-power comparator and sets the interrupt mode.

Parameters
*baseThe low-power comparator registers structure-pointer.
channelThe low-power comparator channel number.
*contextThe pointer to the context structure cy_stc_lpcomp_context_t allocated by the user. The structure is used during the low-power comparator operation for internal configuration and data retention. The user must not modify anything in this structure.

◆ Cy_LPComp_Disable()

void Cy_LPComp_Disable ( LPCOMP_Type *  base,
cy_en_lpcomp_channel_t  channel,
cy_stc_lpcomp_context_t context 
)

Disables the low-power comparator and sets the interrupt mode to disabled.

Note
The interrupt is disabled by this function because when the comparator is disabled its output stops working and the interrupt triggers. The actual configuration is restored from the context in: Cy_LPComp_Enable().
Parameters
*baseThe low-power comparator registers structure-pointer.
channelThe low-power comparator channel number.
*contextThe pointer to the context structure cy_stc_lpcomp_context_t allocated by the user. The structure is used during the low-power comparator operation for internal configuration and data retention. The user must not modify anything in this structure.

◆ Cy_LPComp_GetCompare()

__STATIC_INLINE uint32_t Cy_LPComp_GetCompare ( LPCOMP_Type const *  base,
cy_en_lpcomp_channel_t  channel 
)

Returns a non-zero value when the voltage connected to the positive input is greater than the negative input voltage.

Parameters
*baseThe LPComp register structure-pointer.
channelThe LPComp channel index.
Returns
LPComp compare result. The value is a non-zero value when the voltage connected to the positive input is greater than the negative input voltage.

◆ Cy_LPComp_SetPower()

void Cy_LPComp_SetPower ( LPCOMP_Type *  base,
cy_en_lpcomp_channel_t  channel,
cy_en_lpcomp_pwr_t  power 
)

Sets Drive power mode and speed configuration.

The power consumption and response time vary depending on the selected power mode; power consumption is the highest in Fast mode and the lowest in Ultra-low-power mode, response time is fastest in fast mode and slowest in ultra-low-power mode. Refer to the device datasheet for specifications for the response time and power consumption for various power settings.

Note
The output of the comparator may stop working when Power mode is changed while the comparator is enabled. To avoid this, disable the comparator before changing Power mode.
Parameters
*baseThe low-power comparator registers structure pointer.
channelThe low-power comparator channel number.
powercy_en_lpcomp_pwr_t

◆ Cy_LPComp_SetHysteresis()

void Cy_LPComp_SetHysteresis ( LPCOMP_Type *  base,
cy_en_lpcomp_channel_t  channel,
cy_en_lpcomp_hyst_t  hysteresis 
)

Configures the 10 mV hysteresis level.

Enabling the hysteresis helps ensure that slowly moving voltages or slightly noisy voltages will not cause the output of the comparator to oscillate when the two input voltages are nearly equal.

Parameters
*baseThe low-power comparator registers structure-pointer.
channelThe low-power comparator channel number.
hysteresiscy_en_lpcomp_hyst_t

◆ Cy_LPComp_SetOutputMode()

void Cy_LPComp_SetOutputMode ( LPCOMP_Type *  base,
cy_en_lpcomp_channel_t  channel,
cy_en_lpcomp_out_t  outType 
)

Sets the comparator Output mode.

Parameters
*baseThe low-power comparator registers structure-pointer.
channelThe low-power comparator channel number.
outTypeComparator output mode cy_en_lpcomp_out_t

◆ Cy_LPComp_SetInterruptTriggerMode()

void Cy_LPComp_SetInterruptTriggerMode ( LPCOMP_Type *  base,
cy_en_lpcomp_channel_t  channel,
cy_en_lpcomp_int_t  intType,
cy_stc_lpcomp_context_t context 
)

Sets the interrupt Edge-detect mode.

Parameters
*baseThe low-power comparator registers structure-pointer.
channelThe low-power comparator channel number.
intTypeInterrupt edge trigger selection cy_en_lpcomp_int_t
*contextThe pointer to the context structure cy_stc_lpcomp_context_t allocated by the user. The structure is used during the low-power comparator operation for internal configuration and data retention. The user must not modify anything in this structure.

◆ Cy_LPComp_ZeroCal()

uint32_t Cy_LPComp_ZeroCal ( LPCOMP_Type const *  base,
cy_en_lpcomp_channel_t  channel 
)

Performs custom calibration of the input offset to minimize the error for a specific set of conditions: the comparator reference voltage, supply voltage, and operating temperature.

Refer to technical reference manual (TRM) and the device datasheet for more details.

Note
The comparator offset is trimmed at the factory. For normal operation, further adjustment of trim values is not recommended.
A reference voltage in the range at which the comparator will be used, must be applied to one of the inputs. The two inputs will be shorted internally to perform the offset calibration.
Before calibration the comparator should be in the slow mode with the hysteresis be turned off.
Parameters
*baseThe low-power comparator registers structure-pointer.
channelThe low-power comparator channel number.
Returns
The value from the comparator trim register after the offset calibration is complete. This value has the same format as the input parameter for the Cy_LPComp_LoadTrim() API routine.
Function Usage

◆ Cy_LPComp_LoadTrim()

void Cy_LPComp_LoadTrim ( LPCOMP_Type const *  base,
cy_en_lpcomp_channel_t  channel,
uint32_t  trimVal 
)

Writes a value into the comparator offset trim register.

See Cy_LPComp_ZeroCal() description for the procedure of getting trim.

Parameters
*baseThe low-power comparator registers structure-pointer.
channelThe low-power comparator channel number.
trimValThe value to store into the comparator offset trim-register. This value has the same format as the parameter returned by the Cy_LPComp_ZeroCal() API routine.

◆ Cy_LPComp_GetInterruptStatus()

__STATIC_INLINE uint32_t Cy_LPComp_GetInterruptStatus ( LPCOMP_Type const *  base)

Returns the status of 2 different LPCOMP interrupt requests.

Parameters
*baseThe LPCOMP register structure-pointer.
Returns
Interrupt mask: CY_LPCOMP_CHANNEL0_INTR and CY_LPCOMP_CHANNEL1_INTR.

◆ Cy_LPComp_ClearInterrupt()

__STATIC_INLINE void Cy_LPComp_ClearInterrupt ( LPCOMP_Type *  base,
uint32_t  interrupt 
)

Clears LPCOMP interrupts by setting each bit.

Parameters
*baseThe LPCOMP register structure-pointer.
interruptstatus: CY_LPCOMP_CHANNEL0_INTR and CY_LPCOMP_CHANNEL1_INTR.

◆ Cy_LPComp_SetInterrupt()

__STATIC_INLINE void Cy_LPComp_SetInterrupt ( LPCOMP_Type *  base,
uint32_t  interrupt 
)

Sets a software interrupt request.

Used for a combined interrupt signal from the global signal reference. Also, can be used from either component instance to trigger either or both software interrupts. It sets the INTR_SET interrupt mask.

Parameters
*baseThe LPCOMP register structure-pointer.
interruptInterrupt status: CY_LPCOMP_CHANNEL0_INTR and CY_LPCOMP_CHANNEL1_INTR.

◆ Cy_LPComp_GetInterruptMask()

__STATIC_INLINE uint32_t Cy_LPComp_GetInterruptMask ( LPCOMP_Type const *  base)

Returns an interrupt mask.

Parameters
*baseThe LPCOMP register structure-pointer.
Returns
Interrupt mask: CY_LPCOMP_CHANNEL0_INTR and CY_LPCOMP_CHANNEL1_INTR.

◆ Cy_LPComp_SetInterruptMask()

__STATIC_INLINE void Cy_LPComp_SetInterruptMask ( LPCOMP_Type *  base,
uint32_t  interrupt 
)

Configures which bits of the interrupt request register trigger an interrupt event.

Parameters
*baseThe LPCOMP register structure-pointer.
interruptInterrupt mask: CY_LPCOMP_CHANNEL0_INTR and CY_LPCOMP_CHANNEL1_INTR.

◆ Cy_LPComp_GetInterruptStatusMasked()

__STATIC_INLINE uint32_t Cy_LPComp_GetInterruptStatusMasked ( LPCOMP_Type const *  base)

Returns an interrupt request register masked by an interrupt mask.

Returns the result of the bitwise AND operation between the corresponding interrupt request and mask bits.

Parameters
*baseThe LPCOMP register structure-pointer.
Returns
Interrupt mask: CY_LPCOMP_CHANNEL0_INTR and CY_LPCOMP_CHANNEL1_INTR.