How to make A20 gpio as interrupt and read from user application

1,049 views
Skip to first unread message

Nithin Chakravarthy

unread,
Dec 8, 2014, 8:41:04 AM12/8/14
to linux...@googlegroups.com
Hi,

I have requirement to A20 gpio as interrupt from user space. 
I have custom board to which switches sw1 sw2 sw3 are connected
to gpio PD0,PD1,PD2 respectively. so, if button is pressed i should perforn 
some action. how can i do this from my application side.
so please help me!!! 

Antal Koós

unread,
Dec 8, 2014, 10:31:47 AM12/8/14
to linux...@googlegroups.com

Hi,

1) in C:  https://www.ridgerun.com/wiki/index.php?title=Gpio-int-test.c
2) in Python for A20-Olinuxino-micro (see the poll_in_python.py file):  https://github.com/kantal/PythonGPIO

sels...@gmail.com

unread,
Dec 8, 2014, 11:59:36 AM12/8/14
to linux...@googlegroups.com, Nithin Chakravarthy
See:

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/gpio/sysfs.txt

for the full details.


/sys/class/gpio/gpioN/

[...]

"value" ... reads as either 0 (low) or 1 (high). If the GPIO
is configured as an output, this value may be written;
any nonzero value is treated as high.

If the pin can be configured as interrupt-generating interrupt
and if it has been configured to generate interrupts (see the
description of "edge"), you can poll(2) on that file and
poll(2) will return whenever the interrupt was triggered. If
you use poll(2), set the events POLLPRI and POLLERR. If you
use select(2), set the file descriptor in exceptfds. After
poll(2) returns, either lseek(2) to the beginning of the sysfs
file and read the new value or close the file and re-open it
to read the value.

"edge" ... reads as either "none", "rising", "falling", or
"both". Write these strings to select the signal edge(s)
that will make poll(2) on the "value" file return.

This file exists only if the pin can be configured as an
interrupt generating input pin.


This is a generic interface, you can use it from any language that gives
you access to a poll or select call.


Vincent Bernardoff

unread,
Jun 6, 2015, 1:28:19 PM6/6/15
to linux...@googlegroups.com
Hi,

Thanks you for the link.

Unfortunately as for Linux version 4.0 there seems to be no support for
interrupts (no edge file present).

Are there anybody doing GPIO + interrupts on linux sunxi ?

--
Vincent

Andrea Venturi

unread,
Jun 6, 2015, 4:47:55 PM6/6/15
to linux...@googlegroups.com
some time ago, i started looking at  EINTC, External interrupt:

 http://linux-sunxi.org/External_interrupts

you can have a look at this short thread:

https://groups.google.com/d/msg/linux-sunxi/lPP1aO9tWvI/x6moRqMarlIJ

to make a long story short:

- the external interrupt feature is DIFFERENT then a "generic GPIO" and it's multiplexed on some pins only  (loook for EINTC in allwiner SOC user manual..), few pins can react in the interrupt async way. and AFAIK the PDx pins are not enabled, but please check

- as far as i know, now, on a kernel 4.0 mainline, you can have the lower "A10 original" interrupts EINTx working (at least this is what i found) but the higher (A20 only in a second bank..)

- mripard told  on the list this feature is working by accident  and some work is needed to enable the higher ones (A20 only)

that's what i remember.

Vincent Bernardoff

unread,
Jun 7, 2015, 3:16:39 AM6/7/15
to linux...@googlegroups.com
On 06/06/2015 22:47, Andrea Venturi wrote:
> you can have a look at this short thread:

Ok, awesome, thanks for pointing me into this, interrupts working by
accident on some pins is enough for me ATM :)

Cheers,

--
Vincent
Reply all
Reply to author
Forward
0 new messages