Device::nvic_priority_bits as an `Option<u8>

This commit is contained in:
JackN 2023-03-22 17:26:38 -04:00
parent 9c8ef4b931
commit 6ed3e9d688
5 changed files with 8 additions and 6 deletions

View File

@ -692,8 +692,8 @@ fn process_core(
}; };
let chip_nvic = group.ips.values().find(|x| x.name == want_nvic_name).unwrap(); 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) // 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").unwrap_or(&0)) as u8; 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 mut header_irqs = h.interrupts.get(core_name).unwrap().clone();
let chip_irqs = chip_interrupts let chip_irqs = chip_interrupts

View File

@ -62,7 +62,8 @@ pub mod chip {
pub struct Core { pub struct Core {
pub name: String, pub name: String,
pub peripherals: Vec<core::Peripheral>, pub peripherals: Vec<core::Peripheral>,
pub nvic_priority_bits: u8, #[serde(skip_serializing_if = "Option::is_none")]
pub nvic_priority_bits: Option<u8>,
pub interrupts: Vec<core::Interrupt>, pub interrupts: Vec<core::Interrupt>,
pub dma_channels: Vec<core::DmaChannels>, pub dma_channels: Vec<core::DmaChannels>,
} }

View File

@ -5,7 +5,7 @@ pub struct Metadata {
pub line: &'static str, pub line: &'static str,
pub memory: &'static [MemoryRegion], pub memory: &'static [MemoryRegion],
pub peripherals: &'static [Peripheral], pub peripherals: &'static [Peripheral],
pub nvic_priority_bits: u8, pub nvic_priority_bits: Option<u8>,
pub interrupts: &'static [Interrupt], pub interrupts: &'static [Interrupt],
pub dma_channels: &'static [DmaChannel], pub dma_channels: &'static [DmaChannel],
} }

View File

@ -38,7 +38,8 @@ pub enum MemoryRegionKind {
pub struct Core { pub struct Core {
pub name: String, pub name: String,
pub peripherals: Vec<Peripheral>, pub peripherals: Vec<Peripheral>,
pub nvic_priority_bits: u8, #[serde(default)]
pub nvic_priority_bits: Option<u8>,
pub interrupts: Vec<Interrupt>, pub interrupts: Vec<Interrupt>,
pub dma_channels: Vec<DmaChannel>, pub dma_channels: Vec<DmaChannel>,
} }

View File

@ -195,7 +195,7 @@ impl Gen {
line: {:?}, line: {:?},
memory: {}, memory: {},
peripherals: PERIPHERALS, peripherals: PERIPHERALS,
nvic_priority_bits: {}, nvic_priority_bits: {:?},
interrupts: INTERRUPTS, interrupts: INTERRUPTS,
dma_channels: DMA_CHANNELS, dma_channels: DMA_CHANNELS,
}};", }};",