diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-10-14 12:43:59 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2024-10-14 12:50:14 +0200 |
| commit | 014583aaa5dd10d4580aa24ec9b9f2ddb963559a (patch) | |
| tree | 55d0bd31beca528e97944c08164cb5510066fe8d /tests/stm32 | |
| parent | ad5f7bf6f72f6e1ff512b29eaa843b0dae58d931 (diff) | |
tests/stm32: add uart async and blocking flush test.
Diffstat (limited to 'tests/stm32')
| -rw-r--r-- | tests/stm32/src/bin/usart.rs | 7 | ||||
| -rw-r--r-- | tests/stm32/src/bin/usart_dma.rs | 17 |
2 files changed, 24 insertions, 0 deletions
diff --git a/tests/stm32/src/bin/usart.rs b/tests/stm32/src/bin/usart.rs index 53da30fff..2f601ad0e 100644 --- a/tests/stm32/src/bin/usart.rs +++ b/tests/stm32/src/bin/usart.rs | |||
| @@ -33,6 +33,13 @@ async fn main(_spawner: Spawner) { | |||
| 33 | let mut buf = [0; 2]; | 33 | let mut buf = [0; 2]; |
| 34 | usart.blocking_read(&mut buf).unwrap(); | 34 | usart.blocking_read(&mut buf).unwrap(); |
| 35 | assert_eq!(buf, data); | 35 | assert_eq!(buf, data); |
| 36 | |||
| 37 | // Test flush doesn't hang. | ||
| 38 | usart.blocking_write(&data).unwrap(); | ||
| 39 | usart.blocking_flush().unwrap(); | ||
| 40 | |||
| 41 | // Test flush doesn't hang if there's nothing to flush | ||
| 42 | usart.blocking_flush().unwrap(); | ||
| 36 | } | 43 | } |
| 37 | 44 | ||
| 38 | // Test error handling with with an overflow error | 45 | // Test error handling with with an overflow error |
diff --git a/tests/stm32/src/bin/usart_dma.rs b/tests/stm32/src/bin/usart_dma.rs index 266b81809..a34498376 100644 --- a/tests/stm32/src/bin/usart_dma.rs +++ b/tests/stm32/src/bin/usart_dma.rs | |||
| @@ -51,6 +51,23 @@ async fn main(_spawner: Spawner) { | |||
| 51 | assert_eq!(tx_buf, rx_buf); | 51 | assert_eq!(tx_buf, rx_buf); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | // Test flush doesn't hang. Check multiple combinations of async+blocking. | ||
| 55 | tx.write(&tx_buf).await.unwrap(); | ||
| 56 | tx.flush().await.unwrap(); | ||
| 57 | tx.flush().await.unwrap(); | ||
| 58 | |||
| 59 | tx.write(&tx_buf).await.unwrap(); | ||
| 60 | tx.blocking_flush().unwrap(); | ||
| 61 | tx.flush().await.unwrap(); | ||
| 62 | |||
| 63 | tx.blocking_write(&tx_buf).unwrap(); | ||
| 64 | tx.blocking_flush().unwrap(); | ||
| 65 | tx.flush().await.unwrap(); | ||
| 66 | |||
| 67 | tx.blocking_write(&tx_buf).unwrap(); | ||
| 68 | tx.flush().await.unwrap(); | ||
| 69 | tx.blocking_flush().unwrap(); | ||
| 70 | |||
| 54 | info!("Test OK"); | 71 | info!("Test OK"); |
| 55 | cortex_m::asm::bkpt(); | 72 | cortex_m::asm::bkpt(); |
| 56 | } | 73 | } |
