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:
- 1:a6c3f8680fe0
- Child:
- 2:e7e761471df9
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mdcompat.cpp Mon Aug 07 13:49:51 2017 +0000 @@ -0,0 +1,71 @@ +#include "mdcompat.h" +#include "mbed.h" // must be out of the scope of extern "C" +I2C imu9250(PB_7,PB_6); + +void imu_init(void){ +imu9250.frequency(400000); +} +unsigned short constrain( + unsigned short x, + unsigned short a, + unsigned short b) {unsigned short result; + result= (x<a) ? a:x; + result= (x>b) ? b:x; + return result; +} + +extern "C" { + +int mbed_i2c_write( + unsigned char slave_addr, + unsigned char reg_addr, + unsigned char length, + char const *data) { + + imu9250.write((int)slave_addr,(char const*)reg_addr,1,true);//sending register adress first to indicate which register we are writing and a write register(0) + imu9250.write((int)slave_addr,data,(int)length,false); + + return 0; +} + +int mbed_i2c_read( + unsigned char slave_addr, + unsigned char reg_addr, + unsigned char length, + char *data) { + + imu9250.write((int)slave_addr,(char const*)reg_addr,1,true);//sending register adress first to indicate which register we are writing and a write register(0) + imu9250.read((int)slave_addr,data,(int)length,false); + return 0; +} + +int delay_ms( + unsigned long num_ms) { + return 0; +} + +int get_ms( + unsigned long *count) { + return 0; +} + +int reg_int_cb( + void (*cb)(void), + unsigned char port, + unsigned char pin) { + return 0; +} + +long labs(long x) { + return x > 0 ? x : -x; +} + +float fabsf(float x) { + return x > 0 ? x : -x; +} + +int min(int a, int b) { + return a > b ? b : a; +} + +};