diff options
Diffstat (limited to 'examples/esp32c6/examples/sw_and_hw.rs')
| -rw-r--r-- | examples/esp32c6/examples/sw_and_hw.rs | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/examples/esp32c6/examples/sw_and_hw.rs b/examples/esp32c6/examples/sw_and_hw.rs index c5343bc..7feb985 100644 --- a/examples/esp32c6/examples/sw_and_hw.rs +++ b/examples/esp32c6/examples/sw_and_hw.rs @@ -4,27 +4,23 @@ #[rtic::app(device = esp32c6, dispatchers=[FROM_CPU_INTR0, FROM_CPU_INTR1])] mod app { use esp_backtrace as _; - use esp_hal::{ - gpio::{Event, Gpio9, Input, PullUp, IO}, - peripherals::Peripherals, - prelude::*, - }; + use esp_hal::gpio::{Event, Input, Pull}; use esp_println::println; + #[shared] struct Shared {} #[local] struct Local { - button: Gpio9<Input<PullUp>>, + button: Input<'static>, } // do nothing in init #[init] fn init(_: init::Context) -> (Shared, Local) { println!("init"); - let peripherals = Peripherals::take(); - let io = IO::new(peripherals.GPIO, peripherals.IO_MUX); - let mut button = io.pins.gpio9.into_pull_up_input(); + let peripherals = esp_hal::init(esp_hal::Config::default()); + let mut button = Input::new(peripherals.GPIO9, Pull::Up); button.listen(Event::FallingEdge); foo::spawn().unwrap(); (Shared {}, Local { button }) @@ -41,17 +37,18 @@ mod app { bar::spawn().unwrap(); //enqueue low prio task println!("Inside high prio task, press button now!"); let mut x = 0; - while x < 5000000 { + while x < 50000000 { x += 1; //burn cycles esp_hal::riscv::asm::nop(); } println!("Leaving high prio task."); } + #[task(priority = 2)] async fn bar(_: bar::Context) { println!("Inside low prio task, press button now!"); let mut x = 0; - while x < 5000000 { + while x < 50000000 { x += 1; //burn cycles esp_hal::riscv::asm::nop(); } |
