九、代码3

     Dlgshengfang.cpp VC-VIEW-CLASSWIZARD,PROJECT:SHENGFANGAGSI;CLASSNAME:CDLGSHENGFANG,OBJEOBJECT IDS:CDLGSHENGFANG;messages:www.yippeesoft.com选择WM_INITDIALOG,点击 ADD FUNCTION,确定。www.yippeesoft.com

BOOL CDlgshengfang::OnInitDialog()
&leftsign;
 CDialog::OnInitDialog();
 // TODO: Add extra initialization herewww.yippeesoft.com
 if (PeriDlg.rc.left != -1) &leftsign;
      SetWindowPos(NULL,           /* placement order – not used */
                 PeriDlg.rc.left,             /* left */
                 PeriDlg.rc.top,              /* top  */
                 0,      www.yippeesoft.com                     /* width – not used */
                 0,                           /* height – not used */
                 SWP_NOSIZE &line; SWP_NOZORDER);  /* flags */
 &rightsign;www.yippeesoft.com
 return TRUE;  // return TRUE unless you set the focus to a control
               // EXCEPTION: OCX Property Pages should return FALSE
&rightsign;

十、代码4www.yippeesoft.com

     同样为WM_CLOSE创建对应函数,www.yippeesoft.com

void CDlgshengfang::OnClose()
&leftsign;
 // 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.yippeesoft.com
&rightsign;

11、代码5www.yippeesoft.com

    shengfangagsi.cpp #include "AGSI.h"  #include "common.h" extern AGSIMENU PeriMenu;  // Peripheral Dialog

    struct vtrlist VTREG[] = &leftsign; &leftsign; "PORT1",   AGSIVTRCHAR, 0×00000000, NULL &rightsign;, &rightsign;;
void Watchp10()
&leftsign;
 DWORD   cSBUF, pSBUF;[hide]

 Agsi.ReadSFR(0×90, &cSBUF,  &pSBUF,  0xFF);
 CString str;
 DWORD d=GetTickCount();
 str.Format("%d,%x\\r\\n",d,pSBUF);
 TRACE(str);
&rightsign;[/hide]

DWORD DefineAllWatches(void)
&leftsign;      // define all Watches
 BOOL ret = TRUE;www.yippeesoft.com

 ret &= Agsi.SetWatchOnSFR(0×90, Watchp10, AGSIWRITE); //检测p1写

 return(ret);
 
&rightsign;

// declare all virtual registers
DWORD DefineAllVTREG(void)  
&leftsign;        
 // BOOL ret = TRUE;www.yippeesoft.com
 // int i;
 //
 // for (i = 0; i < (sizeof(VTREG) / sizeof (VTREG[0])); i++)
 // &leftsign;
 //  VTREG[i].hVTR = Agsi.DefineVTR(VTREG[i].pName, VTREG[i].Type, VTREG[i].Value);
 //  if (!VTREG[i].hVTR) ret = FALSE;
 // &rightsign;
 // return(ret);
 return TRUE;
&rightsign;
DWORD DefineAllMenuEntries(void)
&leftsign;  www.yippeesoft.com

 if (!Agsi.Dwww.yippeesoft.comefineMenuItem(&PeriMenu))
 &leftsign;
  return(FALSE);
 &rightsign;
 return(TRUE);
&rightsign;

extern "C" DWORD AGSIEXPORT AgsiEntry (DWORD nCode, void *vp) &leftsign;
 DWORD CpuType;

 switch (nCode) &leftsign;www.yippeesoft.com
  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.yippeesoft.com
   //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.yippeesoft.com
 &rightsign;
 return(TRUE);       // return OK
&rightsign;
uVision

历史博文

标签:, , , , ,
七月 20, 2005 at 10:19 上午 by yippee 1,115 次
Category: Dev
Tags: , , , , ,