PINE64
Questions about GPIO - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: PINE A64(+) (https://forum.pine64.org/forumdisplay.php?fid=4)
+--- Forum: Linux on Pine A64(+) (https://forum.pine64.org/forumdisplay.php?fid=6)
+--- Thread: Questions about GPIO (/showthread.php?tid=294)

Pages: 1 2


GPIO ports - igna09 - 12-31-2015

Hi,
will we able to use gpio ports via web pages stored in a web server running on the pine A64+?


RE: GPIO ports - o9guy - 12-31-2015

We need GPIO exposed in /sys/class via some sort of kernel module like on the Pi (sorry to bring up the pi but that's the model that PineA64 is going to have to strive to be like for community support)

The GPIO on the Odroid C1 (which uses an allwinnder quad core SOC) requires code written in C to access the GPIO (I haven't seen access via a /sys/class/GPIO or anything) but the Pcduino series, which also use the Allwinner SOC, does have a kernel module for /sys/class access.  Hopefully it won't take much to mimic this behavior.  I'd be willing to port the code needed to support the GPIO and other pin-specific functions.

(12-31-2015, 10:28 AM)o9guy Wrote: We need GPIO exposed in /sys/class via some sort of kernel module like on the Pi (sorry to bring up the pi but that's the model that PineA64 is going to have to strive to be like for community support)

The GPIO on the Odroid C1 (which uses an allwinnder quad core SOC) requires code written in C to access the GPIO (I haven't seen access via a /sys/class/GPIO or anything) but the Pcduino series, which also use the Allwinner SOC, does have a kernel module for /sys/class access.  Hopefully it won't take much to mimic this behavior.  I'd be willing to port the code needed to support the GPIO and other pin-specific functions.

But to more directly answer igna09, once we have access to the GPIO via filesystem (i.e. /sys/class GPIO) it will be possible to control them from a webserver using CGI-BIN in python, php, etc.  Here's an example of a web-based control for the Pi: http://www.instructables.com/id/Simple-and-intuitive-web-interface-for-your-Raspbe/?ALLSTEPS

It wouldn't be too hard to adjust the code for the pin convention the GPIO for the allwinner uses.

After that it will be possible to make an IR receiver module that is compatible with LIRC.


RE: GPIO ports - limitlesscodes - 02-07-2016

I don't mind programming in C, in fact I actually prefer it Smile, however I am curious as to if there is a library for the GPIO yet, something like wiringPi.h?


RE: GPIO ports - tllim - 02-07-2016

(02-07-2016, 01:56 PM)limitlesscodes Wrote: I don't mind programming in C, in fact I actually prefer it Smile, however I am curious as to if there is a library for the GPIO yet, something like wiringPi.h?

If you prefers programming in C, cgeck out this link that generate by Sunxi community: http://linux-sunxi.org/GPIO


RE: GPIO ports - limitlesscodes - 02-10-2016

(02-07-2016, 08:25 PM)tllim Wrote:
(02-07-2016, 01:56 PM)limitlesscodes Wrote: I don't mind programming in C, in fact I actually prefer it Smile, however I am curious as to if there is a library for the GPIO yet, something like wiringPi.h?

If you prefers programming in C, cgeck out this link that generate by Sunxi community: http://linux-sunxi.org/GPIO

Thanks much!, are there any updates as to when ubuntu will "officially" be supported?


RE: GPIO ports - tllim - 02-10-2016

(02-10-2016, 12:25 AM)limitlesscodes Wrote:
(02-07-2016, 08:25 PM)tllim Wrote:
(02-07-2016, 01:56 PM)limitlesscodes Wrote: I don't mind programming in C, in fact I actually prefer it Smile, however I am curious as to if there is a library for the GPIO yet, something like wiringPi.h?

If you prefers programming in C, cgeck out this link that generate by Sunxi community: http://linux-sunxi.org/GPIO

Thanks much!, are there any updates as to when ubuntu will "officially" be supported?

Once the Kernel up, looking forward to happen on this month.


Questions about GPIO - limitlesscodes - 02-14-2016

Hey Pine64 backers! I am having difficulty figuring out how I would use C to take user input, button presses, and light LEDs with the GPIO, I understand C fairly well but have no experience with interfacing with"GPIO." Here is the best program I could think of although I believe there is a much better way to do this:
Code:
/*
*Simple pulsing of GPIO example
*/
#include <stdio.h>
#include <string.h>

FILE *zero, *one;

int main(int argc, char *argv[])
{

zero = fopen("/sys/class/gpio/gpio206/value", "w");
one = fopen("/sys/class/gpio/gpio206/value", "w");

while(1)
{
fputs("0\n", zero);
fflush(zero);
fputs("1\n", one);
fflush(one);
}
}
Also what determines the pin number? Thanks for your help!


RE: Questions about GPIO - patrickhwood - 02-14-2016

(02-14-2016, 05:49 PM)limitlesscodes Wrote: Hey Pine64 backers! I am having difficulty figuring out how I would use C to take user input, button presses, and light LEDs with the GPIO, I understand C fairly well but have no experience with interfacing with"GPIO." Here is the best program I could think of although I believe there is a much better way to do this:
Code:
/*
*Simple pulsing of GPIO example
*/
#include <stdio.h>
#include <string.h>

FILE *zero, *one;

int main(int argc, char *argv[])
{

zero = fopen("/sys/class/gpio/gpio206/value", "w");
one = fopen("/sys/class/gpio/gpio206/value", "w");

while(1)
{
fputs("0\n", zero);
fflush(zero);
fputs("1\n", one);
fflush(one);
}
}
Also what determines the pin number? Thanks for your help!

You've got the right general idea.  See http://falsinsoft.blogspot.com/2012/11/access-gpio-from-linux-user-space.html and
http://linux-sunxi.org/GPIO


RE: Questions about GPIO - limitlesscodes - 02-15-2016

(02-14-2016, 07:12 PM)patrickhwood Wrote:
(02-14-2016, 05:49 PM)limitlesscodes Wrote: Hey Pine64 backers! I am having difficulty figuring out how I would use C to take user input, button presses, and light LEDs with the GPIO, I understand C fairly well but have no experience with interfacing with"GPIO." Here is the best program I could think of although I believe there is a much better way to do this:
Code:
/*
*Simple pulsing of GPIO example
*/
#include <stdio.h>
#include <string.h>

FILE *zero, *one;

int main(int argc, char *argv[])
{

zero = fopen("/sys/class/gpio/gpio206/value", "w");
one = fopen("/sys/class/gpio/gpio206/value", "w");

while(1)
{
fputs("0\n", zero);
fflush(zero);
fputs("1\n", one);
fflush(one);
}
}
Also what determines the pin number? Thanks for your help!

You've got the right general idea.  See http://falsinsoft.blogspot.com/2012/11/access-gpio-from-linux-user-space.html and
http://linux-sunxi.org/GPIO
I read through them, so from what I am able to understand my program would only work if the kernel supports GPIO access from sysfs, will the Pine64 support this(I really hope to hear yes)? Also, say I am trying to blink an LED, can you be so kind as to tell my a pin number on the GPIO that can do that?


RE: Questions about GPIO - limitlesscodes - 02-16-2016

Alright, so I kind of figured out pin assignment using the GPIO image on the wiki. I still would like to know what PC, PD, PH, etc. means and when to use them vs. others. Also I would like to know if there is any better way of exporting the pins through C rather than doing something like:
Code:
//near beginning of file
system("echo 71 > /sys/class/gpio/export")
and
Code:
//near end of file
system("echo 71 > /sys/class/gpio/unexport")