Infineon Logo AIROC BTSDK v4.9 - Documentation
 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups
adc.h File Reference

Defines functions to access ADC peripheral. More...

Functions

void adc_config (void)
 Initialize the ADC HW block.
 
void adc_adcCalibrate (UINT32 refVoltageInMicroVolts, ADC_INPUT_CHANNEL_SEL referenceInput)
 Calibrate the ADC against a known (external) voltage. More...
 
INT16 adc_readSampleRaw (ADC_INPUT_CHANNEL_SEL channel_idx)
 Read the analog to digital value on a given channel. More...
 
UINT32 adc_readVoltage (ADC_INPUT_CHANNEL_SEL idx)
 Read the analog to digital value converted to volts on a given channel. More...
 
ADC_POWER_TYPE adc_setPower (ADC_POWER_TYPE pwr)
 Powers on/off the ADC HW block. More...
 
void adc_SetInputRange (ADC_INPUT_RANGE_SEL range_idx)
 Selects the input range of the ADC input channel. More...
 
UINT8 adc_convertGPIOtoADCInput (UINT8 gpio)
 Convert GPIO to ADC input channel number. More...
 
UINT8 adc_convertADCInputtoGPIO (UINT8 adcInput)
 Convert ADC input channel number to GPIO. More...
 
static INLINE void adc_setAdcSampleFrequency (ADC_SAMPLE_FREQUENCY sample_frequency)
 Set the sampling frequency to use. More...
 

Detailed Description

Defines functions to access ADC peripheral.

The ADC provides one-shot conversion of and input analog signal to a digital value (raw or converted to Volts). The maximum sampling rate is 187 KHz with 10 ENOB and the minimum conversion rate is 5.859 KHz.

Function Documentation

void adc_adcCalibrate ( UINT32  refVoltageInMicroVolts,
ADC_INPUT_CHANNEL_SEL  referenceInput 
)

Calibrate the ADC against a known (external) voltage.

Parameters
refVoltageInMicroVoltsThe voltage of the reference in uV.
referenceInputThe ADC channel to which the reference is connected to.
UINT8 adc_convertADCInputtoGPIO ( UINT8  adcInput)

Convert ADC input channel number to GPIO.

Parameters
adcInputThe ADC input channel number.
Returns
The GPIO logical pin number from gpiodriver.h.
UINT8 adc_convertGPIOtoADCInput ( UINT8  gpio)

Convert GPIO to ADC input channel number.

Parameters
gpioThe GPIO logical pin number from gpiodriver.h.
Returns
The ADC channel number.
INT16 adc_readSampleRaw ( ADC_INPUT_CHANNEL_SEL  channel_idx)

Read the analog to digital value on a given channel.

If the ADC is power off, this function will power it on, read and then power it off.

Parameters
channel_idxThe input channel to read from.
Returns
Raw ADC output.
UINT32 adc_readVoltage ( ADC_INPUT_CHANNEL_SEL  idx)

Read the analog to digital value converted to volts on a given channel.

Uncalibrated readings are expected to be within +/-10% while calibrated values are expected to be better than +/-3%. Uses adc_readSampleRaw internally.

Parameters
idxThe input channel to read from.
Returns
The value read in volts, scaled according to the ENOB.
static INLINE void adc_setAdcSampleFrequency ( ADC_SAMPLE_FREQUENCY  sample_frequency)
static

Set the sampling frequency to use.

Default is 5.859 KHz.

Parameters
sample_frequencyThe sample frequency to use.
void adc_SetInputRange ( ADC_INPUT_RANGE_SEL  range_idx)

Selects the input range of the ADC input channel.

This applies to all channels. Choose a range that will cover all ADC input channels.

Parameters
range_idxThe input range of th signal being measured.
ADC_POWER_TYPE adc_setPower ( ADC_POWER_TYPE  pwr)

Powers on/off the ADC HW block.

When reading from a channel, it is not required to power on the ADC before the read.

Parameters
pwrOn or off.
Returns
The previous state.