樹莓派-鍵盤篇

1 keys驅動

新增文件:arch\arm\boot\dts\overlays\example-keys-overlay.dts

/dts-v1/;

/plugin/;

 

/ {

compatible = "brcm,bcm2835";

 

fragment@0 {

target = <&gpio>;

__overlay__ {

keypad_pins: keypad_pins {

brcm,pins = <17 22 23 27>;

brcm,function = <0>; /* in */

brcm,pull = <2>; /* up */

};

};

};

/*

 * Values for input event code is found under the

 * 'Keys and buttons' heading in include/uapi/linux/input.h

 */

fragment@1 {

target-path = "/soc";

__overlay__ {

keypad: keypad {

compatible = "gpio-keys";

#address-cells = <1>;

#size-cells = <0>;

pinctrl-names = "default";

pinctrl-0 = <&keypad_pins>;

status = "okay";

autorepeat;

 

button@17 {

label = "GPIO KEY_UP";

linux,code = <103>;

gpios = <&gpio 17 0>;

};

button@22 {

label = "GPIO KEY_DOWN";

linux,code = <108>;

gpios = <&gpio 22 0>;

};

button@27 {

label = "GPIO KEY_LEFT";

linux,code = <105>;

gpios = <&gpio 27 0>;

};

button@23 {

label = "GPIO KEY_RIGHT";

linux,code = <106>;

gpios = <&gpio 23 0>;

};

};

};

};

 

__overrides__ {

keypad =     <&keypad>,"status";

};

};

 

linux\arch\arm\boot\dts\overlays\Makefile

dtbo-$(RPI_DT_OVERLAYS) += example-keys.dtbo

 

 

2 KERNEL編譯

export PATH=$PATH:/home/thornton/work/pi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=/home/thornton/work/pi/firmware modules_install

 

3 KERNEL更新

將RPI T卡插在LINUX系統下,會彈出兩個盤,一個是KERENL盤和一個BOOT盤

將firmware/lib拷到KERNEL盤,其他拷到BOOT盤

 

4 啓動驅動

dtoverlay=example-keys

使能gpio-keys.ko

 

5 map key to system

Edit file ~/.config/openbox/lxde-rc.xml

Insert this code in the keyboard section:

CODE: SELECT ALL

 

<keybind key="XF86AudioRaiseVolume">

<action name="Execute">

<command>amixer set PCM 250+</command>

</action>

</keybind>

 

<keybind key="XF86AudioLowerVolume">

<action name="Execute">

<command>amixer set PCM 250-</command>

</action>

</keybind>

6 reboot

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章