/*
$License:
Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved.
See included License.txt for License information.
$
*/
/**
* @addtogroup DRIVERS Sensor Driver Layer
* @brief Hardware drivers to communicate with sensors via I2C.
*
* @{
* @file inv_mpu.c
* @brief An I2C-based driver for Invensense gyroscopes.
* @details This driver currently works for the following devices:
* MPU6050
* MPU6500
* MPU9150 (or MPU6050 w/ AK8975 on the auxiliary bus)
* MPU9250 (or MPU6500 w/ AK8963 on the auxiliary bus)
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "inv_mpu_1.h"
#include "inv_mpu_dmp_motion_driver_1.h"
#include "mpu6050_1.h"
#include "delay.h"
#include "usart.h"
#define MPU6050 //定义我们使用的传感器为MPU6050
#define MOTION_DRIVER_TARGET_MSP430 //定义驱动部分,采用MSP430的驱动(移植到STM32F4)
/* The following functions must be defined for this platform:
* i2c_write(unsigned char slave_addr, unsigned char reg_addr,
* unsigned char length, unsigned char const *data)
* i2c_read(unsigned char slave_addr, unsigned char reg_addr,
* unsigned char length, unsigned char *data)
* delay_ms(unsigned long num_ms)
* get_ms(unsigned long *count)
* reg_int_cb(void (*cb)(void), unsigned char port, unsigned char pin)
* labs(long x)
* fabsf(float x)
* min(int a, int b)
*/
#if defined MOTION_DRIVER_TARGET_MSP430
//#include "msp430.h"
//#include "msp430_i2c.h"
//#include "msp430_clock.h"
//#include "msp430_interrupt.h"
#define i2c_write MPU_Write_Len_1
#define i2c_read MPU_Read_Len_1
#define delay_ms delay_ms
#define get_ms_1 mget_ms_1
#define mpu_init mpu_init_1
#define mpu_init_slave mpu_init_slave_1
#define mpu_set_bypass mpu_set_bypass_1
#define mpu_lp_accel_mode mpu_lp_accel_mode_1
#define mpu_lp_motion_interrupt mpu_lp_motion_interrupt_1
#define mpu_set_int_level mpu_set_int_level_1
#define mpu_set_int_latched mpu_set_int_latched_1
#define mpu_set_dmp_state mpu_set_dmp_state_1
#define mpu_get_dmp_state mpu_get_dmp_state_1
#define mpu_get_lpf mpu_get_lpf_1
#define mpu_set_lpf mpu_set_lpf_1
#define mpu_get_gyro_fsr mpu_get_gyro_fsr_1
#define mpu_set_gyro_fsr mpu_set_gyro_fsr_1
#define mpu_get_accel_fsr mpu_get_accel_fsr_1
#define mpu_set_accel_fsr mpu_set_accel_fsr_1
#define mpu_get_compass_fsr mpu_get_compass_fsr_1
#define mpu_get_gyro_sens mpu_get_gyro_sens_1
#define mpu_get_accel_sens mpu_get_accel_sens_1
#define mpu_get_sample_rate mpu_get_sample_rate_1
#define mpu_set_sample_rate mpu_set_sample_rate_1
#define mpu_get_compass_sample_rate mpu_get_compass_sample_rate_1
#define mpu_set_compass_sample_rate mpu_set_compass_sample_rate_1
#define mpu_get_fifo_config mpu_get_fifo_config_1
#define mpu_configure_fifo mpu_configure_fifo_1
#define mpu_get_power_state mpu_get_power_state_1
#define mpu_set_sensors mpu_set_sensors_1
#define mpu_set_accel_bias mpu_set_accel_bias_1
#define mpu_get_gyro_reg mpu_get_gyro_reg_1
#define mpu_get_accel_reg mpu_get_accel_reg_1
#define mpu_get_compass_reg mpu_get_compass_reg_1
#define mpu_get_temperature mpu_get_temperature_1
#define mpu_get_int_status mpu_get_int_status_1
#define mpu_read_fifo mpu_read_fifo_1
#define mpu_read_fifo_stream mpu_read_fifo_stream_1
#define mpu_reset_fifo mpu_reset_fifo_1
#define mpu_write_mem mpu_write_mem_1
#define mpu_read_mem mpu_read_mem_1
#define mpu_load_firmware mpu_load_firmware_1
#define mpu_reg_dump mpu_reg_dump_1
#define mpu_read_reg mpu_read_reg_1
#define mpu_run_self_test mpu_run_self_test_1
#define mpu_register_tap_cb mpu_register_tap_cb_1
#define mget_ms_1 mget_ms_1
#define inv_row_2_scale inv_row_2_scale_1
#define inv_orientation_matrix_to_scalar inv_orientation_matrix_to_scalar_1
#define run_self_test run_self_test_1
#define mpu_dmp_init mpu_dmp_init_1
#define mpu_dmp_get_data mpu_dmp_get_data_1
//static inline int reg_int_cb(struct int_param_s *int_param)
//{
// return msp430_reg_int_cb(int_param->cb, int_param->pin, int_param->lp_exit,
// int_param->active_low);
//}
#define log_i printf //打印信息
#define log_e printf //打印信息
/* labs is already defined by TI's toolchain. */
/* fabs is for doubles. fabsf is for floats. */
#define fabs fabsf
#define min(a,b) ((a<b)?a:b)
#elif defined EMPL_TARGET_MSP430
#include "msp430.h"
#include "msp430_i2c.h"
#include "msp430_clock.h"
#include "msp430_interrupt.h"
#include "log.h"
#define i2c_write msp430_i2c_write
#define i2c_read msp430_i2c_read
#define delay_ms msp430_delay_ms
#define get_ms msp430_get_clock_ms
static inline int reg_int_cb(struct int_param_s *int_param)
{
return msp430_reg_int_cb(int_param->cb, int_param->pin, int_param->lp_exit,
int_param->active_low);
}
#define log_i MPL_LOGI
#define log_e MPL_LOGE
/* labs is already defined by TI's toolchain. */
/* fabs is for doubles. fabsf is for floats. */
#define fabs fabsf
#define min(a,b) ((a<b)?a:b)
#elif defined EMPL_TARGET_UC3L0
/* Instead of using the standard TWI driver from the ASF library, we're using
* a TWI driver that follows the slave address + register address convention.
*/
#include "twi.h"
#include "delay.h"
#include "sysclk.h"
#include "log.h"
#include "sensors_xplained.h"
#include "uc3l0_clock.h"
#define i2c_write(a, b, c, d) twi_write(a, b, d, c)
#define i2c_read(a, b, c, d) twi_read(a, b, d, c)
/* delay_ms is a function already defined in ASF. */
#define get_ms uc3l0_get_clock_ms
static inline int reg_int_cb(struct int_param_s *int_param)
{
sensor_board_irq_connect(int_param->pin, int_param->cb, int_param->arg);
return 0;
}
#define log_i MPL_LOGI
#define log_e MPL_LOGE
/* UC3 is a 32-bit processor, so abs and labs are equivalent. */
#define labs abs
#define fabs(x) (((x)>0)?(x):-(x))
#else
#error Gyro driver is missing the system layer implementations.
#endif
#if !defined MPU6050 && !defined MPU9150 && !defined MPU6500 && !defined MPU9250
#error Which gyro are you using? Define MPUxxxx in your compiler options.
#endif
/* Time for some messy macro work. =]
* #define MPU9150
* is equivalent to..
* #define MPU6050
* #define AK8975_SECONDARY
*
* #define MPU9250
* is equivalent to..
* #define MPU6500
* #define AK8963_SECONDARY
*/
#if defined MPU9150
#ifndef MPU6050
#define MPU6050
#endif /* #ifndef MPU6050 */
#if defined AK8963_SECONDARY
#error "MPU9150 and AK8963_SECONDARY cannot both be defined."
#elif !defined AK8975_SECONDARY /* #if defined AK8963_SECONDARY */
#define AK8975_SECONDARY
#endif /* #if defined AK8963_SECONDARY */
#elif defined MPU9250 /* #if defined MPU9150 */
#ifndef MPU6500
#define MPU6500
#endif /* #ifndef MPU6500 */
#if defined AK8975_SECONDARY
#error "MPU9250 and AK8975_SECONDARY cannot both be defined."
#elif !defined AK8963_SECONDARY /* #if defined AK8975_SECONDARY */
#define AK8963_SECONDARY
#endif /* #if defined AK8975_SECONDARY */
#endif /* #if defined MPU9150 */
#if defined AK8975_SECONDARY || defined AK8963_SECONDARY
#define AK89xx_SECONDARY
#else
/* #warning "No compass = less profit for Invensense. Lame." */
#endif
static int set_int_enable(unsigned char enable);
/* Hardware registers needed by driver. */
struct gyro_reg_s {
unsigned char w
没有合适的资源?快使用搜索试试~ 我知道了~
STM32F103C8T6 双MPU6050 HAL库例程
共152个文件
o:32个
d:32个
crf:31个
需积分: 5 19 下载量 38 浏览量
2022-08-30
18:22:26
上传
评论 1
收藏 6.76MB RAR 举报
温馨提示
使用双MPU6050+蓝牙进行驼背矫正
资源详情
资源评论
资源推荐
收起资源包目录
STM32F103C8T6 双MPU6050 HAL库例程 (152个子文件)
kyphotone.uvguix.86131 184KB
kyphotone.axf 740KB
inv_mpu_1.c 90KB
inv_mpu.c 87KB
inv_mpu_dmp_motion_driver_1.c 58KB
inv_mpu_dmp_motion_driver.c 57KB
system_stm32f1xx.c 15KB
main.c 8KB
stm32f1xx_it.c 7KB
mpu6050_1.c 7KB
usart.c 7KB
mpu6050.c 7KB
mpuiic_1.c 3KB
mpuiic.c 3KB
tim.c 3KB
gpio.c 3KB
stm32f1xx_hal_msp.c 2KB
delay.c 1KB
ble.c 558B
inv_mpu_dmp_motion_driver_1.crf 611KB
inv_mpu_dmp_motion_driver.crf 609KB
stm32f1xx_hal_tim.crf 608KB
inv_mpu_1.crf 604KB
inv_mpu.crf 601KB
main.crf 577KB
stm32f1xx_hal_tim_ex.crf 572KB
stm32f1xx_hal_uart.crf 568KB
mpu6050_1.crf 561KB
mpu6050.crf 560KB
stm32f1xx_hal_rcc.crf 558KB
usart.crf 556KB
ble.crf 554KB
stm32f1xx_hal_dma.crf 554KB
stm32f1xx_hal_flash_ex.crf 552KB
mpuiic_1.crf 552KB
stm32f1xx_hal_flash.crf 551KB
mpuiic.crf 551KB
stm32f1xx_hal_gpio.crf 550KB
stm32f1xx_hal_exti.crf 549KB
stm32f1xx_hal_pwr.crf 549KB
stm32f1xx_hal_rcc_ex.crf 549KB
gpio.crf 548KB
stm32f1xx_it.crf 548KB
tim.crf 548KB
stm32f1xx_hal.crf 548KB
stm32f1xx_hal_msp.crf 547KB
stm32f1xx_hal_cortex.crf 547KB
delay_1.crf 547KB
system_stm32f1xx.crf 547KB
stm32f1xx_hal_gpio_ex.crf 546KB
inv_mpu_dmp_motion_driver_1.d 5KB
inv_mpu_dmp_motion_driver.d 5KB
main.d 4KB
inv_mpu_1.d 4KB
inv_mpu.d 4KB
stm32f1xx_hal_flash_ex.d 4KB
mpu6050_1.d 4KB
stm32f1xx_hal_gpio_ex.d 4KB
stm32f1xx_hal_cortex.d 4KB
stm32f1xx_hal_rcc_ex.d 4KB
stm32f1xx_hal_tim_ex.d 4KB
stm32f1xx_hal_flash.d 4KB
stm32f1xx_hal_gpio.d 4KB
stm32f1xx_hal_exti.d 4KB
stm32f1xx_hal_uart.d 4KB
mpu6050.d 4KB
stm32f1xx_hal_dma.d 4KB
stm32f1xx_hal_rcc.d 4KB
stm32f1xx_hal_pwr.d 4KB
stm32f1xx_hal_tim.d 4KB
stm32f1xx_hal_msp.d 4KB
ble.d 4KB
system_stm32f1xx.d 4KB
mpuiic_1.d 4KB
stm32f1xx_hal.d 4KB
stm32f1xx_it.d 4KB
usart.d 4KB
mpuiic.d 4KB
delay_1.d 4KB
gpio.d 3KB
tim.d 3KB
startup_stm32f103xb.d 56B
kyphotone_STM32F103C8_1.0.0.dbgconf 2KB
kyphotone_kyphotone.dep 133KB
dmpKey.h 19KB
dmpKey.h 19KB
stm32f1xx_hal_conf.h 15KB
dmpmap.h 7KB
dmpmap.h 7KB
mpu6050_1.h 5KB
mpu6050.h 5KB
inv_mpu_1.h 5KB
inv_mpu.h 5KB
inv_mpu_dmp_motion_driver_1.h 4KB
inv_mpu_dmp_motion_driver.h 3KB
main.h 3KB
stm32f1xx_it.h 2KB
mpuiic_1.h 2KB
mpuiic.h 2KB
usart.h 2KB
共 152 条
- 1
- 2
秃头程序猿♀️
- 粉丝: 0
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0