Board logo

标题: arm驱动(7) [打印本页]

作者: yuyang911220    时间: 2014-8-29 17:24     标题: arm驱动(7)

int keyirq_open(struct inode *inode, struct file *file)
{
    clearIrq();

#if 1
    enable_irq(IRQ_EINT0);
    enable_irq(IRQ_EINT1);
    enable_irq(IRQ_EINT6);
#endif

    sema_init(&key_sem, 0);
    return 0;
}

int keyirq_release(struct inode *inode, struct file *filp)
{
#if 1
    disable_irq(IRQ_EINT0);
    disable_irq(IRQ_EINT1);
    disable_irq(IRQ_EINT6);
#endif
    return 0;
}


static int keyirq_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
{
    return 0;
}

struct file_operations keyirq_fops = {
     .owner= THIS_MODULE,
     .read = keyirq_read,
     .open = keyirq_open,
     .release = keyirq_release,
     .ioctl = keyirq_ioctl,
};

int __init keyirq_init(void)
{
    int rc;

    printk("_SDK2410 gpio key driver irq=%d\n", IRQ_EINT0);

    set_irq_type(IRQ_EINT0, IRQT_FALLING);
    set_irq_type(IRQ_EINT1, IRQT_FALLING);
    set_irq_type(IRQ_EINT6, IRQT_FALLING);

    rc = request_irq(IRQ_EINT0, key1_irq_isr, SA_INTERRUPT, "key2345irq", NULL);
    if (rc) {
        printk ("<1>keyirq 1 irq not registered. Error:%d\n", rc);
    }

    rc = request_irq(IRQ_EINT1, key2_irq_isr, SA_INTERRUPT, "key2345irq", NULL);
    if (rc) {
        printk ("<1>keyirq 2 irq not registered. Error:%d\n", rc);
    }

    rc = request_irq(IRQ_EINT6, key3_irq_isr, SA_INTERRUPT, "key2345irq", NULL);
    if (rc) {
        printk ("<1>keyirq 4 irq not registered. Error:%d\n", rc);
    }




欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) Powered by Discuz! 7.0.0