From d2127f6b82e7a97744c81e2a3628ced59d8f1b49 Mon Sep 17 00:00:00 2001 From: bofh <123368+bofh@users.noreply.github.com> Date: Sun, 30 Jul 2023 18:58:40 +0200 Subject: [PATCH] Fix stm32 SPI examples --- examples/stm32f3/src/bin/spi_dma.rs | 2 -- examples/stm32f4/src/bin/spi.rs | 12 +----------- examples/stm32f4/src/bin/spi_dma.rs | 2 -- examples/stm32g0/src/bin/spi_neopixel.rs | 4 +++- examples/stm32l0/src/bin/spi.rs | 2 -- examples/stm32l1/src/bin/spi.rs | 2 -- examples/stm32l4/src/bin/spi.rs | 12 +----------- examples/stm32l4/src/bin/spi_blocking_async.rs | 2 -- examples/stm32l4/src/bin/spi_dma.rs | 2 -- 9 files changed, 5 insertions(+), 35 deletions(-) diff --git a/examples/stm32f3/src/bin/spi_dma.rs b/examples/stm32f3/src/bin/spi_dma.rs index 95b2b6865..d8cdb7e65 100644 --- a/examples/stm32f3/src/bin/spi_dma.rs +++ b/examples/stm32f3/src/bin/spi_dma.rs @@ -8,7 +8,6 @@ use core::str::from_utf8; use defmt::*; use embassy_executor::Spawner; use embassy_stm32::spi::{Config, Spi}; -use embassy_stm32::time::Hertz; use heapless::String; use {defmt_rtt as _, panic_probe as _}; @@ -24,7 +23,6 @@ async fn main(_spawner: Spawner) { p.PB4, p.DMA1_CH3, p.DMA1_CH2, - Hertz(1_000_000), Config::default(), ); diff --git a/examples/stm32f4/src/bin/spi.rs b/examples/stm32f4/src/bin/spi.rs index 05b48f478..b0c62b3f0 100644 --- a/examples/stm32f4/src/bin/spi.rs +++ b/examples/stm32f4/src/bin/spi.rs @@ -7,7 +7,6 @@ use defmt::*; use embassy_stm32::dma::NoDma; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::spi::{Config, Spi}; -use embassy_stm32::time::Hertz; use {defmt_rtt as _, panic_probe as _}; #[entry] @@ -16,16 +15,7 @@ fn main() -> ! { let p = embassy_stm32::init(Default::default()); - let mut spi = Spi::new( - p.SPI3, - p.PC10, - p.PC12, - p.PC11, - NoDma, - NoDma, - Hertz(1_000_000), - Config::default(), - ); + let mut spi = Spi::new(p.SPI3, p.PC10, p.PC12, p.PC11, NoDma, NoDma, Config::default()); let mut cs = Output::new(p.PE0, Level::High, Speed::VeryHigh); diff --git a/examples/stm32f4/src/bin/spi_dma.rs b/examples/stm32f4/src/bin/spi_dma.rs index 3d2a1a1ae..d421b9d5f 100644 --- a/examples/stm32f4/src/bin/spi_dma.rs +++ b/examples/stm32f4/src/bin/spi_dma.rs @@ -8,7 +8,6 @@ use core::str::from_utf8; use defmt::*; use embassy_executor::Spawner; use embassy_stm32::spi::{Config, Spi}; -use embassy_stm32::time::Hertz; use heapless::String; use {defmt_rtt as _, panic_probe as _}; @@ -24,7 +23,6 @@ async fn main(_spawner: Spawner) { p.PB4, p.DMA2_CH3, p.DMA2_CH2, - Hertz(1_000_000), Config::default(), ); diff --git a/examples/stm32g0/src/bin/spi_neopixel.rs b/examples/stm32g0/src/bin/spi_neopixel.rs index 81fdd15cb..ee7aaf33f 100644 --- a/examples/stm32g0/src/bin/spi_neopixel.rs +++ b/examples/stm32g0/src/bin/spi_neopixel.rs @@ -76,7 +76,9 @@ async fn main(_spawner: Spawner) { let p = embassy_stm32::init(Default::default()); info!("Start test using spi as neopixel driver"); - let mut spi = Spi::new_txonly_nosck(p.SPI1, p.PB5, p.DMA1_CH3, NoDma, Hertz(4_000_000), Config::default()); + let mut config = Config::default(); + config.frequency = Hertz(4_000_000); + let mut spi = Spi::new_txonly_nosck(p.SPI1, p.PB5, p.DMA1_CH3, NoDma, config); let mut neopixels = Ws2812::new(); diff --git a/examples/stm32l0/src/bin/spi.rs b/examples/stm32l0/src/bin/spi.rs index 9b5b3e27d..54b7a2dd9 100644 --- a/examples/stm32l0/src/bin/spi.rs +++ b/examples/stm32l0/src/bin/spi.rs @@ -7,7 +7,6 @@ use embassy_executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::spi::{Config, Spi}; -use embassy_stm32::time::Hertz; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] @@ -22,7 +21,6 @@ async fn main(_spawner: Spawner) { p.PA6, NoDma, NoDma, - Hertz(1_000_000), Config::default(), ); diff --git a/examples/stm32l1/src/bin/spi.rs b/examples/stm32l1/src/bin/spi.rs index 0a532e8e3..34faf0619 100644 --- a/examples/stm32l1/src/bin/spi.rs +++ b/examples/stm32l1/src/bin/spi.rs @@ -7,7 +7,6 @@ use embassy_executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::spi::{Config, Spi}; -use embassy_stm32::time::Hertz; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] @@ -22,7 +21,6 @@ async fn main(_spawner: Spawner) { p.PA6, NoDma, NoDma, - Hertz(1_000_000), Config::default(), ); diff --git a/examples/stm32l4/src/bin/spi.rs b/examples/stm32l4/src/bin/spi.rs index 76e316a25..a3097fb48 100644 --- a/examples/stm32l4/src/bin/spi.rs +++ b/examples/stm32l4/src/bin/spi.rs @@ -6,7 +6,6 @@ use defmt::*; use embassy_stm32::dma::NoDma; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::spi::{Config, Spi}; -use embassy_stm32::time::Hertz; use {defmt_rtt as _, panic_probe as _}; #[cortex_m_rt::entry] @@ -15,16 +14,7 @@ fn main() -> ! { let p = embassy_stm32::init(Default::default()); - let mut spi = Spi::new( - p.SPI3, - p.PC10, - p.PC12, - p.PC11, - NoDma, - NoDma, - Hertz(1_000_000), - Config::default(), - ); + let mut spi = Spi::new(p.SPI3, p.PC10, p.PC12, p.PC11, NoDma, NoDma, Config::default()); let mut cs = Output::new(p.PE0, Level::High, Speed::VeryHigh); diff --git a/examples/stm32l4/src/bin/spi_blocking_async.rs b/examples/stm32l4/src/bin/spi_blocking_async.rs index 62ef0130e..868e22117 100644 --- a/examples/stm32l4/src/bin/spi_blocking_async.rs +++ b/examples/stm32l4/src/bin/spi_blocking_async.rs @@ -8,7 +8,6 @@ use embassy_executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::spi::{Config, Spi}; -use embassy_stm32::time::Hertz; use embedded_hal_async::spi::SpiBus; use {defmt_rtt as _, panic_probe as _}; @@ -24,7 +23,6 @@ async fn main(_spawner: Spawner) { p.PC11, NoDma, NoDma, - Hertz(1_000_000), Config::default(), ); diff --git a/examples/stm32l4/src/bin/spi_dma.rs b/examples/stm32l4/src/bin/spi_dma.rs index 89471db5a..01265c49b 100644 --- a/examples/stm32l4/src/bin/spi_dma.rs +++ b/examples/stm32l4/src/bin/spi_dma.rs @@ -6,7 +6,6 @@ use defmt::*; use embassy_executor::Spawner; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::spi::{Config, Spi}; -use embassy_stm32::time::Hertz; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] @@ -21,7 +20,6 @@ async fn main(_spawner: Spawner) { p.PC11, p.DMA1_CH1, p.DMA1_CH2, - Hertz(1_000_000), Config::default(), );