2013-08-01 45 views

回答

0

/driver/i2c/busses /中有i2c-gpio.c文件。在此我們用bit_xfer來填充master_xfer函數。它實施起來有點難。

1

什麼master_xfer設置取決於您的平臺和總線。查看drivers/i2c/busses /下的函數指針設置。請注意,它可以設置爲NULL。

其中它被設置的一個例子是在驅動/ I2C /總線/ I2C-pxa.c:

static const struct i2c_algorithm i2c_pxa_algorithm = { 
     .master_xfer = i2c_pxa_xfer, 
     .functionality = i2c_pxa_functionality, 
}; 

還看包括/ LINUX/i2c.h中:

struct i2c_algorithm { 
     /* If an adapter algorithm can't do I2C-level access, set master_xfer 
      to NULL. If an adapter algorithm can do SMBus access, set 
      smbus_xfer. If set to NULL, the SMBus protocol is simulated 
      using common I2C messages */ 
     /* master_xfer should return the number of messages successfully 
      processed, or a negative value on error */ 
     int (*master_xfer)(struct i2c_adapter *adap, struct i2c_msg *msgs, 
          int num); 
     int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr, 
          unsigned short flags, char read_write, 
          u8 command, int size, union i2c_smbus_data *data); 

     /* To determine what the adapter supports */ 
     u32 (*functionality) (struct i2c_adapter *); 
}; 

* An i2c_msg is the low level representation of one segment of an I2C 
* transaction. It is visible to drivers in the @i2c_transfer() procedure, 
* to userspace from i2c-dev, and to I2C adapter drivers through the 
* @[email protected]_xfer() method. 
* 
+0

感謝您的澄清..是有用的...但假設如果我使用I2c-gpio,請參考。 – kzs

+0

@kzs它看起來像撞擊i2c-gpio接口只使用i2c_adapter結構,而不是i2c_algorithm。 –

+0

沒有彼得,其實它使用,有相同的路徑i2c-gpio.c。因爲我們正在用bit_xfer填充master_xfer函數。感謝您的參考。 – kzs

相關問題