diff options
| author | Ulf Lilleengen <[email protected]> | 2024-10-07 08:14:32 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-10-07 08:14:32 +0000 |
| commit | a74bae3de1ede75fa7c1088976e2313733aa2664 (patch) | |
| tree | 7171b12bc551818f9d16bb70846e33aa907c36df /examples/lpc55s69/src/bin/button_executor.rs | |
| parent | 631fec8d092b247b02d4279b8087cceb49146575 (diff) | |
| parent | e7e245eeb77974bf1f374f24cbf5c0bc41f745f1 (diff) | |
Merge pull request #3343 from george-cosma/hal-with-pac
LPC: embassy-lpc55 hal base with gpio and pint driver
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 | } | ||
