NK-980IOT 评估根据github上下载的linux 4.4y的内核源码编译出来的文件系统,是没有包含LED的心跳指示的 即 heartbeat 指示灯,需要手工添加
方法如下:
内核配置
需要打开 LED Support的设置
另外需要再开启LED Trigger功能
代码修改:
新唐提供的linux 内核源码关于驱动部分没有使用设备树设置,所以需要使用代码添加心跳功能
找到Linux源码的Arch ->Arm -> Mach-nuc980 下的dev.c文件
添加文件头
#include <linux/leds.h>
添加代码
#if defined(CONFIG_LEDS_GPIO)
static struct gpio_led nuc980_ek_leds[] = {
[0] = { /* "right" led, green, userled2 (could be driven by pwm2) */
.name = "ds2",
.gpio = NUC980_PB8,
.active_low = 1,
.default_trigger = "heartbeat",
},
};
static struct gpio_led_platform_data led_data = {
.num_leds = ARRAY_SIZE(nuc980_ek_leds),
.leds = nuc980_ek_leds,
};
static struct platform_device nuc980_gpio_leds_device = {
.name = "leds-gpio",
.id = -1,
.dev.platform_data = &led_data,
};
#endif
设置结构体需要增加LED设备描述
static struct platform_device *nuc980_public_dev[] __initdata = {
if defined(CONFIG_LEDS_GPIO)
&nuc980_gpio_leds_device,
#endif
};
平台初始化的函数需要增LED设备IO的初始化函数
void __init nuc980_platform_init(struct platform_device **device, int size)
{
#if defined(CONFIG_LEDS_GPIO)
if (gpio_request(nuc980_ek_leds[0].gpio, "led-ds2") < 0)
{
printk("can not request gpio[%d] for led-ds2\n", nuc980_ek_leds[0].gpio);
}
else
{
gpio_direction_output(nuc980_ek_leds[0].gpio, nuc980_ek_leds[0].active_low);
}
#endif
}
最后重新编译内核烧写,即可看见黄色的LED 在闪烁
可查看对应的 leds 设备
QQ交流群:761781147