Beaglebone CLIB Home - PlasmaTrout/Beaglebone-CLIB GitHub Wiki
This is a beagle bone library to assist and expedite working with the beagle bones ports and muxs. The intent is to get close to an Arduino feel however still retain the C power, syntax and speed. Its going to say a "pure" C library.
Before you grab the source, make sure you locate your cloud9 directory (if your using the Angstrom distro it should be /var/lib/cloud9). You will want to do your clone from there.
To get the source (which you must have done already) do a:
git clone [email protected]:jdowning/beaglebone-clib.git
This release builds a static library and installs it so that apps can function as simply as the blink test application. To compile and install library use:
./build_library.sh
This will build, install and setup the headers so that any C file you wish now can use <beaglebone.h> and <mainloop.h> if you need to.
To compile against this library you can use the following compilatation format:
gcc -o my_executable my_executable_source.c -lbeaglebone
To test application functionality (and have a working example) you can build the blinktest by executing the shell script:
./build_blinktest.sh
This will build a blink test that can test an LED placed on PIN 3 of P8. If you want to see how simple the code is for this example look at the https://github.com/PlasmaTrout/Beaglebone-CLIB/blob/master/src/blinktest.c source code.
You will have to hit ctrl-c to stop the blinking. If you need to fully reset the ports after the application was ran run the following scripts seperately:
echo 0 > /sys/class/gpio/gpio38/value echo 38 > /sys/class/gpio/unexport
This will shut the power off to pin 3 and then unexport the port.
Its port 38 because port numbers are notated by taked the actual design name of the pin, in this case GPIO1_6, and multiplying 32 by the first number and adding the second. So 32x1+6 is the actual pin number. These translations are done for you in the C headers so use the macros PIN3, PIN4, ETC and don't worry about the actual port unless you are controling the ports via shell
For more information make sure to visit the Pin-Layouts.