/** * CMSIS-SVD parser. * * SVD is the format every Cortex-M vendor publishes to describe a part's * peripherals: base addresses, register offsets, bit fields, and — the part * that matters here — the enumerated meaning of those fields. Decoding * `ENABLE = 4` to `Enabled` is the difference between an LLM reasoning about * a device and guessing about one. * * Four features of the format are load-bearing, and all four appear in the * nRF52840's own file: * * - `derivedFrom`: 31 of its 73 peripherals inherit their entire register map * from a sibling. Ignoring it silently loses 42% of the chip. * - clusters: registers nest, so an address is base + cluster + register. * - `dim` arrays: `DEVICEID[%s]` with dim=2 expands to two registers. * - bit position has three encodings. Nordic uses `lsb`/`msb` for all 2427 of * its fields; other vendors use `bitOffset`/`bitWidth` or `bitRange`. All * three are handled, because assuming one was already wrong once. */ export interface SvdEnum { name: string; value: number; description?: string; } export interface SvdField { name: string; description?: string; /** Least significant bit position. */ lsb: number; /** Bit count, >= 1. */ width: number; enums: SvdEnum[]; } export interface SvdRegister { name: string; description?: string; /** Absolute address: peripheral base + cluster offsets + register offset. */ address: number; size: number; access?: string; resetValue?: number; fields: SvdField[]; } export interface SvdPeripheral { name: string; description?: string; baseAddress: number; groupName?: string; registers: SvdRegister[]; } export interface SvdDevice { name: string; vendor?: string; description?: string; peripherals: SvdPeripheral[]; } /** Raw node captured during the streaming pass, before offsets are resolved. */ interface RawNode { tag: string; attrs: Record; text: string; children: RawNode[]; parent?: RawNode; } /** * Read an SVD from disk into a raw node tree. * * Accepts `.gz` transparently: these files are a couple of megabytes of XML * that compress to about a twentieth of that, and a compressed fixture is far * more pleasant to keep in a repository. */ export declare function loadSvdXml(filePath: string): RawNode; /** Parse an SVD file into a resolved device description. */ export declare function parseSvd(filePath: string): SvdDevice; /** One decoded field of a register value. */ export interface DecodedField { name: string; value: number; /** The enumerated name, when the value matches one. */ meaning?: string; bits: string; description?: string; } /** * Split a raw register value into its named fields. * * This is the whole point of the exercise: `0x00000004` means nothing, while * `ENABLE = 4 (Enabled)` is something to reason about. */ export declare function decodeValue(reg: SvdRegister, value: number): DecodedField[]; export {}; //# sourceMappingURL=parser.d.ts.map