展锐支持矩阵键盘,有KEYIN,KEYOUT的GPIO定义。
components/hal/include/平台名字/key_padmap_平台名字.csv
为配置文件,如果找不到类似的配置文件,说明平台不支持。
那么没有办法也可以用linux下面的matrix_key.c来做。
matrix key的核心思想,是用输入口做外部中断口,有按键按下的时候会进入中断服务程序
matrix_keypad_interrupt
在这个中断服务程序中会启动
matrix_keypad_scan
matrix_keypad_scan中会依次将COL线输出低电平,然后读row的状态,从而确定是哪一个按键按下。
/* assert each column and read the row status out */
for (col = 0; col < pdata->num_col_gpios; col++) {
activate_col(pdata, col, true);
for (row = 0; row < pdata->num_row_gpios; row++)
new_state[col] |=
row_asserted(pdata, row) ? (1 << row) : 0; //读出row的状态
activate_col(pdata, col, false); //依次输出低
}
for (col = 0; col < pdata->num_col_gpios; col++) {
uint32_t bits_changed;
bits_changed = keypad->last_key_state[col] ^ new_state[col];
if (bits_changed == 0)
continue;
for (row = 0; row < pdata->num_row_gpios; row++) {
if ((


1272

被折叠的 条评论
为什么被折叠?



