您的位置:首页 > 其它

S3C6410 GPIO 驱动(三) ---LED应用程序--实现关闭或打开指定LED灯

2012-09-19 14:59 330 查看
/*led_test.c*/

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>

int main(int argc,char ** argv)
{
int fd;
int ret;
int led_on;
int cmd;

fd = open("/dev/leds",0);
if(fd < 0)
{
printf("open leds dev error!\n");
return -1;
}

while(1)
{
printf("please input cmd:\n");
printf("10-led1_on 11-led1_off\n20-led2_on 21-led2_off\n30-led3_on 31-led3_off\n40-led4_on 41-led4_off\n");

scanf("%d",&cmd);

ret = ioctl(fd,cmd,0);
if(ret < 0)
{
printf("input cmd error!\n");
close(fd);
return -1;
}
}

close(fd);

return 0;
}


 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  c cmd input n2