开发者

GPIO pin Interrupt handlers in linux (arm)

Can somebody point me at some sample code for enabling and handling user pin IO interrupts (C language) for an ARM9 in linux?

I am aware that a low level driver may be needed, I just want to get som开发者_Python百科e ideas on how to initialise it, then handle the messaging at the user level etc.

I am familiar with ARM interrupts, and device drivers (in Windows) but I am new to linux programming.

thanks


It really depends on the actual BSP you're using. AFAIK there's no "generic ARM9 gpio interrupt" in Linux, it's pretty much board-specific. E.g. here's an example for a PCA100 board:

static int pca100_sdhc2_init(struct device *dev, irq_handler_t detect_irq,
                void *data)
{
        int ret;

        ret = request_irq(IRQ_GPIOC(29), detect_irq,
                          IRQF_DISABLED | IRQF_TRIGGER_FALLING,
                          "imx-mmc-detect", data);
        if (ret)
                printk(KERN_ERR
                        "pca100: Failed to reuest irq for sd/mmc detection\n");

        return ret;
}

static void pca100_sdhc2_exit(struct device *dev, void *data)
{
        free_irq(IRQ_GPIOC(29), data);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜