Add MAX_ERASE_SIZE const in build script, and use it in flash-wide implementation of embedded-storage traits
This commit is contained in:
parent
1c68c62ebd
commit
095f5ef279
@ -255,6 +255,14 @@ fn main() {
|
||||
];
|
||||
});
|
||||
|
||||
let max_erase_size = flash_memory_regions
|
||||
.iter()
|
||||
.map(|region| region.settings.as_ref().unwrap().erase_size)
|
||||
.max()
|
||||
.unwrap();
|
||||
|
||||
g.extend(quote! { pub const MAX_ERASE_SIZE: u32 = #max_erase_size });
|
||||
|
||||
g.extend(quote! { pub mod flash_regions { #flash_regions } });
|
||||
|
||||
// ========
|
||||
|
@ -2,7 +2,7 @@ use atomic_polyfill::{fence, Ordering};
|
||||
use embassy_hal_common::drop::OnDrop;
|
||||
use embassy_hal_common::{into_ref, PeripheralRef};
|
||||
|
||||
use super::{family, Error, FlashLayout, FlashRegion, FlashSector, FLASH_BASE, FLASH_SIZE, WRITE_SIZE};
|
||||
use super::{family, Error, FlashLayout, FlashRegion, FlashSector, FLASH_BASE, FLASH_SIZE, MAX_ERASE_SIZE, WRITE_SIZE};
|
||||
use crate::flash::FlashBank;
|
||||
use crate::Peripheral;
|
||||
|
||||
@ -179,8 +179,8 @@ impl embedded_storage::nor_flash::ReadNorFlash for Flash<'_> {
|
||||
}
|
||||
|
||||
impl embedded_storage::nor_flash::NorFlash for Flash<'_> {
|
||||
const WRITE_SIZE: usize = 8;
|
||||
const ERASE_SIZE: usize = 2048;
|
||||
const WRITE_SIZE: usize = WRITE_SIZE;
|
||||
const ERASE_SIZE: usize = MAX_ERASE_SIZE;
|
||||
|
||||
fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error> {
|
||||
self.blocking_write(offset, bytes)
|
||||
|
@ -7,6 +7,7 @@ mod common;
|
||||
pub use common::*;
|
||||
|
||||
pub use crate::_generated::flash_regions::*;
|
||||
pub use crate::_generated::MAX_ERASE_SIZE;
|
||||
pub use crate::pac::{FLASH_BASE, FLASH_SIZE, WRITE_SIZE};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
Loading…
Reference in New Issue
Block a user