Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32: Cannot use InputOnlyAnalog gpio pins #388

Closed
Alex-Vining opened this issue Feb 7, 2023 · 1 comment · Fixed by #390
Closed

ESP32: Cannot use InputOnlyAnalog gpio pins #388

Alex-Vining opened this issue Feb 7, 2023 · 1 comment · Fixed by #390
Labels
bug Something isn't working

Comments

@Alex-Vining
Copy link

I'm having trouble trying to setup the read-only analog pins(GPIO34-39) on the esp32. As far as I can tell this is the only implementation of the to_analog() method that you would use to create a AdcPin to interface with an adc. As far as I can tell this trait is only implemented for the IsOutputPin trait which the read-only pins don't have.

Here is example code to reproduce it issue:

#![no_std]
#![no_main]

use esp32_hal::{
    clock::ClockControl, peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc, IO
};
use esp_backtrace as _;
#[xtensa_lx_rt::entry]
fn main() -> ! {
    let peripherals = Peripherals::take();
    let system = peripherals.DPORT.split();
    let clocks = ClockControl::boot_defaults(system.clock_control).freeze();

    // Disable the RTC and TIMG watchdog timers
    let mut rtc = Rtc::new(peripherals.RTC_CNTL);
    let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks);
    let mut wdt0 = timer_group0.wdt;
    let timer_group1 = TimerGroup::new(peripherals.TIMG1, &clocks);
    let mut wdt1 = timer_group1.wdt;

    rtc.rwdt.disable();
    wdt0.disable();
    wdt1.disable();

    let io = IO::new(peripherals.GPIO, peripherals.IO_MUX);

    io.pins.gpio34.into_analog();
    io.pins.gpio35.into_analog();
    io.pins.gpio36.into_analog();
    io.pins.gpio37.into_analog();
    io.pins.gpio38.into_analog();
    io.pins.gpio39.into_analog();

    loop {
        
    }
}

This is the error message:

the method `into_analog` exists for struct `GpioPin<esp32_hal::gpio::Unknown, Bank1GpioRegisterAccess, DualCoreInteruptStatusRegisterAccessBank1, InputOnlyAnalogPinType, Gpio34Signals, 34>`, but its trait bounds were not satisfied
the following trait bounds were not satisfied:
`InputOnlyAnalogPinType: IsOutputPin`rustcClick for full compiler diagnostic
gpio.rs(554, 1): doesn't satisfy `InputOnlyAnalogPinType: IsOutputPin`
@bjoernQ
Copy link
Contributor

bjoernQ commented Feb 7, 2023

Thanks for opening this issue - I think I know what to do and we can hopefully fix this soon

@bjoernQ bjoernQ added the bug Something isn't working label Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants