I'm struggling to try and make sense of the ADC driver, specifically for the MCF51EM256 microcontroller. I am trying to understand how to use more than two channels on a given ADC device. For example, if I open the "adc1" device and then open channels on that device the first two are opened successfully but anything after that fails.
Digging down through the call to fopen() I can see that in the function _adc_open() of module "adc.c" that the channels are always bundled in groups of 2 channels. Once both of those channels have been assigned, any attempt to open another channel will fail because there is no free channel available. Presumably the channels are bundled in pairs so that they can be triggered via the two outputs of the Programmable Delay Block (PDB).
However, I feel like I must be missing something here. For the MCF51EM256 microcontroller the ADC1 there should be 6 channels that can be used to read external voltages. Surely it should be possible to use more than just two of those at a time?
In general, this is what I am trying to do:
fpADC = fopen("adc1:", (const char *)&adcInit); // Open file pointer to ADC
// Open individual ADC channels
fpADCChTempr = fopen("adc1:temperature", (const char *)&adcChTemprInit);
fpADCChVoltage = fopen("adc1:voltage", (const char *)&adcChVoltageInit);
fpADCChCurrent = fopen("adc1:current", (const char *)&adcChCurrentInit);
fpADCChLux = fopen("adc1:lux", (const char *)&adcChLuxInit);
Any suggestions would be greatly appreciated.