capsules_core::adc

Struct AdcDedicated

Source
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>

Source

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 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

Trait Implementations§

Source§

impl<'a, A: Adc<'a> + AdcHighSpeed<'a>> Client for AdcDedicated<'a, A>

Callbacks from the ADC driver

Source§

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>

Callbacks from the High Speed ADC driver

Source§

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 samples
  • length - 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>

Implementations of application syscalls

Source§

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 is
  • data - value sent by the application, varying uses
  • _processid - application identifier, unused
Source§

fn allocate_grant(&self, processid: ProcessId) -> Result<(), Error>

Request to allocate a capsule’s grant for a specific process. Read more
Source§

fn allow_userspace_readable( &self, app: ProcessId, which: usize, slice: ReadWriteProcessBuffer, ) -> Result<ReadWriteProcessBuffer, (ReadWriteProcessBuffer, ErrorCode)>

System call for a process to pass a buffer (a 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

Auto Trait Implementations§

§

impl<'a, A> !Freeze for AdcDedicated<'a, A>

§

impl<'a, A> !RefUnwindSafe for AdcDedicated<'a, A>

§

impl<'a, A> !Send for AdcDedicated<'a, A>

§

impl<'a, A> !Sync for AdcDedicated<'a, A>

§

impl<'a, A> Unpin for AdcDedicated<'a, A>

§

impl<'a, A> !UnwindSafe for AdcDedicated<'a, A>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.