Imagine the following Adc setup: AdcGroupA contains three AdcChannels AdcCh1, AdcCh2, AdcCh3 as shown in the Adc configuration (arxml) below:
<ECUC-CONTAINER-VALUE>
<SHORT-NAME>AdcGroupA</SHORT-NAME>
<DEFINITION-REF DEST="ECUC-PARAM-CONF-CONTAINER-DEF">/Adc/AdcConfigSet/AdcHwUnit/AdcGroup</DEFINITION-REF>
<PARAMETER-VALUES>
...
</PARAMETER-VALUES>
<REFERENCE-VALUES>
<ECUC-REFERENCE-VALUE>
<DEFINITION-REF DEST="ECUC-REFERENCE-DEF">/Adc/AdcConfigSet/AdcHwUnit/AdcGroup/AdcGroupDefinition</DEFINITION-REF>
<VALUE-REF DEST="ECUC-CONTAINER-VALUE">/ActiveEcuC/Adc/AdcConfigSet/AdcHwUnit_ADC0/AdcCh1</VALUE-REF>
</ECUC-REFERENCE-VALUE>
<ECUC-REFERENCE-VALUE>
<DEFINITION-REF DEST="ECUC-REFERENCE-DEF">/Adc/AdcConfigSet/AdcHwUnit/AdcGroup/AdcGroupDefinition</DEFINITION-REF>
<VALUE-REF DEST="ECUC-CONTAINER-VALUE">/ActiveEcuC/Adc/AdcConfigSet/AdcHwUnit_ADC0/AdcCh3</VALUE-REF>
</ECUC-REFERENCE-VALUE>
<ECUC-REFERENCE-VALUE>
<DEFINITION-REF DEST="ECUC-REFERENCE-DEF">/Adc/AdcConfigSet/AdcHwUnit/AdcGroup/AdcGroupDefinition</DEFINITION-REF>
<VALUE-REF DEST="ECUC-CONTAINER-VALUE">/ActiveEcuC/Adc/AdcConfigSet/AdcHwUnit_ADC0/AdcCh2</VALUE-REF>
</ECUC-REFERENCE-VALUE>
</REFERENCE-VALUES>
<SUB-CONTAINERS>
</SUB-CONTAINERS>
</ECUC-CONTAINER-VALUE>
In a Complex Driver or IoHwAb the AdcGroup can then be used as follows:
Adc_ValueGroupType AdcGroupAReadDataBuffer[SIZE_OF_GROUPA];
Adc_StartGroupConversion( AdcGroupA );
…
Std_ReturnType Adc_ReadGroup( AdcGroupA, &AdcGroupAReadDataBuffer[0] );
…
valueAdcCh1 = AdcGroupAReadDataBuffer[IDX_GROUPA_CH1];
valueAdcCh2 = AdcGroupAReadDataBuffer[IDX_GROUPA_CH2];
valueAdcCh3 = AdcGroupAReadDataBuffer[IDX_GROUPA_CH3];
AUTOSAR Adc specification says for Adc_ReadGroup [SWS_Adc_00369] “The group channel values are stored in ascending channel number order.” But which “channel number” is meant here? If I have a look at the behavior of some Adc driver it is obviously not related to the AdcChannel.AdcChannelId. Therefore, I assume that the order is related to the list of references to AdcChannels in the AdcGroup. BUT: this list has no index or ID! See arxml snippet above. So, the order/sorting is not determined by anything. Or is it? Seems like in my toolchain the order is defined by the sequence how you add the AdcChannels to the AdcGroup:
#define IDX_GROUPA_CH1 (0u)
#define IDX_GROUPA_CH2 (2u)
#define IDX_GROUPA_CH3 (1u)
The resulting question is: How do I find out what index is used for an AdcChannel within an AdcGroup (data buffer)? Is there any generated define for this (which would replace the IDX_GROUPA_CH? In the example above)? And please don’t tell me: “have a look at the arxml file” or “As you have configured it”. Keep in mind that the developers of the C-code often have no access or license to the Configuration-Tool-Chain.
from the requirement number its seems that you are using AUTOSAR version 4.2 or higher, I am drafting my answer based on same, mostly it could be same across all 4.X variants. please note that I am explaining based on pure AUTOSAR requirement, some times it can vary for same Chip vendors,
First of all there was no relation with the channel ID and usually the macro with channel ID use to represent the configured channel. The way in which you get the conversion result also depend on configuration parameter AdcGroupAccessMode and AdcStreamingNumSamples . Please considered following example,
Example:-
The configuration example consists of three ADC groups.
Please considered the image given below.
User / application needs to Initialization Adc_SetupResultBuffer() for each ADC group before starting the conversion. And its the responsibility of User / application to proved the enough memory in the buffer to store all converted data. Its allocation is described in below image,
When you call Adc_ReadGroup() API, ADC driver will copy the latest results from the application result buffer to the application read group buffer, To make it more clear application result buffer is the buffer you setup using Adc_SetupResultBuffer(), and application read group buffer is the buffer you passed while calling Adc_ReadGroup() API. please see the diagram below to make the understanding clear.
You can also get the result without using additional buffer, so the same you can use the API Adc_GetStreamLastPointer, this API simply return latest application result buffer (It result buffer of first channel in a group, after completing one cycle if streaming is enabled), It seems to bit complicate first time, but once you understand how the results are stored in memory its very simple and optimised way of accessing the ADC converted result. Please see the diagram mentioned below for better understanding.
Holes this will make you more clear...
How ever these informations are also available in AUTOSAR SWS of 4.2.2 in section 7.1.3, Please go through same if its not clear.
BR, Jerry James