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
mdcompat.cpp
- Committer:
- mbedoguz
- Date:
- 2017-08-08
- Revision:
- 3:8f2d21735748
- Parent:
- 2:e7e761471df9
- Child:
- 4:f395d9cc57c4
File content as of revision 3:8f2d21735748:
#include "mdcompat.h" #include "mbed.h" // must be out of the scope of extern "C" I2C imu9250(I2C_SDA,I2C_SCL); 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) {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); return 0; } int mbed_i2c_read( unsigned char slave_addr, unsigned char reg_addr, unsigned char length, 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); 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; } };