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

📄 test.c

📁 该程序是在S3C2410基础上开发的Linux流水灯驱动程序
💻 C
字号:
#include <stdio.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>
static int fd = -1;
int main(void)
{
  int i,out;
  out = 0xe0;
  fd = open("/dev/IO/0",O_RDWR);
  if(fd<0)
    {
	  printf("failed to open the device \n");
	}
  else
  printf("successed to open the device \n");
  while(1)
    {
	  ioctl(fd , out);
	  for(i=0;i<5000000;i++);
	  out=(out<<1) & 0xf0;  //注意,这里一定要加“& 0xf0”这一项,因为0xe0<<1后就变成了0x1c0,为了把那个1变成0而只获取有用的四位,所以加“& 0xf0”这一项
	 // printf("out=%x \n",out);
       if(out!=0xe0) out|=0x10;
	 // printf("out=%x \n",out);
	  
    }
   close(fd);
   printf("end of test \n");
   return 0;	
}

⌨️ 快捷键说明

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