GPIOIRQ(4)
gpioirq(4) π β¨
okay so bestie, welcome to the gpioirq(4) page from the Kernel Interfaces Manual. this one is literally about installing an interrupt handler on GPIO pins, and it's giving very specific kernel-config energy. no cap. π¦
π NAME π
gpioirq β install an interrupt handler on GPIO pins. periodt. π
β¨ SYNOPSIS β¨
gpioirq* at gpio? offset 0 mask 0x1 flag 0x00
πΈ DESCRIPTION πΈ
okay so the gpioirq driver attaches an interrupt handler to one or more GPIO pins. iconic.
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β interrupt on the positive (rising) edge of the pin.0x02β interrupt on the negative (falling) edge of the pin.0x04β interrupt on both edges of the pin.0x08β assert the interrupt as long as the pin is high.0x10β assert the interrupt as long as the pin is low.
bestie, note this: the interrupt modes are mutually-exclusive, and exactly one interrupt mode must be specified. no mixing and matching. π
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.
π FILES π
/dev/gpioirquβ GPIOIRQ device unit u file. The output from this device are threeuint8_tbytes every time an interrupt fires. The bytes contain the device unit, pin number and the current state of the pin.
π§ EXAMPLES π§
The following example will output the device unit, pin and the pins current state for pins 4, 5, 6, 7, 8, 9, 10, 11, 12 on gpio0:
/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";
}
π SEE ALSO π
gpio(4)drvctl(8)gpioctl(8)
π HISTORY π
The gpioirq driver first appeared in NetBSD 9.0. she's not new new, but she's still cute. π
π AUTHORS π
The gpioirq driver was written by Brad Spencer <brad@anduin.eldar.org>. king behavior. π
π BUGS π
okay so real talk: when an interrupt fires in most devices there is not any information carried along in the interrupt as to whether or not the pin is high or low. hence the driver reads the current state of the pin after the interrupt has fired, and it is possible that the state of the pin could have changed between the time the interrupt fired and the reading of the state. as a practical matter the only time the pin state will be reported wrong is if there is a very large number of interrupts happening.
The driver could have made some assumptions if the interrupt was only for a rising edge or falling edge as in those cases it would be possible to know what the pin state would have been, but in the case of the double edge, there really will not be any way to be sure with most hardware and, in any case, the gpio(4) infrastructure does not support getting at that information even if it did exist.
π¨ important warning: 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.
that's the whole page, bestie π«Ά this cutie came from Debian, dated November 5, 2023 β GPIOIRQ(4) and out π
β¨
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 2016, 2023 Brad Spencer <brad@anduin.eldar.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms