Module esp32c6_hal::adc
source · Expand description
Analog to digital (ADC) conversion support.
Overview
The ADC
module in the analog
driver enables users to perform
analog-to-digital conversions, allowing them to measure real-world
analog signals with high accuracy.
This module provides functions for reading analog values from the
analog to digital converter available on the ESP32-C6: ADC1
.
Example
ADC on Risc-V architecture
// Create ADC instances
let analog = peripherals.APB_SARADC.split();
let mut adc1_config = AdcConfig::new();
let mut pin = adc1_config.enable_pin(io.pins.gpio2.into_analog(), Attenuation::Attenuation11dB);
let mut adc1 = ADC::<ADC1>::adc(
&mut system.peripheral_clock_control,
analog.adc1,
adc1_config,
)
.unwrap();
let mut delay = Delay::new(&clocks);
loop {
let pin_value: u16 = nb::block!(adc1.read(&mut pin)).unwrap();
println!("PIN2 ADC reading = {}", pin_value);
delay.delay_ms(1500u32);
}
Structs
- Basic ADC calibration scheme
- Curve fitting ADC calibration scheme
- Line fitting ADC calibration scheme
Enums
- The attenuation of the ADC pin
- The sampling/readout resolution of the ADC
Traits
- A helper trait to get access to ADC calibration efuses
- A helper trait to do calibrated samples fitting
- Marker trait for ADC which support curve fitting
- Marker trait for ADC units which support line fitting