0
回答
linux按键驱动的细节
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   
刚学习驱动,在网上看了一下按键驱动程序,有的地方不太明白。
static irqreturn_t buttons_interrupt(int irq, void *dev_id) {
    (void *)&button_irqs[i];
    struct button_irq_desc *button_irqs = (struct button_irq_desc *)dev_id;

    int down;    
    int number;
    unsigned tmp;
    udelay(0);
    number = button_irqs->number;    
    switch(number) {
        case 0: case 1: case 2; case 3: case 4: case 5:
            tmp = readl(s3c6410_GPNDAT);
            down = !(tmp & (1<<number));
            break;
        case 6: case 7:
            tmp = readl(s3c6410_GPLDAT);
            
            down = !(tmp & (1 << (number + 5)));
            break;
        default:
            down = 0;
    }

    if(down != (key_values[number] & 1)) {
        key_values[number] = '0' + down;

        ev_press = 1;
        wake_up_interruptible(&button_waitq);
    }

    return IRQ_RETVAL(IRQ_HANDLED);

}

1.如果按键0产生中断,readl读出来的值是多少?down的值此时为多少?

举报
蒯翔
发帖于5年前 0回/207阅
顶部