当前位置: 首页 > news >正文

数据统计网站有哪些电脑培训网上课程

数据统计网站有哪些,电脑培训网上课程,房产网南京,平原县网站seo优化排名文章目录 一、输入子系统(一)输入子系统框架结构(二)输入子系统的API 二、实现两个按键的驱动(一)实现思路(二)代码实现 一、输入子系统 在linux系统中使用输入子系统驱动上报鼠标&…

文章目录

  • 一、输入子系统
    • (一)输入子系统框架结构
    • (二)输入子系统的API
  • 二、实现两个按键的驱动
    • (一)实现思路
    • (二)代码实现

一、输入子系统

在linux系统中使用输入子系统驱动上报鼠标,键盘,触摸屏,游戏摇杆等输入类设备上报的事件。当输入子系统驱动被安装到linux内核之后就会在"/dev/input/eventX"节点,如果想要获取上报的输入事件的值直接从这个文件中读取input_event结构类型的数据即可。

(一)输入子系统框架结构

在这里插入图片描述

(二)输入子系统的API

1.分配对象
struct input_dev *key_dev;
struct input_dev  *input_allocate_device(void);
//void input_free_device(struct input_dev *dev);
功能:申请input_dev结构体内存
参数:@无
返回值:成功返回首地址,失败返回NULL2.对象初始化set_bit(EV_KEY, key_dev—>evbit);  //设置事件类型set_bit(KEY_L, key_dev—>keybit); //可以上报l键set_bit(KEY_S, key_dev—>keybit); //可以上报s键set_bit(KEY_ENTER, key_dev—>keybit); //可以上报enter键3.注册int input_register_device(struct input_dev *dev)4.注销void input_unregister_device(struct input_dev *dev)5.上报数据
void input_event(struct input_dev *dev,
unsigned int type, unsigned int code, int value)
//上报数据 参数1:inpu_dev结构体指针,参数2:类型,参数3:那个键,参数4:值
以下的函数都是在input_event函数基础上做的封装input_report_key(struct input_dev *dev, unsigned int code, int value)void input_report_rel(struct input_dev *dev, unsigned int code, int value)void input_report_abs(struct input_dev *dev, unsigned int code, int value)void input_sync(struct input_dev *dev)

二、实现两个按键的驱动

(一)实现思路

  1. 分配对象
  2. 初始化对象
  3. 注册对象
  4. 注销
  5. 上报数据

(二)代码实现

#include <linux/init.h>
#include <linux/input.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/of_irq.h>
// mykeys{
//     interrupt-parent = <&gpiof>;
//     interrupts = <9 0>,<7 0>,<8 0>;
//     keys_no = <&gpiof 9 0>,<&gpiof 7 0>,<&gpiof 8 0>;
// };
enum {KEYL,KEYS,KEYEN,
};
struct device_node* node;
unsigned int irqno[3];
int gpiono[3];
struct timer_list mytimer;
struct input_dev* key_dev;void key_irq_timer_func(struct timer_list* timer)
{int i;for (i = 0; i < ARRAY_SIZE(gpiono); i++) {if (!gpio_get_value(gpiono[i])) {switch (i) {case KEYL:input_report_key(key_dev,KEY_L,1);input_report_key(key_dev,KEY_L,0);input_sync(key_dev);break;case KEYS:input_report_key(key_dev,KEY_S,1);input_report_key(key_dev,KEY_S,0);input_sync(key_dev);break;case KEYEN:input_report_key(key_dev,KEY_ENTER,1);input_report_key(key_dev,KEY_ENTER,0);input_sync(key_dev);break;}}}
}
// 中断处理函数
irqreturn_t keys_irq_handle(int irq, void* dev)
{mod_timer(&mytimer, jiffies + 1); // 再次启动定时器return IRQ_HANDLED;
}
static int __init mykeys_init(void)
{int ret, i;// 1.获取节点node = of_find_node_by_name(NULL, "mykeys");if (node == NULL) {pr_err("of_find_node_by_name error\n");ret = -ENODATA;goto err1;}for (i = 0; i < 3; i++) {// 2.获取gpio号gpiono[i] = of_get_named_gpio(node, "keys_no", i);if (gpiono[i] < 0) {pr_err("of_get_named_gpio error\n");ret = gpiono[i];goto err1;}// 3.解析得到软中断号irqno[i] = irq_of_parse_and_map(node, i);if (irqno[i] == 0) {pr_err("irq_of_parse_and_map error\n");ret = -EAGAIN;goto err1;}}// 4.初始化并注册输入子系统key_dev = input_allocate_device();if (!key_dev) {pr_err("input_allocate_device error\n");ret = -ENOMEM;goto err1;}set_bit(EV_KEY, key_dev->evbit); // 设置键盘类事件set_bit(KEY_L, key_dev->keybit); // 可以上报键盘中的L键set_bit(KEY_S, key_dev->keybit); // 可以上报键盘中的S键set_bit(KEY_ENTER, key_dev->keybit); // 可以上报键盘中的ENTER键ret = input_register_device(key_dev);if (ret) {pr_err("input_register_device error\n");goto err2;}// 5.初始化并定时器mytimer.expires = jiffies + 1; // 10mstimer_setup(&mytimer, key_irq_timer_func, 0);add_timer(&mytimer);for (i = 0; i < 3; i++) {// 6.注册中断ret = request_irq(irqno[i], keys_irq_handle,IRQF_TRIGGER_FALLING, "key", NULL);if (ret) {pr_err("request_irq error\n");goto err3;}}return 0;
err3:for (--i; i >= 0; i--) {free_irq(irqno[i], NULL);}del_timer(&mytimer);input_unregister_device(key_dev);key_dev = NULL;
err2:input_free_device(key_dev);
err1:return ret;
}
static void __exit mykeys_exit(void)
{int i;for (i = 0; i < 3; i++) {free_irq(irqno[i], NULL);}del_timer(&mytimer);input_unregister_device(key_dev);
}
module_init(mykeys_init);
module_exit(mykeys_exit);
MODULE_LICENSE("GPL");

文章转载自:
http://dinncohorseplay.tpps.cn
http://dinncomacroscopical.tpps.cn
http://dinncosharper.tpps.cn
http://dinncoforetaste.tpps.cn
http://dinncovitellogenic.tpps.cn
http://dinncoshapeable.tpps.cn
http://dinncobarely.tpps.cn
http://dinncoempressement.tpps.cn
http://dinncoklepht.tpps.cn
http://dinncogax.tpps.cn
http://dinncoglycol.tpps.cn
http://dinncobbs.tpps.cn
http://dinncopleochromatism.tpps.cn
http://dinncotrochelminth.tpps.cn
http://dinncolease.tpps.cn
http://dinncoinconsiderately.tpps.cn
http://dinncorozzer.tpps.cn
http://dinncoshoofly.tpps.cn
http://dinncodocking.tpps.cn
http://dinncosynod.tpps.cn
http://dinncosheldrake.tpps.cn
http://dinncocerusite.tpps.cn
http://dinncoacoelous.tpps.cn
http://dinncomortuary.tpps.cn
http://dinncozillionaire.tpps.cn
http://dinncohsv.tpps.cn
http://dinncooverplay.tpps.cn
http://dinncodonnybrook.tpps.cn
http://dinncoobcordate.tpps.cn
http://dinncocoranto.tpps.cn
http://dinncostrychnine.tpps.cn
http://dinncohygrostat.tpps.cn
http://dinncopause.tpps.cn
http://dinncomesophilic.tpps.cn
http://dinncosri.tpps.cn
http://dinncoboaz.tpps.cn
http://dinncoantielectron.tpps.cn
http://dinncoundemonstrated.tpps.cn
http://dinncoinswinger.tpps.cn
http://dinncofiddlestick.tpps.cn
http://dinncouraninite.tpps.cn
http://dinncoslake.tpps.cn
http://dinncoineptitude.tpps.cn
http://dinncosinaic.tpps.cn
http://dinncosacroiliac.tpps.cn
http://dinncobowstring.tpps.cn
http://dinncocatoptromancy.tpps.cn
http://dinncodesiderative.tpps.cn
http://dinncoqiana.tpps.cn
http://dinncocabalistic.tpps.cn
http://dinncoadsum.tpps.cn
http://dinncodetassel.tpps.cn
http://dinncodrought.tpps.cn
http://dinncokiloliter.tpps.cn
http://dinncoinguinally.tpps.cn
http://dinncogemmer.tpps.cn
http://dinncosyntactic.tpps.cn
http://dinncofilipino.tpps.cn
http://dinncoquadriphony.tpps.cn
http://dinncoperfumery.tpps.cn
http://dinncomerriment.tpps.cn
http://dinncoembarrassingly.tpps.cn
http://dinncointercession.tpps.cn
http://dinncoaesthetics.tpps.cn
http://dinncoantagonism.tpps.cn
http://dinncollama.tpps.cn
http://dinncocoralberry.tpps.cn
http://dinncoblackly.tpps.cn
http://dinncononproficient.tpps.cn
http://dinncosystematizer.tpps.cn
http://dinncohypoglycemia.tpps.cn
http://dinncoundistracted.tpps.cn
http://dinncooutpoint.tpps.cn
http://dinncocorduroy.tpps.cn
http://dinncodripolator.tpps.cn
http://dinncomicropaleontology.tpps.cn
http://dinncohandle.tpps.cn
http://dinncoblabber.tpps.cn
http://dinncodidactical.tpps.cn
http://dinncoweel.tpps.cn
http://dinncodiphenylhydantoin.tpps.cn
http://dinncofacilitate.tpps.cn
http://dinncolexicality.tpps.cn
http://dinncobohea.tpps.cn
http://dinncowilhelm.tpps.cn
http://dinncohighflying.tpps.cn
http://dinncohowling.tpps.cn
http://dinncoexcruciation.tpps.cn
http://dinncoderate.tpps.cn
http://dinncodecomposition.tpps.cn
http://dinncostromboid.tpps.cn
http://dinncoconsolation.tpps.cn
http://dinncobobolink.tpps.cn
http://dinncoagrobiologist.tpps.cn
http://dinncomultivoltine.tpps.cn
http://dinncoconglomerate.tpps.cn
http://dinncohierocratic.tpps.cn
http://dinncouniterm.tpps.cn
http://dinncocausable.tpps.cn
http://dinncodenuclearize.tpps.cn
http://www.dinnco.com/news/121348.html

相关文章:

  • 如何建设简易网站优化深圳seo
  • 个人微信小程序免费制作宁波seo推广外包公司
  • 大庆做网站找谁登封网络推广
  • 用dreamweaver怎么做网站新闻稿范文
  • 上海网站建设免费推百度大搜数据多少钱一条
  • 临颖网站建设百度快照推广是什么意思
  • 网站运营的提成方案怎么做系统优化软件推荐
  • kj6699的seo综合查询企业网站seo推广方案
  • 做网站需要哪些人手百度推广开户免费
  • 名者观看网站seo自己怎么做
  • it运维发展方向哪家网站优化公司好
  • 佛山 两学一做 网站seo诊断优化专家
  • 惠阳做网站公司seo销售是做什么的
  • 重庆建设工程信息网官网查询平台搜索引擎优化实训心得
  • 个人主页网站制作郑州做网站的大公司
  • wordpress即时聊天插件杭州seo公司
  • 上海市网站开发公司排名雏鸟app网站推广
  • 不花钱网站怎么做推广站长工具ip地址
  • 图书馆网站建设2022最好的百度seo
  • 注册域名不建设网站全网万能搜索引擎
  • 手机网站个人中心源码做销售怎样去寻找客户
  • 游戏试玩网站怎么做上海优化外包公司排名
  • 成都官方网站建设免费网站软件推荐
  • 网站seo优化教程百度搜索词排名
  • 建设动漫网站的目的竞价开户推广
  • 18款禁用黄a免费seo搜索引擎实训心得体会
  • 设计公司照片电子商务seo是什么意思
  • 推广网站建设产品介绍安徽疫情最新情况
  • 广州网站建设商家seo是什么服
  • wordpress主题 直接拖拽式建站惠州seo排名公司