#register #avr #io

nightly no-std snowgoons4809-device

Register access crate for ATmega4809. DO NOT USE unless you have a good reason.

1 unstable release

0.2.4+snowgoons-hack-4809 Sep 3, 2021

#1958 in Embedded development

28 downloads per month

MIT/Apache

3MB
98K SLoC

snowgoons4809-device

THIS IS A TEMPORARY WORKAROUND

This is a hack of Rahix's crate to permit register access on the ATmega4809, which will only exist until 4809 support is available in the main device.

It is published to crates.io purely to satisfy a dependency requirement.

Do not use this directly in new projects unless you have very good reason.

========== Auto-generated wrappers around registers for AVR microcontrollers.

Usage

Add the following to Cargo.toml:

[dependencies.avr-device]
version = "0.2.3"
features = ["atmega32u4"]

Via the feature you can select which chip you want the register specifications for. The following list is what is currently supported:

  • atmega1280
  • atmega168
  • atmega2560
  • atmega8
  • atmega328p
  • atmega32u4
  • atmega48p
  • atmega64
  • atmega644
  • attiny84
  • attiny85
  • attiny88
  • atmega4809

Build Instructions

The version on crates.io is pre-built. The following is only necessary when trying to build this crate from source.

You need to have atdf2svd, svd2rust, form, rustfmt(for the nightly toolchain) and svdtools (>= 0.1.9) installed:

cargo install atdf2svd
cargo install svd2rust
cargo install form
rustup component add --toolchain nightly rustfmt
pip3 install --user svdtools

Actually, at the time of writing the current version of svd2rust is broken. You will need to build commit d6c668dedfea manually like so:

git clone https://github.com/rust-embedded/svd2rust.git
cd svd2rust
git reset --hard d6c668dedfea
cargo build --release

Next, clone this repo and build the device definitions:

git clone https://github.com/Rahix/avr-device
cd avr-device
make
# You can build for just one specific chip using
# make atmega32u4
# I suggest building documentation as well
cargo +nightly doc --features <chip> --open

Internals

avr-device is generated using atdf2svd and svd2rust. The vendor-provided atdf files can be found in vendor/. The intermediate svd files are patched by svdpatch.py (Adapted from svdpatch.py in stm32-rs) with device-dependent patches in patch/, mainly to improve undescriptive names and missing descriptions.

Adding a new Chip

To add a new chip, download the atdf from http://packs.download.atmel.com/ (or avr-mcu/packs/) and place it in vendor/. Be sure to name it like the Rust module that should be generated. Next, you need to integrate it into the base crate and build system. Follow what was done in commit 290613454fbd ("Add basic support for ATmega64"). Please adhere to the alphabetical sorting that is present so far.

Next, you must create a <chipname>.yaml in patch/ which has at least the following content:

_svd: ../svd/<chipname>.svd

If more patches need to be applied (most likely!), they should be added into this file as well. The patching format is documented in the svdtools README. Ideally, try to reuse the exisiting patches in patch/common/ or patch/timer/.

Finally, try building the crate for your MCU with make <chipname>.

License

avr-device is licensed under either of

at your option.

The vendored atdf files are licensed under the Apache License, Version 2.0 (LICENSE-VENDOR).

Dependencies