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 6:fe57b4405983, committed 2017-10-25
- Comitter:
- hardtail
- Date:
- Wed Oct 25 08:08:53 2017 +0000
- Parent:
- 5:7d1bf3ce0053
- Commit message:
- first commit
Changed in this revision
--- a/I2Cdev.cpp Sat Nov 23 16:47:00 2013 +0000
+++ b/I2Cdev.cpp Wed Oct 25 08:08:53 2017 +0000
@@ -5,7 +5,7 @@
#include "I2Cdev.h"
-#define useDebugSerial
+//#define useDebugSerial
I2Cdev::I2Cdev(): i2c(I2C_SDA,I2C_SCL), debugSerial(USBTX, USBRX)
{
@@ -254,14 +254,15 @@
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]);
+ char *writeData = (char*)malloc(length+1);
+ writeData[0] = regAddr;
+
+ for(int i=0; i<length ; i++){
+ writeData[i+1] = data[i];
}
- i2c.stop();
- return true;
+ int res = i2c.write(devAddr<<1, writeData, length+1, true);
+ free(writeData);
+ return res;
}
bool I2Cdev::writeWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data)
--- a/I2Cdev.h Sat Nov 23 16:47:00 2013 +0000
+++ b/I2Cdev.h Wed Oct 25 08:08:53 2017 +0000
@@ -9,8 +9,8 @@
#include "mbed.h"
-#define I2C_SDA p28
-#define I2C_SCL p27
+#define I2C_SDA P0_23
+#define I2C_SCL P0_22
class I2Cdev {
private:
--- a/MPU6050_6Axis_MotionApps20.h Sat Nov 23 16:47:00 2013 +0000
+++ b/MPU6050_6Axis_MotionApps20.h Wed Oct 25 08:08:53 2017 +0000
@@ -33,7 +33,7 @@
#ifndef _MPU6050_6AXIS_MOTIONAPPS20_H_
#define _MPU6050_6AXIS_MOTIONAPPS20_H_
-#include <iostream>
+//#include <iostream>
#include "I2Cdev.h"
#include "helper_3dmath.h"
@@ -305,7 +305,7 @@
0x07, 0x46, 0x01, 0x9A, // CFG_GYRO_SOURCE inv_send_gyro
0x07, 0x47, 0x04, 0xF1, 0x28, 0x30, 0x38, // CFG_9 inv_send_gyro -> inv_construct3_fifo
0x07, 0x6C, 0x04, 0xF1, 0x28, 0x30, 0x38, // CFG_12 inv_send_accel -> inv_construct3_fifo
- 0x02, 0x16, 0x02, 0x00, 0x01 // D_0_22 inv_set_fifo_rate
+ 0x02, 0x16, 0x02, 0x00, 0x00 // D_0_22 inv_set_fifo_rate
// This very last 0x01 WAS a 0x09, which drops the FIFO rate down to 20 Hz. 0x07 is 25 Hz,
// 0x01 is 100Hz. Going faster than 100Hz (0x00=200Hz) tends to result in very noisy data.