CAT2 Peripheral Driver Library
SARMUX Switch Control Functions

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

Functions

void Cy_SAR_SetAnalogSwitch (SAR_Type *base, uint32_t switchMask, bool state)
 Provide firmware control of the SARMUX switches for firmware sequencing. More...
 
uint32_t Cy_SAR_GetAnalogSwitch (const SAR_Type *base)
 Return the state (open or close) of SARMUX switches. More...
 
__STATIC_INLINE void Cy_SAR_SetVssaVminusSwitch (SAR_Type *base, bool 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, bool ctrl)
 Enable or disable SARSEQ control of one or more switches. More...
 
__STATIC_INLINE void Cy_SAR_SetVssaSarSeqCtrl (SAR_Type *base, bool ctrl)
 Enable or disable SARSEQ control of the switch between VSSA and Vminus of the SARADC. More...
 
void Cy_SAR_SetDiagSwitch (const SAR_Type *base, uint32_t mask, bool setSwitch)
 Firmware control for EXPMUX and DIAGMUX switches to connect analog signals to the SAR. More...
 
uint32_t Cy_SAR_GetDiagSwitch (const SAR_Type *base)
 Get control state for EXPMUX and DIAGMUX switches. More...
 
void Cy_SAR_SetDiagHwCtrl (volatile SAR_Type *base, uint32_t mask)
 Set MUX_SWITCH_HW_CTRL2 register value. More...
 
uint32_t Cy_SAR_GetDiagHwCtrl (const SAR_Type *base)
 Get MUX_SWITCH_HW_CTRL2 register value. More...
 

Detailed Description

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

Function Documentation

◆ Cy_SAR_SetAnalogSwitch()

void Cy_SAR_SetAnalogSwitch ( SAR_Type base,
uint32_t  switchMask,
bool  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
switchMaskThe mask of the switches to either open or close. Select one or more values from the SARMUX Switch Control Register Masks and "OR" them together.
stateOpen or close the desired switches:
  • true - open switch
  • false - close switch.
Note
This is an advanced function used for the low-level hardware control of the switches. This function is not required for a typical SAR sequencer-based application.
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. */
Cy_SAR_SetAnalogSwitch(SAR0, chan0SwitchMask, false);
/* Close the switches for channel 1. */
Cy_SAR_SetAnalogSwitch(SAR0, chan1SwitchMask, false);

◆ Cy_SAR_GetAnalogSwitch()

uint32_t Cy_SAR_GetAnalogSwitch ( const SAR_Type base)

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

Parameters
basePointer to structure describing registers
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 SARMUX Switch Control Register Masks.
Note
This is an advanced function used for the low-level hardware control of the switches. This function is not required for a typical SAR sequencer-based application.

◆ Cy_SAR_SetVssaVminusSwitch()

__STATIC_INLINE void Cy_SAR_SetVssaVminusSwitch ( SAR_Type base,
bool  state 
)

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

This function calls Cy_SAR_SetAnalogSwitch with switchMask set to SAR_MUX_SWITCH0_MUX_FW_VSSA_VMINUS_Msk.

Parameters
basePointer to structure describing registers
statetrue - open or false - close the switch.
Note
This is an advanced function used for the low-level hardware control of the switches. This function is not required for a typical SAR sequencer-based application.
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,
bool  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.
ctrltrue - enable, false - disable SARSEQ control.
Note
This is an advanced function used for the low-level hardware control of the switches. This function is not required for a typical SAR sequencer-based application.
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_HW_CTRL_P0 \
Cy_SAR_SetSwitchSarSeqCtrl(SAR0, switchMask, true);

◆ Cy_SAR_SetVssaSarSeqCtrl()

__STATIC_INLINE void Cy_SAR_SetVssaSarSeqCtrl ( SAR_Type base,
bool  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
ctrltrue - enable or false - disable control.
Note
This is an advanced function used for the low-level hardware control of the switches. This function is not required for a typical SAR sequencer-based application.
Function Usage
/* Scenario: Easily enable SARSEQ control of the switch between Vminus of the SARADC and VSSA. */

◆ Cy_SAR_SetDiagSwitch()

void Cy_SAR_SetDiagSwitch ( const SAR_Type base,
uint32_t  mask,
bool  setSwitch 
)

Firmware control for EXPMUX and DIAGMUX switches to connect analog signals to the SAR.

Parameters
basePointer to structure describing registers
maskMUX_SWITCH2 mask value The mask to open or close switches. Select one or more values from the EXPMUX/DIAGMUX Switch Control Register Masks and "OR" them together.
setSwitchMode (false: Clear mask pattern, true:Set mask pattern)
Returns
None
Note
Applicable to PSOC4 HVMS/PA only.

◆ Cy_SAR_GetDiagSwitch()

uint32_t Cy_SAR_GetDiagSwitch ( const SAR_Type base)

Get control state for EXPMUX and DIAGMUX switches.

Parameters
basePointer to structure describing registers
Returns
Mask which represent DiagSwitches return 0 if no valid switch2 present
Note
Applicable to PSOC4 HVMS/PA only.

◆ Cy_SAR_SetDiagHwCtrl()

void Cy_SAR_SetDiagHwCtrl ( volatile SAR_Type base,
uint32_t  mask 
)

Set MUX_SWITCH_HW_CTRL2 register value.

Parameters
basePointer to structure describing registers
maskThe mask of the MUX_SWITCH_HW_CTRL2 switches to allow SARSEQ control. Select one or more values from the EXPMUX/DIAGMUX Switch Control Register Masks and "OR" them together.
Returns
None
Note
Applicable to PSOC4 HVMS/PA only.

◆ Cy_SAR_GetDiagHwCtrl()

uint32_t Cy_SAR_GetDiagHwCtrl ( const SAR_Type base)

Get MUX_SWITCH_HW_CTRL2 register value.

Parameters
basePointer to structure describing registers
Returns
The mask which represents MUX_SWITCH_HW_CTRL2 Switches.
Note
Applicable to PSOC4 HVMS/PA only.