资源简介
最近在使用MPU9250来学习姿态解算,查询了非常多的网上关于MPU6050和MPU9250的资料,发现内置的DMP可以计算出姿态角,可原代码是用在MSP430和STM407上的,手上有块F429的野火板子,移植过程越到非常多的巨坑,现在想记录下来给各位初学者提供一些便利,这里是源代码,包含教程PPT
代码片段和文件信息
//系统头文件
#include “arch.h“
#include “stdio.h“
//外设头文件
#include “usart.h“
#include “i2c.h“
#include “gpio.h“
#include “main.h“
#include “board_resource.h“
//DMP_Lib头文件
#include “inv_mpu.h“
#include “inv_mpu_dmp_motion_driver.h“
#include “invensense.h“
#include “invensense_adv.h“
#include “eMPL_outputs.h“
#include “mltypes.h“
#include “mpu.h“
#include “log.h“
#include “packet.h“
/* Private typedef -----------------------------------------------------------*/
/* Data read from MPL. */
#define PRINT_ACCEL (0x01)
#define PRINT_GYRO (0x02)
#define PRINT_QUAT (0x04)
#define PRINT_COMPASS (0x08)
#define PRINT_EULER (0x10)
#define PRINT_ROT_MAT (0x20)
#define PRINT_HEADING (0x40)
#define PRINT_PEDO (0x80)
#define PRINT_LINEAR_ACCEL (0x100)
#define PRINT_GRAVITY_VECTOR (0x200)
volatile uint32_t hal_timestamp = 0;
#define ACCEL_ON (0x01)
#define GYRO_ON (0x02)
#define COMPASS_ON (0x04)
#define MOTION (0)
#define NO_MOTION (1)
/* Starting sampling rate. */
#define DEFAULT_MPU_HZ (20)
#define FLASH_SIZE (512)
#define FLASH_MEM_START ((void*)0x1800)
#define PEDO_READ_MS (1000)
#define TEMP_READ_MS (500)
#define COMPASS_READ_MS (100)
struct rx_s {
unsigned char header[3];
unsigned char cmd;
};
struct hal_s {
unsigned char lp_accel_mode;
unsigned char sensors;
unsigned char dmp_on;
unsigned char wait_for_tap;
volatile unsigned char new_gyro;
unsigned char motion_int_mode;
unsigned long no_dmp_hz;
unsigned long next_pedo_ms;
unsigned long next_temp_ms;
unsigned long next_compass_ms;
unsigned int report;
unsigned short dmp_features;
struct rx_s rx;
};
static struct hal_s hal = {0};
/* USB RX binary semaphore. Actually it‘s just a flag. Not included in struct
* because it‘s declared extern elsewhere.
*/
volatile unsigned char rx_new;
unsigned char *mpl_key = (unsigned char*)“eMPL 5.1“;
/* Platform-specific information. Kinda like a boardfile. */
struct platform_data_s {
signed char orientation[9];
};
/* The sensors can be mounted onto the board in any orientation. The mounting
* matrix seen below tells the MPL how to rotate the raw data from the
* driver(s).
* TODO: The following matrices refer to the configuration on internal test
* boards at Invensense. If needed please modify the matrices to match the
* chip-to-body matrix for your particular set up.
*/
static struct platform_data_s gyro_pdata = {
.orientation = {
1 0 0
0 1 0
0 0 1
}
};
#if defined MPU9150 || defined MPU9250
static struct platform_data_s compass_pdata = {
.orientation = {
0 1 0
1 0 0
0 0 -1
}
};
#define COMPASS_ENABLED 1
#elif defined AK8975_SECONDARY
static struct platform_data_s compass_pdata = {
.orientation = {
-1 0 0
0
- 上一篇:Layui后台管理模板 包含页面
- 下一篇:LTE最全的全网信令流程
相关资源
- STM32f103ADC USART FLASH 八段数码管驱动
- 基于spwm波的步进电机细分技术的stm
- STM32开发板综合实验
- stm32智能小车循迹
- 基于stm32F407的音乐播放器
- STM32 AB正交编码器程序
- STM32硬件I2C读写AT24Cxx
- STM32控制OLED图文显示
- STM32 超全的STM32封装库
- stm32单片机3个串口dma方式通信
- 基于STM32的智能万年历课程设计
- MAX31856-STM32编程应用资料.zip
- stm32_lwip.zip
- stm32读写sd卡
- STM32入门程序(详细列出了所有独立外
- 用STM32F103做MP3
- stm32可调时钟程序
- STM32FSMC接口详解
- Micrium_uCOS-III-STM32F107-Eval-Atollic-TrueST
- STM32F103 作为USB Visual Port时驱动问题
- 基于 STM32 的 I2C 时序 - 模拟 I2C
- STM32 CPU 温度采集
- 基于 STM32 的 RTC 实时时钟
- 《从零开始创建uCosIII项目》中的工程
- 单相用电器分析监测装置_2017年江苏省
- stm32f1_hal库使用手册中英文对照.docx
- 从0开始移植UCOS_II到野火stm32开发板
- iAQ-core C型传感器使用总结
- stm32+DHT21程序代码
- stm32f030c8t6手册
评论
共有 条评论