Struct stm32f412g::adc::Adc
source · pub struct Adc<'a> { /* private fields */ }
Implementations§
source§impl<'a> Adc<'a>
impl<'a> Adc<'a>
pub const fn new(clocks: &'a dyn Stm32f4Clocks) -> Adc<'a>
pub fn enable(&self)
pub fn handle_interrupt(&self)
pub fn is_enabled_clock(&self) -> bool
pub fn enable_clock(&self)
pub fn disable_clock(&self)
pub fn enable_temperature(&self)
Trait Implementations§
source§impl<'a> Adc<'a> for Adc<'a>
impl<'a> Adc<'a> for Adc<'a>
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>
Not yet supported
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])>
Capture buffered samples from the ADC continuously at a given frequency, calling the client whenever a buffer fills up. The client is then expected to either stop sampling or provide an additional buffer to sample into. Note that due to hardware constraints the maximum frequency range of the ADC is from 187 kHz to 23 Hz (although its precision is limited at higher frequencies due to aliasing).
channel
: the ADC channel to samplefrequency
: frequency to sample atbuffer1
: first buffer to fill with sampleslength1
: number of samples to collect (up to buffer length)buffer2
: second buffer to fill once the first is fulllength2
: number of samples to collect (up to buffer length)
source§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 send on-going buffered continuous samples to.
This is expected to be called after the samples_ready
callback.
buf
: buffer to fill with sampleslength
: number of samples to collect (up to buffer length)
source§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 buffers after the ADC is stopped.
This is expected to be called after stop_sampling
.
fn 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