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

📄 gpio_test.c

📁 1、将makefile中的 CROSS =/usr/local/arm/2.95.3/bin/arm-linux- CFLAGS+=-I/usr/local/src/2.4.18-rmk7/inc
💻 C
字号:
#include <stdio.h>#include <stdlib.h>#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!!!\n");      		exit ( 1 ) ;  	}	  	while ( 1 ) {      		printf(" please Select number to run program\n");     		printf("1 : led on\n");		printf("2 : led off\n");     		scanf("%d", &val);     		if(val ==1)       		ioctl ( fd , 0 , 10 );      		else if ( val ==2 )  {        		close( fd ); 			break;     		}   	}   return 0;}

⌨️ 快捷键说明

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