?? shengfangagsi.cpp
字號:
// shengfangagsi.cpp : Defines the initialization routines for the DLL.
//
#include "stdafx.h"
#include "Agsi.h"
#include "Common.h"
#include "shengfangagsi.h"
#include "Dlgshengfang.h"
#include "psrun.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern int kin;
extern char at24cio;
DWORD port1;
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////
// CShengfangagsiApp
static DWORD tl3; // Current values
static DWORD tl3p; // Previous values
BEGIN_MESSAGE_MAP(CShengfangagsiApp, CWinApp)
//{{AFX_MSG_MAP(CShengfangagsiApp)
// 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()
/////////////////////////////////////////////////////////////////////////////
// CShengfangagsiApp construction
CShengfangagsiApp::CShengfangagsiApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CShengfangagsiApp object
CShengfangagsiApp theApp;
DWORD DefineAllSFR(void) { // declare all special function registers and their bits
BOOL ret = TRUE;
ret &= Agsi.DefineSFR("T3CON", T3CON, AGSIBYTE, 0); // If more SFR's are defined, do it in a table
ret &= Agsi.DefineSFR("T3MOD", T3MOD, AGSIBYTE, 0);
ret &= Agsi.DefineSFR("TL3", TL3, AGSIBYTE, 0);
ret &= Agsi.DefineSFR("TH3", TH3, AGSIBYTE, 0);
// It is only allowed to define bits which are bitaddressable.
ret &= Agsi.DefineSFR("TF3", T3CON, AGSIBIT, 7);
ret &= Agsi.DefineSFR("TR3", T3CON, AGSIBIT, 6);
ret &= Agsi.DefineSFR("ET3", IE, AGSIBIT, 6);
ret &= Agsi.DefineSFR("PT3", IP, AGSIBIT, 6);
return(ret);
}
//static DWORD tl3; // Current values
//static DWORD tl3p; // Previous values
struct vtrlist VTREG[] = { { "PORT1", AGSIVTRCHAR, 0x00000000, NULL }, };
DWORD DefineAllVTREG(void) { // declare all virtual registers
BOOL ret = TRUE;
int i;
for (i = 0; i < (sizeof(VTREG) / sizeof (VTREG[0])); i++) {
VTREG[i].hVTR = Agsi.DefineVTR(VTREG[i].pName, VTREG[i].Type, VTREG[i].Value);
if (!VTREG[i].hVTR) ret = FALSE;
}
return(ret);
}
void Watchp10()
{
DWORD cSBUF, pSBUF;
Agsi.ReadSFR(0x90, &cSBUF, &pSBUF, 0xFF);
CString str;
DWORD d=GetTickCount();
//str.Format("%d,%x\r\n",d,pSBUF);
//TRACE(str);
Agsi.ReadSFR(TL3, &tl3, &tl3p, 0xFF);
str.Format("%d,%d,%x,%x\r\n",kin,d,tl3p,port1);
TRACE(str);
}
DWORD DefineAllWatches(void)
{ // define all Watches
BOOL ret = TRUE;
ret &= Agsi.SetWatchOnSFR(0x90, Watchp10, AGSIWRITE); //檢測p1寫
return(ret);
}
DWORD DefineAllMenuEntries(void)
{
if (!Agsi.DefineMenuItem(&PeriMenu))
{
return(FALSE);
}
return(TRUE);
}
extern "C" DWORD AGSIEXPORT AgsiEntry (DWORD nCode, void *vp)
{
DWORD CpuType;
switch (nCode)
{
case AGSI_CHECK:
CpuType = *((DWORD *)vp);
if (CpuType == 8051) return(1); // This driver supports the 8051 family of microcontrollers
else return(0); // Other microcontrollers are not supported by the driver
break;
case AGSI_INIT: // Declare all SFR's, VTREG's, Watches and Interrupts here
AgsiConfig = *((AGSICONFIG *)vp);
//AgsiConfig.m_hInstance; // this pointer is used to get the function addresses of uVision
//AgsiConfig.m_pszProjectPath; // Path to application e.g. C:\KEIL\C51\EXAMPLES\HELLO
//AgsiConfig.m_pszDevice; // Simulated Device e.g. 52. This string is extracted out of the -p option.
//AgsiConfig.m_pszConfiguration; // complete dialog DLL options e.g. -p52 -dmydll ...
//AgsiConfig.m_pszAppFile; // name of loaded OMF file including path e.g. C:\KEIL\C51\EXAMPLES\HELLO\HELLO
if (!GetFunctionPointers()) return(FALSE); // get all function pointers for Agsi calls
if (!DefineAllVTREG()) return(FALSE); // define all virtual registers
if (!DefineAllSFR()) return(FALSE); // define all special function registers registers
if (!DefineAllMenuEntries()) return(FALSE); // define all peripheral-menu entries and dialogs
if (!DefineAllWatches()) return(FALSE); // define all watches
break;
case AGSI_TERMINATE: // Free all allocated memory, close all files ...
break;
case AGSI_RESET: // Reset all SFR's of this peripheral
//if (!ResetPeripheral()) return(FALSE);
break;
case AGSI_PREPLL: // Recalculate all peripherals before clock prescaler/PLL is set to a new value
break;
case AGSI_POSTPLL: // Recalculate all peripherals after clock prescaler/PLL is set to a new value
break;
}
return(TRUE); // return OK
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -