int
iic_acquire_bus(
i2c_tag_t ic
int flags
)
int
iic_release_bus(
i2c_tag_t ic
int flags
)
int
iic_exec(
i2c_tag_t ic
i2c_op_t op
i2c_addr_t addr
const void *cmdbuf
size_t cmdlen
void *buf
size_t len
int flags
)
int
iic_smbus_write_byte(
i2c_tag_t ic
i2c_addr_t addr
uint8_t cmd
uint8_t data
int flags
)
int
iic_smbus_read_byte(
i2c_tag_t ic
i2c_addr_t addr
uint8_t cmd
uint8_t *datap
int flags
)
int
iic_smbus_receive_byte(
i2c_tag_t ic
i2c_addr_t addr
uint8_t *datap
int flags
)
i2c_tag_tstruct i2c_controller,
consisting of function pointers filled in by the I2C
controller driver.
i2c_op_ti2c_addr_tstruct i2c_attach_args
struct i2c_attach_args {
i2c_tag_t ia_tag; /* controller */
i2c_addr_t ia_addr; /* address of device */
int ia_size; /* size (for EEPROMs) */
};
ic, flags)I2C_F_POLL
flag indicates to
iic_acquire_bus()
that sleeping is not permitted.
ic, flags)I2C_F_POLL
flag was passed to
iic_acquire_bus(),
it must also be passed to
iic_release_bus().
ic, op, addr, cmdbuf, cmdlen, buf, len, flags))
initiates the operation by sending a START condition on the I2C
bus and then transmitting the address of the target device along
with the transaction type.
If
cmdlen
is non-zero, the command pointed to by
cmdbuf
is then sent to the device.
If
buflen
is non-zero,
iic_exec()
will then transmit or receive the data, as indicated by
op.
If
op
indicates a read operation,
iic_exec()
will send a REPEATED START before transferring the data.
If
op
so indicates, a STOP condition will be sent on the I2C
bus at the conclusion of the operation.
Passing the
I2C_F_POLL
flag indicates to
iic_exec()
that sleeping is not permitted.
ic, addr, cmd, data, flags)cmdlen
of 1 and
len
of 1.
ic, addr, cmd, datap, flags)cmdlen
of 1 and
len
of 1.
ic, addr, datap, flags)cmdlen
of 0 and
len
of 1.
i2c_controller
structure, which is defined as follows:
struct i2c_controller {
void *ic_cookie; /* controller private */
int (*ic_acquire_bus)(void *, int);
void (*ic_release_bus)(void *, int);
int (*ic_exec)(void *, i2c_op_t, i2c_addr_t,
const void *, size_t, void *, size_t, int);
int (*ic_send_start)(void *, int);
int (*ic_send_stop)(void *, int);
int (*ic_initiate_xfer)(void *, i2c_addr_t, int);
int (*ic_read_byte)(void *, uint8_t *, int);
int (*ic_write_byte)(void *, uint8_t, int);
};
The
(*ic_acquire_bus)()
and
(*ic_release_bus)()
functions must always be provided.
The controller driver may elect to provide an
(*ic_exec)()
function.
This function is intended for use by automated controllers
that do not provide manual control over I2C bus conditions
such as START and STOP.
If the
(*ic_exec)()
function is not provided, the following 5 functions will be
used by
iic_exec()
in order to execute the I2C bus operation:
cookie, flags)I2C_F_POLL
flag indicates that sleeping is not permitted.
cookie, flags)I2C_F_POLL
flag indicates that sleeping is not permitted.
cookie, addr, flags)I2C_F_READ
flag indicates a read transfer; the lack of this flag indicates a
write transfer.
The
I2C_F_POLL
flag indicates that sleeping is not permitted.
The error code
ETIMEDOUT
should be returned if a timeout that would indicate that the
device is not present occurs.
cookie, datap, flags)datap.
The
I2C_F_LAST
flag indicates that this is the final byte of the transfer, and that
a NACK condition should be sent on the I2C bus following the transfer
of the byte.
The
I2C_F_STOP
flag indicates that a STOP condition should be sent on the I2C bus following
the transfer of the byte.
The
I2C_F_POLL
flag indicates that sleeping is not permitted.
cookie, data, flags)data
to the I2C bus.
The
I2C_F_STOP
flag indicates that a STOP condition should be sent on the I2C bus following
the transfer of the byte.
The
I2C_F_POLL
flag indicates that sleeping is not permitted.