enhancing Multitech's library for some accelerometer
Fork of MMA845x by
Diff: MMA845x.cpp
- Revision:
- 3:7c2fbf79f607
- Parent:
- 2:70df6adad015
- Child:
- 4:4ff1650da84c
diff -r 70df6adad015 -r 7c2fbf79f607 MMA845x.cpp --- a/MMA845x.cpp Wed Oct 28 17:48:15 2015 +0000 +++ b/MMA845x.cpp Mon Dec 21 10:49:15 2015 -0600 @@ -50,7 +50,9 @@ uint8_t i = 0; char reg_val[1]; + __disable_irq(); _i2c->frequency(100000); + __enable_irq(); _who_am_i = 0x00; // Reset all registers to POR values @@ -288,9 +290,9 @@ buf[0] = reg; buf[1] = data; -// __disable_irq(); // Tickers and other timebase events can jack up the I2C bus for some devices + __disable_irq(); // Tickers and other timebase events can jack up the I2C bus for some devices result |= _i2c->write(_i2c_addr, buf, 2); -// __enable_irq(); // Just need to block during the transaction + __enable_irq(); // Just need to block during the transaction if(result != 0) { debug("MMA845x:writeRegister failed r-%d\n\r",result); @@ -305,18 +307,18 @@ char reg_out[1]; reg_out[0] = reg; -// __disable_irq(); // Tickers and other timebase events can jack up the I2C bus for some devices + __disable_irq(); // Tickers and other timebase events can jack up the I2C bus for some devices result |= _i2c->write(_i2c_addr,reg_out,1,true); -// __enable_irq(); // Just need to block during the transaction + __enable_irq(); // Just need to block during the transaction if(result != 0) { debug("MMA845x::readRegister failed write r- %d\n\r", result); return result; } -// __disable_irq(); // Tickers and other timebase events can jack up the I2C bus for some devices + __disable_irq(); // Tickers and other timebase events can jack up the I2C bus for some devices result |= _i2c->read(_i2c_addr,data,count,false); -// __enable_irq(); // Just need to block during the transaction + __enable_irq(); // Just need to block during the transaction if(result != 0) { debug("MMA845x::readRegister failed read r-%d\n\r",result);