⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gpiotest.c

📁 该压缩包里面含两个源码
💻 C
字号:
#include <stdio.h> 
#include <stdlib.h> //system 
#include <fcntl.h> 
#include <errno.h> 
#include <unistd.h> 
#include <linux/delay.h> 
#include <sys/ioctl.h> 
#define DEVICE_GPIOTEST "/dev/gpio"      //设备节点 
int main(int argc, char *argv[]) 
{ 
  int fd; 
  int val=-1; 
  fd=open(DEVICE_GPIOTEST,O_RDONLY);//打开设备 
  if(fd<0) 
 { 
  perror("can not open device"); 
  exit(1); 
 } 
  while(1){ 
  printf("please select number to run program\n"); 
  printf("1:led on \n2:quit "); 
  scanf("%d",&val);  
  if(val==1) 
   ioctl(fd,1,10); 
  else if(val==2){ 
   close(fd); 
  } 
 } 
  return 0; 
} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -