aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/flash/f4.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-stm32/src/flash/f4.rs')
-rw-r--r--embassy-stm32/src/flash/f4.rs24
1 files changed, 16 insertions, 8 deletions
diff --git a/embassy-stm32/src/flash/f4.rs b/embassy-stm32/src/flash/f4.rs
index 62e0492b5..9c5051492 100644
--- a/embassy-stm32/src/flash/f4.rs
+++ b/embassy-stm32/src/flash/f4.rs
@@ -1,10 +1,10 @@
1use core::ptr::write_volatile; 1use core::ptr::write_volatile;
2use core::sync::atomic::{fence, AtomicBool, Ordering}; 2use core::sync::atomic::{AtomicBool, Ordering, fence};
3 3
4use embassy_sync::waitqueue::AtomicWaker; 4use embassy_sync::waitqueue::AtomicWaker;
5use pac::flash::regs::Sr; 5use pac::flash::regs::Sr;
6 6
7use super::{get_flash_regions, FlashBank, FlashSector, WRITE_SIZE}; 7use super::{FlashBank, FlashSector, WRITE_SIZE, get_flash_regions};
8use crate::_generated::FLASH_SIZE; 8use crate::_generated::FLASH_SIZE;
9use crate::flash::Error; 9use crate::flash::Error;
10use crate::pac; 10use crate::pac;
@@ -246,7 +246,9 @@ pub(crate) fn assert_not_corrupted_read(end_address: u32) {
246 feature = "stm32f439zi", 246 feature = "stm32f439zi",
247 ))] 247 ))]
248 if second_bank_read && pac::DBGMCU.idcode().read().rev_id() < REVISION_3 && !pa12_is_output_pull_low() { 248 if second_bank_read && pac::DBGMCU.idcode().read().rev_id() < REVISION_3 && !pa12_is_output_pull_low() {
249 panic!("Read corruption for stm32f42xxI and stm32f43xxI when PA12 is in use for chips below revision 3, see errata 2.2.11"); 249 panic!(
250 "Read corruption for stm32f42xxI and stm32f43xxI when PA12 is in use for chips below revision 3, see errata 2.2.11"
251 );
250 } 252 }
251 253
252 #[cfg(any( 254 #[cfg(any(
@@ -270,14 +272,16 @@ pub(crate) fn assert_not_corrupted_read(end_address: u32) {
270 feature = "stm32f439zg", 272 feature = "stm32f439zg",
271 ))] 273 ))]
272 if second_bank_read && pac::DBGMCU.idcode().read().rev_id() < REVISION_3 && !pa12_is_output_pull_low() { 274 if second_bank_read && pac::DBGMCU.idcode().read().rev_id() < REVISION_3 && !pa12_is_output_pull_low() {
273 panic!("Read corruption for stm32f42xxG and stm32f43xxG in dual bank mode when PA12 is in use for chips below revision 3, see errata 2.2.11"); 275 panic!(
276 "Read corruption for stm32f42xxG and stm32f43xxG in dual bank mode when PA12 is in use for chips below revision 3, see errata 2.2.11"
277 );
274 } 278 }
275} 279}
276 280
277#[allow(unused)] 281#[allow(unused)]
278fn pa12_is_output_pull_low() -> bool { 282fn pa12_is_output_pull_low() -> bool {
279 use pac::gpio::vals;
280 use pac::GPIOA; 283 use pac::GPIOA;
284 use pac::gpio::vals;
281 const PIN: usize = 12; 285 const PIN: usize = 12;
282 GPIOA.moder().read().moder(PIN) == vals::Moder::OUTPUT 286 GPIOA.moder().read().moder(PIN) == vals::Moder::OUTPUT
283 && GPIOA.pupdr().read().pupdr(PIN) == vals::Pupdr::PULL_DOWN 287 && GPIOA.pupdr().read().pupdr(PIN) == vals::Pupdr::PULL_DOWN
@@ -287,7 +291,7 @@ fn pa12_is_output_pull_low() -> bool {
287#[cfg(test)] 291#[cfg(test)]
288mod tests { 292mod tests {
289 use super::*; 293 use super::*;
290 use crate::flash::{get_sector, FlashBank}; 294 use crate::flash::{FlashBank, get_sector};
291 295
292 #[test] 296 #[test]
293 #[cfg(stm32f429)] 297 #[cfg(stm32f429)]
@@ -370,9 +374,13 @@ mod tests {
370#[cfg(all(bank_setup_configurable))] 374#[cfg(all(bank_setup_configurable))]
371pub(crate) fn check_bank_setup() { 375pub(crate) fn check_bank_setup() {
372 if cfg!(feature = "single-bank") && pac::FLASH.optcr().read().db1m() { 376 if cfg!(feature = "single-bank") && pac::FLASH.optcr().read().db1m() {
373 panic!("Embassy is configured as single-bank, but the hardware is running in dual-bank mode. Change the hardware by changing the db1m value in the user option bytes or configure embassy to use dual-bank config"); 377 panic!(
378 "Embassy is configured as single-bank, but the hardware is running in dual-bank mode. Change the hardware by changing the db1m value in the user option bytes or configure embassy to use dual-bank config"
379 );
374 } 380 }
375 if cfg!(feature = "dual-bank") && !pac::FLASH.optcr().read().db1m() { 381 if cfg!(feature = "dual-bank") && !pac::FLASH.optcr().read().db1m() {
376 panic!("Embassy is configured as dual-bank, but the hardware is running in single-bank mode. Change the hardware by changing the db1m value in the user option bytes or configure embassy to use single-bank config"); 382 panic!(
383 "Embassy is configured as dual-bank, but the hardware is running in single-bank mode. Change the hardware by changing the db1m value in the user option bytes or configure embassy to use single-bank config"
384 );
377 } 385 }
378} 386}