diff options
Diffstat (limited to 'tests/stm32')
| -rw-r--r-- | tests/stm32/Cargo.toml | 10 | ||||
| -rw-r--r-- | tests/stm32/src/bin/eeprom.rs | 30 |
2 files changed, 38 insertions, 2 deletions
diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index 6036a5a97..5a483849c 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml | |||
| @@ -19,8 +19,8 @@ stm32h563zi = ["embassy-stm32/stm32h563zi", "spi-v345", "chrono", "eth", "rng", | |||
| 19 | stm32h753zi = ["embassy-stm32/stm32h753zi", "spi-v345", "chrono", "not-gpdma", "eth", "rng", "fdcan", "hash", "cryp"] | 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"] | 20 | stm32h755zi = ["embassy-stm32/stm32h755zi-cm7", "spi-v345", "chrono", "not-gpdma", "eth", "dac", "rng", "fdcan", "hash", "cryp"] |
| 21 | stm32h7a3zi = ["embassy-stm32/stm32h7a3zi", "spi-v345", "not-gpdma", "rng", "fdcan"] | 21 | stm32h7a3zi = ["embassy-stm32/stm32h7a3zi", "spi-v345", "not-gpdma", "rng", "fdcan"] |
| 22 | stm32l073rz = ["embassy-stm32/stm32l073rz", "cm0", "not-gpdma", "rng"] | 22 | stm32l073rz = ["embassy-stm32/stm32l073rz", "cm0", "not-gpdma", "rng", "eeprom"] |
| 23 | stm32l152re = ["embassy-stm32/stm32l152re", "spi-v1", "chrono", "not-gpdma"] | 23 | stm32l152re = ["embassy-stm32/stm32l152re", "spi-v1", "chrono", "not-gpdma", "eeprom"] |
| 24 | stm32l496zg = ["embassy-stm32/stm32l496zg", "not-gpdma", "rng"] | 24 | stm32l496zg = ["embassy-stm32/stm32l496zg", "not-gpdma", "rng"] |
| 25 | stm32l4a6zg = ["embassy-stm32/stm32l4a6zg", "chrono", "not-gpdma", "rng", "hash"] | 25 | stm32l4a6zg = ["embassy-stm32/stm32l4a6zg", "chrono", "not-gpdma", "rng", "hash"] |
| 26 | stm32l4r5zi = ["embassy-stm32/stm32l4r5zi", "chrono", "not-gpdma", "rng", "dual-bank"] | 26 | stm32l4r5zi = ["embassy-stm32/stm32l4r5zi", "chrono", "not-gpdma", "rng", "dual-bank"] |
| @@ -55,6 +55,7 @@ ucpd = [] | |||
| 55 | cordic = ["dep:num-traits"] | 55 | cordic = ["dep:num-traits"] |
| 56 | dual-bank = ["embassy-stm32/dual-bank"] | 56 | dual-bank = ["embassy-stm32/dual-bank"] |
| 57 | single-bank = ["embassy-stm32/single-bank"] | 57 | single-bank = ["embassy-stm32/single-bank"] |
| 58 | eeprom = [] | ||
| 58 | 59 | ||
| 59 | cm0 = ["portable-atomic/unsafe-assume-single-core"] | 60 | cm0 = ["portable-atomic/unsafe-assume-single-core"] |
| 60 | 61 | ||
| @@ -120,6 +121,11 @@ path = "src/bin/dac_l1.rs" | |||
| 120 | required-features = [ "stm32l152re",] | 121 | required-features = [ "stm32l152re",] |
| 121 | 122 | ||
| 122 | [[bin]] | 123 | [[bin]] |
| 124 | name = "eeprom" | ||
| 125 | path = "src/bin/eeprom.rs" | ||
| 126 | required-features = [ "eeprom",] | ||
| 127 | |||
| 128 | [[bin]] | ||
| 123 | name = "eth" | 129 | name = "eth" |
| 124 | path = "src/bin/eth.rs" | 130 | path = "src/bin/eth.rs" |
| 125 | required-features = [ "eth",] | 131 | required-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"] | ||
| 7 | mod common; | ||
| 8 | |||
| 9 | use common::*; | ||
| 10 | use defmt::assert_eq; | ||
| 11 | use embassy_executor::Spawner; | ||
| 12 | use embassy_stm32::flash::Flash; | ||
| 13 | use {defmt_rtt as _, panic_probe as _}; | ||
| 14 | |||
| 15 | #[embassy_executor::main] | ||
| 16 | async 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 | } | ||
