Skip to content

Commit 42ce44c

Browse files
committed
add HardwareSemaphore (HSEM) test
Enable HSEM test on more MCUs
1 parent 443ffd8 commit 42ce44c

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

tests/stm32/Cargo.toml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@ stm32f767zi = ["embassy-stm32/stm32f767zi", "chrono", "not-gpdma", "eth", "rng"]
1616
stm32g071rb = ["embassy-stm32/stm32g071rb", "cm0", "not-gpdma", "dac", "ucpd"]
1717
stm32g491re = ["embassy-stm32/stm32g491re", "chrono", "stop", "not-gpdma", "rng", "fdcan", "cordic"]
1818
stm32h563zi = ["embassy-stm32/stm32h563zi", "spi-v345", "chrono", "eth", "rng", "fdcan", "hash", "cordic", "stop"]
19-
stm32h753zi = ["embassy-stm32/stm32h753zi", "spi-v345", "chrono", "not-gpdma", "eth", "rng", "fdcan", "hash", "cryp"]
20-
stm32h755zi = ["embassy-stm32/stm32h755zi-cm7", "spi-v345", "chrono", "not-gpdma", "eth", "dac", "rng", "fdcan", "hash", "cryp"]
19+
stm32h753zi = ["embassy-stm32/stm32h753zi", "spi-v345", "chrono", "not-gpdma", "eth", "rng", "fdcan", "hash", "cryp", "hsem"]
20+
stm32h755zi = ["embassy-stm32/stm32h755zi-cm7", "spi-v345", "chrono", "not-gpdma", "eth", "dac", "rng", "fdcan", "hash", "cryp", "hsem"]
2121
stm32h7a3zi = ["embassy-stm32/stm32h7a3zi", "spi-v345", "not-gpdma", "rng", "fdcan"]
2222
stm32l073rz = ["embassy-stm32/stm32l073rz", "cm0", "not-gpdma", "rng"]
2323
stm32l152re = ["embassy-stm32/stm32l152re", "spi-v1", "chrono", "not-gpdma"]
2424
stm32l496zg = ["embassy-stm32/stm32l496zg", "not-gpdma", "rng"]
2525
stm32l4a6zg = ["embassy-stm32/stm32l4a6zg", "chrono", "not-gpdma", "rng", "hash"]
2626
stm32l4r5zi = ["embassy-stm32/stm32l4r5zi", "chrono", "not-gpdma", "rng"]
2727
stm32l552ze = ["embassy-stm32/stm32l552ze", "not-gpdma", "rng", "hash"]
28-
stm32u585ai = ["embassy-stm32/stm32u585ai", "spi-v345", "chrono", "rng", "hash", "cordic"]
28+
stm32u585ai = ["embassy-stm32/stm32u585ai", "spi-v345", "chrono", "rng", "hash", "cordic"]
2929
stm32u5a5zj = ["embassy-stm32/stm32u5a5zj", "spi-v345", "chrono", "rng", "hash"] # FIXME: cordic test cause it crash
30-
stm32wb55rg = ["embassy-stm32/stm32wb55rg", "chrono", "not-gpdma", "ble", "mac" , "rng"]
30+
stm32wb55rg = ["embassy-stm32/stm32wb55rg", "chrono", "not-gpdma", "ble", "mac" , "rng", "hsem"]
3131
stm32wba52cg = ["embassy-stm32/stm32wba52cg", "spi-v345", "chrono", "rng", "hash"]
32-
stm32wl55jc = ["embassy-stm32/stm32wl55jc-cm4", "not-gpdma", "rng", "chrono"]
32+
stm32wl55jc = ["embassy-stm32/stm32wl55jc-cm4", "not-gpdma", "rng", "chrono", "hsem"]
3333
stm32f091rc = ["embassy-stm32/stm32f091rc", "cm0", "not-gpdma", "chrono"]
3434
stm32h503rb = ["embassy-stm32/stm32h503rb", "spi-v345", "rng", "stop"]
3535
stm32h7s3l8 = ["embassy-stm32/stm32h7s3l8", "spi-v345", "rng", "cordic", "hash"] # TODO: fdcan crashes, cryp dma hangs.
@@ -53,6 +53,7 @@ not-gpdma = []
5353
dac = []
5454
ucpd = []
5555
cordic = ["dep:num-traits"]
56+
hsem = []
5657

5758
cm0 = ["portable-atomic/unsafe-assume-single-core"]
5859

@@ -202,6 +203,11 @@ name = "wpan_mac"
202203
path = "src/bin/wpan_mac.rs"
203204
required-features = [ "mac",]
204205

206+
[[bin]]
207+
name = "hsem"
208+
path = "src/bin/hsem.rs"
209+
required-features = [ "hsem",]
210+
205211
# END TESTS
206212

207213
[profile.dev]

tests/stm32/src/bin/hsem.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// required-features: hsem
2+
#![no_std]
3+
#![no_main]
4+
5+
#[path = "../common.rs"]
6+
mod common;
7+
8+
use common::*;
9+
use embassy_executor::Spawner;
10+
use embassy_stm32::hsem::HardwareSemaphore;
11+
12+
#[embassy_executor::main]
13+
async fn main(_spawner: Spawner) {
14+
let p: embassy_stm32::Peripherals = init();
15+
16+
let mut hsem = HardwareSemaphore::new(p.HSEM);
17+
hsem.one_step_lock(5).unwrap();
18+
19+
info!("Test OK");
20+
cortex_m::asm::bkpt();
21+
}

0 commit comments

Comments
 (0)