diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index f5bdadf5b..d179f5e0f 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs @@ -162,11 +162,13 @@ fn main() { let regions_len = flash_memory_regions.len(); flash_regions.extend(quote! { + #[cfg(flash)] pub struct FlashRegions<'d> { _inner: embassy_hal_common::PeripheralRef<'d, crate::peripherals::FLASH>, #(#fields),* } + #[cfg(flash)] impl<'d> FlashRegions<'d> { pub(crate) const fn new(p: embassy_hal_common::PeripheralRef<'d, crate::peripherals::FLASH>) -> Self { Self { diff --git a/embassy-stm32/src/flash/l.rs b/embassy-stm32/src/flash/l.rs index c8d060f0a..edcf2b2f0 100644 --- a/embassy-stm32/src/flash/l.rs +++ b/embassy-stm32/src/flash/l.rs @@ -6,8 +6,6 @@ use super::{FlashRegion, FlashSector, BANK1, WRITE_SIZE}; use crate::flash::Error; use crate::pac; -const ERASE_SIZE: usize = BANK1::SETTINGS.erase_size; - pub(crate) unsafe fn lock() { #[cfg(any(flash_wl, flash_wb, flash_l4))] pac::FLASH.cr().modify(|w| w.set_lock(true)); @@ -75,7 +73,7 @@ pub(crate) unsafe fn blocking_erase_sector(sector: &FlashSector) -> Result<(), E #[cfg(any(flash_wl, flash_wb, flash_l4))] { - let idx = (sector.start - super::FLASH_BASE as u32) / ERASE_SIZE as u32; + let idx = (sector.start - super::FLASH_BASE as u32) / BANK1::SETTINGS.erase_size as u32; #[cfg(flash_l4)] let (idx, bank) = if idx > 255 { (idx - 256, true) } else { (idx, false) }; diff --git a/embassy-stm32/src/flash/other.rs b/embassy-stm32/src/flash/other.rs deleted file mode 100644 index 4ffb4cc35..000000000 --- a/embassy-stm32/src/flash/other.rs +++ /dev/null @@ -1,11 +0,0 @@ -pub trait FlashRegion { - const SETTINGS: FlashRegionSettings; -} - -pub struct FlashRegionSettings { - pub base: usize, - pub size: usize, - pub erase_size: usize, - pub write_size: usize, - pub erase_value: u8, -} diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index ddd5c0fdd..2d49c85b4 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs @@ -43,17 +43,8 @@ pub mod i2c; #[cfg(crc)] pub mod crc; -#[cfg(any( - flash_l0, flash_l1, flash_wl, flash_wb, flash_l4, flash_f3, flash_f4, flash_f7, flash_h7 -))] +#[cfg(flash)] pub mod flash; -#[cfg(not(any( - flash_l0, flash_l1, flash_wl, flash_wb, flash_l4, flash_f3, flash_f4, flash_f7, flash_h7 -)))] -pub mod flash { - mod other; - pub use other::FlashRegion; -} pub mod pwm; #[cfg(rng)] pub mod rng;