I.MX6 SHT20 Linux 驱动移植

/***********************************************************************
* I.MX6 SHT20 Linux 驱动移植
* 说明:
* 本来打算使用SHT10来做湿度检测,发现其并不是I2C接口,当然也使用
* GPIO能获取到相关数据了,不过由于不小心将其烧坏了,所以换成SHT20。
*
* 2016-10-10 深圳 南山平山村 曾剑锋
**********************************************************************/ 一、参考驱动:
Android_Native_Service_SHT20Demo
https://github.com/HowardLin/Android_Native_Service_SHT20Demo/blob/master/SHT20_Module_1.2/sht20_driver/sht20.c#L126 二、驱动修改:
static s32 sht20_get_id(struct i2c_client *client, u8 serial[])
{
s32 result;
u8 serialA[];
u8 serialB[]; u8 command1[] = {0xFA, 0x0F}; /* Read from memory location 1 */
u8 command2[] = {0xFC, 0xC9}; /* Read from memory location 2 */ struct i2c_msg get_serial_number_msg1[] = {
{
.addr = client->addr,
.flags = ~I2C_M_RD,
.len = ,
.buf = command1,
},
{
.addr = client->addr,
.flags = I2C_M_RD,
.len = ,
.buf = serialA,
},
};
result = i2c_transfer(client->adapter, get_serial_number_msg1, ); struct i2c_msg get_serial_number_msg2[] = {
{
.addr = client->addr,
.flags = ~I2C_M_RD,
.len = ,
.buf = command2,
},
{
.addr = client->addr,
.flags = I2C_M_RD,
.len = ,
.buf = serialB,
}
};
result = i2c_transfer(client->adapter, get_serial_number_msg2, ); // printk(KERN_INFO "%x %x %x %x %x %x %x %x", serialB[3], serialB[4], serialA[0], serialA[2], serialA[4], serialA[6], serialB[0], serialB[1]); serial[] = serialB[];
serial[] = serialB[];
serial[] = serialA[];
serial[] = serialA[];
serial[] = serialA[];
serial[] = serialA[];
serial[] = serialB[];
serial[] = serialB[]; return result;
}
上一篇:JQuery基础-- Ajax


下一篇:Linux内核(12) - 子系统的初始化之那些入口函数