golemparts / rppal

A Rust library that provides access to the Raspberry Pi's GPIO, I2C, PWM, SPI and UART peripherals.
MIT License
1.24k stars 98 forks source link

GPIO `is_low` output differs from rppal v0.17.0 impl compared to embedded-hal v1 impl #137

Closed TeyKey1 closed 10 months ago

TeyKey1 commented 10 months ago

It appears that both implementations of is_low differ in output for the same logic level of the input pin:

use embedded_hal::digital::InputPin;
use rppal::gpio::{Gpio, InputPin as RppalInputPin};

fn main() {
    let gpio = Gpio::new().unwrap();

    let mut interrupt = gpio.get(6).unwrap().into_input();
    println!(
        "is low hal: {}, is low rppal: {}",
        InputPin::is_low(&mut interrupt).unwrap(),
        RppalInputPin::is_low(&interrupt)
    );
}

With rppal v0.17.0 and embedded-hal v1.0.0 this code outputs: is low hal: false, is low rppal: true while with rppal v0.16.0 and embedded hal v1.0 rc2 this code outputs is low hal: true, is low rppal: true. During this test the raspi 4b pin was pulled low (0V)

I don't think the rppal v0.17.0 behavior is intended and this is likely a bug. Please let me know if there is some other reason for this change.