This is Linux Kernel character device driver to control the gpio connected LEDs.
Possible commands:
1 - enable led
0 - disable led (disable blinking, if it's active now)
2 <blinks_number> <blinks_interval_ms> - blinking the LEDs with interval in miliseconds and number of blinks used in parameters.
Each of the command can be used for both leds:
echo 1 > /dev/LED_CTRL
echo 2 20 500> /dev/LED_CTRL1
Commands are queued.
- Cross-compile module
make -j$(nproc) ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules
-
This operation should be performed with preinstalled rapbpios kernel build tools.
-
To get and build your own kernel follow the link
-
Kernel sources should be downloaded and build. After your kernel will be stored in linux/ directory.
-
Module directory should be linux/drivers/char_led/
-
Before building add line to Kconfig file in linux/drivers
source "drivers/char_led/Kconfig"
- Before building add line to Makefile in linux/drivers
obj-$(CONFIG_CHAR_LED) += char_led/
- Copy char_led.ko file to the raspberry pi device using ssh.
Example of such copy:
scp /home/strngr/linux/drivers/char_led/char_led.ko pi@192.168.0.101:/home/pi/
- Perform: sudo insmod char_led.ko
Note: If module can not be installed because of it's build on a newer kernel version. (It could be checked with modinfo module_name command). The kernel could be updated using sudo rpi_update. After the job is done use sudo reboot
-
When the module is installed it could be checked using lsmod command
-
Load module using the load.sh script from current directory:
sudo chmod +x ./load.sh
sudo ./load.sh
-
Next module should be seen in /dev/ directory. Check it with
ls /dev/* | grep 'LED_CTRL'
-
Check the module is working with commands
-
For red led:
sudo bash ./test.sh 0 10 200
-
For blue led:
sudo bash ./test.sh 1 10 200
- Now it can be used for your needs.