九、代码3
Dlgshengfang.cpp VC-VIEW-CLASSWIZARD,PROJECT:SHENGFANGAGSI;CLASSNAME:CDLGSHENGFANG,OBJEOBJECT IDS:CDLGSHENGFANG;messages:www.shengfang.org选择WM_INITDIALOG,点击 ADD FUNCTION,确定。www.shengfang.org
BOOL CDlgshengfang::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization herewww.shengfang.org
if (PeriDlg.rc.left != -1) {
SetWindowPos(NULL, /* placement order - not used */
PeriDlg.rc.left, /* left */
PeriDlg.rc.top, /* top */
0, www.shengfang.org /* width - not used */
0, /* height - not used */
SWP_NOSIZE &line; SWP_NOZORDER); /* flags */
}www.shengfang.org
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
十、代码4www.shengfang.org
同样为WM_CLOSE创建对应函数,www.shengfang.org
void CDlgshengfang::OnClose()
{
// TODO: Add your message handler code here and/or call default
GetWindowRect (&pM->pDlg->rc); // save Window position
pM->pDlg->hw = NULL; // clear m_hWnd
DestroyWindow(); //--- modeless
CDialog::OnClose();www.shengfang.org
}
11、代码5www.shengfang.org
shengfangagsi.cpp #include "AGSI.h" #include "common.h" extern AGSIMENU PeriMenu; // Peripheral Dialog
struct vtrlist VTREG[] = { { "PORT1", AGSIVTRCHAR, 0x00000000, NULL }, };
void Watchp10()
{
DWORD cSBUF, pSBUF;[hide]
Agsi.ReadSFR(0x90, &cSBUF, &pSBUF, 0xFF);
CString str;
DWORD d=GetTickCount();
str.Format("%d,%x\r\n",d,pSBUF);
TRACE(str);
}[/hide]
DWORD DefineAllWatches(void)
{ // define all Watches
BOOL ret = TRUE;www.shengfang.org
ret &= Agsi.SetWatchOnSFR(0x90, Watchp10, AGSIWRITE); //检测p1写
return(ret);
}
// declare all virtual registers
DWORD DefineAllVTREG(void)
{
// BOOL ret = TRUE;www.shengfang.org
// 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);
return TRUE;
}
DWORD DefineAllMenuEntries(void)
{ www.shengfang.org
if (!Agsi.Dwww.shengfang.orgefineMenuItem(&PeriMenu))
{
return(FALSE);
}
return(TRUE);
}
extern "C" DWORD AGSIEXPORT AgsiEntry (DWORD nCode, void *vp) {
DWORD CpuType;
switch (nCode) { www.shengfang.org
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 uVisionwww.shengfang.org
//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 (!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;www.shengfang.org
}
return(TRUE); // return OK
}
uVision