driver-tutorial finished

This commit is contained in:
2025-02-25 08:19:58 +00:00
parent 8a8b8cf56a
commit 9eed2d489b
17 changed files with 2393 additions and 0 deletions

30
interrupt/interrupt.c Normal file
View 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);
}