pub struct Adc { /* private fields */ }Expand description
Analog to Digital Convertor (ADC).
Represents an ADC within the RP2350. Each ADC has multiple channels, and each
channel is either associated with a specific GPIO pin or attached to the internal
temperature sensor. You should put the relevant pin into ADC mode by creating an
AdcPin object with it, or you can put the ADC into Temperature Sensing Mode
by calling Adc::take_temp_sensor(). Either way, the resulting objects can be
passed to the OneShot::read() trait method to actually do the read.
Implementations§
Source§impl Adc
impl Adc
Sourcepub fn read_single(&self) -> u16
pub fn read_single(&self) -> u16
Read the most recently sampled ADC value
This function does not wait for the current conversion to finish. If a conversion is still in progress, it returns the result of the previous one.
It also doesn’t trigger a new conversion.
Sourcepub fn enable_temp_sensor(&mut self) -> TempSense
👎Deprecated since 0.9.0: This method may panic, use take_temp_sensor() instead.
pub fn enable_temp_sensor(&mut self) -> TempSense
take_temp_sensor() instead.Enable temperature sensor, returns a channel to use.
This can only be done once before calling Adc::disable_temp_sensor(). If the sensor has already
been enabled, this method will panic.
Sourcepub fn take_temp_sensor(&mut self) -> Option<TempSense>
pub fn take_temp_sensor(&mut self) -> Option<TempSense>
Enable temperature sensor, returns a channel to use
If the sensor has already been enabled, this method returns None.
Sourcepub fn disable_temp_sensor(&mut self, _: TempSense)
pub fn disable_temp_sensor(&mut self, _: TempSense)
Disable temperature sensor, consumes channel
Sourcepub fn build_fifo(&mut self) -> AdcFifoBuilder<'_, u16>
pub fn build_fifo(&mut self) -> AdcFifoBuilder<'_, u16>
Start configuring free-running mode, and set up the FIFO
The AdcFifoBuilder returned by this method can be used
to configure capture options, like sample rate, channels to
capture from etc.
Capturing is started by calling AdcFifoBuilder::start, which
returns an AdcFifo to read from.
Sourcepub fn free_running(&mut self, pin: &dyn AdcChannel)
pub fn free_running(&mut self, pin: &dyn AdcChannel)
Enable free-running mode by setting the start_many flag.
Sourcepub fn wait_ready(&self)
pub fn wait_ready(&self)
Wait for the ADC to become ready.
Also returns immediately if start_many is set, to avoid indefinite blocking.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Adc
impl RefUnwindSafe for Adc
impl Send for Adc
impl !Sync for Adc
impl Unpin for Adc
impl UnwindSafe for Adc
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more