diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-03-15 00:48:11 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-03-15 02:14:24 +0100 |
| commit | 3d6592d22d37402509bd43d88a0a979683f74b04 (patch) | |
| tree | 530e95bc084f7c6e8e2be20bd4e523d75055f201 /tests | |
| parent | 06f35c25176795c8e856ea7b41a52dba4b160f66 (diff) | |
stm32/spi: check zero-length trasnfers.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/stm32/src/bin/spi.rs | 6 | ||||
| -rw-r--r-- | tests/stm32/src/bin/spi_dma.rs | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/tests/stm32/src/bin/spi.rs b/tests/stm32/src/bin/spi.rs index 6151058b7..b079472d5 100644 --- a/tests/stm32/src/bin/spi.rs +++ b/tests/stm32/src/bin/spi.rs | |||
| @@ -55,6 +55,12 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 55 | spi.blocking_transfer(&mut buf, &data).unwrap(); | 55 | spi.blocking_transfer(&mut buf, &data).unwrap(); |
| 56 | assert_eq!(buf, data); | 56 | assert_eq!(buf, data); |
| 57 | 57 | ||
| 58 | // Check zero-length operations, these should be noops. | ||
| 59 | spi.blocking_transfer::<u8>(&mut [], &[]).unwrap(); | ||
| 60 | spi.blocking_transfer_in_place::<u8>(&mut []).unwrap(); | ||
| 61 | spi.blocking_read::<u8>(&mut []).unwrap(); | ||
| 62 | spi.blocking_write::<u8>(&[]).unwrap(); | ||
| 63 | |||
| 58 | info!("Test OK"); | 64 | info!("Test OK"); |
| 59 | cortex_m::asm::bkpt(); | 65 | cortex_m::asm::bkpt(); |
| 60 | } | 66 | } |
diff --git a/tests/stm32/src/bin/spi_dma.rs b/tests/stm32/src/bin/spi_dma.rs index 67785778a..3e9521ae7 100644 --- a/tests/stm32/src/bin/spi_dma.rs +++ b/tests/stm32/src/bin/spi_dma.rs | |||
| @@ -62,6 +62,12 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 62 | spi.transfer(&mut buf, &data).await.unwrap(); | 62 | spi.transfer(&mut buf, &data).await.unwrap(); |
| 63 | assert_eq!(buf, data); | 63 | assert_eq!(buf, data); |
| 64 | 64 | ||
| 65 | // Check zero-length operations, these should be noops. | ||
| 66 | spi.transfer::<u8>(&mut [], &[]).await.unwrap(); | ||
| 67 | spi.transfer_in_place::<u8>(&mut []).await.unwrap(); | ||
| 68 | spi.read::<u8>(&mut []).await.unwrap(); | ||
| 69 | spi.write::<u8>(&[]).await.unwrap(); | ||
| 70 | |||
| 65 | info!("Test OK"); | 71 | info!("Test OK"); |
| 66 | cortex_m::asm::bkpt(); | 72 | cortex_m::asm::bkpt(); |
| 67 | } | 73 | } |
