GithubHelp home page GithubHelp logo

hotovson / avr Goto Github PK

View Code? Open in Web Editor NEW

This project forked from luisgabrielroldan/avr

0.0 1.0 0.0 68 KB

AVR Arduino firmware upload library written in Elixir

License: Apache License 2.0

Elixir 100.00%

avr's Introduction

AVR

CircleCI Hex version

AVR Firmware Uploader (Only Arduino targets are supported).

Why?

Usually in my projects I need hard realtime (e.g. Send/Receive IR signals) which is a complicated task to achieve with Nerves because you have the erlang scheduler plus the OS multitasking. So for those times where realtime is needed the simplest solution is to have hardware that supports it like an Arduino.

But wait... what if I want to also update my little Arduino companion firmware as easy as I update my app firmware?

The Goal

To accomplish this goal I need:

  • The firmware loader: This is done (At least for the Arduino models I use).
  • Firmware version check mechanism: A way to check the current companion firmware version installed (Maybe storing the version on the EEPROM or reading and comparing the firmware in the device).
  • Automated updater: An app to be included in the project to update (Maybe at boot time) the companion/s firmware when is necessary.
  • Compiler task (Optional): To include the Arduino source in the Nerves project and compile the hex file on build.

Usage

AVR.upload("foo/bar/binary.compiled.hex", "ttyACM0", :uno)

IMPORTANT! The hex file has to be compiled to match the target hardware (MCU and Clock speed)

Supported boards:

  • :uno: Arduino Uno
  • :pro8MHzatmega328p: Arduino Pro or Pro Mini ATmega328 (3.3V, 8 MHz)
  • :pro16MHzatmega328p: Arduino Pro or Pro Mini ATmega328 (5V, 16 MHz)
  • :atmega328: Generic ATmega328
  • :atmega328p: Generic ATmega328P

Auto-reset

Arduino boards needs to be reseted to enable the programing mode. The reset is performed automatically using the DTR line when the board is connected by USB.

To use the RPi hardware serial port you need to configure a GPIO pin to work as a reset line using the gpio_reset option:

AVR.upload("foo/bar/binary.compiled.hex", "ttyACM0", :uno, gpio_reset: 4)

On this case, the GPIO04 will be connected to the reset pin.

NOTE: The reset works putting the RESET pint to LOW for a few milliseconds. For this reason you have to use the GPIOs with pull-up resistors (GPIO0-GPIO8).

Installation

If available in Hex, the package can be installed by adding avr to your list of dependencies in mix.exs:

def deps do
  [
    {:avr, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/avr.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.