From 55fb1d51268e87b522ba47e4cdc04978e9880ab0 Mon Sep 17 00:00:00 2001 From: bofh <123368+bofh@users.noreply.github.com> Date: Sun, 30 Jul 2023 19:26:24 +0200 Subject: [PATCH] Fix more stm32 SPI examples --- examples/stm32h7/src/bin/spi.rs | 6 ++++-- examples/stm32h7/src/bin/spi_dma.rs | 6 ++++-- examples/stm32l0/src/bin/lora_cad.rs | 6 ++++-- examples/stm32l0/src/bin/lora_lorawan.rs | 6 ++++-- examples/stm32l0/src/bin/lora_p2p_receive.rs | 6 ++++-- examples/stm32l0/src/bin/lora_p2p_send.rs | 6 ++++-- tests/stm32/src/bin/spi.rs | 1 - tests/stm32/src/bin/spi_dma.rs | 1 - 8 files changed, 24 insertions(+), 14 deletions(-) diff --git a/examples/stm32h7/src/bin/spi.rs b/examples/stm32h7/src/bin/spi.rs index 1f407f00..051a8392 100644 --- a/examples/stm32h7/src/bin/spi.rs +++ b/examples/stm32h7/src/bin/spi.rs @@ -43,6 +43,9 @@ fn main() -> ! { config.rcc.pll1.q_ck = Some(mhz(100)); let p = embassy_stm32::init(config); + let mut spi_config = spi::Config::default(); + spi_config.frequency = mhz(1); + let spi = spi::Spi::new( p.SPI3, p.PB3, @@ -50,8 +53,7 @@ fn main() -> ! { p.PB4, NoDma, NoDma, - mhz(1), - spi::Config::default(), + spi_config, ); let executor = EXECUTOR.init(Executor::new()); diff --git a/examples/stm32h7/src/bin/spi_dma.rs b/examples/stm32h7/src/bin/spi_dma.rs index 53004fc9..5e878ee6 100644 --- a/examples/stm32h7/src/bin/spi_dma.rs +++ b/examples/stm32h7/src/bin/spi_dma.rs @@ -39,6 +39,9 @@ fn main() -> ! { config.rcc.pll1.q_ck = Some(mhz(100)); let p = embassy_stm32::init(config); + let mut spi_config = spi::Config::default(); + spi_config.frequency = mhz(1); + let spi = spi::Spi::new( p.SPI3, p.PB3, @@ -46,8 +49,7 @@ fn main() -> ! { p.PB4, p.DMA1_CH3, p.DMA1_CH4, - mhz(1), - spi::Config::default(), + spi_config, ); let executor = EXECUTOR.init(Executor::new()); diff --git a/examples/stm32l0/src/bin/lora_cad.rs b/examples/stm32l0/src/bin/lora_cad.rs index 588cea1e..ae2393e5 100644 --- a/examples/stm32l0/src/bin/lora_cad.rs +++ b/examples/stm32l0/src/bin/lora_cad.rs @@ -27,6 +27,9 @@ async fn main(_spawner: Spawner) { config.rcc.enable_hsi48 = true; let p = embassy_stm32::init(config); + let mut spi_config = spi::Config::default(); + spi_config.frequency = khz(200); + // SPI for sx1276 let spi = spi::Spi::new( p.SPI1, @@ -35,8 +38,7 @@ async fn main(_spawner: Spawner) { p.PA6, p.DMA1_CH3, p.DMA1_CH2, - khz(200), - spi::Config::default(), + spi_config, ); let nss = Output::new(p.PA15.degrade(), Level::High, Speed::Low); diff --git a/examples/stm32l0/src/bin/lora_lorawan.rs b/examples/stm32l0/src/bin/lora_lorawan.rs index c397edd5..2202deea 100644 --- a/examples/stm32l0/src/bin/lora_lorawan.rs +++ b/examples/stm32l0/src/bin/lora_lorawan.rs @@ -32,6 +32,9 @@ async fn main(_spawner: Spawner) { config.rcc.enable_hsi48 = true; let p = embassy_stm32::init(config); + let mut spi_config = spi::Config::default(); + spi_config.frequency = khz(200); + // SPI for sx1276 let spi = spi::Spi::new( p.SPI1, @@ -40,8 +43,7 @@ async fn main(_spawner: Spawner) { p.PA6, p.DMA1_CH3, p.DMA1_CH2, - khz(200), - spi::Config::default(), + spi_config, ); let nss = Output::new(p.PA15.degrade(), Level::High, Speed::Low); diff --git a/examples/stm32l0/src/bin/lora_p2p_receive.rs b/examples/stm32l0/src/bin/lora_p2p_receive.rs index bb750950..9b6b18b8 100644 --- a/examples/stm32l0/src/bin/lora_p2p_receive.rs +++ b/examples/stm32l0/src/bin/lora_p2p_receive.rs @@ -27,6 +27,9 @@ async fn main(_spawner: Spawner) { config.rcc.enable_hsi48 = true; let p = embassy_stm32::init(config); + let mut spi_config = spi::Config::default(); + spi_config.frequency = khz(200); + // SPI for sx1276 let spi = spi::Spi::new( p.SPI1, @@ -35,8 +38,7 @@ async fn main(_spawner: Spawner) { p.PA6, p.DMA1_CH3, p.DMA1_CH2, - khz(200), - spi::Config::default(), + spi_config, ); let nss = Output::new(p.PA15.degrade(), Level::High, Speed::Low); diff --git a/examples/stm32l0/src/bin/lora_p2p_send.rs b/examples/stm32l0/src/bin/lora_p2p_send.rs index e6fadc01..90bae31e 100644 --- a/examples/stm32l0/src/bin/lora_p2p_send.rs +++ b/examples/stm32l0/src/bin/lora_p2p_send.rs @@ -27,6 +27,9 @@ async fn main(_spawner: Spawner) { config.rcc.enable_hsi48 = true; let p = embassy_stm32::init(config); + let mut spi_config = spi::Config::default(); + spi_config.frequency = khz(200); + // SPI for sx1276 let spi = spi::Spi::new( p.SPI1, @@ -35,8 +38,7 @@ async fn main(_spawner: Spawner) { p.PA6, p.DMA1_CH3, p.DMA1_CH2, - khz(200), - spi::Config::default(), + spi_config, ); let nss = Output::new(p.PA15.degrade(), Level::High, Speed::Low); diff --git a/tests/stm32/src/bin/spi.rs b/tests/stm32/src/bin/spi.rs index 819ecae3..72a8c92e 100644 --- a/tests/stm32/src/bin/spi.rs +++ b/tests/stm32/src/bin/spi.rs @@ -42,7 +42,6 @@ async fn main(_spawner: Spawner) { miso, // Arduino D12 NoDma, NoDma, - Hertz(1_000_000), spi::Config::default(), ); diff --git a/tests/stm32/src/bin/spi_dma.rs b/tests/stm32/src/bin/spi_dma.rs index 78aad24e..443aab57 100644 --- a/tests/stm32/src/bin/spi_dma.rs +++ b/tests/stm32/src/bin/spi_dma.rs @@ -41,7 +41,6 @@ async fn main(_spawner: Spawner) { miso, // Arduino D12 tx_dma, rx_dma, - Hertz(1_000_000), spi::Config::default(), );