program test MPU6050
Dependents: ticker_test_mpu6050
Fork of MPU6050 by
Diff: MPU6050.cpp
- Revision:
- 3:09293fbaf92b
- Parent:
- 1:a3366f09e95c
- Child:
- 4:4926b02b5eab
--- a/MPU6050.cpp Mon Sep 10 21:26:25 2012 +0000 +++ b/MPU6050.cpp Tue Feb 17 18:29:16 2015 +0000 @@ -47,7 +47,25 @@ bool MPU6050::testConnection( void ) { char temp; - temp = this->read(MPU6050_WHO_AM_I_REG); + int i,isOK=1; + char data; + bool isFindSlave=false; + printf("test I2C\n\r"); + for(i=1;i<127;i++) + { wait(0.01); + isOK=connection.read(i*2,&data,1,false); + if(isOK==0){ + printf("slave I2C find : 0X%X\n\r",i); + isFindSlave=true; + } + + } + if(isFindSlave){ + temp = this->read(MPU6050_WHO_AM_I_REG); + printf(" WHO AM I : 0X%X\n\r",temp); + } + else + temp=1; return (temp == (MPU6050_ADDRESS & 0xFE)); }