您正在寻找的头文件是
#include
您需要做的第一件事是分配特定的GPIO.您可以使用此调用执行此操作:
#define GPIO //gpio number
...
if(gpio_request(GPIO, "Description"))
//fail
...
在获得GPIO引脚后,您可以获取它的IRQ
int irq = 0;
if((irq = gpio_to_irq(GPIO)) < 0 /*irq number can't be less than zero*/)
//fail
...
现在,您使用通常的内核例程注册IRQ处理程序.
#include
...
int result = request_irq(irq, handler_function,
IRQF_TRIGGER_LOW, /*here is where you set up on what event should the irq occur*/
"Description", "Device description");
if(result)
//fail
...
在进行模块清理时,请记住free_irq和gpio_free.如果不这样做,您将无法再次分配该GPIO引脚.