From 0d81a207eb4cab5b616104e6818befa5aac9e5f0 Mon Sep 17 00:00:00 2001 From: Harry Brooke Date: Thu, 31 Oct 2024 11:13:45 +0000 Subject: [PATCH] add const FLASH_ERASE_VALUE --- stm32-metapac-gen/src/lib.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/stm32-metapac-gen/src/lib.rs b/stm32-metapac-gen/src/lib.rs index 696c622d6..be0af0c6a 100644 --- a/stm32-metapac-gen/src/lib.rs +++ b/stm32-metapac-gen/src/lib.rs @@ -132,6 +132,18 @@ impl Gen { writeln!(&mut extra, "pub const FLASH_BASE: usize = {};", first_flash.address).unwrap(); writeln!(&mut extra, "pub const FLASH_SIZE: usize = {};", total_flash_size).unwrap(); + let erase_values: HashSet<_> = flash_regions + .iter() + .map(|r| r.settings.as_ref().unwrap().erase_value) + .collect(); + assert_eq!(1, erase_values.len()); + writeln!( + &mut extra, + "pub const FLASH_ERASE_VALUE: u8 = {};", + erase_values.iter().next().unwrap() + ) + .unwrap(); + let write_sizes: HashSet<_> = flash_regions .iter() .map(|r| r.settings.as_ref().unwrap().write_size)