Adjust for changes
This commit is contained in:
parent
cec6425c8e
commit
6588f5429a
@ -7,19 +7,20 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
#[cfg(feature = "unstable")] // unused in stable build
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
|
|
||||||
|
#[cfg(feature = "unstable")] // unused in stable build
|
||||||
use critical_section::Mutex;
|
use critical_section::Mutex;
|
||||||
#[cfg(feature = "unstable")]
|
#[cfg(feature = "unstable")]
|
||||||
use embassy_time::{Duration, Timer};
|
use embassy_time::{Duration, Timer};
|
||||||
use esp_hal::{
|
use esp_hal::gpio::{AnyPin, Input, Level, Output, Pin, Pull};
|
||||||
delay::Delay,
|
|
||||||
gpio::{AnyPin, Input, Level, Output, OutputOpenDrain, Pin, Pull},
|
|
||||||
handler,
|
|
||||||
};
|
|
||||||
#[cfg(feature = "unstable")]
|
#[cfg(feature = "unstable")]
|
||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
gpio::{Event, Flex, Io},
|
// OutputOpenDrain is here because will be unused otherwise
|
||||||
|
delay::Delay,
|
||||||
|
gpio::{Event, Flex, Io, OutputOpenDrain},
|
||||||
|
handler,
|
||||||
interrupt::InterruptConfigurable,
|
interrupt::InterruptConfigurable,
|
||||||
timer::timg::TimerGroup,
|
timer::timg::TimerGroup,
|
||||||
};
|
};
|
||||||
@ -27,16 +28,20 @@ use hil_test as _;
|
|||||||
#[cfg(feature = "unstable")]
|
#[cfg(feature = "unstable")]
|
||||||
use portable_atomic::{AtomicUsize, Ordering};
|
use portable_atomic::{AtomicUsize, Ordering};
|
||||||
|
|
||||||
|
#[cfg(feature = "unstable")] // unused in stable build
|
||||||
static COUNTER: Mutex<RefCell<u32>> = Mutex::new(RefCell::new(0));
|
static COUNTER: Mutex<RefCell<u32>> = Mutex::new(RefCell::new(0));
|
||||||
|
#[cfg(feature = "unstable")] // unused in stable build
|
||||||
static INPUT_PIN: Mutex<RefCell<Option<Input>>> = Mutex::new(RefCell::new(None));
|
static INPUT_PIN: Mutex<RefCell<Option<Input>>> = Mutex::new(RefCell::new(None));
|
||||||
|
|
||||||
struct Context {
|
struct Context {
|
||||||
test_gpio1: AnyPin,
|
test_gpio1: AnyPin,
|
||||||
test_gpio2: AnyPin,
|
test_gpio2: AnyPin,
|
||||||
|
#[cfg(feature = "unstable")]
|
||||||
delay: Delay,
|
delay: Delay,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[handler]
|
#[cfg_attr(feature = "unstable", handler)]
|
||||||
|
#[cfg(feature = "unstable")]
|
||||||
pub fn interrupt_handler() {
|
pub fn interrupt_handler() {
|
||||||
critical_section::with(|cs| {
|
critical_section::with(|cs| {
|
||||||
*COUNTER.borrow_ref_mut(cs) += 1;
|
*COUNTER.borrow_ref_mut(cs) += 1;
|
||||||
@ -56,6 +61,7 @@ mod tests {
|
|||||||
fn init() -> Context {
|
fn init() -> Context {
|
||||||
let peripherals = esp_hal::init(esp_hal::Config::default());
|
let peripherals = esp_hal::init(esp_hal::Config::default());
|
||||||
|
|
||||||
|
#[cfg(feature = "unstable")]
|
||||||
let delay = Delay::new();
|
let delay = Delay::new();
|
||||||
|
|
||||||
let (gpio1, gpio2) = hil_test::common_test_pins!(peripherals);
|
let (gpio1, gpio2) = hil_test::common_test_pins!(peripherals);
|
||||||
@ -74,6 +80,7 @@ mod tests {
|
|||||||
Context {
|
Context {
|
||||||
test_gpio1: gpio1.degrade(),
|
test_gpio1: gpio1.degrade(),
|
||||||
test_gpio2: gpio2.degrade(),
|
test_gpio2: gpio2.degrade(),
|
||||||
|
#[cfg(feature = "unstable")]
|
||||||
delay,
|
delay,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -244,6 +251,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg(feature = "unstable")] // delay is unstable
|
||||||
fn gpio_od(ctx: Context) {
|
fn gpio_od(ctx: Context) {
|
||||||
let mut test_gpio1 = OutputOpenDrain::new(ctx.test_gpio1, Level::High, Pull::Up);
|
let mut test_gpio1 = OutputOpenDrain::new(ctx.test_gpio1, Level::High, Pull::Up);
|
||||||
let mut test_gpio2 = OutputOpenDrain::new(ctx.test_gpio2, Level::High, Pull::Up);
|
let mut test_gpio2 = OutputOpenDrain::new(ctx.test_gpio2, Level::High, Pull::Up);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user