From 9a730ef692d2b5c529f5e1aac58e80c6d04c2458 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Wed, 1 Dec 2021 21:59:53 +0100 Subject: Refactor sx127x radio to use async SPI with DMA --- examples/stm32l0/Cargo.toml | 2 +- examples/stm32l0/src/bin/lorawan.rs | 17 +++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) (limited to 'examples') diff --git a/examples/stm32l0/Cargo.toml b/examples/stm32l0/Cargo.toml index 6d840d503..53ba6ba39 100644 --- a/examples/stm32l0/Cargo.toml +++ b/examples/stm32l0/Cargo.toml @@ -20,7 +20,7 @@ defmt-rtt = "0.3" cortex-m = "0.7.3" cortex-m-rt = "0.7.0" -embedded-hal = "0.2.6" panic-probe = { version = "0.3", features = ["print-defmt"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } heapless = { version = "0.7.5", default-features = false } +embedded-hal = "0.2.6" diff --git a/examples/stm32l0/src/bin/lorawan.rs b/examples/stm32l0/src/bin/lorawan.rs index 5ca69f9a7..cbae88356 100644 --- a/examples/stm32l0/src/bin/lorawan.rs +++ b/examples/stm32l0/src/bin/lorawan.rs @@ -12,7 +12,6 @@ mod example_common; use embassy_lora::{sx127x::*, LoraTimer}; use embassy_stm32::{ dbgmcu::Dbgmcu, - dma::NoDma, exti::ExtiInput, gpio::{Input, Level, Output, Pull, Speed}, rcc, @@ -45,8 +44,8 @@ async fn main(_spawner: embassy::executor::Spawner, mut p: Peripherals) { p.PB3, p.PA7, p.PA6, - NoDma, - NoDma, + p.DMA1_CH3, + p.DMA1_CH2, 200_000.hz(), spi::Config::default(), ); @@ -58,15 +57,9 @@ async fn main(_spawner: embassy::executor::Spawner, mut p: Peripherals) { let ready = Input::new(p.PB4, Pull::Up); let ready_pin = ExtiInput::new(ready, p.EXTI4); - let radio = Sx127xRadio::new( - spi, - cs, - reset, - ready_pin, - DummySwitch, - &mut embassy::time::Delay, - ) - .unwrap(); + let radio = Sx127xRadio::new(spi, cs, reset, ready_pin, DummySwitch) + .await + .unwrap(); let region = region::EU868::default().into(); let mut radio_buffer = [0; 256]; -- cgit