Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
306d118
support psram in DmaTxBuf
liebman Sep 15, 2024
008c8cd
add example that sometimes works :-(
liebman Sep 15, 2024
b231c8b
fmt
liebman Sep 15, 2024
07f780c
cleanups
liebman Sep 15, 2024
b1376b3
allow chunk_size upto (including) 4095
liebman Sep 16, 2024
179e926
this test is passing for me now
liebman Sep 16, 2024
1e37d4f
remove chunk_size and compute based on block_size
liebman Sep 16, 2024
5b2b4c9
return error in `prepare_transfer` if psram is found on non-esp32s3
liebman Sep 18, 2024
12acacd
missing parens
liebman Sep 18, 2024
9e2067d
changelog
liebman Sep 18, 2024
9fce2f4
default 4092 for esp32 & fmt
liebman Sep 18, 2024
b264ee2
no errors anymode
liebman Sep 19, 2024
1e62e91
use block_size is_some to flag invalid psram in prepare_transfer
liebman Sep 19, 2024
510b392
drop block_size from macro, the buffer allocation was not being align…
liebman Sep 19, 2024
af58a61
missed macro example
liebman Sep 19, 2024
70e98d7
use defmt::Format that decodes owner like Debug
liebman Sep 19, 2024
fa7cce0
fix typo
liebman Sep 19, 2024
6c9ff4c
DmaTxBuf: its an error if buffer is in psram and block_size is none
liebman Sep 20, 2024
d18fea7
DmaTxBuf: its an error if buffer is in psram and block_size is none
liebman Sep 20, 2024
37f7bff
update for PSRAM feature changes
liebman Sep 20, 2024
9162e63
Merge branch 'main' into dma-psram-tx-buf
JurajSadel Sep 24, 2024
51028c6
address alignment comments
liebman Sep 24, 2024
d452ef6
fmt
liebman Sep 24, 2024
b24f066
better alignment test
liebman Sep 24, 2024
65adcdf
revert alignment test
liebman Sep 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
this test is passing for me now
  • Loading branch information
liebman committed Sep 20, 2024
commit 179e926198a4d4ec0fd4a1df03498790f4fbf56d
104 changes: 52 additions & 52 deletions hil-test/tests/spi_half_duplex_write_psram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
#![no_main]
use esp_alloc as _;
use esp_hal::{
dma::{Dma, DmaBufBlkSize, DmaPriority, DmaTxBuf},
dma::{Dma, DmaBufBlkSize, DmaPriority, DmaRxBuf, DmaTxBuf},
dma_buffers,
dma_descriptors_chunk_size,
gpio::{interconnect::InputSignal, Io},
pcnt::{channel::EdgeMode, unit::Unit, Pcnt},
peripherals::SPI2,
prelude::*,
spi::{
master::{Address, Command, Spi, SpiDma},
master::{Address, Command, HalfDuplexReadWrite, Spi, SpiDma},
HalfDuplexMode,
SpiDataMode,
SpiMode,
Expand Down Expand Up @@ -76,13 +77,7 @@ mod tests {
let pcnt = Pcnt::new(peripherals.PCNT);
let dma = Dma::new(peripherals.DMA);

cfg_if::cfg_if! {
if #[cfg(any(feature = "esp32", feature = "esp32s2"))] {
let dma_channel = dma.spi2channel;
} else {
let dma_channel = dma.channel0;
}
}
let dma_channel = dma.channel0;

let mosi_loopback = mosi.peripheral_input();

Expand All @@ -101,7 +96,7 @@ mod tests {
#[test]
#[timeout(3)]
fn test_spi_writes_are_correctly_by_pcnt(ctx: Context) {
const DMA_BUFFER_SIZE: usize = 64;
const DMA_BUFFER_SIZE: usize = 4;
const DMA_CHUNK_SIZE: usize = 4032; // 64 byte aligned
const DMA_ALIGNMENT: DmaBufBlkSize = DmaBufBlkSize::Size32; // matches dcache line size

Expand Down Expand Up @@ -149,46 +144,51 @@ mod tests {
assert_eq!(unit.get_value(), (6 * DMA_BUFFER_SIZE) as _);
}

// TODO: when the first test is working, we can add a second one!
// #[test]
// #[timeout(3)]
// fn test_spidmabus_writes_are_correctly_by_pcnt(ctx: Context) {
// const DMA_BUFFER_SIZE: usize = 64;

// let (rx, rxd, buffer, descriptors) = dma_buffers!(1,
// DMA_BUFFER_SIZE); let dma_rx_buf = DmaRxBuf::new(rxd,
// rx).unwrap(); let dma_tx_buf = DmaTxBuf::new(descriptors,
// buffer).unwrap();

// let unit = ctx.pcnt_unit;
// let mut spi = ctx.spi.with_buffers(dma_rx_buf, dma_tx_buf);

// unit.channel0.set_edge_signal(ctx.pcnt_source);
// unit.channel0
// .set_input_mode(EdgeMode::Hold, EdgeMode::Increment);

// let buffer = [0b0110_1010; DMA_BUFFER_SIZE];
// // Write the buffer where each byte has 3 pos edges.
// spi.write(
// SpiDataMode::Single,
// Command::None,
// Address::None,
// 0,
// &buffer,
// )
// .unwrap();

// assert_eq!(unit.get_value(), (3 * DMA_BUFFER_SIZE) as _);

// spi.write(
// SpiDataMode::Single,
// Command::None,
// Address::None,
// 0,
// &buffer,
// )
// .unwrap();

// assert_eq!(unit.get_value(), (6 * DMA_BUFFER_SIZE) as _);
// }
#[test]
#[timeout(3)]
fn test_spidmabus_writes_are_correctly_by_pcnt(ctx: Context) {
const DMA_BUFFER_SIZE: usize = 4;
const DMA_CHUNK_SIZE: usize = 4032; // 64 byte aligned
const DMA_ALIGNMENT: DmaBufBlkSize = DmaBufBlkSize::Size32; // matches dcache line size

let (_, descriptors) = dma_descriptors_chunk_size!(0, DMA_BUFFER_SIZE, DMA_CHUNK_SIZE);
let buffer = dma_alloc_buffer!(DMA_BUFFER_SIZE, DMA_ALIGNMENT as usize);
let dma_tx_buf =
DmaTxBuf::new_with_chunk_size(descriptors, buffer, DMA_CHUNK_SIZE, Some(DMA_ALIGNMENT))
.unwrap();

let (rx, rxd, _, _) = dma_buffers!(1, 0);
let dma_rx_buf = DmaRxBuf::new(rxd, rx).unwrap();

let unit = ctx.pcnt_unit;
let mut spi = ctx.spi.with_buffers(dma_rx_buf, dma_tx_buf);

unit.channel0.set_edge_signal(ctx.pcnt_source);
unit.channel0
.set_input_mode(EdgeMode::Hold, EdgeMode::Increment);

let buffer = [0b0110_1010; DMA_BUFFER_SIZE];
// Write the buffer where each byte has 3 pos edges.
spi.write(
SpiDataMode::Single,
Command::None,
Address::None,
0,
&buffer,
)
.unwrap();

assert_eq!(unit.get_value(), (3 * DMA_BUFFER_SIZE) as _);

spi.write(
SpiDataMode::Single,
Command::None,
Address::None,
0,
&buffer,
)
.unwrap();

assert_eq!(unit.get_value(), (6 * DMA_BUFFER_SIZE) as _);
}
}