Remove ability to set alt layout - it does not work.
This commit is contained in:
parent
31b364b9b0
commit
fee89ed7c7
@ -34,7 +34,7 @@ impl<'d> Flash<'d, Async> {
|
||||
}
|
||||
|
||||
pub fn into_regions(self) -> FlashLayout<'d, Async> {
|
||||
family::set_default_layout();
|
||||
assert!(family::is_default_layout());
|
||||
FlashLayout::new(self.inner)
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ impl<'d> Flash<'d, Blocking> {
|
||||
|
||||
impl<'d, MODE> Flash<'d, MODE> {
|
||||
pub fn into_blocking_regions(self) -> FlashLayout<'d, Blocking> {
|
||||
family::set_default_layout();
|
||||
assert!(family::is_default_layout());
|
||||
FlashLayout::new(self.inner)
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,9 @@ use super::{FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE};
|
||||
use crate::flash::Error;
|
||||
use crate::pac;
|
||||
|
||||
pub const fn set_default_layout() {}
|
||||
pub const fn is_default_layout() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
pub const fn get_flash_regions() -> &'static [&'static FlashRegion] {
|
||||
&FLASH_REGIONS
|
||||
|
@ -7,7 +7,9 @@ use super::{FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE};
|
||||
use crate::flash::Error;
|
||||
use crate::pac;
|
||||
|
||||
pub const fn set_default_layout() {}
|
||||
pub const fn is_default_layout() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
pub const fn get_flash_regions() -> &'static [&'static FlashRegion] {
|
||||
&FLASH_REGIONS
|
||||
|
@ -69,7 +69,7 @@ mod alt_regions {
|
||||
|
||||
impl<'d> Flash<'d> {
|
||||
pub fn into_alt_regions(self) -> AltFlashLayout<'d, Async> {
|
||||
super::set_alt_layout();
|
||||
assert!(!super::is_default_layout());
|
||||
|
||||
// SAFETY: We never expose the cloned peripheral references, and their instance is not public.
|
||||
// Also, all async flash region operations are protected with a mutex.
|
||||
@ -86,7 +86,7 @@ mod alt_regions {
|
||||
}
|
||||
|
||||
pub fn into_alt_blocking_regions(self) -> AltFlashLayout<'d, Blocking> {
|
||||
super::set_alt_layout();
|
||||
assert!(!super::is_default_layout());
|
||||
|
||||
// SAFETY: We never expose the cloned peripheral references, and their instance is not public.
|
||||
// Also, all blocking flash region operations are protected with a cs.
|
||||
@ -191,38 +191,21 @@ impl FlashSector {
|
||||
}
|
||||
|
||||
#[cfg(any(stm32f427, stm32f429, stm32f437, stm32f439, stm32f469, stm32f479))]
|
||||
pub fn set_default_layout() {
|
||||
unsafe {
|
||||
pac::FLASH.optkeyr().write(|w| w.set_optkey(0x08192A3B));
|
||||
pac::FLASH.optkeyr().write(|w| w.set_optkey(0x4C5D6E7F));
|
||||
pac::FLASH.optcr().modify(|r| {
|
||||
r.set_db1m(false);
|
||||
r.set_optlock(true)
|
||||
});
|
||||
};
|
||||
pub(crate) fn is_default_layout() -> bool {
|
||||
unsafe { !pac::FLASH.optcr().read().db1m() }
|
||||
}
|
||||
|
||||
#[cfg(not(any(stm32f427, stm32f429, stm32f437, stm32f439, stm32f469, stm32f479)))]
|
||||
pub const fn set_default_layout() {}
|
||||
|
||||
#[cfg(any(stm32f427, stm32f429, stm32f437, stm32f439, stm32f469, stm32f479))]
|
||||
fn set_alt_layout() {
|
||||
unsafe {
|
||||
pac::FLASH.optkeyr().write(|w| w.set_optkey(0x08192A3B));
|
||||
pac::FLASH.optkeyr().write(|w| w.set_optkey(0x4C5D6E7F));
|
||||
pac::FLASH.optcr().modify(|r| {
|
||||
r.set_db1m(true);
|
||||
r.set_optlock(true)
|
||||
});
|
||||
};
|
||||
pub(crate) const fn is_default_layout() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
#[cfg(any(stm32f427, stm32f429, stm32f437, stm32f439, stm32f469, stm32f479))]
|
||||
pub fn get_flash_regions() -> &'static [&'static FlashRegion] {
|
||||
if unsafe { pac::FLASH.optcr().read().db1m() } {
|
||||
&ALT_FLASH_REGIONS
|
||||
} else {
|
||||
if is_default_layout() {
|
||||
&FLASH_REGIONS
|
||||
} else {
|
||||
&ALT_FLASH_REGIONS
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,9 @@ use super::{FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE};
|
||||
use crate::flash::Error;
|
||||
use crate::pac;
|
||||
|
||||
pub const fn set_default_layout() {}
|
||||
pub const fn is_default_layout() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
pub const fn get_flash_regions() -> &'static [&'static FlashRegion] {
|
||||
&FLASH_REGIONS
|
||||
|
@ -7,7 +7,9 @@ use super::{FlashRegion, FlashSector, BANK1_REGION, FLASH_REGIONS, WRITE_SIZE};
|
||||
use crate::flash::Error;
|
||||
use crate::pac;
|
||||
|
||||
pub const fn set_default_layout() {}
|
||||
pub const fn is_default_layout() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
const fn is_dual_bank() -> bool {
|
||||
FLASH_REGIONS.len() == 2
|
||||
|
@ -6,7 +6,9 @@ use super::{FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE};
|
||||
use crate::flash::Error;
|
||||
use crate::pac;
|
||||
|
||||
pub const fn set_default_layout() {}
|
||||
pub const fn is_default_layout() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
pub const fn get_flash_regions() -> &'static [&'static FlashRegion] {
|
||||
&FLASH_REGIONS
|
||||
|
@ -2,7 +2,9 @@
|
||||
|
||||
use super::{Error, FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE};
|
||||
|
||||
pub const fn set_default_layout() {}
|
||||
pub const fn is_default_layout() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
pub const fn get_flash_regions() -> &'static [&'static FlashRegion] {
|
||||
&FLASH_REGIONS
|
||||
|
Loading…
Reference in New Issue
Block a user