CAT2 Peripheral Driver Library
Switch Control Functions

This set of functions is for controlling routing switches. More...

Functions

void Cy_CTB_SetAnalogSwitch (CTBM_Type *base, cy_en_ctb_opamp_sel_t opampNum, uint32_t switchMask, bool switchState)
 Provides firmware control of the CTB switches. More...
 
uint32_t Cy_CTB_GetAnalogSwitch (const CTBM_Type *base, cy_en_ctb_opamp_sel_t opampNum)
 Returns the open or closed state of the specified analog switch. More...
 
__STATIC_INLINE void Cy_CTB_OpenAllSwitches (CTBM_Type *base)
 Open all the switches and disable all hardware control of the switches. More...
 
__STATIC_INLINE void Cy_CTB_EnableSarSeqCtrl (CTBM_Type *base, uint32_t switchMask)
 Enables the SAR sequencer control of specified switch(es). More...
 
__STATIC_INLINE void Cy_CTB_DisableSarSeqCtrl (CTBM_Type *base, uint32_t switchMask)
 Disables the SAR sequencer control of specified switch(es). More...
 

Detailed Description

This set of functions is for controlling routing switches.

Function Documentation

◆ Cy_CTB_SetAnalogSwitch()

void Cy_CTB_SetAnalogSwitch ( CTBM_Type *  base,
cy_en_ctb_opamp_sel_t  opampNum,
uint32_t  switchMask,
bool  switchState 
)

Provides firmware control of the CTB switches.

Each call to this function can open a set of switches or close a set of switches in one register.

Parameters
baseThe pointer to structure-describing registers.
opampNumCY_CTB_OPAMP_0, CY_CTB_OPAMP_1, or CY_CTB_OPAMP_BOTH
switchMaskThe mask of the switches to either open or close. The switch masks can be found in the OpAmp Switch Macros. Use the enum that is consistent with the specified OpAmp.
Note
Some switch mask positions may match for both OpAmps, so it is allowed to carefully use this function for both OpAmps simultaneously.
Parameters
switchStateThe boolean switch state: true - closed, false - opened.
Function Usage
/* Scenario: OA0 has been configured as an opamp with 10x output drive using the
* pre-defined Cy_CTB_Fast_Opamp0_Opamp10x configuration. The 10x output has
* a dedicated connection to Pin 1.2.
*
* Call SetAnalogSwitch to route the non-inverting input of OA0 to Pin 1.6
* and the inverting input to Pin 1.1.
*
* Note that the CTB port may vary based on device.
*
* Select OA0 switch register.
* Select two switches for Pin 0 and Pin 1 of the CTB port.
* Set the state of the switches to closed
*/

◆ Cy_CTB_GetAnalogSwitch()

uint32_t Cy_CTB_GetAnalogSwitch ( const CTBM_Type *  base,
cy_en_ctb_opamp_sel_t  opampNum 
)

Returns the open or closed state of the specified analog switch.

Parameters
baseThe pointer to structure-describing registers.
opampNumCY_CTB_OPAMP_0 or CY_CTB_OPAMP_1. CY_CTB_OPAMP_NONE and CY_CTB_OPAMP_BOTH are invalid options.
Returns
The state of the switches in the provided OpAmp. Compare this value to the switch masks in the following masks: OpAmp Switch Macros
Function Usage
/* Scenario: Query if the positive terminal of Opamp0 is connected to P1.6 or not. */
uint32_t switchMask;
switchMask = Cy_CTB_GetAnalogSwitch(CTBM0, CY_CTB_OPAMP_0);
{
/* The positive terminal of OA0 is connected to P1.6. */
}

◆ Cy_CTB_OpenAllSwitches()

__STATIC_INLINE void Cy_CTB_OpenAllSwitches ( CTBM_Type *  base)

Open all the switches and disable all hardware control of the switches.

Primarily used as a quick method of re-configuring all analog connections that are sparsely closed.

Parameters
baseThe pointer to structure-describing registers.
Function Usage
/* Scenario: Reset all the switches to destroy all previous connections. */

◆ Cy_CTB_EnableSarSeqCtrl()

__STATIC_INLINE void Cy_CTB_EnableSarSeqCtrl ( CTBM_Type *  base,
uint32_t  switchMask 
)

Enables the SAR sequencer control of specified switch(es).

This allows the SAR ADC to use routes through the CTB when configuring its channels. See Input from CTB output via SARBUS0/1 for the more details.

There are three switches in the CTB that can be enabled by the SAR sequencer.

  • D51: This switch connects the output of Opamp0 to the SARBUS0
  • D52: This switch connects the output of Opamp1 to the SARBUS0
  • D62: This switch connects the output of Opamp1 to the SARBUS1
Parameters
basePointer to structure describing registers
switchMaskThe switch(es) in which to enable SAR sequencer control SAR Sequencer Controlled Switch Macros
Function Usage
/* Scenario: The SAR ADC has been configured to sample the opamp outputs.
* Enable SAR sequencer control of all three switches in the CTB. */

◆ Cy_CTB_DisableSarSeqCtrl()

__STATIC_INLINE void Cy_CTB_DisableSarSeqCtrl ( CTBM_Type *  base,
uint32_t  switchMask 
)

Disables the SAR sequencer control of specified switch(es).

Parameters
baseThe pointer to structure-describing registers.
switchMaskThe switch(es) in which to disable SAR sequencer control SAR Sequencer Controlled Switch Macros
Function Usage
/* Scenario: The SAR ADC no longer needs to sample the opamp outputs.
* Disable SAR sequencer control of all three switches in the CTB. */