GithubHelp home page GithubHelp logo

bitbank2 / armbianio Goto Github PK

View Code? Open in Web Editor NEW
78.0 9.0 27.0 223 KB

A C (+ Python and Java) library for simplifying access to I2C, SPI and GPIO on boards supported by Armbian

License: GNU General Public License v3.0

Makefile 0.45% C 45.05% Python 34.70% Shell 8.45% Java 11.34%

armbianio's Introduction

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

  • Now supports any Linux distribution for ARM SBCs (e.g. RPI, OrangePi, NanoPi, etc)
  • Will support all SBCs supported by Armbian (soon)
  • Includes simple functions for communicating with GPIO, I2C and SPI buses
  • References GPIO pins by physical pin number
  • Includes functions for detecting presence of and reading status of on-board key/button (not all boards have one)
  • Python bindings are generated with ctypesgen
  • Cross platform RPi.GPIO clone is in the works
  • Java bindings use a simple interface file and JNA

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
[email protected]

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

armbianio's People

Contributors

attilagyorffy avatar bitbank2 avatar clouetb avatar leperet avatar melroy89 avatar pbezza avatar sgjava avatar tido- avatar tonymac32 avatar zeekoe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

armbianio's Issues

Warnings when compiling Armbianio

I just cloned the ArmbianIO repo and used make to compile on my NanoPi Neo 2 (clean Armbian install + apt update/upgrade) but received two warnings in the process:

armbianio.c: In function ‘GPIOThread’:
armbianio.c:460:12: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
int iPin = (int)param; // pin number is passed in
^
armbianio.c: In function ‘AIOAddGPIOCallback’:
armbianio.c:520:43: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
pthread_create(&tinfo, NULL, GPIOThread, (void *)iPin);

Use of ctypesgen (a dead-end project)

Python2 is just about EOL. Python3 is exceptionally mature now, and on version 3.6. Using ctypesgen in this project means you can't use Python3, as it is not compatible. A quick visit to the ctypesgen repo shows this has been a known issue for 3 years, and nobody has changed anything on that front. Frustrated users have migrated to CFFI instead, as it accomplishes the same thing, but is under active development, and therefore supports Python3.

not working on RPi's

Tried the demo on a Pi 3B+ and a Pi Zero WH. Both errored thusly:

Unrecognized board type, aborting...
Problem initializing ArmbianIO library

uname: Linux servo 5.4.83-v7+

FWIW, there is no /run/machine-id with this kernel.

"error setting direction on GPIO pin..."

When calling AIOAddGPIO on the Raspberry Pi, I keep getting the error error setting direction on GPIO pin 8 and other pins. Any idea what might be the cause? Thanks!

Adding rockpro 64

Hi
I have added the rockpro 64 information to armbianio.c.
The previous pin tabulations are disorganized and some are unlabelled, so i added this at the start of the list to avoid the issues further down the list of systems.
I attach the modified armbianio.c which includes "RockPro 64"
armbianio.c.txt

File python/ctypesgen.py missing

When building the python wrapper using wrapper.sh, I'm getting "./wrapper.sh: 39: ctypesgen.py: not found". When checked the repo, I cannot find this file under the /python directory.

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.