diff options
| -rw-r--r-- | tests/stm32/src/bin/spi.rs | 15 | ||||
| -rw-r--r-- | tests/stm32/src/bin/spi_dma.rs | 12 |
2 files changed, 27 insertions, 0 deletions
diff --git a/tests/stm32/src/bin/spi.rs b/tests/stm32/src/bin/spi.rs index 47d0017ac..6151058b7 100644 --- a/tests/stm32/src/bin/spi.rs +++ b/tests/stm32/src/bin/spi.rs | |||
| @@ -37,9 +37,24 @@ 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 | |||
| 43 | info!("Test OK"); | 58 | info!("Test OK"); |
| 44 | cortex_m::asm::bkpt(); | 59 | cortex_m::asm::bkpt(); |
| 45 | } | 60 | } |
diff --git a/tests/stm32/src/bin/spi_dma.rs b/tests/stm32/src/bin/spi_dma.rs index ce80bde74..67785778a 100644 --- a/tests/stm32/src/bin/spi_dma.rs +++ b/tests/stm32/src/bin/spi_dma.rs | |||
| @@ -50,6 +50,18 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 50 | spi.transfer_in_place(&mut buf).await.unwrap(); | 50 | spi.transfer_in_place(&mut buf).await.unwrap(); |
| 51 | assert_eq!(buf, data); | 51 | assert_eq!(buf, data); |
| 52 | 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 | |||
| 53 | info!("Test OK"); | 65 | info!("Test OK"); |
| 54 | cortex_m::asm::bkpt(); | 66 | cortex_m::asm::bkpt(); |
| 55 | } | 67 | } |
