Firefly开源社区

标题: How to control GPIO in Android application? [打印本页]

作者: zamster    时间: 2015-9-9 16:10
标题: 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.
作者: carlinluo    时间: 2015-9-9 16:14
http://developer.t-firefly.com/thread-2436-1-1.html  

a sample for you
作者: zamster    时间: 2015-9-10 09:06
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 09:53
本帖最后由 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

作者: zamster    时间: 2015-9-10 13:38
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...
作者: wangwu125    时间: 2015-9-11 08:48
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.
作者: wangwu125    时间: 2015-9-11 08:55
you also need add chmod 0666  /sys/class/gpio* init.rc
add  ueventd.rc /sys/class/gpio/*             0666   root       root




欢迎光临 Firefly开源社区 (https://dev.t-firefly.com/) Powered by Discuz! X3.1