Interrupt Functions

group group_ctb_functions_interrupts

This set of functions is related to the comparator interrupts.

Functions

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

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

    /* Scenario: Both opamps have been configured as comparators with interrupts enabled.
     * Retrieve the interrupt status to determine which interrupt was triggered. */
    uint32_t intrStatus;
    
    intrStatus = Cy_CTB_GetInterruptStatus(CTBM0, CY_CTB_OPAMP_BOTH);

    /* Clear both comparator interrupts so that subsequent interrupts can be handled. */
    Cy_CTB_ClearInterrupt(CTBM0, CY_CTB_OPAMP_BOTH);

    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. */
    }
Return

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: Edge was not detected

  • Non-zero: Configured edge type was detected

Function Usage

Parameters

__STATIC_INLINE void Cy_CTB_ClearInterrupt (CTBM_Type *base, cy_en_ctb_opamp_sel_t compNum)

Clear 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.

Return

None

Parameters

__STATIC_INLINE void Cy_CTB_SetInterrupt (CTBM_Type *base, cy_en_ctb_opamp_sel_t compNum)

Force the CTB interrupt to trigger using software.

Return

None

Parameters

__STATIC_INLINE void Cy_CTB_SetInterruptMask (CTBM_Type *base, cy_en_ctb_opamp_sel_t compNum)

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

    /* Scenario: Enable interrupt request for both comparators. */

    Cy_CTB_SetInterruptMask(CTBM0, CY_CTB_OPAMP_BOTH);
    
Return

None

Function Usage

Parameters

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

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

    /* 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);
    }
Return

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: Interrupt output not forwarded to interrupt controller

  • Non-zero: Interrupt output forwarded to interrupt controller

Function Usage

Parameters

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

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

This is the bitwise AND of Cy_CTB_GetInterruptStatus and Cy_CTB_GetInterruptMask.

Return

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) is detected and masked.

  • 0: Configured edge not detected or not masked

  • Non-zero: Configured edge type detected and masked

Parameters