📄 test_led.c
字号:
#include <stdio.h>#include <stdlib.h>#include <sys/ioctl.h>#include <unistd.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <sys/mman.h>#include "gpio_test.h"#define DEVICE_GPIODRV "/tmp/led"int main(){ int fd; int val=-1; if((fd=open(DEVICE_GPIODRV,O_RDONLY | O_NONBLOCK))<0) { printf("open device: %s\n",DEVICE_GPIODRV); perror("can not open device"); exit(1); } while(1){ printf("0:set ,1:clear,2: quit :"); scanf("%d",&val); if(val==0) ioctl(fd,IOWRITE,0); else if(val==1) ioctl(fd,IOCLEAR,0); else if(val==2){ close(fd); return 0; }else{ printf("val is %d\n",val); continue; } } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -