diff --git a/CHANGELOG.md b/CHANGELOG.md index a1a7ca14b59..f579d25d7a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed a race condition causing SpiDma to stop working unexpectedly (#869) - Fixed async uart serial, and updated the embassy_serial examples (#871). - Fix ESP32-S3 direct-boot (#873) +- Fix ESP32-C6 ADC (#876) ### Removed diff --git a/esp-hal-common/src/analog/adc/riscv.rs b/esp-hal-common/src/analog/adc/riscv.rs index e58b04c7fd9..12d74389535 100644 --- a/esp-hal-common/src/analog/adc/riscv.rs +++ b/esp-hal-common/src/analog/adc/riscv.rs @@ -646,6 +646,19 @@ where let attenuation = self.attenuations[channel as usize].unwrap() as u8; ADCI::config_onetime_sample(channel, attenuation); ADCI::start_onetime_sample(); + + // see https://github.com/espressif/esp-idf/blob/b4268c874a4cf8fcf7c0c4153cffb76ad2ddda4e/components/hal/adc_oneshot_hal.c#L105-L107 + // the delay might be a bit generous but longer delay seem to not cause problems + #[cfg(esp32c6)] + { + extern "C" { + fn ets_delay_us(us: u32); + } + unsafe { + ets_delay_us(40); + } + ADCI::start_onetime_sample(); + } } // Wait for ADC to finish conversion