Browse Source

init

master
commit
0886ceb0aa
4 changed files with 34 additions and 0 deletions
  1. +3
    -0
      Readme.md
  2. BIN
      gpio
  3. +26
    -0
      main.cpp
  4. +5
    -0
      makefile

+ 3
- 0
Readme.md View File

@ -0,0 +1,3 @@
# Readme
Projecto to create a CPP class for managing GPIO of beagle bone black.

BIN
gpio View File


+ 26
- 0
main.cpp View File

@ -0,0 +1,26 @@
/*To test the gpio class for BeagleBone Black
Gerardo Marx, April/20/2020*/
#include<iostream> // to input/output strings
#include<fstream>
#include<sstream>
#define GPIO_PATH "/sys/class/gpio/gpio"
int main(int argc, char *argv[]){
if(argc!=2){
std::cout << "The command usage is gpio #" << std::endl;
std::cout << "where # is the gpio number" << std:: endl;
return 2;
}
std::cout << "Starting program" << std::endl;
int number = 44; // gpio
std::string path;
std::ostringstream s;
std::ofstream fs;
std::string file = "direction";
s << GPIO_PATH << number; // gpio path
path = std::string(s.str());
fs.open((path + file).c_str());
fs << "output";
fs.close();
return 0;
}

+ 5
- 0
makefile View File

@ -0,0 +1,5 @@
all:
g++ main.cpp -o gpio
debug:
g++ -g main.cpp -o gpio

Loading…
Cancel
Save