pub struct AdcDedicated<'a, A: Adc<'a> + AdcHighSpeed<'a>> { /* private fields */ }
Expand description
ADC syscall driver, used by applications to interact with ADC.
Not currently virtualized: does not share the ADC with other capsules and only one application can use it at a time. Supports continuous and high speed sampling.
Implementations§
Source§impl<'a, A: Adc<'a> + AdcHighSpeed<'a>> AdcDedicated<'a, A>
impl<'a, A: Adc<'a> + AdcHighSpeed<'a>> AdcDedicated<'a, A>
Sourcepub fn new(
adc: &'a A,
grant: Grant<App, UpcallCount<1>, AllowRoCount<0>, AllowRwCount<2>>,
channels: &'a [<A as Adc<'a>>::Channel],
adc_buf1: &'static mut [u16; 128],
adc_buf2: &'static mut [u16; 128],
adc_buf3: &'static mut [u16; 128],
) -> AdcDedicated<'a, A>
pub fn new( adc: &'a A, grant: Grant<App, UpcallCount<1>, AllowRoCount<0>, AllowRwCount<2>>, channels: &'a [<A as Adc<'a>>::Channel], adc_buf1: &'static mut [u16; 128], adc_buf2: &'static mut [u16; 128], adc_buf3: &'static mut [u16; 128], ) -> AdcDedicated<'a, A>
Create a new Adc
application interface.
adc
- ADC driver to provide application access tochannels
- list of ADC channels usable by applicationsadc_buf1
- buffer used to hold ADC samplesadc_buf2
- second buffer used when continuously sampling ADC
Trait Implementations§
Source§impl<'a, A: Adc<'a> + AdcHighSpeed<'a>> Client for AdcDedicated<'a, A>
impl<'a, A: Adc<'a> + AdcHighSpeed<'a>> Client for AdcDedicated<'a, A>
Callbacks from the ADC driver
Source§fn sample_ready(&self, sample: u16)
fn sample_ready(&self, sample: u16)
Single sample operation complete.
Collects the sample and provides a callback to the application.
sample
- analog sample value
Source§impl<'a, A: Adc<'a> + AdcHighSpeed<'a>> HighSpeedClient for AdcDedicated<'a, A>
impl<'a, A: Adc<'a> + AdcHighSpeed<'a>> HighSpeedClient for AdcDedicated<'a, A>
Callbacks from the High Speed ADC driver
Source§fn samples_ready(&self, buf: &'static mut [u16], length: usize)
fn samples_ready(&self, buf: &'static mut [u16], length: usize)
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 necessary. If only filling a single buffer, stops sampling operation when the application buffer is full.
buf
- internal buffer filled with analog sampleslength
- number of valid samples in the buffer, guaranteed to be less than or equal to buffer length
Source§impl<'a, A: Adc<'a> + AdcHighSpeed<'a>> SyscallDriver for AdcDedicated<'a, A>
impl<'a, A: Adc<'a> + AdcHighSpeed<'a>> SyscallDriver for AdcDedicated<'a, A>
Implementations of application syscalls
Source§fn command(
&self,
command_num: usize,
channel: usize,
frequency: usize,
processid: ProcessId,
) -> CommandReturn
fn command( &self, command_num: usize, channel: usize, frequency: usize, processid: ProcessId, ) -> CommandReturn
Method for the application to command or query this driver.
command_num
- which command call this isdata
- value sent by the application, varying uses_processid
- application identifier, unused
Source§fn allocate_grant(&self, processid: ProcessId) -> Result<(), Error>
fn allocate_grant(&self, processid: ProcessId) -> Result<(), Error>
Source§fn allow_userspace_readable(
&self,
app: ProcessId,
which: usize,
slice: ReadWriteProcessBuffer,
) -> Result<ReadWriteProcessBuffer, (ReadWriteProcessBuffer, ErrorCode)>
fn allow_userspace_readable( &self, app: ProcessId, which: usize, slice: ReadWriteProcessBuffer, ) -> Result<ReadWriteProcessBuffer, (ReadWriteProcessBuffer, ErrorCode)>
UserspaceReadableProcessBuffer
) to the kernel that the kernel can
either read or write. The kernel calls this method only after it checks
that the entire buffer is within memory the process can both read and
write. Read more