如何知道Linux中特定引脚的中断/GPIO编号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11212637/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to know the Interrupt/GPIO number for a specific pin in linux
提问by Abd elrahman Diab
i'm doing a project in which i need to handle an interrupt in Linux.
我正在做一个项目,我需要在 Linux 中处理一个中断。
the board i'm using is an ARM9Boardbased on the s3c6410 MCU by Samsung (arm 11 processor) and it has the following I/O interface :
我使用的板是一个ARM9Board由三星(臂11处理器)的基础上S3C6410 MCU和它下面的I / O接口:
as the image shows i have EINTx pins for external interrupts and GPxx pins as GPIO pins and i don't mind using any of them but i don't have their numbers !
如图所示,我有用于外部中断的 EINTx 引脚和作为 GPIO 引脚的 GPxx 引脚,我不介意使用它们中的任何一个,但我没有它们的编号!
For EINTx pins :
对于 EINTx 引脚:
when i call
当我打电话时
int request_irq(unsigned int irq, void (*handler)(int, struct pt_regs *),
unsigned long flags, const char *device);
i need the interrupt number to pass it as the first paramter of the function , so how can i get the irq number for example the EINT16 pin ?
我需要中断号将它作为函数的第一个参数传递,那么我怎样才能获得 irq 号,例如 EINT16 引脚?
For GPxx pins :the same story as i need the GPIO pin nuumber to pass it to those functions
对于 GPxx 引脚:与我需要 GPIO 引脚编号将其传递给这些函数的情况相同
int gpio_request(unsigned gpio, const char *label);
int gpio_direction_input(unsigned gpio);
int gpio_to_irq(unsigned gpio);
i.e how do i know the GPIO number for the GPP8 pin ?
即我如何知道 GPP8 引脚的 GPIO 编号?
i searched the board documents and datasheet but it doesn't contain anything about how to get those numbers , any idea or help on where to look ?
我搜索了董事会文件和数据表,但它没有包含任何关于如何获取这些数字的信息,任何关于在哪里查找的想法或帮助?
采纳答案by embedded.kyle
The Embedded Linux you are using should have a GPIO driver that has #define
statements for the GPIO pins. You can then get the IRQ number of the specific GPIO using something like:
您使用的嵌入式 Linux 应该有一个 GPIO 驱动程序,其中包含#define
GPIO 引脚的语句。然后,您可以使用以下内容获取特定 GPIO 的 IRQ 编号:
irq_num = gpio_to_irq(S3C64XX_GPP(8));
irq_num = gpio_to_irq(S3C64XX_GPP(8));
The Linux GPIO lib support for that particular chip is available in the the following file:
以下文件中提供了对该特定芯片的 Linux GPIO 库支持:
linux/arch/arm/mach-s3c6400/include/mach/gpio.h
linux/arch/arm/mach-s3c6400/include/mach/gpio.h
There you will find all the #define
statements for the various GPIO.
在那里您将找到#define
各种 GPIO 的所有语句。
See the section on GPIO Conventions in their documentation:
请参阅其文档中有关 GPIO 约定的部分:
回答by jen1982
I was doing some work on the GPIO pin as well but it's on a different board, AM335x. Just to let you know, there's quite few of way to do it. One of the method we are using is using memory board to access (write or read) the GPIO pin.
我也在 GPIO 引脚上做了一些工作,但它在不同的板上,AM335x。只是让你知道,有很多方法可以做到。我们使用的方法之一是使用内存板访问(写入或读取)GPIO 引脚。
This is a really good article to help me to get things working. Register access to the GPIOs of the Beaglebone via memory mapping
这是一篇非常好的文章,可以帮助我完成工作。通过内存映射注册对 Beaglebone GPIO 的访问