1.updata mbed os 5. 2.restore I2C SDA lock low.
Fork of MPU9150_DMP_Nucleo by
Diff: MPU9150.cpp
- Revision:
- 1:8ff0beb54dd4
- Parent:
- 0:74f0ae286b03
- Child:
- 2:e523a92390b6
diff -r 74f0ae286b03 -r 8ff0beb54dd4 MPU9150.cpp --- a/MPU9150.cpp Sun Aug 31 12:52:29 2014 +0000 +++ b/MPU9150.cpp Mon Sep 01 13:35:07 2014 +0000 @@ -67,32 +67,23 @@ reset(); wait_ms(20); sleep(false); - -//does this exist in the 9150? - char product[6] = {0,0,0,0,0,0}; - read(0x77, product, 6 ); - int rev = ((product[5] & 0x01) << 2) | ((product[3] & 0x01) << 1) | - (product[1] & 0x01); - debug.printf("%02X, %02X, %02X, %02X, %02X, %02X\r\n", product[0], product[1], product[2], product[3], product[4], product[5]); - debug.printf("Product Revision: %d\r\n", rev); - setMemoryBank(0x10, true, true); setMemoryStartAddress(0x06); - debug.printf("Hardware Version: %d\r\n", readMemoryByte()); +// debug.printf("Hardware Version: %d\r\n", readMemoryByte()); setMemoryBank(0); // check OTP bank valid uint8_t otpValid = getOTPBankValid(); - debug.printf("optValid: %d\r\n", otpValid); +// debug.printf("optValid: %d\r\n", otpValid); //Enabling interrupt latch, clear on any read, AUX bypass enabled write(MPU6050_RA_INT_PIN_CFG, 0x32); if (writeMemoryBlock(dmpMemory, MPU6050_DMP_CODE_SIZE, 0 ,0, true)) { - debug.printf("Success! DMP code written and verified.\r\n"); + // debug.printf("Success! DMP code written and verified.\r\n"); if (writeDMPConfigurationSet(dmpConfig, MPU6050_DMP_CONFIG_SIZE)) { - debug.printf("Success! DMP configuration written and verified.\r\n"); +// debug.printf("Success! DMP configuration written and verified.\r\n"); setIntDMPEnabled(true); setInterruptFifoOverflowEnable(true); setSampleRateDivider(4); @@ -208,7 +199,7 @@ setDMPEnabled(false); - debug.printf("finished\r\n"); + // debug.printf("finished\r\n"); } } @@ -609,10 +600,10 @@ // make sure this chunk doesn't go past the bank boundary (256 bytes) if (chunkSize > 256 - address) chunkSize = 256 - address; - debug.printf("reading %d", chunkSize); + //debug.printf("reading %d", chunkSize); // read the chunk of data as specified read(MPU6050_RA_MEM_R_W, (char*)(data+i), chunkSize); - debug.printf("read"); + //debug.printf("read"); // increase byte index by [chunkSize] i += chunkSize; @@ -658,7 +649,7 @@ read(MPU6050_RA_MEM_R_W, (char*)verifyBuffer, chunkSize); if (memcmp(progBuffer, verifyBuffer, chunkSize) != 0) { free(verifyBuffer); - debug.printf("invalid(%d, %d)\r\n", bank, read_errors, write_errors); + //debug.printf("invalid(%d, %d)\r\n", bank, read_errors, write_errors); return false; // uh oh. } } @@ -757,7 +748,7 @@ int16_t MPU9150::get16(char reg_addr){ char data[2]; - if(!read(reg_addr, data, 2))debug.printf("get16: read fail:%02X\r\n", reg_addr); + read(reg_addr, data, 2); return (data[0]<<8) + data[1]; } @@ -778,7 +769,7 @@ for(int i = 0; i < length; i++) { if(!i2c.write(data[i])){ write_errors++; - debug.printf("Write Error %d\r\n", reg_addr); + //debug.printf("Write Error %d\r\n", reg_addr); return false; } } @@ -814,12 +805,12 @@ bool MPU9150::read(char reg_addr, char* data, int length){ if(i2c.write(device_address << 1, ®_addr, 1, true)){ read_errors ++; - debug.printf("Read: Address Write Error %d\r\n", reg_addr); + //debug.printf("Read: Address Write Error %d\r\n", reg_addr); return false; } if(i2c.read(device_address << 1, data, length)){ read_errors ++; - debug.printf("Read: Error %d\r\n", reg_addr); + //debug.printf("Read: Error %d\r\n", reg_addr); return false; } return true;