Пример #1
0
void
accm_write_stream(u8_t len, u8_t *data) {
  i2c_transmitinit(ADXL345_ADDR);
  while (i2c_busy());
  PRINTFDEBUG("I2C Ready to TX(stream)\n");

  i2c_transmit_n(len, data);	// start tx and send conf reg 
  while (i2c_busy());
  PRINTFDEBUG("WRITE_STR %u B to 0x%02X\n", len, data[0]);
}
Пример #2
0
void
tlc59116_write_stream(uint8_t len, uint8_t *data)
{
  i2c_transmitinit(TLC59116_ADDR);
  while(i2c_busy());
  PRINTFDEBUG("I2C Ready to TX(stream)\n");

  i2c_transmit_n(len, data);    /* start tx and send conf reg */
  while(i2c_busy());
  PRINTFDEBUG("WRITE_STR %u B to 0x%02X\n", len, data[0]);
}
Пример #3
0
void
accm_write_reg(u8_t reg, u8_t val) {
  u8_t tx_buf[] = {reg, val};

  i2c_transmitinit(ADXL345_ADDR);
  while (i2c_busy());
  PRINTFDEBUG("I2C Ready to TX\n");

  i2c_transmit_n(2, tx_buf);
  while (i2c_busy());
  PRINTFDEBUG("WRITE_REG 0x%02X @ reg 0x%02X\n", val, reg);
}
Пример #4
0
void
tlc59116_write_reg(uint8_t reg, uint8_t val)
{
  uint8_t tx_buf[] = { reg, val };

  i2c_transmitinit(TLC59116_ADDR);
  while(i2c_busy());
  PRINTFDEBUG("I2C Ready to TX\n");

  i2c_transmit_n(2, tx_buf);
  while(i2c_busy());
  PRINTFDEBUG("WRITE_REG 0x%02X @ reg 0x%02X\n", val, reg);
}
Пример #5
0
void
accm_read_stream(u8_t reg, u8_t len, u8_t *whereto) {
  u8_t rtx = reg;
  PRINTFDEBUG("READ_STR %u B from 0x%02X\n", len, reg);

  /* transmit the register to start reading from */
  i2c_transmitinit(ADXL345_ADDR);
  while (i2c_busy());
  i2c_transmit_n(1, &rtx);
  while (i2c_busy());

  /* receive the data */
  i2c_receiveinit(ADXL345_ADDR);
  while (i2c_busy());
  i2c_receive_n(len, whereto);
  while (i2c_busy());
}
Пример #6
0
u8_t
accm_read_reg(u8_t reg) {
  u8_t retVal = 0;
  u8_t rtx = reg;
  PRINTFDEBUG("READ_REG 0x%02X\n", reg);

  /* transmit the register to read */
  i2c_transmitinit(ADXL345_ADDR);
  while (i2c_busy());
  i2c_transmit_n(1, &rtx);
  while (i2c_busy());

  /* receive the data */
  i2c_receiveinit(ADXL345_ADDR);
  while (i2c_busy());
  i2c_receive_n(1, &retVal);
  while (i2c_busy());

  return retVal;
}
Пример #7
0
/*---------------------------------------------------------------------------*/
static uint16_t
sht25_read_reg(uint8_t reg)
{
  uint8_t buf[] = { 0x00, 0x00 };
  uint16_t retval;
  uint8_t rtx = reg;

  /* transmit the register to read */
  i2c_transmitinit(SHT25_ADDR);
  while(i2c_busy());
  i2c_transmit_n(1, &rtx);
  while(i2c_busy());
  /* receive the data */
  i2c_receiveinit(SHT25_ADDR);
  while(i2c_busy());
  i2c_receive_n(2, &buf[0]);
  while(i2c_busy());

  retval = (uint16_t)(buf[0] << 8 | (buf[1]));
  return retval;
}
Пример #8
0
uint8_t
tlc59116_read_reg(uint8_t reg)
{
  uint8_t retVal = 0;
  uint8_t rtx = reg;

  PRINTFDEBUG("READ_REG 0x%02X\n", reg);

  /* transmit the register to read */
  i2c_transmitinit(TLC59116_ADDR);
  while(i2c_busy());
  i2c_transmit_n(1, &rtx);
  while(i2c_busy());

  /* receive the data */
  i2c_receiveinit(TLC59116_ADDR);
  while(i2c_busy());
  i2c_receive_n(1, &retVal);
  while(i2c_busy());

  return retVal;
}