aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/stm32f3/src/bin/flash.rs2
-rw-r--r--examples/stm32f4/src/bin/flash.rs13
-rw-r--r--examples/stm32f7/src/bin/flash.rs4
-rw-r--r--examples/stm32h7/src/bin/flash.rs4
-rw-r--r--examples/stm32l0/src/bin/flash.rs2
-rw-r--r--examples/stm32l1/src/bin/flash.rs2
-rw-r--r--examples/stm32wl/src/bin/flash.rs2
7 files changed, 15 insertions, 14 deletions
diff --git a/examples/stm32f3/src/bin/flash.rs b/examples/stm32f3/src/bin/flash.rs
index baa7484d0..e40ad4fc0 100644
--- a/examples/stm32f3/src/bin/flash.rs
+++ b/examples/stm32f3/src/bin/flash.rs
@@ -15,7 +15,7 @@ async fn main(_spawner: Spawner) {
15 15
16 const ADDR: u32 = 0x26000; 16 const ADDR: u32 = 0x26000;
17 17
18 let mut f = Flash::new(p.FLASH); 18 let mut f = Flash::new(p.FLASH).into_regions().bank1_region;
19 19
20 info!("Reading..."); 20 info!("Reading...");
21 let mut buf = [0u8; 8]; 21 let mut buf = [0u8; 8];
diff --git a/examples/stm32f4/src/bin/flash.rs b/examples/stm32f4/src/bin/flash.rs
index 7ea068a42..bd3a7c95e 100644
--- a/examples/stm32f4/src/bin/flash.rs
+++ b/examples/stm32f4/src/bin/flash.rs
@@ -5,7 +5,6 @@
5use defmt::{info, unwrap}; 5use defmt::{info, unwrap};
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::flash::Flash; 7use embassy_stm32::flash::Flash;
8use embedded_storage::nor_flash::{NorFlash, ReadNorFlash};
9use {defmt_rtt as _, panic_probe as _}; 8use {defmt_rtt as _, panic_probe as _};
10 9
11#[embassy_executor::main] 10#[embassy_executor::main]
@@ -13,6 +12,8 @@ async fn main(_spawner: Spawner) {
13 let p = embassy_stm32::init(Default::default()); 12 let p = embassy_stm32::init(Default::default());
14 info!("Hello Flash!"); 13 info!("Hello Flash!");
15 14
15 // Once can also call `into_regions()` to get access to NorFlash implementations
16 // for each of the unique characteristics.
16 let mut f = Flash::new(p.FLASH); 17 let mut f = Flash::new(p.FLASH);
17 18
18 // Sector 5 19 // Sector 5
@@ -30,19 +31,19 @@ fn test_flash(f: &mut Flash, offset: u32, size: u32) {
30 31
31 info!("Reading..."); 32 info!("Reading...");
32 let mut buf = [0u8; 32]; 33 let mut buf = [0u8; 32];
33 unwrap!(f.read(offset, &mut buf)); 34 unwrap!(f.blocking_read(offset, &mut buf));
34 info!("Read: {=[u8]:x}", buf); 35 info!("Read: {=[u8]:x}", buf);
35 36
36 info!("Erasing..."); 37 info!("Erasing...");
37 unwrap!(f.erase(offset, offset + size)); 38 unwrap!(f.blocking_erase(offset, offset + size));
38 39
39 info!("Reading..."); 40 info!("Reading...");
40 let mut buf = [0u8; 32]; 41 let mut buf = [0u8; 32];
41 unwrap!(f.read(offset, &mut buf)); 42 unwrap!(f.blocking_read(offset, &mut buf));
42 info!("Read after erase: {=[u8]:x}", buf); 43 info!("Read after erase: {=[u8]:x}", buf);
43 44
44 info!("Writing..."); 45 info!("Writing...");
45 unwrap!(f.write( 46 unwrap!(f.blocking_write(
46 offset, 47 offset,
47 &[ 48 &[
48 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 49 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
@@ -52,7 +53,7 @@ fn test_flash(f: &mut Flash, offset: u32, size: u32) {
52 53
53 info!("Reading..."); 54 info!("Reading...");
54 let mut buf = [0u8; 32]; 55 let mut buf = [0u8; 32];
55 unwrap!(f.read(offset, &mut buf)); 56 unwrap!(f.blocking_read(offset, &mut buf));
56 info!("Read: {=[u8]:x}", buf); 57 info!("Read: {=[u8]:x}", buf);
57 assert_eq!( 58 assert_eq!(
58 &buf[..], 59 &buf[..],
diff --git a/examples/stm32f7/src/bin/flash.rs b/examples/stm32f7/src/bin/flash.rs
index 4a7bca1fa..aabfe8557 100644
--- a/examples/stm32f7/src/bin/flash.rs
+++ b/examples/stm32f7/src/bin/flash.rs
@@ -14,12 +14,12 @@ async fn main(_spawner: Spawner) {
14 let p = embassy_stm32::init(Default::default()); 14 let p = embassy_stm32::init(Default::default());
15 info!("Hello Flash!"); 15 info!("Hello Flash!");
16 16
17 const ADDR: u32 = 0x8_0000; 17 const ADDR: u32 = 0x8_0000; // This is the offset into the third region, the absolute address is 4x32K + 128K + 0x8_0000.
18 18
19 // wait a bit before accessing the flash 19 // wait a bit before accessing the flash
20 Timer::after(Duration::from_millis(300)).await; 20 Timer::after(Duration::from_millis(300)).await;
21 21
22 let mut f = Flash::new(p.FLASH); 22 let mut f = Flash::new(p.FLASH).into_regions().bank1_region3;
23 23
24 info!("Reading..."); 24 info!("Reading...");
25 let mut buf = [0u8; 32]; 25 let mut buf = [0u8; 32];
diff --git a/examples/stm32h7/src/bin/flash.rs b/examples/stm32h7/src/bin/flash.rs
index ee86bdbf6..7ee9838c9 100644
--- a/examples/stm32h7/src/bin/flash.rs
+++ b/examples/stm32h7/src/bin/flash.rs
@@ -14,12 +14,12 @@ async fn main(_spawner: Spawner) {
14 let p = embassy_stm32::init(Default::default()); 14 let p = embassy_stm32::init(Default::default());
15 info!("Hello Flash!"); 15 info!("Hello Flash!");
16 16
17 const ADDR: u32 = 0x08_0000; 17 const ADDR: u32 = 0; // This is the offset into bank 2, the absolute address is 0x8_0000
18 18
19 // wait a bit before accessing the flash 19 // wait a bit before accessing the flash
20 Timer::after(Duration::from_millis(300)).await; 20 Timer::after(Duration::from_millis(300)).await;
21 21
22 let mut f = Flash::new(p.FLASH); 22 let mut f = Flash::new(p.FLASH).into_regions().bank2_region;
23 23
24 info!("Reading..."); 24 info!("Reading...");
25 let mut buf = [0u8; 32]; 25 let mut buf = [0u8; 32];
diff --git a/examples/stm32l0/src/bin/flash.rs b/examples/stm32l0/src/bin/flash.rs
index ffe4fb10b..337425028 100644
--- a/examples/stm32l0/src/bin/flash.rs
+++ b/examples/stm32l0/src/bin/flash.rs
@@ -15,7 +15,7 @@ async fn main(_spawner: Spawner) {
15 15
16 const ADDR: u32 = 0x26000; 16 const ADDR: u32 = 0x26000;
17 17
18 let mut f = Flash::new(p.FLASH); 18 let mut f = Flash::new(p.FLASH).into_regions().bank1_region;
19 19
20 info!("Reading..."); 20 info!("Reading...");
21 let mut buf = [0u8; 8]; 21 let mut buf = [0u8; 8];
diff --git a/examples/stm32l1/src/bin/flash.rs b/examples/stm32l1/src/bin/flash.rs
index 476ed51a4..38feb0d76 100644
--- a/examples/stm32l1/src/bin/flash.rs
+++ b/examples/stm32l1/src/bin/flash.rs
@@ -15,7 +15,7 @@ async fn main(_spawner: Spawner) {
15 15
16 const ADDR: u32 = 0x26000; 16 const ADDR: u32 = 0x26000;
17 17
18 let mut f = Flash::new(p.FLASH); 18 let mut f = Flash::new(p.FLASH).into_regions().bank1_region;
19 19
20 info!("Reading..."); 20 info!("Reading...");
21 let mut buf = [0u8; 8]; 21 let mut buf = [0u8; 8];
diff --git a/examples/stm32wl/src/bin/flash.rs b/examples/stm32wl/src/bin/flash.rs
index 2a8880624..e6bc2865c 100644
--- a/examples/stm32wl/src/bin/flash.rs
+++ b/examples/stm32wl/src/bin/flash.rs
@@ -15,7 +15,7 @@ async fn main(_spawner: Spawner) {
15 15
16 const ADDR: u32 = 0x36000; 16 const ADDR: u32 = 0x36000;
17 17
18 let mut f = Flash::new(p.FLASH); 18 let mut f = Flash::new(p.FLASH).into_regions().bank1_region;
19 19
20 info!("Reading..."); 20 info!("Reading...");
21 let mut buf = [0u8; 8]; 21 let mut buf = [0u8; 8];