diff --git a/examples/stm32l4/src/bin/spi_dma.rs b/examples/stm32l4/src/bin/spi_dma.rs index ca77c2f9..2d176a3d 100644 --- a/examples/stm32l4/src/bin/spi_dma.rs +++ b/examples/stm32l4/src/bin/spi_dma.rs @@ -18,8 +18,8 @@ use example_common::*; use embassy_stm32::spi::{Spi, Config}; use embassy_traits::spi::FullDuplex; use embassy_stm32::time::Hertz; -use embassy_stm32::gpio::{Output, Level, Speed}; -use embedded_hal::digital::v2::OutputPin; +use embassy_stm32::gpio::{Output, Level, Speed, Input, Pull}; +use embedded_hal::digital::v2::{OutputPin, InputPin}; #[embassy::task] async fn main_task() { @@ -36,16 +36,29 @@ async fn main_task() { Config::default(), ); - let mut cs = Output::new(p.PE0, Level::High, Speed::VeryHigh); - loop { - let write = [0x0A; 10]; - let mut read = [0; 10]; - unwrap!(cs.set_low()); - spi.read_write(&mut read, &write).await.ok(); - unwrap!(cs.set_high()); - info!("xfer {=[u8]:x}", read); + // These are the pins for the Inventek eS-Wifi SPI Wifi Adapter. + + let mut boot = Output::new(p.PB12, Level::Low, Speed::VeryHigh); + let mut wake = Output::new(p.PB13, Level::Low, Speed::VeryHigh); + let mut reset = Output::new(p.PE8, Level::Low, Speed::VeryHigh); + let mut cs = Output::new(p.PE0, Level::High, Speed::VeryHigh); + let mut ready = Input::new(p.PE1, Pull::Up); + + cortex_m::asm::delay(100_000); + reset.set_high(); + cortex_m::asm::delay(100_000); + + while ready.is_low().unwrap() { + info!("waiting for ready"); } + + let write = [0x0A; 10]; + let mut read = [0; 10]; + unwrap!(cs.set_low()); + spi.read_write(&mut read, &write).await.ok(); + unwrap!(cs.set_high()); + info!("xfer {=[u8]:x}", read); } struct ZeroClock;