diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-03-15 01:39:38 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-03-15 01:39:38 +0000 |
| commit | ff1215c6f9295d960c5111d30f27ca047605414d (patch) | |
| tree | cf065e87589733f37d7c15c99d20b5e9132cd4c4 /tests | |
| parent | 8ef8ab170766051be22cc93ec0359f1f95dc6027 (diff) | |
| parent | 059b16423458a80c5cb4e1630260d6c564a88e84 (diff) | |
Merge #664
664: stm32: more spi fixes r=Dirbaio a=Dirbaio
Co-authored-by: Dario Nieuwenhuis <[email protected]>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/stm32/src/bin/spi.rs | 21 | ||||
| -rw-r--r-- | tests/stm32/src/bin/spi_dma.rs | 21 |
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/stm32/src/bin/spi.rs b/tests/stm32/src/bin/spi.rs index 47d0017ac..b079472d5 100644 --- a/tests/stm32/src/bin/spi.rs +++ b/tests/stm32/src/bin/spi.rs | |||
| @@ -37,9 +37,30 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 37 | // Arduino pins D11 and D12 (MOSI-MISO) are connected together with a 1K resistor. | 37 | // Arduino pins D11 and D12 (MOSI-MISO) are connected together with a 1K resistor. |
| 38 | // so we should get the data we sent back. | 38 | // so we should get the data we sent back. |
| 39 | let mut buf = data; | 39 | let mut buf = data; |
| 40 | spi.blocking_transfer(&mut buf, &data).unwrap(); | ||
| 41 | assert_eq!(buf, data); | ||
| 42 | |||
| 40 | spi.blocking_transfer_in_place(&mut buf).unwrap(); | 43 | spi.blocking_transfer_in_place(&mut buf).unwrap(); |
| 41 | assert_eq!(buf, data); | 44 | assert_eq!(buf, data); |
| 42 | 45 | ||
| 46 | // Check read/write don't hang. We can't check they transfer the right data | ||
| 47 | // without fancier test mechanisms. | ||
| 48 | spi.blocking_write(&buf).unwrap(); | ||
| 49 | spi.blocking_read(&mut buf).unwrap(); | ||
| 50 | spi.blocking_write(&buf).unwrap(); | ||
| 51 | spi.blocking_read(&mut buf).unwrap(); | ||
| 52 | spi.blocking_write(&buf).unwrap(); | ||
| 53 | |||
| 54 | // Check transfer doesn't break after having done a write, due to garbage in the FIFO | ||
| 55 | spi.blocking_transfer(&mut buf, &data).unwrap(); | ||
| 56 | assert_eq!(buf, data); | ||
| 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 | |||
| 43 | info!("Test OK"); | 64 | info!("Test OK"); |
| 44 | cortex_m::asm::bkpt(); | 65 | cortex_m::asm::bkpt(); |
| 45 | } | 66 | } |
diff --git a/tests/stm32/src/bin/spi_dma.rs b/tests/stm32/src/bin/spi_dma.rs index 59a5bcd0c..3e9521ae7 100644 --- a/tests/stm32/src/bin/spi_dma.rs +++ b/tests/stm32/src/bin/spi_dma.rs | |||
| @@ -47,6 +47,27 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 47 | spi.transfer(&mut buf, &data).await.unwrap(); | 47 | spi.transfer(&mut buf, &data).await.unwrap(); |
| 48 | assert_eq!(buf, data); | 48 | assert_eq!(buf, data); |
| 49 | 49 | ||
| 50 | spi.transfer_in_place(&mut buf).await.unwrap(); | ||
| 51 | assert_eq!(buf, data); | ||
| 52 | |||
| 53 | // Check read/write don't hang. We can't check they transfer the right data | ||
| 54 | // without fancier test mechanisms. | ||
| 55 | spi.write(&buf).await.unwrap(); | ||
| 56 | spi.read(&mut buf).await.unwrap(); | ||
| 57 | spi.write(&buf).await.unwrap(); | ||
| 58 | spi.read(&mut buf).await.unwrap(); | ||
| 59 | spi.write(&buf).await.unwrap(); | ||
| 60 | |||
| 61 | // Check transfer doesn't break after having done a write, due to garbage in the FIFO | ||
| 62 | spi.transfer(&mut buf, &data).await.unwrap(); | ||
| 63 | assert_eq!(buf, data); | ||
| 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 | |||
| 50 | info!("Test OK"); | 71 | info!("Test OK"); |
| 51 | cortex_m::asm::bkpt(); | 72 | cortex_m::asm::bkpt(); |
| 52 | } | 73 | } |
