Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


Sidebar

products:sbc:common:applications:gpio:irq

This is an old revision of the document!


GPIO Interrupts

Introduction

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.

Hardware Connection

Connect the physical pins (PIN20 and PIN15) using a DuPont line.

System Configuration

  • Get GPIOH6 number

Refer 40-Pin Header to get the GPIO number is 433.

  • Export GPIO
$ 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.

Demo Source Code

  • Get demo source code
$ wget https://dl.khadas.com/development/code/docs_source/gpio_interrupts.c
  • Compile the source code
$ gcc -o gpio_interrupts gpio_interrupts.c

Demonstrate

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!
Last modified: 2022/07/04 02:23 by frank