commit 0886ceb0aaf6554315fa19572aa947a166fdc83b Author: Gerardo Marx Date: Wed Jul 15 00:50:03 2020 +0000 init diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..124508a --- /dev/null +++ b/Readme.md @@ -0,0 +1,3 @@ +# Readme +Projecto to create a CPP class for managing GPIO of beagle bone black. + diff --git a/gpio b/gpio new file mode 100755 index 0000000..ed45e40 Binary files /dev/null and b/gpio differ diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..055999b --- /dev/null +++ b/main.cpp @@ -0,0 +1,26 @@ +/*To test the gpio class for BeagleBone Black + Gerardo Marx, April/20/2020*/ +#include // to input/output strings +#include +#include +#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; +} diff --git a/makefile b/makefile new file mode 100644 index 0000000..c25adf9 --- /dev/null +++ b/makefile @@ -0,0 +1,5 @@ +all: + g++ main.cpp -o gpio + +debug: + g++ -g main.cpp -o gpio