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

来源:互联网 发布:python中数据清洗的库 编辑:程序博客网 时间:2024/05/22 20:42
#include<stdio.h>#include<stdlib.h>#include<sys/types.h>#include<sys/stat.h>#include<fcntl.h>#define MAXC 10main(){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;}

0 0