Trait kernel::hil::adc::AdcHighSpeed
[−]
[src]
pub trait AdcHighSpeed: Adc { fn sample_highspeed(
&self,
channel: &Self::Channel,
frequency: u32,
buffer1: &'static mut [u16],
length1: usize,
buffer2: &'static mut [u16],
length2: usize
) -> (ReturnCode, Option<&'static mut [u16]>, Option<&'static mut [u16]>); fn provide_buffer(
&self,
buf: &'static mut [u16],
length: usize
) -> (ReturnCode, Option<&'static mut [u16]>); fn retrieve_buffers(
&self
) -> (ReturnCode, Option<&'static mut [u16]>, Option<&'static mut [u16]>); }
Interface for continuously sampling at a given frequency on a channel. Requires the AdcSimple interface to have been implemented as well.
Required Methods
fn sample_highspeed(
&self,
channel: &Self::Channel,
frequency: u32,
buffer1: &'static mut [u16],
length1: usize,
buffer2: &'static mut [u16],
length2: usize
) -> (ReturnCode, Option<&'static mut [u16]>, Option<&'static mut [u16]>)
&self,
channel: &Self::Channel,
frequency: u32,
buffer1: &'static mut [u16],
length1: usize,
buffer2: &'static mut [u16],
length2: usize
) -> (ReturnCode, Option<&'static mut [u16]>, Option<&'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.
fn provide_buffer(
&self,
buf: &'static mut [u16],
length: usize
) -> (ReturnCode, Option<&'static mut [u16]>)
&self,
buf: &'static mut [u16],
length: usize
) -> (ReturnCode, Option<&'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.
fn retrieve_buffers(
&self
) -> (ReturnCode, Option<&'static mut [u16]>, Option<&'static mut [u16]>)
&self
) -> (ReturnCode, Option<&'static mut [u16]>, Option<&'static mut [u16]>)
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 success if the ADC was inactive, but
there may still be no buffers that are some
if the driver had already
returned all buffers.