树莓派-键盘篇

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

树莓派-键盘篇_第1张图片

 

5 map key to system

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

Insert this code in the keyboard section:

CODE: SELECT ALL

 

amixer set PCM 250+

 

amixer set PCM 250-

6 reboot

你可能感兴趣的:(技术)