资源简介
最近在使用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最全的全网信令流程
相关资源
- 基于stm32f103ve的程序——跑马灯实验
- 基于STM32RCT6的步进电机驱动程序
- stm32f407上的两个can发送和接收例程
- STM32 led 时钟
- STM32 2.4G通信例程
- 直流无刷电机方波驱动 stm32 例程代码
- STM32中文资料
- STM32蓝牙和串口程序
- STM32f103超声波模块例程
- stm32f103c8t6 4 oled.rar
- stm32f030 IAP Demo(原创)
- STM32基于rt_thread操作系统的SDHC卡文件
- NRF24L01实现51与STM32双向通讯
- STM32F103 串口程序(完整版)
- stm32 ds18b20 温度传感器 测试通过
- stm32官方例程
- STM32F103定时器中断程序
- [免费]基于stm32f103ze 的OLED驱动代码
- STM32F103RBT6驱动UC1698控制芯片的160160黑
- STM32F103 DS18B20 V3.5.0固件库驱动程序工
- STM32定时器使用入门。看了这个程序会
- SIM908 SDIO FSMC STM32 FIFO
- STM32F103 CC2500完整驱动(模拟SPI)
- AD7606采集程序
- stm32 用SPI 方式读写 SDHC
- stm32通过DMA方式采集ADC数据
- 意法半导体STM全系列微控制器STM32ST
- 基于STM32芯片的SX1278 驱动 LORA.rar
- STM32的PCB封装库,以及原理图库,48
- SX1280.rar
评论
共有 条评论