108 lines
24 KiB
XML
108 lines
24 KiB
XML
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
|
|
<section xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="_mpu6050_8cpp_source" xml:lang="zh">
|
|
<title>mpu6050.cpp</title>
|
|
<indexterm><primary>D:/gitt/MicrochipFor32/bsp_MPU6050/mpu6050.cpp</primary></indexterm>
|
|
浏览该文件的文档.<programlisting linenumbering="unnumbered"><anchor xml:id="_mpu6050_8cpp_source_1l00001"/>00001
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00012"/>00012 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00013"/>00013 <emphasis role="comment">//  头文件</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00014"/>00014 <emphasis role="preprocessor">#include "bscpp_IIC_STM32.h"</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00015"/>00015 <emphasis role="preprocessor">#include "<link linkend="_mpu6050_8h">mpu6050.h</link>"</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00016"/><link linkend="_mpu6050_8cpp_1ae7d7fd8356f1a04698bf36a2ff087f7b">00016</link> <emphasis role="preprocessor">#define delay_ms(var) HAL_Delay(var)</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00017"/><link linkend="_mpu6050_8cpp_1a0e5583807e7dcaae30835311a2195583">00017</link> bscpp_IIC_STM32 <link linkend="_mpu6050_8cpp_1a0e5583807e7dcaae30835311a2195583">mpu6050IIC</link>(IIC_SCK_GPIO_Port,IIC_SCK_Pin,IIC_SDA_GPIO_Port,IIC_SDA_Pin);
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00019"/>00019 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00020"/>00020 <emphasis role="comment">//  函数区</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00025"/><link linkend="_mpu6050_8cpp_1ab1f8c6111d59b60a2edb4ee3e8aa3113">00025</link> <emphasis role="comment"></emphasis><link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> <link linkend="_mpu6050_8cpp_1ab1f8c6111d59b60a2edb4ee3e8aa3113">MPU_Init</link>(<emphasis role="keywordtype">void</emphasis>){
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00026"/>00026     <link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> res;
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00027"/>00027     <emphasis role="comment">//MPU_IIC_Init();//初始化IIC总线</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00028"/>00028     <link linkend="_mpu6050_8cpp_1a0be9b422bb8613f8444db4af5234e1a1">MPU_Write_Byte</link>(<link linkend="_mpu6050_8h_1abbe7ea135ee03eb0f1296ecb22be7554">MPU_PWR_MGMT1_REG</link>,0X80); <emphasis role="comment">//复位MPU6050</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00029"/>00029     <link linkend="_mpu6050_8cpp_1ae7d7fd8356f1a04698bf36a2ff087f7b">delay_ms</link>(100);
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00030"/>00030     <link linkend="_mpu6050_8cpp_1a0be9b422bb8613f8444db4af5234e1a1">MPU_Write_Byte</link>(<link linkend="_mpu6050_8h_1abbe7ea135ee03eb0f1296ecb22be7554">MPU_PWR_MGMT1_REG</link>,0X00); <emphasis role="comment">//唤醒MPU6050 </emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00031"/>00031     <link linkend="_mpu6050_8cpp_1aa27cc30326ce4980b289a0e1c3f76b5e">MPU_Set_Gyro_Fsr</link>(3);                    <emphasis role="comment">//陀螺仪传感器,±2000dps</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00032"/>00032     <link linkend="_mpu6050_8cpp_1a6c391137bc5880c3b5e15e84c5a3380f">MPU_Set_Accel_Fsr</link>(0);                   <emphasis role="comment">//加速度传感器,±2g</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00033"/>00033     <link linkend="_mpu6050_8cpp_1a04e58232ce838e94d54aa2b53287cb41">MPU_Set_Rate</link>(50);                       <emphasis role="comment">//设置采样率50Hz</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00034"/>00034     <link linkend="_mpu6050_8cpp_1a0be9b422bb8613f8444db4af5234e1a1">MPU_Write_Byte</link>(<link linkend="_mpu6050_8h_1afa56d3602a6044562c45cecf6403fb8b">MPU_INT_EN_REG</link>,0X00);    <emphasis role="comment">//关闭所有中断</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00035"/>00035     <link linkend="_mpu6050_8cpp_1a0be9b422bb8613f8444db4af5234e1a1">MPU_Write_Byte</link>(<link linkend="_mpu6050_8h_1a0146ef35d7ff0b037eafb0a5dac53b0f">MPU_USER_CTRL_REG</link>,0X00); <emphasis role="comment">//I2C主模式关闭</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00036"/>00036     <link linkend="_mpu6050_8cpp_1a0be9b422bb8613f8444db4af5234e1a1">MPU_Write_Byte</link>(<link linkend="_mpu6050_8h_1a6ac27367cd834a85810e99df72b97621">MPU_FIFO_EN_REG</link>,0X00);   <emphasis role="comment">//关闭FIFO</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00037"/>00037     <link linkend="_mpu6050_8cpp_1a0be9b422bb8613f8444db4af5234e1a1">MPU_Write_Byte</link>(<link linkend="_mpu6050_8h_1a41676476ba5dbb1b213f8f8e252d17f9">MPU_INTBP_CFG_REG</link>,0X80); <emphasis role="comment">//INT引脚低电平有效</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00038"/>00038     res=<link linkend="_mpu6050_8cpp_1a17c11d19a2bb21d61610f08cb2cbe2f7">MPU_Read_Byte</link>(<link linkend="_mpu6050_8h_1a9668e5ccfcfb0aa64da044a381a56f9c">MPU_DEVICE_ID_REG</link>);
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00039"/>00039     <emphasis role="keywordflow">if</emphasis>(res==<link linkend="_mpu6050_8h_1ac3281ee64415e63422da7d65db161891">MPU_ADDR</link>)<emphasis role="comment">//器件ID正确</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00040"/>00040     {
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00041"/>00041         <link linkend="_mpu6050_8cpp_1a0be9b422bb8613f8444db4af5234e1a1">MPU_Write_Byte</link>(<link linkend="_mpu6050_8h_1abbe7ea135ee03eb0f1296ecb22be7554">MPU_PWR_MGMT1_REG</link>,0X01); <emphasis role="comment">//设置CLKSEL,PLL X轴为参考</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00042"/>00042         <link linkend="_mpu6050_8cpp_1a0be9b422bb8613f8444db4af5234e1a1">MPU_Write_Byte</link>(<link linkend="_mpu6050_8h_1a3fa9eb0485744e73d0274b198f0ad705">MPU_PWR_MGMT2_REG</link>,0X00); <emphasis role="comment">//加速度与陀螺仪都工作</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00043"/>00043         <link linkend="_mpu6050_8cpp_1a04e58232ce838e94d54aa2b53287cb41">MPU_Set_Rate</link>(50);                       <emphasis role="comment">//设置采样率为50Hz</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00044"/>00044     }<emphasis role="keywordflow">else</emphasis> <emphasis role="keywordflow">return</emphasis> 1;
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00045"/>00045     <emphasis role="keywordflow">return</emphasis> 0;}
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00046"/>00046 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00055"/><link linkend="_mpu6050_8cpp_1aa27cc30326ce4980b289a0e1c3f76b5e">00055</link> <emphasis role="comment"></emphasis><link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> <link linkend="_mpu6050_8cpp_1aa27cc30326ce4980b289a0e1c3f76b5e">MPU_Set_Gyro_Fsr</link>(<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> fsr){
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00056"/>00056     <emphasis role="keywordflow">return</emphasis> <link linkend="_mpu6050_8cpp_1a0be9b422bb8613f8444db4af5234e1a1">MPU_Write_Byte</link>(<link linkend="_mpu6050_8h_1ac8ce2e66126327cf30cfba19c4c38db5">MPU_GYRO_CFG_REG</link>,fsr<<3);<emphasis role="comment">//设置陀螺仪满量程范围  </emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00057"/>00057     }
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00058"/>00058 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00067"/><link linkend="_mpu6050_8cpp_1a6c391137bc5880c3b5e15e84c5a3380f">00067</link> <emphasis role="comment"></emphasis><link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> <link linkend="_mpu6050_8cpp_1a6c391137bc5880c3b5e15e84c5a3380f">MPU_Set_Accel_Fsr</link>(<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> fsr){
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00068"/>00068     <emphasis role="keywordflow">return</emphasis> <link linkend="_mpu6050_8cpp_1a0be9b422bb8613f8444db4af5234e1a1">MPU_Write_Byte</link>(<link linkend="_mpu6050_8h_1a7bc1a37b846a3869f13a29e00072bbc7">MPU_ACCEL_CFG_REG</link>,fsr<<3);<emphasis role="comment">//设置加速度传感器满量程范围  </emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00069"/>00069     }
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00070"/>00070 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00076"/><link linkend="_mpu6050_8cpp_1a2fb9973c9f5ea5327649d0eef5e96217">00076</link> <emphasis role="comment"></emphasis><link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> <link linkend="_mpu6050_8cpp_1a2fb9973c9f5ea5327649d0eef5e96217">MPU_Set_LPF</link>(<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link> lpf){
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00077"/>00077     <link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> data=0;
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00078"/>00078     <emphasis role="keywordflow">if</emphasis>(lpf>=188)data=1;
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00079"/>00079     <emphasis role="keywordflow">else</emphasis> <emphasis role="keywordflow">if</emphasis>(lpf>=98)data=2;
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00080"/>00080     <emphasis role="keywordflow">else</emphasis> <emphasis role="keywordflow">if</emphasis>(lpf>=42)data=3;
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00081"/>00081     <emphasis role="keywordflow">else</emphasis> <emphasis role="keywordflow">if</emphasis>(lpf>=20)data=4;
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00082"/>00082     <emphasis role="keywordflow">else</emphasis> <emphasis role="keywordflow">if</emphasis>(lpf>=10)data=5;
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00083"/>00083     <emphasis role="keywordflow">else</emphasis> data=6; 
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00084"/>00084     <emphasis role="keywordflow">return</emphasis> <link linkend="_mpu6050_8cpp_1a0be9b422bb8613f8444db4af5234e1a1">MPU_Write_Byte</link>(<link linkend="_mpu6050_8h_1a5034e2fc680fc68faa369a48f6955837">MPU_CFG_REG</link>,data);<emphasis role="comment">//设置数字低通滤波器  </emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00085"/>00085     }
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00086"/>00086 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00092"/><link linkend="_mpu6050_8cpp_1a04e58232ce838e94d54aa2b53287cb41">00092</link> <emphasis role="comment"></emphasis><link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> <link linkend="_mpu6050_8cpp_1a04e58232ce838e94d54aa2b53287cb41">MPU_Set_Rate</link>(<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link> rate){
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00093"/>00093     <link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> data;
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00094"/>00094     <emphasis role="keywordflow">if</emphasis>(rate>1000)rate=1000;
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00095"/>00095     <emphasis role="keywordflow">if</emphasis>(rate<4)rate=4;
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00096"/>00096     data=1000/rate-1;
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00097"/>00097     data=<link linkend="_mpu6050_8cpp_1a0be9b422bb8613f8444db4af5234e1a1">MPU_Write_Byte</link>(<link linkend="_mpu6050_8h_1a4b95cfafadb4b30146a17fac36819ca3">MPU_SAMPLE_RATE_REG</link>,data);  <emphasis role="comment">//设置数字低通滤波器</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00098"/>00098     <emphasis role="keywordflow">return</emphasis> <link linkend="_mpu6050_8cpp_1a2fb9973c9f5ea5327649d0eef5e96217">MPU_Set_LPF</link>(rate/2); <emphasis role="comment">//自动设置LPF为采样率的一半</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00099"/>00099     }
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00100"/>00100 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00105"/><link linkend="_mpu6050_8cpp_1a41eaf87c26b1281d9d5fc6a06abcf2a8">00105</link> <emphasis role="comment"></emphasis><emphasis role="keywordtype">short</emphasis> <link linkend="_mpu6050_8cpp_1a41eaf87c26b1281d9d5fc6a06abcf2a8">MPU_Get_Temperature</link>(<emphasis role="keywordtype">void</emphasis>){
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00106"/>00106     <link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> buf[2]; 
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00107"/>00107     <emphasis role="keywordtype">short</emphasis> raw;
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00108"/>00108     <emphasis role="keywordtype">float</emphasis> temp;
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00109"/>00109     <link linkend="_mpu6050_8cpp_1a63161fa966899e4e7c5791e40ebf2b0a">MPU_Read_Len</link>(<link linkend="_mpu6050_8h_1ac3281ee64415e63422da7d65db161891">MPU_ADDR</link>,<link linkend="_mpu6050_8h_1af2665b26b7f1ce9b3982a9f6418748e9">MPU_TEMP_OUTH_REG</link>,2,buf); 
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00110"/>00110     raw=((<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>)buf[0]<<8)|buf[1];  
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00111"/>00111     temp=36.53+((double)raw)/340;  
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00112"/>00112     <emphasis role="keywordflow">return</emphasis> temp*100;}
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00113"/>00113 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00121"/><link linkend="_mpu6050_8cpp_1a8f28105f9dcccc709b78d7d0ce497633">00121</link> <emphasis role="comment"></emphasis><link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> <link linkend="_mpu6050_8cpp_1a8f28105f9dcccc709b78d7d0ce497633">MPU_Get_Gyroscope</link>(<emphasis role="keywordtype">short</emphasis> *gx,<emphasis role="keywordtype">short</emphasis> *gy,<emphasis role="keywordtype">short</emphasis> *gz){
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00122"/>00122     <link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> buf[6],res;  
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00123"/>00123     res=<link linkend="_mpu6050_8cpp_1a63161fa966899e4e7c5791e40ebf2b0a">MPU_Read_Len</link>(<link linkend="_mpu6050_8h_1ac3281ee64415e63422da7d65db161891">MPU_ADDR</link>,<link linkend="_mpu6050_8h_1a7e16f1a459d902b070ca67df67be862b">MPU_GYRO_XOUTH_REG</link>,6,buf);
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00124"/>00124     <emphasis role="keywordflow">if</emphasis>(res==0){
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00125"/>00125         *gx=((<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>)buf[0]<<8)|buf[1];  
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00126"/>00126         *gy=((<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>)buf[2]<<8)|buf[3];  
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00127"/>00127         *gz=((<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>)buf[4]<<8)|buf[5];}
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00128"/>00128     <emphasis role="keywordflow">return</emphasis> res;}
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00129"/>00129 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00137"/><link linkend="_mpu6050_8cpp_1a2a0a02f6d7c597828a0cc282c76e99e3">00137</link> <emphasis role="comment"></emphasis><link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> <link linkend="_mpu6050_8cpp_1a2a0a02f6d7c597828a0cc282c76e99e3">MPU_Get_Accelerometer</link>(<emphasis role="keywordtype">short</emphasis> *ax,<emphasis role="keywordtype">short</emphasis> *ay,<emphasis role="keywordtype">short</emphasis> *az){
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00138"/>00138     <link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> buf[6],res;  
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00139"/>00139     res=<link linkend="_mpu6050_8cpp_1a63161fa966899e4e7c5791e40ebf2b0a">MPU_Read_Len</link>(<link linkend="_mpu6050_8h_1ac3281ee64415e63422da7d65db161891">MPU_ADDR</link>,<link linkend="_mpu6050_8h_1a571a31cdf2a467b2b1df39fea686ea0d">MPU_ACCEL_XOUTH_REG</link>,6,buf);
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00140"/>00140     <emphasis role="keywordflow">if</emphasis>(res==0){
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00141"/>00141         *ax=((<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>)buf[0]<<8)|buf[1];  
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00142"/>00142         *ay=((<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>)buf[2]<<8)|buf[3];  
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00143"/>00143         *az=((<link linkend="_varint_8h_1ace9d960e74685e2cd84b36132dbbf8aa">u16</link>)buf[4]<<8)|buf[5];}
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00144"/>00144     <emphasis role="keywordflow">return</emphasis> res;}
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00146"/>00146 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00147"/>00147 <emphasis role="comment">//  适配区</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00156"/><link linkend="_mpu6050_8cpp_1a59b1c26b234be88e97435a1b3c061330">00156</link> <emphasis role="comment"></emphasis><link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> <link linkend="_mpu6050_8cpp_1a59b1c26b234be88e97435a1b3c061330">MPU_Write_Len</link>(<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> addr,<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> reg,<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> len,<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> *buf){
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00157"/>00157     <link linkend="_mpu6050_8cpp_1a0e5583807e7dcaae30835311a2195583">mpu6050IIC</link>.IIC_Write(addr,reg,(<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)buf,len);
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00158"/>00158     <emphasis role="keywordflow">return</emphasis> 0;}
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00159"/>00159 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00168"/><link linkend="_mpu6050_8cpp_1a63161fa966899e4e7c5791e40ebf2b0a">00168</link> <emphasis role="comment"></emphasis><link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> <link linkend="_mpu6050_8cpp_1a63161fa966899e4e7c5791e40ebf2b0a">MPU_Read_Len</link>(<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> addr,<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> reg,<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> len,<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> *buf){
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00169"/>00169     <link linkend="_mpu6050_8cpp_1a0e5583807e7dcaae30835311a2195583">mpu6050IIC</link>.IIC_Read(addr,reg,(<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link>*)buf,len);
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00170"/>00170     <emphasis role="keywordflow">return</emphasis> 0;}
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00171"/>00171 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00178"/><link linkend="_mpu6050_8cpp_1a0be9b422bb8613f8444db4af5234e1a1">00178</link> <emphasis role="comment"></emphasis><link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> <link linkend="_mpu6050_8cpp_1a0be9b422bb8613f8444db4af5234e1a1">MPU_Write_Byte</link>(<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> reg,<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> data){
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00179"/>00179     <link linkend="_mpu6050_8cpp_1a0e5583807e7dcaae30835311a2195583">mpu6050IIC</link>.IIC_WriteOneByte(<link linkend="_mpu6050_8h_1ac3281ee64415e63422da7d65db161891">MPU_ADDR</link>,reg,data);
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00180"/>00180     <emphasis role="keywordflow">return</emphasis> 0;}
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00181"/>00181 <emphasis role="comment">//----------------------------------------------------------------------------------------------------</emphasis>
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00187"/><link linkend="_mpu6050_8cpp_1a17c11d19a2bb21d61610f08cb2cbe2f7">00187</link> <emphasis role="comment"></emphasis><link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> <link linkend="_mpu6050_8cpp_1a17c11d19a2bb21d61610f08cb2cbe2f7">MPU_Read_Byte</link>(<link linkend="_varint_8h_1a92c50087ca0e64fa93fc59402c55f8ca">u8</link> reg){
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00188"/>00188     <emphasis role="keywordflow">return</emphasis> <link linkend="_mpu6050_8cpp_1a0e5583807e7dcaae30835311a2195583">mpu6050IIC</link>.IIC_ReadOneByte(<link linkend="_mpu6050_8h_1ac3281ee64415e63422da7d65db161891">MPU_ADDR</link>,reg);}
|
|
<anchor xml:id="_mpu6050_8cpp_source_1l00190"/>00190
|
|
</programlisting></section>
|