Skip to content

Commit

Permalink
feat(gpio): add embassy async button input demo
Browse files Browse the repository at this point in the history
  • Loading branch information
andelf committed Jun 24, 2024
1 parent 93931bf commit 8bb15cb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ This crate is a working-in-progress and not ready for use.

- Peripherals:
- [x] basic start up code: linker, startup
- [x] Embassy time driver using MCHTMR
- [x] SYSCTL init
- [x] PLL setting (only PLL0 is supported, since others might be unsafe)
- [x] GPIO, Flex, Input, Output
- [x] Async GPIO
- [x] RTT support (defmt, defmt-rtt)
- [x] UART support
- [x] blocking TX, RX
- [x] I2C support
- [x] blocking, eh traits
- [x] UART blocking TX, RX
- [x] I2C blocking
- MCUs
- HPM5300 - currently it's the only supported series

Expand Down
27 changes: 27 additions & 0 deletions examples/embassy_button.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#![no_main]
#![no_std]
#![feature(type_alias_impl_trait)]

use embassy_executor::Spawner;
use hpm_hal::gpio::{Input, Level, Output, Pull};
use {defmt_rtt as _, hpm_hal as hal};

#[embassy_executor::main(entry = "hpm_hal::entry")]
async fn main(_spawner: Spawner) -> ! {
let p = hal::init(Default::default());

let mut button = Input::new(p.PA03, Pull::Down); // hpm5300evklite, BOOT1_KEY
let mut led = Output::new(p.PA10, Level::Low, Default::default());
loop {
button.wait_for_falling_edge().await;
defmt::info!("PA03 Button pressed! current={}", button.is_high());
led.toggle();
}
}

#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
//let _ = println!("\n\n\n{}", info);

loop {}
}

0 comments on commit 8bb15cb

Please sign in to comment.