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

OpenDrain functionality seems to be broken since 1.0.0-beta.0 #3179

Closed
bjoernQ opened this issue Feb 26, 2025 · 6 comments · Fixed by #3181
Closed

OpenDrain functionality seems to be broken since 1.0.0-beta.0 #3179

bjoernQ opened this issue Feb 26, 2025 · 6 comments · Fixed by #3181
Labels
bug Something isn't working peripheral:gpio GPIO peripheral
Milestone

Comments

@bjoernQ
Copy link
Contributor

bjoernQ commented Feb 26, 2025

We removed the explicit OpenDrainOutput driver in favor of a config on Output (and making it into Flex)

Working with the OpenDrainOutput driver on 0.23.1 (connect the two pins)

    let mut a = OutputOpenDrain::new(peripherals.GPIO6, Level::High, Pull::Up);
    let mut b = OutputOpenDrain::new(peripherals.GPIO7, Level::High, Pull::Up);

    let delay = Delay::new();

    loop {
        println!("high/high");
        a.set_high();
        b.set_high();
        delay.delay_millis(5);
        println!("{} {}", a.is_high(), b.is_high());

        println!("low/high");
        a.set_low();
        b.set_high();
        delay.delay_millis(5);
        println!("{} {}", a.is_high(), b.is_high());

        println!("high/low");
        a.set_high();
        b.set_low();
        delay.delay_millis(5);
        println!("{} {}", a.is_high(), b.is_high());

        println!("low/low");
        a.set_low();
        b.set_low();
        delay.delay_millis(5);
        println!("{} {}", a.is_high(), b.is_high());

        println!();
    }

Non-working on 1.0.0-beta.0 (connect the two pins)

    let mut a = Output::new(
        peripherals.GPIO6,
        Level::High,
        OutputConfig::default()
            .with_drive_mode(DriveMode::OpenDrain)
            .with_pull(Pull::Up),
    )
    .into_flex();
    let mut b = Output::new(
        peripherals.GPIO7,
        Level::High,
        OutputConfig::default()
            .with_drive_mode(DriveMode::OpenDrain)
            .with_pull(Pull::Up),
    )
    .into_flex();

    let delay = Delay::new();

    loop {
        println!("high/high");
        a.set_high();
        b.set_high();
        delay.delay_millis(5);
        println!("{} {}", a.is_high(), b.is_high());

        println!("low/high");
        a.set_low();
        b.set_high();
        delay.delay_millis(5);
        println!("{} {}", a.is_high(), b.is_high());

        println!("high/low");
        a.set_high();
        b.set_low();
        delay.delay_millis(5);
        println!("{} {}", a.is_high(), b.is_high());

        println!("low/low");
        a.set_low();
        b.set_low();
        delay.delay_millis(5);
        println!("{} {}", a.is_high(), b.is_high());

        println!();
    }

In 1.0.0-beta.0 we never read a high level

@bjoernQ bjoernQ added the peripheral:gpio GPIO peripheral label Feb 26, 2025
@MabezDev MabezDev added this to the 1.0.0-beta.1 milestone Feb 26, 2025
@MabezDev MabezDev added the bug Something isn't working label Feb 26, 2025
@MabezDev
Copy link
Member

There seems to be a difference in how to set the pin into open drain before #3029, we used to call set_to_open_drain_output now we just set the w.pad_driver() bit in apply_config instead. I suppose set_to_open_drain_output was doing something we're not doing now. Alternatively the order of operations could matter here.

@bjoernQ
Copy link
Contributor Author

bjoernQ commented Feb 26, 2025

I think we can solve it with just some documentation (i.e. an additional step is needed to regain the full functionality of OpenDrainOutput) - let me see

@bjoernQ bjoernQ mentioned this issue Feb 26, 2025
6 tasks
@bjoernQ
Copy link
Contributor Author

bjoernQ commented Feb 26, 2025

Yes - no code changes needed

@bugadani
Copy link
Contributor

In 1.0.0-beta.0 we never read a high level

Huh did I forget to remove the readback functions?

@MabezDev

This comment has been minimized.

@MabezDev
Copy link
Member

In 1.0.0-beta.0 we never read a high level

Huh did I forget to remove the readback functions?

The output is read once it's turned into Flex, so you didn't forget anything.

@github-project-automation github-project-automation bot moved this from Todo to Done in esp-rs Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working peripheral:gpio GPIO peripheral
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants