⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex02dll.cpp

📁 该模拟器是在Keil7.0中使用。 只要把Ex02Dll.dll复制到 X:KeilC51BIN目录下。 打开测试程序
💻 CPP
字号:
// Ex02Dll.cpp : Defines the initialization routines for the DLL.
//

#include "stdafx.h"
#include "Ex02Dll.h"
#include "AGSI.h"
#include "Common.h"
#include "Formclass.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

//
//	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.
//

/////////////////////////////////////////////////////////////////////////////
// CEx02DllApp

BEGIN_MESSAGE_MAP(CEx02DllApp, CWinApp)
	//{{AFX_MSG_MAP(CEx02DllApp)
		// 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()

/////////////////////////////////////////////////////////////////////////////
// CEx02DllApp construction

CEx02DllApp::CEx02DllApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CEx02DllApp object

CEx02DllApp theApp;
/////////////////////////////////////////////////////////////////////////////

static DWORD  cP0,pP0;

AGSITIMER SWTimer;

void timer3 (void) {

}

DWORD DefineAllSFR(void) {           // declare all special function registers and their bits
  BOOL ret = TRUE;
  ret &= Agsi.DefineSFR("P0", 0x80 , AGSIBYTE, 0);  // If more SFR's are defined, do it in a table
  return(ret);
}

DWORD DefineAllWatches(void) {      // define all Watches
  BOOL ret = TRUE;
  ret &= Agsi.SetWatchOnSFR(P0,   timer3, AGSIREAD);

  SWTimer = Agsi.CreateTimer(timer3);
  if (!SWTimer) return(FALSE);
  Agsi.SetTimer(SWTimer,10);
  return(ret);
}



DWORD DefineAllMenuEntries(void) {  // declare all peripheral-menu entries and dialogs

  if (!Agsi.DefineMenuItem(&FormMenu)) 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);
      if (!GetFunctionPointers()) return(FALSE);   // get all function pointers for Agsi calls
	  if (!DefineAllMenuEntries()) return(FALSE);
//	  if (!DefineAllSFR()) return(FALSE);          // define all special function registers
	  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
      
	  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 + -