stm32-metapac: add option to generate chip metadata as a rust const.

This commit is contained in:
Dario Nieuwenhuis
2022-02-09 00:28:05 +01:00
parent 2cf79f6569
commit 4d73d87b40
3 changed files with 170 additions and 9 deletions

View File

@ -0,0 +1,97 @@
#[derive(Debug, Eq, PartialEq, Clone)]
pub struct Metadata {
pub name: &'static str,
pub family: &'static str,
pub line: &'static str,
pub memory: &'static [MemoryRegion],
pub peripherals: &'static [Peripheral],
pub interrupts: &'static [Interrupt],
pub dma_channels: &'static [DmaChannel],
}
#[derive(Debug, Eq, PartialEq, Clone)]
pub struct MemoryRegion {
pub name: &'static str,
pub kind: MemoryRegionKind,
pub address: u32,
pub size: u32,
}
#[derive(Debug, Eq, PartialEq, Clone)]
pub enum MemoryRegionKind {
Flash,
Ram,
}
#[derive(Debug, Eq, PartialEq, Clone)]
pub struct Interrupt {
pub name: &'static str,
pub number: u32,
}
#[derive(Debug, Eq, PartialEq, Clone)]
pub struct Package {
pub name: &'static str,
pub package: &'static str,
}
#[derive(Debug, Eq, PartialEq, Clone)]
pub struct Peripheral {
pub name: &'static str,
pub address: u64,
pub registers: Option<PeripheralRegisters>,
pub rcc: Option<PeripheralRcc>,
pub pins: &'static [PeripheralPin],
pub dma_channels: &'static [PeripheralDmaChannel],
pub interrupts: &'static [PeripheralInterrupt],
}
#[derive(Debug, Eq, PartialEq, Clone)]
pub struct PeripheralRegisters {
pub kind: &'static str,
pub version: &'static str,
pub block: &'static str,
}
#[derive(Debug, Eq, PartialEq, Clone)]
pub struct PeripheralInterrupt {
pub signal: &'static str,
pub interrupt: &'static str,
}
#[derive(Debug, Eq, PartialEq, Clone)]
pub struct PeripheralRcc {
pub clock: &'static str,
pub enable: Option<PeripheralRccRegister>,
pub reset: Option<PeripheralRccRegister>,
}
#[derive(Debug, Eq, PartialEq, Clone)]
pub struct PeripheralRccRegister {
pub register: &'static str,
pub field: &'static str,
}
#[derive(Debug, Eq, PartialEq, Clone)]
pub struct PeripheralPin {
pub pin: &'static str,
pub signal: &'static str,
pub af: Option<&'static str>,
}
#[derive(Debug, Eq, PartialEq, Clone)]
pub struct DmaChannel {
pub name: &'static str,
pub dma: &'static str,
pub channel: u32,
pub dmamux: Option<&'static str>,
pub dmamux_channel: Option<u32>,
}
#[derive(Debug, Eq, PartialEq, Clone)]
pub struct PeripheralDmaChannel {
pub signal: &'static str,
pub channel: Option<&'static str>,
pub dmamux: Option<&'static str>,
pub request: Option<u32>,
}