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>) -> Result<Self, Error>where
ADCX: AdcCalEfuse + CalibrationAccess,
pub fn new(adc_instance: ADCX, config: AdcConfig<ADCX>) -> Result<Self, Error>where
ADCX: AdcCalEfuse + CalibrationAccess,
Creates a new ADC instance with the given configuration.
Sourcepub fn read_blocking<PIN, CS>(
&mut self,
pin: &mut AdcPin<PIN, ADCX, CS>,
) -> Result<u16, Error>where
PIN: AdcChannel,
CS: AdcCalScheme<ADCX>,
pub fn read_blocking<PIN, CS>(
&mut self,
pin: &mut AdcPin<PIN, ADCX, CS>,
) -> Result<u16, Error>where
PIN: AdcChannel,
CS: AdcCalScheme<ADCX>,
Starts and waits for a conversion on the specified pin and returns the result.
§Errors
Returns Error::ChannelNotConfigured if the channel was not configured in
AdcConfig.
Sourcepub fn read_oneshot<PIN, CS>(
&mut self,
pin: &mut AdcPin<PIN, ADCX, CS>,
) -> Result<u16, Error>where
PIN: AdcChannel,
CS: AdcCalScheme<ADCX>,
pub fn read_oneshot<PIN, CS>(
&mut self,
pin: &mut AdcPin<PIN, ADCX, CS>,
) -> Result<u16, Error>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.
§Errors
Returns Error::ChannelNotConfigured if the channel was not configured in
AdcConfig.
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.
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>,
) -> Result<u16, Error>
pub async fn read_oneshot<PIN, CS>( &mut self, pin: &mut AdcPin<PIN, ADCX, CS>, ) -> Result<u16, Error>
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.
§Errors
Returns Error::ChannelNotConfigured if the channel was not configured in
AdcConfig.