完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
移植DMP,上电后出现如下情况:
compass not found. mpu initialization complete...... mpu_set_sensor complete ...... mpu_configure_fifo complete ...... mpu_set_sample_rate complete ...... dmp_load_motion_driver_firmware come across error ...... dmp_set_orientation complete ...... dmp_enable_feature complete ...... dmp_set_fifo_rate complete ...... setting bias succesfully ...... mpu_set_dmp_state come across error ...... 求大神指导 |
|
相关推荐
4个回答
|
|
帮顶....
|
|
|
|
#include "stm32_iic.h"
#define SCL_H GPIOB->BSRR = GPIO_Pin_6 #define SCL_L GPIOB->BRR = GPIO_Pin_6 #define SDA_H GPIOB->BSRR = GPIO_Pin_7 #define SDA_L GPIOB->BRR = GPIO_Pin_7 #define SCL_read GPIOB->IDR & GPIO_Pin_6 #define SDA_read GPIOB->IDR & GPIO_Pin_7 //IICר?????±???? static void I2C_delay(void) { volatile int i = 40; while (i) i--; } void delay5ms(void) { int i=5000; while(i) { i--; } } //IIC?????????? void i2cInit(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD; GPIO_Init(GPIOB, &GPIO_InitStructure); } static bool I2C_Start(void) { SDA_H; SCL_H; I2C_delay(); if (!SDA_read) return false; SDA_L; I2C_delay(); if (SDA_read) return false; SDA_L; I2C_delay(); return true; } static void I2C_Stop(void) { SCL_L; I2C_delay(); SDA_L; I2C_delay(); SCL_H; I2C_delay(); SDA_H; I2C_delay(); } static void I2C_Ack(void) { SCL_L; I2C_delay(); SDA_L; I2C_delay(); SCL_H; I2C_delay(); SCL_L; I2C_delay(); } static void I2C_NoAck(void) { SCL_L; I2C_delay(); SDA_H; I2C_delay(); SCL_H; I2C_delay(); SCL_L; I2C_delay(); } static bool I2C_WaitAck(void) { u8 ucErrTime=0; SCL_L; I2C_delay(); SDA_H; I2C_delay(); SCL_H; I2C_delay(); if (SDA_read) {ucErrTime++; if(ucErrTime>250) { I2C_Stop(); return false; } // SCL_L; return false; } SCL_L; return true; } static void I2C_SendByte(uint8_t byte) { uint8_t i = 8; while (i--) { SCL_L; I2C_delay(); if (byte & 0x80) SDA_H; else SDA_L; byte <<= 1; I2C_delay(); SCL_H; I2C_delay(); } SCL_L; } static uint8_t I2C_ReceiveByte(void) { uint8_t i = 8; uint8_t byte = 0; SDA_H; while (i--) { byte <<= 1; SCL_L; I2C_delay(); SCL_H; I2C_delay(); if (SDA_read) { byte |= 0x01; } } SCL_L; return byte; } bool i2cWriteBuffer(uint8_t addr, uint8_t reg, uint8_t len, uint8_t * data) { int i; if (!I2C_Start()) return false; I2C_SendByte(addr << 1 | I2C_Direction_Transmitter); if (!I2C_WaitAck()) { I2C_Stop(); return false; } I2C_SendByte(reg); I2C_WaitAck(); for (i = 0; i < len; i++) { I2C_SendByte(data); if (!I2C_WaitAck()) { I2C_Stop(); return false; } data++; } I2C_Stop(); delay5ms(); return true; } int8_t i2cwrite(uint8_t addr, uint8_t reg, uint8_t len, uint8_t * data) { if(i2cWriteBuffer(addr,reg,len,data)) return TRUE; // } else // { // return FALSE; // } return FALSE; } int8_t i2cread(uint8_t addr, uint8_t reg, uint8_t len, uint8_t *buf) { if(i2cRead(addr,reg,len,buf)) return TRUE; else return FALSE; //return FALSE; } bool i2cWrite(uint8_t addr, uint8_t reg, uint8_t data) { if (!I2C_Start()) return false; I2C_SendByte(addr << 1 | I2C_Direction_Transmitter); if (!I2C_WaitAck()) { I2C_Stop(); return false; } I2C_SendByte(reg); I2C_WaitAck(); I2C_SendByte(data); I2C_WaitAck(); I2C_Stop(); delay5ms(); return true; } bool i2cRead(uint8_t addr, uint8_t reg, uint8_t len, uint8_t *buf) { if (!I2C_Start()) return false; I2C_SendByte(addr << 1 | I2C_Direction_Transmitter); if (!I2C_WaitAck()) { I2C_Stop(); return false; } I2C_SendByte(reg); I2C_WaitAck(); I2C_Start(); I2C_SendByte(addr << 1 | I2C_Direction_Receiver); I2C_WaitAck(); while (len) { *buf = I2C_ReceiveByte(); if (len == 1) I2C_NoAck(); else I2C_Ack(); buf++; len--; } I2C_Stop(); return true; } uint16_t i2cGetErrorCounter(void) { // TODO maybe fix this, but since this is test code, doesn't matter. return 0; } 各位帮忙看看这个IIC哪出问题了? |
|
|
|
你好,你试过用SPI读取MPU9250的磁力计数据吗?我再这块遇到问题了,不知道怎么解决?
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
请问下图大疆lightbridge2遥控器主板电源芯片型号是什么?
4303 浏览 1 评论
使用常见的二极管、三极管和mos做MCU和模组的电平转换电路,但是模组和MCU无法正常通信,为什么?
127浏览 2评论
为了提高USIM卡电路的可靠性和稳定性,在电路设计中须注意的点有哪些?
82浏览 2评论
103浏览 2评论
89浏览 2评论
112浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-7-28 08:17 , Processed in 0.735198 second(s), Total 84, Slave 68 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191