# BeagleBone Black C++ GPIO library

HCI Data Source: markdown, Import: https://raw.githubusercontent.com/mkaczanowski/BeagleBoneBlack-GPIO/master/README.md, Section:

Build Status

BeagleBoneBlack-GPIO

The library is a convenient manager for BeagleBone Black GPIO pins. In a nutshell it:

  • wraps sysfs operations (i.e., export, unexport, read, write, wait)
  • translates pin IDs to pin header names (ie. GPIO 38 = P8_03)
  • handles the state (i.e., unexports previously exported pins)
  • provides detailed data about the selected pin (i.e., allocation, location, id, modes, ...)

Example

g++ -std=c++17 -lstdc++fs gpio/*.cpp gpio/*.h main.cpp -o example
#include "gpio/const.h"
#include "gpio/manager.h"

using namespace beagle::gpio;

int main() {
  GPIOManager *gp = GPIOManager::getInstance();
  auto pin = getPin("P8_10");

  if (!pin) {
    return 255;
  }

  gp->exportPin(pin.value().gpio);
  gp->setDirection(pin.value().gpio, INPUT);
  gp->setEdge(pin.value().gpio, RISING);

  gp->waitForEdge(pin.value().gpio);
  gp->~GPIOManager();

  return 0;
}

Reference

Pinout

Pin setup (by Derek Molloy)