GPIOIRQ(4) | Device Drivers Manual | GPIOIRQ(4) |
gpioirq
—
gpioirq* at gpio? offset 0 mask 0x1 flag 0x00
gpioirq
driver attaches an interrupt handler to a
one or more GPIO pins.
The base pin number is specified in the kernel configuration file with the offset locator. The mask locator can be 0x01 or greater to indicate that more pins should have an interrupt handler attached to them.
The flag locator specifies the interrupt mode to use:
0x01
0x02
0x04
0x08
0x10
Note that the interrupts modes are mutually-exclusive, and exactly
one interrupt mode must be specified. These flags correspond to the
GPIO_INTR
mode bits defined in
sys/gpio.h. In addition to the interrupt mode,
setting 0x1000
in flags will
enable the printing of a message to the console whenever the interrupt
handler is called.
The offset, mask, and
flag locators can also be specified when
gpioirq
is attached at runtime using the
GPIOATTACH
ioctl(2) on the
gpio(4) device.
/etc/gpio.conf contains: gpio0 attach gpioirq 4 0x1ff 0x04 or a kernel was compiled to have the same parameters. #!/usr/pkg/bin/perl $dev = "/dev/gpioirq0"; sysopen(DEV,$dev,O_RDONLY) || die "sysopen: $!"; while (sysread(DEV,$b,3)) { @v = unpack("CCC",$b); print join(',',@v); print "\n"; }
gpioirq
driver first appeared in
NetBSD 9.0.
gpioirq
driver was written by Brad
Spencer
<brad@anduin.eldar.org>.
It is important that if the gpioirq(4) device is opened that it be read, as it may be possible to run the kernel out of memory if the device is opened but not read and interrupts occur on a pin tied to the driver.
November 5, 2023 | NetBSD 10.1 |