Struct capsules::adc::Adc
[−]
[src]
pub struct Adc<'a, A: Adc + AdcHighSpeed + 'a> { adc: &'a A, channels: &'a [&'a <A as Adc>::Channel], active: Cell<bool>, mode: Cell<AdcMode>, app: MapCell<App>, channel: Cell<usize>, callback: Cell<Option<Callback>>, app_buf_offset: Cell<usize>, samples_remaining: Cell<usize>, samples_outstanding: Cell<usize>, next_samples_outstanding: Cell<usize>, using_app_buf1: Cell<bool>, adc_buf1: TakeCell<'static, [u16]>, adc_buf2: TakeCell<'static, [u16]>, adc_buf3: TakeCell<'static, [u16]>, }
ADC application driver, used by applications to interact with ADC. Not currently virtualized, only one application can use it at a time.
Fields
adc: &'a A
channels: &'a [&'a <A as Adc>::Channel]
active: Cell<bool>
mode: Cell<AdcMode>
app: MapCell<App>
channel: Cell<usize>
callback: Cell<Option<Callback>>
app_buf_offset: Cell<usize>
samples_remaining: Cell<usize>
samples_outstanding: Cell<usize>
next_samples_outstanding: Cell<usize>
using_app_buf1: Cell<bool>
adc_buf1: TakeCell<'static, [u16]>
adc_buf2: TakeCell<'static, [u16]>
adc_buf3: TakeCell<'static, [u16]>
Methods
impl<'a, A: Adc + AdcHighSpeed + 'a> Adc<'a, A>
[src]
Functions to create, initialize, and interact with the ADC
pub fn new(
adc: &'a A,
channels: &'a [&'a <A as Adc>::Channel],
adc_buf1: &'static mut [u16; 128],
adc_buf2: &'static mut [u16; 128],
adc_buf3: &'static mut [u16; 128]
) -> Adc<'a, A>
[src]
adc: &'a A,
channels: &'a [&'a <A as Adc>::Channel],
adc_buf1: &'static mut [u16; 128],
adc_buf2: &'static mut [u16; 128],
adc_buf3: &'static mut [u16; 128]
) -> Adc<'a, A>
Create a new Adc application interface
adc - ADC driver to provide application access to channels - list of ADC channels usable by applications adc_buf1 - buffer used to hold ADC samples adc_buf2 - second buffer used when continuously sampling ADC
fn initialize(&self) -> ReturnCode
[src]
Initialize the ADC This can be called harmlessly if the ADC has already been initialized
fn replace_buffer(&self, buf: &'static mut [u16]) -> &TakeCell<'static, [u16]>
[src]
Store a buffer we've regained ownership of and return a handle to it
The handle can have map
called on it in order to process the data in
the buffer
buf - buffer to be stored
fn take_and_map_buffer<F: FnOnce(&'static mut [u16])>(&self, closure: F)
[src]
Find a buffer to give to the ADC to store samples in
closure - function to run on the found buffer
fn sample(&self, channel: usize) -> ReturnCode
[src]
Collect a single analog sample on a channel
channel - index into channels
array, which channel to sample
fn sample_continuous(&self, channel: usize, frequency: u32) -> ReturnCode
[src]
Collected repeated single analog samples on a channel
channel - index into channels
array, which channel to sample
frequency - number of samples per second to collect
fn sample_buffer(&self, channel: usize, frequency: u32) -> ReturnCode
[src]
Collect a buffer-full of analog samples Samples are collected into the first app buffer provided. The number of samples collected is equal to the size of the buffer "allowed"
channel - index into channels
array, which channel to sample
frequency - number of samples per second to collect
fn sample_buffer_continuous(&self, channel: usize, frequency: u32) -> ReturnCode
[src]
Collect analog samples continuously Fills one "allowed" application buffer at a time and then swaps to filling the second buffer. Callbacks occur when the in use "allowed" buffer fills
channel - index into channels
array, which channel to sample
frequency - number of samples per second to collect
fn stop_sampling(&self) -> ReturnCode
[src]
Stops sampling the ADC Any active operation by the ADC is canceled. No additional callbacks will occur. Also retrieves buffers from the ADC (if any)
Trait Implementations
impl<'a, A: Adc + AdcHighSpeed + 'a> Client for Adc<'a, A>
[src]
Callbacks from the ADC driver
fn sample_ready(&self, sample: u16)
[src]
Single sample operation complete Collects the sample and provides a callback to the application
sample - analog sample value
impl<'a, A: Adc + AdcHighSpeed + 'a> HighSpeedClient for Adc<'a, A>
[src]
Callbacks from the High Speed ADC driver
fn samples_ready(&self, buf: &'static mut [u16], length: usize)
[src]
Internal buffer has filled from a buffered sampling operation. Copies data over to application buffer, determines if more data is needed, and performs a callback to the application if ready. If continuously sampling, also swaps application buffers and continues sampling when neccessary. If only filling a single buffer, stops sampling operation when the application buffer is full.
buf - internal buffer filled with analog samples length - number of valid samples in the buffer, guaranteed to be less than or equal to buffer length
impl<'a, A: Adc + AdcHighSpeed + 'a> Driver for Adc<'a, A>
[src]
Implementations of application syscalls
fn allow(
&self,
_appid: AppId,
allow_num: usize,
slice: AppSlice<Shared, u8>
) -> ReturnCode
[src]
&self,
_appid: AppId,
allow_num: usize,
slice: AppSlice<Shared, u8>
) -> ReturnCode
Provides access to a buffer from the application to store data in or read data from
_appid - application identifier, unused allow_num - which allow call this is slice - representation of application memory to copy data into
fn subscribe(&self, subscribe_num: usize, callback: Callback) -> ReturnCode
[src]
Provides a callback which can be used to signal the application
subscribe_num - which subscribe call this is callback - callback object which can be scheduled to signal the application
fn command(
&self,
command_num: usize,
channel: usize,
frequency: usize,
_appid: AppId
) -> ReturnCode
[src]
&self,
command_num: usize,
channel: usize,
frequency: usize,
_appid: AppId
) -> ReturnCode
Method for the application to command or query this driver
command_num - which command call this is data - value sent by the application, varying uses _appid - application identifier, unused