buttontest.c

来自「arm2440下」· C语言 代码 · 共 51 行

C
51
字号
#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <sys/ioctl.h>#include <fcntl.h>#include <pthread.h>/*void thread(void){	while(1)	{		printf("I am still running\n");		sleep(1);	}}*/int main(){	int fd;	pthread_t id;	int ret;	unsigned int new;	int count = 0;	fd = open("/dev/button",O_RDWR);	if(fd < 0)	{		//printf("open exint10 error \n");		printf("open exint0 error \n");		return -1;	}	else	{		printf("open sussssssssssssssss\n");	}//	ret = pthread_create(&id,NULL,(void*)thread,NULL);	while(1)	{				read(fd,&new,sizeof(new));		printf("new==========%d\n",new);		sleep(1);	}	close(fd);	return 0;}

⌨️ 快捷键说明

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