MTB CAT1 Peripheral driver library

General Description

This set of functions is for DC measurement mode.

Functions

void Cy_ADCMic_SelectDcChannel (MXS40ADCMIC_Type *base, cy_en_adcmic_dc_channel_t channel)
 Sets the specified DC measurement channel. More...
 
cy_en_adcmic_status_t Cy_ADCMic_IsEndConversion (MXS40ADCMIC_Type *base, cy_en_adcmic_return_mode_t retMode)
 Immediately return the status of the conversion or does not return (blocking) until the conversion completes, depending on the retMode parameter. More...
 
__STATIC_INLINE int16_t Cy_ADCMic_GetDcResult (MXS40ADCMIC_Type *base)
 Returns the DC conversion result from the CIC status register. More...
 
void Cy_ADCMic_SetDcOffset (int16_t offset, cy_stc_adcmic_context_t *context)
 Sets the offset value for DC measurement calibration. More...
 
void Cy_ADCMic_SetDcGain (int16_t gain, cy_stc_adcmic_context_t *context)
 Sets the gain value for DC measurement calibration. More...
 
int16_t Cy_ADCMic_CountsTo_mVolts (int16_t adcCounts, cy_stc_adcmic_context_t const *context)
 Convert the ADC output to millivolts as an int16. More...
 
int32_t Cy_ADCMic_CountsTo_uVolts (int16_t adcCounts, cy_stc_adcmic_context_t const *context)
 Convert the ADC output to microvolts as an int32. More...
 
float Cy_ADCMic_CountsTo_Volts (int16_t adcCounts, cy_stc_adcmic_context_t const *context)
 Convert the ADC output to volts as a float. More...
 

Function Documentation

◆ Cy_ADCMic_SelectDcChannel()

void Cy_ADCMic_SelectDcChannel ( MXS40ADCMIC_Type base,
cy_en_adcmic_dc_channel_t  channel 
)

Sets the specified DC measurement channel.

Parameters
baseThe pointer to the hardware ADCMic block.
channelThe DC measurement channel cy_en_adcmic_dc_channel_t.
Note
This function is useful for DC measurement only.
Function Usage
/* Scenario: Initialize ADCMic for the DC measurement: */
uint16_t data = 0U;
if (CY_ADCMIC_SUCCESS != Cy_ADCMic_Init(MXS40ADCMIC0, &config, CY_ADCMIC_DC))
{
/* Something went wrong, insert error handling here */
}
Cy_ADCMic_SelectDcChannel(MXS40ADCMIC0, CY_ADCMIC_GPIO0); /* Switch to the GPIO_0 */
Cy_ADCMic_Enable(MXS40ADCMIC0); /* Enable the block operation */
Cy_ADCMic_IsEndConversion(MXS40ADCMIC0, CY_ADCMIC_WAIT_FOR_RESULT); /* Wait the conversion is done */
Cy_ADCMic_Disable(MXS40ADCMIC0); /* Stop the operation */
data = Cy_ADCMic_GetDcResult(MXS40ADCMIC0); /* Get the result */

◆ Cy_ADCMic_IsEndConversion()

cy_en_adcmic_status_t Cy_ADCMic_IsEndConversion ( MXS40ADCMIC_Type base,
cy_en_adcmic_return_mode_t  retMode 
)

Immediately return the status of the conversion or does not return (blocking) until the conversion completes, depending on the retMode parameter.

In blocking mode, there is a time out of about 10 seconds for a CPU speed of 100 MHz.

Parameters
basePointer to structure describing registers
retModeA value of the enum cy_en_adcmic_return_mode_t
Returns
Side Effects
This function reads the end of conversion status interrupt bit and clears it after.
Note
CY_ADCMIC_WAIT_FOR_RESULT return modes are not recommended for use in RTOS environment.
Function Usage
/* Scenario: Initialize ADCMic for the DC measurement: */
uint16_t data = 0U;
if (CY_ADCMIC_SUCCESS != Cy_ADCMic_Init(MXS40ADCMIC0, &config, CY_ADCMIC_DC))
{
/* Something went wrong, insert error handling here */
}
Cy_ADCMic_SelectDcChannel(MXS40ADCMIC0, CY_ADCMIC_GPIO0); /* Switch to the GPIO_0 */
Cy_ADCMic_Enable(MXS40ADCMIC0); /* Enable the block operation */
Cy_ADCMic_IsEndConversion(MXS40ADCMIC0, CY_ADCMIC_WAIT_FOR_RESULT); /* Wait the conversion is done */
Cy_ADCMic_Disable(MXS40ADCMIC0); /* Stop the operation */
data = Cy_ADCMic_GetDcResult(MXS40ADCMIC0); /* Get the result */

◆ Cy_ADCMic_GetDcResult()

__STATIC_INLINE int16_t Cy_ADCMic_GetDcResult ( MXS40ADCMIC_Type base)

Returns the DC conversion result from the CIC status register.

Parameters
baseThe pointer to the hardware ADCMic block.
Returns
The signed DC conversion result.
Function Usage
/* Scenario: Initialize ADCMic for the DC measurement: */
uint16_t data = 0U;
if (CY_ADCMIC_SUCCESS != Cy_ADCMic_Init(MXS40ADCMIC0, &config, CY_ADCMIC_DC))
{
/* Something went wrong, insert error handling here */
}
Cy_ADCMic_SelectDcChannel(MXS40ADCMIC0, CY_ADCMIC_GPIO0); /* Switch to the GPIO_0 */
Cy_ADCMic_Enable(MXS40ADCMIC0); /* Enable the block operation */
Cy_ADCMic_IsEndConversion(MXS40ADCMIC0, CY_ADCMIC_WAIT_FOR_RESULT); /* Wait the conversion is done */
Cy_ADCMic_Disable(MXS40ADCMIC0); /* Stop the operation */
data = Cy_ADCMic_GetDcResult(MXS40ADCMIC0); /* Get the result */

◆ Cy_ADCMic_SetDcOffset()

void Cy_ADCMic_SetDcOffset ( int16_t  offset,
cy_stc_adcmic_context_t context 
)

Sets the offset value for DC measurement calibration.

Parameters
offsetThe offset value.
contextThe pointer to the context structure cy_stc_adcmic_context_t.

◆ Cy_ADCMic_SetDcGain()

void Cy_ADCMic_SetDcGain ( int16_t  gain,
cy_stc_adcmic_context_t context 
)

Sets the gain value for DC measurement calibration.

Parameters
gainThe gain value.
contextThe pointer to the context structure cy_stc_adcmic_context_t.

◆ Cy_ADCMic_CountsTo_mVolts()

int16_t Cy_ADCMic_CountsTo_mVolts ( int16_t  adcCounts,
cy_stc_adcmic_context_t const *  context 
)

Convert the ADC output to millivolts as an int16.

For example, if the ADC measured 0.534 volts, the return value would be 534. The calculation of voltage depends on the DC range. The equation used is:

mV = (RawCounts - Offset) * 1000 / Gain

where,

  • RawCounts: Raw counts returned by the Cy_ADCMic_GetDcResult.
  • Offset - the offset value, can be adjusted by the Cy_ADCMic_SetDcOffset, essentially it is a raw count value of the CY_ADCMIC_REFGND voltage measurement.
  • 1000 - amount of millivolts in 1 volt
  • Gain: the gain value, can be adjusted by the Cy_ADCMic_SetDcGain, depends on DC range, essentially it is an amount of raw counts per 1 volt of input voltage.
Note
This function is for DC measurement only.
Parameters
adcCountsConversion result from Cy_ADCMic_GetDcResult
contextThe pointer to the context structure cy_stc_adcmic_context_t.
Returns
Result in millivolts.
Function Usage
result = GetResultAvg(CY_ADCMIC_GPIO7);
microvolts = Cy_ADCMic_CountsTo_uVolts(result, &context);
millivolts = Cy_ADCMic_CountsTo_mVolts(result, &context);
volts = Cy_ADCMic_CountsTo_Volts (result, &context);

◆ Cy_ADCMic_CountsTo_uVolts()

int32_t Cy_ADCMic_CountsTo_uVolts ( int16_t  adcCounts,
cy_stc_adcmic_context_t const *  context 
)

Convert the ADC output to microvolts as an int32.

For example, if the ADC measured 0.534 volts, the return value would be 534000. The calculation of voltage depends on the DC range. The equation used is:

uV = (RawCounts - Offset) * 1000000 / Gain

where,

  • RawCounts: Raw counts returned by the Cy_ADCMic_GetDcResult.
  • Offset - the offset value, can be adjusted by the Cy_ADCMic_SetDcOffset, essentially it is a raw count value of the CY_ADCMIC_REFGND voltage measurement.
  • 1000000 - amount of microvolts in 1 volt
  • Gain: the gain value, can be adjusted by the Cy_ADCMic_SetDcGain, depends on DC range, essentially it is an amount of raw counts per 1 volt of input voltage.
Note
This function is for DC measurement only.
Parameters
adcCountsConversion result from Cy_ADCMic_GetDcResult
contextThe pointer to the context structure cy_stc_adcmic_context_t.
Returns
Result in microvolts.
Function Usage
result = GetResultAvg(CY_ADCMIC_GPIO7);
microvolts = Cy_ADCMic_CountsTo_uVolts(result, &context);
millivolts = Cy_ADCMic_CountsTo_mVolts(result, &context);
volts = Cy_ADCMic_CountsTo_Volts (result, &context);

◆ Cy_ADCMic_CountsTo_Volts()

float Cy_ADCMic_CountsTo_Volts ( int16_t  adcCounts,
cy_stc_adcmic_context_t const *  context 
)

Convert the ADC output to volts as a float.

For example, if the ADC measured 0.534 volts, the return value would be 0.534. The calculation of voltage depends on the DC range. The equation used is:

V = (RawCounts - Offset) / Gain

where,

Note
This function is for DC measurement only.
Parameters
adcCountsConversion result from Cy_ADCMic_GetDcResult
contextThe pointer to the context structure cy_stc_adcmic_context_t.
Returns
Result in volts.
Function Usage
result = GetResultAvg(CY_ADCMIC_GPIO7);
microvolts = Cy_ADCMic_CountsTo_uVolts(result, &context);
millivolts = Cy_ADCMic_CountsTo_mVolts(result, &context);
volts = Cy_ADCMic_CountsTo_Volts (result, &context);