Module capsules_core::adc

source ·
Expand description

Syscall driver capsules for ADC sampling.

This module has two ADC syscall driver capsule implementations.

The first, called AdcDedicated, assumes that it has complete (dedicated) control of the kernel ADC. This capsule provides userspace with the ability to perform single, continuous, and high speed samples. However, using this capsule means that no other capsule or kernel service can use the ADC. It also allows only a single process to use the ADC: other processes will receive NOMEM errors.

The second, called AdcVirtualized, sits top of an ADC virtualizer. This capsule shares the ADC with the rest of the kernel through this virtualizer, so allows other kernel services and capsules to use the ADC. It also supports multiple processes requesting ADC samples concurrently. However, it only supports processes requesting single ADC samples: they cannot sample continuously or at high speed.

§Usage


let adc_channels = static_init!(
    [&'static sam4l::adc::AdcChannel; 6],
    [
        &sam4l::adc::CHANNEL_AD0, // A0
        &sam4l::adc::CHANNEL_AD1, // A1
        &sam4l::adc::CHANNEL_AD3, // A2
        &sam4l::adc::CHANNEL_AD4, // A3
        &sam4l::adc::CHANNEL_AD5, // A4
        &sam4l::adc::CHANNEL_AD6, // A5
    ]
);
let adc = static_init!(
    capsules::adc::AdcDedicated<'static, sam4l::adc::Adc>,
    capsules::adc::AdcDedicated::new(
        &mut sam4l::adc::ADC0,
        adc_channels,
        &mut capsules::adc::ADC_BUFFER1,
        &mut capsules::adc::ADC_BUFFER2,
        &mut capsules::adc::ADC_BUFFER3
    )
);
sam4l::adc::ADC0.set_client(adc);

Structs§

  • 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.
  • Multiplexed ADC syscall driver, used by applications and capsules. Virtualized, and can be use by multiple applications at the same time; requests are queued. Does not support continuous or high-speed sampling.
  • Holds buffers that the application has passed us

Constants§

  • Buffers to use for DMA transfers The size is chosen somewhat arbitrarily, but has been tested. At 175000 Hz, buffers need to be swapped every 70 us and copied over before the next swap. In testing, it seems to keep up fine.