mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-09-28 12:50:53 +00:00
Add basic HIL test for GPIO that can be configured as pin for (#1963)
This commit is contained in:
parent
e708dbc777
commit
42bbdaeb4f
@ -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,
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user