blob: fde804fb74a631d93d85658deccb72c16aee1656 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#![no_std]
#![no_main]
use defmt::*;
use embassy_executor::Spawner;
use embassy_stm32::gpio::{AnyPin, Level, Output, Speed};
use embassy_stm32::rcc::LsConfig;
use embassy_stm32::{Config, Peri, low_power};
use embassy_time::Timer;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main(executor = "low_power::Executor")]
async fn async_main(spawner: Spawner) {
let mut config = Config::default();
config.rcc.ls = LsConfig::default_lsi();
// when enabled the power-consumption is much higher during stop, but debugging and RTT is working
// if you wan't to measure the power-consumption, or for production: uncomment this line
// config.enable_debug_during_sleep = false;
let p = embassy_stm32::init(config);
spawner.spawn(unwrap!(blinky(p.PC7.into())));
spawner.spawn(unwrap!(timeout()));
}
#[embassy_executor::task]
async fn blinky(led: Peri<'static, AnyPin>) -> ! {
let mut led = Output::new(led, Level::Low, Speed::Low);
loop {
info!("high");
led.set_high();
Timer::after_millis(300).await;
info!("low");
led.set_low();
Timer::after_millis(300).await;
}
}
// when enable_debug_during_sleep is false, it is more difficult to reprogram the MCU
// therefore we block the MCU after 30s to be able to reprogram it easily
#[embassy_executor::task]
async fn timeout() -> ! {
Timer::after_secs(30).await;
loop {}
}
|