Trait kernel::hil::adc::AdcHighSpeed
source · pub trait AdcHighSpeed<'a>: Adc<'a> {
// Required methods
fn sample_highspeed(
&self,
channel: &Self::Channel,
frequency: u32,
buffer1: &'static mut [u16],
length1: usize,
buffer2: &'static mut [u16],
length2: usize,
) -> Result<(), (ErrorCode, &'static mut [u16], &'static mut [u16])>;
fn provide_buffer(
&self,
buf: &'static mut [u16],
length: usize,
) -> Result<(), (ErrorCode, &'static mut [u16])>;
fn retrieve_buffers(
&self,
) -> Result<(Option<&'static mut [u16]>, Option<&'static mut [u16]>), ErrorCode>;
fn set_highspeed_client(&self, client: &'a dyn HighSpeedClient);
}
Expand description
Interface for continuously sampling at a given frequency on a channel. Requires the AdcSimple interface to have been implemented as well.
Required Methods§
sourcefn sample_highspeed(
&self,
channel: &Self::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: &Self::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.
All ADC samples will be the raw ADC value left-justified in the u16.
sourcefn 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.
All ADC samples will be the raw ADC value left-justified in the u16.
sourcefn 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.
All ADC samples will be the raw ADC value left-justified in the u16.