stm32/spi: more exhaustive test.
This commit is contained in:
parent
306110f56e
commit
06f35c2517
@ -37,9 +37,24 @@ async fn main(_spawner: Spawner, p: Peripherals) {
|
|||||||
// Arduino pins D11 and D12 (MOSI-MISO) are connected together with a 1K resistor.
|
// Arduino pins D11 and D12 (MOSI-MISO) are connected together with a 1K resistor.
|
||||||
// so we should get the data we sent back.
|
// so we should get the data we sent back.
|
||||||
let mut buf = data;
|
let mut buf = data;
|
||||||
|
spi.blocking_transfer(&mut buf, &data).unwrap();
|
||||||
|
assert_eq!(buf, data);
|
||||||
|
|
||||||
spi.blocking_transfer_in_place(&mut buf).unwrap();
|
spi.blocking_transfer_in_place(&mut buf).unwrap();
|
||||||
assert_eq!(buf, data);
|
assert_eq!(buf, data);
|
||||||
|
|
||||||
|
// Check read/write don't hang. We can't check they transfer the right data
|
||||||
|
// without fancier test mechanisms.
|
||||||
|
spi.blocking_write(&buf).unwrap();
|
||||||
|
spi.blocking_read(&mut buf).unwrap();
|
||||||
|
spi.blocking_write(&buf).unwrap();
|
||||||
|
spi.blocking_read(&mut buf).unwrap();
|
||||||
|
spi.blocking_write(&buf).unwrap();
|
||||||
|
|
||||||
|
// Check transfer doesn't break after having done a write, due to garbage in the FIFO
|
||||||
|
spi.blocking_transfer(&mut buf, &data).unwrap();
|
||||||
|
assert_eq!(buf, data);
|
||||||
|
|
||||||
info!("Test OK");
|
info!("Test OK");
|
||||||
cortex_m::asm::bkpt();
|
cortex_m::asm::bkpt();
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,18 @@ async fn main(_spawner: Spawner, p: Peripherals) {
|
|||||||
spi.transfer_in_place(&mut buf).await.unwrap();
|
spi.transfer_in_place(&mut buf).await.unwrap();
|
||||||
assert_eq!(buf, data);
|
assert_eq!(buf, data);
|
||||||
|
|
||||||
|
// Check read/write don't hang. We can't check they transfer the right data
|
||||||
|
// without fancier test mechanisms.
|
||||||
|
spi.write(&buf).await.unwrap();
|
||||||
|
spi.read(&mut buf).await.unwrap();
|
||||||
|
spi.write(&buf).await.unwrap();
|
||||||
|
spi.read(&mut buf).await.unwrap();
|
||||||
|
spi.write(&buf).await.unwrap();
|
||||||
|
|
||||||
|
// Check transfer doesn't break after having done a write, due to garbage in the FIFO
|
||||||
|
spi.transfer(&mut buf, &data).await.unwrap();
|
||||||
|
assert_eq!(buf, data);
|
||||||
|
|
||||||
info!("Test OK");
|
info!("Test OK");
|
||||||
cortex_m::asm::bkpt();
|
cortex_m::asm::bkpt();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user