{"id":14971652,"url":"https://github.com/rahix/avr-device","last_synced_at":"2026-01-07T01:17:14.817Z","repository":{"id":38419099,"uuid":"186051104","full_name":"Rahix/avr-device","owner":"Rahix","description":"Register access crate for AVR microcontrollers","archived":false,"fork":false,"pushed_at":"2025-05-06T07:34:30.000Z","size":737,"stargazers_count":206,"open_issues_count":14,"forks_count":77,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-05-14T22:08:37.110Z","etag":null,"topics":["avr","avr-microcontrollers","rust-embedded","svd2rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rahix.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-05-10T20:34:37.000Z","updated_at":"2025-05-09T00:34:38.000Z","dependencies_parsed_at":"2023-11-14T16:28:46.506Z","dependency_job_id":"aa99572f-67cf-4c11-9037-0382cca4dca6","html_url":"https://github.com/Rahix/avr-device","commit_stats":{"total_commits":283,"total_committers":49,"mean_commits":5.775510204081633,"dds":0.3639575971731449,"last_synced_commit":"2a46a0cc32d38cd98a2c4fc27bc838e8cf94e0db"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rahix%2Favr-device","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rahix%2Favr-device/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rahix%2Favr-device/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rahix%2Favr-device/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rahix","download_url":"https://codeload.github.com/Rahix/avr-device/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254235700,"owners_count":22036964,"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":["avr","avr-microcontrollers","rust-embedded","svd2rust"],"created_at":"2024-09-24T13:45:36.842Z","updated_at":"2026-01-07T01:17:14.812Z","avatar_url":"https://github.com/Rahix.png","language":"Rust","readme":"avr-device [![crates.io page](https://img.shields.io/crates/v/avr-device.svg)](https://crates.io/crates/avr-device) [![docs.rs](https://docs.rs/avr-device/badge.svg)](https://docs.rs/avr-device) ![Continuous Integration](https://github.com/Rahix/avr-device/workflows/Continuous%20Integration/badge.svg)\n==========\nAuto-generated wrappers around registers for AVR microcontrollers.\n\n## Usage\nAdd the following to `Cargo.toml`:\n```toml\n[dependencies.avr-device]\nversion = \"0.8.1\"\nfeatures = [\"atmega32u4\"]\n```\n\nWith the feature you can select which chip you want the register definitions\nfor.  For a full list of supported AVR chips, please check\n[`Cargo.toml`](https://github.com/rahix/avr-device/blob/main/Cargo.toml#L30).\n\n## Build Instructions\nThe PACs (Peripheral Access Crates, or really modules, in our case) **are not**\nchecked into git. Rather, we generate them at build time, via an automated\nprocess implemented in [`build.rs`](./build.rs). It takes the ATDF files\nMicrochip (former Atmel) provides plus some patches of our own making as inputs,\nand outputs a module generated from those device descriptions. These inputs\n**are** checked-in. The process is similar to what the `*bindgen` crates\nprovide, just has more steps. So, in short, building should be a matter of\nselecting the features and running cargo.\n\n### Adding a new Chip\nTo add a new chip:\n\n1. Download the ATDF from \u003chttp://packs.download.atmel.com/\u003e and place it in\n   `vendor/`. Be sure to name it like the Rust module that should be generated.\n2. Add a feature of the same name to `Cargo.toml` (it should enable\n   `device-selected`);\n3. Add any needed patches to a yaml file with the same name under the `patch`\n   directory, ideally by including some of the snippets present in\n   `patch/common` and `patch/timer`; The format is decribed\n   [here](https://github.com/rust-embedded/svdtools#device-and-peripheral-yaml-format),\n   but it should not include the top-level `_svd` key, as that's handled by the\n   build system; If patching is unneeded (it's almost always needed!), the file\n   can be omitted.\n4. Add the module as a feature in [`Cargo.toml`](./Cargo.toml), enabling `device-selected`.\n5. Include the module into the tree, in [`devices.rs`](./src/devices.rs),\n   following the format used by other modules in that file;\n6. Update [`lib.rs`](./src/lib.rs) to conditionally `use` the new MCU module,\n   and add it to the lists of selected and available MCUs in the doc comment.\n7. Finally, try building the crate for your MCU with\n   `cargo build --features \u003cmcu\u003e,rt`.\n8. Also check the built documentation for inconsistencies, via\n   `cargo doc --features \u003cmcu\u003e,rt --open` (it will pop up in your browser).\n   \n## Internals\nSince the vendor does not provide SVDs we can pass to [`svd2rust`][], we\ngenerate one via [`atdf2svd`][]. The sequence is as follows:\n\n1. Check which MCUs are known to the crate\n   ([build.rs:get_available_mcus](./build.rs));\n2. Select which to build for by checking enabled features\n   ([build.rs:select_mcu](./build.rs));\n3. Generate the Rust module ([build.rs:build_mcu_module](./build.rs));\n   \n   Substeps are:\n   1. Register inputs with cargo;\n   2. Get a temporary directory;\n   3. Apply `atdf2svd`;\n   4. If a yaml patch exists, use it via [`svdtools`][] and read the new content\n      / else, read the content of the unpatched file to continue;\n   5. Get the output directory;\n   6. Apply `svd2rust`;\n   7. Run [`prettyplease`][] on the module to make it readable in [`docs.rs`][];\n4. It will be included from `$OUT_DIR/pac/\u003cmcu\u003e.rs` into the path\n   `avr_device::devices::\u003cmcu\u003e` (private), and re-exported as\n   `avr_device::\u003cmcu\u003e` (public).\n\n[`atdf2svd`]: https://github.com/Rahix/atdf2svd\n[`svd2rust`]: https://github.com/rust-embedded/svd2rust\n[`svdtools`]: https://github.com/rust-embedded/svdtools\n[`prettyplease`]: https://github.com/dtolnay/prettyplease\n[`docs.rs`]: https://docs.rs/avr-device/latest/avr_device\n\n## License\n*avr-device* is licensed under either of\n\n * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\nThe vendored *atdf* files are licensed under the Apache License, Version 2.0 ([LICENSE-VENDOR](vendor/LICENSE)).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frahix%2Favr-device","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frahix%2Favr-device","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frahix%2Favr-device/lists"}