完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我的想法很简单就是直接7290来一个中断我就用I2C读取他的键值,其他的啥子都不操作,先仿照写了一个中断的驱动,按键盘上的任何键都会进入中断,说明中断时对的!没问题!然后我就想在中断理用I2C读取键值,加上读取函数加上就开发板就重启了,我的I2C用的引脚和开发板上的时钟PCF8763的是一样的?是不是就不初始化I2C的引脚,只需要申请总线直接就可以用了,求大家指点!!!!!!!!!
#include #include #include #include #include #include #include #include #include //#include #include #include #include //#include "gps.h" #include #include #include //中断头文件 #include #include #define DPRINTK(x...) printk("7290key_irq DEBUG:" x) #define DRIVER_NAME "7290key_irq" #define BUZZER_GPIO EXYNOS4_GPD0(0) #define ZLG7290 0x71 #define zlg7290key_read() i2c_smbus_read_byte(0x70) static struct i2c_client*g_client; static irqreturn_t eint22_interrupt(int irq,void *dev_id) { static int Flay; unsigned char res ; printk("receive a interrupt 22!n"); printk("%s, %dn", __FUNCTION__, __LINE__); ndelay(20); if(gpio_get_value(EXYNOS4_GPX2(6))) { return IRQ_HANDLED; } // res = zlg7290key_read(); int ret =0; int count=0; char data_buff[20]; ret=i2c_master_send(g_client,ZLG7290,1); ret=i2c_master_recv(g_client,data_buff,count); //copy_to_user(buf,data_buff,count); printk("ZLG7290 KEY value :%d!n",data_buff[0]); return IRQ_HANDLED; } static int keyirq_probe(struct platform_device *pdev) { int ret; char *banner = "7290key_irq Initializen"; printk(banner); ret = gpio_request(EXYNOS4_GPX2(6), "EINT22"); if (ret) { printk("%s: request GPIO %d for EINT22 failed, ret = %dn", DRIVER_NAME, EXYNOS4_GPX2(6), ret); return ret; } s3c_gpio_cfgpin(EXYNOS4_GPX2(6), S3C_GPIO_SFN(0xF)); s3c_gpio_setpull(EXYNOS4_GPX2(6), S3C_GPIO_PULL_UP); gpio_free(EXYNOS4_GPX2(6)); //注册中断 ret=request_irq(IRQ_EINT(22),eint22_interrupt,IRQ_TYPE_EDGE_FALLING,"my_eint22",pdev); if(ret<0) { printk("Request IRQ %d failed, %dn",IRQ_EINT(22),ret); goto exit; } return 0; exit: return ret; } static int keyirq_remove (struct platform_device *pdev) { free_irq(IRQ_EINT(22),pdev); return 0; } static int keyirq_suspend (struct platform_device *pdev, pm_message_t state) { DPRINTK("keyirq suspend:power off!n"); return 0; } static int keyirq_resume (struct platform_device *pdev) { DPRINTK("keyirq resume:power on!n"); return 0; } static struct platform_driver keyirq_driver = { .probe = keyirq_probe, .remove = keyirq_remove, .suspend = keyirq_suspend, .resume = keyirq_resume, .driver = { .name = DRIVER_NAME, .owner = THIS_MODULE, }, }; static __devinit int zlg7290_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { printk("ZLG7290 device is detectedn"); g_client=client; return 0; } static __devexit int zlg7290_i2c_remove(struct i2c_client *client) {// snd_soc_unregister_codec(&client->dev); kfree(i2c_get_clientdata(client)); return 0; } static const struct i2c_device_id zlg7290_id[] = { {"zlg7290-i2c", 0}, {}, }; MODULE_DEVICE_TABLE(i2c, zlg7290_id); static struct i2c_driver zlg7290_i2c_driver = { .driver = { .name = "zlg7290-i2c", .owner = THIS_MODULE, }, .probe = zlg7290_i2c_probe, .remove = __devexit_p(zlg7290_i2c_remove), .id_table = zlg7290_id, }; static void __exit keyirq_exit(void) { platform_driver_unregister(&keyirq_driver); i2c_del_driver(&zlg7290_i2c_driver); printk("7290key driver remove n"); } static int __init keyirq_init(void) { int ret = 0; // #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) i2c_add_driver(&zlg7290_i2c_driver); if (ret != 0) { printk(KERN_ERR "Failed to register zlg7290 I2C driver: %dn", ret); } // #endif return platform_driver_register(&keyirq_driver); } module_init(keyirq_init); module_exit(keyirq_exit); MODULE_LICENSE("Dual BSD/GPL"); MODULE_AUTHOR("zL/."); |
|
相关推荐
2个回答
|
|
顶一下~~~~~~~~~~~~~~
|
|
|
|
不同的IIC,是不同的设备,要建设备节点,不可像单片机上那么操作
|
|
|
|
只有小组成员才能发言,加入小组>>
「含关键代码」基于AM3352/AM3354/AM3359的Linux开发案例分享
4868 浏览 0 评论
87357 浏览 0 评论
【高手问答】如何做到精通linux技术?资深工程师带你突破难点
4674 浏览 2 评论
3566 浏览 2 评论
解读Linux :先从创建一个文件夹用来存放jdk压缩文件开始
2451 浏览 0 评论
1949浏览 3评论
这是i.mx6ull的关于usb的宏定义,能解释下这些宏定义的意思
1317浏览 1评论
1226浏览 1评论
求解:aarch64交叉编译工具已经安装成功,环境变量已经配置,怎么将系统架构切换为ARM的架构
1295浏览 0评论
电脑和虚拟机可以互ping,电脑和开发板也可以互ping,但是虚拟机和开发板ping不通是什么原因
1209浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 16:23 , Processed in 1.305225 second(s), Total 78, Slave 61 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号