--- a/kernel-4.4/drivers/input/keyboard/gpio_keys.c+++ b/kernel-4.4/drivers/input/keyboard/gpio_keys.c@@ -32,6 +32,11 @@#include<linux/of_irq.h>#include<linux/spinlock.h>++#define LOG_TAG "[BUTTON]: %s() line: %d "+#define PRINTK_T(fmt, args...) printk(KERN_INFO LOG_TAG...
CONFIG_INPUT_GPIO_KEYS=y ``` 然后,通过设备树(DTS)文件描述GPIO键盘驱动: ```yaml gpio-keys { compatible = "gpio-keys"; pinctrl-names = "default"; pinctrl-0 = <&gpio_key_pins>; #address-cells = <1>; #size-cells = <0>; button@0 { label = "gpio-button 0"; linux,code = <KEY...
structgpio_keys_button_data{structgpio_desc*gpiod;intlast_state;intcount;intthreshold; };structgpio_button_data{conststructgpio_keys_button*button;structinput_dev*input;structgpio_desc*gpiod;unsignedshort*code;structtimer_listrelease_timer;unsignedintrelease_delay;/* in msecs, for IRQ-only buttons...
gpio-keys { compatible = "gpio-keys"; autorepeat; powerkey { label = "power key"; linux,code = <116>; /* KEY_POWER */ gpios = <&gpio0 GPIO_A5 GPIO_ACTIVE_LOW>; gpio-key,wakeup; debounce-interval = <5>; }; }; 在这个示例中,定义了一个名为powerkey的按键,它使用GPIO0的A5引脚...
pinctrl-0= <&gpio_keys_default>; key_1 { label ="key_1"; gpios = <&gpio07GPIO_ACTIVE_HIGH>; linux,input-type= <1>; linux,code = <0x01>;/* KEY_1 */gpio-key,wakeup; debounce-interval = <15>; }; }; debug log: [root]# hexdump /dev/input/event0[49.799309]gpio_keys_gpio...
Linux kernel驱动,针对gpio-keys实现了一个专用驱动,在使用GPIO模拟按键的场合时,只需配置设备树即可实现相应的按键功能,其中kernel driver对应的文件路为drivers\input\keyboard\gpio_keys.c,对应的设备树描述文档路径为Documentation\devicetree\bindings\input\gpio-keys.txt。 gpio-keys.txt文档中,有如下描述: Each bu...
linux gpio keys Linux是一种开源操作系统,广泛应用于各种嵌入式设备中。在Linux内核中,GPIO(General Purpose Input/Output)是一种用于与硬件设备交互的机制。GPIO Keys是一个Linux子系统,用于将物理按键或按钮映射到输入事件,以便应用程序可以通过捕获这些事件来执行相应操作。
gpio_keys: volume_keys@0 { compatible = "gpio-keys"; #address-cells = <1>; #size-cells = <0>; autorepeat; switch@9 { label = "volume-up"; linux,code = <115>; gpios = <&gpio3 0 GPIO_ACTIVE_LOW>; gpio-key,wakeup;
- linux,code: input子系统所定义的按键代码,参见:include/dt-bindings/input/input.h关于keys和buttons的code定义。 Optional subnode-properties -linux,input-type:定义该key/button所依赖的event type(input子系统定义),默认为1 == EV_KEY。 -debounce-interval:定义该key/button的去抖间隔,默认为5ms。
Show me the code: 从上述代码可看到,gpio_keys.c节点内定义两个按键节点: “key_power”、”key_headset”。每个按键节点包括一个gpio所用到的所有硬件属性。拿第一个设备节点解析: 代码语言:javascript 代码运行次数:0 运行 AI代码解释 key_power{label="Power Key";//按键描述性名称linux,code=<116>;//...