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

Add basic GPIO HIL test for AnyPin and touch pin #1963

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion hil-test/tests/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use esp_backtrace as _;
use esp_hal::{
clock::ClockControl,
delay::Delay,
gpio::{Gpio2, Gpio3, GpioPin, Input, Io, Level, Output, Pull},
gpio::{any_pin::AnyPin, Gpio2, Gpio3, GpioPin, Input, Io, Level, Output, Pull},
macros::handler,
peripherals::Peripherals,
system::SystemControl,
Expand Down Expand Up @@ -276,4 +276,32 @@ mod tests {
assert_eq!(io2.is_low(), true);
assert_eq!(io3.is_set_low(), true);
}

// Tests touch pin (GPIO2) as AnyPin and Output
// https://github.com/esp-rs/esp-hal/issues/1943
#[test]
fn test_gpio_touch_anypin_output() {
let any_pin2 = AnyPin::new(unsafe { GpioPin::<2>::steal() });
let any_pin3 = AnyPin::new(unsafe { GpioPin::<3>::steal() });

let out_pin = Output::new(any_pin2, Level::High);
let in_pin = Input::new(any_pin3, Pull::Down);

assert_eq!(out_pin.is_set_high(), true);
assert_eq!(in_pin.is_high(), true);
}

// Tests touch pin (GPIO2) as AnyPin and Input
// https://github.com/esp-rs/esp-hal/issues/1943
#[test]
fn test_gpio_touch_anypin_input() {
let any_pin2 = AnyPin::new(unsafe { GpioPin::<2>::steal() });
let any_pin3 = AnyPin::new(unsafe { GpioPin::<3>::steal() });

let out_pin = Output::new(any_pin3, Level::Low);
let in_pin = Input::new(any_pin2, Pull::Down);

assert_eq!(out_pin.is_set_high(), false);
assert_eq!(in_pin.is_high(), false);
}
}