diff options
| author | liebman <[email protected]> | 2025-12-18 15:04:45 -0800 |
|---|---|---|
| committer | liebman <[email protected]> | 2025-12-19 07:55:34 -0800 |
| commit | 9008e4ca79a8cea093484f09d02c9ca67e7e2b1f (patch) | |
| tree | 2ef61e05b4d687c8451253b930efae37c309e489 | |
| parent | 905bdfa7662c2ac5d2dfc81219c9704955473253 (diff) | |
low-power: stm32wl5x
| -rw-r--r-- | embassy-stm32/CHANGELOG.md | 1 | ||||
| -rw-r--r-- | embassy-stm32/src/low_power.rs | 47 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/mod.rs | 4 | ||||
| -rw-r--r-- | embassy-stm32/src/rtc/low_power.rs | 4 | ||||
| -rw-r--r-- | embassy-stm32/src/rtc/v3.rs | 4 | ||||
| -rw-r--r-- | examples/stm32wl5x-lp/.cargo/config.toml | 9 | ||||
| -rw-r--r-- | examples/stm32wl5x-lp/Cargo.toml | 39 | ||||
| -rw-r--r-- | examples/stm32wl5x-lp/build.rs | 5 | ||||
| -rw-r--r-- | examples/stm32wl5x-lp/memory.x | 15 | ||||
| -rw-r--r-- | examples/stm32wl5x-lp/src/bin/blinky.rs | 59 |
10 files changed, 168 insertions, 19 deletions
diff --git a/embassy-stm32/CHANGELOG.md b/embassy-stm32/CHANGELOG.md index 9e0d69078..ae2c0168b 100644 --- a/embassy-stm32/CHANGELOG.md +++ b/embassy-stm32/CHANGELOG.md | |||
| @@ -73,6 +73,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
| 73 | - low-power: update rtc api to allow reconfig | 73 | - low-power: update rtc api to allow reconfig |
| 74 | - adc: consolidate ringbuffer | 74 | - adc: consolidate ringbuffer |
| 75 | - feat: Added RTC low-power support for STM32WLEx ([#4716](https://github.com/embassy-rs/embassy/pull/4716)) | 75 | - feat: Added RTC low-power support for STM32WLEx ([#4716](https://github.com/embassy-rs/embassy/pull/4716)) |
| 76 | - feat: Added low-power support for STM32WL5x ([#5108](https://github.com/embassy-rs/embassy/pull/5108)) | ||
| 76 | - fix: Correct STM32WBA VREFBUFTRIM values | 77 | - fix: Correct STM32WBA VREFBUFTRIM values |
| 77 | - low_power: remove stop_with rtc and initialize in init if low-power feature enabled. | 78 | - low_power: remove stop_with rtc and initialize in init if low-power feature enabled. |
| 78 | - feat: stm32/dsi support zero parameter commands in `write_cmd` ([#4847](https://github.com/embassy-rs/embassy/pull/4847)) | 79 | - feat: stm32/dsi support zero parameter commands in `write_cmd` ([#4847](https://github.com/embassy-rs/embassy/pull/4847)) |
diff --git a/embassy-stm32/src/low_power.rs b/embassy-stm32/src/low_power.rs index 02116e08a..71befcf34 100644 --- a/embassy-stm32/src/low_power.rs +++ b/embassy-stm32/src/low_power.rs | |||
| @@ -136,10 +136,10 @@ pub fn stop_ready(stop_mode: StopMode) -> bool { | |||
| 136 | }) | 136 | }) |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | #[cfg(any(stm32l4, stm32l5, stm32u5, stm32wba, stm32wb, stm32wlex, stm32u0))] | 139 | #[cfg(any(stm32l4, stm32l5, stm32u5, stm32wba, stm32wb, stm32wl, stm32u0))] |
| 140 | use crate::pac::pwr::vals::Lpms; | 140 | use crate::pac::pwr::vals::Lpms; |
| 141 | 141 | ||
| 142 | #[cfg(any(stm32l4, stm32l5, stm32u5, stm32wba, stm32wb, stm32wlex, stm32u0))] | 142 | #[cfg(any(stm32l4, stm32l5, stm32u5, stm32wba, stm32wb, stm32wl, stm32u0))] |
| 143 | impl Into<Lpms> for StopMode { | 143 | impl Into<Lpms> for StopMode { |
| 144 | fn into(self) -> Lpms { | 144 | fn into(self) -> Lpms { |
| 145 | match self { | 145 | match self { |
| @@ -184,19 +184,28 @@ impl Executor { | |||
| 184 | 184 | ||
| 185 | pub(crate) unsafe fn on_wakeup_irq_or_event() { | 185 | pub(crate) unsafe fn on_wakeup_irq_or_event() { |
| 186 | if !get_driver().is_stopped() { | 186 | if !get_driver().is_stopped() { |
| 187 | trace!("low power: time driver not stopped!"); | ||
| 187 | return; | 188 | return; |
| 188 | } | 189 | } |
| 189 | 190 | ||
| 190 | critical_section::with(|cs| { | 191 | critical_section::with(|cs| { |
| 191 | #[cfg(any(stm32wlex, stm32wb))] | 192 | #[cfg(any(stm32wl, stm32wb))] |
| 192 | { | 193 | { |
| 193 | let es = crate::pac::PWR.extscr().read(); | 194 | let es = crate::pac::PWR.extscr().read(); |
| 194 | #[cfg(stm32wlex)] | 195 | #[cfg(stm32wl)] |
| 195 | match (es.c1stopf(), es.c1stop2f()) { | 196 | match (es.c1stopf(), es.c1stop2f()) { |
| 196 | (true, false) => debug!("low power: wake from STOP1"), | 197 | (true, false) => debug!("low power: cpu1 wake from STOP1"), |
| 197 | (false, true) => debug!("low power: wake from STOP2"), | 198 | (false, true) => debug!("low power: cpu1 wake from STOP2"), |
| 198 | (true, true) => debug!("low power: wake from STOP1 and STOP2 ???"), | 199 | (true, true) => debug!("low power: cpu1 wake from STOP1 and STOP2 ???"), |
| 199 | (false, false) => trace!("low power: stop mode not entered"), | 200 | (false, false) => trace!("low power: cpu1 stop mode not entered"), |
| 201 | }; | ||
| 202 | #[cfg(stm32wl5x)] | ||
| 203 | // TODO: only for the current cpu | ||
| 204 | match (es.c2stopf(), es.c2stop2f()) { | ||
| 205 | (true, false) => debug!("low power: cpu2 wake from STOP1"), | ||
| 206 | (false, true) => debug!("low power: cpu2 wake from STOP2"), | ||
| 207 | (true, true) => debug!("low power: cpu2 wake from STOP1 and STOP2 ???"), | ||
| 208 | (false, false) => trace!("low power: cpu2 stop mode not entered"), | ||
| 200 | }; | 209 | }; |
| 201 | 210 | ||
| 202 | #[cfg(stm32wb)] | 211 | #[cfg(stm32wb)] |
| @@ -206,9 +215,6 @@ impl Executor { | |||
| 206 | (true, true) => debug!("low power: cpu1 and cpu2 wake from STOP"), | 215 | (true, true) => debug!("low power: cpu1 and cpu2 wake from STOP"), |
| 207 | (false, false) => trace!("low power: stop mode not entered"), | 216 | (false, false) => trace!("low power: stop mode not entered"), |
| 208 | }; | 217 | }; |
| 209 | crate::pac::PWR.extscr().modify(|w| { | ||
| 210 | w.set_c1cssf(false); | ||
| 211 | }); | ||
| 212 | 218 | ||
| 213 | let _has_stopped2 = { | 219 | let _has_stopped2 = { |
| 214 | #[cfg(stm32wb)] | 220 | #[cfg(stm32wb)] |
| @@ -220,6 +226,12 @@ impl Executor { | |||
| 220 | { | 226 | { |
| 221 | es.c1stop2f() | 227 | es.c1stop2f() |
| 222 | } | 228 | } |
| 229 | |||
| 230 | #[cfg(stm32wl5x)] | ||
| 231 | { | ||
| 232 | // TODO: I think we could just use c1stop2f() here as it won't enter a stop mode unless BOTH cpus will enter it. | ||
| 233 | es.c1stop2f() | es.c2stop2f() | ||
| 234 | } | ||
| 223 | }; | 235 | }; |
| 224 | 236 | ||
| 225 | #[cfg(not(stm32wb))] | 237 | #[cfg(not(stm32wb))] |
| @@ -235,6 +247,13 @@ impl Executor { | |||
| 235 | REFCOUNT_STOP1 = 0; | 247 | REFCOUNT_STOP1 = 0; |
| 236 | } | 248 | } |
| 237 | } | 249 | } |
| 250 | // Clear all stop flags | ||
| 251 | #[cfg(stm32wl)] | ||
| 252 | crate::pac::PWR.extscr().modify(|w| { | ||
| 253 | w.set_c1cssf(true); | ||
| 254 | #[cfg(stm32wl5x)] | ||
| 255 | w.set_c2cssf(true); | ||
| 256 | }); | ||
| 238 | } | 257 | } |
| 239 | get_driver().resume_time(cs); | 258 | get_driver().resume_time(cs); |
| 240 | 259 | ||
| @@ -337,7 +356,7 @@ impl Executor { | |||
| 337 | #[cfg(all(stm32wb, feature = "low-power"))] | 356 | #[cfg(all(stm32wb, feature = "low-power"))] |
| 338 | self.configure_stop_stm32wb(_cs)?; | 357 | self.configure_stop_stm32wb(_cs)?; |
| 339 | 358 | ||
| 340 | #[cfg(any(stm32l4, stm32l5, stm32u5, stm32u0, stm32wb, stm32wba, stm32wlex))] | 359 | #[cfg(any(stm32l4, stm32l5, stm32u5, stm32u0, stm32wb, stm32wba, stm32wl))] |
| 341 | crate::pac::PWR.cr1().modify(|m| m.set_lpms(stop_mode.into())); | 360 | crate::pac::PWR.cr1().modify(|m| m.set_lpms(stop_mode.into())); |
| 342 | #[cfg(stm32h5)] | 361 | #[cfg(stm32h5)] |
| 343 | crate::pac::PWR.pmcr().modify(|v| { | 362 | crate::pac::PWR.pmcr().modify(|v| { |
| @@ -352,9 +371,11 @@ impl Executor { | |||
| 352 | fn configure_pwr(&self) { | 371 | fn configure_pwr(&self) { |
| 353 | Self::get_scb().clear_sleepdeep(); | 372 | Self::get_scb().clear_sleepdeep(); |
| 354 | // Clear any previous stop flags | 373 | // Clear any previous stop flags |
| 355 | #[cfg(stm32wlex)] | 374 | #[cfg(stm32wl)] |
| 356 | crate::pac::PWR.extscr().modify(|w| { | 375 | crate::pac::PWR.extscr().modify(|w| { |
| 357 | w.set_c1cssf(true); | 376 | w.set_c1cssf(true); |
| 377 | #[cfg(stm32wl5x)] | ||
| 378 | w.set_c2cssf(true); | ||
| 358 | }); | 379 | }); |
| 359 | 380 | ||
| 360 | #[cfg(feature = "low-power-pender")] | 381 | #[cfg(feature = "low-power-pender")] |
diff --git a/embassy-stm32/src/rcc/mod.rs b/embassy-stm32/src/rcc/mod.rs index 753ee1290..c0a50615e 100644 --- a/embassy-stm32/src/rcc/mod.rs +++ b/embassy-stm32/src/rcc/mod.rs | |||
| @@ -313,7 +313,7 @@ impl RccInfo { | |||
| 313 | 313 | ||
| 314 | #[allow(dead_code)] | 314 | #[allow(dead_code)] |
| 315 | fn increment_minimum_stop_refcount_with_cs(&self, _cs: CriticalSection) { | 315 | fn increment_minimum_stop_refcount_with_cs(&self, _cs: CriticalSection) { |
| 316 | #[cfg(all(any(stm32wlex, stm32wb), feature = "low-power"))] | 316 | #[cfg(all(any(stm32wl, stm32wb), feature = "low-power"))] |
| 317 | match self.stop_mode { | 317 | match self.stop_mode { |
| 318 | StopMode::Stop1 | StopMode::Stop2 => increment_stop_refcount(_cs, StopMode::Stop2), | 318 | StopMode::Stop1 | StopMode::Stop2 => increment_stop_refcount(_cs, StopMode::Stop2), |
| 319 | _ => {} | 319 | _ => {} |
| @@ -334,7 +334,7 @@ impl RccInfo { | |||
| 334 | 334 | ||
| 335 | #[allow(dead_code)] | 335 | #[allow(dead_code)] |
| 336 | fn decrement_minimum_stop_refcount_with_cs(&self, _cs: CriticalSection) { | 336 | fn decrement_minimum_stop_refcount_with_cs(&self, _cs: CriticalSection) { |
| 337 | #[cfg(all(any(stm32wlex, stm32wb), feature = "low-power"))] | 337 | #[cfg(all(any(stm32wl, stm32wb), feature = "low-power"))] |
| 338 | match self.stop_mode { | 338 | match self.stop_mode { |
| 339 | StopMode::Stop1 | StopMode::Stop2 => decrement_stop_refcount(_cs, StopMode::Stop2), | 339 | StopMode::Stop1 | StopMode::Stop2 => decrement_stop_refcount(_cs, StopMode::Stop2), |
| 340 | _ => {} | 340 | _ => {} |
diff --git a/embassy-stm32/src/rtc/low_power.rs b/embassy-stm32/src/rtc/low_power.rs index cd5cea081..e15eddc22 100644 --- a/embassy-stm32/src/rtc/low_power.rs +++ b/embassy-stm32/src/rtc/low_power.rs | |||
| @@ -114,11 +114,11 @@ impl Rtc { | |||
| 114 | use crate::pac::EXTI; | 114 | use crate::pac::EXTI; |
| 115 | EXTI.rtsr(0).modify(|w| w.set_line(RTC::EXTI_WAKEUP_LINE, true)); | 115 | EXTI.rtsr(0).modify(|w| w.set_line(RTC::EXTI_WAKEUP_LINE, true)); |
| 116 | 116 | ||
| 117 | #[cfg(not(stm32wb))] | 117 | #[cfg(not(any(stm32wb, stm32wl5x)))] |
| 118 | { | 118 | { |
| 119 | EXTI.imr(0).modify(|w| w.set_line(RTC::EXTI_WAKEUP_LINE, true)); | 119 | EXTI.imr(0).modify(|w| w.set_line(RTC::EXTI_WAKEUP_LINE, true)); |
| 120 | } | 120 | } |
| 121 | #[cfg(stm32wb)] | 121 | #[cfg(any(stm32wb, stm32wl5x))] |
| 122 | { | 122 | { |
| 123 | EXTI.cpu(0).imr(0).modify(|w| w.set_line(RTC::EXTI_WAKEUP_LINE, true)); | 123 | EXTI.cpu(0).imr(0).modify(|w| w.set_line(RTC::EXTI_WAKEUP_LINE, true)); |
| 124 | } | 124 | } |
diff --git a/embassy-stm32/src/rtc/v3.rs b/embassy-stm32/src/rtc/v3.rs index f7ebea73e..49c9778df 100644 --- a/embassy-stm32/src/rtc/v3.rs +++ b/embassy-stm32/src/rtc/v3.rs | |||
| @@ -131,7 +131,7 @@ impl SealedInstance for crate::peripherals::RTC { | |||
| 131 | 131 | ||
| 132 | #[cfg(feature = "low-power")] | 132 | #[cfg(feature = "low-power")] |
| 133 | cfg_if::cfg_if!( | 133 | cfg_if::cfg_if!( |
| 134 | if #[cfg(any(stm32g4, stm32wlex))] { | 134 | if #[cfg(any(stm32g4, stm32wl))] { |
| 135 | const EXTI_WAKEUP_LINE: usize = 20; | 135 | const EXTI_WAKEUP_LINE: usize = 20; |
| 136 | } else if #[cfg(stm32g0)] { | 136 | } else if #[cfg(stm32g0)] { |
| 137 | const EXTI_WAKEUP_LINE: usize = 19; | 137 | const EXTI_WAKEUP_LINE: usize = 19; |
| @@ -142,7 +142,7 @@ impl SealedInstance for crate::peripherals::RTC { | |||
| 142 | 142 | ||
| 143 | #[cfg(feature = "low-power")] | 143 | #[cfg(feature = "low-power")] |
| 144 | cfg_if::cfg_if!( | 144 | cfg_if::cfg_if!( |
| 145 | if #[cfg(any(stm32g4, stm32wlex))] { | 145 | if #[cfg(any(stm32g4, stm32wl))] { |
| 146 | type WakeupInterrupt = crate::interrupt::typelevel::RTC_WKUP; | 146 | type WakeupInterrupt = crate::interrupt::typelevel::RTC_WKUP; |
| 147 | } else if #[cfg(any(stm32g0, stm32u0))] { | 147 | } else if #[cfg(any(stm32g0, stm32u0))] { |
| 148 | type WakeupInterrupt = crate::interrupt::typelevel::RTC_TAMP; | 148 | type WakeupInterrupt = crate::interrupt::typelevel::RTC_TAMP; |
diff --git a/examples/stm32wl5x-lp/.cargo/config.toml b/examples/stm32wl5x-lp/.cargo/config.toml new file mode 100644 index 000000000..969068656 --- /dev/null +++ b/examples/stm32wl5x-lp/.cargo/config.toml | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] | ||
| 2 | # replace your chip as listed in `probe-rs chip list` | ||
| 3 | runner = "probe-rs run --chip STM32WLE5JCIx --connect-under-reset" | ||
| 4 | |||
| 5 | [build] | ||
| 6 | target = "thumbv7em-none-eabi" | ||
| 7 | |||
| 8 | [env] | ||
| 9 | DEFMT_LOG = "debug" | ||
diff --git a/examples/stm32wl5x-lp/Cargo.toml b/examples/stm32wl5x-lp/Cargo.toml new file mode 100644 index 000000000..b1823fb8a --- /dev/null +++ b/examples/stm32wl5x-lp/Cargo.toml | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | [package] | ||
| 2 | edition = "2024" | ||
| 3 | name = "embassy-stm32wl5x-lp" | ||
| 4 | version = "0.1.0" | ||
| 5 | license = "MIT OR Apache-2.0" | ||
| 6 | publish = false | ||
| 7 | |||
| 8 | [dependencies] | ||
| 9 | # Change stm32wl55jc-cm4 to your chip name, if necessary. | ||
| 10 | embassy-stm32 = { version = "0.4.0", path = "../../embassy-stm32", features = ["defmt", "stm32wl55jc-cm4", "time-driver-any", "memory-x", "unstable-pac", "exti", "chrono", "low-power-pender"] } | ||
| 11 | embassy-sync = { version = "0.7.2", path = "../../embassy-sync", features = ["defmt"] } | ||
| 12 | embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["defmt"] } | ||
| 13 | embassy-time = { version = "0.5.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | ||
| 14 | embassy-embedded-hal = { version = "0.5.0", path = "../../embassy-embedded-hal" } | ||
| 15 | |||
| 16 | defmt = "1.0.1" | ||
| 17 | defmt-rtt = { version = "1.1.0", optional = true } | ||
| 18 | defmt-serial = { git = "https://github.com/gauteh/defmt-serial", rev = "411ae7fa909b4fd2667885aff687e009b9108190", optional = true } | ||
| 19 | |||
| 20 | cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } | ||
| 21 | cortex-m-rt = "0.7.0" | ||
| 22 | embedded-hal = "1.0.0" | ||
| 23 | embedded-storage = "0.3.1" | ||
| 24 | panic-probe = { version = "1.0.0", features = ["print-defmt"] } | ||
| 25 | chrono = { version = "^0.4", default-features = false } | ||
| 26 | static_cell = { version = "2.1.1", default-features = false } | ||
| 27 | |||
| 28 | [profile.release] | ||
| 29 | debug = 2 | ||
| 30 | |||
| 31 | [package.metadata.embassy] | ||
| 32 | build = [ | ||
| 33 | { target = "thumbv7em-none-eabi", artifact-dir = "out/examples/stm32wl" } | ||
| 34 | ] | ||
| 35 | |||
| 36 | [features] | ||
| 37 | default = ["defmt-serial"] | ||
| 38 | defmt-rtt = ["dep:defmt-rtt"] | ||
| 39 | defmt-serial = ["dep:defmt-serial"] | ||
diff --git a/examples/stm32wl5x-lp/build.rs b/examples/stm32wl5x-lp/build.rs new file mode 100644 index 000000000..8cd32d7ed --- /dev/null +++ b/examples/stm32wl5x-lp/build.rs | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | fn main() { | ||
| 2 | println!("cargo:rustc-link-arg-bins=--nmagic"); | ||
| 3 | println!("cargo:rustc-link-arg-bins=-Tlink.x"); | ||
| 4 | println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); | ||
| 5 | } | ||
diff --git a/examples/stm32wl5x-lp/memory.x b/examples/stm32wl5x-lp/memory.x new file mode 100644 index 000000000..4590867a8 --- /dev/null +++ b/examples/stm32wl5x-lp/memory.x | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | MEMORY | ||
| 2 | { | ||
| 3 | /* NOTE 1 K = 1 KiBi = 1024 bytes */ | ||
| 4 | FLASH : ORIGIN = 0x08000000, LENGTH = 256K | ||
| 5 | SHARED_RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 128 | ||
| 6 | RAM (rwx) : ORIGIN = 0x20000080, LENGTH = 64K - 128 | ||
| 7 | } | ||
| 8 | |||
| 9 | SECTIONS | ||
| 10 | { | ||
| 11 | .shared_data : | ||
| 12 | { | ||
| 13 | *(.shared_data) | ||
| 14 | } > SHARED_RAM | ||
| 15 | } | ||
diff --git a/examples/stm32wl5x-lp/src/bin/blinky.rs b/examples/stm32wl5x-lp/src/bin/blinky.rs new file mode 100644 index 000000000..068b65248 --- /dev/null +++ b/examples/stm32wl5x-lp/src/bin/blinky.rs | |||
| @@ -0,0 +1,59 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | |||
| 4 | use core::mem::MaybeUninit; | ||
| 5 | |||
| 6 | use defmt::*; | ||
| 7 | #[cfg(feature = "defmt-rtt")] | ||
| 8 | use defmt_rtt as _; | ||
| 9 | use embassy_executor::Spawner; | ||
| 10 | use embassy_stm32::SharedData; | ||
| 11 | use embassy_stm32::gpio::{Level, Output, Speed}; | ||
| 12 | use embassy_time::Timer; | ||
| 13 | use panic_probe as _; | ||
| 14 | |||
| 15 | #[unsafe(link_section = ".shared_data")] | ||
| 16 | static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit(); | ||
| 17 | |||
| 18 | #[embassy_executor::main(executor = "embassy_stm32::Executor", entry = "cortex_m_rt::entry")] | ||
| 19 | async fn async_main(_spawner: Spawner) { | ||
| 20 | let mut config = embassy_stm32::Config::default(); | ||
| 21 | // enable HSI clock | ||
| 22 | // config.rcc.hsi = true; | ||
| 23 | // enable LSI clock for RTC | ||
| 24 | config.rcc.ls = embassy_stm32::rcc::LsConfig::default_lsi(); | ||
| 25 | config.rcc.msi = Some(embassy_stm32::rcc::MSIRange::RANGE4M); | ||
| 26 | config.rcc.sys = embassy_stm32::rcc::Sysclk::MSI; | ||
| 27 | #[cfg(feature = "defmt-serial")] | ||
| 28 | { | ||
| 29 | // disable debug during sleep to reduce power consumption since we are | ||
| 30 | // using defmt-serial on LPUART1. | ||
| 31 | config.enable_debug_during_sleep = false; | ||
| 32 | } | ||
| 33 | let p = embassy_stm32::init_primary(config, &SHARED_DATA); | ||
| 34 | |||
| 35 | #[cfg(feature = "defmt-serial")] | ||
| 36 | { | ||
| 37 | use embassy_stm32::mode::Blocking; | ||
| 38 | use embassy_stm32::usart::Uart; | ||
| 39 | use static_cell::StaticCell; | ||
| 40 | let config = embassy_stm32::usart::Config::default(); | ||
| 41 | let uart = Uart::new_blocking(p.LPUART1, p.PA3, p.PA2, config).expect("failed to configure UART!"); | ||
| 42 | static SERIAL: StaticCell<Uart<'static, Blocking>> = StaticCell::new(); | ||
| 43 | defmt_serial::defmt_serial(SERIAL.init(uart)); | ||
| 44 | } | ||
| 45 | |||
| 46 | info!("Hello World!"); | ||
| 47 | |||
| 48 | let mut led = Output::new(p.PB15, Level::High, Speed::Low); | ||
| 49 | |||
| 50 | loop { | ||
| 51 | info!("low"); | ||
| 52 | led.set_low(); | ||
| 53 | Timer::after_millis(5000).await; | ||
| 54 | |||
| 55 | info!("high"); | ||
| 56 | led.set_high(); | ||
| 57 | Timer::after_millis(5000).await; | ||
| 58 | } | ||
| 59 | } | ||
