Hi. this is L.F
this post is about GPIO(General Purpose Input/Output), that can make it easy to use extra modules.(ex : read data from other chips, control other chips)
CubieBoard2 has 96 extend pin interface. Except some pins for special purpose, we can use it frankly.
This is the GPIO Pin Defination for Cubian. Pin Number for ‘Special Purpose’ are not expressed.
Now, let me show some simple example for using GPIO.
- CubieBoard2 with Cubian
In this example, I’ll use pin number 17, defined ‘PG9’ marked in first picture.
Connect input cable to pin number 17, and the other end to GND pin.(anything you want)
- Open GPIO pin to access specific pin.
# echo 17 > /sys/class/gpio/export
then, you can see dev file for access pin no.17
# ls /sys/class/gpio/
export gpio17_pg9 gpiochip1 unexport
- Now, pin No.17 can use for Input or Output.
# echo out > /sys/class/gpio/pin_number/direction
# echo in > /sys/class/gpio/pin_number/direction
(in this example, configure direction to OUTPUT)
- Finally, export signal to pin No.17 PG9
# echo 1 > /sys/class/gpio/gpio17_pg9/value (LED ON)
# echo 0 > /sys/class/gpio/gpio17_pg9/value (LED OFF)
And here is another example C code for test LED module. if you run successfully, LED will blinking 1 time a second.