Working on readReg
Fork of MPL3115A2 by
Diff: MPL3115.cpp
- Revision:
- 3:641510862795
- Parent:
- 2:c705222de18d
diff -r c705222de18d -r 641510862795 MPL3115.cpp --- a/MPL3115.cpp Wed Apr 26 00:10:29 2017 +0000 +++ b/MPL3115.cpp Tue Feb 27 15:56:28 2018 +0000 @@ -50,7 +50,33 @@ } + int MPL3115::readReg(int address) { + int length = 8; + char d[1]; + char readData[length]; + + d[0] = MPL3115_STATUS; + MPL3115_i2c.write(MPL3115_I2C_ADDRESS,d,1,true); + MPL3115_i2c.read(MPL3115_I2C_ADDRESS,readData,length); + for (int i = 0; i < length; i++) { + if (readData[i]) { + printf("The readData of %d is 1\r\n",i); + } else { + printf("The readData of %d is 0\r\n",i); + } + } + + //printf("The readData is : %s\r\n", readData); + int returnValue = 0; + for (int i = 0; i < length; i++) { + returnValue << readData[i]; + } + + return returnValue; + +} + void MPL3115::acquire_MPL3115_data_Altitude_in_m(float * alt_data) {