button_test.c
来自「按键驱动实验 基于TEB-44B0实验平台的按键驱动 包括按键驱动程序与测试」· C语言 代码 · 共 38 行
C
38 行
/* button_test.c - little program to test the response of the button’s driver*/// modified by Vencent for TEB-44B0 board#include <stdio.h>#include <string.h>#include <errno.h>//#include <asm/MC68VZ328.h>//#include "s3c44b0x.h"#include <asm/fcntl.h>#define DEVICE_FILE_NAME "/dev/button"/* main */main() { int file_desc=0; int isTSopen=0; int bytes_transfered=0; int i; char buffer; file_desc = open(DEVICE_FILE_NAME,O_RDWR); if(file_desc < 0) { printf("Can't open device file: %s\n",DEVICE_FILE_NAME); printf("Error: %s\n",strerror(errno)); } else { printf("Device %s open -> It works!!!!\n",DEVICE_FILE_NAME); isTSopen=1; } while(1){ if(isTSopen) { bytes_transfered=read(file_desc,&buffer,sizeof(buffer)); printf("nb bytes transfered: %d\n",bytes_transfered); printf("the message is %c !\n",buffer); } } }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?