?? 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 + -