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

📄 seeddec2407view.cpp

📁 usb 上位机程序
💻 CPP
字号:
// SEEDDEC2407View.cpp : implementation of the CSEEDDEC2407View class
//

#include "stdafx.h"
#include "SEEDDEC2407.h"

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

#include "SEEDDEC2407Doc.h"
#include "CntrItem.h"
#include "SEEDDEC2407View.h"

#define VR_USB_VERION       0xB8

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

/////////////////////////////////////////////////////////////////////////////
// CSEEDDEC2407View

IMPLEMENT_DYNCREATE(CSEEDDEC2407View, CRichEditView)

BEGIN_MESSAGE_MAP(CSEEDDEC2407View, CRichEditView)
	//{{AFX_MSG_MAP(CSEEDDEC2407View)
		// 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()

/////////////////////////////////////////////////////////////////////////////
// CSEEDDEC2407View construction/destruction

CSEEDDEC2407View::CSEEDDEC2407View()
{
	// 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;
	}
}

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

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

	return CRichEditView::PreCreateWindow(cs);
}

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


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

/////////////////////////////////////////////////////////////////////////////
// CSEEDDEC2407View printing

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


void CSEEDDEC2407View::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);
   }
}


/////////////////////////////////////////////////////////////////////////////
// CSEEDDEC2407View diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CSEEDDEC2407View message handlers

⌨️ 快捷键说明

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