Giter Site home page Giter Site logo

svd8zig's Introduction

Sorry guys, this is my spin on svg4zig. Lower case regs, updated zig version + fixed some bugs. Have absolutely no time to prettify it or write any sensible description. I use it in my project so should be kept up to date for some time.

Plans: I plan to merge dma0/dma1/dmaX into array of the same type since it is derived from the same reg group type. WHy: zig embeded group is unmaintained and has poor approach to svd file conversion.

svd4zig

Generate Zig header files from CMSIS-SVD files for accessing MMIO registers.

Features

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:

  • This was the one used as a starting point
  • 100% in Zig
  • Naming conventions are taken from the datasheet (i.e. all caps), so it's easy to follow along
  • Strong Assumptions™ in the svd are targeted towards STM32 devices (the original used a STM32F767ZG, this fork was developed with an STM32F407)
  • The tool doesn't just output registers but also other information about the device (e.g. interrupts)

Features taken from lynaghk's svd2zig:

  • Registers are modeled with packed structs (see this post from the original authors)

New features:

  • Unused bits are manually aligned to 8 bit boundaries to avoid incurring in this bug

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.

Build:

zig build -Drelease-safe

Usage:

./zig-cache/bin/svd4zig path/to/svd/file > path/to/output.zig
zig fmt path/to/output.zig

Suggested location to find SVD file:

https://github.com/posborne/cmsis-svd

How to use the generated code:

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) {}

svd8zig's People

Contributors

justinbalexander avatar rbino avatar marnix avatar 16hournaps avatar kyrias avatar firefox317 avatar ikubaku avatar markfirmware avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.