mirror of
https://github.com/Hizenberg469/Driver-tutorial.git
synced 2026-04-19 16:32:23 +03:00
driver-tutorial finished
This commit is contained in:
30
interrupt/interrupt.c
Normal file
30
interrupt/interrupt.c
Normal file
@@ -0,0 +1,30 @@
|
||||
#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);
|
||||
}
|
||||
Reference in New Issue
Block a user