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
Configures a given ADC instance using the provided configuration, and initializes 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>,
Starts and waits for a conversion on the specified pin and returns 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>,
Requests that the ADC begin a conversion on the specified pin.
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>
Reconfigures the ADC driver to operate in 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
Starts a conversion on the specified pin and waits for the result.
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.