下午好。我的目标是编写一个简单的 c 程序,在我的 beagleboard-xm 上运行,并每 100 毫秒在 gpio 引脚上打开一个 LED。我想使用定时器中断来实现这一点。我正在尝试遵循本教程
http://www.kunen.org/uC/beagle/omap_dmtimer.html
但我想念一些东西。我需要一些内核操作吗?我在 beagleboard-xm 上安装了本机 gcc 编译器,在 windows 7 上安装了带有 Code Sourcery 的交叉编译器,我可以构建简单的程序来操作 LED,但两个编译器都无法识别本教程中使用的头文件:
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/clk.h>
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <asm/io.h>
#include <mach/dmtimer.h>
#include <linux/types.h>
任何建议将不胜感激。在此先感谢这里我发布了我用于 GPIO 操作的代码
#include <stdio.h>
#include<signal.h>
#include<unistd.h>
void sig_handler(int signo) {
if (signo == SIGINT) {
FILE *fp;
if ((fp = fopen("/sys/class/gpio/gpio157/direction", "w")) == NULL ) {
exit(1);
} else {
fprintf(fp, "low");
fclose(fp);
}
fp = fopen("/sys/class/gpio/unexport", "w");
fprintf(fp, "157");
fclose(fp);
printf("Closing and cleaning \n");
}
}
void main() {
FILE *fp;
printf("\n*************************************\n"
"* Welcome to PIN Blink program *\n"
"* ....blinking pin 22 on port GPIO *\n"
"* ....rate of 1 Hz............ *\n"
"**************************************\n");
if (signal(SIGINT, sig_handler) == SIG_ERR )
printf("\ncan't catch SIGINT\n");
fp = fopen("/sys/class/gpio/export", "w");
fprintf(fp, "157");
fclose(fp);
printf("...export file accessed, new pin now accessible\n");
while (1) {
if ((fp = fopen("/sys/class/gpio/gpio157/direction", "w")) == NULL ) {
printf("Error \n");
exit(1);
}
fprintf(fp, "high");
fclose(fp);
sleep(1);
if ((fp = fopen("/sys/class/gpio/gpio157/direction", "w")) == NULL ) {
printf("Error \n");
exit(1);
}
fprintf(fp, "low");
fclose(fp);
sleep(1);
}
}