资源简介
压缩包里面含有MPU6050六轴陀螺仪模块的c语言源码及陀螺仪的使用手册。
代码片段和文件信息
#include
#include
#include
#include
#include “Com.h“
#define TOTAL_PORT_NUM 65
#define START_PORT_NUM 0
#define iBufferSize 250
#define UARTBufferLength 98304
#undef SYNCHRONOUS_MODE
static HANDLE hComDev[TOTAL_PORT_NUM] ={NULL};
static unsigned long long ulComMask = 0;
static HANDLE hCOMThread[TOTAL_PORT_NUM] ={NULL};
static OVERLAPPED stcWriteStatus[TOTAL_PORT_NUM] = {0};
static OVERLAPPED stcReadStatus[TOTAL_PORT_NUM] = {0};
#ifdef SYNCHRONOUS_MODE
static HANDLE hReceiveEvent[TOTAL_PORT_NUM] ={NULL};
#endif
static volatile char chrUARTBuffers[TOTAL_PORT_NUM][UARTBufferLength]={0};
static volatile unsigned long ulUARTBufferStart[TOTAL_PORT_NUM]={0} ulUARTBufferEnd[UARTBufferLength]={0};
unsigned short CollectUARTData(const unsigned long ulCOMNochar chrUARTBufferOutput[])
{
unsigned long ulLength=0;
unsigned long ulEnd ;
unsigned long ulStart ;
#ifdef SYNCHRONOUS_MODE
WaitForSingleobject(hReceiveEvent[ulIndexCorrect]INFINITE);
ResetEvent(hReceiveEvent[ulIndexCorrect]);
#endif
ulEnd = ulUARTBufferEnd[ulCOMNo];
ulStart = ulUARTBufferStart[ulCOMNo];
if (ulEnd == ulStart)
return(0);
if (ulEnd > ulStart)
{
memcpy((void*)chrUARTBufferOutput(void*)(chrUARTBuffers[ulCOMNo]+ulStart)ulEnd-ulStart);
ulLength = ulEnd-ulStart;
}
else
{
memcpy((void*)chrUARTBufferOutput(void*)(chrUARTBuffers[ulCOMNo]+ulStart)UARTBufferLength-ulStart);
if ( ulEnd != 0 )
{
memcpy((void*)(chrUARTBufferOutput+(UARTBufferLength-ulStart))(void*)chrUARTBuffers[ulCOMNo]ulEnd);
}
ulLength = UARTBufferLength+ulEnd-ulStart;
}
ulUARTBufferStart[ulCOMNo] = ulEnd;
return (unsigned short) ulLength;
}
signed char SendUARTMessageLength(const unsigned long ulChannelNo const char chrSendBuffer[]const unsigned short usLen)
{
DWORD iR;
DWORD dwRes;
DCB dcb;
char chrDataToSend[1000] = {0};
memcpy(chrDataToSendchrSendBufferusLen);
memcpy(&chrDataToSend[usLen]chrSendBufferusLen);
GetCommState(hComDev[ulChannelNo] &dcb);
dcb.fDtrControl = 0;//DTR = 1;发送
SetCommState(hComDev[ulChannelNo] &dcb);
if ( WriteFile(hComDev[ulChannelNo]chrSendBufferusLen&iR&(stcWriteStatus[ulChannelNo])) || GetLastError() != ERROR_IO_PENDING )
return -1;
dwRes = WaitForSingleobject(stcWriteStatus[ulChannelNo].hEvent1000);
Sleep(10);
dcb.fDtrControl = 1;//DTR = 0;接收
SetCommState(hComDev[ulChannelNo] &dcb);
Sleep(10);
if(dwRes != WAIT_object_0 || ! GetOverlappedResult(hComDev[ulChannelNo] &stcWriteStatus[ulChannelNo] &iR FALSE))
return 0;
return 0;
}
DWORD WINAPI ReceiveCOMData(PVOID pParam)
{
unsigned long uLen;
unsigned long ulLen1;
unsigned long ulLen2;
DWORD dwRes;
COMSTAT Comstat;
DWORD dwErrorFlags;
char chrBuffer[iBufferSize]={0};
unsigned long ulUARTBufferEndTemp=ulUARTBufferEnd[0];
unsigned long ulComNumber = 0;
memcpy(&ulComNumberpParam4)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2013-09-29 16:40 MPU6050\C语言读取模块实例程序VS2010\
目录 0 2013-09-29 16:41 MPU6050\C语言读取模块实例程序VS2010\Debug\
文件 7 2013-09-06 23:25 MPU6050\C语言读取模块实例程序VS2010\Debug\Com.ini
文件 43008 2013-09-29 16:39 MPU6050\C语言读取模块实例程序VS2010\Debug\UARTTest.exe
文件 891 2012-11-03 11:38 MPU6050\C语言读取模块实例程序VS2010\UARTTest.sln
文件 12800 2013-09-29 16:40 MPU6050\C语言读取模块实例程序VS2010\UARTTest.suo
目录 0 2013-09-29 16:41 MPU6050\C语言读取模块实例程序VS2010\UARTTest\
文件 8007 2012-11-03 12:34 MPU6050\C语言读取模块实例程序VS2010\UARTTest\Com.cpp
文件 536 2012-03-23 04:44 MPU6050\C语言读取模块实例程序VS2010\UARTTest\Com.h
文件 7 2013-09-06 23:25 MPU6050\C语言读取模块实例程序VS2010\UARTTest\Com.ini
文件 1560 2012-11-03 11:38 MPU6050\C语言读取模块实例程序VS2010\UARTTest\ReadMe.txt
文件 213 2012-11-03 11:38 MPU6050\C语言读取模块实例程序VS2010\UARTTest\stdafx.cpp
文件 233 2012-11-03 11:38 MPU6050\C语言读取模块实例程序VS2010\UARTTest\stdafx.h
文件 236 2012-11-03 11:38 MPU6050\C语言读取模块实例程序VS2010\UARTTest\targetver.h
文件 2734 2013-09-29 16:39 MPU6050\C语言读取模块实例程序VS2010\UARTTest\UARTTest.cpp
文件 4440 2012-11-03 11:42 MPU6050\C语言读取模块实例程序VS2010\UARTTest\UARTTest.vcxproj
文件 1484 2012-11-03 11:42 MPU6050\C语言读取模块实例程序VS2010\UARTTest\UARTTest.vcxproj.filters
文件 143 2012-11-03 11:38 MPU6050\C语言读取模块实例程序VS2010\UARTTest\UARTTest.vcxproj.user
文件 1266559 2013-09-29 16:36 MPU6050\MPU6050使用说明书V4.pdf
目录 0 2013-09-28 16:43 MPU6050\单片机解析实例\
文件 1104 2013-09-29 16:37 MPU6050\单片机解析实例\main.c
文件 396058 2013-10-15 01:01 MPU6050\单片机解析实例\STM32解析MPU6050.zip
文件 987 2013-09-28 16:43 MPU6050\单片机解析实例\usart.c
目录 0 2013-09-29 01:54 MPU6050\上位机\
文件 194 2013-09-29 16:26 MPU6050\上位机\Config.ini
文件 612 2013-09-28 21:43 MPU6050\上位机\Matlab绘图.m
文件 1135104 2013-09-29 16:24 MPU6050\上位机\MiniIMU.exe
文件 0 2016-01-01 21:06 MPU6050\上位机\加速度.txt
文件 0 2016-01-01 21:06 MPU6050\上位机\角度.txt
文件 0 2016-01-01 21:06 MPU6050\上位机\角速度.txt
目录 0 2013-09-28 16:25 MPU6050\芯片资料\
............此处省略3个文件信息
评论
共有 条评论