It is modified accordingly to work with sparkfun dmp library under mbed platform
Dependents: MPU9250-dmp-bluepill MPU9250-dmp
Fork of MotionDriver_6_1 by
Diff: mdcompat.cpp
- Revision:
- 4:f395d9cc57c4
- Parent:
- 3:8f2d21735748
- Child:
- 5:e4e36c17ba70
--- a/mdcompat.cpp Tue Aug 08 14:14:26 2017 +0000 +++ b/mdcompat.cpp Thu Aug 10 14:42:44 2017 +0000 @@ -1,7 +1,14 @@ #include "mdcompat.h" #include "mbed.h" // must be out of the scope of extern "C" I2C imu9250(I2C_SDA,I2C_SCL); - +Ticker stamper; +unsigned long stamper_count=0; +void counter(){ + stamper_count++; +} +void stamper_init(void){ +stamper.attach(&counter,1); +} void imu_init(void){ imu9250.frequency(400000); } @@ -20,11 +27,11 @@ unsigned char slave_addr, unsigned char reg_addr, unsigned char length, - char const *data) {const char RA[]={reg_addr}; - - imu9250.write((int)slave_addr<<1,RA,1,1);//sending register adress first to indicate which register we are writing and a write register(0) - imu9250.write((int)slave_addr<<1,data,(int)length,0); + unsigned char *data) { + unsigned char buffer[]={reg_addr,data[0]}; + 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) return 0; } @@ -32,19 +39,21 @@ unsigned char slave_addr, unsigned char reg_addr, unsigned char length, - char *data) {const char RA[]={reg_addr}; + unsigned char *data) {const char RA[]={reg_addr}; imu9250.write((int)slave_addr<<1,RA, 1, 1); // no stop - imu9250.read((int)slave_addr<<1, data, 1, 0); + imu9250.read((int)slave_addr<<1,(char*)data, 1, 0); return 0; } int delay_ms( unsigned long num_ms) { + wait_ms(num_ms); return 0; } int get_ms( - unsigned long *count) { + unsigned long *count=(unsigned long*)malloc(sizeof(unsigned long))) { + *count=stamper_count; return 0; }