leddrv_test.c
来自「Linux设备驱动程序 硬件平台:H9200评估板(基于AT91RM9200构」· C语言 代码 · 共 48 行
C
48 行
#include <stdio.h>#include <string.h>#include <malloc.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>#include <signal.h>static void Delay(int);int main(void){ int fd,count; int i=3; unsigned long rgcon; if((fd=open("/dev/led",O_RDWR))==-1) { perror("open error"); exit(1); } rgcon=0xc000; while(i--){ if((count=write(fd,(char *)&rgcon,4))!=4) { perror("write1 error"); exit(1); } Delay(100); //rgcon=rgcon<<1; //if((rgcon&0xf000)==0) // {rgcon=0x4000;} } close(fd); return 0;}static void Delay(int x){ int i,j,k; for(i=0;i<x;i++) for(j=0;j<0xff;j++) for(k=0;k<0xff;k++);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?