Using C to access on board LEDs and GPIO Pins for Beagle Bone Black

I’ve hooked up my Beagle Bone Black through the micro USB cable to a computer running Windows 7. I was able to follow a project which involves cross compiling and remote connecting to the Beagle Bone through an the Eclipse Luna environment. It tuns a simple hello world program in C. Here’s the link: http://jkuhlm.bplaced.net/hellobone/

I want to start advancing this code to control GPIO pins, blink LEDs, read and write to registers, etc. I’m wondering what include files I need to do this and what function calls to use. Is there a mass list somewhere that I can be referred to? All the tutorials and help that I’ve seen only talk about C++ and I need to use C.

Thanks for any help!

For barebones use TI starterware supply example code from TI.

I want to start advancing this code to control GPIO pins, blink LEDs, read and write to registers, etc. I’m wondering what include files I need to do this and what function calls to use. Is there a mass list somewhere that I can be referred to? All the tutorials and help that I’ve seen only talk about C++ and I need to use C.

Which tutorials ? I’ve seen several examples where the persons demonstrating the code think they’re using C++, but their code is all C. Remember, a C++ compiler can build / compile C code too. Derrek Molloy’s example however does seem to be C++ where possible.

With that said: https://learnbuildshare.wordpress.com/2013/05/19/beaglebone-black-controlling-user-leds-using-c/

This code is all C except for the statement

**using** namespace std;

Which probably means this person was using g++ instead of** gcc. **It is also what I’d consider bad practice . . .The #include statements are all C, and as such all library functions used are in C. Demonstrated by printf() ( C++ uses cout, and the insertion operator << ).

Anyway, I’m not sure that example is “good” or not, but baring that it is a example in how to blink the USR LEDs in C.

As for the linux libc headers . . .
debian@beaglebone:~$ apt-cache search linux-libc
linux-libc-dev - Linux support headers for userspace development

so

debian@beaglebone:~$ sudo apt-get install linux-libc-dev

Should do the trick.

Ah, you did say cross compiling so . . . my instructions above were for native( on the BBB ).

Well since you forgot to mention which cross tools you’re using . . .

https://wiki.debian.org/Multiarch/HOWTO

Also, Derrek Molloy has a video on youtube for setting up a cross toolchain for the beaglebone white, and possibly an early video for setting up a cross toolchain for the beaglebone black using the armel ABI. If you follow that video exactly, and use the armhf ABI instead, it should work perfectly fine. It did for me.

Thanks Will! I got the code to work. It was exactly what I needed. Just a starting point with some of the include files and function calls I needed.

https://github.com/jackmitch/libsoc

It may already even be installed if you're using a recent Debian release from Robert.

Cheers,