aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/flash/mod.rs
diff options
context:
space:
mode:
authorRasmus Melchior Jacobsen <[email protected]>2023-03-30 05:27:57 +0200
committerRasmus Melchior Jacobsen <[email protected]>2023-03-30 05:27:57 +0200
commit91d8afd371c20d21765713a45625f62ce25d97b6 (patch)
tree78b0169917caf5eb7d68e0708e2cbaa1b770b71e /embassy-stm32/src/flash/mod.rs
parent89129babf99c0e7087dfef6ce1ebf9d822ded6d1 (diff)
Add AltFlashLayout for supported F4 chips
Diffstat (limited to 'embassy-stm32/src/flash/mod.rs')
-rw-r--r--embassy-stm32/src/flash/mod.rs58
1 files changed, 32 insertions, 26 deletions
diff --git a/embassy-stm32/src/flash/mod.rs b/embassy-stm32/src/flash/mod.rs
index 1e7d4c657..7dc714715 100644
--- a/embassy-stm32/src/flash/mod.rs
+++ b/embassy-stm32/src/flash/mod.rs
@@ -1,5 +1,35 @@
1use embedded_storage::nor_flash::{NorFlashError, NorFlashErrorKind}; 1use embedded_storage::nor_flash::{NorFlashError, NorFlashErrorKind};
2 2
3#[cfg(flash)]
4mod common;
5
6#[cfg(flash)]
7pub use common::*;
8
9pub use crate::_generated::flash_regions::*;
10pub use crate::pac::{FLASH_BASE, FLASH_SIZE, WRITE_SIZE};
11
12pub struct FlashRegion {
13 pub base: u32,
14 pub size: u32,
15 pub erase_size: u32,
16 pub write_size: u32,
17 pub erase_value: u8,
18}
19
20#[derive(Debug, PartialEq)]
21pub struct FlashSector {
22 pub index: u8,
23 pub start: u32,
24 pub size: u32,
25}
26
27impl Drop for FlashLayout<'_> {
28 fn drop(&mut self) {
29 unsafe { family::lock() };
30 }
31}
32
3#[cfg_attr(any(flash_l0, flash_l1, flash_l4, flash_wl, flash_wb), path = "l.rs")] 33#[cfg_attr(any(flash_l0, flash_l1, flash_l4, flash_wl, flash_wb), path = "l.rs")]
4#[cfg_attr(flash_f3, path = "f3.rs")] 34#[cfg_attr(flash_f3, path = "f3.rs")]
5#[cfg_attr(flash_f4, path = "f4.rs")] 35#[cfg_attr(flash_f4, path = "f4.rs")]
@@ -39,32 +69,8 @@ mod family {
39 } 69 }
40} 70}
41 71
42#[cfg(flash)] 72#[allow(unused_imports)]
43mod common; 73pub use family::*;
44
45#[cfg(flash)]
46pub use common::*;
47
48pub struct FlashRegion {
49 pub base: u32,
50 pub size: u32,
51 pub erase_size: u32,
52 pub write_size: u32,
53 pub erase_value: u8,
54}
55
56#[derive(Debug, PartialEq)]
57pub struct FlashSector {
58 pub index: u8,
59 pub start: u32,
60 pub size: u32,
61}
62
63impl Drop for FlashLayout<'_> {
64 fn drop(&mut self) {
65 unsafe { family::lock() };
66 }
67}
68 74
69#[derive(Debug, Copy, Clone, PartialEq, Eq)] 75#[derive(Debug, Copy, Clone, PartialEq, Eq)]
70#[cfg_attr(feature = "defmt", derive(defmt::Format))] 76#[cfg_attr(feature = "defmt", derive(defmt::Format))]