device iic
#include
<dev/iicbus/iic.h>
The iic device driver provides generic I/O
to any iicbus(4) instance. In order to control I2C
devices, use /dev/iic? with the following
ioctls:
I2CSTARTI2CRPTSTARTI2CSTOPI2CRSTCARDI2CWRITEI2CREADI2CRDWRIIC_M_RD is set in flags.
Otherwise the transfer is a write transfer. The
slave element specifies the 7-bit address for the
transfer. The len element is the length of the data.
The buf element is a buffer for that data. This
ioctl is intended to be Linux compatible.The following data structures are defined in
<dev/iicbus/iic.h> and
referenced above:
struct iiccmd {
u_char slave;
int count;
int last;
char *buf;
};
/* Designed to be compatible with linux's struct i2c_msg */
struct iic_msg
{
uint16_t slave;
uint16_t flags;
#define IIC_M_RD 0x0001 /* read vs write */
uint16_t len; /* msg length */
uint8_t * buf;
};
struct iic_rdwr_data {
struct iic_msg *msgs;
uint32_t nmsgs;
};
It is also possible to use read/write routines, then I2C
start/stop handshake is managed by the iicbus(4) system.
However, the address used for the read/write routines is the one passed to
last I2CSTART ioctl(2) to this
device.
The iic manual page first appeared in
FreeBSD 3.0.
This manual page was written by Nicolas Souchu and M. Warner Losh.
Only the I2CRDWR
ioctl(2) is thread safe. All other interfaces suffer from
some kind of race.