Led
Led
LED, Drivers Enablement
Compile your kernel, once compiled we enable all needed drivers via menuconfig
user@Minnowboard:~$ cd linux
user@Minnowboard:~$ make menuconfig
@Linux Kernel Menuconfig > Device Drivers
Symbol: NEW_LEDS [=y]
Prompt: LED Support
@Linux Kernel Menuconfig > Device Drivers > LED Support
Symbol: LEDS_CLASS [=y]
Prompt: LED Class Support
@Linux Kernel Menuconfig > Device Drivers > LED Support
Symbol: LEDS_GPIO [=m]
Prompt: LED Support for GPIO connected LEDs
@Linux Kernel Menuconfig > Device Drivers > LED Support > LED Trigger support
Symbol: LEDS_TRIGGERS [=y]
Prompt: LED Trigger support
And within this "LED Trigger support" section select a variety of triggers to work with, let's start with Hearbeat and OneShot
@Linux Kernel Menuconfig > Device Drivers > LED Support > LED Trigger support
Symbol: LEDS_TRIGGER_ONESHOT [=m]
Prompt: LED One-shot Trigger
@Linux Kernel Menuconfig > Device Drivers > LED Support > LED Trigger support
Symbol: LEDS_TRIGGER_HEARTBEAT [=m]
Prompt: LED Heartbeat Trigger
Once configured, we save the changes, compile and reboot
LED, Module Test
root@Minnowboard:~# modprobe leds_gpio
root@Minnowboard:~# modprobe ledtrig_heartbeat
root@Minnowboard:~# modprobe ledtrig_oneshot
user@Minnowboard:~$ lsmod | grep led
ledtrig_oneshot 16384 0
ledtrig_heartbeat 16384 0
leds_gpio 16384 0
Download, modify and compile the following code: https://github.com/mjoldfield/seabass/blob/master/seabass-leds/seabass-leds.c You might need to specify different GPIO numbers. Wait! There is an easy way to do that
user@Minnowboard:~$ cd linuxlearning/kernelspace
user@Minnowboard:~$ make
Now insert and make use of both triggers, ledtrig_heartbeat and ledtrig_oneshot. You can also go back to your kernel menuconfig and enable the rest of the triggers
root@Minnowboard:~# insmod linuxlearning/kernelspace/seabass-leds.ko
user@Minnowboard:~$ ls /sys/class/leds/
mmc0:: mmc1:: mmc2:: seabass:green:user seabass:red:user seabass:yellow:user
user@Minnowboard:~$ cat /sys/class/leds/seabass\:red\:user/trigger
none mmc0 mmc1 mmc2 [heartbeat] oneshot
Resources
End of File
Last updated