pyrohaz - "... I would consider using the adc interrupts but that may interrupt my main interrupt (and my main interrupt takes priority)."
If they are ordinary mechanical pots, then you can likely be a bit 'sloppy' with reading their values, i.e. a millisecond or two either way isn't going to make much difference, is it? So running the ADC 'conversion completed' interrupt at a lower priority is likely okay. Though, you might also be able to break 'analogRead' into two parts, one to start the conversion, and the other to retrieve the result, and call it in your main loop. This would remove the need for an interrupt.
Hacking the code should be doable. The actual work is something like:
uint32 analogRead(uint8 pin) {
if (pin >= NR_ANALOG_PINS)
return 0;
return adc_read(PIN_MAP[pin].adc);
}
static inline int adc_read(int channel) {
/* Set channel */
ADC_SQR3 = channel;
/* Start the conversion */
CR2_SWSTART_BIT = 1;
/* Wait for it to finish */
while(SR_EOC_BIT == 0)
;
return ADC_DR;
}
So spilt this into two functions, one to start the conversion on a pin, and the other to wait for and retrieve the value (while(SR_EOC_BIT == 0)
), and you can let the ADC sample as long as it needs, and read the value when its convenient.
"Could DMA be used to sample the pots and store their 12bit value directly in an array/variable?"
Yes.
The simplest setup might be to start the conversion as normal, and let DMA store the converted value. I'm not sure how much processing time that would save, but I suspect that once DMA is configured correctly, it might be pretty efficient.
If the Maple-mini's own ADC pins were used, then sampling 8 signals would be relatively straightforward (though still some deep peripheral code hacking). Each ADC has 'scan modes' which can scan a set of pins, and store the values in memory using DMA. Without scan mode, DMA alone would store the value for the same pin into memory.
However, for your circuit, with an external multiplexer, doing an ADC conversion for all the 'multiplexer channels' using only DMA would be a bit more complex. The MCU will need to send set the 'multiplexer channel number' on some digital output (GPIO) pins too. So as wel as using ADC 'scan mode' and DMA, there would need to be a second DMA channel set up to push the 'multiplexer channel number' to the GPIO output pins. Doable, but it might be unpleasant to debug.