You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Jacob Peters 44201d5370 Add core registers for Cortex M0 and M0+ (#86)
* Refactored core register functions

Most of this was just renaming function calls

* More refactoring

* Added calls to the core register functions

* Return error on missing NvicPrioBits

* Added function to check the value of vendor _systick_config

This should work but it is a bit brittle.
If vendorSystickConfig isn't lowercase for false it will return true

* Add extra check for vendor_systick_config

* fix formatting
7 months ago
..
.buildkite A quick fix for ATDF codegen and register groups (#59) 7 months ago
.github Fix build api breaks and morale (#85) 7 months ago
.gyro Fix build api breaks and morale (#85) 7 months ago
characterized Characterize (#60) 7 months ago
src Add core registers for Cortex M0 and M0+ (#86) 7 months ago
tests update clap, fix logs of optional types (#48) 7 months ago
.gitattributes Vendor (#19) 7 months ago
.gitignore add parsing the access type for svd (#22) 7 months ago
.gitmodules Vendor (#19) 7 months ago
LICENSE Initial commit 7 months ago
README.md update build badge 7 months ago
build.zig Fix build api breaks and morale (#85) 7 months ago
deps.zig Fix build api breaks and morale (#85) 7 months ago
gyro.lock Fix build api breaks and morale (#85) 7 months ago
gyro.zzz add comptime for uses of ++ (#53) 7 months ago

README.md

regz

Build status

regz is a Zig code generator for microcontrollers. Vendors often publish files that have the details of special function registers, for ARM this is called a "System View Description" (SVD), for AVR the format is called ATDF. This tool outputs a single file for you to start interacting with the hardware:

const regs = @import("nrf52.zig").registers;

pub fn main() void {
    regs.P0.PIN_CNF[17].modify(.{
        .DIR = 1,
        .INPUT = 1,
        .PULL = 0,
        .DRIVE = 0,
        .SENSE = 0,
    });
    regs.P0.OUT.modify(.{ .PIN17 = 1 });
}

NOTE: just including that file is not enough to run code on a microcontroller, this is a fairly low-level tool and it is intended that the generated code be used with something like microzig.

One can get SVD files from your vendor, or another good place is posborne/cmsis-svd, it's a python based SVD parser and they have a large number of files available.

For ATDF you need to unzip the appropriate atpack from the registry.

Building

regz targets zig master.

git clone https://github.com/ZigEmbeddedGroup/regz.git
cd regz
zig build

Using regz to generate code

Files provided may be either SVD or ATDF.

Provide path on command line:

regz <path-to-svd> > my-chip.zig

Provide schema via stdin, must specify the schema type:

cat my-file.svd | regz --schema svd > my-chip.zig

Does this work for RISC-V?

It seems that manufacturers are using SVD to represent registers on their RISC-V based products despite it being an ARM standard. At best regz will generate the register definitions without an interrupt table (for now), if you run into problems issues will be warmly welcomed!

What about MSP430?

TI does have another type of XML-based register schema, it is also unimplemented but planned for support.

Okay but I want [some other architecture/format]

The main idea is to target what LLVM can target, however Zig's C backend in underway so it's likely more exotic architectures could be reached in the future. If you know of any others we should look into, please make an issue!

Roadmap

  • SVD: mostly implemented and usable for mosts MCUs, but a few finishing touches in order to suss out any bugs:
    • nested clusters
    • order generated exactly as defined in schema
    • finalize derivation of different components
    • comprehensive suite of tests
    • RISC-V interrupt table generation
  • ATDF: AVR's register schema format
  • insert name of Texus Insturment's register schema format for MSP430