Andy I was reading about the ADC peripheral and I think I have DMA sorted out. Pretty much the same as with spi, we only need to write one function to enable and disable the DMA Enable bit. My guess is that leaflabs never got to do it, because that is not libmaple, but the equivalent spi ones were already in libmaple…
Anyway, I will give at shot after work, and see if I can write the modifications to your sketch. Given that the ADC is not too fast, I dont think there will be a big improvement by using DMA in a single channel, but with DMA we can use the interleaved mode with ADC2 and double the bandwidth, and from the datasheet I understand DMA is a requirement to be able to use the interleaved mode:
11.8 DMA request
Since converted regular channels value are stored in a unique data register, it is necessary
to use DMA for conversion of more than one regular channel. This avoids the loss of data
already stored in the ADC_DR register.
Only the end of conversion of a regular channel generates a DMA request, which allows the
transfer of its converted data from the ADC_DR register to the destination location selected
by the user.
Note: Only ADC1 and ADC3 have this DMA capability. ADC2-converted data can be transferred in
dual ADC mode using DMA thanks to master ADC1.
So I will need to add an ISR, change a couple of bits in CR2, and set the DMA controller, pretty similar to what we did with SPI.
Once that works, I will look at enabling the interleaved mode.