MTB CAT1 Peripheral driver library
Switch Control Functions

General Description

This set of functions is for controlling routing switches.

Functions

void Cy_CTB_SetAnalogSwitch (CTBM_Type *base, cy_en_ctb_switch_register_sel_t switchSelect, uint32_t switchMask, cy_en_ctb_switch_state_t state)
 Provide firmware control of the CTB switches. More...
 
uint32_t Cy_CTB_GetAnalogSwitch (const CTBM_Type *base, cy_en_ctb_switch_register_sel_t switchSelect)
 Return 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 (SAR Sequencer and DSI) control of the switches. More...
 
__STATIC_INLINE void Cy_CTB_EnableSarSeqCtrl (CTBM_Type *base, cy_en_ctb_switch_sar_seq_t switchMask)
 Enable SAR sequencer control of specified switch(es). More...
 
__STATIC_INLINE void Cy_CTB_DisableSarSeqCtrl (CTBM_Type *base, cy_en_ctb_switch_sar_seq_t switchMask)
 Disable SAR sequencer control of specified switch(es). More...
 

Function Documentation

◆ Cy_CTB_SetAnalogSwitch()

void Cy_CTB_SetAnalogSwitch ( CTBM_Type base,
cy_en_ctb_switch_register_sel_t  switchSelect,
uint32_t  switchMask,
cy_en_ctb_switch_state_t  state 
)

Provide 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
basePointer to structure describing registers
switchSelectA value of the enum cy_en_ctb_switch_register_sel_t to select the switch register
switchMaskThe mask of the switches to either open or close. The switch masks can be found in the following enums: cy_en_ctb_oa0_switches_t, cy_en_ctb_oa1_switches_t, and cy_en_ctb_ctd_switches_t. Use the enum that is consistent with the provided register.
stateCY_CTB_SWITCH_OPEN or CY_CTB_SWITCH_CLOSE
Returns
None
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 9.2.
*
* Call SetAnalogSwitch to route the non-inverting input of OA0 to Pin 9.0
* and the inverting input to Pin 9.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_SetAnalogSwitch(CTBM0, switchSelect, switchMask, state);

◆ Cy_CTB_GetAnalogSwitch()

uint32_t Cy_CTB_GetAnalogSwitch ( const CTBM_Type base,
cy_en_ctb_switch_register_sel_t  switchSelect 
)

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

Parameters
basePointer to structure describing registers
switchSelectA value of the enum cy_en_ctb_switch_register_sel_t to select the switch register
Returns
The state of the switches in the provided register. Compare this value to the switch masks in the following enums: cy_en_ctb_oa0_switches_t, cy_en_ctb_oa1_switches_t, and cy_en_ctb_ctd_switches_t.
Function Usage
/* Scenario: Query if the positive terminal of Opamp0 is connected to P9.0 or not. */
uint32_t switchMask;
if ((uint32_t) CY_CTB_SW_OA0_POS_PIN0_MASK == (switchMask & ((uint32_t) CY_CTB_SW_OA0_POS_PIN0_MASK)))
{
/* The positive terminal of OA0 is connected to P9.0. */
}

◆ Cy_CTB_OpenAllSwitches()

__STATIC_INLINE void Cy_CTB_OpenAllSwitches ( CTBM_Type base)

Open all the switches and disable all hardware (SAR Sequencer and DSI) control of the switches.

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

Parameters
basePointer to structure describing registers
Returns
None
Function Usage
/* Scenario: Reset all the switches to destroy all previous connections. */

◆ Cy_CTB_EnableSarSeqCtrl()

__STATIC_INLINE void Cy_CTB_EnableSarSeqCtrl ( CTBM_Type base,
cy_en_ctb_switch_sar_seq_t  switchMask 
)

Enable SAR sequencer control of specified switch(es).

This allows the SAR ADC to use routes through the CTB when configuring its channels.

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

  • D51: This switch connects the negative input of Opamp0 to the SARBUS0
  • D52: This switch connects the positive input of Opamp1 to the SARBUS0
  • D62: This switch connects the positive input of Opamp1 to the SARBUS1
Parameters
basePointer to structure describing registers
switchMaskThe switch or switches in which to enable SAR sequencer control. Use an enumerated value from cy_en_ctb_switch_sar_seq_t.
Returns
None
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,
cy_en_ctb_switch_sar_seq_t  switchMask 
)

Disable SAR sequencer control of specified switch(es).

Parameters
basePointer to structure describing registers
switchMaskThe switch or switches in which to disable SAR sequencer control. Use an enumerated value from cy_en_ctb_switch_sar_seq_t.
Returns
None
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. */