linux内核源码里的平台设备led驱动(不断闪烁)

驱动代码

#include 
#include 
#include 
#include 
#include 
#include 

struct gpio_led leds[] = {
    {"led0", "heartbeat", GPIOA(18), 0, 0, 0},
};

struct gpio_led_platform_data pdata = {
    .num_leds = ARRAY_SIZE(leds),
    .leds = leds,
};


struct platform_device mypdev = {
    .name = "leds-gpio", 
    .id = -1,
    .dev = {
        .platform_data = &pdata,
    },
};

module_driver(mypdev, platform_device_register, platform_device_unregister);
MODULE_LICENSE("GPL");

 

驱动配置在图形化配置菜单里选:

Device Driver ---> Led Support

如下图配置

linux内核源码里的平台设备led驱动(不断闪烁)_第1张图片

 

加载驱动后,led不断闪烁;

^_^ /# echo 1 > /sys/class/leds/led0/brightness                             //led亮
^_^ /# echo 0 > /sys/class/leds/led0/brightness                             //led灭

 

你可能感兴趣的:(OrangePi)