diff --git a/Cargo.lock b/Cargo.lock index 7bd0cdb..75bf756 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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", diff --git a/stm32-data-gen/Cargo.toml b/stm32-data-gen/Cargo.toml index ba8f21e..6ae7720 100644 --- a/stm32-data-gen/Cargo.toml +++ b/stm32-data-gen/Cargo.toml @@ -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" } diff --git a/stm32-metapac-gen/Cargo.toml b/stm32-metapac-gen/Cargo.toml index f9a12fb..60eddef 100644 --- a/stm32-metapac-gen/Cargo.toml +++ b/stm32-metapac-gen/Cargo.toml @@ -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" diff --git a/stm32-metapac-gen/src/data.rs b/stm32-metapac-gen/src/data.rs index 9e3549d..dc24d63 100644 --- a/stm32-metapac-gen/src/data.rs +++ b/stm32-metapac-gen/src/data.rs @@ -158,7 +158,10 @@ pub mod ir { pub items: Vec, } - #[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, @@ -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, } -#[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, } +// 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, } +// 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,