当前位置:网站首页>Ti AM335X工控模块矩阵键盘电路的设计与驱动移植
Ti AM335X工控模块矩阵键盘电路的设计与驱动移植
2022-07-26 01:58:00 【szembed】
本内容的验证使用的盈鹏飞嵌入式CoM-335x核心模块及评估板EAC-335X,简要介绍如下:

前言
与按键相比,矩阵按键(键盘)使用更少的GPIO实现更多按键接口。以下,基于COM-335x核心模块,介绍linux嵌入式系统中矩阵键盘的编码实习过程,简单从原理、键值编码阐述。
1 原理简述
按按键的有效电平分,可分为高电平触发与低电平触发两种。一般地,高电平触发的按键,在原理设计上行地址通过电阻下拉;低电平触发,行地址上拉。分别如图1-1、图1-2所示,软件配置时需注意触发电平。


软件层面,Linux input子系统提供支撑。其架构如图1-3,更多关于input子系统,请查阅资料或内核代码。

2 按键配置
按键配置关注两个问题,一是IO分配,二是键值。IO根据原理分配,注意有效电平、行配置为输入;键值有两种方式获得,人工计算与函数调用。以下分两节介绍第1章中按键该如何配置。
2.1 高电平触发的按键配置
,图1-1的按键为3行2列,行地址下拉。IO配置行输入、列输出、下拉、高电平触发,在COM-335x的dts中配置如下:

注:以上代码清单中,红色字体为行地址的IO分配,黑色为列地址的IO分配。

注:
① 以上代码清单中,各个GPIO有效电平均为高,即:GPIO_ACTIVE_HIGH;
② debounce-delay-ms表示去抖时间,单位为毫秒;
③ col-scan-delay-us 表示列扫描间隔时间,单位为微秒。
④ linux,keymap 属性的值为键值,该处通过计算得到。其计算公式如图2-1:

以“MENU”的键值为例,其“linux,keymap”的值计算方法如下:

从include/dt-bindings/input/linux-event-codes.h文件中,找到MENU的值为139,即16进制的8B(共4位16进制数,不足的高位补0),如图2-2所示。

图2-2
综上,32~25位为行号、24~17位为列好、低16位为键值,转换成16进制数方便阅读(4位2进制数表示1位16进制数)。0x0000008b 表示0行0列、键值为139。
2.2 低电平触发的按键配置
图1-2的按键为6行3列,行地址上拉。IO配置行输入、列输出、上拉、低电平触发,在COM-335x的dts中配置如下:

注:以上代码清单中,红色字体为行地址的IO分配,黑色为列地址的IO分配。



注:
① gpio-activelow 表示低电平触发,若无该属性,则表示高电平有效;
② linux,no-autorepeat 表示禁用按键重复,即:长按某一按键时,只打印一次;
③ 调用MATRIX_KEY函数计算键值,这种方法比2.1节中直观,请函数运行如图2-3,键值的定义依然从include/dt-bindings/input/linux-event-codes.h 文件中获得。

图2-3
边栏推荐
- Make and makefile summary I
- The work of robot engineering and the puzzle of postgraduate entrance examination "volume" supplement
- E. Split into two sets
- Worthington nuclease and Micrococcus related research and determination scheme
- Software group verification
- Y77. Chapter IV Prometheus' monitoring system and practice -- Prometheus' service discovery mechanism (VIII)
- Installing and using R in Anaconda
- Create a future and enjoy extraordinary | gbase Nantah General Motors unveiled opengauss Developer Day 2022
- leetcode/只出现一次的数字
- BGP知识点总结
猜你喜欢

网络之IP地址

QT program beautification of the use of style sheets, QT uses pictures as the background and transparency of controls, QT custom button styles

Go operation excel library excel use

Video game quiz? I think it's useless. It's better to do these well!

Worthington产气荚膜梭菌神经氨酸酶的特征及测定

# Dest0g3 520迎新赛(更新中)

pdf. JS introduction

Qt程序美化之样式表的使用方法,Qt使用图片作为背景与控件透明化,Qt自定义按钮样式

DialogRPT-Dialog Ranking Pretrained Transformers

怎么使用宝塔面板把node全栈项目部署到服务器上
随机推荐
[in simple terms, play with FPGA learning 11 --- testbench writing skills 2]
Implementation of recommendation system collaborative filtering in spark
Relationship between HTC mobile official solution, s-on/s-off and super CID
Redis cluster construction (based on 6.x)
一种MCU事件型驱动C框架
opengauss如何手工安装(非OM方式)
How idea can quickly delete recently opened projects
Alibaba cloud redis development specification
Phoenix中常用shell操作
FFT is used to estimate the image resampling factor after interpolation
Leetcode algorithm 147. insert and sort the linked list
[independent station construction] Shopify seller: learn these points and double the sales volume of online stores!
【深入浅出玩转FPGA学习11----Testbench书写技巧2】
y77.第四章 Prometheus大厂监控体系及实战 -- prometheus的服务发现机制(八)
leetcode/只出现一次的数字
Qt程序美化之样式表的使用方法,Qt使用图片作为背景与控件透明化,Qt自定义按钮样式
MPLS知识点
Build embedded development environment and FRP penetration under win
达梦数据库表导入导出按钮灰色,导入不了dmp文件
MySQL locking table problem