• Stars
    star
    1,264
  • Rank 37,217 (Top 0.8 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created over 5 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

embedded-hal abstractions for AVR microcontrollers

avr-hal Continuous Integration arduino-hal docs atmega-hal docs attiny-hal docs

Hardware Abstraction Layer for AVR microcontrollers and common boards (for example Arduino). Based on the avr-device crate.

Quickstart

You need a nightly Rust compiler for compiling Rust code for AVR. The correct version will be installed automatically due to the rust-toolchain.toml file.

Install dependencies:

  • Ubuntu

    sudo apt install avr-libc gcc-avr pkg-config avrdude libudev-dev build-essential
  • Macos

    xcode-select --install # if you haven't already done so
    brew tap osx-cross/avr
    brew install avr-gcc avrdude
  • Windows

    Install Scoop using Powershell

    Set-ExecutionPolicy RemoteSigned -Scope CurrentUser # Needed to run a remote script the first time
    irm get.scoop.sh | iex

    Install avr-gcc and avrdude

    scoop install avr-gcc
    scoop install avrdude
    

    See Setting up environment for more information.

Next, install "ravedude", a tool which seamlessly integrates flashing your board into the usual cargo workflow:

cargo +stable install ravedude

Go into ./examples/arduino-uno (or the directory for whatever board you want), and run the following commands:

cd examples/arduino-uno

# Build and run it on a connected board
cargo run --bin uno-blink

Starting your own project

The best way to start your own project is via the avr-hal-template which you can easily use with cargo-generate:

cargo install cargo-generate
cargo generate --git https://github.com/Rahix/avr-hal-template.git

Repository Structure

The avr-hal repository is a workspace containing all components making up the HAL. Here is an overview:

arduino-hal arduino-hal docs

arduino-hal is the batteries-included HAL for all Arduino & similar boards. This is what you probably want to use for your projects. It is intentionally built to abstract away the differences between boards as much as possible.

examples/*

The examples directory contains lots of examples for common hardware. Do note that not all examples were ported to all boards, but there is a good chance that you can still use the code. Currently, the Arduino Uno crate contains the most examples.

mcu/atmega-hal atmega-hal docs , mcu/attiny-hal attiny-hal docs

HAL crates for AVR microcontroller families. If you have a custom board, you'll want to work with these crates. Please check their documentation for a list of supported MCUs.

avr-hal-generic avr-hal-generic docs

This is a generic crate containing most of the HAL implementations in the form of macros which are instanciated in each HAL crate for the specific MCUs. If you intend to write drivers that work with any AVR chip, targeting avr-hal-generic is probably the best route.

avr-specs/

The avr-specs/ directory contains rustc target definitions for all supported microcontrollers. You will need these for compiling rust code for AVR. The avr-hal-template already includes them for convenience.

ravedude crates.io page

ravedude is a utility for seamlessly integrating avrdude and a serial console into the cargo workflow. With a bit of configuration (check its README!) you can then upload your code to your board and view its output over the serial console by just using cargo run as you would normally.

Disclaimer

This project is not affiliated with either Microchip (former Atmel) nor any of the Vendors that created the boards supported in this repository.

License

avr-hal is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

More Repositories

1

avr-device

Register access crate for AVR microcontrollers
Rust
170
star
2

shared-bus

Crate for sharing buses between multiple devices
Rust
129
star
3

avr-hal-template

cargo-generate template for avr-hal projects
Rust
125
star
4

visualizer2

OpenGL Audio Visualizers in Rust
Rust
94
star
5

tbot

Automation/Testing tool for Embedded Linux Development
Python
84
star
6

spacestation

A procedural spacestation generator
Hy
25
star
7

port-expander

Abstraction for IĀ²C port-expanders
Rust
17
star
8

atdf2svd

Converter from Atmel's atdf format to CMSIS SVD
Rust
17
star
9

pa-visualizer

A collection of pulseaudio visualizers written in rust (and python)
Rust
17
star
10

pavu-mixer

"Hardware Mixer" for PulseAudio
Rust
13
star
11

Poppy-Logic-Controller

A budget PLC-like board for controlling 24V DC equipment.
Rust
13
star
12

profirust

A PROFIBUS-DP compatible communication stack written in Rust
Rust
10
star
13

atmega32u4

Low level access to ATmega32U4 registers in Rust
Rust
10
star
14

arduino-leonardo

Board Support Crate for Arduino Leonardo in Rust
Rust
5
star
15

leonardo-examples

Arduino Leonardo Examples in Rust
Rust
5
star
16

eagre-asn1

A Rust asn1 library
Rust
4
star
17

atmega32u4-hal

Hardware Abstraction Layer for ATmega32U4
Rust
3
star
18

blog-theme

Theme for my personal blog
Sass
3
star
19

Julia3D

Julia sets visualized in 3d using webgl
JavaScript
3
star
20

Alien-Invaders

This is a tower defense game where you have to protect your base against incoming UFOs. The game is written in Javascript and playable in every Web-Browser.
JavaScript
2
star
21

eagre-ecs

A Rust entity-component system
Rust
1
star
22

i2c-proxy-demo

Demo of a proxy for multiple devices on the same bus
Rust
1
star
23

frequency-bands

E-UTRA frequency bands cheatsheet
HTML
1
star
24

tf2-voicelines

A website that aims to be a quick way to find Team Fortress 2 quotes
HTML
1
star
25

elite-panel

elite-panel is a side panel/companion for Elite Dangerous.
JavaScript
1
star
26

DummyProject

A MMO that is played in browser
1
star
27

coriolis-sim

Simulating a coriolis station from Elite: Dangerous and its problems
Rust
1
star