aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorliebman <[email protected]>2025-12-13 10:01:57 -0800
committerliebman <[email protected]>2025-12-13 10:01:57 -0800
commit67a67c7d3cd9a5e2b917b108bfdebc858a2f79a3 (patch)
treefe24d4fdd9804cecf1e0a99e88d66b629f029a5b
parent803b809e5dbe7651b7171917e02289b067e90dad (diff)
stm32: update stm32wle5 low powe examples
-rw-r--r--examples/stm32wle5/src/bin/adc.rs18
-rw-r--r--examples/stm32wle5/src/bin/blinky.rs22
-rw-r--r--examples/stm32wle5/src/bin/button_exti.rs18
-rw-r--r--examples/stm32wle5/src/bin/i2c.rs23
4 files changed, 5 insertions, 76 deletions
diff --git a/examples/stm32wle5/src/bin/adc.rs b/examples/stm32wle5/src/bin/adc.rs
index ea91fb063..8cc84ccdf 100644
--- a/examples/stm32wle5/src/bin/adc.rs
+++ b/examples/stm32wle5/src/bin/adc.rs
@@ -34,24 +34,6 @@ async fn async_main(_spawner: Spawner) {
34 // Initialize STM32WL peripherals (use default config like wio-e5-async example) 34 // Initialize STM32WL peripherals (use default config like wio-e5-async example)
35 let p = embassy_stm32::init(config); 35 let p = embassy_stm32::init(config);
36 36
37 // start with all GPIOs as analog to reduce power consumption
38 for r in [
39 embassy_stm32::pac::GPIOA,
40 embassy_stm32::pac::GPIOB,
41 embassy_stm32::pac::GPIOC,
42 embassy_stm32::pac::GPIOH,
43 ] {
44 r.moder().modify(|w| {
45 for i in 0..16 {
46 // don't reset these if probe-rs should stay connected!
47 #[cfg(feature = "defmt-rtt")]
48 if config.enable_debug_during_sleep && r == embassy_stm32::pac::GPIOA && [13, 14].contains(&i) {
49 continue;
50 }
51 w.set_moder(i, embassy_stm32::pac::gpio::vals::Moder::ANALOG);
52 }
53 });
54 }
55 #[cfg(feature = "defmt-serial")] 37 #[cfg(feature = "defmt-serial")]
56 { 38 {
57 use embassy_stm32::mode::Blocking; 39 use embassy_stm32::mode::Blocking;
diff --git a/examples/stm32wle5/src/bin/blinky.rs b/examples/stm32wle5/src/bin/blinky.rs
index 9f0c04672..3b7eb7761 100644
--- a/examples/stm32wle5/src/bin/blinky.rs
+++ b/examples/stm32wle5/src/bin/blinky.rs
@@ -32,24 +32,6 @@ async fn async_main(_spawner: Spawner) {
32 // Initialize STM32WL peripherals (use default config like wio-e5-async example) 32 // Initialize STM32WL peripherals (use default config like wio-e5-async example)
33 let p = embassy_stm32::init(config); 33 let p = embassy_stm32::init(config);
34 34
35 // start with all GPIOs as analog to reduce power consumption
36 for r in [
37 embassy_stm32::pac::GPIOA,
38 embassy_stm32::pac::GPIOB,
39 embassy_stm32::pac::GPIOC,
40 embassy_stm32::pac::GPIOH,
41 ] {
42 r.moder().modify(|w| {
43 for i in 0..16 {
44 // don't reset these if probe-rs should stay connected!
45 #[cfg(feature = "defmt-rtt")]
46 if config.enable_debug_during_sleep && r == embassy_stm32::pac::GPIOA && [13, 14].contains(&i) {
47 continue;
48 }
49 w.set_moder(i, embassy_stm32::pac::gpio::vals::Moder::ANALOG);
50 }
51 });
52 }
53 #[cfg(feature = "defmt-serial")] 35 #[cfg(feature = "defmt-serial")]
54 { 36 {
55 use embassy_stm32::mode::Blocking; 37 use embassy_stm32::mode::Blocking;
@@ -67,10 +49,10 @@ async fn async_main(_spawner: Spawner) {
67 loop { 49 loop {
68 info!("low"); 50 info!("low");
69 led.set_low(); 51 led.set_low();
70 Timer::after_millis(500).await; 52 Timer::after_millis(15000).await;
71 53
72 info!("high"); 54 info!("high");
73 led.set_high(); 55 led.set_high();
74 Timer::after_millis(500).await; 56 Timer::after_millis(15000).await;
75 } 57 }
76} 58}
diff --git a/examples/stm32wle5/src/bin/button_exti.rs b/examples/stm32wle5/src/bin/button_exti.rs
index f248b6147..9ffc39948 100644
--- a/examples/stm32wle5/src/bin/button_exti.rs
+++ b/examples/stm32wle5/src/bin/button_exti.rs
@@ -39,24 +39,6 @@ async fn async_main(_spawner: Spawner) {
39 // Initialize STM32WL peripherals (use default config like wio-e5-async example) 39 // Initialize STM32WL peripherals (use default config like wio-e5-async example)
40 let p = embassy_stm32::init(config); 40 let p = embassy_stm32::init(config);
41 41
42 // start with all GPIOs as analog to reduce power consumption
43 for r in [
44 embassy_stm32::pac::GPIOA,
45 embassy_stm32::pac::GPIOB,
46 embassy_stm32::pac::GPIOC,
47 embassy_stm32::pac::GPIOH,
48 ] {
49 r.moder().modify(|w| {
50 for i in 0..16 {
51 // don't reset these if probe-rs should stay connected!
52 #[cfg(feature = "defmt-rtt")]
53 if config.enable_debug_during_sleep && r == embassy_stm32::pac::GPIOA && [13, 14].contains(&i) {
54 continue;
55 }
56 w.set_moder(i, embassy_stm32::pac::gpio::vals::Moder::ANALOG);
57 }
58 });
59 }
60 #[cfg(feature = "defmt-serial")] 42 #[cfg(feature = "defmt-serial")]
61 { 43 {
62 use embassy_stm32::mode::Blocking; 44 use embassy_stm32::mode::Blocking;
diff --git a/examples/stm32wle5/src/bin/i2c.rs b/examples/stm32wle5/src/bin/i2c.rs
index 68c17a672..bd94c061f 100644
--- a/examples/stm32wle5/src/bin/i2c.rs
+++ b/examples/stm32wle5/src/bin/i2c.rs
@@ -40,24 +40,6 @@ async fn async_main(_spawner: Spawner) {
40 // Initialize STM32WL peripherals (use default config like wio-e5-async example) 40 // Initialize STM32WL peripherals (use default config like wio-e5-async example)
41 let p = embassy_stm32::init(config); 41 let p = embassy_stm32::init(config);
42 42
43 // start with all GPIOs as analog to reduce power consumption
44 for r in [
45 embassy_stm32::pac::GPIOA,
46 embassy_stm32::pac::GPIOB,
47 embassy_stm32::pac::GPIOC,
48 embassy_stm32::pac::GPIOH,
49 ] {
50 r.moder().modify(|w| {
51 for i in 0..16 {
52 // don't reset these if probe-rs should stay connected!
53 #[cfg(feature = "defmt-rtt")]
54 if config.enable_debug_during_sleep && r == embassy_stm32::pac::GPIOA && [13, 14].contains(&i) {
55 continue;
56 }
57 w.set_moder(i, embassy_stm32::pac::gpio::vals::Moder::ANALOG);
58 }
59 });
60 }
61 #[cfg(feature = "defmt-serial")] 43 #[cfg(feature = "defmt-serial")]
62 { 44 {
63 use embassy_stm32::mode::Blocking; 45 use embassy_stm32::mode::Blocking;
@@ -79,14 +61,15 @@ async fn async_main(_spawner: Spawner) {
79 let mut i2c = I2c::new(p.I2C2, p.PB15, p.PA15, IrqsI2C, p.DMA1_CH6, p.DMA1_CH7, { 61 let mut i2c = I2c::new(p.I2C2, p.PB15, p.PA15, IrqsI2C, p.DMA1_CH6, p.DMA1_CH7, {
80 let mut config = i2c::Config::default(); 62 let mut config = i2c::Config::default();
81 config.frequency = Hertz::khz(100); 63 config.frequency = Hertz::khz(100);
82 config.timeout = Duration::from_millis(500); 64 config.timeout = Duration::from_millis(1000);
83 config 65 config
84 }); 66 });
85 67
68 let _device_busy = low_power::DeviceBusy::new_stop2();
86 loop { 69 loop {
87 let mut buffer = [0; 2]; 70 let mut buffer = [0; 2];
88 // read the temperature register of the onboard lm75 71 // read the temperature register of the onboard lm75
89 match i2c.read(0x48, &mut buffer).await { 72 match i2c.write_read(0x48, &[0x00], &mut buffer).await {
90 Ok(_) => info!("--> {:?}", buffer), 73 Ok(_) => info!("--> {:?}", buffer),
91 Err(e) => info!("--> Error: {:?}", e), 74 Err(e) => info!("--> Error: {:?}", e),
92 } 75 }