stm32/spi: check zero-length trasnfers.

This commit is contained in:
Dario Nieuwenhuis 2022-03-15 00:48:11 +01:00
parent 06f35c2517
commit 3d6592d22d
2 changed files with 12 additions and 0 deletions

View file

@ -55,6 +55,12 @@ async fn main(_spawner: Spawner, p: Peripherals) {
spi.blocking_transfer(&mut buf, &data).unwrap();
assert_eq!(buf, data);
// Check zero-length operations, these should be noops.
spi.blocking_transfer::<u8>(&mut [], &[]).unwrap();
spi.blocking_transfer_in_place::<u8>(&mut []).unwrap();
spi.blocking_read::<u8>(&mut []).unwrap();
spi.blocking_write::<u8>(&[]).unwrap();
info!("Test OK");
cortex_m::asm::bkpt();
}

View file

@ -62,6 +62,12 @@ async fn main(_spawner: Spawner, p: Peripherals) {
spi.transfer(&mut buf, &data).await.unwrap();
assert_eq!(buf, data);
// Check zero-length operations, these should be noops.
spi.transfer::<u8>(&mut [], &[]).await.unwrap();
spi.transfer_in_place::<u8>(&mut []).await.unwrap();
spi.read::<u8>(&mut []).await.unwrap();
spi.write::<u8>(&[]).await.unwrap();
info!("Test OK");
cortex_m::asm::bkpt();
}