-
Notifications
You must be signed in to change notification settings - Fork 1
Control Gpio
- to use shell command
- to use Api
First you have to access the serial console - setup console, in the terminal. Then power on,and input command in the terminal
cd /sys/class/gpio
echo 38 > export
Then you will find a directory gpio38
cd gpio38
ls
Then you will find some files in this directory,and we usually use "value" and "direction "
- value:gpio value, low level: 0, high level: 1
get value
cat value
set value
echo 0/1 > value
- direction: include some modes
in: to set gpio "input mode"
echo in > direction
out: to set gpio "output mode"
echo out > direction
low:to set gpio "output mode", and value=0
echo low > direction
cat value
high:to set gpio "output mode", and value=1
echo high > direction
cat value
cd ../
echo 38 > unexport
## To Use Api
Use I/O opration to control gpio,and we have provided the api - to use RKGpioApi.c
-
Enable Gpio: RK_GpioOpen();
-
Set Value: RK_GpioWrite();
-
Gey Value: RK_GpioRead();
-
Set Edge(not necessary): RK_GpioEdge();
-
Disable Gpio: RK_GpioClose();
and if you need file descriptor of value, use:
-
Open Gpio Value and return fd: RK_GpioValueOpen();
-
Close Gpio Value: RK_GpioValueClose();