Re: I2C driver modification for BH1710FVC Ambient Light Sensor

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

 



Hi Rogério,

On Mon, 30 Aug 2010 12:33:26 -0300, Rogério de Souza Moraes wrote:
> 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.

As the transaction format you need isn't part of SMBus, I assume that
your controller is an I2C master and you should simply use
i2c_master_recv() in your device driver.

-- 
Jean Delvare
--
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