首页 Soft PlugIn RAN乱 Dev开发 Info资料 English WAP 留言 登陆 注册
-
Posted by Yippee | 评论(1) | 引用(0) | 阅读2854次
Keil uVision c51 agsi 插件DLL制作3

九、代码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


字体:

Permanant URI永久地址 http://www.shengfang.org/blog/p/keilagsi3.php
Trackback URI引用地址 http://www.shengfang.org/blog/tb.php?tb_id=1121825947

2005年7月20日10:19星期三  [Dev开发] 追踪此文的RSS
路过在 2007年12月16日00:20星期日 评论:

称呼:    登陆   注册
   不注册,但记住我的信息
邮件:
(非必须)
评论: [UBB代码帮助]
粗体 斜体 下划线 链接 水平线 引用



验证码: 请输入你看见的数字
关闭UBB      提交时自动将内容复制到剪贴板

公告
Fire and Motion!

统计信息
[Yippee]||[统计]||日志:1839
在线: 16||用户: 2576 [列表]
今日:2237||到访:2854091
Rss:885225||评论:1604

最新日志

最新评论

友情链接

日历

最新引用

搜索

归档

杂项
Get RSS Feed (Version 2.0)
Get Atom Feed (Version 0.3)
编码:  UTF-8