Module attiny_hal::adc
source · Expand description
Analog-to-Digital Converter
§Example
For full source code, please refer to the ATmega ADC example:
atmega2560-adc.rs
let dp = attiny_hal::Peripherals::take().unwrap();
let pins = attiny_hal::pins!(dp);
let mut adc = Adc::new(dp.ADC, Default::default());
let channels: [attiny_hal::adc::Channel; 4] = [
pins.pa0.into_analog_input(&mut adc).into_channel(),
pins.pa1.into_analog_input(&mut adc).into_channel(),
pins.pa2.into_analog_input(&mut adc).into_channel(),
pins.pa3.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§
- Additional channels
Structs§
- Configuration for the ADC peripheral.
Enums§
- The division factor between the system clock frequency and the input clock to the AD converter.
- Select the voltage reference for the ADC peripheral
Traits§
- Trait marking a type as an ADC channel for a certain ADC.
- Internal trait for the low-level ADC peripheral.
Type Aliases§
- Check the
avr_hal_generic::adc::Adc
documentation. - Check the
avr_hal_generic::adc::Channel
documentation.