VADC comprises of independent analog channels with Analog/Digital converters to convert analog input to discrete digital output.
In the following sections it will be described, how to integrate the driver into the application framework.
Preparation
Include Files
Include following header file into your C code:
Variables
Module Initialisation
The module initialisation can be done in the same function:
Group Initialisation
The group initialisation can be done in the same function:
Queued Transfers
Now, VADC is initialised. Here,Three channels are used for queued transfers
for(int chnIx=0; chnIx<3; ++chnIx) {
Ifx_VADC_RES resultTrace[3*10];
for(int i=0; i<3*10; ++i)
{
unsigned chnIx = i % 3;
Ifx_VADC_RES conversionResult;
do {
} while( !conversionResult.B.VF );
resultTrace[i] = conversionResult;
}
}
Auto Scan
Autoscan of 5 channels
{
for(int chnIx=0; chnIx<5; ++chnIx) {
unsigned channels = (1 << adcChannelConfig[chnIx].
channelId);
unsigned mask = channels;
boolean continuous =
TRUE;
}
for(int chnIx=0; chnIx<5; ++chnIx) {
unsigned channel = adcChannel[chnIx].
channel;
Ifx_VADC_RES conversionResult;
do {
} while( !conversionResult.B.VF );
{
unsigned expected = ((adcMaxPlus1Value * (VADC_COMMANDS_CHN_PER_VOLTAGE_GROUP*group + channel) * vStep) / (vRef-vGnd));
result |= clib_trace(conversionResult.B.CHNR, channel);
result |= clib_trace_tolerant(conversionResult.B.RESULT, expected, 5);
}
}
}
Background Scan
Background Scan of 2 channels
for(int chnIx=0; chnIx<2; ++chnIx)
{
unsigned channels = (1 << adcChannelConfig[chnIx].
channelId);
unsigned mask = channels;
}
boolean continuous =
TRUE;
for(int chnIx=0; chnIx<2; ++chnIx)
{
unsigned channel = adcChannel[chnIx].
channel;
Ifx_VADC_RES conversionResult;
do
{
} while( !conversionResult.B.VF );
}