linux gpio-leds driver


linux gpio-leds driver

gpio-leds dts

source:
drivers/leds/


documentation:
linux/Documentation/devicetree/bindings/leds/leds-gpio.txt

dts:

	leds {
		compatible = "gpio-leds";
		pinctrl-names = "default";
		pinctrl-0 = <&leds_default>;
		status = "okay";

		led0 {
			gpios = <&gpio 07 GPIO_ACTIVE_HIGH>;
			default-state = "on";
		};

		led1:heartbeat-led {
            label = "heartbeat-led";
			gpios = <&gpio 08 GPIO_ACTIVE_HIGH>;
            linux,default-trigger = "heartbeat";
            /*linux,default-trigger = "timer";*/
		};
	};

[root]# pwd
/sys/devices/platform/leds/leds
[root]#
[root]# ls
led0 led1



control led

        leds {
                compatible = "gpio-leds";
                pinctrl-names = "default";
                pinctrl-0 = <&led0_pins_default>;
                status = "okay";

                led0 {
                        lable = "led0";
                        gpios = <&gpio 18 GPIO_ACTIVE_HIGH>;
                        linux,default-trigger = "default-on";
                };

        };
root@soc:/opt/wangyangkai# cat led.sh 
#!/bin/sh

echo 0 > /sys/devices/platform/leds/leds/led0/brightness
usleep 200000
echo 255 > /sys/devices/platform/leds/leds/led0/brightness

root@soc:/opt/wangyangkai# 




免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM