Logo Search packages:      
Sourcecode: linux-fsl-imx51 version File versions  Download package

static int mxc_i2c_writebytes ( mxc_i2c_device dev,
struct i2c_msg *  msg,
int  last 
) [static]

Write the data to the data register. Generates a stop signal if this is the last message to be sent or if no ack was received for the data sent.

dev the mxc i2c structure used to get to the right i2c device
*msg pointer to a message structure that contains the slave address and data to be sent
last indicates that this is the last message to be received
The function returns the number of bytes written or -1 on time out or if no ack was received for the data that was sent.

Definition at line 351 of file mxc_i2c.c.

References mxc_i2c_device::membase, mxc_i2c_stop(), and mxc_i2c_wait_for_tc().

Referenced by mxc_i2c_xfer().

      int i;
      char *buf = msg->buf;
      int len = msg->len;
      volatile unsigned int cr;

      cr = readw(dev->membase + MXC_I2CR);
      /* Set MTX to switch to transmit mode */
      cr |= MXC_I2CR_MTX;
      writew(cr, dev->membase + MXC_I2CR);

      for (i = 0; i < len; i++) {
             * Write the data
            writew(*buf++, dev->membase + MXC_I2DR);
            if (mxc_i2c_wait_for_tc(dev, msg->flags)) {
                  return -1;
      if (last > 0) {

      return i;

Generated by  Doxygen 1.6.0   Back to index