diff options
Diffstat (limited to 'examples/lpc55s69/src/bin/button_executor.rs')
| -rw-r--r-- | examples/lpc55s69/src/bin/button_executor.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/examples/lpc55s69/src/bin/button_executor.rs b/examples/lpc55s69/src/bin/button_executor.rs new file mode 100644 index 000000000..836b1c9eb --- /dev/null +++ b/examples/lpc55s69/src/bin/button_executor.rs | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | //! This example has been made with the LPCXpresso55S69 board in mind, which has a built-in LED on | ||
| 2 | //! PIO1_6 and a button (labeled "user") on PIO1_9. | ||
| 3 | |||
| 4 | #![no_std] | ||
| 5 | #![no_main] | ||
| 6 | |||
| 7 | use defmt::*; | ||
| 8 | use embassy_executor::Spawner; | ||
| 9 | use embassy_nxp::gpio::{Input, Level, Output, Pull}; | ||
| 10 | use {defmt_rtt as _, panic_halt as _}; | ||
| 11 | |||
| 12 | #[embassy_executor::main] | ||
| 13 | async fn main(_spawner: Spawner) -> ! { | ||
| 14 | let p = embassy_nxp::init(Default::default()); | ||
| 15 | |||
| 16 | let mut led = Output::new(p.PIO1_6, Level::Low); | ||
| 17 | let mut button = Input::new(p.PIO1_9, Pull::Up); | ||
| 18 | |||
| 19 | info!("Entered main loop"); | ||
| 20 | loop { | ||
| 21 | button.wait_for_rising_edge().await; | ||
| 22 | info!("Button pressed"); | ||
| 23 | led.toggle(); | ||
| 24 | } | ||
| 25 | } | ||
