diff options
| author | okhsunrog <[email protected]> | 2025-05-21 22:33:44 +0300 |
|---|---|---|
| committer | okhsunrog <[email protected]> | 2025-05-21 22:33:44 +0300 |
| commit | c88bc972316634da586589adcefa49bb02a2cf0f (patch) | |
| tree | 7f36ec4bcb7fad315fa53d08e3759f0f3d58f774 /tests/stm32/src/bin/eeprom.rs | |
| parent | e4a6d7aeddd686e47e1a26cd129e7bb646dcb0be (diff) | |
added eeprom to tests
Diffstat (limited to 'tests/stm32/src/bin/eeprom.rs')
| -rw-r--r-- | tests/stm32/src/bin/eeprom.rs | 30 |
1 files changed, 30 insertions, 0 deletions
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 | } | ||
