Struct rp2040_hal::adc::Adc
source · pub struct Adc { /* private fields */ }
Expand description
Analog to Digital Convertor (ADC).
Represents an ADC within the RP2040. 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§
source§impl<F: Function, M: PullType> Channel<Adc> for AdcPin<Pin<DynPinId, F, M>>where
DynPinId: ValidFunction<F>,
impl<F: Function, M: PullType> Channel<Adc> for AdcPin<Pin<DynPinId, F, M>>where
DynPinId: ValidFunction<F>,
source§impl<F: Function, M: PullType> Channel<Adc> for AdcPin<Pin<Gpio26, F, M>>where
Gpio26: ValidFunction<F>,
impl<F: Function, M: PullType> Channel<Adc> for AdcPin<Pin<Gpio26, F, M>>where
Gpio26: ValidFunction<F>,
source§impl<F: Function, M: PullType> Channel<Adc> for AdcPin<Pin<Gpio27, F, M>>where
Gpio27: ValidFunction<F>,
impl<F: Function, M: PullType> Channel<Adc> for AdcPin<Pin<Gpio27, F, M>>where
Gpio27: ValidFunction<F>,
source§impl<F: Function, M: PullType> Channel<Adc> for AdcPin<Pin<Gpio28, F, M>>where
Gpio28: ValidFunction<F>,
impl<F: Function, M: PullType> Channel<Adc> for AdcPin<Pin<Gpio28, F, M>>where
Gpio28: ValidFunction<F>,
source§impl<F: Function, M: PullType> Channel<Adc> for AdcPin<Pin<Gpio29, F, M>>where
Gpio29: ValidFunction<F>,
impl<F: Function, M: PullType> Channel<Adc> for AdcPin<Pin<Gpio29, F, M>>where
Gpio29: ValidFunction<F>,
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