Class module for MPL3115A2 I2C Barometric Sensor
Dependents: mDotEVBM2X MTDOT-EVBDemo-DRH MTDOT-BOX-EVB-Factory-Firmware-LIB-108 MTDOT-UDKDemo_Senet ... more
Diff: MPL3115A2.cpp
- Revision:
- 2:cc50526dae10
- Parent:
- 1:072fd24cc12b
- Child:
- 3:c41ffe71300f
--- a/MPL3115A2.cpp Wed Oct 28 17:46:01 2015 +0000
+++ b/MPL3115A2.cpp Mon Dec 21 10:49:40 2015 -0600
@@ -52,7 +52,9 @@
uint8_t i = 0;
char reg_val[1];
+ __disable_irq();
_i2c->frequency(400000);
+ __enable_irq();
// Reset all registers to POR values
reg_val[0] = 0x04;
@@ -343,9 +345,9 @@
buf[0] = reg;
memcpy(buf+1,data,count);
-// __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, (count + 1));
-// __enable_irq(); // Just need to block during the transaction
+ __enable_irq(); // Just need to block during the transaction
if(result != 0) {
debug("MPL3115A2:writeRegister failed\n\r");
@@ -360,18 +362,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("MPL3115A2::readRegister failed write\n\r");
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("MPL3115A2::readRegister failed read\n\r");