Merge pull request #4224 from felipebalbi/button

imxrt: add button example
This commit is contained in:
Dario Nieuwenhuis 2025-06-01 12:20:01 +00:00 committed by GitHub
commit d23d5d6a4c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -0,0 +1,29 @@
#![no_std]
#![no_main]
use defmt::info;
use embassy_executor::Spawner;
use embassy_futures::select::{select, Either};
use embassy_imxrt::gpio;
use {defmt_rtt as _, embassy_imxrt_examples as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let p = embassy_imxrt::init(Default::default());
let mut user1 = gpio::Input::new(p.PIO1_1, gpio::Pull::None, gpio::Inverter::Disabled);
let mut user2 = gpio::Input::new(p.PIO0_10, gpio::Pull::None, gpio::Inverter::Disabled);
loop {
let res = select(user1.wait_for_falling_edge(), user2.wait_for_falling_edge()).await;
match res {
Either::First(()) => {
info!("Button `USER1' pressed");
}
Either::Second(()) => {
info!("Button `USER2' pressed");
}
}
}
}