diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-10-14 10:52:32 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-10-14 10:52:32 +0000 |
| commit | 4f08d5bc5ff0f765198665b1f37b6372f43b8567 (patch) | |
| tree | 55d0bd31beca528e97944c08164cb5510066fe8d /tests | |
| parent | c84495ef2eb99580fea5392b2b3aff5ad66043a0 (diff) | |
| parent | 014583aaa5dd10d4580aa24ec9b9f2ddb963559a (diff) | |
Merge pull request #3379 from qwerty19106/stm32_async_flush
Stm32: implement async flush for UART
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/rp/.cargo/config.toml | 1 | ||||
| -rw-r--r-- | tests/stm32/.cargo/config.toml | 1 | ||||
| -rw-r--r-- | tests/stm32/src/bin/usart.rs | 7 | ||||
| -rw-r--r-- | tests/stm32/src/bin/usart_dma.rs | 17 |
4 files changed, 24 insertions, 2 deletions
diff --git a/tests/rp/.cargo/config.toml b/tests/rp/.cargo/config.toml index de7bb0e56..4337924cc 100644 --- a/tests/rp/.cargo/config.toml +++ b/tests/rp/.cargo/config.toml | |||
| @@ -11,7 +11,6 @@ runner = "teleprobe client run" | |||
| 11 | rustflags = [ | 11 | rustflags = [ |
| 12 | # Code-size optimizations. | 12 | # Code-size optimizations. |
| 13 | #"-Z", "trap-unreachable=no", | 13 | #"-Z", "trap-unreachable=no", |
| 14 | "-C", "inline-threshold=5", | ||
| 15 | "-C", "no-vectorize-loops", | 14 | "-C", "no-vectorize-loops", |
| 16 | ] | 15 | ] |
| 17 | 16 | ||
diff --git a/tests/stm32/.cargo/config.toml b/tests/stm32/.cargo/config.toml index 8752da59b..d94342598 100644 --- a/tests/stm32/.cargo/config.toml +++ b/tests/stm32/.cargo/config.toml | |||
| @@ -9,7 +9,6 @@ runner = "teleprobe client run" | |||
| 9 | rustflags = [ | 9 | rustflags = [ |
| 10 | # Code-size optimizations. | 10 | # Code-size optimizations. |
| 11 | #"-Z", "trap-unreachable=no", | 11 | #"-Z", "trap-unreachable=no", |
| 12 | "-C", "inline-threshold=5", | ||
| 13 | "-C", "no-vectorize-loops", | 12 | "-C", "no-vectorize-loops", |
| 14 | ] | 13 | ] |
| 15 | 14 | ||
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 | } |
