aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32l1
diff options
context:
space:
mode:
authorokhsunrog <[email protected]>2025-05-21 09:54:19 +0300
committerokhsunrog <[email protected]>2025-05-21 09:54:19 +0300
commit27ca627fc83974d926630b4a1bfc9783c3c86bb9 (patch)
tree61bf4ebe87c3ddd9cbcb9a3828f98d66054524ca /examples/stm32l1
parent437e45df2b468caf13475ffaf3d55cc4f01e2d6b (diff)
added examples
Diffstat (limited to 'examples/stm32l1')
-rw-r--r--examples/stm32l1/src/bin/eeprom.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/examples/stm32l1/src/bin/eeprom.rs b/examples/stm32l1/src/bin/eeprom.rs
new file mode 100644
index 000000000..370246644
--- /dev/null
+++ b/examples/stm32l1/src/bin/eeprom.rs
@@ -0,0 +1,32 @@
1#![no_std]
2#![no_main]
3
4use defmt::{info, unwrap};
5use embassy_executor::Spawner;
6use embassy_stm32::flash::{Flash, EEPROM_BASE, EEPROM_SIZE};
7use {defmt_rtt as _, panic_probe as _};
8
9#[embassy_executor::main]
10async fn main(_spawner: Spawner) {
11 let p = embassy_stm32::init(Default::default());
12
13 info!("Hello Eeprom! Start: {}, Size: {}", EEPROM_BASE, EEPROM_SIZE);
14
15 const ADDR: u32 = 0x0;
16
17 let mut f = Flash::new_blocking(p.FLASH);
18
19 info!("Reading...");
20 let mut buf = [0u8; 8];
21 unwrap!(f.eeprom_read_slice(ADDR, &mut buf));
22 info!("Read: {=[u8]:x}", buf);
23
24 info!("Writing...");
25 unwrap!(f.eeprom_write_slice(ADDR, &[1, 2, 3, 4, 5, 6, 7, 8]));
26
27 info!("Reading...");
28 let mut buf = [0u8; 8];
29 unwrap!(f.eeprom_read_slice(ADDR, &mut buf));
30 info!("Read: {=[u8]:x}", buf);
31 assert_eq!(&buf[..], &[1, 2, 3, 4, 5, 6, 7, 8]);
32}