Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Add C++ header generation #120

Open
ikskuh opened this issue Feb 29, 2024 · 0 comments
Open

Add C++ header generation #120

ikskuh opened this issue Feb 29, 2024 · 0 comments

Comments

@ikskuh
Copy link

ikskuh commented Feb 29, 2024

We should be able to emit a well-formatted C++ header from regz so we can also support users to have C code in their project that can access registers.

Imho, we can support registers way better in C++ than in C and provide features similar to MicroZig where we can have something like

using regs = microzig::chip::registers;
using pinfunc = regs::io::bank0::gpio0::function;

regs::io::bank0::gpio0::ctrl.access() // returns a current value + pointer to register as a struct
    .set_ctrl(pinfunc::uart) // modifies bits in the saved state
    .apply(); // writes back the bits to the register

instead of

IO_BANK0_GPIO0_CTRL |= IO_BANK0_GPIO0_CTRL_FUNCSEL_UART;

With such an API, several changes can be written at once, providing a high level readable API similar to what we have in Zig.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant