diff --git a/stm32-data-gen/src/chips.rs b/stm32-data-gen/src/chips.rs index a62cb68..ff585d2 100644 --- a/stm32-data-gen/src/chips.rs +++ b/stm32-data-gen/src/chips.rs @@ -692,8 +692,8 @@ fn process_core( }; let chip_nvic = group.ips.values().find(|x| x.name == want_nvic_name).unwrap(); - // With the current data sources, this value is always either 2 or 4, and never unwraps to None(0) - let nvic_priority_bits = *(defines.0.get("__NVIC_PRIO_BITS").unwrap_or(&0)) as u8; + // With the current data sources, this value is always either 2 or 4, and never resolves to None + let nvic_priority_bits = defines.0.get("__NVIC_PRIO_BITS").map(|bits| *bits as u8); let mut header_irqs = h.interrupts.get(core_name).unwrap().clone(); let chip_irqs = chip_interrupts diff --git a/stm32-data-serde/src/lib.rs b/stm32-data-serde/src/lib.rs index 46fc255..dd44b07 100644 --- a/stm32-data-serde/src/lib.rs +++ b/stm32-data-serde/src/lib.rs @@ -62,7 +62,8 @@ pub mod chip { pub struct Core { pub name: String, pub peripherals: Vec, - pub nvic_priority_bits: u8, + #[serde(skip_serializing_if = "Option::is_none")] + pub nvic_priority_bits: Option, pub interrupts: Vec, pub dma_channels: Vec, } diff --git a/stm32-metapac-gen/res/src/metadata.rs b/stm32-metapac-gen/res/src/metadata.rs index 3e7efc0..2342765 100644 --- a/stm32-metapac-gen/res/src/metadata.rs +++ b/stm32-metapac-gen/res/src/metadata.rs @@ -5,7 +5,7 @@ pub struct Metadata { pub line: &'static str, pub memory: &'static [MemoryRegion], pub peripherals: &'static [Peripheral], - pub nvic_priority_bits: u8, + pub nvic_priority_bits: Option, pub interrupts: &'static [Interrupt], pub dma_channels: &'static [DmaChannel], } diff --git a/stm32-metapac-gen/src/data.rs b/stm32-metapac-gen/src/data.rs index 3298398..38e85d6 100644 --- a/stm32-metapac-gen/src/data.rs +++ b/stm32-metapac-gen/src/data.rs @@ -38,7 +38,8 @@ pub enum MemoryRegionKind { pub struct Core { pub name: String, pub peripherals: Vec, - pub nvic_priority_bits: u8, + #[serde(default)] + pub nvic_priority_bits: Option, pub interrupts: Vec, pub dma_channels: Vec, } diff --git a/stm32-metapac-gen/src/lib.rs b/stm32-metapac-gen/src/lib.rs index 4a91e2c..f2599b9 100644 --- a/stm32-metapac-gen/src/lib.rs +++ b/stm32-metapac-gen/src/lib.rs @@ -195,7 +195,7 @@ impl Gen { line: {:?}, memory: {}, peripherals: PERIPHERALS, - nvic_priority_bits: {}, + nvic_priority_bits: {:?}, interrupts: INTERRUPTS, dma_channels: DMA_CHANNELS, }};",