Skip to content

C++ GPIO library for BeagleBone Black development board

Notifications You must be signed in to change notification settings

LemonDMN2/BeagleBoneBlack-GPIO

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

#compiled under BeagleBone(target) environment
#if compiled under VM(host) environment, changed "g++" to "g++-arm-linux-gnueabihf" to cross compile
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)

About

C++ GPIO library for BeagleBone Black development board

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 100.0%