|
之前在uboot里更改实现了le的点亮,现在编写程序点亮led
下面是程序
/*
* led.c
*
* Created on: 2014-4-09
* Author: Vic
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/types.h>
int main(int argc, char *argv[]){
int fd;
char buf;
fd = open("/sys/class/leds/usr0/brightness",O_WRONLY);
if(fd<0){
printf("Can not open led device.");
return 0;
}
while(1){
buf = '0'; // LED off
write(fd,&buf,1);
sleep(1);
buf = '1'; // LED on
write(fd,&buf,1);
sleep(1);
}
close(fd);
return 0;
}
把程序编译arm-none-linux-gnueabi-gcc -o led led.c
生成的可执行文件放到板子上./led
就可以看到led闪烁了
|
|