2021-04-09 23:48:12 +00:00
|
|
|
#![no_std]
|
|
|
|
#![no_main]
|
|
|
|
#![feature(trait_alias)]
|
|
|
|
#![feature(min_type_alias_impl_trait)]
|
|
|
|
#![feature(impl_trait_in_bindings)]
|
|
|
|
#![feature(type_alias_impl_trait)]
|
2021-05-20 08:54:10 +00:00
|
|
|
#![allow(incomplete_features)]
|
2021-04-09 23:48:12 +00:00
|
|
|
|
|
|
|
#[path = "../example_common.rs"]
|
|
|
|
mod example_common;
|
|
|
|
use embassy::executor::Executor;
|
|
|
|
use embassy::util::Forever;
|
2021-07-23 15:49:53 +00:00
|
|
|
use embassy_stm32::dbgmcu::Dbgmcu;
|
2021-05-20 08:54:10 +00:00
|
|
|
use embassy_stm32::exti::ExtiInput;
|
2021-04-09 23:48:12 +00:00
|
|
|
use embassy_stm32::gpio::{Input, Pull};
|
|
|
|
use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge};
|
|
|
|
use example_common::*;
|
|
|
|
|
|
|
|
use cortex_m_rt::entry;
|
|
|
|
|
|
|
|
#[embassy::task]
|
|
|
|
async fn main_task() {
|
2021-05-01 01:07:17 +00:00
|
|
|
let p = embassy_stm32::init(Default::default());
|
|
|
|
|
2021-04-09 23:48:12 +00:00
|
|
|
let button = Input::new(p.PC13, Pull::Down);
|
|
|
|
let mut button = ExtiInput::new(button, p.EXTI13);
|
|
|
|
|
|
|
|
info!("Press the USER button...");
|
|
|
|
|
|
|
|
loop {
|
|
|
|
button.wait_for_rising_edge().await;
|
|
|
|
info!("Pressed!");
|
|
|
|
button.wait_for_falling_edge().await;
|
|
|
|
info!("Released!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static EXECUTOR: Forever<Executor> = Forever::new();
|
|
|
|
|
|
|
|
#[entry]
|
|
|
|
fn main() -> ! {
|
|
|
|
info!("Hello World!");
|
|
|
|
|
2021-07-22 21:12:07 +00:00
|
|
|
unsafe { Dbgmcu::enable_all() }
|
2021-04-09 23:48:12 +00:00
|
|
|
|
|
|
|
let executor = EXECUTOR.put(Executor::new());
|
|
|
|
|
|
|
|
executor.run(|spawner| {
|
|
|
|
unwrap!(spawner.spawn(main_task()));
|
|
|
|
})
|
|
|
|
}
|