All Projects → Rahix → Avr Hal

Rahix / Avr Hal

Licence: other
embedded-hal abstractions for AVR microcontrollers

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Avr Hal

Ir Tester
Quick IR Value Tester
Stars: ✭ 14 (-93.55%)
Mutual labels:  arduino, avr
Tinygo
Go compiler for small places. Microcontrollers, WebAssembly (WASM/WASI), and command-line tools. Based on LLVM.
Stars: ✭ 9,068 (+4078.8%)
Mutual labels:  arduino, avr
Calunium
Arduino clone based on the ATmega644P/ATmega1284P
Stars: ✭ 30 (-86.18%)
Mutual labels:  arduino, avr
Arduino freertos library
A FreeRTOS Library for all Arduino AVR Devices (Uno, Leonardo, Mega, etc)
Stars: ✭ 523 (+141.01%)
Mutual labels:  arduino, avr
Avr8js
Arduino (8-bit AVR) simulator, written in JavaScript and runs in the browser / Node.js
Stars: ✭ 102 (-53%)
Mutual labels:  arduino, avr
Platformio Core
PlatformIO is a professional collaborative platform for embedded development 👽 A place where Developers and Teams have true Freedom! No more vendor lock-in!
Stars: ✭ 5,539 (+2452.53%)
Mutual labels:  arduino, avr
Blog
A set of various projects based on ESP8266, ESP32, ATtiny13, ATtiny85, ATtiny2313, ATmega8, ATmega328, ATmega32, STM32 and more.
Stars: ✭ 198 (-8.76%)
Mutual labels:  arduino, avr
Mightycore
Arduino hardware package for ATmega1284, ATmega644, ATmega324, ATmega324PB, ATmega164, ATmega32, ATmega16 and ATmega8535
Stars: ✭ 413 (+90.32%)
Mutual labels:  arduino, avr
Megacore
Arduino hardware package for ATmega64, ATmega128, ATmega640, ATmega1280, ATmega1281, ATmega2560, ATmega2561, AT90CAN32, AT90CAN64 and AT90CAN128
Stars: ✭ 206 (-5.07%)
Mutual labels:  arduino, avr
Erika3
ERIKA Enterprise v3 RTOS
Stars: ✭ 98 (-54.84%)
Mutual labels:  arduino, avr
Logic Analyzer
Logic Analyzer, for Arduino, AVR, ESP8266 and STM32 with a very nice working processing interface, you could run it also on any Android device.
Stars: ✭ 203 (-6.45%)
Mutual labels:  arduino, avr
Marlin
Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. | Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
Stars: ✭ 12,217 (+5529.95%)
Mutual labels:  arduino, avr
Arduinomenu
Arduino generic menu/interactivity system
Stars: ✭ 520 (+139.63%)
Mutual labels:  arduino, avr
Minicore
Arduino hardware package for ATmega8, ATmega48, ATmega88, ATmega168, ATmega328 and ATmega328PB
Stars: ✭ 546 (+151.61%)
Mutual labels:  arduino, avr
Bare Arduino Project
Start your Arduino projects right out of the box
Stars: ✭ 505 (+132.72%)
Mutual labels:  arduino, avr
Attinycore
Arduino core for ATtiny 1634, 828, x313, x4, x41, x5, x61, x7 and x8
Stars: ✭ 974 (+348.85%)
Mutual labels:  arduino, avr
Homebrew Avr
Homebrew AVR Toolchain
Stars: ✭ 294 (+35.48%)
Mutual labels:  arduino, avr
Microcore
An optimized Arduino hardware package for ATtiny13
Stars: ✭ 348 (+60.37%)
Mutual labels:  arduino, avr
Deepsleepscheduler
DeepSleepScheduler is a lightweight, cooperative task scheduler library with configurable sleep and task supervision.
Stars: ✭ 59 (-72.81%)
Mutual labels:  arduino, avr
Qpn
QP-nano real-time embedded framework/RTOS for embedded systems based on active objects (actors) and hierarchical state machines
Stars: ✭ 107 (-50.69%)
Mutual labels:  arduino, avr

avr-hal Continuous Integration

embedded-hal implementations for AVR microcontrollers. Based on the register definitions from avr-device.

Quickstart

You need a nightly Rust compiler for compiling Rust code for AVR. Note: Due to a regression, versions after nightly-2021-01-07 are currently broken (see #124). Please use that version of the compiler for now. You can install it using

rustup toolchain install nightly-2021-01-07

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

cd boards/arduino-uno

# Now you are ready to build your first avr blink example!
cargo +nightly-2021-01-07 build --example uno-blink

# For some boards, you can even run it directly (this will attempt to flash it
# onto a connected board):
cargo +nightly-2021-01-07 run --example uno-blink

# For others, you can find the binary file in
ls ../../target/avr-atmega328p/debug/examples/uno-blink.elf
# and e.g. create an ihex file using
avr-objcopy -S -j .text -j .data -O ihex uno-blink.elf uno-blink.hex

Starting your own project

This is a step-by-step guide for creating a new project targeting Arduino Uno (ATmega328P). You can of course apply the same steps for any other microcontroller.

  1. Start by creating a new project:

    cargo new --bin avr-example
    cd avr-example
    
  2. If you're using rustup, you probably want to set an override for this directory, to use the nightly toolchain (as mentioned above, use nightly-2021-01-07 for the time being):

    rustup override set nightly-2021-01-07
    
  3. Copy the target description for your MCU from avr-specs/ (e.g. avr-atmega328p.json) into your project.

  4. Create a file .cargo/config.toml with the following content:

    [build]
    target = "avr-atmega328p.json"
    
    [unstable]
    build-std = ["core"]
    
  5. Fill Cargo.toml with these additional directives:

    [dependencies]
    # A panic handler is needed.  This is a crate with the most basic one.
    # The `leonardo-panic` example shows a more elaborate version.
    panic-halt = "0.2.0"
    
    [dependencies.arduino-uno]
    git = "https://github.com/rahix/avr-hal"
    rev = "<insert latest git-commit hash here>"
    # ^- Pin the dependency to a specific version.  You should use the latest
    # commit hash from the avr-hal master branch.  You can find it here:
    #
    #    https://github.com/rahix/avr-hal/commits/master
    
    # Configure the build for minimal size
    [profile.dev]
    panic = "abort"
    lto = true
    opt-level = "s"
    
    [profile.release]
    panic = "abort"
    codegen-units = 1
    debug = true
    lto = true
    opt-level = "s"
    

    Note: If you at some point want to update to a newer version of avr-hal, you just need to put a later commit hash into the rev = field. For any breaking changes which might require you to fix something in your code, read the CHANGELOG.

  6. Start your project with this basic template:

    #![no_std]
    #![no_main]
    
    // Pull in the panic handler from panic-halt
    extern crate panic_halt;
    
    use arduino_uno::prelude::*;
    
    #[arduino_uno::entry]
    fn main() -> ! {
        let dp = arduino_uno::Peripherals::take().unwrap();
    
        unimplemented!()
    }
    
  7. Build with these commands (make sure you're using nightly rust!):

    cargo build
    # or
    cargo build --release
    

    and find your binary in target/avr-atmega328p/debug/ (or target/avr-atmega328p/release).

  8. (Optional): To make development as smooth as possible, you can configure a cargo runner for your board. This repository contains a few example scripts (e.g. uno-runner.sh, leonardo-runner.sh) which you can copy into your project. You'll then need to add the following section to your .cargo/config.toml:

    [target.'cfg(target_arch = "avr")']
    runner = "./uno-runner.sh"
    

    And that's it, now you can build an run your project in a single command!

    cargo run
    # or
    cargo run --release
    

Repository Structure

This repository contains the following components:

  • A generic crate containing implementations that can be used chip-independently and macros to create chip-dependent instances of peripheral abstractions. This crate is named avr-hal-generic.
  • HAL crates for each MCU in chips/. These make use of avr-hal-generic to create chip-specific definitions.
  • Board Support Crates for popular hardware in boards/. They, for the most part, just re-export functionality from the chip-HAL, with the names that are printed on the PCB.

Supported MCUs

The following HAL crates currently exist. Take a look at the docs for more details on what's supported.

Supported Boards

In boards/ there are crates for the following hardware. Please note that this project is in no way affiliated with any of the vendors.

Each board crate comes with a few examples showing how to use them. For more details, follow the links to the documentation.

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].