4412用户层调用驱动控制led灯

#include
#include


#include
#include
#include


#define MAXC 10


main()
{
int fd;
char gpio[MAXC], cmd[MAXC];
const char *leds = "/dev/leds";


if((fd = open(leds, O_RDWR|O_NOCTTY|O_NDELAY)) < 0)
{
printf("open %s faild \n", leds);
}
else
{
while(1)
{
printf("Input gpio cmd:\n");
scanf("%s %s", gpio, cmd);


printf("the returned value of ioctl: %d\n\n\n", ioctl(fd, atoi(cmd), atoi(gpio)));  // 建议查看一下内核中ioctl函数
printf("open %s success\n", leds);
}
}


return 0;
}

你可能感兴趣的:(Linux)