Let sector computation be shared across families

This commit is contained in:
Rasmus Melchior Jacobsen
2023-03-30 08:32:36 +02:00
parent e3c4e00be0
commit e7129371d0
10 changed files with 208 additions and 199 deletions

View File

@@ -3,10 +3,14 @@ use core::ptr::write_volatile;
use atomic_polyfill::{fence, Ordering};
use super::{FlashSector, BANK1_REGION, WRITE_SIZE};
use super::{FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE};
use crate::flash::Error;
use crate::pac;
pub(crate) const fn get_flash_regions() -> &'static [&'static FlashRegion] {
&FLASH_REGIONS
}
pub(crate) unsafe fn lock() {
pac::FLASH.cr().modify(|w| w.set_lock(true));
}
@@ -99,13 +103,3 @@ unsafe fn blocking_wait_ready() -> Result<(), Error> {
}
}
}
pub(crate) fn get_sector(address: u32) -> FlashSector {
let sector_size = BANK1_REGION.erase_size;
let index = address / sector_size;
FlashSector {
index: index as u8,
start: BANK1_REGION.base + index * sector_size,
size: sector_size,
}
}