From 8a1658ab0e946b1fb6e91a9b22e92a51b78704ec Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Fri, 31 May 2024 22:19:17 +0200 Subject: [PATCH] stm32/spi: test zero-length transfers in more cases. --- tests/stm32/src/bin/spi.rs | 2 ++ tests/stm32/src/bin/spi_dma.rs | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/stm32/src/bin/spi.rs b/tests/stm32/src/bin/spi.rs index 0d670b7c1..8be3b1a7c 100644 --- a/tests/stm32/src/bin/spi.rs +++ b/tests/stm32/src/bin/spi.rs @@ -76,6 +76,8 @@ async fn main(_spawner: Spawner) { mosi_out.set_low(); spi.blocking_read(&mut buf).unwrap(); assert_eq!(buf, [0x00; 9]); + spi.blocking_read::(&mut []).unwrap(); + spi.blocking_read::(&mut []).unwrap(); drop(mosi_out); drop(spi); diff --git a/tests/stm32/src/bin/spi_dma.rs b/tests/stm32/src/bin/spi_dma.rs index 0cd3690ec..a8001a111 100644 --- a/tests/stm32/src/bin/spi_dma.rs +++ b/tests/stm32/src/bin/spi_dma.rs @@ -63,8 +63,12 @@ async fn main(_spawner: Spawner) { spi.transfer_in_place::(&mut []).await.unwrap(); spi.read::(&mut []).await.unwrap(); spi.write::(&[]).await.unwrap(); + spi.blocking_transfer::(&mut [], &[]).unwrap(); + spi.blocking_transfer_in_place::(&mut []).unwrap(); + spi.blocking_read::(&mut []).unwrap(); + spi.blocking_write::(&[]).unwrap(); - // === Check mixing blocking with async. + // Check mixing blocking with async. spi.blocking_transfer(&mut buf, &data).unwrap(); assert_eq!(buf, data); spi.transfer(&mut buf, &data).await.unwrap(); @@ -110,6 +114,8 @@ async fn main(_spawner: Spawner) { mosi_out.set_low(); spi.read(&mut buf).await.unwrap(); assert_eq!(buf, [0x00; 9]); + spi.read::(&mut []).await.unwrap(); + spi.blocking_read::(&mut []).unwrap(); drop(mosi_out); drop(spi); @@ -121,6 +127,8 @@ async fn main(_spawner: Spawner) { spi.blocking_write(&buf).unwrap(); spi.write(&buf).await.unwrap(); spi.write(&buf).await.unwrap(); + spi.write::(&[]).await.unwrap(); + spi.blocking_write::(&[]).unwrap(); drop(spi); // Test tx-only nosck. @@ -133,6 +141,8 @@ async fn main(_spawner: Spawner) { spi.blocking_write(&buf).unwrap(); spi.write(&buf).await.unwrap(); spi.write(&buf).await.unwrap(); + spi.write::(&[]).await.unwrap(); + spi.blocking_write::(&[]).unwrap(); drop(spi); }