CAT2 Peripheral Driver Library

This set of functions is related to the comparator interrupts. More...

Functions

__STATIC_INLINE uint32_t Cy_CTB_GetInterruptStatus (const CTBM_Type *base, cy_en_ctb_opamp_sel_t compNum)
 Returns the status of the interrupt when the configured comparator edge is detected. More...
 
__STATIC_INLINE void Cy_CTB_ClearInterrupt (CTBM_Type *base, cy_en_ctb_opamp_sel_t compNum)
 Clears the CTB comparator triggered interrupt. More...
 
__STATIC_INLINE void Cy_CTB_SetInterrupt (CTBM_Type *base, cy_en_ctb_opamp_sel_t compNum)
 Forces the CTB interrupt to trigger using software. More...
 
__STATIC_INLINE void Cy_CTB_SetInterruptMask (CTBM_Type *base, cy_en_ctb_opamp_sel_t compNum)
 Configures the CTB comparator edge interrupt to be forwarded to the CPU interrupt controller. More...
 
__STATIC_INLINE uint32_t Cy_CTB_GetInterruptMask (const CTBM_Type *base, cy_en_ctb_opamp_sel_t compNum)
 Returns whether the CTB comparator edge interrupt output is forwarded to the CPU interrupt controller as configured by Cy_CTB_SetInterruptMask. More...
 
__STATIC_INLINE uint32_t Cy_CTB_GetInterruptStatusMasked (const CTBM_Type *base, cy_en_ctb_opamp_sel_t compNum)
 Returns the CTB comparator edge output interrupt state after being masked. More...
 

Detailed Description

This set of functions is related to the comparator interrupts.

Function Documentation

◆ Cy_CTB_GetInterruptStatus()

__STATIC_INLINE uint32_t Cy_CTB_GetInterruptStatus ( const CTBM_Type *  base,
cy_en_ctb_opamp_sel_t  compNum 
)

Returns the status of the interrupt when the configured comparator edge is detected.

Parameters
baseThe pointer to structure-describing registers.
compNumCY_CTB_OPAMP_0, CY_CTB_OPAMP_1, or CY_CTB_OPAMP_BOTH
Returns
The interrupt status. If compNum is CY_CTB_OPAMP_BOTH, cast the returned status to cy_en_ctb_opamp_sel_t to determine which comparator edge (or both) was detected.
  • 0: The edge was not detected
  • Non-zero: The configured edge type was detected.
Function Usage
/* Scenario: Both opamps have been configured as comparators with interrupts enabled.
* Retrieve the interrupt status to determine which interrupt was triggered. */
uint32_t intrStatus;
/* Clear both comparator interrupts so that subsequent interrupts can be handled. */
if (CY_CTB_OPAMP_0 == (intrStatus & CY_CTB_OPAMP_0))
{
/* Do something when comparator 0 interrupt occurs. */
}
if (CY_CTB_OPAMP_1 == (intrStatus & CY_CTB_OPAMP_1))
{
/* Do something when comparator 1 interrupt occurs. */
}

◆ Cy_CTB_ClearInterrupt()

__STATIC_INLINE void Cy_CTB_ClearInterrupt ( CTBM_Type *  base,
cy_en_ctb_opamp_sel_t  compNum 
)

Clears the CTB comparator triggered interrupt.

The interrupt must be cleared with this function so that the hardware can set subsequent interrupts and those interrupts can be forwarded to the interrupt controller, if enabled.

Parameters
baseThe pointer to structure-describing registers.
compNumCY_CTB_OPAMP_0, CY_CTB_OPAMP_1, or CY_CTB_OPAMP_BOTH

◆ Cy_CTB_SetInterrupt()

__STATIC_INLINE void Cy_CTB_SetInterrupt ( CTBM_Type *  base,
cy_en_ctb_opamp_sel_t  compNum 
)

Forces the CTB interrupt to trigger using software.

Parameters
baseThe pointer to structure-describing registers.
compNumCY_CTB_OPAMP_0, CY_CTB_OPAMP_1, or CY_CTB_OPAMP_BOTH

◆ Cy_CTB_SetInterruptMask()

__STATIC_INLINE void Cy_CTB_SetInterruptMask ( CTBM_Type *  base,
cy_en_ctb_opamp_sel_t  compNum 
)

Configures the CTB comparator edge interrupt to be forwarded to the CPU interrupt controller.

Parameters
baseThe pointer to structure-describing registers.
compNumCY_CTB_OPAMP_NONE, CY_CTB_OPAMP_0, CY_CTB_OPAMP_1, or CY_CTB_OPAMP_BOTH. Calling this function with CY_CTB_OPAMP_NONE will disable all interrupt requests.
Function Usage
/* Scenario: Enable interrupt request for both comparators. */

◆ Cy_CTB_GetInterruptMask()

__STATIC_INLINE uint32_t Cy_CTB_GetInterruptMask ( const CTBM_Type *  base,
cy_en_ctb_opamp_sel_t  compNum 
)

Returns whether the CTB comparator edge interrupt output is forwarded to the CPU interrupt controller as configured by Cy_CTB_SetInterruptMask.

Parameters
baseThe pointer to structure-describing registers.
compNumCY_CTB_OPAMP_0, CY_CTB_OPAMP_1, or CY_CTB_OPAMP_BOTH
Returns
The interrupt mask. If compNum is CY_CTB_OPAMP_BOTH, cast the returned mask to cy_en_ctb_opamp_sel_t to determine which comparator interrupt output (or both) is forwarded.
  • 0: None interrupt output was forwarded to the interrupt controller.
  • Non-zero: An interrupt output was forwarded to the interrupt controller.
Function Usage
/* Scenario: Check if comparator 0 interrupts are enabled. If not, enable it. */
uint32_t intrMask;
intrMask = Cy_CTB_GetInterruptMask(CTBM0, CY_CTB_OPAMP_0);
if (0UL == intrMask)
{
Cy_CTB_SetInterruptMask(CTBM0, CY_CTB_OPAMP_0);
}

◆ Cy_CTB_GetInterruptStatusMasked()

__STATIC_INLINE uint32_t Cy_CTB_GetInterruptStatusMasked ( const CTBM_Type *  base,
cy_en_ctb_opamp_sel_t  compNum 
)

Returns the CTB comparator edge output interrupt state after being masked.

This is the bitwise AND of Cy_CTB_GetInterruptStatus and Cy_CTB_GetInterruptMask.

Parameters
baseThe pointer to structure-describing registers.
compNumCY_CTB_OPAMP_0, CY_CTB_OPAMP_1, or CY_CTB_OPAMP_BOTH
Returns
If compNum is CY_CTB_OPAMP_BOTH, cast the returned value to cy_en_ctb_opamp_sel_t to determine which comparator interrupt output (or both) was detected and masked.
  • 0: The configured edge was not detected or masked.
  • Non-zero: The configured edge type was detected and masked