Remove flash size

This commit is contained in:
starship 2023-03-01 10:58:59 +03:00
parent 1c6fa0e802
commit 0ebc58c21f
2 changed files with 1 additions and 16 deletions

View File

@ -33,55 +33,46 @@ use cortex_m::interrupt;
#[cfg(any(stm32f0, stm32f3))] #[cfg(any(stm32f0, stm32f3))]
mod pointers { mod pointers {
pub const DEVICE_ID_PTR: *const u8 = 0x1FFF_F7AC as _; pub const DEVICE_ID_PTR: *const u8 = 0x1FFF_F7AC as _;
pub const FLASH_SIZE_PTR: *const u16 = 0x1FFF_F7CC as _;
} }
#[cfg(stm32f1)] #[cfg(stm32f1)]
mod pointers { mod pointers {
pub const DEVICE_ID_PTR: *const u8 = 0x1FFF_F7E8 as _; pub const DEVICE_ID_PTR: *const u8 = 0x1FFF_F7E8 as _;
pub const FLASH_SIZE_PTR: *const u16 = 0x1FFF_F7E0 as _;
} }
#[cfg(any(stm32f2, stm32f4))] #[cfg(any(stm32f2, stm32f4))]
mod pointers { mod pointers {
pub const DEVICE_ID_PTR: *const u8 = 0x1FFF_7A10 as _; pub const DEVICE_ID_PTR: *const u8 = 0x1FFF_7A10 as _;
pub const FLASH_SIZE_PTR: *const u16 = 0x1FFF_7A22 as _;
} }
#[cfg(any(stm32f72x, stm32f73x))] #[cfg(any(stm32f72x, stm32f73x))]
mod pointers { mod pointers {
pub const DEVICE_ID_PTR: *const u8 = 0x1FF0_7A10 as _; pub const DEVICE_ID_PTR: *const u8 = 0x1FF0_7A10 as _;
pub const FLASH_SIZE_PTR: *const u16 = 0x1FF0_7A22 as _;
} }
#[cfg(any(stm32f76x, stm32f77x))] #[cfg(any(stm32f76x, stm32f77x))]
mod pointers { mod pointers {
pub const DEVICE_ID_PTR: *const u8 = 0x1FF0_F420 as _; pub const DEVICE_ID_PTR: *const u8 = 0x1FF0_F420 as _;
pub const FLASH_SIZE_PTR: *const u16 = 0x1FF0_F442 as _;
} }
#[cfg(any(stm32g0, stm32l4, stm32wb5x))] #[cfg(any(stm32g0, stm32l4, stm32wb5x))]
mod pointers { mod pointers {
pub const DEVICE_ID_PTR: *const u8 = 0x1FFF_7590 as _; pub const DEVICE_ID_PTR: *const u8 = 0x1FFF_7590 as _;
pub const FLASH_SIZE_PTR: *const u16 = 0x1FFF_75E0 as _;
} }
#[cfg(any(stm32h72x, stm32h73x, stm32h74x, stm32h75x))] #[cfg(any(stm32h72x, stm32h73x, stm32h74x, stm32h75x))]
mod pointers { mod pointers {
pub const DEVICE_ID_PTR: *const u8 = 0x1FF1_E800 as _; pub const DEVICE_ID_PTR: *const u8 = 0x1FF1_E800 as _;
pub const FLASH_SIZE_PTR: *const u16 = 0x1FF1_E880 as _;
} }
#[cfg(any(stm32h7ax, stm32h7bx))] #[cfg(any(stm32h7ax, stm32h7bx))]
mod pointers { mod pointers {
pub const DEVICE_ID_PTR: *const u8 = 0x08FF_F800 as _; pub const DEVICE_ID_PTR: *const u8 = 0x08FF_F800 as _;
pub const FLASH_SIZE_PTR: *const u16 = 0x08FF_F80C as _;
} }
#[cfg(stm32l0)] #[cfg(stm32l0)]
mod pointers { mod pointers {
pub const DEVICE_ID_PTR: *const u8 = 0x1FF8_0050 as _; pub const DEVICE_ID_PTR: *const u8 = 0x1FF8_0050 as _;
pub const FLASH_SIZE_PTR: *const u16 = 0x1FF8_007C as _;
} }
use pointers::*; use pointers::*;
@ -111,8 +102,3 @@ pub fn device_id_hex() -> &'static str {
core::str::from_utf8_unchecked(&DEVICE_ID_STR) core::str::from_utf8_unchecked(&DEVICE_ID_STR)
} }
} }
/// Returns the Flash memory size of the device in Kbytes
pub fn flash_size_kb() -> u16 {
unsafe { *FLASH_SIZE_PTR }
}

View File

@ -4,7 +4,7 @@
use cortex_m_rt::entry; use cortex_m_rt::entry;
use defmt::*; use defmt::*;
use embassy_stm32::device_signature::{device_id, device_id_hex, flash_size_kb}; use embassy_stm32::device_signature::{device_id, device_id_hex};
use {defmt_rtt as _, panic_probe as _}; use {defmt_rtt as _, panic_probe as _};
#[entry] #[entry]
@ -12,7 +12,6 @@ fn main() -> ! {
// Example to show how to read the unique id of the mcu // Example to show how to read the unique id of the mcu
info!("Device ID: {:?}", device_id()); info!("Device ID: {:?}", device_id());
info!("Device Hex ID: {:?}", device_id_hex()); info!("Device Hex ID: {:?}", device_id_hex());
info!("Flash Size in KB = {:?}", flash_size_kb());
// Main is done, run this future that never finishes // Main is done, run this future that never finishes
loop { loop {