make address of registers show as hex

This commit is contained in:
eZio Pan 2024-02-24 13:06:50 +08:00 committed by Dario Nieuwenhuis
parent ca48d94684
commit 24b62ea85d
4 changed files with 59 additions and 6 deletions

2
Cargo.lock generated
View File

@ -85,7 +85,7 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "chiptool"
version = "0.1.0"
source = "git+https://github.com/embassy-rs/chiptool?rev=247ccbe44669ac716393247e56693a396e641e4a#247ccbe44669ac716393247e56693a396e641e4a"
source = "git+https://github.com/embassy-rs/chiptool?rev=1c198ae678ebd426751513f0deab6fbd6f8b8211#1c198ae678ebd426751513f0deab6fbd6f8b8211"
dependencies = [
"anyhow",
"clap",

View File

@ -17,7 +17,7 @@ quick-xml = { version = "0.26.0", features = ["serialize"] }
regex = "1.7.1"
serde = { version = "1.0.157", features = ["derive"] }
serde_yaml = "0.9.19"
chiptool = { git = "https://github.com/embassy-rs/chiptool", rev="247ccbe44669ac716393247e56693a396e641e4a" }
chiptool = { git = "https://github.com/embassy-rs/chiptool", rev = "1c198ae678ebd426751513f0deab6fbd6f8b8211" }
serde_json = "1.0.94"
rayon = { version = "1.7.0", optional = true }
stm32-data-serde = { version = "0.1.0", path = "../stm32-data-serde" }

View File

@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
[dependencies]
regex = "1.7.1"
chiptool = { git = "https://github.com/embassy-rs/chiptool", rev="247ccbe44669ac716393247e56693a396e641e4a" }
chiptool = { git = "https://github.com/embassy-rs/chiptool", rev = "1c198ae678ebd426751513f0deab6fbd6f8b8211" }
serde = { version = "1.0.157", features = [ "derive" ] }
serde_json = "1.0.94"
proc-macro2 = "1.0.52"

View File

@ -158,7 +158,10 @@ pub mod ir {
pub items: Vec<BlockItem>,
}
#[derive(Debug, Eq, PartialEq, Clone, Deserialize)]
// Notice:
// BlockItem has custom Debug implement,
// when modify the struct, make sure Debug impl reflect the change.
#[derive(Eq, PartialEq, Clone, Deserialize)]
pub struct BlockItem {
pub name: String,
pub description: Option<String>,
@ -169,6 +172,20 @@ pub mod ir {
pub inner: BlockItemInner,
}
// Notice:
// Debug implement AFFECT OUTPUT METAPAC, modify with caution
impl std::fmt::Debug for BlockItem {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("BlockItem")
.field("name", &self.name)
.field("description", &self.description)
.field("array", &self.array)
.field("byte_offset", &format_args!("{:#x}", self.byte_offset))
.field("inner", &self.inner)
.finish()
}
}
#[derive(EnumDebug, Eq, PartialEq, Clone, Deserialize)]
pub enum BlockItemInner {
Block(BlockItemBlock),
@ -274,7 +291,10 @@ pub struct Chip {
pub packages: Vec<Package>,
}
#[derive(Debug, Eq, PartialEq, Clone, Deserialize)]
// Notice:
// MemoryRegion has custom Debug implement,
// when modify the struct, make sure Debug impl reflect the change.
#[derive(Eq, PartialEq, Clone, Deserialize)]
pub struct MemoryRegion {
pub name: String,
pub kind: MemoryRegionKind,
@ -283,6 +303,20 @@ pub struct MemoryRegion {
pub settings: Option<FlashSettings>,
}
// Notice:
// Debug implement AFFECT OUTPUT METAPAC, modify with caution
impl std::fmt::Debug for MemoryRegion {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("MemoryRegion")
.field("name", &self.name)
.field("kind", &self.kind)
.field("address", &format_args!("{:#x}", self.address))
.field("size", &self.size)
.field("settings", &self.settings)
.finish()
}
}
#[derive(Debug, Eq, PartialEq, Clone, Deserialize)]
pub struct FlashSettings {
pub erase_size: u32,
@ -320,7 +354,10 @@ pub struct Package {
pub package: String,
}
#[derive(Debug, Eq, PartialEq, Clone, Deserialize)]
// Notice:
// Peripheral has custom Debug implement,
// when modify struct, make sure Debug impl reflect the change.
#[derive(Eq, PartialEq, Clone, Deserialize)]
pub struct Peripheral {
pub name: String,
pub address: u64,
@ -336,6 +373,22 @@ pub struct Peripheral {
pub interrupts: Vec<PeripheralInterrupt>,
}
// Notice:
// Debug implement AFFECT OUTPUT METAPAC, modify with caution
impl std::fmt::Debug for Peripheral {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Peripheral")
.field("name", &self.name)
.field("address", &format_args!("{:#x}", self.address))
.field("registers", &self.registers)
.field("rcc", &self.rcc)
.field("pins", &self.pins)
.field("dma_channels", &self.dma_channels)
.field("interrupts", &self.interrupts)
.finish()
}
}
#[derive(Debug, Eq, PartialEq, Clone, Deserialize)]
pub struct PeripheralInterrupt {
pub signal: String,