pub struct Adc<'a> { /* private fields */ }
Implementations§
Trait Implementations§
source§impl<'a> Adc<'a> for Adc<'a>
impl<'a> Adc<'a> for Adc<'a>
Implements an ADC capable reading ADC samples on any channel.
§type Channel = AdcChannelSetup
type Channel = AdcChannelSetup
The chip-dependent type of an ADC channel.
source§fn sample(
&self,
channel: &<Adc<'a> as Adc<'a>>::Channel,
) -> Result<(), ErrorCode>
fn sample( &self, channel: &<Adc<'a> as Adc<'a>>::Channel, ) -> Result<(), ErrorCode>
Request a single ADC sample on a particular channel.
Used for individual samples that have no timing requirements.
All ADC samples will be the raw ADC value left-justified in the u16.
source§fn sample_continuous(
&self,
_channel: &<Adc<'a> as Adc<'a>>::Channel,
_frequency: u32,
) -> Result<(), ErrorCode>
fn sample_continuous( &self, _channel: &<Adc<'a> as Adc<'a>>::Channel, _frequency: u32, ) -> Result<(), ErrorCode>
Request repeated ADC samples on a particular channel.
Callbacks will occur at the given frequency with low jitter and can be
set to any frequency supported by the chip implementation. However
callbacks may be limited based on how quickly the system can service
individual samples, leading to missed samples at high frequencies.
All ADC samples will be the raw ADC value left-justified in the u16.
source§fn stop_sampling(&self) -> Result<(), ErrorCode>
fn stop_sampling(&self) -> Result<(), ErrorCode>
Stop a sampling operation.
Can be used to stop any simple or high-speed sampling operation. No
further callbacks will occur.
source§fn get_resolution_bits(&self) -> usize
fn get_resolution_bits(&self) -> usize
Function to ask the ADC how many bits of resolution are in the samples
it is returning.
source§fn get_voltage_reference_mv(&self) -> Option<usize>
fn get_voltage_reference_mv(&self) -> Option<usize>
Function to ask the ADC what reference voltage it used when taking the
samples. This allows the user of this interface to calculate an actual
voltage from the ADC reading. Read more
fn set_client(&self, client: &'a dyn Client)
source§impl<'a> AdcHighSpeed<'a> for Adc<'a>
impl<'a> AdcHighSpeed<'a> for Adc<'a>
source§fn sample_highspeed(
&self,
channel: &<Adc<'a> as Adc<'a>>::Channel,
frequency: u32,
buffer1: &'static mut [u16],
length1: usize,
buffer2: &'static mut [u16],
length2: usize,
) -> Result<(), (ErrorCode, &'static mut [u16], &'static mut [u16])>
fn sample_highspeed( &self, channel: &<Adc<'a> as Adc<'a>>::Channel, frequency: u32, buffer1: &'static mut [u16], length1: usize, buffer2: &'static mut [u16], length2: usize, ) -> Result<(), (ErrorCode, &'static mut [u16], &'static mut [u16])>
Start sampling continuously into buffers.
Samples are double-buffered, going first into
buffer1
and then into
buffer2
. A callback is performed to the client whenever either buffer
is full, which expects either a second buffer to be sent via the
provide_buffer
call. Length fields correspond to the number of
samples that should be collected in each buffer. If an error occurs,
the buffers will be returned. Read moresource§fn provide_buffer(
&self,
buf: &'static mut [u16],
length: usize,
) -> Result<(), (ErrorCode, &'static mut [u16])>
fn provide_buffer( &self, buf: &'static mut [u16], length: usize, ) -> Result<(), (ErrorCode, &'static mut [u16])>
Provide a new buffer to fill with the ongoing
sample_continuous
configuration.
Expected to be called in a buffer_ready
callback. Note that if this
is not called before the second buffer is filled, samples will be
missed. Length field corresponds to the number of samples that should
be collected in the buffer. If an error occurs, the buffer will be
returned. Read moresource§fn retrieve_buffers(
&self,
) -> Result<(Option<&'static mut [u16]>, Option<&'static mut [u16]>), ErrorCode>
fn retrieve_buffers( &self, ) -> Result<(Option<&'static mut [u16]>, Option<&'static mut [u16]>), ErrorCode>
Reclaim ownership of buffers.
Can only be called when the ADC is inactive, which occurs after a
successful
stop_sampling
. Used to reclaim buffers after a sampling
operation is complete. Returns Ok() if the ADC was inactive, but
there may still be no buffers that are some
if the driver had already
returned all buffers. Read morefn set_highspeed_client(&self, client: &'a dyn HighSpeedClient)
Auto Trait Implementations§
impl<'a> !Freeze for Adc<'a>
impl<'a> !RefUnwindSafe for Adc<'a>
impl<'a> !Send for Adc<'a>
impl<'a> !Sync for Adc<'a>
impl<'a> Unpin for Adc<'a>
impl<'a> !UnwindSafe for Adc<'a>
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
Mutably borrows from an owned value. Read more