📄 loadfile.cpp
字号:
// LoadFile.cpp : Defines the entry point for the console applicaDSPon.
//
#include "stdafx.h"
#include "LoadFile.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;
HANDLE hFile = INVALID_HANDLE_VALUE;
HANDLE hMapFile = NULL;
BYTE *pDSPProg = NULL;
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);
}
//Load bin to interal program RAM
status = DSP100WritePortULong(hdsp, DSPP, 0x400);
DSP100LoadProgram(pBuffer, "test01_acces.bin");
//Initialize PCI only read zone
dwSegment = 0x8000ffe0 / 0x400000;
dwSegment |= 0x400;
dwOffset = 0x8000ffe0 % 0x400000;
DSP100WritePortULong(hdsp, DSPP, dwSegment);
ZeroMemory(pBuffer + dwOffset, 32 * 4);
printf("DSP zone 0x%0x \n", *(DWORD *)(pBuffer + dwOffset));
//Set DSPINT and release dsp from reset
status = DSP100ReadPortULong(hdsp, HDCR, &dwData);
if (DSP_SUCCESS(status)) {
dwData |= 0x2;
status = DSP100WritePortULong(hdsp, HDCR, dwData);
}
//Read PCI read only zone
dwSegment = 0x8000ffe0 / 0x400000;
dwSegment |= 0x400;
dwOffset = 0x8000ffe0 % 0x400000;
DSP100WritePortULong(hdsp, DSPP, dwSegment);
printf("DSP zone 0x%x \n", *(DWORD *)(pBuffer + dwOffset));
//Unlock
status = DSP100UnlockMem(hdsp, hMap);
}
status = EndDSP100(hdsp);
return nRetCode;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -