stm32/spi: check zero-length trasnfers.
This commit is contained in:
parent
06f35c2517
commit
3d6592d22d
@ -55,6 +55,12 @@ async fn main(_spawner: Spawner, p: Peripherals) {
|
|||||||
spi.blocking_transfer(&mut buf, &data).unwrap();
|
spi.blocking_transfer(&mut buf, &data).unwrap();
|
||||||
assert_eq!(buf, data);
|
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");
|
info!("Test OK");
|
||||||
cortex_m::asm::bkpt();
|
cortex_m::asm::bkpt();
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,12 @@ async fn main(_spawner: Spawner, p: Peripherals) {
|
|||||||
spi.transfer(&mut buf, &data).await.unwrap();
|
spi.transfer(&mut buf, &data).await.unwrap();
|
||||||
assert_eq!(buf, data);
|
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");
|
info!("Test OK");
|
||||||
cortex_m::asm::bkpt();
|
cortex_m::asm::bkpt();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user