MTB CAT1 Peripheral driver library

General Description

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. More...
 
__STATIC_INLINE void Cy_CTB_ClearInterrupt (CTBM_Type *base, cy_en_ctb_opamp_sel_t compNum)
 Clear the CTB comparator triggered interrupt. More...
 
__STATIC_INLINE void Cy_CTB_SetInterrupt (CTBM_Type *base, cy_en_ctb_opamp_sel_t compNum)
 Force the CTB interrupt to trigger using software. More...
 
__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. More...
 
__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. More...
 
__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. More...
 

Function Documentation

◆ Cy_CTB_GetInterruptStatus()

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

Parameters
basePointer 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: Edge was not detected
  • Non-zero: 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 
)

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.

Parameters
basePointer to structure describing registers
compNumCY_CTB_OPAMP_0, CY_CTB_OPAMP_1, or CY_CTB_OPAMP_BOTH
Returns
None

◆ Cy_CTB_SetInterrupt()

__STATIC_INLINE void Cy_CTB_SetInterrupt ( CTBM_Type base,
cy_en_ctb_opamp_sel_t  compNum 
)

Force the CTB interrupt to trigger using software.

Parameters
basePointer to structure describing registers
compNumCY_CTB_OPAMP_0, CY_CTB_OPAMP_1, or CY_CTB_OPAMP_BOTH
Returns
None

◆ Cy_CTB_SetInterruptMask()

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

Parameters
basePointer 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.
Returns
None
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 
)

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

Parameters
basePointer 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: Interrupt output not forwarded to interrupt controller
  • Non-zero: Interrupt output forwarded to 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 
)

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

This is the bitwise AND of Cy_CTB_GetInterruptStatus and Cy_CTB_GetInterruptMask.

Parameters
basePointer 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) is detected and masked.
  • 0: Configured edge not detected or not masked
  • Non-zero: Configured edge type detected and masked