[ARMv7] BBB-rev C and GPIO / C coding

Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[ARMv7] BBB-rev C and GPIO / C coding

Olivier BURELLI
Hello all.

First, i introduce myself. Olivier, having basic programming language.

I bought a Beaglebone Black.

My goal is:

* Use OpenBSD and nothing else, no matter how is difficult, i will use what is available
* Learn how to program the BBB. (I am aware that C libraries for this platform are not really distributed)
* Make home automation (I also play with arduino uno)

Status:

For the moment, I manage to light via GPIOCTL, a LED on the pin 23 header P9.

$ doas gpioctl gpio1 17 on

my /etc/rc.securelevel:

# Digital Output:
gpioctl gpio1 17 set out pinH9_23
gpioctl gpio3 21 set out pinH9_25
gpioctl gpio3 25 set out pinH9_27

Question : in this way (I am not an expert in programming):

_ Should I create a tree (directory) to turn on my LED in C language ?
_ Should I instead use the physical addresses to turn on my LED in C language ?
_ Regarding analog inputs, are they recognized by the kernel as GPIO ?
_ Do you have some interesting link to documentations, to help me ?


Thanks in advance.

Olivier.

Reply | Threaded
Open this post in threaded view
|

Re: [ARMv7] BBB-rev C and GPIO / C coding

Ian Sutton-2
On Sun, Nov 25, 2018 at 3:45 AM Olivier Burelli <[hidden email]> wrote:

> For the moment, I manage to light via GPIOCTL, a LED on the pin 23 header P9.
>
> $ doas gpioctl gpio1 17 on
>
> my /etc/rc.securelevel:
>
> # Digital Output:
> gpioctl gpio1 17 set out pinH9_23
> gpioctl gpio3 21 set out pinH9_25
> gpioctl gpio3 25 set out pinH9_27
>
> Question : in this way (I am not an expert in programming):
>
> _ Should I create a tree (directory) to turn on my LED in C language ?

No -- See below

> _ Should I instead use the physical addresses to turn on my LED in C language ?

Use ioctl(2) calls on the gpio device file.

> _ Regarding analog inputs, are they recognized by the kernel as GPIO ?

No, those pins are not wired to GPIO. They are there own thing.

> _ Do you have some interesting link to documentations, to help me ?

The gpio(4), gpioctl(8) man pages should suffice. If you have any
further issues you can mail this list.

Best,
ians

Reply | Threaded
Open this post in threaded view
|

Re: [ARMv7] BBB-rev C and GPIO / C coding

Olivier BURELLI
Hello Ian,

thank you for showing me the way.

I will check ioctl, gpioctl and gpio.

I will continue to take a look on the *.c files (thank to S.)

Thank you.

Oliv.

On Tue, 27 Nov 2018 09:34:39 -0600
Ian Sutton <[hidden email]> wrote:

> On Sun, Nov 25, 2018 at 3:45 AM Olivier Burelli <[hidden email]>
> wrote:
> > For the moment, I manage to light via GPIOCTL, a LED on the pin 23
> > header P9.
> >
> > $ doas gpioctl gpio1 17 on
> >
> > my /etc/rc.securelevel:
> >
> > # Digital Output:
> > gpioctl gpio1 17 set out pinH9_23
> > gpioctl gpio3 21 set out pinH9_25
> > gpioctl gpio3 25 set out pinH9_27
> >
> > Question : in this way (I am not an expert in programming):
> >
> > _ Should I create a tree (directory) to turn on my LED in C
> > language ?  
>
> No -- See below
>
> > _ Should I instead use the physical addresses to turn on my LED in
> > C language ?  
>
> Use ioctl(2) calls on the gpio device file.
>
> > _ Regarding analog inputs, are they recognized by the kernel as
> > GPIO ?  
>
> No, those pins are not wired to GPIO. They are there own thing.
>
> > _ Do you have some interesting link to documentations, to help
> > me ?  
>
> The gpio(4), gpioctl(8) man pages should suffice. If you have any
> further issues you can mail this list.
>
> Best,
> ians