コード例 #1
0
ファイル: lm75.c プロジェクト: AlexShiLucky/NuttX
static int lm75_writeb16(FAR struct lm75_dev_s *priv, uint8_t regaddr,
                         b16_t regval)
{
  uint8_t buffer[3];
  b8_t regb8;

  sninfo("addr: %02x value: %08x\n", regaddr, regval);

  /* Set up a 3 byte message to send */

  buffer[0] = regaddr;

  regb8 = b16tob8(regval);
  buffer[1] = (uint8_t)(regb8 >> 8);
  buffer[2] = (uint8_t)regb8;

  /* Write the register address followed by the data (no RESTART) */

  return lm75_i2c_write(priv, buffer, 3);
}
コード例 #2
0
ファイル: lm75.c プロジェクト: justdoitding/Nuttx_PSoC4
static int lm75_writeb16(FAR struct lm75_dev_s *priv, uint8_t regaddr,
                         b16_t regval)
{
  uint8_t buffer[3];
  b8_t regb8;

  sndbg("addr: %02x value: %08x\n", regaddr, regval);

  /* Set up a 3 byte message to send */

  buffer[0] = regaddr;

  regb8 = b16tob8(regval);
  buffer[1] = (uint8_t)(regb8 >> 8);
  buffer[2] = (uint8_t)regb8;

  /* Write the register address followed by the data (no RESTART) */

  I2C_SETADDRESS(priv->i2c, priv->addr, 7);
  return I2C_WRITE(priv->i2c, buffer, 3);
}