nucleus-db 0.0.1

STM32 constraint database: pin/AF/peripheral lookup tables for the Nucleus toolchain
Documentation
//! Alternate-function data for the STM32F446RE.
//!
//! [`F446RE`] is the full-device table generated at build time by `build.rs`
//! from the vendored ST pin data in `packdata/` (see [`crate::pack`]).
//!
//! [`SEED`] is a small, manually checked subset covering the peripherals used
//! in the README's example `stm32.toml`, verified against the STM32F446xx
//! datasheet "Alternate function mapping" table (DS10693). It is kept purely
//! as a cross-validation oracle: a unit test asserts every seed entry appears
//! identically in the generated table, so a regression in the parser or bad
//! upstream data fails the build.
//!
//! Each entry is `(pin, AF number, peripheral, signal)`.

use crate::{AfMapping, Pin, Port};

const fn map(
    port: Port,
    number: u8,
    af: u8,
    peripheral: &'static str,
    signal: &'static str,
) -> AfMapping {
    AfMapping {
        pin: Pin::new(port, number),
        af,
        peripheral,
        signal,
    }
}

// Defines `pub(crate) const F446RE`, generated by build.rs from packdata/.
include!(concat!(env!("OUT_DIR"), "/f446re_gen.rs"));

#[cfg(test)]
pub(crate) const SEED: &[AfMapping] = &[
    // SPI1 (AF5)
    map(Port::A, 4, 5, "SPI1", "NSS"),
    map(Port::A, 5, 5, "SPI1", "SCK"),
    map(Port::A, 6, 5, "SPI1", "MISO"),
    map(Port::A, 7, 5, "SPI1", "MOSI"),
    // USART2 (AF7)
    map(Port::A, 2, 7, "USART2", "TX"),
    map(Port::A, 3, 7, "USART2", "RX"),
    // I2C1 (AF4)
    map(Port::B, 8, 4, "I2C1", "SCL"),
    map(Port::B, 9, 4, "I2C1", "SDA"),
    // TIM2 (AF1)
    map(Port::A, 0, 1, "TIM2", "CH1"),
    map(Port::A, 1, 1, "TIM2", "CH2"),
];