pub struct Adc<'d, ADC, Dm: DriverMode> { /* private fields */ }unstable only.Expand description
Analog-to-Digital Converter peripheral driver.
Implementations§
Source§impl<'d, ADCX> Adc<'d, ADCX, Blocking>where
ADCX: RegisterAccess + 'd,
impl<'d, ADCX> Adc<'d, ADCX, Blocking>where
ADCX: RegisterAccess + 'd,
Sourcepub fn new(adc_instance: ADCX, _config: AdcConfig<ADCX>) -> Self
pub fn new(adc_instance: ADCX, _config: AdcConfig<ADCX>) -> Self
Configure a given ADC instance using the provided configuration, and initialize the ADC for use
The ESP32-S31 SAR ADC has a single attenuation setting, so the attenuation given per pin has no effect.
Sourcepub fn into_async(self) -> Adc<'d, ADCX, Async>
pub fn into_async(self) -> Adc<'d, ADCX, Async>
Reconfigures the ADC driver to operate in asynchronous mode.
Sourcepub fn read_blocking<PIN, CS>(&mut self, pin: &mut AdcPin<PIN, ADCX, CS>) -> u16where
PIN: AdcChannel,
CS: AdcCalScheme<ADCX>,
pub fn read_blocking<PIN, CS>(&mut self, pin: &mut AdcPin<PIN, ADCX, CS>) -> u16where
PIN: AdcChannel,
CS: AdcCalScheme<ADCX>,
Start and wait for a conversion on the specified pin and return the result
The result is in the range 0..=FULL_SCALE, and an input tied to
ground reads about ZERO_DIFF_CODE.
Sourcepub fn read_oneshot<PIN, CS>(
&mut self,
pin: &mut AdcPin<PIN, ADCX, CS>,
) -> Result<u16, ()>where
PIN: AdcChannel,
CS: AdcCalScheme<ADCX>,
pub fn read_oneshot<PIN, CS>(
&mut self,
pin: &mut AdcPin<PIN, ADCX, CS>,
) -> Result<u16, ()>where
PIN: AdcChannel,
CS: AdcCalScheme<ADCX>,
Request that the ADC begin a conversion on the specified pin
This method takes an AdcPin reference, as it is expected that the ADC will be able to sample whatever channel underlies the pin.
The result is in the range 0..=FULL_SCALE, and an input tied to
ground reads about ZERO_DIFF_CODE.
Source§impl<'d, ADCX> Adc<'d, ADCX, Async>where
ADCX: RegisterAccess + 'd,
impl<'d, ADCX> Adc<'d, ADCX, Async>where
ADCX: RegisterAccess + 'd,
Sourcepub fn into_blocking(self) -> Adc<'d, ADCX, Blocking>
pub fn into_blocking(self) -> Adc<'d, ADCX, Blocking>
Create a new instance in crate::Blocking mode.
Sourcepub async fn read_oneshot<PIN, CS>(
&mut self,
pin: &mut AdcPin<PIN, ADCX, CS>,
) -> u16
pub async fn read_oneshot<PIN, CS>( &mut self, pin: &mut AdcPin<PIN, ADCX, CS>, ) -> u16
Start a conversion on the specified pin and wait for the result.
This method takes an AdcPin reference, as it is expected that the ADC will be able to sample whatever channel underlies the pin.
The result is in the range 0..=FULL_SCALE, and an input tied to
ground reads about ZERO_DIFF_CODE.