API Reference | |
Low Power Callback | |
The driver supports SysPm callback for Deep Sleep and Hibernate 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) |
Initializes LPCOMP and returns the LPCOMP register address. More... | |
void | Cy_LPComp_Enable (LPCOMP_Type *base, cy_en_lpcomp_channel_t channel) |
Enables the LPCOMP and sets the LPCOMP interrupt mode. More... | |
void | Cy_LPComp_Disable (LPCOMP_Type *base, cy_en_lpcomp_channel_t channel) |
Disables the LPCOMP power and sets the interrupt mode to disabled. More... | |
__STATIC_INLINE void | Cy_LPComp_GlobalEnable (LPCOMP_Type *base) |
Activates the IP of the LPCOMP hardware block. More... | |
__STATIC_INLINE void | Cy_LPComp_GlobalDisable (LPCOMP_Type *base) |
Deactivates the IP of the LPCOMP 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 nonzero 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 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 (LPCOMP_Type *base, cy_en_lpcomp_channel_t channel, cy_en_lpcomp_int_t intType) |
Sets the interrupt edge-detect mode. 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 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... | |
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 LPCOMP and returns the LPCOMP register address.
*base | LPCOMP registers structure pointer. |
*config | The pointer to the configuration structure for PDL. |
channel | The LPCOMP channel index. |
void Cy_LPComp_Enable | ( | LPCOMP_Type * | base, |
cy_en_lpcomp_channel_t | channel | ||
) |
Enables the LPCOMP and sets the LPCOMP interrupt mode.
*base | The LPCOMP register structure pointer. |
channel | The LPCOMP channel index. |
void Cy_LPComp_Disable | ( | LPCOMP_Type * | base, |
cy_en_lpcomp_channel_t | channel | ||
) |
Disables the LPCOMP power and sets the interrupt mode to disabled.
*base | The LPCOMP register structure pointer. |
channel | The LPCOMP channel index. |
__STATIC_INLINE void Cy_LPComp_GlobalEnable | ( | LPCOMP_Type * | base | ) |
Activates the IP of the LPCOMP hardware block.
This API should be enabled before operating any channel of comparators. Note: Interrupts can be enabled after the block is enabled and the appropriate start-up time has elapsed: 3 us for the normal power mode; 6 us for the LP mode; 50 us for the ULP mode.
*base | The structure of the channel pointer. |
__STATIC_INLINE void Cy_LPComp_GlobalDisable | ( | LPCOMP_Type * | base | ) |
Deactivates the IP of the LPCOMP hardware block.
(Analog in power down, open all switches, all clocks off).
*base | The structure of the channel pointer. |
__STATIC_INLINE void Cy_LPComp_UlpReferenceEnable | ( | LPCOMP_Type * | base | ) |
Enables the local reference-generator circuit.
*base | The structure of the channel pointer. |
__STATIC_INLINE void Cy_LPComp_UlpReferenceDisable | ( | LPCOMP_Type * | base | ) |
Disables the local reference-generator circuit.
*base | The structure of the channel pointer. |
__STATIC_INLINE uint32_t Cy_LPComp_GetCompare | ( | LPCOMP_Type const * | base, |
cy_en_lpcomp_channel_t | channel | ||
) |
This function returns a nonzero value when the voltage connected to the positive input is greater than the negative input voltage.
*base | The LPComp register structure pointer. |
channel | The LPComp channel index. |
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.
*base | The LPCOMP register structure pointer. |
channel | The LPCOMP channel index. |
power | The power setting sets an operation mode of the component: 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 |
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.
*base | The LPCOMP register structure pointer. |
channel | The LPCOMP channel index. |
hysteresis | Sets an operation mode of the component CY_LPCOMP_HYST_ENABLE (=1) - Enables HYST CY_LPCOMP_HYST_DISABLE(=0) - Disable HYST. |
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. At least one unconnected input causes a comparator undefined output.
*base | The LPCOMP register structure pointer. |
channel | The LPCOMP channel index. |
inputP | Positive 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 the hibernate mode. |
inputN | Negative 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. |
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.
*base | The LPCOMP register structure pointer. |
channel | The LPCOMP channel index. |
outType | Interrupt edge trigger selection CY_LPCOMP_OUT_PULSE (=0) - the DSI output with the pulse option, no bypass CY_LPCOMP_OUT_DIRECT (=1) - the bypass mode, the direct output of the comparator CY_LPCOMP_OUT_SYNC (=2) - DSI output with the level option, it is similar to the bypass mode but it is 1 cycle slow than the bypass. [DSI_LEVELx : DSI_BYPASSx] = [Bit11 : Bit10] 0 : 0 = 0x00 -> Pulse (PULSE) 1 : 0 = 0x02 -> Level (SYNC) x : 1 = 0x01 -> Bypass (Direct). |
void Cy_LPComp_SetInterruptTriggerMode | ( | LPCOMP_Type * | base, |
cy_en_lpcomp_channel_t | channel, | ||
cy_en_lpcomp_int_t | intType | ||
) |
Sets the interrupt edge-detect mode.
This also controls the value provided on the output.
*base | The LPCOMP register structure pointer. |
channel | The LPCOMP channel index. |
intType | Interrupt edge trigger selection CY_LPCOMP_INTR_DISABLE (=0) - Disabled, no interrupt will be detected CY_LPCOMP_INTR_RISING (=1) - Rising edge CY_LPCOMP_INTR_FALLING (=2) - Falling edge CY_LPCOMP_INTR_BOTH (=3) - Both rising and falling edges. |
__STATIC_INLINE uint32_t Cy_LPComp_GetInterruptStatus | ( | LPCOMP_Type const * | base | ) |
Returns the status of 2 different LPCOMP interrupt requests.
*base | The LPCOMP register structure pointer. |
__STATIC_INLINE void Cy_LPComp_ClearInterrupt | ( | LPCOMP_Type * | base, |
uint32_t | interrupt | ||
) |
Clears LPCOMP interrupts by setting each bit.
*base | The LPCOMP register structure pointer. |
interrupt | Bit 0: COMP0 Interrupt status Bit 1: COMP1 Interrupt status |
__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. It sets the INTR_SET interrupt mask.
*base | The LPCOMP register structure pointer. |
interrupt | Bit 0: COMP0 Interrupt status Bit 1: COMP1 Interrupt status |
__STATIC_INLINE uint32_t Cy_LPComp_GetInterruptMask | ( | LPCOMP_Type const * | base | ) |
Returns an interrupt mask.
*base | The LPCOMP register structure pointer. |
__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.
*base | The LPCOMP register structure pointer. |
interrupt | uint32_t interruptMask: Bit Mask of interrupts to set. Bit 0: COMP0 Interrupt Mask Bit 1: COMP1 Interrupt Mask |
__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.
*base | The LPCOMP register structure pointer. |
__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.
*base | The LPCOMP register structure pointer. |
channel | The LPCOMP channel index. |