我的想法很简单就是直接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/.");