Class module for MPL3115A2 I2C Barometric Sensor
Dependents: mDotEVBM2X MTDOT-EVBDemo-DRH MTDOT-BOX-EVB-Factory-Firmware-LIB-108 MTDOT-UDKDemo_Senet ... more
Revision 3:c41ffe71300f, committed 2016-10-17
- Comitter:
- Leon Lindenfelser
- Date:
- Mon Oct 17 08:41:40 2016 -0500
- Parent:
- 2:cc50526dae10
- Child:
- 4:b612babc2c3b
- Commit message:
- Remove disable and enable of irqs around I2C accesses. Mbed5 takes care of peripheral access protection.
Changed in this revision
MPL3115A2.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/MPL3115A2.cpp Mon Dec 21 10:49:40 2015 -0600 +++ b/MPL3115A2.cpp Mon Oct 17 08:41:40 2016 -0500 @@ -52,9 +52,7 @@ 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; @@ -345,12 +343,10 @@ buf[0] = reg; memcpy(buf+1,data,count); - __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 if(result != 0) { - debug("MPL3115A2:writeRegister failed\n\r"); + debug("MPL3115A2:writeRegister failed r-%d\n\r",result); } return result; @@ -362,18 +358,14 @@ char reg_out[1]; reg_out[0] = reg; - __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 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 result |= _i2c->read(_i2c_addr,data,count,false); - __enable_irq(); // Just need to block during the transaction if(result != 0) { debug("MPL3115A2::readRegister failed read\n\r");