Also not shown above but I'm confident I managed to set IO_MUX_GPIO2_REG to x001802 inside my modified Espruino build readADC() before any IDF calls , using api calls in the EspIdf GPIO library. Including gpio_reset_pin()
and still experienced the same behaviour on multiple analogRead calls, dispute the register being set as above.
So not sure at all where to go, it does seem Espruino is putting the ADC peripheral in a bad state somehow.
Edit .. I did not try to modify the Espruino ESP32 pin setting code in jshardware.c, which as you say earlier does not currently have an analog option. And I further note that the esp32-c3 IDF ADC library for IDF v5 is very different to the current and current Espruino ADC handling will need a rewrite anyway. Also current GPIO calls in jshardware.c are using HAL level calls and not the IDF GPIO library API so it looks like quite a bit of change and testing to get to v5 in this area.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Also not shown above but I'm confident I managed to set IO_MUX_GPIO2_REG to x001802 inside my modified Espruino build readADC() before any IDF calls , using api calls in the EspIdf GPIO library. Including gpio_reset_pin()
and still experienced the same behaviour on multiple analogRead calls, dispute the register being set as above.
So not sure at all where to go, it does seem Espruino is putting the ADC peripheral in a bad state somehow.
Edit .. I did not try to modify the Espruino ESP32 pin setting code in jshardware.c, which as you say earlier does not currently have an analog option. And I further note that the esp32-c3 IDF ADC library for IDF v5 is very different to the current and current Espruino ADC handling will need a rewrite anyway. Also current GPIO calls in jshardware.c are using HAL level calls and not the IDF GPIO library API so it looks like quite a bit of change and testing to get to v5 in this area.