aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32wle5/src/bin/blinky.rs
diff options
context:
space:
mode:
authorRaul Alimbekov <[email protected]>2025-12-16 09:05:22 +0300
committerGitHub <[email protected]>2025-12-16 09:05:22 +0300
commitc9a04b4b732b7a3b696eb8223664c1a7942b1875 (patch)
tree6dbe5c02e66eed8d8762f13f95afd24f8db2b38c /examples/stm32wle5/src/bin/blinky.rs
parentcde24a3ef1117653ba5ed4184102b33f745782fb (diff)
parent5ae6e060ec1c90561719aabdc29d5b6e7b8b0a82 (diff)
Merge branch 'main' into main
Diffstat (limited to 'examples/stm32wle5/src/bin/blinky.rs')
-rw-r--r--examples/stm32wle5/src/bin/blinky.rs58
1 files changed, 58 insertions, 0 deletions
diff --git a/examples/stm32wle5/src/bin/blinky.rs b/examples/stm32wle5/src/bin/blinky.rs
new file mode 100644
index 000000000..3b7eb7761
--- /dev/null
+++ b/examples/stm32wle5/src/bin/blinky.rs
@@ -0,0 +1,58 @@
1#![no_std]
2#![no_main]
3
4use defmt::*;
5#[cfg(feature = "defmt-rtt")]
6use defmt_rtt as _;
7use embassy_executor::Spawner;
8use embassy_stm32::gpio::{Level, Output, Speed};
9use embassy_stm32::low_power;
10use embassy_time::Timer;
11use panic_probe as _;
12use static_cell::StaticCell;
13
14#[embassy_executor::main(executor = "low_power::Executor")]
15async fn async_main(_spawner: Spawner) {
16 let mut config = embassy_stm32::Config::default();
17 // enable HSI clock
18 config.rcc.hsi = true;
19 // enable LSI clock for RTC
20 config.rcc.ls = embassy_stm32::rcc::LsConfig::default_lsi();
21 config.rcc.msi = Some(embassy_stm32::rcc::MSIRange::RANGE4M);
22 config.rcc.sys = embassy_stm32::rcc::Sysclk::MSI;
23 #[cfg(feature = "defmt-serial")]
24 {
25 // disable debug during sleep to reduce power consumption since we are
26 // using defmt-serial on LPUART1.
27 config.enable_debug_during_sleep = false;
28 // if we are using defmt-serial on LPUART1, we need to use HSI for the clock
29 // so that its registers are preserved during STOP modes.
30 config.rcc.mux.lpuart1sel = embassy_stm32::pac::rcc::vals::Lpuart1sel::HSI;
31 }
32 // Initialize STM32WL peripherals (use default config like wio-e5-async example)
33 let p = embassy_stm32::init(config);
34
35 #[cfg(feature = "defmt-serial")]
36 {
37 use embassy_stm32::mode::Blocking;
38 use embassy_stm32::usart::Uart;
39 let config = embassy_stm32::usart::Config::default();
40 let uart = Uart::new_blocking(p.LPUART1, p.PC0, p.PC1, config).expect("failed to configure UART!");
41 static SERIAL: StaticCell<Uart<'static, Blocking>> = StaticCell::new();
42 defmt_serial::defmt_serial(SERIAL.init(uart));
43 }
44
45 info!("Hello World!");
46
47 let mut led = Output::new(p.PB5, Level::High, Speed::Low);
48
49 loop {
50 info!("low");
51 led.set_low();
52 Timer::after_millis(15000).await;
53
54 info!("high");
55 led.set_high();
56 Timer::after_millis(15000).await;
57 }
58}