How to control GPIO in Android application?

Hi,

I want to create android application that is able to control GPIO, LED, Serial port.
I’ve searched a lot but can’t get enough of good solution.
The following is the programming path which I understand.

Android App (Java) —> Android JNI —> Android Native Code (C/C++) —> ??? —> Device Drivers

. How can I access the Device Drivers (GPIO, LED, Serial port) in Android Native C/C++ code?

. Do I need to modify or create existing device driver for using GPIO, LED, Serial port?

. Is there library provided to read/write specific resource like “/sys/class/gpio/gpio91/value”?

. Would you let me know how to access GPIO, LED, Serial port in Android App with sample source code or SDK?

Thanks.

http://developer.t-firefly.com/thread-2436-1-1.html

a sample for you

thanks.

in your sample, how can I build luobogpio.c (driver) file and put luobogpio.o (maybe..) file into dev/luobogpio?

本帖最后由 carlinluo 于 2015-9-10 10:16 编辑

zamster 发表于 2015-9-10 09:06
thanks.

in your sample, how can I build luobogpio.c (driver) file and put luobogpio.o (maybe..) f …

http://wiki.t-firefly.com/index.php/Firefly-RK3288/Build_android

I want to know how to build custom driver file. (not to build android sdk)
meaning of build custom driver file indicates that adding a new file (luobogpio.c into where?), modifying Makefile, creating object file, and so on.

still don’t get it enough…

Serial ------ demo ./base/tests/SerialChat/src/com/android/serialchat/SerialChat.java
gpoi --------- usage cd /sys/class/gpio&& echo 18 > export &&cd gpio18&echo out > direction &&echo 1 > value.

you also need add chmod 0666 /sys/class/gpio* init.rc
add ueventd.rc /sys/class/gpio/* 0666 root root