I2C driver modification for BH1710FVC Ambient Light Sensor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi folks,

I am developing a driver for the Ambient Light Sensor BH1710FVC that
communicates by i2c bus. My problem is that the type of message that
this chip accept is this:

S Addr Rd [A] [DataHigh] A [DataLow] NA P

I searched in the file "Documentation/i2c/smbus-protocol" for one
function that communicate like this, but I did not find. I tried to
use the function i2c_smbus_read_byte twice (reading data high first
and so the data low), but the chip do not accept communicate this way.

So I've based in the function i2c_smbus_read_byte to build the
function that implements the protocol like I need.

I modified the file i2c-core.c in the function i2c_smbus_xfer_emulated
creating an I2C_SMBUS_WORD.
In first switch I add:

        case I2C_SMBUS_WORD:
                if (read_write == I2C_SMBUS_READ) {
                        msg[0].len = 2;
                        msg[0].flags = I2C_M_RD | flags;
                        num = 1;
                }
                break;

and for the second switch I added the following case:

                        case I2C_SMBUS_WORD:
                                data->word = msgbuf0[0] | (msgbuf0[1] << 8);
                                break;

After this modification my Ambient Light Sensor driver is working just fine.

So I want to know if there is a better way to implement this without
need to modify the i2c driver.

Regards,

Rogerio
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux