fix that i2c device of sensor framework cannot set i2c address
This commit is contained in:
@@ -64,6 +64,8 @@ int I2cDriverInit(struct I2cDriver *i2c_driver, const char *driver_name)
|
||||
|
||||
i2c_driver->driver.private_data = i2c_driver->private_data;
|
||||
|
||||
i2c_driver->driver.configure = i2c_driver->configure;
|
||||
|
||||
ret = I2cDriverRegister(&i2c_driver->driver);
|
||||
if (EOK != ret) {
|
||||
KPrintf("I2cDriverInit DriverRegister error %u\n", ret);
|
||||
|
||||
@@ -37,7 +37,7 @@ static uint32 I2cDeviceWrite(void *dev, struct BusBlockWriteParam *write_param)
|
||||
struct I2cHardwareDevice *i2c_dev = (struct I2cHardwareDevice *)dev;
|
||||
struct I2cDataStandard i2c_msg;
|
||||
|
||||
i2c_msg.addr = I2C_SLAVE_ADDR;
|
||||
i2c_msg.addr = i2c_dev->i2c_dev_addr;
|
||||
i2c_msg.flags = I2C_WR;
|
||||
i2c_msg.buf = NONE;
|
||||
i2c_msg.len = 0;
|
||||
@@ -55,7 +55,7 @@ static uint32 I2cDeviceRead(void *dev, struct BusBlockReadParam *read_param)
|
||||
struct I2cHardwareDevice *i2c_dev = (struct I2cHardwareDevice *)dev;
|
||||
struct I2cDataStandard i2c_msg;
|
||||
|
||||
i2c_msg.addr = I2C_SLAVE_ADDR;
|
||||
i2c_msg.addr = i2c_dev->i2c_dev_addr;
|
||||
i2c_msg.flags = I2C_RD;
|
||||
i2c_msg.buf = read_param->buffer;
|
||||
i2c_msg.len = read_param->size;
|
||||
|
||||
@@ -55,6 +55,8 @@ struct I2cDriver
|
||||
{
|
||||
struct Driver driver;
|
||||
|
||||
uint32 (*configure) (void *drv, struct BusConfigureInfo *configure_info);
|
||||
|
||||
void *private_data;
|
||||
};
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define I2C_SLAVE_ADDR 0x44
|
||||
#define I2C_WR 0x0000
|
||||
#define I2C_RD (1u << 0)
|
||||
#define I2C_ADDR_10BIT (1u << 2)
|
||||
@@ -61,7 +60,7 @@ struct I2cHardwareDevice
|
||||
struct HardwareDev haldev;
|
||||
const struct I2cDevDone *i2c_dev_done;
|
||||
|
||||
void *private_data;
|
||||
uint16 i2c_dev_addr;
|
||||
};
|
||||
|
||||
/*Register the I2C device*/
|
||||
|
||||
Reference in New Issue
Block a user