motion library for mpu6050, mpu9250 and etc, supports i2c and spi
mpu_mbed_config.h@0:814475fdc553, 2016-07-05 (annotated)
- Committer:
- yihui
- Date:
- Tue Jul 05 07:19:59 2016 +0000
- Revision:
- 0:814475fdc553
initial
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yihui | 0:814475fdc553 | 1 | |
yihui | 0:814475fdc553 | 2 | |
yihui | 0:814475fdc553 | 3 | #ifndef _MPU_MBED_CONFIG_H_ |
yihui | 0:814475fdc553 | 4 | #define _MPU_MBED_CONFIG_H_ |
yihui | 0:814475fdc553 | 5 | |
yihui | 0:814475fdc553 | 6 | #include "wait_api.h" |
yihui | 0:814475fdc553 | 7 | #include "us_ticker_api.h" |
yihui | 0:814475fdc553 | 8 | |
yihui | 0:814475fdc553 | 9 | //#define MPU_USE_I2C |
yihui | 0:814475fdc553 | 10 | #define MPU_USE_SPI |
yihui | 0:814475fdc553 | 11 | |
yihui | 0:814475fdc553 | 12 | #define MPU9250 |
yihui | 0:814475fdc553 | 13 | //#define MPU6050 |
yihui | 0:814475fdc553 | 14 | |
yihui | 0:814475fdc553 | 15 | #ifdef MPU_USE_I2C |
yihui | 0:814475fdc553 | 16 | #include "mbed_i2c.h" |
yihui | 0:814475fdc553 | 17 | #define mpu_hal_write(a, b, c, d) mbed_i2c_write(a, b, c, d) |
yihui | 0:814475fdc553 | 18 | #define mpu_hal_read(a, b, c, d) mbed_i2c_read(a, b, c, d) |
yihui | 0:814475fdc553 | 19 | |
yihui | 0:814475fdc553 | 20 | #else // MPU_USE_SPI |
yihui | 0:814475fdc553 | 21 | #include "mbed_spi.h" |
yihui | 0:814475fdc553 | 22 | #define mpu_hal_write(a, b, c, d) mbed_spi_write(b, c, d) |
yihui | 0:814475fdc553 | 23 | #define mpu_hal_read(a, b, c, d) mbed_spi_read(b, c, d) |
yihui | 0:814475fdc553 | 24 | |
yihui | 0:814475fdc553 | 25 | #endif |
yihui | 0:814475fdc553 | 26 | |
yihui | 0:814475fdc553 | 27 | #define __no_operation __nop |
yihui | 0:814475fdc553 | 28 | #define delay_ms wait_ms |
yihui | 0:814475fdc553 | 29 | #define log_i(args...) //printf(args) |
yihui | 0:814475fdc553 | 30 | #define log_e(args...) //printf(args) |
yihui | 0:814475fdc553 | 31 | #define labs abs |
yihui | 0:814475fdc553 | 32 | #define fabs(x) (((x)>0)?(x):-(x)) |
yihui | 0:814475fdc553 | 33 | #define min(x, y) (((x) < (y)) ? (x) : (y)) |
yihui | 0:814475fdc553 | 34 | |
yihui | 0:814475fdc553 | 35 | static inline unsigned long get_ms(unsigned long *t) |
yihui | 0:814475fdc553 | 36 | { |
yihui | 0:814475fdc553 | 37 | unsigned long ms = us_ticker_read() / 1000; |
yihui | 0:814475fdc553 | 38 | *t = ms; |
yihui | 0:814475fdc553 | 39 | return ms; |
yihui | 0:814475fdc553 | 40 | } |
yihui | 0:814475fdc553 | 41 | static inline int reg_int_cb(struct int_param_s *int_param) |
yihui | 0:814475fdc553 | 42 | { |
yihui | 0:814475fdc553 | 43 | return 0; |
yihui | 0:814475fdc553 | 44 | } |
yihui | 0:814475fdc553 | 45 | |
yihui | 0:814475fdc553 | 46 | #endif // _MPU_MBED_CONFIG_H_ |