Device driver for the Freescale MMA845x family of accelerometers.

Fork of MMA845x by Sam Grove

Committer:
1994timmeh
Date:
Wed Jan 11 04:12:05 2017 +0000
Revision:
2:555f8ba0c959
Parent:
1:37ddb4739f02
sdfasdf

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sam_grove 0:9d1e3a344e4f 1 /**
sam_grove 0:9d1e3a344e4f 2 * @file MMA845x.cpp
1994timmeh 2:555f8ba0c959 3 * @brief Device driver - MMA845X 3-axis accelerometer IC W/RTOS support
1994timmeh 2:555f8ba0c959 4 * @author Tim Barr
sam_grove 0:9d1e3a344e4f 5 * @version 1.0
sam_grove 0:9d1e3a344e4f 6 * @see http://cache.freescale.com/files/sensors/doc/data_sheet/MMA8451Q.pdf
sam_grove 0:9d1e3a344e4f 7 * @see http://cache.freescale.com/files/sensors/doc/data_sheet/MMA8452Q.pdf
sam_grove 0:9d1e3a344e4f 8 * @see http://cache.freescale.com/files/sensors/doc/data_sheet/MMA8453Q.pdf
sam_grove 0:9d1e3a344e4f 9 *
1994timmeh 2:555f8ba0c959 10 * Copyright (c) 2015
sam_grove 0:9d1e3a344e4f 11 *
sam_grove 0:9d1e3a344e4f 12 * Licensed under the Apache License, Version 2.0 (the "License");
sam_grove 0:9d1e3a344e4f 13 * you may not use this file except in compliance with the License.
sam_grove 0:9d1e3a344e4f 14 * You may obtain a copy of the License at
sam_grove 0:9d1e3a344e4f 15 *
sam_grove 0:9d1e3a344e4f 16 * http://www.apache.org/licenses/LICENSE-2.0
sam_grove 0:9d1e3a344e4f 17 *
sam_grove 0:9d1e3a344e4f 18 * Unless required by applicable law or agreed to in writing, software
sam_grove 0:9d1e3a344e4f 19 * distributed under the License is distributed on an "AS IS" BASIS,
sam_grove 0:9d1e3a344e4f 20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
sam_grove 0:9d1e3a344e4f 21 * See the License for the specific language governing permissions and
sam_grove 0:9d1e3a344e4f 22 * limitations under the License.
1994timmeh 2:555f8ba0c959 23 *
1994timmeh 2:555f8ba0c959 24 * 5/5/2015 Forked from https://developer.mbed.org/users/sam_grove/code/MMA845x/
1994timmeh 2:555f8ba0c959 25 *
1994timmeh 2:555f8ba0c959 26 * 6/20/2015 TAB Added setup functions and polling data capability. Also added RTOS calls
1994timmeh 2:555f8ba0c959 27 * TODO Still need to add interrupt support for other Accelerometer mode support
sam_grove 0:9d1e3a344e4f 28 */
sam_grove 0:9d1e3a344e4f 29
1994timmeh 2:555f8ba0c959 30 #include "MMA845x.h"
1994timmeh 2:555f8ba0c959 31 #include "mbed_debug.h"
1994timmeh 2:555f8ba0c959 32 #include "rtos.h"
1994timmeh 2:555f8ba0c959 33 #include "MTSLog.h"
sam_grove 0:9d1e3a344e4f 34
1994timmeh 2:555f8ba0c959 35 MMA845x::MMA845x(I2C &i2c, SA0 const i2c_addr, InterruptIn* int1, InterruptIn* int2)
sam_grove 0:9d1e3a344e4f 36 {
1994timmeh 2:555f8ba0c959 37 _i2c = &i2c;
1994timmeh 2:555f8ba0c959 38 _int1 = int1;
1994timmeh 2:555f8ba0c959 39 _int2 = int2;
sam_grove 0:9d1e3a344e4f 40
1994timmeh 2:555f8ba0c959 41 _i2c_addr = (0x1c | i2c_addr) << 1;
sam_grove 0:9d1e3a344e4f 42
1994timmeh 2:555f8ba0c959 43 MMA845x::init();
1994timmeh 2:555f8ba0c959 44
sam_grove 0:9d1e3a344e4f 45 return;
sam_grove 0:9d1e3a344e4f 46 }
sam_grove 0:9d1e3a344e4f 47
1994timmeh 2:555f8ba0c959 48 uint8_t MMA845x::init(void)
sam_grove 0:9d1e3a344e4f 49 {
1994timmeh 2:555f8ba0c959 50 uint8_t result = 0;
1994timmeh 2:555f8ba0c959 51 uint8_t i = 0;
1994timmeh 2:555f8ba0c959 52 char reg_val[1];
1994timmeh 2:555f8ba0c959 53
1994timmeh 2:555f8ba0c959 54 _i2c->frequency(100000);
1994timmeh 2:555f8ba0c959 55 _who_am_i = 0x00;
1994timmeh 2:555f8ba0c959 56
1994timmeh 2:555f8ba0c959 57 // Reset all registers to POR values
1994timmeh 2:555f8ba0c959 58 result = MMA845x::writeRegister(CTRL_REG2, 0xFF); //REG 0x2B
1994timmeh 2:555f8ba0c959 59 if (result == 0) {
1994timmeh 2:555f8ba0c959 60
1994timmeh 2:555f8ba0c959 61 do {
1994timmeh 2:555f8ba0c959 62 // wait for the reset bit to clear. readRegister may error out so we re-try 10 times
1994timmeh 2:555f8ba0c959 63 osDelay(200);
1994timmeh 2:555f8ba0c959 64 reg_val[0] = 0x40;
1994timmeh 2:555f8ba0c959 65 result = MMA845x::readRegister(CTRL_REG2,1,reg_val);
1994timmeh 2:555f8ba0c959 66 reg_val[0] = reg_val[0] & 0x40;
1994timmeh 2:555f8ba0c959 67 i++;
1994timmeh 2:555f8ba0c959 68 } while(((reg_val[0] != 0)||( result != 0)) && (i<=10));
1994timmeh 2:555f8ba0c959 69 }
1994timmeh 2:555f8ba0c959 70
1994timmeh 2:555f8ba0c959 71 if (result == 0) {
1994timmeh 2:555f8ba0c959 72 result = MMA845x::readRegister(WHO_AM_I,1,reg_val);
1994timmeh 2:555f8ba0c959 73 }
1994timmeh 2:555f8ba0c959 74
1994timmeh 2:555f8ba0c959 75 switch (reg_val[0]) {
1994timmeh 2:555f8ba0c959 76 case MMA8451:
1994timmeh 2:555f8ba0c959 77 case MMA8452:
1994timmeh 2:555f8ba0c959 78 case MMA8453:
1994timmeh 2:555f8ba0c959 79 _who_am_i= reg_val[0];
1994timmeh 2:555f8ba0c959 80 if ((_int1 == NULL) && (_int2 == NULL))
1994timmeh 2:555f8ba0c959 81 _polling_mode = true;
1994timmeh 2:555f8ba0c959 82 else _polling_mode = false;
1994timmeh 2:555f8ba0c959 83 break;
1994timmeh 2:555f8ba0c959 84 default:
1994timmeh 2:555f8ba0c959 85 debug ("Device not supported by this library!\n\r");
1994timmeh 2:555f8ba0c959 86 result = 1;
1994timmeh 2:555f8ba0c959 87 }
1994timmeh 2:555f8ba0c959 88
1994timmeh 2:555f8ba0c959 89 if(result != 0) {
1994timmeh 2:555f8ba0c959 90 debug("MMA845x:init failed\n\r");
sam_grove 0:9d1e3a344e4f 91 }
1994timmeh 2:555f8ba0c959 92
1994timmeh 2:555f8ba0c959 93
1994timmeh 2:555f8ba0c959 94 return result;
1994timmeh 2:555f8ba0c959 95 }
1994timmeh 2:555f8ba0c959 96
1994timmeh 2:555f8ba0c959 97 uint8_t MMA845x::setCommonParameters(RANGE range, RESOLUTION resolution, LOW_NOISE lo_noise,
1994timmeh 2:555f8ba0c959 98 DATA_RATE data_rate, OVERSAMPLE_MODE os_mode, HPF_MODE hpf_mode) const
1994timmeh 2:555f8ba0c959 99 {
1994timmeh 2:555f8ba0c959 100 uint8_t result = 0;
1994timmeh 2:555f8ba0c959 101 char datain[1];
1994timmeh 2:555f8ba0c959 102 uint8_t dataout = 0;
1994timmeh 2:555f8ba0c959 103
1994timmeh 2:555f8ba0c959 104 result |= MMA845x::readRegister(SYSMOD,1,datain); // Make sure MMA845x is in Stand-By mode
1994timmeh 2:555f8ba0c959 105 if ((datain[0] & 0x03) != 0 ) {
1994timmeh 2:555f8ba0c959 106 debug ("MMA845x not in STAND BY mode\n\f");
1994timmeh 2:555f8ba0c959 107 debug("MMA845x:setCommonParameters failed\n\r");
1994timmeh 2:555f8ba0c959 108 result = 1;
1994timmeh 2:555f8ba0c959 109 return result;
1994timmeh 2:555f8ba0c959 110 }
1994timmeh 2:555f8ba0c959 111
1994timmeh 2:555f8ba0c959 112 result |= MMA845x::readRegister(CTRL_REG1, 1, datain);
1994timmeh 2:555f8ba0c959 113 dataout = (datain[0] & 0xB1) | resolution | lo_noise | data_rate;
1994timmeh 2:555f8ba0c959 114 result |= MMA845x::writeRegister(CTRL_REG1, dataout); // Set resolution, Low Noise mode, and data rate
1994timmeh 2:555f8ba0c959 115
1994timmeh 2:555f8ba0c959 116 result |= MMA845x::readRegister(CTRL_REG2,1, datain);
1994timmeh 2:555f8ba0c959 117 dataout = (datain[0] & 0xFB) | os_mode;
1994timmeh 2:555f8ba0c959 118 result |= MMA845x::writeRegister(CTRL_REG2, dataout); // Set Oversample mode
1994timmeh 2:555f8ba0c959 119
1994timmeh 2:555f8ba0c959 120 result |= MMA845x::readRegister(XYZ_DATA_CFG,1, datain);
1994timmeh 2:555f8ba0c959 121 dataout = range | hpf_mode;
1994timmeh 2:555f8ba0c959 122 result |= MMA845x::writeRegister(XYZ_DATA_CFG, dataout); //Set HPF mode and range
1994timmeh 2:555f8ba0c959 123
1994timmeh 2:555f8ba0c959 124 // result |= MMA845x::readRegister(HP_FILTER_CUTOFF,1, datain);
1994timmeh 2:555f8ba0c959 125 // result |= MMA845x::writeRegister(HP_FILTER_CUTOFF, dataout); //REG 0xF HPF settings
1994timmeh 2:555f8ba0c959 126
1994timmeh 2:555f8ba0c959 127 if(result != 0) {
1994timmeh 2:555f8ba0c959 128 debug("MMA845x:setParameters failed\n\r");
1994timmeh 2:555f8ba0c959 129 }
1994timmeh 2:555f8ba0c959 130
1994timmeh 2:555f8ba0c959 131 return result;
1994timmeh 2:555f8ba0c959 132
1994timmeh 2:555f8ba0c959 133 }
1994timmeh 2:555f8ba0c959 134
1994timmeh 2:555f8ba0c959 135 uint8_t MMA845x::enableMotionDetect(void) const
1994timmeh 2:555f8ba0c959 136 {
1994timmeh 2:555f8ba0c959 137 uint8_t result = 0;
1994timmeh 2:555f8ba0c959 138 return result;
1994timmeh 2:555f8ba0c959 139 }
1994timmeh 2:555f8ba0c959 140
1994timmeh 2:555f8ba0c959 141 uint8_t MMA845x::enablePulseDetect(void) const
1994timmeh 2:555f8ba0c959 142 {
1994timmeh 2:555f8ba0c959 143 uint8_t result = 0;
1994timmeh 2:555f8ba0c959 144 return result;
sam_grove 0:9d1e3a344e4f 145 }
sam_grove 0:9d1e3a344e4f 146
1994timmeh 2:555f8ba0c959 147 uint8_t MMA845x::enableOrientationDetect(void) const
1994timmeh 2:555f8ba0c959 148 {
1994timmeh 2:555f8ba0c959 149 uint8_t result = 0;
1994timmeh 2:555f8ba0c959 150
1994timmeh 2:555f8ba0c959 151 if(_who_am_i != MMA8451) {
1994timmeh 2:555f8ba0c959 152 debug("%s %d: Feature not compatible with the connected device.\n", __FILE__, __LINE__);
1994timmeh 2:555f8ba0c959 153 result = 1;
1994timmeh 2:555f8ba0c959 154 }
1994timmeh 2:555f8ba0c959 155
1994timmeh 2:555f8ba0c959 156 return result;
1994timmeh 2:555f8ba0c959 157 }
1994timmeh 2:555f8ba0c959 158
1994timmeh 2:555f8ba0c959 159 uint8_t MMA845x::enableTransientDetect(void) const
1994timmeh 2:555f8ba0c959 160 {
1994timmeh 2:555f8ba0c959 161 uint8_t result = 0;
1994timmeh 2:555f8ba0c959 162 return result;
1994timmeh 2:555f8ba0c959 163 }
1994timmeh 2:555f8ba0c959 164
1994timmeh 2:555f8ba0c959 165 uint8_t MMA845x::enableAutoSleep(void) const
sam_grove 0:9d1e3a344e4f 166 {
1994timmeh 2:555f8ba0c959 167 uint8_t result = 0;
1994timmeh 2:555f8ba0c959 168 return result;
1994timmeh 2:555f8ba0c959 169 }
1994timmeh 2:555f8ba0c959 170
1994timmeh 2:555f8ba0c959 171 uint8_t MMA845x::enableFIFO(void) const
1994timmeh 2:555f8ba0c959 172 {
1994timmeh 2:555f8ba0c959 173 uint8_t result = 0;
1994timmeh 2:555f8ba0c959 174
1994timmeh 2:555f8ba0c959 175 if(_who_am_i != MMA8451) {
1994timmeh 2:555f8ba0c959 176 debug("%s %d: Feature not compatible with the connected device.\n", __FILE__, __LINE__);
1994timmeh 2:555f8ba0c959 177 result = 1;
1994timmeh 2:555f8ba0c959 178 }
1994timmeh 2:555f8ba0c959 179
1994timmeh 2:555f8ba0c959 180 return result;
1994timmeh 2:555f8ba0c959 181 }
1994timmeh 2:555f8ba0c959 182
1994timmeh 2:555f8ba0c959 183 uint8_t MMA845x::activeMode(void) const
1994timmeh 2:555f8ba0c959 184 {
1994timmeh 2:555f8ba0c959 185 uint8_t result = 0;
1994timmeh 2:555f8ba0c959 186 char datain[1];
1994timmeh 2:555f8ba0c959 187 uint8_t dataout;
1994timmeh 2:555f8ba0c959 188
1994timmeh 2:555f8ba0c959 189 result |= MMA845x::readRegister(CTRL_REG1,1, datain);
1994timmeh 2:555f8ba0c959 190 dataout = (datain[0] & 0xFE) | 0x01 ;
1994timmeh 2:555f8ba0c959 191 result |= MMA845x::writeRegister(CTRL_REG1, dataout); // Set to active mode
1994timmeh 2:555f8ba0c959 192
1994timmeh 2:555f8ba0c959 193 return result;
sam_grove 0:9d1e3a344e4f 194 }
1994timmeh 2:555f8ba0c959 195 uint8_t MMA845x::standbyMode(void) const
1994timmeh 2:555f8ba0c959 196 {
1994timmeh 2:555f8ba0c959 197 uint8_t result = 0;
1994timmeh 2:555f8ba0c959 198 char datain[1];
1994timmeh 2:555f8ba0c959 199 uint8_t dataout;
1994timmeh 2:555f8ba0c959 200
1994timmeh 2:555f8ba0c959 201 result |= MMA845x::readRegister(CTRL_REG1,1, datain);
1994timmeh 2:555f8ba0c959 202 dataout = (datain[0] & 0xFE);
1994timmeh 2:555f8ba0c959 203 result |= MMA845x::writeRegister(CTRL_REG1, dataout); // Set to standby mode
1994timmeh 2:555f8ba0c959 204
1994timmeh 2:555f8ba0c959 205 return result;
1994timmeh 2:555f8ba0c959 206 }
1994timmeh 2:555f8ba0c959 207
1994timmeh 2:555f8ba0c959 208 uint8_t MMA845x::getStatus(void) const
sam_grove 0:9d1e3a344e4f 209 {
1994timmeh 2:555f8ba0c959 210 uint8_t result = 0;
1994timmeh 2:555f8ba0c959 211 char datain[1];
1994timmeh 2:555f8ba0c959 212 uint8_t dataout;
1994timmeh 2:555f8ba0c959 213
1994timmeh 2:555f8ba0c959 214 result = MMA845x::readRegister(STATUS,1, datain);
1994timmeh 2:555f8ba0c959 215
1994timmeh 2:555f8ba0c959 216 if (result != 0)
1994timmeh 2:555f8ba0c959 217 dataout = result;
1994timmeh 2:555f8ba0c959 218 else
1994timmeh 2:555f8ba0c959 219 dataout = datain[0];
1994timmeh 2:555f8ba0c959 220
1994timmeh 2:555f8ba0c959 221 return dataout;
1994timmeh 2:555f8ba0c959 222 }
1994timmeh 2:555f8ba0c959 223
1994timmeh 2:555f8ba0c959 224 int16_t MMA845x::getX(void)
1994timmeh 2:555f8ba0c959 225 {
1994timmeh 2:555f8ba0c959 226 char datain[2];
1994timmeh 2:555f8ba0c959 227
1994timmeh 2:555f8ba0c959 228 if (_polling_mode) {
1994timmeh 2:555f8ba0c959 229 MMA845x::readRegister(OUT_X_MSB,2, datain);
1994timmeh 2:555f8ba0c959 230 _data._x = ((datain[0] << 8) | datain[1]); /* data is 14 bit signed with 2 LSB = 0 */
1994timmeh 2:555f8ba0c959 231 _data._x /= 4; /* need to shift first to preserve sign then /4 to remove LSBs */
1994timmeh 2:555f8ba0c959 232 }
1994timmeh 2:555f8ba0c959 233 return _data._x;
1994timmeh 2:555f8ba0c959 234
1994timmeh 2:555f8ba0c959 235 }
1994timmeh 2:555f8ba0c959 236
1994timmeh 2:555f8ba0c959 237 int16_t MMA845x::getY(void)
1994timmeh 2:555f8ba0c959 238 {
1994timmeh 2:555f8ba0c959 239 char datain[2];
1994timmeh 2:555f8ba0c959 240
1994timmeh 2:555f8ba0c959 241 if (_polling_mode) {
1994timmeh 2:555f8ba0c959 242 MMA845x::readRegister(OUT_Y_MSB,2, datain);
1994timmeh 2:555f8ba0c959 243 _data._y = ((datain[0] << 8) | datain[1]); /* data is 14 bit signed with 2 LSB = 0 */
1994timmeh 2:555f8ba0c959 244 _data._y /= 4; /* need to shift first to preserve sign then /4 to remove LSBs */
1994timmeh 2:555f8ba0c959 245 }
sam_grove 0:9d1e3a344e4f 246 return _data._y;
sam_grove 0:9d1e3a344e4f 247 }
sam_grove 0:9d1e3a344e4f 248
1994timmeh 2:555f8ba0c959 249 int16_t MMA845x::getZ(void)
sam_grove 0:9d1e3a344e4f 250 {
1994timmeh 2:555f8ba0c959 251 char datain[2];
1994timmeh 2:555f8ba0c959 252
1994timmeh 2:555f8ba0c959 253 if (_polling_mode) {
1994timmeh 2:555f8ba0c959 254 MMA845x::readRegister(OUT_Z_MSB,2, datain);
1994timmeh 2:555f8ba0c959 255 _data._z = ((datain[0] << 8) | datain[1]); /* data is 14 bit signed with 2 LSB = 0 */
1994timmeh 2:555f8ba0c959 256 _data._z /= 4; /* need to shift first to preserve sign then /4 to remove LSBs */
1994timmeh 2:555f8ba0c959 257 }
1994timmeh 2:555f8ba0c959 258
sam_grove 0:9d1e3a344e4f 259 return _data._z;
sam_grove 0:9d1e3a344e4f 260 }
1994timmeh 2:555f8ba0c959 261
1994timmeh 2:555f8ba0c959 262 MMA845x_DATA MMA845x::getXYZ(void)
sam_grove 0:9d1e3a344e4f 263 {
1994timmeh 2:555f8ba0c959 264 char datain[6];
1994timmeh 2:555f8ba0c959 265
1994timmeh 2:555f8ba0c959 266 if (_polling_mode) {
1994timmeh 2:555f8ba0c959 267 MMA845x::readRegister(OUT_X_MSB,6, datain); /* data is 14 bit signed with 2 LSB = 0 */
1994timmeh 2:555f8ba0c959 268 _data._x = ((datain[0] << 8) | datain[1]); /* need to shift first to preserve sign */
1994timmeh 2:555f8ba0c959 269 _data._x /= 4; /* then /4 to remove LSBs */
1994timmeh 2:555f8ba0c959 270 _data._y = ((datain[2] << 8) | datain[3]);
1994timmeh 2:555f8ba0c959 271 _data._y /= 4;
1994timmeh 2:555f8ba0c959 272 _data._z = ((datain[4] << 8) | datain[5]);
1994timmeh 2:555f8ba0c959 273 _data._z /= 4;
1994timmeh 2:555f8ba0c959 274 } else {
1994timmeh 2:555f8ba0c959 275 logInfo("NOT POLLING MODE\n\r");
1994timmeh 2:555f8ba0c959 276 }
1994timmeh 2:555f8ba0c959 277
sam_grove 0:9d1e3a344e4f 278 return _data;
sam_grove 0:9d1e3a344e4f 279 }
sam_grove 0:9d1e3a344e4f 280
1994timmeh 2:555f8ba0c959 281 char MMA845x::getWhoAmI(void) const
1994timmeh 2:555f8ba0c959 282 {
1994timmeh 2:555f8ba0c959 283 return _who_am_i;
1994timmeh 2:555f8ba0c959 284 }
1994timmeh 2:555f8ba0c959 285
1994timmeh 2:555f8ba0c959 286 uint8_t MMA845x::writeRegister(uint8_t const reg, uint8_t const data) const
sam_grove 0:9d1e3a344e4f 287 {
sam_grove 0:9d1e3a344e4f 288 char buf[2] = {reg, data};
sam_grove 0:9d1e3a344e4f 289 uint8_t result = 0;
1994timmeh 2:555f8ba0c959 290
1994timmeh 2:555f8ba0c959 291 buf[0] = reg;
1994timmeh 2:555f8ba0c959 292 buf[1] = data;
1994timmeh 2:555f8ba0c959 293
1994timmeh 2:555f8ba0c959 294 result |= _i2c->write(_i2c_addr, buf, 2);
1994timmeh 2:555f8ba0c959 295
1994timmeh 2:555f8ba0c959 296 if(result != 0) {
1994timmeh 2:555f8ba0c959 297 debug("MMA845x:writeRegister failed r-%d\n\r",result);
sam_grove 0:9d1e3a344e4f 298 }
1994timmeh 2:555f8ba0c959 299
1994timmeh 2:555f8ba0c959 300 return result;
sam_grove 0:9d1e3a344e4f 301 }
sam_grove 0:9d1e3a344e4f 302
1994timmeh 2:555f8ba0c959 303 uint8_t MMA845x::readRegister(uint8_t const reg, uint8_t count, char* data) const
sam_grove 0:9d1e3a344e4f 304 {
1994timmeh 2:555f8ba0c959 305 uint8_t result = 0;
1994timmeh 2:555f8ba0c959 306 char reg_out[1];
1994timmeh 2:555f8ba0c959 307
1994timmeh 2:555f8ba0c959 308 reg_out[0] = reg;
1994timmeh 2:555f8ba0c959 309 result |= _i2c->write(_i2c_addr,reg_out,1,true);
1994timmeh 2:555f8ba0c959 310
1994timmeh 2:555f8ba0c959 311 if(result != 0) {
1994timmeh 2:555f8ba0c959 312 debug("MMA845x::readRegister failed write r- %d\n\r", result);
1994timmeh 2:555f8ba0c959 313 return result;
sam_grove 0:9d1e3a344e4f 314 }
1994timmeh 2:555f8ba0c959 315
1994timmeh 2:555f8ba0c959 316 result |= _i2c->read(_i2c_addr,data,count,false);
sam_grove 0:9d1e3a344e4f 317
1994timmeh 2:555f8ba0c959 318 if(result != 0) {
1994timmeh 2:555f8ba0c959 319 debug("MMA845x::readRegister failed read r-%d\n\r",result);
sam_grove 0:9d1e3a344e4f 320 }
1994timmeh 2:555f8ba0c959 321
1994timmeh 2:555f8ba0c959 322 return result;
sam_grove 0:9d1e3a344e4f 323 }