资源描述:
《s3c2440开发板按键中断驱动》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、/*************************************NAME:button.c*************************************/#include#include#include#include#include#include#include#include#inclu
2、de#include#include#include#include#include#include#defineDEVICE_NAME"IRQ-Test"structbutton_irq_desc{intirq;intpin;intpin_setting;intnumber;cha
3、r*name;};#if!defined(CONFIG_SKY2440_IRQ_TEST)staticstructbutton_irq_descbutton_irqs[]={{IRQ_EINT1,S3C2410_GPF1,S3C2410_GPF1_EINT1,0,"KEY1"},/*K1*/{IRQ_EINT4,S3C2410_GPF4,S3C2410_GPF4_EINT4,1,"KEY2"},/*K2*/{IRQ_EINT2,S3C2410_GPF2,S3C2410_GPF2_EINT2,2,"KEY3"},/*K3*/{IRQ_E
4、INT0,S3C2410_GPF0,S3C2410_GPF0_EINT0,3,"KEY4"},/*K4*/};#elsestaticstructbutton_irq_descbutton_irqs[]={{IRQ_EINT9,S3C2410_GPG1,S3C2410_GPG1_EINT9,0,"KEY1"},/*K1*/{IRQ_EINT11,S3C2410_GPG3,S3C2410_GPG3_EINT11,1,"KEY2"},/*K2*/{IRQ_EINT2,S3C2410_GPF2,S3C2410_GPF2_EINT2,2,"KE
5、Y3"},/*K3*/{IRQ_EINT0,S3C2410_GPF0,S3C2410_GPF0_EINT0,3,"KEY4"},/*K4*/};#endifstaticvolatilecharkey_values[]={'0','0','0','0'};staticDECLARE_WAIT_QUEUE_HEAD(button_waitq);staticvolatileintev_press=0;//°´ÏÂΪ1¶ÁºóΪ0staticirqreturn_tirq_interrupt(intirq,void*dev_id){stru
6、ctbutton_irq_desc*button_irqs=(structbutton_irq_desc*)dev_id;intdown;down=!s3c2410_gpio_getpin(button_irqs->pin);if(down!=(key_values[button_irqs->number]&1)){key_values[button_irqs->number]='0'+down;ev_press=1;wake_up_interruptible(&button_waitq);}returnIRQ_RETVAL(IRQ_
7、HANDLED);}staticinttq2440_irq_open(structinode*inode,structfile*file){inti;interr=0;for(i=0;i8、&button_irqs[i]);if(err)break;}if(err){i--;for(;i>=0;i--){if(button_irqs[i].irq<0)continue;disable_irq(button_