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

775 views
Skip to first unread message

Brendan Merna

unread,
Jun 10, 2015, 11:30:50 AM6/10/15
to beagl...@googlegroups.com
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!

Mark Lazarewicz

unread,
Jun 10, 2015, 3:00:39 PM6/10/15
to beagl...@googlegroups.com
For barebones use TI  starterware supply  example code from TI.

Sent from Yahoo Mail on Android


From:"Brendan Merna" <bmer...@gmail.com>
Date:Wed, Jun 10, 2015 at 11:30 AM
Subject:[beagleboard] 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 more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

William Hermans

unread,
Jun 10, 2015, 5:50:24 PM6/10/15
to beagl...@googlegroups.com
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.

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.

William Hermans

unread,
Jun 10, 2015, 6:03:32 PM6/10/15
to beagl...@googlegroups.com
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.

Brendan Merna

unread,
Jun 12, 2015, 9:23:04 AM6/12/15
to beagl...@googlegroups.com
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.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Jack Mitchell

unread,
Jun 12, 2015, 10:36:41 AM6/12/15
to beagl...@googlegroups.com
https://github.com/jackmitch/libsoc

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

Cheers,
Reply all
Reply to author
Forward
0 new messages