diff options
| author | Dominik Sliwa <[email protected]> | 2023-08-18 22:10:13 +0200 |
|---|---|---|
| committer | Dominik Sliwa <[email protected]> | 2023-08-18 23:44:56 +0200 |
| commit | 5bc0175be9482be4737dfffd3a615cee3301e775 (patch) | |
| tree | c595044255c71a0e0d6a17d011bfc17709f6d43d /embassy-stm32/src/flash | |
| parent | 97da34595cb9943affadb1ce8785556108b977df (diff) | |
configure flash latency after axi clock and handle different flash in STM32H7A/B devices
Diffstat (limited to 'embassy-stm32/src/flash')
| -rw-r--r-- | embassy-stm32/src/flash/h7.rs | 12 | ||||
| -rw-r--r-- | embassy-stm32/src/flash/mod.rs | 4 |
2 files changed, 13 insertions, 3 deletions
diff --git a/embassy-stm32/src/flash/h7.rs b/embassy-stm32/src/flash/h7.rs index bb429d773..625bf13fc 100644 --- a/embassy-stm32/src/flash/h7.rs +++ b/embassy-stm32/src/flash/h7.rs | |||
| @@ -11,7 +11,7 @@ pub const fn is_default_layout() -> bool { | |||
| 11 | } | 11 | } |
| 12 | 12 | ||
| 13 | const fn is_dual_bank() -> bool { | 13 | const fn is_dual_bank() -> bool { |
| 14 | FLASH_REGIONS.len() == 2 | 14 | FLASH_REGIONS.len() >= 2 |
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | pub fn get_flash_regions() -> &'static [&'static FlashRegion] { | 17 | pub fn get_flash_regions() -> &'static [&'static FlashRegion] { |
| @@ -49,6 +49,7 @@ pub(crate) unsafe fn blocking_write(start_address: u32, buf: &[u8; WRITE_SIZE]) | |||
| 49 | }; | 49 | }; |
| 50 | bank.cr().write(|w| { | 50 | bank.cr().write(|w| { |
| 51 | w.set_pg(true); | 51 | w.set_pg(true); |
| 52 | #[cfg(flash_h7)] | ||
| 52 | w.set_psize(2); // 32 bits at once | 53 | w.set_psize(2); // 32 bits at once |
| 53 | }); | 54 | }); |
| 54 | cortex_m::asm::isb(); | 55 | cortex_m::asm::isb(); |
| @@ -85,7 +86,10 @@ pub(crate) unsafe fn blocking_erase_sector(sector: &FlashSector) -> Result<(), E | |||
| 85 | let bank = pac::FLASH.bank(sector.bank as usize); | 86 | let bank = pac::FLASH.bank(sector.bank as usize); |
| 86 | bank.cr().modify(|w| { | 87 | bank.cr().modify(|w| { |
| 87 | w.set_ser(true); | 88 | w.set_ser(true); |
| 88 | w.set_snb(sector.index_in_bank) | 89 | #[cfg(flash_h7)] |
| 90 | w.set_snb(sector.index_in_bank); | ||
| 91 | #[cfg(flash_h7ab)] | ||
| 92 | w.set_ssn(sector.index_in_bank); | ||
| 89 | }); | 93 | }); |
| 90 | 94 | ||
| 91 | bank.cr().modify(|w| { | 95 | bank.cr().modify(|w| { |
| @@ -126,6 +130,10 @@ unsafe fn blocking_wait_ready(bank: pac::flash::Bank) -> Result<(), Error> { | |||
| 126 | error!("incerr"); | 130 | error!("incerr"); |
| 127 | return Err(Error::Seq); | 131 | return Err(Error::Seq); |
| 128 | } | 132 | } |
| 133 | if sr.crcrderr() { | ||
| 134 | error!("crcrderr"); | ||
| 135 | return Err(Error::Seq); | ||
| 136 | } | ||
| 129 | if sr.operr() { | 137 | if sr.operr() { |
| 130 | return Err(Error::Prog); | 138 | return Err(Error::Prog); |
| 131 | } | 139 | } |
diff --git a/embassy-stm32/src/flash/mod.rs b/embassy-stm32/src/flash/mod.rs index 4308037f2..fb20dcd38 100644 --- a/embassy-stm32/src/flash/mod.rs +++ b/embassy-stm32/src/flash/mod.rs | |||
| @@ -65,9 +65,11 @@ impl FlashRegion { | |||
| 65 | #[cfg_attr(flash_f7, path = "f7.rs")] | 65 | #[cfg_attr(flash_f7, path = "f7.rs")] |
| 66 | #[cfg_attr(flash_g0, path = "g0.rs")] | 66 | #[cfg_attr(flash_g0, path = "g0.rs")] |
| 67 | #[cfg_attr(flash_h7, path = "h7.rs")] | 67 | #[cfg_attr(flash_h7, path = "h7.rs")] |
| 68 | #[cfg_attr(flash_h7ab, path = "h7.rs")] | ||
| 68 | #[cfg_attr( | 69 | #[cfg_attr( |
| 69 | not(any( | 70 | not(any( |
| 70 | flash_l0, flash_l1, flash_l4, flash_wl, flash_wb, flash_f0, flash_f3, flash_f4, flash_f7, flash_g0, flash_h7 | 71 | flash_l0, flash_l1, flash_l4, flash_wl, flash_wb, flash_f0, flash_f3, flash_f4, flash_f7, flash_g0, flash_h7, |
| 72 | flash_h7ab | ||
| 71 | )), | 73 | )), |
| 72 | path = "other.rs" | 74 | path = "other.rs" |
| 73 | )] | 75 | )] |
