This is an old revision of the document!
This document mainly introduces how to use GPIO interrupts on Khadas SBC. You will know how to use GPIO interrupts with the GPIO number test program.
Use GPIOH6
on VIM3 as a example.
Connect the physical pins (PIN20 and PIN15) using a DuPont line.
GPIOH6
number
Refer 40-Pin Header to get the GPIO number is 433
.
$ echo 433 | sudo tee /sys/class/gpio/export
Please use gpio readall to check the status of GPIOH_6, if it is not shown as a normal GPIO, you need to remove uart3 from overlays in the /boot/env.txt file.
Check the Device Tree Overlay for more details.
$ wget https://dl.khadas.com/development/code/docs_source/gpio_interrupts.c
$ gcc -o gpio_interrupts gpio_interrupts.c
The test code running format is as follows:
$ sudo ./gpio_interrupts <edge> [pull]
Run test:
$ sudo ./gpio_interrupts rising down . GPIO 433 interrupt occurred! .. GPIO 433 interrupt occurred! . GPIO 433 interrupt occurred! . GPIO 433 interrupt occurred!