diff options
| author | xoviat <[email protected]> | 2025-12-13 23:19:46 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-12-13 23:19:46 +0000 |
| commit | 574868282518ceb81bddcb03bee38fc5b6208a5a (patch) | |
| tree | 2c9ba989a39bbca1d8a452419319648f424bd2e0 /examples | |
| parent | d2740f8fad566f30bed24df970f1297209005126 (diff) | |
| parent | edc58c3f1122196313dada19f0068bb948775f12 (diff) | |
Merge pull request #5059 from liebman/stm32-init-gpio-analog
stm32: set pins to ANALOG on init
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/stm32wle5/src/bin/adc.rs | 18 | ||||
| -rw-r--r-- | examples/stm32wle5/src/bin/blinky.rs | 22 | ||||
| -rw-r--r-- | examples/stm32wle5/src/bin/button_exti.rs | 18 | ||||
| -rw-r--r-- | examples/stm32wle5/src/bin/i2c.rs | 20 |
4 files changed, 3 insertions, 75 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..8e7a6e2d8 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,7 +61,7 @@ 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 | ||
