Skip to content

Commit

Permalink
Fix HIL tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominaezzz committed May 23, 2024
1 parent fb339e2 commit 377885f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
20 changes: 11 additions & 9 deletions hil-test/tests/spi_full_duplex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ use esp_hal::{
gpio::Io,
peripherals::Peripherals,
prelude::*,
spi::{master::Spi, FullDuplexMode, SpiMode},
spi::{
master::{Spi, SpiFifo},
FullDuplexMode,
SpiMode,
},
system::SystemControl,
};

struct Context {
spi: Spi<'static, esp_hal::peripherals::SPI2, FullDuplexMode>,
spi: SpiFifo<'static, esp_hal::peripherals::SPI2, FullDuplexMode>,
}

impl Context {
Expand All @@ -41,14 +45,12 @@ impl Context {
let mosi = io.pins.gpio4;
let cs = io.pins.gpio5;

let spi = Spi::new(peripherals.SPI2, 1000u32.kHz(), SpiMode::Mode0, &clocks).with_pins(
Some(sclk),
Some(mosi),
Some(miso),
Some(cs),
);
let (spi, fifo) = Spi::new(peripherals.SPI2, 1000u32.kHz(), SpiMode::Mode0, &clocks);
let spi = spi.with_pins(Some(sclk), Some(mosi), Some(miso), Some(cs));

Context { spi }
Context {
spi: SpiFifo::new(spi, fifo),
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions hil-test/tests/spi_full_duplex_dma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ mod tests {
dma_buffers!(DMA_BUFFER_SIZE);

let mut spi = Spi::new(peripherals.SPI2, 100.kHz(), SpiMode::Mode0, &clocks)
.0
.with_pins(Some(sclk), Some(mosi), Some(miso), Some(cs))
.with_dma(dma_channel.configure(
false,
Expand Down Expand Up @@ -104,6 +105,7 @@ mod tests {
let (tx_buffer, mut tx_descriptors, rx_buffer, mut rx_descriptors) = dma_buffers!(4, 2);

let mut spi = Spi::new(peripherals.SPI2, 100.kHz(), SpiMode::Mode0, &clocks)
.0
.with_pins(Some(sclk), Some(mosi), Some(miso), Some(cs))
.with_dma(dma_channel.configure(
false,
Expand Down Expand Up @@ -149,6 +151,7 @@ mod tests {
dma_buffers!(DMA_BUFFER_SIZE);

let mut spi = Spi::new(peripherals.SPI2, 100.kHz(), SpiMode::Mode0, &clocks)
.0
.with_pins(Some(sclk), Some(mosi), Some(miso), Some(cs))
.with_dma(dma_channel.configure(
false,
Expand Down

0 comments on commit 377885f

Please sign in to comment.