|
楼主 |
发表于 2011-9-19 11:51:10
|
显示全部楼层
回复 2# michaelzjh
测试程序源码:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
int main(){
int fd,ret;
char *i;
fd=open("/dev/my_ok6410_leds",0);
if(fd<0){
printf("open device error\n");
exit(0);
}
else{
printf("succeeded to open device\n");
while(1){
ioctl(fd,1,0);
ioctl(fd,0,1);
ioctl(fd,0,2);
ioctl(fd,0,3);
if(ret==0)
printf("led1 is on!\n");
sleep(2);
ioctl(fd,0,0);
ioctl(fd,1,1);
ioctl(fd,0,2);
ioctl(fd,0,3);
if(ret==0)
printf("led2 is on!\n");
sleep(2);
ioctl(fd,0,0);
ioctl(fd,0,1);
ioctl(fd,1,2);
ioctl(fd,0,3);
if(ret==0)
printf("led3 is on!\n");
sleep(2);
ioctl(fd,0,0);
ioctl(fd,0,1);
ioctl(fd,0,2);
ioctl(fd,1,3);
if(ret==0)
printf("led4 is on!\n");
sleep(2);
}
close(fd);
}
return 0;
} |
|