当前位置:   article > 正文

mpu6050六轴陀螺仪dmp姿态解算-C语言移植(stm32+hal)_mpu6050dmp库stm32移植

mpu6050dmp库stm32移植

官方库源文件:
1 移植官方6个库文件
2 修改inv_mpu.h中结构体

// 新增   void (*tmp)(void);
struct int_param_s {
#if defined EMPL_TARGET_MSP430 || defined MOTION_DRIVER_TARGET_MSP430
    void (*cb)(void);
    unsigned short pin;
    unsigned char lp_exit;
    unsigned char active_low;
#elif defined EMPL_TARGET_UC3L0
    unsigned long pin;
    void (*cb)(volatile void*);
    void *arg;
#elif defined EMPL_TARGET_STM32L
    void (*cb)(void);
#endif
   void (*tmp)(void);
};
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

3 修改inv_mpu.c

// 步骤二:注释掉
#ifndef EMPL_TARGET_STM32L    
  //  if (int_param)
  //      reg_int_cb(int_param);
  • 1
  • 2
  • 3
  • 4

4 修改 inv_mpu_motion_driver.c

// 注释 __no_operation();
int dmp_set_accel_bias(long *bias)
{
    long accel_bias_body[3];
    unsigned char regs[12];
    long long accel_sf;
    unsigned short accel_sens;

    mpu_get_accel_sens(&accel_sens);
    accel_sf = (long long)accel_sens << 15;

 //    __no_operation();
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

5 keil中增加宏定义

STM32F103_DMP,MPU6050,EMPL,MPL_LOG_NDEBUG=1
  • 1

6 移植核心[修改inv_mpu.c|inv_mpu_motion_driver.c]

 #if defined STM32F103_DMP
 #include "mpu.h"   
 #define i2c_write   MPU_Write_Len
 #define i2c_read    MPU_Read_Len  
 #define delay_ms    HAL_Delay
 #define get_ms      get_ms_count
 #define log_i       printf
 #define log_e       printf
 #define min(a,b) ((a<b)?a:b)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/467185
推荐阅读
相关标签
  

闽ICP备14008679号