nucleus-compiler
The Nucleus pinmux compiler: the stm32.toml → diagnostics pipeline.
Status (Phase 2 — complete)
config— parsesstm32.tomlinto typed structs (serde+toml). Peripheral tables are kept as raw key→value maps so the parser stays stable as peripherals are added.model— hand-maintained tables mapping config keys (tx,mosi,sda,channel1…) to database signal names, marking required vs. optional pins, and assigning each peripheral to an F446 bus (APB1/APB2/AHB1).solver— validates a parsed config against [nucleus-db] and returns the four Phase-2 conflict classes:- pin collision — two signals on one physical pin
- AF mismatch — a pin that doesn't expose the requested signal on this MCU
- missing required pin — a peripheral declared without a required pin
- clock domain disabled — a peripheral whose bus clock is turned off via
[clocks]
check/check_family— one-call entry points used bynucleus-cli(and, later, the LSP).
Conflicts are returned in deterministic order; a doubly-used pin yields exactly one collision error.
Status (Phase 3 — complete)
codegen— lowers a validated config to two C files viagenerate(&config, &db):nucleus_config.h— a typed config struct per peripheral,externHAL handle declarations, and theNucleus_Init()prototype.nucleus_init.c— resolved config struct instances, handle definitions, and a singleNucleus_Init()that enables GPIO/peripheral clocks, configures alternate-function muxing (GPIO_AF<n>_<PERIPH>numbers fromnucleus-db), and calls stockHAL_*_Initfunctions.
The generated code never reimplements the HAL — only Init calls with resolved parameters, so HAL point-releases don't break output. Output is byte-deterministic (tested). Tested HAL family: STM32F4 (stm32f4xx_hal.h).