Posts: 2
Threads: 1
Likes Received: 0 in 0 posts
Likes Given: 0
Joined: Nov 2019
I'm using C to control the GPIO port. Only the 17-pin works.
So I tried the python-API, while everything works well.
And then I use the C source code under the python-api.
It works the same as wiringPi...in my opinion, it should work as the python likes.
/sys/class/gpio/gpio.../value works well...
the code I used is the c_gpio.c under source folder of python-api.
setup...
setup_gpio...
output_gpio...
cleanup...
I want to know how to use it ....
•
Posts: 948
Threads: 20
Likes Received: 62 in 54 posts
Likes Given: 12
Joined: Jul 2018
The primary condition is to use the program with administration privileges, otherwise no access to the hardware.
Second case, it might be simple to use wirnigPi, like the added examples, included with linaro installation.
Light blue words might be a link. Have you try to click on them?
•
Posts: 2
Threads: 1
Likes Received: 0 in 0 posts
Likes Given: 0
Joined: Nov 2019
(11-21-2019, 06:03 AM)Im4Tinker Wrote: The primary condition is to use the program with administration privileges, otherwise no access to the hardware.
Second case, it might be simple to use wirnigPi, like the added examples, included with linaro installation.
In my case...wiringPi doesn't work...and I used the administration privileges...
I'm tring to use mmap to do it...but the GPIO8 block seems no right...
•
Posts: 52
Threads: 2
Likes Received: 5 in 4 posts
Likes Given: 0
Joined: Sep 2018
11-23-2019, 09:18 AM
(This post was last modified: 11-23-2019, 03:45 PM by k247tEK. Edited 5 times in total.)
(11-21-2019, 01:20 PM)liugchome2004 Wrote: (11-21-2019, 06:03 AM)Im4Tinker Wrote: The primary condition is to use the program with administration privileges, otherwise no access to the hardware.
Second case, it might be simple to use wirnigPi, like the added examples, included with linaro installation.
In my case...wiringPi doesn't work...and I used the administration privileges...
I'm tring to use mmap to do it...but the GPIO8 block seems no right...
hi liugchome2004,
by.. GPIO8 you mean physical pin 8 , GPIOASUS 161, wPi 15
that is set as serial TX.. by device tree maybe ;-]....
have you tried
then set to output
gpio readall..
Code:
root@localhost:~# gpio readall
+-----+-----+---------+------+---+--Tinker--+---+------+---------+-----+-----+
| CPU | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | CPU |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| | | 3.3v | | | 1 || 2 | | | 5v | | |
| 252 | 8 | SDA.1 | I2C | 1 | 3 || 4 | | | 5v | | |
| 253 | 9 | SCL.1 | I2C | 1 | 5 || 6 | | | 0v | | |
| 17 | 7 | GPIO0C1 | IN | 0 | 7 || 8 | 0 | OUT | GPIO5B1 | 15 | 161 |
| | | 0v | | | 9 || 10 | 1 | SERL | RxD.1 | 16 | 160 |
| 164 | 0 | GPIO5B4 | OUT | 0 | 11 || 12 | 0 | I2S | I2S_CLK | 1 | 184 |
| 166 | 2 | GPIO5B6 | IN | 0 | 13 || 14 | | | 0v | | |
| 167 | 3 | GPIO5B7 | IN | 0 | 15 || 16 | 0 | IN | GPIO5B2 | 4 | 162 |
| | | 3.3v | | | 17 || 18 | 0 | IN | GPIO5B3 | 5 | 163 |
| 257 | 12 | MOSI.2 | SPI | 0 | 19 || 20 | | | 0v | | |
| 256 | 13 | MISO.2 | SPI | 1 | 21 || 22 | 0 | IN | GPIO5C3 | 6 | 171 |
| 254 | 14 | SCLK.2 | SPI | 1 | 23 || 24 | 1 | SPI | CE0.2 | 10 | 255 |
| | | 0v | | | 25 || 26 | 1 | IN | GPIO8A3 | 11 | 251 |
| 233 | 30 | SDA.4 | I2C | 1 | 27 || 28 | 1 | I2C | SCL.4 | 31 | 234 |
| 165 | 21 | RTSN.4 | SERL | 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 | I2S_FS | I2S | 0 | 35 || 36 | 1 | SERL | RxD.3 | 27 | 223 |
| 224 | 25 | TxD.3 | SERL | 0 | 37 || 38 | 1 | I2S | I2S_SDI | 28 | 187 |
| | | 0v | | | 39 || 40 | 0 | I2S | I2S_SDO | 29 | 188 |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| CPU | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | CPU |
+-----+-----+---------+------+---+--Tinker--+---+------+---------+-----+-----+
root@localhost:~#
i use this simple c program to test PIN wPi 0 to blink LED on & off..
Code:
#include <stdio.h>
#include <wiringPi.h>
// #define LED 0 matches with ASUS_GPIO 164! This can be checked with command 'sudo gpio readall'.
#define LED 0
int main (void)
{
printf ("TB blink\n");
wiringPiSetup ();
pinMode (LED, OUTPUT);
for (;;)
{
printf ("led on\n");
digitalWrite (LED, HIGH);
delay (500);
printf ("led off\n");
digitalWrite (LED, LOW);
delay (500);
}
return 0;
}
I still do not know how to use the alt0, alt1, alt2, alt3, alt4 & alt5 modes
--------------- ;-]..
hope it helps
k,
-----
ps.. searching for mmap & gpio got me to..
Low Level Programming of the Raspberry Pi in C &
an old post here..
GPIO mmap vs. sysfs, picberry, OneWire DS18B20 and other fairytales
and for offsets for tinker board this might help..
package com.diozero.internal.board.tinkerboard;
now my head hurts ]]]].......
•