4

Does Raspbian come out of the box with some GPIO library for C, or if not, does it have any in the standard repository?

Sure I could just download and compile any of the libs on my own from .tgz but then I lose auto-updates and the likes, so I thought I'd ask first.

SF.
  • 920
  • 1
  • 8
  • 21
  • 1
    The linux kernel GPIO interface is language agnostic, see http://raspberrypi.stackexchange.com/questions/11996/reading-gpio-states-using-c/12001#12001 Any language specific wrapper on this, C or otherwise, is just that: a wrapper. – goldilocks Dec 02 '13 at 23:06

3 Answers3

3

If you are looking for something comparable to Arduino, consider looking at WiringPi. WiringPi is an Arduino wiring-like library written in C and released under the GNU LGPLv3 license. The code example looks very similar to code written for the Arduino.

You could also take a look at the bcm2835 library. The example code looks pretty simple.

Just some extra suggestions to those already out there.

syb0rg
  • 8,188
  • 4
  • 37
  • 51
  • I know both, and can install them from tarballs just fine, but does either of them come as .deb package for Raspberry? If so, what is the package name? Neither apt-cache search bcm2835 nor apt-cache search WiringPi return anything. – SF. Aug 06 '13 at 11:33
  • To my knowledge, no. – syb0rg Aug 06 '13 at 15:00
2

There is a Python GPIO library in the package repository of Raspbian, but no C or any other counterpart at this time.

You can search for them yourself my typing:

$ apt-cache search gpio

If you understand how the GPIO works, you will notice that you can access the main functions using the file system mapping, just by reading and writing into files in the file system. This option is auto-updated together with the kernel and modules.

You can always use direct register access to use the GPIO, as described in the elinux RPi Low Level page, but I don't think that would help you achieve your objective though.

syb0rg
  • 8,188
  • 4
  • 37
  • 51
Marco Poli
  • 1,861
  • 10
  • 20
0

i program in python however i believe a quick google search of

WiringPi 

should provide you with what you need plus some very useful extras such as software pwm etc.

D Mason
  • 135
  • 1
  • 11
  • I see no .deb packages, apt repositories or any of the like. Just plain old tarballs. "Installation seems to be a key issue, so I’ll be looking at providing a .deb package for Raspbian – I know there is already a package available for Arch, but things are changing quite rapidly right now." - Posted on March 11, 2013 by Gordon. – SF. Aug 22 '13 at 11:31
  • I was able to install the WiringPi module using the git method. https://github.com/WiringPi/WiringPi-Python here is the repositry, instructions are shown in the readme section. mind it is worth also using the update function to ensure you have the latest version. – D Mason Aug 22 '13 at 11:36