rbino/svd4zig
Convert System View Description (svd) files to Zig headers for baremetal development
Generate Zig header files from CMSIS-SVD files for accessing MMIO registers.
This is a fork of this svd2zig
that uses the output
format based of this other svd2zig
.
It's named svd4zig
since it's svd2zig * 2
.
Features taken from justinbalexander's svd2zig
:
Features taken from lynaghk's svd2zig
:
New features:
The entire specification is not completely supported yet, feel free to send pull requests to flesh out the parts of the specification that are missing for your project.
zig build -Drelease-safe
./zig-cache/bin/svd4zig path/to/svd/file > path/to/output.zig
zig fmt path/to/output.zig
https://github.com/posborne/cmsis-svd
Have a look at this blogpost for all the details, a short example to set and read some registers:
// registers.zig is the generated file
const regs = @import("registers.zig");
// Enable HSI
regs.RCC.CR.modify(.{ .HSION = 1 });
// Wait for HSI ready
while (regs.RCC.CR.read().HSIRDY != 1) {}
// Select HSI as clock source
regs.RCC.CFGR.modify(.{ .SW0 = 0, .SW1 = 0 });
// Enable external high-speed oscillator (HSE)
regs.RCC.CR.modify(.{ .HSEON = 1 });
// Wait for HSE ready
while (regs.RCC.CR.read().HSERDY != 1) {}