Files
Driver-tutorial/interrupt/interrupt.c
2025-02-25 08:19:58 +00:00

30 lines
824 B
C

#include <linux/kernel.h>
#include <linux/module.h>
#include <asm/irq.h>
#include <asm/mach/irq.h>
#include <linux/interrupt.h>
irqreturn_t myIRQ(int irq, void *devid){
//Clear pending interrupt
return IRQ_HANDLED;
}
int my_open(void){
//Set polarity and type of interrupt
//this is the api to register interrupt to
//kernel driver.
requet_irq(30, myIRQ, 0, "MYIRQ", 1);
//This 30 is the line number in interrupt register
//stored. It's like a id to the interrupt handler.
//The last line is the decive number. If multiple
//device uses same IRQ handler, then this last argument
//is used to diffrentiate between various devices using
//the same IRQ Handler.
}
void my_release(void){
//To release the interrupt handler
//free_irq api is used.
free_irq(30,1);
}