CAT2 Peripheral Driver Library

Functions

void Cy_DSADC_LockProtReg (PACSS_MMIO_Type *base)
 Lock the protected registers. More...
 
void Cy_DSADC_UnlockProtReg (PACSS_MMIO_Type *base)
 Unlock the protected registers. More...
 
bool Cy_DSADC_GetLockStatus (const PACSS_MMIO_Type *base)
 Get the status of the protection register that is needed to be accessed to unlock Lock Protected Registers. More...
 
void Cy_DSADC_Init (const PACSS_Type *base, cy_stc_dsadc_config_t *config)
 Full Init of the sigma-delta AGC. More...
 
void Cy_DSADC_Deinit (const PACSS_Type *base)
 Full DeInit of the sigma-delta AGC. More...
 
void Cy_DSADC_Enable (const PACSS_Type *base, cy_stc_dsadc_config_t *config)
 Full Enable configured parts of the sigma-delta AGC. More...
 
void Cy_DSADC_Disable (const PACSS_Type *base)
 Full Disable all parts of the sigma-delta ADC. More...
 
void Cy_DSADC_EnableSequencer (PACSS_MMIO_Type *base)
 Enable the ADC Sequencer and AREF. More...
 
void Cy_DSADC_DisableSequencer (PACSS_MMIO_Type *base)
 Disable the ADC Sequencer. More...
 
bool Cy_DSADC_GetSequencerBusy (const PACSS_MMIO_Type *base, uint8_t channel)
 Get the sequencer status. More...
 
uint8_t Cy_DSADC_AgcGetGainLevel (const PACSS_MMIO_Type *base)
 Get current gain level. More...
 
uint16_t Cy_DSADC_AgcGetFastDecimatorResult (const PACSS_MMIO_Type *base)
 Get the AGC Fast Decimator Result. More...
 
float32_t Cy_DSADC_CountsTo_Volts (int32_t counts, float32_t vref, float32_t analogGain, cy_stc_dsadc_dchan_config_t *dchan_config)
 Converts the input from raw DSADC counts to Volts. More...
 
float32_t Cy_DSADC_CountsTo_mVolts (int32_t counts, float32_t vref, float32_t analogGain, cy_stc_dsadc_dchan_config_t *dchan_config)
 Converts the input from raw DSADC counts to millivolts. More...
 
float32_t Cy_DSADC_CountsTo_uVolts (int32_t counts, float32_t vref, float32_t analogGain, cy_stc_dsadc_dchan_config_t *dchan_config)
 Converts the input from raw DSADC counts to microvolts. More...
 
void Cy_DSADC_ConnectTemperature (PACSS_MMIO_Type *base, uint32_t selectMask)
 Connects the specified pin to the parts of the on-die temperature sensor. More...
 
void Cy_DSADC_DisconnectTemperature (PACSS_MMIO_Type *base, uint32_t selectMask)
 Disconnects the specified pin from the parts of the on-die temperature sensor. More...
 
void Cy_DSADC_EnableTemperature (PACSS_MMIO_Type *base)
 Enables the on-die temperature sensor. More...
 
void Cy_DSADC_DisableTemperature (PACSS_MMIO_Type *base)
 Enables the on-die temperature sensor. More...
 
void Cy_DSADC_InitTemperature (PACSS_MMIO_Type *base, cy_stc_dsadc_temperature_config_t *config)
 Initializes the on-die temperature sensor. More...
 
void Cy_DSADC_InitializeDieTempConfigs (cy_stc_dsadc_temperature_config_t *one, cy_stc_dsadc_temperature_config_t *unit, cy_en_dsadc_temperature_setup_t setup, cy_en_dsadc_temp_volt_meas_t target)
 Initialize the two configurations used for on-die temperature measurement with the value derived from the measurement conditions data stored in SFLASH. More...
 
uint32_t Cy_DSADC_CalcCurrentRatio (int32_t currentOne, int32_t currentUnit)
 Initialize the two configurations used for on-die temperature measurement with the value derived from the measurement conditions data stored in SFLASH. More...
 
int32_t Cy_DSADC_CalcDieTemp (int32_t vbeOne, int32_t vbeUnit, uint32_t currentRatio, cy_en_dsadc_temperature_setup_t setup)
 Calculate on-die temperature with delta VBE measurement and current ratio, normalize the Delta VBE measurement to the ratio of the current sources, converting the delta between two on-die temperature measurements to degree celsius. More...
 
void Cy_DSADC_StartConvert (PACSS_Type *base, cy_en_dsadc_convert_source_t source)
 Start convert selected source. More...
 
void Cy_DSADC_StopConvert (PACSS_DCHAN_Type *base)
 Stop convert selected source. More...
 
void Cy_DSADC_EnableLowPowerMode (PACSS_MMIO_Type *base)
 Enables the AREF lower power mode. More...
 
void Cy_DSADC_DisableLowPowerMode (PACSS_MMIO_Type *base)
 Disables the AREF lower power mode. More...
 

Detailed Description

Function Documentation

◆ Cy_DSADC_LockProtReg()

void Cy_DSADC_LockProtReg ( PACSS_MMIO_Type *  base)

Lock the protected registers.

Parameters
baseThe pointer to the MMIO instance of the PACSS.
Warning
There is no protection against locking registers from the threads or interrupts. Users should take care of critical sections if needed.
Note
Used to lock trim registers.
Function Usage
/* Scenario: Unlock the locked registers before the basic configuration of the DSADC IP block. */
if(true == Cy_DSADC_GetLockStatus(PACSS_MMIO))
{
/* Unlock protected registers. */
}
/* Make base configuration of DSADC IP block. */
/* Lock protected registers if necessary. */
Cy_DSADC_LockProtReg(PACSS_MMIO);

◆ Cy_DSADC_UnlockProtReg()

void Cy_DSADC_UnlockProtReg ( PACSS_MMIO_Type *  base)

Unlock the protected registers.

Parameters
baseThe pointer to the MMIO instance of the PACSS.
Note
Used to unlock trim registers.
Function Usage
/* Scenario: Unlock the locked registers before the basic configuration of the DSADC IP block. */
if(true == Cy_DSADC_GetLockStatus(PACSS_MMIO))
{
/* Unlock protected registers. */
}
/* Make base configuration of DSADC IP block. */
/* Lock protected registers if necessary. */
Cy_DSADC_LockProtReg(PACSS_MMIO);

◆ Cy_DSADC_GetLockStatus()

bool Cy_DSADC_GetLockStatus ( const PACSS_MMIO_Type *  base)

Get the status of the protection register that is needed to be accessed to unlock Lock Protected Registers.

Parameters
baseThe pointer to the MMIO instance of the PACSS.
Returns
Status of the protection register.
  • true : if locked.
  • false : if unlocked.
Note
Used to check if trim registers is locked or unlocked.
Function Usage
/* Scenario: Unlock the locked registers before the basic configuration of the DSADC IP block. */
if(true == Cy_DSADC_GetLockStatus(PACSS_MMIO))
{
/* Unlock protected registers. */
}
/* Make base configuration of DSADC IP block. */
/* Lock protected registers if necessary. */
Cy_DSADC_LockProtReg(PACSS_MMIO);

◆ Cy_DSADC_Init()

void Cy_DSADC_Init ( const PACSS_Type *  base,
cy_stc_dsadc_config_t config 
)

Full Init of the sigma-delta AGC.

Parameters
baseThe base address for the PACSS.
configConfiguration options for the PACSS. See cy_stc_dsadc_config_t.
Note
Init enable sequencer and internal HPBGR, wait for settle then enable all ACHANs, wait to stabilize analog part then enable all DCHANs and configure AGC if required.

◆ Cy_DSADC_Deinit()

void Cy_DSADC_Deinit ( const PACSS_Type *  base)

Full DeInit of the sigma-delta AGC.

Parameters
baseThe base address for the PACSS.
Note
DeInit in opposite order to the Init
See also
Cy_DSADC_Init

◆ Cy_DSADC_Enable()

void Cy_DSADC_Enable ( const PACSS_Type *  base,
cy_stc_dsadc_config_t config 
)

Full Enable configured parts of the sigma-delta AGC.

Parameters
baseThe base address for the PACSS.
configConfiguration options for the PACSS. See cy_stc_dsadc_config_t.
Note
Sequencer and internal reference will be enabled always.
Only those parts will be enabled for which pointers are not NULL in the config

◆ Cy_DSADC_Disable()

void Cy_DSADC_Disable ( const PACSS_Type *  base)

Full Disable all parts of the sigma-delta ADC.

Parameters
baseThe base address for the PACSS.

◆ Cy_DSADC_EnableSequencer()

void Cy_DSADC_EnableSequencer ( PACSS_MMIO_Type *  base)

Enable the ADC Sequencer and AREF.

Parameters
baseThe pointer to the MMIO instance of the PACSS.

◆ Cy_DSADC_DisableSequencer()

void Cy_DSADC_DisableSequencer ( PACSS_MMIO_Type *  base)

Disable the ADC Sequencer.

Parameters
baseThe pointer to the MMIO instance of the PACSS.

◆ Cy_DSADC_GetSequencerBusy()

bool Cy_DSADC_GetSequencerBusy ( const PACSS_MMIO_Type *  base,
uint8_t  channel 
)

Get the sequencer status.

Parameters
baseThe pointer to the MMIO instance of the PACSS.
channelAnalog channel index. Valid inputs are between 0 and 1.
Returns
Sequencer busy. True if sequencer busy, False - otherwise.

◆ Cy_DSADC_AgcGetGainLevel()

uint8_t Cy_DSADC_AgcGetGainLevel ( const PACSS_MMIO_Type *  base)

Get current gain level.

Parameters
baseThe pointer to the MMIO instance of the PACSS.
Returns
Current gain level.

◆ Cy_DSADC_AgcGetFastDecimatorResult()

uint16_t Cy_DSADC_AgcGetFastDecimatorResult ( const PACSS_MMIO_Type *  base)

Get the AGC Fast Decimator Result.

Parameters
baseThe pointer to the MMIO instance of the PACSS.
Returns
AGC Fast Decimator Result.

◆ Cy_DSADC_CountsTo_Volts()

float32_t Cy_DSADC_CountsTo_Volts ( int32_t  counts,
float32_t  vref,
float32_t  analogGain,
cy_stc_dsadc_dchan_config_t dchan_config 
)

Converts the input from raw DSADC counts to Volts.

Parameters
countsConversion result from Cy_DSADC_GetResult().
vrefReference voltage in Volts.
analogGainAnalog gain value for the Digital Channel.
dchan_configConfiguration options for the Digital Channel. See cy_stc_dsadc_dchan_config_t
Returns
Result in volts.
Function Usage
/* Scenario: DCADC conversion has completed and result is valid.
* Retrieve the result on DCHAN0 and convert it to volts.
*/
/* HPBGR reference voltage */
#define CY_DCADC_HBPGR_VOLTAGE (1.2F)
#define CY_DSADC_ANALOG_GAIN_DCHAN0 (1.0F)
/* Get the result of the conversion on DCHAN0. */
int32_t result = Cy_DSADC_GetResult(PACSS_DCHAN0);
/* Convert the result to volts. */
CY_DCADC_HBPGR_VOLTAGE,
CY_DSADC_ANALOG_GAIN_DCHAN0,
&dchan_config);

◆ Cy_DSADC_CountsTo_mVolts()

float32_t Cy_DSADC_CountsTo_mVolts ( int32_t  counts,
float32_t  vref,
float32_t  analogGain,
cy_stc_dsadc_dchan_config_t dchan_config 
)

Converts the input from raw DSADC counts to millivolts.

Parameters
countsConversion result from Cy_DSADC_GetResult().
vrefReference voltage in Volts.
analogGainAnalog gain value for the Digital Channel.
dchan_configConfiguration options for the Digital Channel. See cy_stc_dsadc_dchan_config_t
Returns
Result in millivolts.
Function Usage
/* Scenario: DCADC conversion has completed and result is valid.
* Retrieve the result on DCHAN0 and convert it to millivolts.
*/
/* HPBGR reference voltage */
#define CY_DCADC_HBPGR_VOLTAGE (1.2F)
#define CY_DSADC_ANALOG_GAIN_DCHAN0 (1.0F)
/* Get the result of the conversion on DCHAN0. */
int32_t result = Cy_DSADC_GetResult(PACSS_DCHAN0);
/* Convert the result to millivolts. */
float32_t millivolts = Cy_DSADC_CountsTo_mVolts(result,
CY_DCADC_HBPGR_VOLTAGE,
CY_DSADC_ANALOG_GAIN_DCHAN0,
&dchan_config);

◆ Cy_DSADC_CountsTo_uVolts()

float32_t Cy_DSADC_CountsTo_uVolts ( int32_t  counts,
float32_t  vref,
float32_t  analogGain,
cy_stc_dsadc_dchan_config_t dchan_config 
)

Converts the input from raw DSADC counts to microvolts.

Parameters
countsConversion result from Cy_DSADC_GetResult().
vrefReference voltage in Volts.
analogGainAnalog gain value for the Digital Channel.
dchan_configConfiguration options for the Digital Channel. See cy_stc_dsadc_dchan_config_t
Returns
Result in microvolts.
Function Usage
/* Scenario: DCADC conversion has completed and result is valid.
* Retrieve the result on DCHAN0 and convert it to microvolts.
*/
/* HPBGR reference voltage */
#define CY_DCADC_HBPGR_VOLTAGE (1.2F)
#define CY_DSADC_ANALOG_GAIN_DCHAN0 (1.0F)
/* Get the result of the conversion on DCHAN0. */
int32_t result = Cy_DSADC_GetResult(PACSS_DCHAN0);
/* Convert the result to microvolts. */
float32_t microvolts = Cy_DSADC_CountsTo_uVolts(result,
CY_DCADC_HBPGR_VOLTAGE,
CY_DSADC_ANALOG_GAIN_DCHAN0,
&dchan_config);

◆ Cy_DSADC_ConnectTemperature()

void Cy_DSADC_ConnectTemperature ( PACSS_MMIO_Type *  base,
uint32_t  selectMask 
)

Connects the specified pin to the parts of the on-die temperature sensor.

Parameters
baseThe pointer to the MMIO instance of the PACSS.
selectMaskConnect the specified signal to the temperature sensor. See On-die Temperature Masks

◆ Cy_DSADC_DisconnectTemperature()

void Cy_DSADC_DisconnectTemperature ( PACSS_MMIO_Type *  base,
uint32_t  selectMask 
)

Disconnects the specified pin from the parts of the on-die temperature sensor.

Parameters
baseThe pointer to the MMIO instance of the PACSS.
selectMaskDisconnect the specified signal from the temperature sensor. See On-die Temperature Masks

◆ Cy_DSADC_EnableTemperature()

void Cy_DSADC_EnableTemperature ( PACSS_MMIO_Type *  base)

Enables the on-die temperature sensor.

Parameters
baseThe pointer to the MMIO instance of the PACSS.

◆ Cy_DSADC_DisableTemperature()

void Cy_DSADC_DisableTemperature ( PACSS_MMIO_Type *  base)

Enables the on-die temperature sensor.

Parameters
baseThe pointer to the MMIO instance of the PACSS.

◆ Cy_DSADC_InitTemperature()

void Cy_DSADC_InitTemperature ( PACSS_MMIO_Type *  base,
cy_stc_dsadc_temperature_config_t config 
)

Initializes the on-die temperature sensor.

Parameters
baseThe pointer to the MMIO instance of the PACSS.
configConfiguration options for the temperature sensor. See cy_stc_dsadc_temperature_config_t.
Note
Before use, the structure should be initialized by using the Cy_DSADC_InitializeDieTempConfigs function.
Function Usage
/* Cy_DSADC_CalcCurrentRatio and Cy_DSADC_CalcDieTemp expects a delta between two 29-bit measurements.
* This example is configured for 21-bit results so they must be shifted before
* calculating the temperature.
*/
#define CY_DSADC_GET_DIE_TEMP_SHIFT (8)
/* Enable Temperature Sensor. */
/* Wait 1000Us to allow it to settle. */
/* Initialize the die temp configurations structures based on the data stored in SFLASH. */
/* Each time the die temp is reconfigured, allow it to settle. */
/* Get the ratio of the resistor measurements to normalize the results. */
Cy_DSADC_InitTemperature(PACSS_MMIO, &one_config);
/* Each time the die temp is reconfigured, allow it to settle. */
/* Get result when conversion is complete. */
int32_t dieTempOneCounts = Cy_DSADC_GetResult(PACSS_DCHAN0);
/* Configure for the unit measurement */
Cy_DSADC_InitTemperature(PACSS_MMIO, &unit_config);
/* Each time the die temp is reconfigured, allow it to settle. */
/* Get result when conversion is complete. */
int32_t dieTempUnitCounts = Cy_DSADC_GetResult(PACSS_DCHAN0);
/* Calculate the current ratio for the die temp measurement. */
uint32_t currentRatio = Cy_DSADC_CalcCurrentRatio(dieTempOneCounts << CY_DSADC_GET_DIE_TEMP_SHIFT, dieTempUnitCounts << CY_DSADC_GET_DIE_TEMP_SHIFT);

◆ Cy_DSADC_InitializeDieTempConfigs()

void Cy_DSADC_InitializeDieTempConfigs ( cy_stc_dsadc_temperature_config_t one,
cy_stc_dsadc_temperature_config_t unit,
cy_en_dsadc_temperature_setup_t  setup,
cy_en_dsadc_temp_volt_meas_t  target 
)

Initialize the two configurations used for on-die temperature measurement with the value derived from the measurement conditions data stored in SFLASH.

Parameters
oneOn-die temperature configuration for the 1x(9.6 uA) current measurement. See cy_stc_dsadc_temperature_config_t
unitOn-die temperature configuration for 9x(9.6 uA * 9 = 86.4 uA) current measurement. See cy_stc_dsadc_temperature_config_t
setupPrimary or alternate temperature measurement parameters selection. See cy_en_dsadc_temperature_setup_t
targetAcross resistor or transistor temperature measurement selection. See cy_en_dsadc_temp_volt_meas_t
Function Usage
/* Scenario: Initialization On-Die temperature configuration structures cy_stc_dsadc_temperature_config_t. */
/* Temperature sensor one configuration for the 1 measurement */
/* Temperature sensor unit configuration for the 1 measurement */
/* Initialize the die temp configurations structures based on the data stored in SFLASH */
/* Each time the die temp is reconfigured, allow it to settle. */
/* Configure for the one measurement. */
Cy_DSADC_InitTemperature(PACSS_MMIO, &one_config);
/* Each time the die temp is reconfigured, allow it to settle. */

◆ Cy_DSADC_CalcCurrentRatio()

uint32_t Cy_DSADC_CalcCurrentRatio ( int32_t  currentOne,
int32_t  currentUnit 
)

Initialize the two configurations used for on-die temperature measurement with the value derived from the measurement conditions data stored in SFLASH.

Parameters
currentOneThe result of 1x(one) measurement across resistor.
currentUnitThe result of 9x(unit) measurement across resistor.
Returns
The ratio of measurement results across resistor.
Function Usage
/* Cy_DSADC_CalcCurrentRatio and Cy_DSADC_CalcDieTemp expects a delta between two 29-bit measurements.
* This example is configured for 21-bit results so they must be shifted before
* calculating the temperature.
*/
#define CY_DSADC_GET_DIE_TEMP_SHIFT (8)
/* Enable Temperature Sensor. */
/* Wait 1000Us to allow it to settle. */
/* Initialize the die temp configurations structures based on the data stored in SFLASH. */
/* Each time the die temp is reconfigured, allow it to settle. */
/* Get the ratio of the resistor measurements to normalize the results. */
Cy_DSADC_InitTemperature(PACSS_MMIO, &one_config);
/* Each time the die temp is reconfigured, allow it to settle. */
/* Get result when conversion is complete. */
int32_t dieTempOneCounts = Cy_DSADC_GetResult(PACSS_DCHAN0);
/* Configure for the unit measurement */
Cy_DSADC_InitTemperature(PACSS_MMIO, &unit_config);
/* Each time the die temp is reconfigured, allow it to settle. */
/* Get result when conversion is complete. */
int32_t dieTempUnitCounts = Cy_DSADC_GetResult(PACSS_DCHAN0);
/* Calculate the current ratio for the die temp measurement. */
uint32_t currentRatio = Cy_DSADC_CalcCurrentRatio(dieTempOneCounts << CY_DSADC_GET_DIE_TEMP_SHIFT, dieTempUnitCounts << CY_DSADC_GET_DIE_TEMP_SHIFT);

◆ Cy_DSADC_CalcDieTemp()

int32_t Cy_DSADC_CalcDieTemp ( int32_t  vbeOne,
int32_t  vbeUnit,
uint32_t  currentRatio,
cy_en_dsadc_temperature_setup_t  setup 
)

Calculate on-die temperature with delta VBE measurement and current ratio, normalize the Delta VBE measurement to the ratio of the current sources, converting the delta between two on-die temperature measurements to degree celsius.

Parameters
vbeOneThe result of 1x(one) measurement across transistor.
vbeUnitThe result of 9x(unit) measurement across transistor.
currentRatioThe ratio of measurement results across resistor.
setupPrimary or alternate temperature measurement parameters selection. See cy_en_dsadc_temperature_setup_t
Returns
Calculated temperature in fixed point Q12.20 format.
Note
The ratio of current sources or transistors is usually 9/1 so normalization can be done with the equation: newDelta = delta*LN(9)/LN(ratio) Natural logarithm is processor intensive so we instead use the linear approximation: newDelta = delta+delta*(A*ratio+B), where: delta = ADC(UNIT)-ADC(1) (29 bit signed result) A = -0.0534 B = 0.4804 T = (a2 * x^2 * 2^(-34) + a1 * x * 2^(-9) + a0 * 2^14) where x = newDelta For the fixed point 12.20 format calculation(not performed): T = T/2^20
Function Usage
/* Update the die temp config for the transistor load mode */
/* Each time the die temp is reconfigured, allow it to settle. */
/* Configure for the first measurement. */
Cy_DSADC_InitTemperature(PACSS_MMIO, &one_config);
/* Each time the die temp is reconfigured, allow it to settle. */
/* Get result when conversion is complete. */
dieTempOneCounts = Cy_DSADC_GetResult(PACSS_DCHAN0);
/* Configure for the unit measurement. */
Cy_DSADC_InitTemperature(PACSS_MMIO, &unit_config);
/* Each time the die temp is reconfigured, allow it to settle. */
/* Get result when conversion is complete. */
dieTempUnitCounts = Cy_DSADC_GetResult(PACSS_DCHAN0);
/* Calculate the on-die temperature. */
int32_t dieTemperature = Cy_DSADC_CalcDieTemp(dieTempOneCounts << CY_DSADC_GET_DIE_TEMP_SHIFT,
dieTempUnitCounts << CY_DSADC_GET_DIE_TEMP_SHIFT,
currentRatio,
/* Convert the Q12.20 fixed point result to floating point. */
float32_t result = (float32_t)dieTemperature / (float32_t)(1U << CY_DSADC_TEMPERATURE_FRACTION_BITS);

◆ Cy_DSADC_StartConvert()

void Cy_DSADC_StartConvert ( PACSS_Type *  base,
cy_en_dsadc_convert_source_t  source 
)

Start convert selected source.

Parameters
baseThe base address for the PACSS.
sourceSelected source to start convert
See also
cy_en_dsadc_convert_source_t

◆ Cy_DSADC_StopConvert()

void Cy_DSADC_StopConvert ( PACSS_DCHAN_Type *  base)

Stop convert selected source.

Parameters
baseThe base address for the Digital Channel.
Note
One more measurements after call this function may occurs before full stop.

◆ Cy_DSADC_EnableLowPowerMode()

void Cy_DSADC_EnableLowPowerMode ( PACSS_MMIO_Type *  base)

Enables the AREF lower power mode.

Parameters
baseThe pointer to the MMIO instance of the PACSS.
Warning
In deepsleep mode, AREF lower power mode is automatically enabled, so it must be disabled after exiting deepsleep.

◆ Cy_DSADC_DisableLowPowerMode()

void Cy_DSADC_DisableLowPowerMode ( PACSS_MMIO_Type *  base)

Disables the AREF lower power mode.

Parameters
baseThe pointer to the MMIO instance of the PACSS.
Warning
In deepsleep mode, AREF lower power mode is automatically enabled, so it must be disabled after exiting deepsleep.