- 論壇徽章:
- 0
|
我在看按鍵的驅(qū)動程序時,對中斷處理函數(shù)中的一行代碼(下面代碼紅色的部分)不清楚,望高手賜教,謝謝,相關(guān)代碼如下:
static volatile int key_values [] = {0, 0, 0, 0};
static DECLARE_WAIT_QUEUE_HEAD(button_waitq);
static volatile int ev_press = 0;
struct button_irq_desc
{
int irq;
int pin;
int pin_setting;
int number;
char *name;
};
/* 用來指定按鍵所用的外部中斷引腳及中斷觸發(fā)方式, 名字 */
static struct button_irq_desc button_irqs [] =
{
{IRQ_EINT4, S3C2410_GPF(4), S3C2410_GPF4_EINT4, 0, "KEY1"}, /* K1 */
{IRQ_EINT5, S3C2410_GPF(5), S3C2410_GPF5_EINT5, 1, "KEY2"}, /* K2 */
{IRQ_EINT6, S3C2410_GPF(6), S3C2410_GPF6_EINT6, 2, "KEY3"}, /* K3 */
{IRQ_EINT7, S3C2410_GPF(7), S3C2410_GPF7_EINT7, 3, "KEY4"}, /* K4 */
};
static irqreturn_t buttons_interrupt(int irq, void *dev_id)
{
struct button_irq_desc *button_irqs = (struct button_irq_desc *)dev_id;
int key_press = s3c2410_gpio_getpin(button_irqs->pin);
if (key_press == 0)
{
mdelay(5);
key_press = s3c2410_gpio_getpin(button_irqs->pin);
if (key_press == 0)
key_values[button_irqs->number] = (button_irqs->number + 1);//這行代碼是干什么用的
}
ev_press = 1;
wake_up_interruptible(&button_waitq);
return IRQ_RETVAL(IRQ_HANDLED);
} |
|