Let flash module be conditionally included
This commit is contained in:
parent
ddbd509865
commit
b7dfc8de10
@ -162,11 +162,13 @@ fn main() {
|
|||||||
|
|
||||||
let regions_len = flash_memory_regions.len();
|
let regions_len = flash_memory_regions.len();
|
||||||
flash_regions.extend(quote! {
|
flash_regions.extend(quote! {
|
||||||
|
#[cfg(flash)]
|
||||||
pub struct FlashRegions<'d> {
|
pub struct FlashRegions<'d> {
|
||||||
_inner: embassy_hal_common::PeripheralRef<'d, crate::peripherals::FLASH>,
|
_inner: embassy_hal_common::PeripheralRef<'d, crate::peripherals::FLASH>,
|
||||||
#(#fields),*
|
#(#fields),*
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(flash)]
|
||||||
impl<'d> FlashRegions<'d> {
|
impl<'d> FlashRegions<'d> {
|
||||||
pub(crate) const fn new(p: embassy_hal_common::PeripheralRef<'d, crate::peripherals::FLASH>) -> Self {
|
pub(crate) const fn new(p: embassy_hal_common::PeripheralRef<'d, crate::peripherals::FLASH>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
@ -6,8 +6,6 @@ use super::{FlashRegion, FlashSector, BANK1, WRITE_SIZE};
|
|||||||
use crate::flash::Error;
|
use crate::flash::Error;
|
||||||
use crate::pac;
|
use crate::pac;
|
||||||
|
|
||||||
const ERASE_SIZE: usize = BANK1::SETTINGS.erase_size;
|
|
||||||
|
|
||||||
pub(crate) unsafe fn lock() {
|
pub(crate) unsafe fn lock() {
|
||||||
#[cfg(any(flash_wl, flash_wb, flash_l4))]
|
#[cfg(any(flash_wl, flash_wb, flash_l4))]
|
||||||
pac::FLASH.cr().modify(|w| w.set_lock(true));
|
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))]
|
#[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)]
|
#[cfg(flash_l4)]
|
||||||
let (idx, bank) = if idx > 255 { (idx - 256, true) } else { (idx, false) };
|
let (idx, bank) = if idx > 255 { (idx - 256, true) } else { (idx, false) };
|
||||||
|
@ -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,
|
|
||||||
}
|
|
@ -43,17 +43,8 @@ pub mod i2c;
|
|||||||
|
|
||||||
#[cfg(crc)]
|
#[cfg(crc)]
|
||||||
pub mod crc;
|
pub mod crc;
|
||||||
#[cfg(any(
|
#[cfg(flash)]
|
||||||
flash_l0, flash_l1, flash_wl, flash_wb, flash_l4, flash_f3, flash_f4, flash_f7, flash_h7
|
|
||||||
))]
|
|
||||||
pub mod 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;
|
pub mod pwm;
|
||||||
#[cfg(rng)]
|
#[cfg(rng)]
|
||||||
pub mod rng;
|
pub mod rng;
|
||||||
|
Loading…
Reference in New Issue
Block a user