mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
drivers/si70xx: check connection during init()
This commit is contained in:
parent
b24be6a6ae
commit
5f30c7a593
@ -65,18 +65,24 @@ int si70xx_init(si70xx_t *dev, i2c_t i2c_dev, uint8_t address)
|
|||||||
/* setup the i2c bus */
|
/* setup the i2c bus */
|
||||||
i2c_acquire(dev->i2c_dev);
|
i2c_acquire(dev->i2c_dev);
|
||||||
int result = i2c_init_master(dev->i2c_dev, I2C_SPEED_NORMAL);
|
int result = i2c_init_master(dev->i2c_dev, I2C_SPEED_NORMAL);
|
||||||
|
i2c_release(dev->i2c_dev);
|
||||||
|
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
i2c_release(dev->i2c_dev);
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = si70xx_test(dev);
|
||||||
|
if (result < 0) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initialize the peripheral */
|
/* initialize the peripheral */
|
||||||
|
i2c_acquire(dev->i2c_dev);
|
||||||
i2c_write_byte(dev->i2c_dev, dev->address, SI70XX_RESET);
|
i2c_write_byte(dev->i2c_dev, dev->address, SI70XX_RESET);
|
||||||
|
i2c_release(dev->i2c_dev);
|
||||||
|
|
||||||
/* sensor is ready after at most 25 ms */
|
/* sensor is ready after at most 25 ms */
|
||||||
xtimer_usleep(25 * MS_IN_USEC);
|
xtimer_usleep(25 * MS_IN_USEC);
|
||||||
i2c_release(dev->i2c_dev);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user