mirror of
https://github.com/embassy-rs/embassy.git
synced 2025-10-01 06:10:41 +00:00
embassy-stm32. support g0 second flash bank
This commit is contained in:
parent
eaa44c3d3f
commit
f1ffbf2f7e
@ -20,7 +20,7 @@ pub(crate) unsafe fn lock() {
|
||||
}
|
||||
pub(crate) unsafe fn unlock() {
|
||||
// Wait, while the memory interface is busy.
|
||||
while pac::FLASH.sr().read().bsy() {}
|
||||
wait_busy();
|
||||
|
||||
// Unlock flash
|
||||
if pac::FLASH.cr().read().lock() {
|
||||
@ -53,12 +53,16 @@ pub(crate) unsafe fn blocking_write(start_address: u32, buf: &[u8; WRITE_SIZE])
|
||||
|
||||
pub(crate) unsafe fn blocking_erase_sector(sector: &FlashSector) -> Result<(), Error> {
|
||||
let idx = (sector.start - super::FLASH_BASE as u32) / super::BANK1_REGION.erase_size as u32;
|
||||
while pac::FLASH.sr().read().bsy() {}
|
||||
wait_busy();
|
||||
clear_all_err();
|
||||
|
||||
interrupt::free(|_| {
|
||||
pac::FLASH.cr().modify(|w| {
|
||||
w.set_per(true);
|
||||
w.set_bker(sector.bank == crate::flash::FlashBank::Bank2);
|
||||
#[cfg(flash_g0x0)]
|
||||
w.set_pnb(idx as u16);
|
||||
#[cfg(not(flash_g0x0))]
|
||||
w.set_pnb(idx as u8);
|
||||
w.set_strt(true);
|
||||
});
|
||||
@ -94,3 +98,13 @@ pub(crate) unsafe fn clear_all_err() {
|
||||
// This clears all "write 1 to clear" bits.
|
||||
pac::FLASH.sr().modify(|_| {});
|
||||
}
|
||||
|
||||
#[cfg(any(flash_g0x0, flash_g0x1))]
|
||||
fn wait_busy(){
|
||||
while pac::FLASH.sr().read().bsy() & pac::FLASH.sr().read().bsy2() {}
|
||||
}
|
||||
|
||||
#[cfg(not(any(flash_g0x0, flash_g0x1)))]
|
||||
fn wait_busy(){
|
||||
while pac::FLASH.sr().read().bsy() {}
|
||||
}
|
@ -97,7 +97,7 @@ pub enum FlashBank {
|
||||
#[cfg_attr(flash_f2, path = "f2.rs")]
|
||||
#[cfg_attr(flash_f4, path = "f4.rs")]
|
||||
#[cfg_attr(flash_f7, path = "f7.rs")]
|
||||
#[cfg_attr(any(flash_g0, flash_g4c2, flash_g4c3, flash_g4c4), path = "g.rs")]
|
||||
#[cfg_attr(any(flash_g0x0, flash_g0x1, flash_g4c2, flash_g4c3, flash_g4c4), path = "g.rs")]
|
||||
#[cfg_attr(flash_h7, path = "h7.rs")]
|
||||
#[cfg_attr(flash_h7ab, path = "h7.rs")]
|
||||
#[cfg_attr(flash_u5, path = "u5.rs")]
|
||||
@ -107,7 +107,7 @@ pub enum FlashBank {
|
||||
#[cfg_attr(
|
||||
not(any(
|
||||
flash_l0, flash_l1, flash_l4, flash_l5, flash_wl, flash_wb, flash_f0, flash_f1, flash_f2, flash_f3, flash_f4,
|
||||
flash_f7, flash_g0, flash_g4c2, flash_g4c3, flash_g4c4, flash_h7, flash_h7ab, flash_u5, flash_h50, flash_u0,
|
||||
flash_f7, flash_g0x0, flash_g0x1, flash_g4c2, flash_g4c3, flash_g4c4, flash_h7, flash_h7ab, flash_u5, flash_h50, flash_u0,
|
||||
flash_h5,
|
||||
)),
|
||||
path = "other.rs"
|
||||
|
Loading…
x
Reference in New Issue
Block a user