aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorUlf Lilleengen <[email protected]>2025-05-23 14:15:15 +0200
committerGitHub <[email protected]>2025-05-23 14:15:15 +0200
commit94f9b2707486ca3eade5bf4b237edf3d6aa90f35 (patch)
treeed91d32d5c462bc919957bc6ea3eccccd9c0d260 /tests
parentf7405493c184ce453ac3f7ba97f7f2689f978194 (diff)
parentc88bc972316634da586589adcefa49bb02a2cf0f (diff)
Merge pull request #4228 from okhsunrog/adding_eeprom
Adding EEPROM support to embassy-stm32
Diffstat (limited to 'tests')
-rw-r--r--tests/stm32/Cargo.toml10
-rw-r--r--tests/stm32/src/bin/eeprom.rs30
2 files changed, 38 insertions, 2 deletions
diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml
index e78520e40..8d10f6593 100644
--- a/tests/stm32/Cargo.toml
+++ b/tests/stm32/Cargo.toml
@@ -19,8 +19,8 @@ stm32h563zi = ["embassy-stm32/stm32h563zi", "spi-v345", "chrono", "eth", "rng",
19stm32h753zi = ["embassy-stm32/stm32h753zi", "spi-v345", "chrono", "not-gpdma", "eth", "rng", "fdcan", "hash", "cryp"] 19stm32h753zi = ["embassy-stm32/stm32h753zi", "spi-v345", "chrono", "not-gpdma", "eth", "rng", "fdcan", "hash", "cryp"]
20stm32h755zi = ["embassy-stm32/stm32h755zi-cm7", "spi-v345", "chrono", "not-gpdma", "eth", "dac", "rng", "fdcan", "hash", "cryp"] 20stm32h755zi = ["embassy-stm32/stm32h755zi-cm7", "spi-v345", "chrono", "not-gpdma", "eth", "dac", "rng", "fdcan", "hash", "cryp"]
21stm32h7a3zi = ["embassy-stm32/stm32h7a3zi", "spi-v345", "not-gpdma", "rng", "fdcan"] 21stm32h7a3zi = ["embassy-stm32/stm32h7a3zi", "spi-v345", "not-gpdma", "rng", "fdcan"]
22stm32l073rz = ["embassy-stm32/stm32l073rz", "cm0", "not-gpdma", "rng"] 22stm32l073rz = ["embassy-stm32/stm32l073rz", "cm0", "not-gpdma", "rng", "eeprom"]
23stm32l152re = ["embassy-stm32/stm32l152re", "spi-v1", "chrono", "not-gpdma"] 23stm32l152re = ["embassy-stm32/stm32l152re", "spi-v1", "chrono", "not-gpdma", "eeprom"]
24stm32l496zg = ["embassy-stm32/stm32l496zg", "not-gpdma", "rng"] 24stm32l496zg = ["embassy-stm32/stm32l496zg", "not-gpdma", "rng"]
25stm32l4a6zg = ["embassy-stm32/stm32l4a6zg", "chrono", "not-gpdma", "rng", "hash"] 25stm32l4a6zg = ["embassy-stm32/stm32l4a6zg", "chrono", "not-gpdma", "rng", "hash"]
26stm32l4r5zi = ["embassy-stm32/stm32l4r5zi", "chrono", "not-gpdma", "rng", "dual-bank"] 26stm32l4r5zi = ["embassy-stm32/stm32l4r5zi", "chrono", "not-gpdma", "rng", "dual-bank"]
@@ -55,6 +55,7 @@ ucpd = []
55cordic = ["dep:num-traits"] 55cordic = ["dep:num-traits"]
56dual-bank = ["embassy-stm32/dual-bank"] 56dual-bank = ["embassy-stm32/dual-bank"]
57single-bank = ["embassy-stm32/single-bank"] 57single-bank = ["embassy-stm32/single-bank"]
58eeprom = []
58 59
59cm0 = ["portable-atomic/unsafe-assume-single-core"] 60cm0 = ["portable-atomic/unsafe-assume-single-core"]
60 61
@@ -120,6 +121,11 @@ path = "src/bin/dac_l1.rs"
120required-features = [ "stm32l152re",] 121required-features = [ "stm32l152re",]
121 122
122[[bin]] 123[[bin]]
124name = "eeprom"
125path = "src/bin/eeprom.rs"
126required-features = [ "eeprom",]
127
128[[bin]]
123name = "eth" 129name = "eth"
124path = "src/bin/eth.rs" 130path = "src/bin/eth.rs"
125required-features = [ "eth",] 131required-features = [ "eth",]
diff --git a/tests/stm32/src/bin/eeprom.rs b/tests/stm32/src/bin/eeprom.rs
new file mode 100644
index 000000000..61d249fd7
--- /dev/null
+++ b/tests/stm32/src/bin/eeprom.rs
@@ -0,0 +1,30 @@
1#![no_std]
2#![no_main]
3
4// required-features: eeprom
5
6#[path = "../common.rs"]
7mod common;
8
9use common::*;
10use defmt::assert_eq;
11use embassy_executor::Spawner;
12use embassy_stm32::flash::Flash;
13use {defmt_rtt as _, panic_probe as _};
14
15#[embassy_executor::main]
16async fn main(_spawner: Spawner) {
17 // Initialize the board and obtain a Peripherals instance
18 let p: embassy_stm32::Peripherals = init();
19
20 let mut f = Flash::new_blocking(p.FLASH);
21 const ADDR: u32 = 0x0;
22
23 unwrap!(f.eeprom_write_slice(ADDR, &[1, 2, 3, 4, 5, 6, 7, 8]));
24 let mut buf = [0u8; 8];
25 unwrap!(f.eeprom_read_slice(ADDR, &mut buf));
26 assert_eq!(&buf[..], &[1, 2, 3, 4, 5, 6, 7, 8]);
27
28 info!("Test OK");
29 cortex_m::asm::bkpt();
30}