Re-initializing ADC

I’ve just ported my capacitive touch library (called TouchLib) to the photon. The library reconfigures the ADC to use the internal sample and hold capacitor to measure capacitance on analog inputs and works pretty well for that purpose.

However, I cannot seem to combine my library with a normal analogRead() to read out a normal analog sensor, since my library has reconfigured the ADC for only 1 sample and no DMA.

I think it should be possible to also get analogRead() working again if my library calls HAL_ADC_DMA_Init() after taking the measurements, but this function is not exported in hal_dynalib_gpio.h.

Is there any other way without having to modify the hal and still get my library and analogRead() working together again?

Have you tried setting the pinMode() to anything other than AN_INPUT for the device to “force” re-init for analogRead()?
Alternatively you could try (undocumented) pinMode(pin, AN_INPUT)

I found the issue. Turns out my code to re-configure the ADC for normal analogRead() had a bug. It’s fixed now.