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

📄 interrupt.cpp

📁 Windows 2000下PCI数据采集卡WDM驱动,非常完整
💻 CPP
字号:
// LoadFile.cpp : Defines the entry point for the console applicaDSPon.
//

#include "stdafx.h"
#include "Interrupt.h"

#include "..\..\inc\DSP100.h"
#include "..\..\inc\reg.h"

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

/////////////////////////////////////////////////////////////////////////////
// The one and only applicaDSPon object

CWinApp theApp;

using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
	int nRetCode = 0;

	// iniDSPalize MFC and print and error on failure
	if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
	{
		// TODO: change error code to suit your needs
		cerr << _T("Fatal Error: MFC iniDSPalizaDSPon failed") << endl;
		nRetCode = 1;
	}
	else
	{
		// TODO: code your applicaDSPon's behavior here.
		CString strHello;
		strHello.LoadString(IDS_HELLO);
		cout << (LPCTSTR)strHello << endl;
	}

	//Add code 
	
	DSPSTATUS status	= DSP_OK;
	
	HDSP100 hdsp		= NULL;
	
	DWORD dwSize		= 0;
	DWORD dwRVal		= 0;
	
	DWORD dwMask		= 0;
	DWORD dwShift		= 0;
	DWORD dwData		= 0;
	
	DWORD dwSegment		= 0;
	DWORD dwOffset		= 0;
	
	HANDLE hMap			= NULL;
	BYTE *pBuffer		= NULL;
	
	int i = 0, j = 0;

	status = BeginDSP100(1, &hdsp);
	
	//Lock 4m memory window
	status = DSP100LockMem(hdsp, -1, -1 , &hMap, (PVOID *)&pBuffer);
	
	if (DSP_SUCCESS(status)) {
		//Reset DSP
		status = DSP100ReadPortULong(hdsp, HDCR, &dwData);
		if (DSP_SUCCESS(status)) {
			dwData |= 0x1;
			status = DSP100WritePortULong(hdsp, HDCR, dwData);
		}
		
		status = DSP100WritePortULong(hdsp, DSPP, 0x400);
		ZeroMemory(pBuffer, 64 * 1024);
		DSP100LoadProgram(pBuffer, "test01_int_s.bin");
		
		//Initialize DSP Write only zone
		dwSegment	=  0x8000ffe0 / 0x400000;
		dwSegment	|= 0x400;
		dwOffset	=  0x8000ffe0 % 0x400000;
		DSP100WritePortULong(hdsp, DSPP, dwSegment);
		ZeroMemory(pBuffer + dwOffset, 32 * 4);
		printf("DSP Write only zone 1 is 0x%x \n", *(DWORD *)(pBuffer + dwOffset));
		printf("DSP Write only zone 2 is 0x%x \n", *(DWORD *)(pBuffer + dwOffset + 4));
		
		//Initialize PCI Write only zone
		dwSegment	=  0x8000ffc0 / 0x400000;
		dwSegment	|= 0x400;
		dwOffset	=  0x8000ffc0 % 0x400000;
		DSP100WritePortULong(hdsp, DSPP, dwSegment);
		ZeroMemory(pBuffer + dwOffset, 32 * 4);
		printf("PCI Write only zone 1 is 0x%x \n", *(DWORD *)(pBuffer + dwOffset));
		printf("PCI Write only zone 2 is 0x%x \n", *(DWORD *)(pBuffer + dwOffset + 4));

		DSP100ReadPortULong(hdsp, HSR, &dwData);
		dwData &= 0xfffffffb;
		DSP100WritePortULong(hdsp, HSR, dwData);
		
		//Set DSPINT and release dsp from reset
		status = DSP100ReadPortULong(hdsp, HDCR, &dwData);
		if (DSP_SUCCESS(status)) {
			dwData |= 0x2;
			status = DSP100WritePortULong(hdsp, HDCR, dwData);
		}
		
		//Read DSP write only zone
		dwSegment	=  0x8000ffe0 / 0x400000;
		dwSegment	|= 0x400;
		dwOffset	=  0x8000ffe0 % 0x400000;
		DSP100WritePortULong(hdsp, DSPP, dwSegment);
		
		printf("DSP Write only zone 1 is 0x%x \n", *(DWORD *)(pBuffer + dwOffset));
		printf("DSP Write only zone 2 is 0x%x \n", *(DWORD *)(pBuffer + dwOffset + 4));
	
		//Set PCI Write only zone
		dwSegment	=  0x8000ffc0 / 0x400000;
		dwSegment	|= 0x400;
		dwOffset	=  0x8000ffc0 % 0x400000;
		DSP100WritePortULong(hdsp, DSPP, dwSegment);

		*(DWORD *)(pBuffer + dwOffset) = 0x1c1c1c1c;
		printf("Set PCI Write only zone 1 to 0x0 \n");
			
		printf("PCI Write only zone 1 is 0x%x \n", *(DWORD *)(pBuffer + dwOffset));
		printf("PCI Write only zone 2 is 0x%x \n", *(DWORD *)(pBuffer + dwOffset + 4));

		//Set DSPINT and release dsp from reset
		status = DSP100ReadPortULong(hdsp, HDCR, &dwData);
		if (DSP_SUCCESS(status)) {
			dwData |= 0x2;
			status = DSP100WritePortULong(hdsp, HDCR, dwData);
		}
		
		//Read DSP write only zone
		dwSegment	=  0x8000ffe0 / 0x400000;
		dwSegment	|= 0x400;
		dwOffset	=  0x8000ffe0 % 0x400000;
		DSP100WritePortULong(hdsp, DSPP, dwSegment);
		
		printf("DSP Write only zone 1 is 0x%x \n", *(DWORD *)(pBuffer + dwOffset));
		printf("DSP Write only zone 2 is 0x%x \n", *(DWORD *)(pBuffer + dwOffset + 4));
		
		//Read HSR
		status = DSP100ReadPortULong(hdsp, HSR, &dwData);
		if (DSP_SUCCESS(status)) {
			printf("HSR is 0x%x \n", dwData);
		}
		
		dwData |= 0x4;
		DSP100WritePortULong(hdsp, HSR, dwData);
	}
		
	//Unlock 
	status = DSP100UnlockMem(hdsp, hMap);
	
	status = EndDSP100(hdsp);
	
	return nRetCode;

}

⌨️ 快捷键说明

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