Linux 中的嵌入式系统中断/硬件处理
在我的 AT91SAM9RL-EK ARM 板上,运行 Linux 2.6.30 buildroot,我有以下内容。
cat /proc/interrupts
CPU0
1: 6475 AIC at91_tick, rtc0, ttyS0
10: 11 AIC mmc0
13: 4 AIC atmel_spi.0
18: 23533 AIC tc_clkevt
20: 0 AIC atmel_tsadcc
22: 0 AIC atmel_usba_udc
23: 0 AIC atmel_lcdfb
24: 0 AIC AC97C
40: 1 GPIO atmel_usba_udc
47: 0 GPIO mmc0
64: 6 GPIO Right Click
65: 10 GPIO Left Click
右键和左键单击是我板上的按钮。现在我想修改按钮的中断处理程序(例如,它们在单击时给我一个输出)。
在哪里可以找到按钮的中断处理程序或驱动程序(或其源文件)?
或者我可以编写自己的驱动程序并为按钮注册它们(当我在用户空间中时)以及如何注册?
这是有关 PIO 的主板指南中的一些数据
IO... Per.... Application Usage............................................ Pow. by
PB0 TXD3 USER’S PUSH BUTTON 1 PB0 as LEFT CLICK VDDIOP
PB1 RXD3 USER’S PUSH BUTTON 2 PB1 as RIGHT CLICK VDDIOP
On my AT91SAM9RL-EK ARM board, running a Linux 2.6.30 buildroot, I have the following.
cat /proc/interrupts
CPU0
1: 6475 AIC at91_tick, rtc0, ttyS0
10: 11 AIC mmc0
13: 4 AIC atmel_spi.0
18: 23533 AIC tc_clkevt
20: 0 AIC atmel_tsadcc
22: 0 AIC atmel_usba_udc
23: 0 AIC atmel_lcdfb
24: 0 AIC AC97C
40: 1 GPIO atmel_usba_udc
47: 0 GPIO mmc0
64: 6 GPIO Right Click
65: 10 GPIO Left Click
The right and left click are the buttons on my board. Now I want to modify the interrupt handlers for the buttons (for example that they give me an output when clicked).
Where can I find the interrupt handlers or drivers (or the sourcefiles for them) for the buttons?
Or can I write my own drivers and register them (while I am in user-space) for the buttons and how?
This is some data from the boards guide about the PIO
IO... Per.... Application Usage............................................ Pow. by
PB0 TXD3 USER’S PUSH BUTTON 1 PB0 as LEFT CLICK VDDIOP
PB1 RXD3 USER’S PUSH BUTTON 2 PB1 as RIGHT CLICK VDDIOP
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我没有针对您的董事会的具体答案,但我可以为您提供一些指导以及您需要的信息。
解决问题的最简单方法是放弃“中断处理程序”要求并简单地轮询 GPIO 线。只要您是 root 用户,就可以从用户空间执行此操作。许多开发环境提供内核模块来为您执行此操作,将结果作为
/dev
或/proc
中的条目公开。如果要处理中断,则需要编写 Linux 设备驱动程序。最好的起点是很棒的 Linux 设备驱动程序书籍,可从 http://lwn.net/Kernel/ 下载LDD3/
GPIO 驱动程序非常简单,主要由对
register_irq()
的调用和用户空间接口代码组成。用户空间接口代码将比其余代码大得多,并且也会让您最头疼。I don't have a specific answer for your board, but I can give you some pointers with the information you need.
The simplest way to solve your problem is to drop the 'interrupt handlers' requirement and simply poll the GPIO lines. You can do this from userspace, so long as you're root. Many development environments supply a kernel module to do this for you, exposing the results as an entry in
/dev
or/proc
.If you're going to handle interrupts, you need to write a Linux device driver. The best place to start here is the awesome Linux Device Drivers book, downloadable at http://lwn.net/Kernel/LDD3/
A GPIO driver is very simple and will mostly consist of a call to
register_irq()
and your userspace interface code. The userspace interface code will be much larger than the rest of the code and also cause you the most headaches.我对特定的主板和 buildroot 没有任何经验,但研究 gpio.txt 位于内核树内的文档目录中。有一些关于如何使用 sysfs 从用户空间使用 GPIO 的说明。
I don't have any experience with the specific board and buildroot, but it might be interesting to look into gpio.txt in the Documentation dir inside the kernel tree. There's some explanation on how to use GPIO from userspace using sysfs.