Remove Drop for AltFlashLayout

This commit is contained in:
Rasmus Melchior Jacobsen 2023-05-23 22:50:41 +02:00
parent 879c621394
commit faf506b300
7 changed files with 19 additions and 7 deletions

View File

@ -17,6 +17,7 @@ impl<'d> Flash<'d> {
}
pub fn into_regions(self) -> FlashLayout<'d> {
family::set_default_layout();
FlashLayout::new(self.release())
}

View File

@ -7,6 +7,8 @@ use super::{FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE};
use crate::flash::Error;
use crate::pac;
pub const fn set_default_layout() {}
pub const fn get_flash_regions() -> &'static [&'static FlashRegion] {
&FLASH_REGIONS
}

View File

@ -7,6 +7,8 @@ use super::{FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE};
use crate::flash::Error;
use crate::pac;
pub const fn set_default_layout() {}
pub const fn get_flash_regions() -> &'static [&'static FlashRegion] {
&FLASH_REGIONS
}

View File

@ -79,19 +79,20 @@ mod alt_regions {
}
}
impl Drop for AltFlashLayout<'_> {
fn drop(&mut self) {
unsafe {
super::lock();
crate::pac::FLASH.optcr().modify(|r| r.set_db1m(false))
};
}
}
}
#[cfg(any(stm32f427, stm32f429, stm32f437, stm32f439, stm32f469, stm32f479))]
pub use alt_regions::{AltFlashLayout, ALT_FLASH_REGIONS};
#[cfg(any(stm32f427, stm32f429, stm32f437, stm32f439, stm32f469, stm32f479))]
pub fn set_default_layout() {
unsafe { crate::pac::FLASH.optcr().modify(|r| r.set_db1m(false)) };
}
#[cfg(not(any(stm32f427, stm32f429, stm32f437, stm32f439, stm32f469, stm32f479)))]
pub const fn set_default_layout() {}
#[cfg(any(stm32f427, stm32f429, stm32f437, stm32f439, stm32f469, stm32f479))]
pub fn get_flash_regions() -> &'static [&'static FlashRegion] {
if unsafe { pac::FLASH.optcr().read().db1m() } {

View File

@ -6,6 +6,8 @@ use super::{FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE};
use crate::flash::Error;
use crate::pac;
pub const fn set_default_layout() {}
pub const fn get_flash_regions() -> &'static [&'static FlashRegion] {
&FLASH_REGIONS
}

View File

@ -7,6 +7,8 @@ use super::{FlashRegion, FlashSector, BANK1_REGION, FLASH_REGIONS, WRITE_SIZE};
use crate::flash::Error;
use crate::pac;
pub const fn set_default_layout() {}
const fn is_dual_bank() -> bool {
FLASH_REGIONS.len() == 2
}

View File

@ -6,6 +6,8 @@ use super::{FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE};
use crate::flash::Error;
use crate::pac;
pub const fn set_default_layout() {}
pub const fn get_flash_regions() -> &'static [&'static FlashRegion] {
&FLASH_REGIONS
}