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.
Dependents: MPU9250-dmp-bluepill MPU9250-dmp
Fork of MotionDriver_6_1 by
Revision 5:e4e36c17ba70, committed 2017-08-11
- Comitter:
- mbedoguz
- Date:
- Fri Aug 11 07:42:24 2017 +0000
- Parent:
- 4:f395d9cc57c4
- Child:
- 6:7469a85601f1
- Commit message:
- mbedcompat is updated.; mbed_i2c_write and mbed_i2c_read functions are all fixed and working.;
Changed in this revision
| mdcompat.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/mdcompat.cpp Thu Aug 10 14:42:44 2017 +0000
+++ b/mdcompat.cpp Fri Aug 11 07:42:24 2017 +0000
@@ -28,10 +28,15 @@
unsigned char reg_addr,
unsigned char length,
unsigned char *data) {
- unsigned char buffer[]={reg_addr,data[0]};
+
+ unsigned char buffer[length+1];
+ buffer[0]=reg_addr;
+ for(int i=0;i<length;i++){
+ buffer[i+1]=data[i];
+ }
const char* x=(const char*)buffer;//
- imu9250.write((int)slave_addr<<1,x,2,0);//sending register adress first to indicate which register we are writing and a write register(0)
+ imu9250.write((int)slave_addr<<1,x,length+1,0);//sending register adress first to indicate which register we are writing and a write register(0)
return 0;
}
@@ -40,8 +45,12 @@
unsigned char reg_addr,
unsigned char length,
unsigned char *data) {const char RA[]={reg_addr};
+ unsigned char buffer[length];
+ for(int i=0;i<length;i++){
+ buffer[i]=data[i];
+ }
imu9250.write((int)slave_addr<<1,RA, 1, 1); // no stop
- imu9250.read((int)slave_addr<<1,(char*)data, 1, 0);
+ imu9250.read((int)slave_addr<<1,(char*)data, length, 0);
return 0;
}
