diff options
| author | Rasmus Melchior Jacobsen <[email protected]> | 2023-05-26 15:23:36 +0200 |
|---|---|---|
| committer | Rasmus Melchior Jacobsen <[email protected]> | 2023-05-26 15:41:08 +0200 |
| commit | fee89ed7c7f79d7e70421e7f0915c13bcfdefb2f (patch) | |
| tree | 3e3c4e1ab20de454a1ff2485aec30c2e76e2c622 /embassy-stm32/src/flash/f4.rs | |
| parent | 31b364b9b0a18a9ebb341747861441b11f621ea0 (diff) | |
Remove ability to set alt layout - it does not work.
Diffstat (limited to 'embassy-stm32/src/flash/f4.rs')
| -rw-r--r-- | embassy-stm32/src/flash/f4.rs | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/embassy-stm32/src/flash/f4.rs b/embassy-stm32/src/flash/f4.rs index 25d96ca1e..5e1fc696f 100644 --- a/embassy-stm32/src/flash/f4.rs +++ b/embassy-stm32/src/flash/f4.rs | |||
| @@ -69,7 +69,7 @@ mod alt_regions { | |||
| 69 | 69 | ||
| 70 | impl<'d> Flash<'d> { | 70 | impl<'d> Flash<'d> { |
| 71 | pub fn into_alt_regions(self) -> AltFlashLayout<'d, Async> { | 71 | pub fn into_alt_regions(self) -> AltFlashLayout<'d, Async> { |
| 72 | super::set_alt_layout(); | 72 | assert!(!super::is_default_layout()); |
| 73 | 73 | ||
| 74 | // SAFETY: We never expose the cloned peripheral references, and their instance is not public. | 74 | // SAFETY: We never expose the cloned peripheral references, and their instance is not public. |
| 75 | // Also, all async flash region operations are protected with a mutex. | 75 | // Also, all async flash region operations are protected with a mutex. |
| @@ -86,7 +86,7 @@ mod alt_regions { | |||
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | pub fn into_alt_blocking_regions(self) -> AltFlashLayout<'d, Blocking> { | 88 | pub fn into_alt_blocking_regions(self) -> AltFlashLayout<'d, Blocking> { |
| 89 | super::set_alt_layout(); | 89 | assert!(!super::is_default_layout()); |
| 90 | 90 | ||
| 91 | // SAFETY: We never expose the cloned peripheral references, and their instance is not public. | 91 | // SAFETY: We never expose the cloned peripheral references, and their instance is not public. |
| 92 | // Also, all blocking flash region operations are protected with a cs. | 92 | // Also, all blocking flash region operations are protected with a cs. |
| @@ -191,38 +191,21 @@ impl FlashSector { | |||
| 191 | } | 191 | } |
| 192 | 192 | ||
| 193 | #[cfg(any(stm32f427, stm32f429, stm32f437, stm32f439, stm32f469, stm32f479))] | 193 | #[cfg(any(stm32f427, stm32f429, stm32f437, stm32f439, stm32f469, stm32f479))] |
| 194 | pub fn set_default_layout() { | 194 | pub(crate) fn is_default_layout() -> bool { |
| 195 | unsafe { | 195 | unsafe { !pac::FLASH.optcr().read().db1m() } |
| 196 | pac::FLASH.optkeyr().write(|w| w.set_optkey(0x08192A3B)); | ||
| 197 | pac::FLASH.optkeyr().write(|w| w.set_optkey(0x4C5D6E7F)); | ||
| 198 | pac::FLASH.optcr().modify(|r| { | ||
| 199 | r.set_db1m(false); | ||
| 200 | r.set_optlock(true) | ||
| 201 | }); | ||
| 202 | }; | ||
| 203 | } | 196 | } |
| 204 | 197 | ||
| 205 | #[cfg(not(any(stm32f427, stm32f429, stm32f437, stm32f439, stm32f469, stm32f479)))] | 198 | #[cfg(not(any(stm32f427, stm32f429, stm32f437, stm32f439, stm32f469, stm32f479)))] |
| 206 | pub const fn set_default_layout() {} | 199 | pub(crate) const fn is_default_layout() -> bool { |
| 207 | 200 | true | |
| 208 | #[cfg(any(stm32f427, stm32f429, stm32f437, stm32f439, stm32f469, stm32f479))] | ||
| 209 | fn set_alt_layout() { | ||
| 210 | unsafe { | ||
| 211 | pac::FLASH.optkeyr().write(|w| w.set_optkey(0x08192A3B)); | ||
| 212 | pac::FLASH.optkeyr().write(|w| w.set_optkey(0x4C5D6E7F)); | ||
| 213 | pac::FLASH.optcr().modify(|r| { | ||
| 214 | r.set_db1m(true); | ||
| 215 | r.set_optlock(true) | ||
| 216 | }); | ||
| 217 | }; | ||
| 218 | } | 201 | } |
| 219 | 202 | ||
| 220 | #[cfg(any(stm32f427, stm32f429, stm32f437, stm32f439, stm32f469, stm32f479))] | 203 | #[cfg(any(stm32f427, stm32f429, stm32f437, stm32f439, stm32f469, stm32f479))] |
| 221 | pub fn get_flash_regions() -> &'static [&'static FlashRegion] { | 204 | pub fn get_flash_regions() -> &'static [&'static FlashRegion] { |
| 222 | if unsafe { pac::FLASH.optcr().read().db1m() } { | 205 | if is_default_layout() { |
| 223 | &ALT_FLASH_REGIONS | ||
| 224 | } else { | ||
| 225 | &FLASH_REGIONS | 206 | &FLASH_REGIONS |
| 207 | } else { | ||
| 208 | &ALT_FLASH_REGIONS | ||
| 226 | } | 209 | } |
| 227 | } | 210 | } |
| 228 | 211 | ||
