library for MPU6050 and MPU9250, supports both I2C and SPI

Dependents:   Seeed_nRF51822_MPU9250

Committer:
yihui
Date:
Thu Dec 10 07:39:48 2015 +0000
Revision:
0:972f3778c19c
initial

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yihui 0:972f3778c19c 1
yihui 0:972f3778c19c 2
yihui 0:972f3778c19c 3 #ifndef _MPU_MBED_CONFIG_H_
yihui 0:972f3778c19c 4 #define _MPU_MBED_CONFIG_H_
yihui 0:972f3778c19c 5
yihui 0:972f3778c19c 6 #include "wait_api.h"
yihui 0:972f3778c19c 7 #include "us_ticker_api.h"
yihui 0:972f3778c19c 8
yihui 0:972f3778c19c 9 //#define MPU_USE_I2C
yihui 0:972f3778c19c 10 #define MPU_USE_SPI
yihui 0:972f3778c19c 11
yihui 0:972f3778c19c 12 #define MPU9250
yihui 0:972f3778c19c 13 //#define MPU6050
yihui 0:972f3778c19c 14
yihui 0:972f3778c19c 15 #ifdef MPU_USE_I2C
yihui 0:972f3778c19c 16 #include "mbed_i2c.h"
yihui 0:972f3778c19c 17 #define mpu_hal_write(a, b, c, d) mbed_i2c_write(a, b, c, d)
yihui 0:972f3778c19c 18 #define mpu_hal_read(a, b, c, d) mbed_i2c_read(a, b, c, d)
yihui 0:972f3778c19c 19
yihui 0:972f3778c19c 20 #else // MPU_USE_SPI
yihui 0:972f3778c19c 21 #include "mbed_spi.h"
yihui 0:972f3778c19c 22 #define mpu_hal_write(a, b, c, d) mbed_spi_write(b, c, d)
yihui 0:972f3778c19c 23 #define mpu_hal_read(a, b, c, d) mbed_spi_read(b, c, d)
yihui 0:972f3778c19c 24
yihui 0:972f3778c19c 25 #endif
yihui 0:972f3778c19c 26
yihui 0:972f3778c19c 27 #define __no_operation __nop
yihui 0:972f3778c19c 28 #define delay_ms wait_ms
yihui 0:972f3778c19c 29 #define log_i(args...) //printf(args)
yihui 0:972f3778c19c 30 #define log_e(args...) //printf(args)
yihui 0:972f3778c19c 31 #define labs abs
yihui 0:972f3778c19c 32 #define fabs(x) (((x)>0)?(x):-(x))
yihui 0:972f3778c19c 33 #define min(x, y) (((x) < (y)) ? (x) : (y))
yihui 0:972f3778c19c 34
yihui 0:972f3778c19c 35 static inline unsigned long get_ms(unsigned long *t)
yihui 0:972f3778c19c 36 {
yihui 0:972f3778c19c 37 unsigned long ms = us_ticker_read() / 1000;
yihui 0:972f3778c19c 38 *t = ms;
yihui 0:972f3778c19c 39 return ms;
yihui 0:972f3778c19c 40 }
yihui 0:972f3778c19c 41 static inline int reg_int_cb(struct int_param_s *int_param)
yihui 0:972f3778c19c 42 {
yihui 0:972f3778c19c 43 return 0;
yihui 0:972f3778c19c 44 }
yihui 0:972f3778c19c 45
yihui 0:972f3778c19c 46 #endif // _MPU_MBED_CONFIG_H_