Addressing multiple BeagleBone GPIO pins in C

Since I am in the process of writing a HD44780 compatible LCD display driver for the beagle bone, I need to have a very simple piece of C code that writes data to multiple GPIO pins at the same time. In particular I need to have a function that when given a binary value, will turn ON/OFF may GPIO pins. For example, lets say the end-user is using the following 5 GPIO pins, P8_3, P8_4, P8_5, P8_11 and P8_12. Now lets say he just wants to turn ON pins P8_4 and P8_11, while leaving the others OFF. I created a neat piece of code that takes the pin selection in a binary format, and performs the appropriate ON/OFF switching operations. The latest version of this code can be found at the following github repository, https://github.com/nunoalves/BeagleBone-GPIO-in-C.

While this code works quite well, it is not really complete. For starters, I haven’t included all BeagleBone GPIO pins. You can include them all yourself in the function initialize_each_enabled_gpio(). Please refer to this earlier blog post for hints about how to do it. I also haven’t split this code into a different header file, so it’s its own library. I will do so, after I release the drivers for the HD44780 LCD display. Finally, this code could need some cleaning and optimization…

Here is a screenshot of the program running in the BeagleBone.

To compile and run this code just type the following commands in the BeagleBone terminal.

gcc main.c
./a.out

Finally, for those of you that are Doxygen fans, here is a printout of the code documentation.


2 comments on “Addressing multiple BeagleBone GPIO pins in C

  1. idem on said:

    Hi,

    It’s a pleasure to find people working and publishing on BeagleBone :)

    can you explain why there are only :
    P8_3:
    P8_4:
    P8_5:
    P8_11:
    P8_12:

    in you library?

    Regards,
    Idem

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">