-
Notifications
You must be signed in to change notification settings - Fork 243
Open
Labels
hal-apiAPI design for the different components of avr-halAPI design for the different components of avr-hal
Description
Hello, this is a great project. When trying to perform the Adc.read
method on a Pin<Analog>
object, I receive the following error:
the trait bound `arduino_uno::atmega328p_hal::port::Pin<arduino_uno::atmega328p_hal::port::mode::Analog>: embedded_hal::adc::Channel<arduino_uno::adc::Adc>` is not satisfied
required because of the requirements on the impl of `arduino_uno::prelude::_embedded_hal_adc_OneShot<arduino_uno::adc::Adc, _, arduino_uno::atmega328p_hal::port::Pin<arduino_uno::atmega328p_hal::port::mode::Analog>>` for `arduino_uno::adc::Adc` rustc(E0277)
which cleaned up for you benefit becomes:
the trait bound `Pin<Analog>: Channel<Adc>` is not satisfied
required because of the requirements on the impl of `OneShot<Adc, _, Pin<Analog>>` for `Adc` rustc(E0277)
I believe that this just means that the downgraded/generic Pin<Analog>
object needs this OneShot
trait implemented? It's a little hard to figure out what is and isn't implemented with all of the procedural macros.
Here is a minimal reproducible example:
#![no_std]
#![no_main]
extern crate panic_halt;
use arduino_uno::prelude::*;
use nb;
#[arduino_uno::entry]
fn main() -> ! {
let peripherals = arduino_uno::Peripherals::take().unwrap();
let mut pins = arduino_uno::Pins::new(
peripherals.PORTB, peripherals.PORTC, peripherals.PORTD
);
let mut adc = arduino_uno::adc::Adc::new(
peripherals.ADC, arduino_uno::adc::AdcSettings::default()
);
let analog_pin = pins.a0.into_analog_input(&mut adc).downgrade();
let val: u16 = nb::block!(adc.read(&mut analog_pin)).void_unwrap();
loop {}
}
davystrong
Metadata
Metadata
Assignees
Labels
hal-apiAPI design for the different components of avr-halAPI design for the different components of avr-hal