Module adc

Source
Expand description

Analog-to-Digital Converter

§Example

Complete example source code can be found in the repository: atmega2560-adc.rs

let dp = atmega_hal::Peripherals::take().unwrap();
let pins = atmega_hal::pins!(dp);

let mut adc = Adc::new(dp.ADC, Default::default());

let channels: [atmega_hal::adc::Channel; 4] = [
    pins.pf0.into_analog_input(&mut adc).into_channel(),
    pins.pf1.into_analog_input(&mut adc).into_channel(),
    pins.pf2.into_analog_input(&mut adc).into_channel(),
    pins.pf3.into_analog_input(&mut adc).into_channel(),
];

for (index, channel) in channels.iter().enumerate() {
    let value = adc.read_blocking(channel);
    ufmt::uwrite!(&mut serial, "CH{}: {} ", index, value).unwrap();
}

Modules§

channel
Additional channels

Structs§

AdcSettings
Configuration for the ADC peripheral.

Enums§

ClockDivider
The division factor between the system clock frequency and the input clock to the AD converter.
ReferenceVoltage
Select the voltage reference for the ADC peripheral

Traits§

AdcChannel
Trait marking a type as an ADC channel for a certain ADC.
AdcOps
Internal trait for the low-level ADC peripheral.

Type Aliases§

Adc
Check the avr_hal_generic::adc::Adc documentation.
Channel
Check the avr_hal_generic::adc::Channel documentation.