{"id":13710806,"url":"https://github.com/justinbalexander/svd2zig","last_synced_at":"2025-05-06T19:32:39.947Z","repository":{"id":53143155,"uuid":"239372586","full_name":"justinbalexander/svd2zig","owner":"justinbalexander","description":"Convert System View Description (svd) files to Zig headers for baremetal development","archived":false,"fork":false,"pushed_at":"2021-04-04T20:36:37.000Z","size":66,"stargazers_count":30,"open_issues_count":5,"forks_count":26,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-01T10:05:59.888Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/justinbalexander.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-09T20:52:46.000Z","updated_at":"2025-03-24T06:56:27.000Z","dependencies_parsed_at":"2022-08-29T20:00:49.003Z","dependency_job_id":null,"html_url":"https://github.com/justinbalexander/svd2zig","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinbalexander%2Fsvd2zig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinbalexander%2Fsvd2zig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinbalexander%2Fsvd2zig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinbalexander%2Fsvd2zig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/justinbalexander","download_url":"https://codeload.github.com/justinbalexander/svd2zig/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252753741,"owners_count":21799003,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T23:01:01.032Z","updated_at":"2025-05-06T19:32:34.894Z","avatar_url":"https://github.com/justinbalexander.png","language":"Zig","funding_links":[],"categories":["Development Tools","Systems Programming"],"sub_categories":["Embedded Development"],"readme":"# svd2Zig\n\nGenerate\n[Zig](https://ziglang.org/)\nheader files from\n[CMSIS-SVD](http://www.keil.com/pack/doc/CMSIS/SVD/html/index.html)\nfiles for accessing MMIO registers.\n\nThe entire specification is not completely supported yet. The header file that\nwas needed and prompted this repository was for the STM32F767ZG, which is\ncompletely translated into Zig.\n\nFeel free to send pull requests to flesh out the parts of the specification that\nare missing for your project.\n\nThe output is intentionally formatted in the usual C style so that simple\ntext completion capabilities can be used to quickly find the correct register\nvalues and fields. This eliminates the need for a language server protocol\nextension, at the expense of not following the Zig style guide.\n\n## Build:\n\n```\nzig build -Drelease-safe\n```\n\n## Usage:\n\n```\n./zig-cache/bin/svd2zig path/to/svd/file \u003e path/to/output.zig\nzig fmt path/to/output.zig # to prettify\n```\n\n## Suggested location to find SVD file:\n\nhttps://github.com/posborne/cmsis-svd\n\n## Sample Output (after running through zig fmt):\n\n```zig\n/// Access control\npub const AC_BASE_ADDRESS = 0xe000ef90;\n\n/// Instruction and Data Tightly-Coupled Memory           Control Registers\npub const AC_ITCMCR_ADDRESS = 0xe000ef90 + 0x0;\npub const AC_ITCMCR_RESET_VALUE = 0x0;\npub inline fn AC_ITCMCR_Write(setting: u32) void {\n    const write_mask = 0x7f;\n    const mmio_ptr = @intToPtr(*volatile u32, AC_ITCMCR_ADDRESS);\n    mmio_ptr.* = setting \u0026 write_mask;\n}\npub inline fn AC_ITCMCR_Read() u32 {\n    const mmio_ptr = @intToPtr(*volatile u32, AC_ITCMCR_ADDRESS);\n    return mmio_ptr.*;\n}\n\n/// EN\npub const AC_ITCMCR_EN_OFFSET = 0;\npub const AC_ITCMCR_EN_MASK = 0x1 \u003c\u003c AC_ITCMCR_EN_OFFSET;\npub inline fn AC_ITCMCR_EN(setting: u32) u32 {\n    return (setting \u0026 0x1) \u003c\u003c AC_ITCMCR_EN_OFFSET;\n}\n\n/// RMW\npub const AC_ITCMCR_RMW_OFFSET = 1;\npub const AC_ITCMCR_RMW_MASK = 0x1 \u003c\u003c AC_ITCMCR_RMW_OFFSET;\npub inline fn AC_ITCMCR_RMW(setting: u32) u32 {\n    return (setting \u0026 0x1) \u003c\u003c AC_ITCMCR_RMW_OFFSET;\n}\n\n/// RETEN\npub const AC_ITCMCR_RETEN_OFFSET = 2;\npub const AC_ITCMCR_RETEN_MASK = 0x1 \u003c\u003c AC_ITCMCR_RETEN_OFFSET;\npub inline fn AC_ITCMCR_RETEN(setting: u32) u32 {\n    return (setting \u0026 0x1) \u003c\u003c AC_ITCMCR_RETEN_OFFSET;\n}\n\n/// SZ\npub const AC_ITCMCR_SZ_OFFSET = 3;\npub const AC_ITCMCR_SZ_MASK = 0xf \u003c\u003c AC_ITCMCR_SZ_OFFSET;\npub inline fn AC_ITCMCR_SZ(setting: u32) u32 {\n    return (setting \u0026 0xf) \u003c\u003c AC_ITCMCR_SZ_OFFSET;\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustinbalexander%2Fsvd2zig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjustinbalexander%2Fsvd2zig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustinbalexander%2Fsvd2zig/lists"}