我正在尝试在 Orange Pi Plus H3 上使用中断。我已从 here 下载了 WiringOP并安装了它。
但是当我运行程序时,我收到消息:
gpio:无法打开GPIO导出接口(interface):没有这样的文件或目录 WiringPiISR:无法打开/sys/class/gpio/gpio7/value:没有这样的文件或目录
我发现了很多类似的问题,但没有一个解决方案不适合我。例如,在/boot/config.txt 中进行更改,但在我的/boot/目录中我没有 config.txt 文件等。
有什么办法可以解决这个问题吗?
这是我测试过的代码:
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <wiringPi.h>
// WPi 7 to PA7, ie. Physical OPi-pin 29||WPi 8 to PA8, ie. Physical OPi-pin 31||WPi 9 to PG08 OPi-pin 32||
// WPi 10 to PA09 OPi-pin 33|| WPi 12 to PPA10 OPi-pin 35 || WPi 15 to PG06 OPi-pin 38
#define BUTTON_PIN 8
// the event counter
volatile int eventCounter = 0;
// -------------------------------------------------------------------------
void myInterrupt(void) {
eventCounter++;
}
// -------------------------------------------------------------------------
int main(void) {
// sets up the wiringPi library
if (wiringPiSetup () < 0) {
fprintf (stderr, "Unable to setup wiringPi: %s\n", strerror (errno));
return 1;
}
pinMode(BUTTON_PIN, INPUT);
pullUpDnControl (BUTTON_PIN, PUD_UP) ;
if ( wiringPiISR (BUTTON_PIN, INT_EDGE_FALLING, &myInterrupt) < 0 ) {
fprintf (stderr, "Unable to setup ISR: %s\n", strerror (errno));
return 1;
}
// display counter value every second.
while ( 1 ) {
// printf( "%d\n", eventCounter );
if (eventCounter != 0) {
system("systemctl suspend");
//printf("Error!!!");
}
eventCounter = 0;
delay( 100 ); // wait 0.1 second
}
return 0;
}
我的系统是 Lubuntu 15.04,使用 Loboris 的修改内核。
最佳答案
嗯。经过长时间与 OrangePI 的合作,找到了解决方案。
在 Orange Pi 上使用中断的唯一方法是安装 Armbian 。然后安装this version of WiringOP最后克隆这个:https://github.com/ua3nbw/gpiokey
将会有wpi.c文件。使用gcc编译它并在您选择的引脚上进行中断(默认 - 引脚8)。
不幸的是,我的 Orange 在第一次中断后 5 秒就关闭了。也许稍后我会找到解决这个问题的方法。
关于c - 接线PiISR : No such file or directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38420725/