MTB CAT1 Peripheral driver library
SARMUX Switch Control Functions

General Description

This set of functions is for controlling/querying the SARMUX switches.

Functions

void Cy_SAR_SetAnalogSwitch (SAR_Type *base, cy_en_sar_switch_register_sel_t switchSelect, uint32_t switchMask, cy_en_sar_switch_state_t state)
 Provide firmware control of the SARMUX switches for firmware sequencing. More...
 
uint32_t Cy_SAR_GetAnalogSwitch (const SAR_Type *base, cy_en_sar_switch_register_sel_t switchSelect)
 Return the state (open or close) of SARMUX switches. More...
 
__STATIC_INLINE void Cy_SAR_SetVssaVminusSwitch (SAR_Type *base, cy_en_sar_switch_state_t state)
 Open or close the switch between VSSA and Vminus of the SARADC through firmware. More...
 
void Cy_SAR_SetSwitchSarSeqCtrl (SAR_Type *base, uint32_t switchMask, cy_en_sar_switch_sar_seq_ctrl_t ctrl)
 Enable or disable SARSEQ control of one or more switches. More...
 
__STATIC_INLINE void Cy_SAR_SetVssaSarSeqCtrl (SAR_Type *base, cy_en_sar_switch_sar_seq_ctrl_t ctrl)
 Enable or disable SARSEQ control of the switch between VSSA and Vminus of the SARADC. More...
 

Function Documentation

◆ Cy_SAR_SetAnalogSwitch()

void Cy_SAR_SetAnalogSwitch ( SAR_Type base,
cy_en_sar_switch_register_sel_t  switchSelect,
uint32_t  switchMask,
cy_en_sar_switch_state_t  state 
)

Provide firmware control of the SARMUX switches for firmware sequencing.

Each call to this function can open or close a set of switches. Previously configured switches are untouched.

If the SARSEQ is enabled, there is no need to use this function.

Parameters
basePointer to structure describing registers
switchSelectThe switch register that contains the desired switches. Select a value from cy_en_sar_switch_register_sel_t.
switchMaskThe mask of the switches to either open or close. Select one or more values from the cy_en_sar_mux_switch_fw_ctrl_t enum and "OR" them together.
stateOpen or close the desired switches. Select a value from cy_en_sar_switch_state_t.
Returns
None
Function Usage
/* Scenario:
* - Channel 0 is configured as a differential pair between P10.0 and P10.1.
* - Channel 1 is configured to sample the internal DieTemp sensor.
* Close required switches to make these connections.
* Make sure to also enable the SAR sequencer control of these same switches. */
uint32_t chan0SwitchMask = CY_SAR_MUX_FW_P0_VPLUS | CY_SAR_MUX_FW_P1_VMINUS;
/* Close the switches for channel 0. */
/* Close the switches for channel 1. */

◆ Cy_SAR_GetAnalogSwitch()

uint32_t Cy_SAR_GetAnalogSwitch ( const SAR_Type base,
cy_en_sar_switch_register_sel_t  switchSelect 
)

Return the state (open or close) of SARMUX switches.

Parameters
basePointer to structure describing registers
switchSelectThe switch register that contains the desired switches. Select a value from cy_en_sar_switch_register_sel_t.
Returns
Each bit corresponds to a single switch, where a bit value of 0 is open and 1 is closed. Compare this value to the switch masks in cy_en_sar_mux_switch_fw_ctrl_t.

◆ Cy_SAR_SetVssaVminusSwitch()

__STATIC_INLINE void Cy_SAR_SetVssaVminusSwitch ( SAR_Type base,
cy_en_sar_switch_state_t  state 
)

Open or close the switch between VSSA and Vminus of the SARADC through firmware.

This function calls Cy_SAR_SetAnalogSwitch with switchSelect set to CY_SAR_MUX_SWITCH0 and switchMask set to SAR_MUX_SWITCH0_MUX_FW_VSSA_VMINUS_Msk.

Parameters
basePointer to structure describing registers
stateOpen or close the switch. Select a value from cy_en_sar_switch_state_t.
Returns
None
Function Usage
/* Scenario: Easily close the switch between Vminus of the SARADC and VSSA. */

◆ Cy_SAR_SetSwitchSarSeqCtrl()

void Cy_SAR_SetSwitchSarSeqCtrl ( SAR_Type base,
uint32_t  switchMask,
cy_en_sar_switch_sar_seq_ctrl_t  ctrl 
)

Enable or disable SARSEQ control of one or more switches.

Previously configured switches are untouched.

Parameters
basePointer to structure describing registers
switchMaskThe mask of the switches. Select one or more values from the cy_en_sar_mux_switch_sq_ctrl_t enum and "OR" them together.
ctrlEnable or disable SARSEQ control. Select a value from cy_en_sar_switch_sar_seq_ctrl_t.
Returns
None
Function Usage
/* Scenario: The SAR sequencer needs control of all switches on the dedicated SARMUX port
* so that the channels can by sampled in a round robin fashion without CPU intervention. */
uint32_t switchMask = CY_SAR_MUX_SQ_CTRL_P0 \

◆ Cy_SAR_SetVssaSarSeqCtrl()

__STATIC_INLINE void Cy_SAR_SetVssaSarSeqCtrl ( SAR_Type base,
cy_en_sar_switch_sar_seq_ctrl_t  ctrl 
)

Enable or disable SARSEQ control of the switch between VSSA and Vminus of the SARADC.

This function calls Cy_SAR_SetSwitchSarSeqCtrl with switchMask set to SAR_MUX_SWITCH_SQ_CTRL_MUX_SQ_CTRL_VSSA_Msk.

Parameters
basePointer to structure describing registers
ctrlEnable or disable control. Select a value from cy_en_sar_switch_sar_seq_ctrl_t.
Returns
None
Function Usage
/* Scenario: Easily enable SARSEQ control of the switch between Vminus of the SARADC and VSSA. */