Beispiel #1
0
/*---------------------------------------------------------------------------*/
void
bme280_arch_i2c_read_mem(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t bytes)
{
  i2c_master_enable();
  if(i2c_single_send(addr, reg) == I2C_MASTER_ERR_NONE) {
    while(i2c_master_busy());
    i2c_burst_receive(addr, buf, bytes);
  }
}
Beispiel #2
0
/*---------------------------------------------------------------------------*/
static uint16_t
sht25_read_reg(uint8_t reg, uint8_t *buf, uint8_t regNum)
{
  if(i2c_single_send(SHT25_ADDR, reg) == I2C_MASTER_ERR_NONE) {
    if(i2c_burst_receive(SHT25_ADDR, buf, regNum) == I2C_MASTER_ERR_NONE) {
      return SHT25_SUCCESS;
    }
  }
  return SHT25_ERROR;
}
/*---------------------------------------------------------------------------*/
static int value(int type) {
	uint8_t temp[2] = { 0, 0 };

	/* set pointer to temperature register */
	i2c_single_send(SE95_ADDR, 0);
	/* receive the data */
	i2c_burst_receive(SE95_ADDR, temp, 2);

	return ((( temp[0] << 8 ) + temp[1]) >> 3);
}
Beispiel #4
0
/*---------------------------------------------------------------------------*/
static uint16_t
sht25_read_reg(uint8_t reg, uint8_t *buf, uint8_t num)
{
  if((buf == NULL) || (num <= 0)) {
    return SHT25_ERROR;
  }

  i2c_master_enable();
  if(i2c_single_send(SHT25_ADDR, reg) == I2C_MASTER_ERR_NONE) {
    if(i2c_burst_receive(SHT25_ADDR, buf, num) == I2C_MASTER_ERR_NONE) {
      return SHT25_SUCCESS;
    }
  }
  return SHT25_ERROR;
}