2021-01-21 19:00:43 +01:00
|
|
|
#![no_std]
|
|
|
|
#![no_main]
|
|
|
|
#![feature(trait_alias)]
|
|
|
|
#![feature(type_alias_impl_trait)]
|
|
|
|
|
|
|
|
#[path = "../example_common.rs"]
|
|
|
|
mod example_common;
|
|
|
|
use example_common::{panic, *};
|
|
|
|
|
|
|
|
use cortex_m_rt::entry;
|
|
|
|
use embassy::executor::{task, Executor};
|
|
|
|
use embassy::gpio::*;
|
|
|
|
use embassy::util::Forever;
|
|
|
|
use embassy_stm32f4::exti;
|
|
|
|
use embassy_stm32f4::interrupt;
|
|
|
|
use futures::pin_mut;
|
2021-02-13 21:41:36 -03:00
|
|
|
use stm32f4xx_hal::prelude::*;
|
2021-01-21 19:00:43 +01:00
|
|
|
use stm32f4xx_hal::stm32;
|
|
|
|
|
|
|
|
static EXTI: Forever<exti::ExtiManager> = Forever::new();
|
|
|
|
|
|
|
|
#[task]
|
2021-02-13 21:41:36 -03:00
|
|
|
async fn run(dp: stm32::Peripherals, _cp: cortex_m::Peripherals) {
|
2021-01-21 19:00:43 +01:00
|
|
|
let gpioa = dp.GPIOA.split();
|
|
|
|
|
|
|
|
let button = gpioa.pa0.into_pull_up_input();
|
|
|
|
|
|
|
|
let exti = EXTI.put(exti::ExtiManager::new(dp.EXTI, dp.SYSCFG.constrain()));
|
|
|
|
let pin = exti.new_pin(button, interrupt::take!(EXTI0));
|
|
|
|
pin_mut!(pin);
|
|
|
|
|
|
|
|
info!("Starting loop");
|
|
|
|
|
|
|
|
loop {
|
|
|
|
pin.as_mut().wait_for_rising_edge().await;
|
|
|
|
info!("edge detected!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static EXECUTOR: Forever<Executor> = Forever::new();
|
|
|
|
|
|
|
|
#[entry]
|
|
|
|
fn main() -> ! {
|
|
|
|
let dp = stm32::Peripherals::take().unwrap();
|
|
|
|
let cp = cortex_m::peripheral::Peripherals::take().unwrap();
|
|
|
|
|
2021-02-02 05:14:52 +01:00
|
|
|
let executor = EXECUTOR.put(Executor::new());
|
|
|
|
executor.run(|spawner| {
|
|
|
|
unwrap!(spawner.spawn(run(dp, cp)));
|
|
|
|
});
|
2021-01-21 19:00:43 +01:00
|
|
|
}
|