How to Set Matrix Keyboard ?
Answer.
1. Taking the 2X2 Matrix Keyboard as an example, the circuit design is as follows:
2. Taking the SOM board as an example, modify ma35d1-som-256m.dts and the keypad part is as follows:
Code: Select all
&keypad {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_keypad>;
keypad,num-rows = <2>;
keypad,num-columns = <2>;
linux,keymap = <
MATRIX_KEY(0x00, 0x00, KEY_1) /* key_1 */
MATRIX_KEY(0x00, 0x01, KEY_2) /* key_2 */
MATRIX_KEY(0x01, 0x00, KEY_3) /* key_3 */
MATRIX_KEY(0x01, 0x01, KEY_4) /* key_4 */
>;
};
keypad {
pinctrl_keypad: keypadgrp{
nuvoton,pins =
<SYS_GPF_MFPL_PF4MFP_KPI_ROW0 &pcfg_default>,
<SYS_GPF_MFPL_PF5MFP_KPI_ROW1 &pcfg_default>,
<SYS_GPF_MFPL_PF0MFP_KPI_COL0 &pcfg_default>,
<SYS_GPF_MFPL_PF1MFP_KPI_COL1 &pcfg_default>;
};
};
#MA35 , #Keyboard , #dts
.