⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 seeddec2xxxview.cpp

📁 实现和dsp6416T通讯的USB上位机程序!可以向DSP发送数据
💻 CPP
字号:
// SEEDDEC2XXXView.cpp : implementation of the CSEEDDEC2XXXView class
//

#include "stdafx.h"
#include "SEEDDEC2XXX.h"

#include "seeddecusb.h"
#include "ezusbsys.h"

#include "SEEDDEC2XXXDoc.h"
#include "CntrItem.h"
#include "SEEDDEC2XXXView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#define VR_USB_VERION       0xB8

/////////////////////////////////////////////////////////////////////////////
// CSEEDDEC2XXXView

IMPLEMENT_DYNCREATE(CSEEDDEC2XXXView, CRichEditView)

BEGIN_MESSAGE_MAP(CSEEDDEC2XXXView, CRichEditView)
	//{{AFX_MSG_MAP(CSEEDDEC2XXXView)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	ON_WM_DESTROY()
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CRichEditView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CRichEditView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CRichEditView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSEEDDEC2XXXView construction/destruction

CSEEDDEC2XXXView::CSEEDDEC2XXXView()
{
	// TODO: add construction code here
	if(OpenDriver() == FALSE)
	{
		AfxMessageBox("打开USB驱动失败,请复位板卡");
	}
	//获得当前的USB工作的标准
		//得到USB工作在2.0标准,还是1.1标准
	/*命令请求定义*/
	char buffer1[64];
	VENDOR_OR_CLASS_REQUEST_CONTROL	myRequest;
	ULONG venderlong;
	int recnBytes = 0;
	/*发送命令,使DSP先定入固定的数据*/
	myRequest.direction = 1;
	myRequest.index = 0;
	myRequest.value = 0;
	myRequest.request = VR_USB_VERION;
	// vendor specific request type (2)
	myRequest.requestType=2; 
    // recepient is device (0)
	myRequest.recepient=0;
	/*传回一个数据长度*/
	venderlong = 1;
	Sx2SendVendorReq(&myRequest,
					 &buffer1[0],
					 venderlong,
					 &recnBytes);
	if(buffer1[0] ==0x55)
	{
		theApp.m_USB2or11 = 1;
		theApp.m_USBbufferlong = 512;
	}
	if((int)buffer1[0] == 0x54)
	{
		theApp.m_USB2or11 = 2;
		theApp.m_USBbufferlong = 64;
	}
}

CSEEDDEC2XXXView::~CSEEDDEC2XXXView()
{
	CloseDriver();
}

BOOL CSEEDDEC2XXXView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CRichEditView::PreCreateWindow(cs);
}

void CSEEDDEC2XXXView::OnInitialUpdate()
{
	CRichEditView::OnInitialUpdate();


	// Set the printing margins (720 twips = 1/2 inch).
	SetMargins(CRect(720, 720, 720, 720));
}

/////////////////////////////////////////////////////////////////////////////
// CSEEDDEC2XXXView printing

BOOL CSEEDDEC2XXXView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}


void CSEEDDEC2XXXView::OnDestroy()
{
	// Deactivate the item on destruction; this is important
	// when a splitter view is being used.
   CRichEditView::OnDestroy();
   COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this);
   if (pActiveItem != NULL && pActiveItem->GetActiveView() == this)
   {
      pActiveItem->Deactivate();
      ASSERT(GetDocument()->GetInPlaceActiveItem(this) == NULL);
   }
}


/////////////////////////////////////////////////////////////////////////////
// CSEEDDEC2XXXView diagnostics

#ifdef _DEBUG
void CSEEDDEC2XXXView::AssertValid() const
{
	CRichEditView::AssertValid();
}

void CSEEDDEC2XXXView::Dump(CDumpContext& dc) const
{
	CRichEditView::Dump(dc);
}

CSEEDDEC2XXXDoc* CSEEDDEC2XXXView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSEEDDEC2XXXDoc)));
	return (CSEEDDEC2XXXDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CSEEDDEC2XXXView message handlers

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -