Skip to content

Commit 6588f54

Browse files
committed
Adjust for changes
1 parent cec6425 commit 6588f54

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

hil-test/tests/gpio.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,41 @@
77
#![no_std]
88
#![no_main]
99

10+
#[cfg(feature = "unstable")] // unused in stable build
1011
use core::cell::RefCell;
1112

13+
#[cfg(feature = "unstable")] // unused in stable build
1214
use critical_section::Mutex;
1315
#[cfg(feature = "unstable")]
1416
use embassy_time::{Duration, Timer};
17+
use esp_hal::gpio::{AnyPin, Input, Level, Output, Pin, Pull};
18+
#[cfg(feature = "unstable")]
1519
use esp_hal::{
20+
// OutputOpenDrain is here because will be unused otherwise
1621
delay::Delay,
17-
gpio::{AnyPin, Input, Level, Output, OutputOpenDrain, Pin, Pull},
22+
gpio::{Event, Flex, Io, OutputOpenDrain},
1823
handler,
19-
};
20-
#[cfg(feature = "unstable")]
21-
use esp_hal::{
22-
gpio::{Event, Flex, Io},
2324
interrupt::InterruptConfigurable,
2425
timer::timg::TimerGroup,
2526
};
2627
use hil_test as _;
2728
#[cfg(feature = "unstable")]
2829
use portable_atomic::{AtomicUsize, Ordering};
2930

31+
#[cfg(feature = "unstable")] // unused in stable build
3032
static COUNTER: Mutex<RefCell<u32>> = Mutex::new(RefCell::new(0));
33+
#[cfg(feature = "unstable")] // unused in stable build
3134
static INPUT_PIN: Mutex<RefCell<Option<Input>>> = Mutex::new(RefCell::new(None));
3235

3336
struct Context {
3437
test_gpio1: AnyPin,
3538
test_gpio2: AnyPin,
39+
#[cfg(feature = "unstable")]
3640
delay: Delay,
3741
}
3842

39-
#[handler]
43+
#[cfg_attr(feature = "unstable", handler)]
44+
#[cfg(feature = "unstable")]
4045
pub fn interrupt_handler() {
4146
critical_section::with(|cs| {
4247
*COUNTER.borrow_ref_mut(cs) += 1;
@@ -56,6 +61,7 @@ mod tests {
5661
fn init() -> Context {
5762
let peripherals = esp_hal::init(esp_hal::Config::default());
5863

64+
#[cfg(feature = "unstable")]
5965
let delay = Delay::new();
6066

6167
let (gpio1, gpio2) = hil_test::common_test_pins!(peripherals);
@@ -74,6 +80,7 @@ mod tests {
7480
Context {
7581
test_gpio1: gpio1.degrade(),
7682
test_gpio2: gpio2.degrade(),
83+
#[cfg(feature = "unstable")]
7784
delay,
7885
}
7986
}
@@ -244,6 +251,7 @@ mod tests {
244251
}
245252

246253
#[test]
254+
#[cfg(feature = "unstable")] // delay is unstable
247255
fn gpio_od(ctx: Context) {
248256
let mut test_gpio1 = OutputOpenDrain::new(ctx.test_gpio1, Level::High, Pull::Up);
249257
let mut test_gpio2 = OutputOpenDrain::new(ctx.test_gpio2, Level::High, Pull::Up);

0 commit comments

Comments
 (0)