aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32wl5x-lp/src
diff options
context:
space:
mode:
authorxoviat <[email protected]>2025-12-19 17:56:09 +0000
committerGitHub <[email protected]>2025-12-19 17:56:09 +0000
commitecb395e9334360994a9201c0ad3e7e921aa2d81a (patch)
tree77fe36797942a3f1bba868bb3fd7229077bef528 /examples/stm32wl5x-lp/src
parent905bdfa7662c2ac5d2dfc81219c9704955473253 (diff)
parent941707372099ae5b82e8adf48ec4d0470a1642de (diff)
Merge pull request #5108 from liebman/low-power-stm32wl5x
low-power: stm32wl5x
Diffstat (limited to 'examples/stm32wl5x-lp/src')
-rw-r--r--examples/stm32wl5x-lp/src/bin/blinky.rs57
1 files changed, 57 insertions, 0 deletions
diff --git a/examples/stm32wl5x-lp/src/bin/blinky.rs b/examples/stm32wl5x-lp/src/bin/blinky.rs
new file mode 100644
index 000000000..60b671a77
--- /dev/null
+++ b/examples/stm32wl5x-lp/src/bin/blinky.rs
@@ -0,0 +1,57 @@
1// This example is configured for the nucleo-wl55jc board. Curret monitor should show just a few microamps when the device is in stop2 mode.
2#![no_std]
3#![no_main]
4
5use core::mem::MaybeUninit;
6
7use defmt::*;
8#[cfg(feature = "defmt-rtt")]
9use defmt_rtt as _;
10use embassy_executor::Spawner;
11use embassy_stm32::SharedData;
12use embassy_stm32::gpio::{Level, Output, Speed};
13use embassy_time::Timer;
14use panic_probe as _;
15
16#[unsafe(link_section = ".shared_data")]
17static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
18
19#[embassy_executor::main(executor = "embassy_stm32::Executor", entry = "cortex_m_rt::entry")]
20async fn async_main(_spawner: Spawner) {
21 let mut config = embassy_stm32::Config::default();
22 config.rcc.ls = embassy_stm32::rcc::LsConfig::default_lsi();
23 config.rcc.msi = Some(embassy_stm32::rcc::MSIRange::RANGE4M);
24 config.rcc.sys = embassy_stm32::rcc::Sysclk::MSI;
25 #[cfg(feature = "defmt-serial")]
26 {
27 // disable debug during sleep to reduce power consumption since we are
28 // using defmt-serial on LPUART1.
29 config.enable_debug_during_sleep = false;
30 }
31 let p = embassy_stm32::init_primary(config, &SHARED_DATA);
32
33 #[cfg(feature = "defmt-serial")]
34 {
35 use embassy_stm32::mode::Blocking;
36 use embassy_stm32::usart::Uart;
37 use static_cell::StaticCell;
38 let config = embassy_stm32::usart::Config::default();
39 let uart = Uart::new_blocking(p.LPUART1, p.PA3, p.PA2, config).expect("failed to configure UART!");
40 static SERIAL: StaticCell<Uart<'static, Blocking>> = StaticCell::new();
41 defmt_serial::defmt_serial(SERIAL.init(uart));
42 }
43
44 info!("Hello World!");
45
46 let mut led = Output::new(p.PB15, Level::High, Speed::Low);
47
48 loop {
49 info!("low");
50 led.set_low();
51 Timer::after_millis(5000).await;
52
53 info!("high");
54 led.set_high();
55 Timer::after_millis(5000).await;
56 }
57}