stm32l0: Use embassy::main
for examples
This commit is contained in:
parent
4ccac69929
commit
cad43587e6
@ -1,4 +1,5 @@
|
||||
pub use super::types::*;
|
||||
use crate::dbgmcu::Dbgmcu;
|
||||
use crate::pac;
|
||||
use crate::peripherals::{self, CRS, RCC, SYSCFG};
|
||||
use crate::rcc::{get_freqs, set_freqs, Clocks};
|
||||
@ -172,11 +173,7 @@ impl<'d> Rcc<'d> {
|
||||
unsafe {
|
||||
pac::RCC.ahbenr().modify(|w| w.set_dma1en(enable_dma));
|
||||
|
||||
pac::DBGMCU.cr().modify(|w| {
|
||||
w.set_dbg_sleep(true);
|
||||
w.set_dbg_standby(true);
|
||||
w.set_dbg_stop(true);
|
||||
});
|
||||
Dbgmcu::enable_all();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,21 +8,20 @@
|
||||
|
||||
#[path = "../example_common.rs"]
|
||||
mod example_common;
|
||||
use embassy_stm32::{
|
||||
gpio::{Level, Output, Speed},
|
||||
rcc::*,
|
||||
};
|
||||
|
||||
use defmt::panic;
|
||||
use embassy::executor::Spawner;
|
||||
use embassy::time::{Duration, Timer};
|
||||
use embassy_stm32::gpio::{Level, Output, Speed};
|
||||
use embassy_stm32::rcc::Rcc;
|
||||
use embassy_stm32::Peripherals;
|
||||
use embedded_hal::digital::v2::OutputPin;
|
||||
use example_common::*;
|
||||
|
||||
use cortex_m_rt::entry;
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
#[embassy::main]
|
||||
async fn main(_spawner: Spawner, mut p: Peripherals) {
|
||||
info!("Hello World!");
|
||||
|
||||
let mut p = embassy_stm32::init(Default::default());
|
||||
|
||||
Rcc::new(p.RCC).enable_debug_wfe(&mut p.DBGMCU, true);
|
||||
|
||||
let mut led = Output::new(p.PB5, Level::High, Speed::Low);
|
||||
@ -30,10 +29,10 @@ fn main() -> ! {
|
||||
loop {
|
||||
info!("high");
|
||||
led.set_high().unwrap();
|
||||
cortex_m::asm::delay(1_000_000);
|
||||
Timer::after(Duration::from_millis(300)).await;
|
||||
|
||||
info!("low");
|
||||
led.set_low().unwrap();
|
||||
cortex_m::asm::delay(1_000_000);
|
||||
Timer::after(Duration::from_millis(300)).await;
|
||||
}
|
||||
}
|
||||
|
@ -8,20 +8,17 @@
|
||||
|
||||
#[path = "../example_common.rs"]
|
||||
mod example_common;
|
||||
use embassy::executor::Executor;
|
||||
use embassy::time::Clock;
|
||||
use embassy::util::Forever;
|
||||
|
||||
use defmt::panic;
|
||||
use embassy::executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{Input, Pull};
|
||||
use embassy_stm32::rcc;
|
||||
use embassy_stm32::{rcc, Peripherals};
|
||||
use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge};
|
||||
use example_common::*;
|
||||
|
||||
use cortex_m_rt::entry;
|
||||
|
||||
#[embassy::task]
|
||||
async fn main_task() {
|
||||
let mut p = embassy_stm32::init(Default::default());
|
||||
#[embassy::main]
|
||||
async fn main(_spawner: Spawner, mut p: Peripherals) {
|
||||
let mut rcc = rcc::Rcc::new(p.RCC);
|
||||
rcc.enable_debug_wfe(&mut p.DBGMCU, true);
|
||||
// Enables SYSCFG
|
||||
@ -39,26 +36,3 @@ async fn main_task() {
|
||||
info!("Released!");
|
||||
}
|
||||
}
|
||||
|
||||
struct ZeroClock;
|
||||
|
||||
impl Clock for ZeroClock {
|
||||
fn now(&self) -> u64 {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
static EXECUTOR: Forever<Executor> = Forever::new();
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
info!("Hello World!");
|
||||
|
||||
unsafe { embassy::time::set_clock(&ZeroClock) };
|
||||
|
||||
let executor = EXECUTOR.put(Executor::new());
|
||||
|
||||
executor.run(|spawner| {
|
||||
unwrap!(spawner.spawn(main_task()));
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user