MTB CAT1 Peripheral driver library

General Description

API Reference

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

Functions

cy_en_lpcomp_status_t Cy_LPComp_Init_Ext (LPCOMP_Type *base, cy_en_lpcomp_channel_t channel, const cy_stc_lpcomp_config_t *config, cy_stc_lpcomp_context_t *context)
 Cy_LPComp_Init_Ext() is an extended version of existing function Cy_LPComp_Init(). More...
 
void Cy_LPComp_Enable_Ext (LPCOMP_Type *base, cy_en_lpcomp_channel_t channel, cy_stc_lpcomp_context_t *context)
 Cy_LPComp_Enable_Ext() is an extended version of existing function Cy_LPComp_Enable(). More...
 
void Cy_LPComp_Disable_Ext (LPCOMP_Type *base, cy_en_lpcomp_channel_t channel, cy_stc_lpcomp_context_t *context)
 Cy_LPComp_Disable_Ext() is an extended version of existing function Cy_LPComp_Disable(). More...
 
cy_en_lpcomp_status_t Cy_LPComp_Init (LPCOMP_Type *base, cy_en_lpcomp_channel_t channel, const cy_stc_lpcomp_config_t *config)
 Initializes the low-power comparator and returns the status of the initialization. More...
 
void Cy_LPComp_Enable (LPCOMP_Type *base, cy_en_lpcomp_channel_t channel)
 Enables the low-power comparator and sets Interrupt mode. More...
 
void Cy_LPComp_Disable (LPCOMP_Type *base, cy_en_lpcomp_channel_t channel)
 Disables the low-power comparator power and sets Interrupt mode to the disabled state. More...
 
__STATIC_INLINE void Cy_LPComp_GlobalEnable (LPCOMP_Type *base)
 Activates the IP of the low-power comparator hardware block. More...
 
__STATIC_INLINE void Cy_LPComp_GlobalDisable (LPCOMP_Type *base)
 Deactivates the IP of the low-power comparator hardware block. More...
 
__STATIC_INLINE void Cy_LPComp_UlpReferenceEnable (LPCOMP_Type *base)
 Enables the local reference-generator circuit. More...
 
__STATIC_INLINE void Cy_LPComp_UlpReferenceDisable (LPCOMP_Type *base)
 Disables the local reference-generator circuit. More...
 
__STATIC_INLINE uint32_t Cy_LPComp_GetCompare (LPCOMP_Type const *base, cy_en_lpcomp_channel_t channel)
 This function 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_Ext (LPCOMP_Type *base, cy_en_lpcomp_channel_t channel, cy_en_lpcomp_pwr_t power, cy_stc_lpcomp_context_t *context)
 Cy_LPComp_SetPower_Ext() is an extended version of existing function Cy_LPComp_SetPower(). More...
 
void Cy_LPComp_SetPower (LPCOMP_Type *base, cy_en_lpcomp_channel_t channel, cy_en_lpcomp_pwr_t power)
 Sets the drive power and speeds to one of the four settings. More...
 
void Cy_LPComp_SetHysteresis (LPCOMP_Type *base, cy_en_lpcomp_channel_t channel, cy_en_lpcomp_hyst_t hysteresis)
 Adds the 30mV hysteresis to the comparator. More...
 
void Cy_LPComp_SetInputs (LPCOMP_Type *base, cy_en_lpcomp_channel_t channel, cy_en_lpcomp_inputs_t inputP, cy_en_lpcomp_inputs_t inputN)
 Sets the comparator input sources. More...
 
void Cy_LPComp_SetOutputMode (LPCOMP_Type *base, cy_en_lpcomp_channel_t channel, cy_en_lpcomp_out_t outType)
 Sets the type of the comparator DSI output. More...
 
void Cy_LPComp_SetInterruptTriggerMode_Ext (LPCOMP_Type *base, cy_en_lpcomp_channel_t channel, cy_en_lpcomp_int_t intType, cy_stc_lpcomp_context_t *context)
 Cy_LPComp_SetInterruptTriggerMode_Ext() is an extended version of existing function Cy_LPComp_SetInterruptTriggerMode(). More...
 
void Cy_LPComp_SetInterruptTriggerMode (LPCOMP_Type *base, cy_en_lpcomp_channel_t channel, cy_en_lpcomp_int_t intType)
 This function sets the interrupt edge-detect mode and controls the value provided on the output. More...
 
__STATIC_INLINE uint32_t Cy_LPComp_GetInterruptStatus (LPCOMP_Type const *base)
 Returns the status of two different low-power comparator interrupt requests. More...
 
__STATIC_INLINE void Cy_LPComp_ClearInterrupt (LPCOMP_Type *base, uint32_t interrupt)
 Clears low-power comparator 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 will 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...
 
__STATIC_INLINE void Cy_LPComp_ConnectULPReference (LPCOMP_Type *base, cy_en_lpcomp_channel_t channel)
 Connects the local reference generator output to the comparator negative input. More...
 

Function Documentation

◆ Cy_LPComp_Init_Ext()

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

Cy_LPComp_Init_Ext() is an extended version of existing function Cy_LPComp_Init().

This implementation follows the thread-safe approach and is preferable for usage.

This function initializes the low-power comparator and returns the status of the initialization.

Note
Interrupt edge-detect mode and drive power mode are not written to the registers during the function execution. This can result in unexpected interrupts when the comparator is enabled. Instead, the configurations are saved to the context and applied in the Cy_LPComp_Enable_Ext() function.
Parameters
*baseThe low-power comparator registers structure pointer.
channelThe low-power comparator channel index.
*configThe pointer to the configuration structure for PDL.
*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 *base checking result. If the pointer is NULL, returns an error.

◆ Cy_LPComp_Enable_Ext()

void Cy_LPComp_Enable_Ext ( LPCOMP_Type base,
cy_en_lpcomp_channel_t  channel,
cy_stc_lpcomp_context_t context 
)

Cy_LPComp_Enable_Ext() is an extended version of existing function Cy_LPComp_Enable().

This implementation follows the thread-safe approach and is preferable for usage.

This function enables the low-power comparator and sets interrupt edge-detect and drive power modes.

Parameters
*baseThe low-power comparator register structure pointer.
channelThe low-power comparator channel index.
*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
None.

◆ Cy_LPComp_Disable_Ext()

void Cy_LPComp_Disable_Ext ( LPCOMP_Type base,
cy_en_lpcomp_channel_t  channel,
cy_stc_lpcomp_context_t context 
)

Cy_LPComp_Disable_Ext() is an extended version of existing function Cy_LPComp_Disable().

This implementation follows the thread-safe approach and is preferable for usage.

This function disables the low-power comparator power and sets interrupt edge-detect mode to the disabled state.

Note
This function disables the comparator interrupt to prevent a false trigger that may happen due to stop working of the comparator unpowered output.
Disabled states for comparator interrupt and drive power are not preserved in the context. The actual configurations for interrupt edge-detect and drive power are restored from the context in: Cy_LPComp_Enable_Ext().
Parameters
*baseThe low-power comparator register structure pointer.
channelThe low-power comparator channel index.
*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
None.

◆ 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 
)

Initializes the low-power comparator and returns the status of the initialization.

Parameters
*baseThe low-power comparator registers structure pointer.
channelThe low-power comparator channel index.
*configThe pointer to the configuration structure for PDL.
Returns
cy_en_lpcomp_status_t *base checking result. If the pointer is NULL, returns an error.

◆ Cy_LPComp_Enable()

void Cy_LPComp_Enable ( LPCOMP_Type base,
cy_en_lpcomp_channel_t  channel 
)

Enables the low-power comparator and sets Interrupt mode.

Parameters
*baseThe low-power comparator register structure pointer.
channelThe low-power comparator channel index.
Returns
None.

◆ Cy_LPComp_Disable()

void Cy_LPComp_Disable ( LPCOMP_Type base,
cy_en_lpcomp_channel_t  channel 
)

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

Parameters
*baseThe low-power comparator register structure pointer.
channelThe low-power comparator channel index.
Returns
None.

◆ Cy_LPComp_GlobalEnable()

__STATIC_INLINE void Cy_LPComp_GlobalEnable ( LPCOMP_Type base)

Activates the IP of the low-power comparator hardware block.

Call this function before operating any comparator channel.

Note
Interrupts can be enabled after the block is enabled and appropriate start-up time has elapsed:
  • 3 us for normal power mode;
  • 6 us for LP mode;
  • 50 us for ULP mode.
Parameters
*baseThe low-power comparator register structure pointer.
Returns
None.

◆ Cy_LPComp_GlobalDisable()

__STATIC_INLINE void Cy_LPComp_GlobalDisable ( LPCOMP_Type base)

Deactivates the IP of the low-power comparator hardware block.

(Analog is in power down, open all switches, all clocks are off).

Parameters
*baseThe low-power comparator register structure pointer.
Returns
None.

◆ Cy_LPComp_UlpReferenceEnable()

__STATIC_INLINE void Cy_LPComp_UlpReferenceEnable ( LPCOMP_Type base)

Enables the local reference-generator circuit.

Parameters
*baseThe low-power comparator register structure pointer.
Returns
None.

◆ Cy_LPComp_UlpReferenceDisable()

__STATIC_INLINE void Cy_LPComp_UlpReferenceDisable ( LPCOMP_Type base)

Disables the local reference-generator circuit.

Parameters
*baseThe low-power comparator register structure pointer.
Returns
None.

◆ Cy_LPComp_GetCompare()

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

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

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

◆ Cy_LPComp_SetPower_Ext()

void Cy_LPComp_SetPower_Ext ( LPCOMP_Type base,
cy_en_lpcomp_channel_t  channel,
cy_en_lpcomp_pwr_t  power,
cy_stc_lpcomp_context_t context 
)

Cy_LPComp_SetPower_Ext() is an extended version of existing function Cy_LPComp_SetPower().

This implementation follows the thread-safe approach and is preferable for usage.

This function sets the drive power and speeds to one of the four settings.

Note
The drive power mode is preserved in the context, except state CY_LPCOMP_MODE_OFF.
The mode of the interrupt is restored after the block is enabled and appropriate start-up time has elapsed:
  • 3 us for normal power mode;
  • 6 us for LP mode;
  • 50 us for ULP mode. Otherwise, unexpected interrupts can occur.
Parameters
*baseThe low-power comparator register structure pointer.
channelThe low-power comparator channel index.
powerDefines the component power mode:
  • CY_LPCOMP_OFF_POWER (=0) - off power;
  • CY_LPCOMP_MODE_ULP (=1) - slow/ultra low power;
  • CY_LPCOMP_MODE_LP (=2) - medium/low power;
  • CY_LPCOMP_MODE_NORMAL (=3) - fast/normal power.
*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
None.

◆ Cy_LPComp_SetPower()

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

Sets the drive power and speeds to one of the four settings.

Note
Interrupts can be enabled after the block is enabled and appropriate start-up time has elapsed:
  • 3 us for normal power mode;
  • 6 us for LP mode;
  • 50 us for ULP mode. Otherwise, unexpected interrupts can occur.
Parameters
*baseThe low-power comparator register structure pointer.
channelThe low-power comparator channel index.
powerDefines the component power mode:
  • CY_LPCOMP_OFF_POWER (=0) - off power;
  • CY_LPCOMP_MODE_ULP (=1) - slow/ultra low power;
  • CY_LPCOMP_MODE_LP (=2) - medium/low power;
  • CY_LPCOMP_MODE_NORMAL (=3) - fast/normal power.
Returns
None.

◆ Cy_LPComp_SetHysteresis()

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

Adds the 30mV hysteresis to the comparator.

Parameters
*baseThe low-power comparator register structure pointer.
channelThe low-power comparator channel index.
hysteresisDefines the component operation mode:
  • CY_LPCOMP_HYST_ENABLE (=1) - enables HYST;
  • CY_LPCOMP_HYST_DISABLE (=0) - disables HYST.
Returns
None.

◆ Cy_LPComp_SetInputs()

void Cy_LPComp_SetInputs ( LPCOMP_Type base,
cy_en_lpcomp_channel_t  channel,
cy_en_lpcomp_inputs_t  inputP,
cy_en_lpcomp_inputs_t  inputN 
)

Sets the comparator input sources.

The comparator inputs can be connected to the dedicated GPIO pins or AMUXBUSA/AMUXBUSB. Additionally, the negative comparator input can be connected to the local VREF. Even one unconnected input causes a comparator undefined output.

Note
Connection to AMUXBUSA/AMUXBUSB requires closing the additional switches, which are part of the IO system. These switches can be configured using the HSIOM->AMUX_SPLIT_CTL[3] register. For details, refer to the appropriate Technical Reference Manual (TRM).
Parameters
*baseThe low-power comparator register structure pointer.
channelThe low-power comparator channel index.
inputPPositive input selection:
  • CY_LPCOMP_SW_GPIO (0x01u);
  • CY_LPCOMP_SW_AMUXBUSA (0x02u) - Hi-Z in Hibernate mode;
  • CY_LPCOMP_SW_AMUXBUSB (0x04u) - Hi-Z in Hibernate mode.
Note
: the option AMUXBUS should NOT be selected in case of usage device from CAT1D family.
Parameters
inputNNegative input selection:
  • CY_LPCOMP_SW_GPIO (0x01u);
  • CY_LPCOMP_SW_AMUXBUSA (0x02u) - Hi-Z in Hibernate mode;
  • CY_LPCOMP_SW_AMUXBUSB (0x04u) - Hi-Z in Hibernate mode;
  • CY_LPCOMP_SW_LOCAL_VREF (0x08u) - the negative input only for a crude REF.
Note
: the option AMUXBUS should NOT be selected in case of usage device from CAT1D family.
Returns
None.

◆ Cy_LPComp_SetOutputMode()

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

Sets the type of the comparator DSI output.

Parameters
*baseThe low-power comparator register structure pointer.
channelThe low-power comparator channel index.
outTypeInterrupt-edge trigger selection:
  • CY_LPCOMP_OUT_PULSE (=0) - the DSI output with the pulse option, no bypass;
  • CY_LPCOMP_OUT_DIRECT (=1) - Bypass mode, the direct output of the comparator;
  • CY_LPCOMP_OUT_SYNC (=2) - the DSI output with the level option, it is similar to Bypass mode, but it is 1 cycle slower. [DSI_LEVELx : DSI_BYPASSx] = [Bit11 : Bit10] 0 : 0 = 0x00 -> Pulse (PULSE) 1 : 0 = 0x02 -> Level (SYNC) x : 1 = 0x01 -> Bypass (Direct).
Returns
None.

◆ Cy_LPComp_SetInterruptTriggerMode_Ext()

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

Cy_LPComp_SetInterruptTriggerMode_Ext() is an extended version of existing function Cy_LPComp_SetInterruptTriggerMode().

This implementation follows the thread-safe approach and is preferable for usage.

This function sets the interrupt edge-detect mode and controls the value provided on the output.

Note
The interrupt edge-detect mode is preserved in the context, except state CY_LPCOMP_INTR_DISABLE.
The mode of the interrupt is restored after the block is enabled and appropriate start-up time has elapsed:
  • 3 us is for normal power mode;
  • 6 us for LP mode;
  • 50 us for ULP mode.
Parameters
*baseThe low-power comparator register structure pointer.
channelThe low-power comparator channel index.
intTypeInterrupt edge trigger selection:
  • CY_LPCOMP_INTR_DISABLE (=0) - disabled, no interrupt will be detected;
  • CY_LPCOMP_INTR_RISING (=1) - the rising edge;
  • CY_LPCOMP_INTR_FALLING (=2) - the falling edge;
  • CY_LPCOMP_INTR_BOTH (=3) - both rising and falling edges.
*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
None.

◆ Cy_LPComp_SetInterruptTriggerMode()

void Cy_LPComp_SetInterruptTriggerMode ( LPCOMP_Type base,
cy_en_lpcomp_channel_t  channel,
cy_en_lpcomp_int_t  intType 
)

This function sets the interrupt edge-detect mode and controls the value provided on the output.

Note
Interrupts can be enabled after the block is enabled and appropriate start-up time has elapsed:
  • 3 us is for normal power mode;
  • 6 us for LP mode;
  • 50 us for ULP mode.
Parameters
*baseThe low-power comparator register structure pointer.
channelThe low-power comparator channel index.
intTypeThe interrupt edge trigger selection:
  • CY_LPCOMP_INTR_DISABLE (=0) - disabled, no interrupt will be detected;
  • CY_LPCOMP_INTR_RISING (=1) - the rising edge;
  • CY_LPCOMP_INTR_FALLING (=2) - the falling edge;
  • CY_LPCOMP_INTR_BOTH (=3) - both rising and falling edges.
Returns
None.

◆ Cy_LPComp_GetInterruptStatus()

__STATIC_INLINE uint32_t Cy_LPComp_GetInterruptStatus ( LPCOMP_Type const *  base)

Returns the status of two different low-power comparator interrupt requests.

Parameters
*baseThe low-power comparator register structure pointer.
Returns
bit mapping information:
  • Bit 0: COMP0 interrupt status
  • Bit 1: COMP1 interrupt status

◆ Cy_LPComp_ClearInterrupt()

__STATIC_INLINE void Cy_LPComp_ClearInterrupt ( LPCOMP_Type base,
uint32_t  interrupt 
)

Clears low-power comparator interrupts by setting each bit.

Parameters
*baseThe low-power comparator register structure pointer.
interrupt
  • Bit 0: COMP0 interrupt status
  • Bit 1: COMP1 interrupt status
Returns
None.

◆ Cy_LPComp_SetInterrupt()

__STATIC_INLINE void Cy_LPComp_SetInterrupt ( LPCOMP_Type base,
uint32_t  interrupt 
)

Sets a software interrupt request.

This function is used in the case of combined interrupt signal from the global signal reference. This function from either component instance can be used to trigger either or both software interrupts. The function sets the INTR_SET interrupt mask.

Parameters
*baseThe low-power comparator register structure pointer.
interrupt
  • Bit 0: COMP0 interrupt status
  • Bit 1: COMP1 interrupt status
Returns
None.

◆ Cy_LPComp_GetInterruptMask()

__STATIC_INLINE uint32_t Cy_LPComp_GetInterruptMask ( LPCOMP_Type const *  base)

Returns an interrupt mask.

Parameters
*baseThe low-power comparator register structure pointer.
Returns
bit mapping information:
  • Bit 0: COMP0 interrupt mask
  • Bit 1: COMP1 interrupt mask

◆ Cy_LPComp_SetInterruptMask()

__STATIC_INLINE void Cy_LPComp_SetInterruptMask ( LPCOMP_Type base,
uint32_t  interrupt 
)

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

Parameters
*baseThe low-power comparator register structure pointer.
interruptuint32_t interruptMask: Bit Mask of interrupts to set.
  • Bit 0: COMP0 interrupt mask
  • Bit 1: COMP1 interrupt mask
Returns
None.

◆ 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 low-power comparator register structure pointer.
Returns
bit mapping information:
  • Bit 0: COMP0 interrupt masked
  • Bit 1: COMP1 interrupt masked

◆ Cy_LPComp_ConnectULPReference()

__STATIC_INLINE void Cy_LPComp_ConnectULPReference ( LPCOMP_Type base,
cy_en_lpcomp_channel_t  channel 
)

Connects the local reference generator output to the comparator negative input.

Parameters
*baseThe low-power comparator register structure pointer.
channelThe low-power comparator channel index.
Returns
None.