OldRolly
Posts: 3
Joined: Thu Dec 24, 2015 12:04 pm

GPIO and serial IF programming with C language

Mon Jan 04, 2016 1:52 pm

Hi everybody,
I am just starting with a new RPi2B and would like to ask the community if you can give me some hints for accessing the GPIO pins as well as for the programming of serial interfaces from C programs. Which libraries do I need and how can I include these libraries into the gcc compiler?

Maybe you can give me some examples. I have got experience with C programming, however, I am new with the Raspberry Pi stuff and Raspian.

Thanks a lot for your help.

enedil
Posts: 66
Joined: Sat Feb 21, 2015 4:22 pm
Location: Toruń, Poland
Contact: Website

Re: GPIO and serial IF programming with C language

Mon Jan 04, 2016 2:43 pm

Try with this - without redundant overhead:
http://www.pieter-jan.com/node/15
- What Can a Thoughtful Man Hope for Mankind on Earth, Given the Experience of the Past Million Years?
- Nothing.

Kurt Vonnegut, Cat's Cradle

User avatar
RogerW
Posts: 286
Joined: Sat Dec 20, 2014 12:15 pm
Location: London UK

Re: GPIO and serial IF programming with C language

Mon Jan 04, 2016 3:34 pm

enedil wrote:Try with this - without redundant overhead:
http://www.pieter-jan.com/node/15
This will give you bare bones access. You could also look at wiringPi.
https://projects.drogon.net/raspberry-pi/
This seems to be installed as standard in Jessie. It includes all the basic GPIO functions, serial and much more.
I have not used it in anger, I just checked that the header file and library were there. There must be plenty of people around here with far mor knowledge.

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: GPIO and serial IF programming with C language

Mon Jan 04, 2016 5:20 pm

if you don't mind to read a little bit in German (most is in English, though):

http://www.mindstormsforum.de/viewtopic ... 689#p67924

http://www.mindstormsforum.de/viewtopic ... =15#p67785
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

Return to “C/C++”