-
大小: 564KB文件類型: .zip金幣: 2下載: 0 次發布日期: 2021-05-12
- 語言: 其他
- 標簽: MPU6050DMP??
資源簡介
TM4C123G可用的MPU6050全部代碼。

代碼片段和文件信息
///*
//*?Function?:?本程序學習測試mpu6050?沒有DMP
//*?Date ?:?2016/07/9?start
//*?Author ?:?aceLin
//*?FileName?:?mpu6050_main.c
//*?MCU ?:?TM4C123GH6PM?40PIN(board)
//*?Version ?:?1.0
//*?Breif ?:?按鍵優化不夠
//*?Updata???:?none
//*/
/*=====標準庫頭文件?=============*/
#include?
#include?
/*=====?TivaWare?驅動庫頭文件====*/
#include?
#include?“inc/hw_memmap.h“
#include?“inc/hw_types.h“
#include?“driverlib/gpio.h“
#include?“driverlib/sysctl.h“
#include?“driverlib/debug.h“
#include?“driverlib/fpu.h“
#include?“driverlib/pin_map.h“
#include?“driverlib/rom.h“
#include?“utils/uartstdio.h“
/*=====?用戶頭文件?==========*/
#include?“led.h“
#include?“key.h“
#include?“sys.h“
#include?“UART_Init.h“
#include?“I2C.h“
#include?“mpu6050.h“
#include?“mpu6050_firRefi.h“
#include?“inv_mpu.h“
#include?“inv_mpu_dmp_motion_driver.h“
//*****************************************************************************
//如果驅動程序庫遇到錯誤,則調用錯誤例程.
#ifdef?DEBUG
void
__error__(char?*pcFilename?uint32_t?ui32Line)
{
}
#endif
/*======?定義全局變量(如果需要的話)=============*/
uint16_t?tmp; //溫度
short?aacxaacyaacz; //加速度傳感器原始數據
short?gyroxgyroygyroz; //陀螺儀原始數據
float?pitchrollyaw;? //歐拉角
/*======此處放函數聲明(如果有的話)==============*/
void?usart1_niming_report(u8?funu8*datau8?len);
void?mpu6050_send_data(short?aacxshort?aacyshort?aaczshort?gyroxshort?gyroyshort?gyroz);
void?usart1_report_imu(short?aacxshort?aacyshort?aaczshort?gyroxshort?gyroyshort?gyrozshort?rollshort?pitchshort?yaw);
int?main(void){
????//uint32_t?i?=?0;
uint8_t?report=1; //默認開啟上報
const?int8_t?Test_UART_array[]=?{“Tiva?C?TM4C123GH6PM?UART?TEST!\n“};
????//設置系統時鐘:5分頻、使用PLL、外接16MHz晶振、使用主振蕩器。
//處理器系統時鐘為?PLL(400MHz)/2?/?SYSCTL(5)?=?40MHz
????SysCtlClockSet(SYSCTL_SYSDIV_5|
???? SYSCTL_USE_PLL|
SYSCTL_XTAL_16MHZ|
SYSCTL_OSC_MAIN);
????ROM_FPUEnable();
????ROM_FPULazyStackingEnable();
????ConfigureUART(); //#外設#?串口初始化
????/*===基本硬件初始化===*/
????KEY_Init(); //#硬件#?按鍵初始化
????LED_Init(); //#硬件#?LED初始化
????MPU_Init(); //#硬件#?本工程測試內容,MPU6050初始化
????//UARTprintf(Test_UART_array);
????//LED_B_ON();
????/**?第一步,檢測器件。這一步成功后面的就都好解決了?***/
//MPU_Init()函數返回0成功,返回1失敗
while(mpu_dmp_init()){//進入while,檢測不到MPU6050
//UARTprintf(“MPU6050?Error“);
//UARTprintf(“Please?Check!??????\n“);
LED_R_ON(); //亮紅燈,錯誤警告
}//?end?while
????/***?跳出循環,說明與MPU6050通信正常?***/
????LED_R_OFF(); //紅燈滅,工作正常
????//UARTprintf(“MPU6050?Ready!\n“);
????usart1_send_char(Test_UART_array[1]);
while(1){
if(mpu_dmp_get_data(&pitch&roll&yaw)==0){
//temp=MPU_Get_Temperature(); //得到溫度值
MPU_Get_Accelerometer(&aacx&aacy&aacz); //得到加速度傳感器數據
MPU_Get_Gyroscope(&gyrox&gyroy&gyroz); //得到陀螺儀數據
if(report)mpu6050_send_data(aacxaacyaaczgyroxgyroygyroz);//用自定義幀發送加速度和陀螺儀原始數據
if(report)usart1_report_imu(aacxaacyaaczgyroxgyroygyroz(int)(roll*100)(int)(pitch*100)(int)(yaw
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????421??2016-07-09?08:39??4_MPU6050_DMP_makeIt\.ccsproject
?????文件???????33588??2016-07-10?03:21??4_MPU6050_DMP_makeIt\.cproject
?????目錄???????????0??2016-07-10?06:04??4_MPU6050_DMP_makeIt\.launches\
?????文件????????4565??2016-07-09?09:39??4_MPU6050_DMP_makeIt\.launches\GPIO_IN_KEY.launch
?????文件????????4523??2016-07-07?12:21??4_MPU6050_DMP_makeIt\.launches\hello.launch
?????文件????????4614??2016-07-10?03:39??4_MPU6050_DMP_makeIt\.launches\MPU6050_DMP_makeIt.launch
?????文件????????4572??2016-07-09?20:38??4_MPU6050_DMP_makeIt\.launches\test_MPU6050.launch
?????文件????????4600??2016-07-09?20:56??4_MPU6050_DMP_makeIt\.launches\test_MPU6050_DMP.launch
?????文件????????4572??2016-07-09?20:03??4_MPU6050_DMP_makeIt\.launches\test_softI2C.launch
?????文件????????1345??2016-07-10?03:21??4_MPU6050_DMP_makeIt\.project
?????目錄???????????0??2016-07-10?06:04??4_MPU6050_DMP_makeIt\Debug\
?????文件?????????460??2016-07-10?05:53??4_MPU6050_DMP_makeIt\Debug\ccsObjs.opt
?????文件??????123730??2016-07-09?14:20??4_MPU6050_DMP_makeIt\Debug\GPIO_IN_KEY_li
?????目錄???????????0??2016-07-10?06:04??4_MPU6050_DMP_makeIt\Debug\Hardware\
?????目錄???????????0??2016-07-10?06:04??4_MPU6050_DMP_makeIt\Debug\Hardware\24Cxx\
?????文件????????1275??2016-07-09?20:14??4_MPU6050_DMP_makeIt\Debug\Hardware\24Cxx\24Cxx.d
?????文件???????21492??2016-07-09?20:14??4_MPU6050_DMP_makeIt\Debug\Hardware\24Cxx\24Cxx.obj
?????文件????????1510??2016-07-09?20:14??4_MPU6050_DMP_makeIt\Debug\Hardware\24Cxx\subdir_rules.mk
?????文件?????????566??2016-07-09?20:14??4_MPU6050_DMP_makeIt\Debug\Hardware\24Cxx\subdir_vars.mk
?????目錄???????????0??2016-07-10?06:04??4_MPU6050_DMP_makeIt\Debug\Hardware\DMP\
?????文件????????3343??2016-07-10?03:37??4_MPU6050_DMP_makeIt\Debug\Hardware\DMP\inv_mpu.d
?????文件??????174416??2016-07-10?03:37??4_MPU6050_DMP_makeIt\Debug\Hardware\DMP\inv_mpu.obj
?????文件????????3267??2016-07-10?03:38??4_MPU6050_DMP_makeIt\Debug\Hardware\DMP\inv_mpu_dmp_motion_driver.d
?????文件??????124336??2016-07-10?03:38??4_MPU6050_DMP_makeIt\Debug\Hardware\DMP\inv_mpu_dmp_motion_driver.obj
?????文件????????2861??2016-07-10?05:53??4_MPU6050_DMP_makeIt\Debug\Hardware\DMP\subdir_rules.mk
?????文件?????????844??2016-07-10?05:53??4_MPU6050_DMP_makeIt\Debug\Hardware\DMP\subdir_vars.mk
?????目錄???????????0??2016-07-10?06:04??4_MPU6050_DMP_makeIt\Debug\Hardware\I2C\
?????文件????????1105??2016-07-10?03:39??4_MPU6050_DMP_makeIt\Debug\Hardware\I2C\I2C.d
?????文件???????21828??2016-07-10?03:39??4_MPU6050_DMP_makeIt\Debug\Hardware\I2C\I2C.obj
?????文件????????1536??2016-07-10?05:53??4_MPU6050_DMP_makeIt\Debug\Hardware\I2C\subdir_rules.mk
?????文件?????????542??2016-07-10?05:53??4_MPU6050_DMP_makeIt\Debug\Hardware\I2C\subdir_vars.mk
............此處省略89個文件信息
- 上一篇:鄂爾多斯市行政界線
- 下一篇:DC005電源端子AD封裝+原理圖+使用說明
評論
共有 條評論