GPIO from C or C++

I wrote a C++ class to abstract those file operations (including pin muxing) and turn them into simple configure/set/get calls.


#include "bonelib/gpio.hpp"

BeagleBone::gpio* CS = BeagleBone::gpio::P8(2);
BeagleBone::gpio* DO = BeagleBone::gpio::P8(4);
BeagleBone::gpio* CLK = BeagleBone::gpio::P8(6);


for (int i = 0; i < 8; i++) {
   DO->set(txd & 0x01);
   txd >>= 1;

If runtime performance is not a big deal, it works great.

This library, works for MX and C4 series?

Don’t know. I’m using it with the stock Angstrom distribution on a BeagleBone A6a.

If any changes are required, it’s open source. Don’t hesitate to create a branch and I can give you write permission.

I have seen many such libraries. The biggest difference between
between my lib and other implementations is that mine supports
read/write operations on blocks of GPIOs. You can take a bunch of
random wires and use them in your app as an ordered set, i.e. allocate
a block of 8 wires and treat them as a byte. Another big difference is
that I wrote it to make porting applications easier, so they can be
developed on a high-end platform and then moved to a microcontroller.
Currently only Beaglebone is supported, but adding Beagleboard or RPi
should be trivial. Launchpad with Stellaris mcu is next in line.