Struct sam4l::adc::Adc
[−]
[src]
pub struct Adc { registers: *mut AdcRegisters, enabled: Cell<bool>, adc_clk_freq: Cell<u32>, active: Cell<bool>, continuous: Cell<bool>, dma_running: Cell<bool>, cpu_clock: Cell<bool>, timer_repeats: Cell<u8>, timer_counts: Cell<u8>, rx_dma: Cell<Option<&'static DMAChannel>>, rx_dma_peripheral: DMAPeripheral, rx_length: Cell<usize>, next_dma_buffer: TakeCell<'static, [u16]>, next_dma_length: Cell<usize>, stopped_buffer: TakeCell<'static, [u16]>, client: Cell<Option<&'static EverythingClient>>, }
ADC driver code for the SAM4L.
Fields
registers: *mut AdcRegisters
enabled: Cell<bool>
adc_clk_freq: Cell<u32>
active: Cell<bool>
continuous: Cell<bool>
dma_running: Cell<bool>
cpu_clock: Cell<bool>
timer_repeats: Cell<u8>
timer_counts: Cell<u8>
rx_dma: Cell<Option<&'static DMAChannel>>
rx_dma_peripheral: DMAPeripheral
rx_length: Cell<usize>
next_dma_buffer: TakeCell<'static, [u16]>
next_dma_length: Cell<usize>
stopped_buffer: TakeCell<'static, [u16]>
client: Cell<Option<&'static EverythingClient>>
Methods
impl Adc
[src]
Functions for initializing the ADC.
const fn new(
base_address: *mut AdcRegisters,
rx_dma_peripheral: DMAPeripheral
) -> Adc
[src]
base_address: *mut AdcRegisters,
rx_dma_peripheral: DMAPeripheral
) -> Adc
Create a new ADC driver.
base_address
: pointer to the ADC's memory mapped I/O registersrx_dma_peripheral
: type used for DMA transactions
pub fn set_client<C: EverythingClient>(&self, client: &'static C)
[src]
Sets the client for this driver.
client
: reference to capsule which handles responses
pub fn set_dma(&self, rx_dma: &'static DMAChannel)
[src]
Sets the DMA channel for this driver.
rx_dma
: reference to the DMA channel the ADC should use
pub fn handle_interrupt(&mut self)
[src]
Interrupt handler for the ADC.
fn config_and_enable(&self, frequency: u32) -> ReturnCode
[src]
Trait Implementations
impl Adc for Adc
[src]
Implements an ADC capable reading ADC samples on any channel.
type Channel = AdcChannel
The chip-dependent type of an ADC channel.
fn initialize(&self) -> ReturnCode
[src]
Enable and configure the ADC. This can be called multiple times with no side effects.
fn sample(&self, channel: &Self::Channel) -> ReturnCode
[src]
Capture a single analog sample, calling the client when complete. Returns an error if the ADC is already sampling.
channel
: the ADC channel to sample
fn sample_continuous(
&self,
channel: &Self::Channel,
frequency: u32
) -> ReturnCode
[src]
&self,
channel: &Self::Channel,
frequency: u32
) -> ReturnCode
Request repeated analog samples on a particular channel, calling after each sample. In order to not unacceptably slow down the system collecting samples, this interface is limited to one sample every 100 microseconds (10000 samples per second). To sample faster, use the sample_highspeed function.
channel
: the ADC channel to samplefrequency
: the number of samples per second to collect
fn stop_sampling(&self) -> ReturnCode
[src]
Stop continuously sampling the ADC.
This is expected to be called to stop continuous sampling operations,
but can be called to abort any currently running operation. The buffer,
if any, will be returned via the samples_ready
callback.
impl AdcHighSpeed for Adc
[src]
Implements an ADC capable of continuous sampling
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]>)
[src]
&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]>)
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)
fn provide_buffer(
&self,
buf: &'static mut [u16],
length: usize
) -> (ReturnCode, Option<&'static mut [u16]>)
[src]
&self,
buf: &'static mut [u16],
length: usize
) -> (ReturnCode, Option<&'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)
fn retrieve_buffers(
&self
) -> (ReturnCode, Option<&'static mut [u16]>, Option<&'static mut [u16]>)
[src]
&self
) -> (ReturnCode, Option<&'static mut [u16]>, Option<&'static mut [u16]>)
Reclaim buffers after the ADC is stopped.
This is expected to be called after stop_sampling
.
impl DMAClient for Adc
[src]
Implements a client of a DMA.
fn xfer_done(&self, pid: DMAPeripheral)
[src]
Handler for DMA transfer completion.
pid
: the DMA peripheral that is complete