CAT2 Peripheral Driver Library
Comparator Functions

This set of functions is specific to Comparator mode. More...

Functions

void Cy_CTB_CompSetInterruptEdgeType (CTBM_Type *base, cy_en_ctb_opamp_sel_t compNum, cy_en_ctb_comp_edge_t edge)
 Configures the type of an edge that will trigger a comparator interrupt. More...
 
uint32_t Cy_CTB_CompGetStatus (const CTBM_Type *base, cy_en_ctb_opamp_sel_t compNum)
 Returns the comparator output status. More...
 

Detailed Description

This set of functions is specific to Comparator mode.

Function Documentation

◆ Cy_CTB_CompSetInterruptEdgeType()

void Cy_CTB_CompSetInterruptEdgeType ( CTBM_Type *  base,
cy_en_ctb_opamp_sel_t  compNum,
cy_en_ctb_comp_edge_t  edge 
)

Configures the type of an edge that will trigger a comparator interrupt.

Parameters
baseThe pointer to structure-describing registers.
compNumCY_CTB_OPAMP_0, CY_CTB_OPAMP_1, or CY_CTB_OPAMP_BOTH
edgeThe type of the edge that will trigger an interrupt. Select a value from cy_en_ctb_comp_edge_t.
Function Usage
/* Scenario: Configure both edges (rising and falling) to trigger an interrupt in Comparator 0. */

◆ Cy_CTB_CompGetStatus()

uint32_t Cy_CTB_CompGetStatus ( const CTBM_Type *  base,
cy_en_ctb_opamp_sel_t  compNum 
)

Returns the comparator output status.

When the positive input voltage is greater than the negative input voltage, the comparator status is high. Otherwise, the status is low.

Parameters
baseThe pointer to structure-describing registers.
compNumCY_CTB_OPAMP_0 or CY_CTB_OPAMP_1. CY_CTB_OPAMP_NONE and CY_CTB_OPAMP_BOTH are invalid options.
Returns
The comparator status. A value of 0 is returned if compNum is invalid.
  • 0: The status is low
  • 1: The status is high
Function Usage
/* Scenario: Get the comparator output status on Comparator 0 to determine
* the if the positive input voltage is greater than or less than the
* negative input voltage. */
uint32_t status;
if (1UL == status)
{
/* Positive input voltage is greater than the negative input voltage. */
}
else
{
/* Positive input voltage is less than the negative input voltage. */
}