bitbank2 / ArmbianIO

A C (+ Python and Java) library for simplifying access to I2C, SPI and GPIO on boards supported by Armbian
GNU General Public License v3.0
79 stars 27 forks source link

Logo

ArmbianIO is a C library for accessing I2C, SPI and GPIO ports in a consistent way across all of the SBCs that Armbian supports. Since Armbian supports SBCs from multiple OEMs using a variety of SoCs, the GPIO pin numbering is different on each board. Linux provides kernel drivers for communicating with the I2C and SPI bus in a consistent way, but the GPIO numbering can vary widely. This library aims to create simple wrapper functions for accessing I2C, SPI and creates a consistent numbering scheme for accessing GPIO ports based on the physical pin number. Other I/O libraries have tried to copy the BCM (Broadcom) I/O numbering to be compatible with Raspberry Pi hardware, but this creates a new layer of confusion and incompatibility since different boards expose different numbers and arrangements of GPIO ports. By using a numbering scheme based on the physical pin numbers of the boards, it becomes much easier to correctly connect devices on every board supported by Armbian. This also allows for boards with additional GPIOs such as the Orange Pi Zero which has two more usable pins on its TTY header.

NB: ArmbianIO requires Armbian with a mainline (4.x) kernel. Older versions don't have the unique board identifier (/run/machine.id)

Features

To build the C library, simply type 'make' in the terminal. To build the sample app, type 'make -f make_demo'. This will build the 'demo' executable to show that the library is working.

To build Python bindings cd ArmbianIO/python then ./wrapper.sh. You can run as many times as you like since the script cleans up and regenerates the wrapper from the C headers. sudo python ledtest.py to run LED test after wiring up project.

To build Java bindings cd ArmbianIO/java then ./wrapper.sh. You can run as many times as you like since the script cleans up and compiles the wrapper. The Java bindings depend on Oracle JDK 8 which wrapper.sh installs. If you wish to use another JDK then you will need to modify wrapper.sh. Use sudo java -Djava.library.path=/usr/local/lib -cp jna-4.5.0.jar:armbianio.jar:. LedTest to run LED test after wiring up project.

Copyright (c) 2017 by Larry Bank
Project started 11/13/2017
bitbank@pobox.com

If you find this code useful, please consider buying me a cup of coffee
paypal