Use correct index and bank
This commit is contained in:
parent
c212f30be0
commit
7d64f5cda7
@ -77,7 +77,14 @@ pub(crate) unsafe fn blocking_erase(from: u32, to: u32) -> Result<(), Error> {
|
||||
|
||||
#[cfg(any(flash_wl, flash_wb, flash_l4))]
|
||||
{
|
||||
let idx = page / super::ERASE_SIZE as u32;
|
||||
let idx = (page - super::FLASH_BASE as u32) / super::ERASE_SIZE as u32;
|
||||
|
||||
#[cfg(flash_l4)]
|
||||
let (idx, bank) = if idx > 255 {
|
||||
(idx - 256, true)
|
||||
} else {
|
||||
(idx, false)
|
||||
};
|
||||
|
||||
pac::FLASH.cr().modify(|w| {
|
||||
w.set_per(true);
|
||||
@ -86,6 +93,8 @@ pub(crate) unsafe fn blocking_erase(from: u32, to: u32) -> Result<(), Error> {
|
||||
w.set_strt(true);
|
||||
#[cfg(any(flash_l4))]
|
||||
w.set_start(true);
|
||||
#[cfg(any(flash_l4))]
|
||||
w.set_bker(bank);
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user