public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
* I2C driver modification for BH1710FVC Ambient Light Sensor
@ 2010-08-30 15:33 Rogério de Souza Moraes
       [not found] ` <AANLkTinzBkHsLO3TqwoPFb3AjVQ5xziSg_F7wFtB0c0R-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Rogério de Souza Moraes @ 2010-08-30 15:33 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-08-30 15:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-30 15:33 I2C driver modification for BH1710FVC Ambient Light Sensor Rogério de Souza Moraes
     [not found] ` <AANLkTinzBkHsLO3TqwoPFb3AjVQ5xziSg_F7wFtB0c0R-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-08-30 15:58   ` Jean Delvare

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox