diff options
| author | Bob McWhirter <[email protected]> | 2021-07-21 10:52:26 -0400 |
|---|---|---|
| committer | Bob McWhirter <[email protected]> | 2021-07-23 13:22:39 -0400 |
| commit | bee7f60f080e091bb26cb3aa9c7239cda6a3ffac (patch) | |
| tree | ded8ca9004f35c7fde384c6d9150367e3c9c5e36 | |
| parent | 0d2051243ef62aac7210dd68c7569912fa315fb2 (diff) | |
Improve the SPIv2 DMA example to verify it actually works.
| -rw-r--r-- | examples/stm32l4/src/bin/spi_dma.rs | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/examples/stm32l4/src/bin/spi_dma.rs b/examples/stm32l4/src/bin/spi_dma.rs index ca77c2f9b..2d176a3d2 100644 --- a/examples/stm32l4/src/bin/spi_dma.rs +++ b/examples/stm32l4/src/bin/spi_dma.rs | |||
| @@ -18,8 +18,8 @@ use example_common::*; | |||
| 18 | use embassy_stm32::spi::{Spi, Config}; | 18 | use embassy_stm32::spi::{Spi, Config}; |
| 19 | use embassy_traits::spi::FullDuplex; | 19 | use embassy_traits::spi::FullDuplex; |
| 20 | use embassy_stm32::time::Hertz; | 20 | use embassy_stm32::time::Hertz; |
| 21 | use embassy_stm32::gpio::{Output, Level, Speed}; | 21 | use embassy_stm32::gpio::{Output, Level, Speed, Input, Pull}; |
| 22 | use embedded_hal::digital::v2::OutputPin; | 22 | use embedded_hal::digital::v2::{OutputPin, InputPin}; |
| 23 | 23 | ||
| 24 | #[embassy::task] | 24 | #[embassy::task] |
| 25 | async fn main_task() { | 25 | async fn main_task() { |
| @@ -36,16 +36,29 @@ async fn main_task() { | |||
| 36 | Config::default(), | 36 | Config::default(), |
| 37 | ); | 37 | ); |
| 38 | 38 | ||
| 39 | |||
| 40 | // These are the pins for the Inventek eS-Wifi SPI Wifi Adapter. | ||
| 41 | |||
| 42 | let mut boot = Output::new(p.PB12, Level::Low, Speed::VeryHigh); | ||
| 43 | let mut wake = Output::new(p.PB13, Level::Low, Speed::VeryHigh); | ||
| 44 | let mut reset = Output::new(p.PE8, Level::Low, Speed::VeryHigh); | ||
| 39 | let mut cs = Output::new(p.PE0, Level::High, Speed::VeryHigh); | 45 | let mut cs = Output::new(p.PE0, Level::High, Speed::VeryHigh); |
| 46 | let mut ready = Input::new(p.PE1, Pull::Up); | ||
| 40 | 47 | ||
| 41 | loop { | 48 | cortex_m::asm::delay(100_000); |
| 42 | let write = [0x0A; 10]; | 49 | reset.set_high(); |
| 43 | let mut read = [0; 10]; | 50 | cortex_m::asm::delay(100_000); |
| 44 | unwrap!(cs.set_low()); | 51 | |
| 45 | spi.read_write(&mut read, &write).await.ok(); | 52 | while ready.is_low().unwrap() { |
| 46 | unwrap!(cs.set_high()); | 53 | info!("waiting for ready"); |
| 47 | info!("xfer {=[u8]:x}", read); | ||
| 48 | } | 54 | } |
| 55 | |||
| 56 | let write = [0x0A; 10]; | ||
| 57 | let mut read = [0; 10]; | ||
| 58 | unwrap!(cs.set_low()); | ||
| 59 | spi.read_write(&mut read, &write).await.ok(); | ||
| 60 | unwrap!(cs.set_high()); | ||
| 61 | info!("xfer {=[u8]:x}", read); | ||
| 49 | } | 62 | } |
| 50 | 63 | ||
| 51 | struct ZeroClock; | 64 | struct ZeroClock; |
