Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 3:3c0727618a3b, committed 2017-08-23
- Comitter:
- OsmanKameric
- Date:
- Wed Aug 23 17:25:27 2017 +0000
- Parent:
- 2:e2081d9de7af
- Child:
- 4:df70fe9d6635
- Commit message:
- First
Changed in this revision
--- a/I2Cdev.cpp Wed Feb 01 11:09:14 2017 +0000
+++ b/I2Cdev.cpp Wed Aug 23 17:25:27 2017 +0000
@@ -7,12 +7,12 @@
#define useDebugSerial
-I2Cdev::I2Cdev(): debugSerial(p6, p8), i2c(p26,p27)
+I2Cdev::I2Cdev(): i2c(p26,p27)
{
}
-I2Cdev::I2Cdev(PinName p26, PinName p27): debugSerial(p30, p31), i2c(p26,p27)
+I2Cdev::I2Cdev(PinName p26, PinName p27): i2c(p26,p27)
{
}
@@ -248,7 +248,7 @@
data_write[0]=regAddr; // I2C sends MSB first. Namely >>|subAddress|>>|data|
data_write[1]=data;
i2c.write(devAddr,data_write,2,0); // i2c.write(int address, char* data, int length, bool repeated=false);
- //return writeBytes(devAddr, regAddr, 1, &data);
+ return writeBytes(devAddr, regAddr, 1, &data);
return true;
}
@@ -265,11 +265,11 @@
bool I2Cdev::writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data)
{
i2c.start();
- //i2c.write(devAddr<<1);
- //i2c.write(regAddr);
- //for(int i = 0; i < length; i++) {
- // i2c.write(data[i]);
- //}
+ i2c.write(devAddr<<1);
+ i2c.write(regAddr);
+ for(int i = 0; i < length; i++) {
+ i2c.write(data[i]);
+ }
//i2c.write(devAddr, regAddr, )
i2c.stop();
return true;
--- a/I2Cdev.h Wed Feb 01 11:09:14 2017 +0000
+++ b/I2Cdev.h Wed Aug 23 17:25:27 2017 +0000
@@ -11,11 +11,11 @@
#define I2C_SDA p26
#define I2C_SCL p27
-extern Serial pc;
+//extern Serial pc;
class I2Cdev {
private:
I2C i2c;
- Serial debugSerial;
+ //Serial debugSerial;
public:
I2Cdev();
I2Cdev(PinName i2cSda, PinName i2cScl);
--- a/MPU6050.cpp Wed Feb 01 11:09:14 2017 +0000
+++ b/MPU6050.cpp Wed Aug 23 17:25:27 2017 +0000
@@ -62,9 +62,13 @@
float aRes;
float gRes;
int Ascale = AFS_2G;
+
+//int16_t ax,ay,az;
+//int16_t gx,gy,gz;
+
float ax,ay,az;
-float gx,gy,gz;
-#define useDebugSerial
+float gx,gy,gz;
+//#define useDebugSerial
//instead of using pgmspace.h
typedef const unsigned char prog_uchar;
@@ -74,7 +78,7 @@
/** Default constructor, uses default I2C address.
* @see MPU6050_DEFAULT_ADDRESS
*/
-MPU6050::MPU6050() : debugSerial(p30, p31)
+MPU6050::MPU6050()
{
devAddr = MPU6050_DEFAULT_ADDRESS;
}
@@ -85,7 +89,7 @@
* @see MPU6050_ADDRESS_AD0_LOW
* @see MPU6050_ADDRESS_AD0_HIGH
*/
-MPU6050::MPU6050(uint8_t address) : debugSerial(p30, p31)
+MPU6050::MPU6050(uint8_t address)
{
devAddr = address;
}
@@ -138,6 +142,7 @@
setFullScaleGyroRange(MPU6050_GYRO_FS_250);
setFullScaleAccelRange(MPU6050_ACCEL_FS_2);
setSleepEnabled(false); // thanks to Jack Elston for pointing this one out!
+
#ifdef useDebugSerial
debugSerial.printf("MPU6050::initialize end\n");
--- a/MPU6050.h Wed Feb 01 11:09:14 2017 +0000
+++ b/MPU6050.h Wed Aug 23 17:25:27 2017 +0000
@@ -416,8 +416,13 @@
//extern DigitalOut LED2;
/* Sensor datas to be used in program */
+
+//extern int16_t ax,ay,az;
+//extern int16_t gx,gy,gz;
+
extern float ax,ay,az;
extern float gx,gy,gz;
+
extern Serial pc;
extern int16_t accelData[3],gyroData[3],tempData;
extern float accelBias[3], gyroBias[3];
@@ -426,7 +431,7 @@
class MPU6050 {
private:
I2Cdev i2Cdev;
- Serial debugSerial;
+ //Serial debugSerial;
public:
MPU6050();
MPU6050(uint8_t address);