How to register a GPIO as Led or Button

From WRTnode Wiki Site
Jump to: navigation, search
This page contains changes which are not marked for translation.

Other languages:
English 100% • ‎中文(中国大陆)‎ 100%

"make menuconfig" to enter the configuration interface,select:
Led driver:

LED modules    --->   <*> kmod-leds-gpio 
                      <*> kmod-ledtrig-usbdev

Button driver:

Other modules  --->   <*> kmod-gpio-button-hotplug.

Open the WRTNODE.dts
add Led:

   gpio-leds {
       compatible = "gpio-leds";
       indicator {
           label = "wrtnode:blue:indicator";
           gpios = <&gpio1 14 1>;
       };
   }; 

"compatible" match "compatible" in leds-gpio.c, "label" is the name of the device,<&gpio1 14 1> is equivalent to GPIO#38

Usergpio1.png

Addled1.png

add Button:

   gpio-keys-polled {
       compatible = "gpio-keys-polled";
       #address-cells = <1>;
       #size-cells = <0>;
       poll-interval = <20>;
       reset {
           label = "reset";
           gpios = <&gpio0 1 1>;
           linux,code = <0x198>;
         };
   };