📄 spectrumdll.cpp
字号:
// spectrumdll.cpp : Defines the initialization routines for the DLL.
//
#include "stdafx.h"
#include "spectrumdll.h"
#include "funfile.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//
// Note!
//
// If this DLL is dynamically linked against the MFC
// DLLs, any functions exported from this DLL which
// call into MFC must have the AFX_MANAGE_STATE macro
// added at the very beginning of the function.
//
// For example:
//
// extern "C" BOOL PASCAL EXPORT ExportedFunction()
// {
// AFX_MANAGE_STATE(AfxGetStaticModuleState());
// // normal function body here
// }
//
// It is very important that this macro appear in each
// function, prior to any calls into MFC. This means that
// it must appear as the first statement within the
// function, even before any object variable declarations
// as their constructors may generate calls into the MFC
// DLL.
//
// Please see MFC Technical Notes 33 and 58 for additional
// details.
//
/////////////////////////////////////////////////////////////////////////////
// CSpectrumdllApp
BEGIN_MESSAGE_MAP(CSpectrumdllApp, CWinApp)
//{{AFX_MSG_MAP(CSpectrumdllApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSpectrumdllApp construction
CSpectrumdllApp::CSpectrumdllApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CSpectrumdllApp object
CSpectrumdllApp theApp;
extern "C" int _stdcall ReadTTL(int * Input0,int * Input1,int * Input2,int * Input3,int * Input4)
{
HANDLE hDriver=NULL;
hDriver=hOpenDevice();
if(!hDriver) return 0;
if(!BulkRead(hDriver)) return 0;
if(!CloseDevice(hDriver)) return 0;
if(BulkReadData[0]&0x01) *Input0=1; else *Input0=0;
if(BulkReadData[0]&0x02) *Input1=1; else *Input1=0;
if(BulkReadData[0]&0x04) *Input2=1; else *Input2=0;
if(BulkReadData[0]&0x08) *Input3=1; else *Input3=0;
if(BulkReadData[0]&0x10) *Input4=1; else *Input4=0;
return 1;
}
extern "C" int _stdcall ReadAmp(int * Amp0,int * Amp1)
{
unsigned short temp1,temp0;
HANDLE hDriver=NULL;
hDriver=hOpenDevice();
if(!hDriver) return 0;
if(!BulkRead(hDriver)) return 0;
if(!CloseDevice(hDriver)) return 0;
temp0=*((unsigned short *)(BulkReadData+1));
temp1=*((unsigned short *)(BulkReadData+3));
*Amp0=(int)temp0;
*Amp1=(int)temp1;
return 1;
}
extern "C" int _stdcall WriteMotor(int Motor0,int Motor1,int Motor2,int Motor3,int Motor4)
{
union MOTOR{
int a;
unsigned char output;
};
MOTOR temp;
HANDLE hDriver=NULL;
hDriver=hOpenDevice();
if(!hDriver) return 0;
temp.a=Motor0;
BulkWriteData[0]=temp.output;
temp.a=Motor1;
BulkWriteData[1]=temp.output;
temp.a=Motor2;
BulkWriteData[2]=temp.output;
temp.a=Motor3;
BulkWriteData[3]=temp.output;
temp.a=Motor4;
BulkWriteData[4]=temp.output;
if(!BulkWrite(hDriver)) return 0;
if(!CloseDevice(hDriver)) return 0;
return 1;
}
extern "C" int _stdcall PowerSwitch(int Sw0,int Sw1)
{
HANDLE hDriver=NULL;
hDriver=hOpenDevice();
if(!hDriver) return 0;
if(!VendorCmmd(hDriver,Sw0,Sw1)) return 0;
if(!CloseDevice(hDriver)) return 0;
return 1;
}
extern "C" int _stdcall Hold8051Reset(void)
{
HANDLE hDriver=NULL;
hDriver=hOpenDevice();
if(!hDriver) return 0;
if(!Reset8051Hold(hDriver)) return 0;
if(!CloseDevice(hDriver)) return 0;
return 1;
}
extern "C" int _stdcall Free8051Reset(void)
{
HANDLE hDriver=NULL;
hDriver=hOpenDevice();
if(!hDriver) return 0;
if(!Reset8051Free(hDriver)) return 0;
if(!CloseDevice(hDriver)) return 0;
return 1;
}
extern "C" int _stdcall ChangeAmp(int Amp0,int Amp1)
{
union MOTOR{
int a;
unsigned char output;
};
MOTOR temp;
temp.a=Amp0;
BulkWriteData[5]=temp.output;
temp.a=Amp1;
BulkWriteData[6]=temp.output;
HANDLE hDriver=NULL;
hDriver=hOpenDevice();
if(!hDriver) return 0;
if(!BulkWrite(hDriver)) return 0;
if(!CloseDevice(hDriver)) return 0;
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -