Skip to content
Snippets Groups Projects
Commit 31920f96 authored by Hauke Petersen's avatar Hauke Petersen
Browse files

Merge pull request #4305 from haukepetersen/fix_l3g4200_init

drivers/l3g4200d: fixed initialization
parents c8d89cb6 cb6f3e95
No related branches found
No related tags found
No related merge requests found
...@@ -39,16 +39,6 @@ int l3g4200d_init(l3g4200d_t *dev, i2c_t i2c, uint8_t address, ...@@ -39,16 +39,6 @@ int l3g4200d_init(l3g4200d_t *dev, i2c_t i2c, uint8_t address,
{ {
char tmp; char tmp;
/* Acquire exclusive access to the bus. */
i2c_acquire(dev->i2c);
/* initialize the I2C bus */
if (i2c_init_master(i2c, I2C_SPEED) < 0) {
/* Release the bus for other threads. */
i2c_release(dev->i2c);
return -1;
}
i2c_release(dev->i2c);
/* write device descriptor */ /* write device descriptor */
dev->i2c = i2c; dev->i2c = i2c;
dev->addr = address; dev->addr = address;
...@@ -71,9 +61,16 @@ int l3g4200d_init(l3g4200d_t *dev, i2c_t i2c, uint8_t address, ...@@ -71,9 +61,16 @@ int l3g4200d_init(l3g4200d_t *dev, i2c_t i2c, uint8_t address,
break; break;
} }
/* acquire exclusive access to the bus. */
i2c_acquire(dev->i2c);
/* initialize the I2C bus */
if (i2c_init_master(i2c, I2C_SPEED) < 0) {
/* Release the bus for other threads. */
i2c_release(dev->i2c);
return -1;
}
/* configure CTRL_REG1 */ /* configure CTRL_REG1 */
tmp = ((mode & 0xf) << L3G4200D_CTRL1_MODE_POS) | L3G4200D_CTRL1_ALLON; tmp = ((mode & 0xf) << L3G4200D_CTRL1_MODE_POS) | L3G4200D_CTRL1_ALLON;
i2c_acquire(dev->i2c);
if (i2c_write_reg(dev->i2c, dev->addr, L3G4200D_REG_CTRL1, tmp) != 1) { if (i2c_write_reg(dev->i2c, dev->addr, L3G4200D_REG_CTRL1, tmp) != 1) {
i2c_release(dev->i2c); i2c_release(dev->i2c);
return -1; return -1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment