资源描述:
《嵌入式LINUX四按键驱动》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、GeneratedbyFoxitPDFCreator©FoxitSoftwarehttp://www.foxitsoftware.comForevaluationonly.对一个具有四个按键的按键驱动的分析源代码:/*Headers-------------------------------------------------*/#include#include#include#include
2、#include#include#include#include#include#include#include#include#include#include#include#in
3、clude#ifdefCONFIG_DEVFS_FS#include#endif/*Vars----------------------------------------------------*/#defineDEVICE_NAME"buttons"#defineEXTINT_OFF(IRQ_EINT4-4)unsignedintbuttons_major=0;unsignedintbuttons_minor=0;unsignedintty
4、pe=IRQT_FALLING;structbutton_info{unsignedintirq_no;unsignedintgpio_port;unsignedintIN;intbutton_no;};structbutton_inforealarm_button_info[4]={{IRQ_EINT19,S3C2410_GPG11,S3C2410_GPG11_INP,1},{IRQ_EINT8,S3C2410_GPG0,S3C2410_GPG0_INP,2},GeneratedbyFoxitPDFCreator©Foxit
5、Softwarehttp://www.foxitsoftware.comForevaluationonly.{IRQ_EINT11,S3C2410_GPG3,S3C2410_GPG3_INP,3},{IRQ_EINT2,S3C2410_GPF2,S3C2410_GPF2_INP,4},};structrealarm_button_dev{structbutton_infobuttoninfo_tab[4];intextint_num[4];structsemaphoresem;wait_queue_head_twq;struc
6、tcdevbuttons_dev;};structrealarm_button_dev*realarm_button_device;voids3c_irq_ack(unsignedintirqno){unsignedlongbitval=1UL<<(irqno-IRQ_EINT0);__raw_writel(bitval,S3C2410_SRCPND);__raw_writel(bitval,S3C2410_INTPND);return;}voids3c_irqext_ack(unsignedintirqno){unsigne
7、dlongreq;unsignedlongbit;bit=1UL<<(irqno-EXTINT_OFF);__raw_writel(bit,S3C2410_EINTPEND);req=__raw_readl(S3C2410_EINTPEND);if(irqno<=IRQ_EINT7){if((req&0xf0)==0)s3c_irq_ack(IRQ_EINT4t7);}else{if((req>>8)==0)s3c_irq_ack(IRQ_EINT8t23);GeneratedbyFoxitPDFCreator©FoxitSo
8、ftwarehttp://www.foxitsoftware.comForevaluationonly.}return;}intrealarm_interrupt_init(unsignedintirq,unsignedinttype){unsignedlonggpcon_r