|
发表于 2023-3-3 11:48:15
1019 浏览 0 回复
T618 如何添加矩阵按键
需求:
如何添加矩阵按键?
解决方案:
- 如下2×2矩阵键盘示例:
- 1.pinmap.c (function应配置为keyin*/keyout*)
- {REG_PIN_KEYIN1, BITS_PIN_AF(0)},
- {REG_MISC_PIN_KEYIN1, BITS_PIN_DS(1)|BIT_PIN_NULL|BIT_PIN_WPU|BIT_PIN_SLP_AP|BIT_PIN_SLP_WPU|BIT_PIN_SLP_IE},//KEYIN1
- {REG_PIN_KEYIN2, BITS_PIN_AF(0)},
- {REG_MISC_PIN_KEYIN2, BITS_PIN_DS(1)|BIT_PIN_NULL|BIT_PIN_WPU|BIT_PIN_SLP_AP|BIT_PIN_SLP_WPU|BIT_PIN_SLP_IE},//KEYIN2
- {REG_PIN_KEYOUT0, BITS_PIN_AF(0)},
- {REG_MISC_PIN_KEYOUT0, BITS_PIN_DS(1)|BIT_PIN_NULL|BIT_PIN_WPU|BIT_PIN_SLP_AP|BIT_PIN_SLP_WPU|BIT_PIN_SLP_IE},//KEYOUT0
- {REG_PIN_KEYOUT1, BITS_PIN_AF(0)},
- {REG_MISC_PIN_KEYOUT1, BITS_PIN_DS(1)|BIT_PIN_NULL|BIT_PIN_WPU|BIT_PIN_SLP_AP|BIT_PIN_SLP_WPU|BIT_PIN_SLP_IE},//KEYOUT1
- 2.dts
- keypad: keypad@32250000 {
- compatible = "sprd,s9820e-keypad";
- reg = <0 0x32250000 0 0x1000>
- interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>;
- clocks = <&aonapb_gate CLK_KPD_EB>,
- <&aonapb_gate CLK_KPD_RTC_EB>;
- clock-names = "enable", "rtc";
- keypad,num-rows= <2>; //使用了keyout0和keyout1,num由使用到的最大的keyout1确定
- keypad,num-columns = <3>; //使用了keyin1和keyin2,num由使用到的最大的keyin2确定
- debounce-inteval = <5>;
- linux,keymap = <0x00010066 /*KEYOUT0 KEYIN1 keycode1*/
- 0x0101008B /*KEYOUT1 KEYIN1 keycode2*/
- 0x01020057 /*KEYOUT1 KEYIN2 keycode3*/
- 0x00020059>;/*KEYOUT0 KEYIN2 keycode4*/
- status = "okay";
- keymap计算方式:row << 24 | column << 16 | key-code
- key-code定义于/include/uapi/linux/input-event-codes.h
- 以上num-rows、num-columns、keymap需客制化修改
- 3.驱动
- sprd_keypad.c
- /kernel4.14/arch/aem64/configs/sprd_sharkl5pro_defconfig
- +CONFIG_KEYBOARD_SPRD = y
复制代码
|
|
手机微信同号:13682654092
|
|
|
|
|
登录或注册
|