Tinker Board Forum

Full Version: wiringPi for Android
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6
Hello there, i am new to this forum. I have a TinkerBoard since 6 weeks and I try to port a project of mine. As I have already adapted the wiringPi code from Asus to Android, I would like to share it.
You can find it on github: https://github.com/joerg65/wiringTinker_Android
As I describe there, to use the wiringPi GPIO functions from an app, it is needed a gpiomem driver. You will find the source code for the gpiomem driver also on my github repositories: https://github.com/joerg65/gpiomem_tinkerboard
If there are any question, please ask better here and not on github. I tried to explain everything well. but sometimes there are missing some information.
Only some functions as GPIO read and write and soft pwm are tested, so there might be some not functional parts. The spi also need a modification in kernel, this I would publish in the next days.
great news, thank you !
Great job, thanks for your work !

I push the library into jniLibs folder and build an android app to access gpio, it is working for me.

This is my execution result.
[attachment=91]

* I modify the Application.mk for tinkerboard
Code:
APP_ABI := armeabi armeabi-v7a
Fine that it work for you and thank you for the update.
Hi 
I have xamarin with visual studio 2015 with c# for make my android app.
how can i use this library for programming?
thanks
Hi, I have no experience with xamarin and c#. But it should be possible to import the libwiringPi.so library.
Take a look here: https://developer.xamarin.com/guides/and...libraries/
First you need to compile the wiringPi, for that you'll need the Android NDK.


Great job, works very well. Thank you.
Thank you.
But please don't use the softPWM functions. I found that it blocks the UI heavily and not yet found the reason why. On Odroid C1/C2 the same code runs well.
(09-27-2017, 05:24 PM)lobo Wrote: [ -> ]Hello there, i am new to this forum. I have a TinkerBoard since 6 weeks and I try to port a project of mine. As I have already adapted the wiringPi code from Asus to Android, I would like to share it.
You can find it on github: https://github.com/joerg65/wiringTinker_Android
As I describe there, to use the wiringPi GPIO functions from an app, it is needed a gpiomem driver. You will find the source code for the gpiomem driver also on my github repositories: https://github.com/joerg65/gpiomem_tinkerboard
If there are any question, please ask better here and not on github. I tried to explain everything well. but sometimes there are missing some information.
Only some functions as GPIO read and write and soft pwm are tested, so there might be some not functional parts. The spi also need a modification in kernel, this I would publish in the next days.

Hi lobo, 
thanks for you share ,  which gpio port we can use (i mean not occupy for system )?
Hi leonzhangzhang,
here you can see all gpio that are usable by wiringPi:

Code:
root@rk3288:/ # /system/bin/gpio readall
+-----+-----+---------+------+---+--Tinker--+---+------+---------+-----+-----+
| CPU | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | CPU |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
|     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
| 252 |   8 |   SDA.1 |      | 1 |  3 || 4  |   |      | 5V      |     |     |
| 253 |   9 |   SCL.1 |      | 1 |  5 || 6  |   |      | 0v      |     |     |
|  17 |   7 | GPIO0C1 |   IN | 0 |  7 || 8  | 0 | SERL | TxD1    | 15  | 161 |
|     |     |      0v |      |   |  9 || 10 | 1 | SERL | RxD1    | 16  | 160 |
| 164 |   0 | GPIO5B4 |   IN | 1 | 11 || 12 | 0 |      | GPIO6A0 | 1   | 184 |
| 166 |   2 | GPIO5B6 |   IN | 0 | 13 || 14 |   |      | 0v      |     |     |
| 167 |   3 | GPIO5B7 |   IN | 1 | 15 || 16 | 1 | IN   | GPIO5B2 | 4   | 162 |
|     |     |    3.3v |      |   | 17 || 18 | 1 | IN   | GPIO5B3 | 5   | 163 |
| 257 |  12 |   MOSI1 |      | 0 | 19 || 20 |   |      | 0v      |     |     |
| 256 |  13 |   MISO1 |      | 0 | 21 || 22 | 0 | IN   | GPIO5C3 | 6   | 171 |
| 254 |  14 |   SCLK1 |      | 1 | 23 || 24 | 1 |      | CE0     | 10  | 255 |
|     |     |      0v |      |   | 25 || 26 | 1 |      | CE1     | 11  | 251 |
| 233 |  30 |   SDA.2 |   IN | 1 | 27 || 28 | 1 |      | SCL.2   | 31  | 234 |
| 165 |  21 | GPIO5B5 |   IN | 1 | 29 || 30 |   |      | 0v      |     |     |
| 168 |  22 | GPIO5C0 |   IN | 1 | 31 || 32 | 1 | SERL | GPIO7C7 | 26  | 239 |
| 238 |  23 | GPIO7C6 | SERL | 1 | 33 || 34 |   |      | 0v      |     |     |
| 185 |  24 | GPIO6A1 |      | 0 | 35 || 36 | 1 | IN   | GPIO7A7 | 27  | 223 |
| 224 |  25 | GPIO7B0 |   IN | 0 | 37 || 38 | 0 |      | GPIO6A3 | 28  | 187 |
|     |     |      0v |      |   | 39 || 40 | 0 |      | GPIO6A4 | 29  | 188 |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| CPU | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | CPU |
+-----+-----+---------+------+---+--Tinker--+---+------+---------+-----+-----+

All the pins that are IN or OUT can be used.
Note that the pins 32 and 33 normally also are usable, but I changed the devicetree to have the ttyS4 there.
Best is you check on your own system with gpio readall.
Pages: 1 2 3 4 5 6