Skip to content

Latest commit

 

History

History
57 lines (42 loc) · 1.31 KB

README.md

File metadata and controls

57 lines (42 loc) · 1.31 KB

arduino--

arduino-- is a C++ library for AVR microcontrollers.

The project got kicked off by this blog post by Ben Laurie, Grown-up Arduino programming.

In a nutshell, the idea is to move as much work as possible into the compilation phase via C++ templates, and have a system where toggling an output pin in C++ compiles down to a single assembler instruction, while still having an abstraction layer that is at least very similar between devices.

This is what hello world - blinking an LED - looks like:

/*
 The hello world of arduino--, a C++ take on the Arduino libraries.

 Blinks an LED connected to digital pin 13 (which is connected to an LED
 on all Arduino variants that we know of).
 */

#include "arduino--.h"
#include <avr/sleep.h>

int main(void)
    {
    // Arduino Pin D13 is an output
    Arduino::D13::modeOutput();

    while(true)
        {
        // toggle the pin
        Arduino::D13::toggle();
        // wait
        _delay_ms(2000);
        }

    return 0;
    }

Getting started

Prerequisites

  • avrdude
  • avr-gcc
  • avr-binutils
  • avr-libc
  • perl
  • python

On a Mac, installation via Homebrew is recommended:

brew tap osx-cross/avr
brew install avr-gcc

This will automatically install avr-binutils and avr-libs, too.