我正在尝试将IRQ 处理程序附加到gpio bank 0即0B irq no 97
。
目前,我的实现返回-1
. 我究竟做错了什么?这将是一个非常简单的问题。
#include <stdio.h>
#include <unistd.h>
#include "gpio.h"
#include <sys/neutrino.h>
#include "interrupt.h"
volatile unsigned int gpio0_irq_count;
static const struct sigevent * gpio0_irq_handler (void *gpio, int id){
gpio0_irq_count++;
return NULL;
}
int main(){
int ret;
unsigned long count=0;
ret = InterruptAttach(97, gpio0_irq_handler, NULL,0,_NTO_INTR_FLAGS_TRK_MSK);
printf("%s: Registering handler for irq %d result = %d\n",__func__ , 97, ret);
if (ret)
return -1;
while(1){
printf("%s:[%lu] : gpio0_irq_count = %d\n", __func__, count++, gpio0_irq_count);
sleep(2);
}
}
错误的输出是:
main: Registering handler for irq 97 result = -1