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

📄 blankcmd.cpp

📁 M16C Flash Starter Software Ver.2.0.0.46 Source Files.zip是瑞萨的M16C系列单片机的flash烧写程序。
💻 CPP
字号:
// BlankCmd. cpp: the implementation of the CBlankCmd class.   
//
// This software can be offered for free and used as necessary to aid 
// in your program developments.
//
// RENESAS TECHNOLOGY CORPORATION, RENESAS SOLUTIONS CORPORATION,
// and related original software developers assume no responsibility 
// for any damage or infringement of any third-party's rights, originating 
// in the use of the following software.
// Please use this software under the agreement and acceptance of these conditions. 
//
// Copyright(C)1998(2003) RENESAS TECHNOLOGY CORPORATION AND RENESAS SOLUTIONS CORPORATION
// ALL RIGHTS RESERVED
//
//////////////////////////////////////////////////////////////////////
#include <afxtempl.h>

#include "stdafx.h"
#include "M16Cflsh.h"
#include "PrgssDlg.h"

#include "BlankCmd.h"

#include "defining.h"

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

//////////////////////////////////////////////////////////////////////
//Construction/disappearance
//////////////////////////////////////////////////////////////////////

CBlankCmd::CBlankCmd()
{

}

CBlankCmd::~CBlankCmd()
{

}

//////////// Addition //////////////////////////////////////////

BOOL CBlankCmd::exec(void)
{
	BOOL bResult = FALSE;
	CM16CflshApp*		pApp = (CM16CflshApp*)AfxGetApp();
	MSG				msg;

	// I acquire the communication object.
	CSerialComm& comObj = GetSerialComm();

	//I acquire the address of the range where I check blanks. 
	unsigned int nStartAddress = 0;
	unsigned int nEndAddress = 0;
	//It is the address, default value.
//	if(!GetAddressFromDialg(&nStartAddress, &nEndAddress, ADDRESS_SIZE))
	//The use range of the address, file.
	if(!GetFileAddress(&nStartAddress, &nEndAddress, ADDRESS_SIZE))
	{
		return FALSE;
	}

	//It ends if the start address is bigger than the end address. 
	if(!ChkStartToEnd(nStartAddress, nEndAddress))
	{
		AfxGetMainWnd()->MessageBox(GetResString(IDS_SMALESTART), GetResString(IDS_FLASH_TITLE), MB_ICONWARNING);
		return FALSE;
	}

	//Setting the dialog for the progress report.
	CProgressDlg* pDlg;
	BOOL bCancel = FALSE;
	pDlg = CProgressDlg::Instance(&bCancel, NULL);
	pDlg->InitialDialog("Blank check.", "Blank Check", 
							0, (nEndAddress - nStartAddress - 0x0100) / TO_INT, 0);

	//I check the memory range where it was designated blanks. 
	for(int nSendAddress = nStartAddress; (long)nSendAddress < (long)nEndAddress;
												nSendAddress += 0x0100)
	{												
		//I receive data.
		comObj.CleanUp(NULL);
		BYTE receive[PAGE_SIZE];
		if(!DoRead(&comObj, receive, nSendAddress))
		{
			pDlg->Done();
			return FALSE;
		}

		// I check whether there is blanks.
		CString strOther;
		for(int nIndex = 0; nIndex < PAGE_SIZE; nIndex++)
		{
			if(BLANK != receive[nIndex])
			{
				// Except for blank was discovered.
				CString strFindMsg = GetResString(IDS_FIND_NBLANK);
				strFindMsg += HexToStr(nSendAddress + nIndex);
				AfxGetMainWnd()->MessageBox(strFindMsg, GetResString(IDS_FLASH_TITLE));
				pDlg->Done();
				return bResult;
			}
		}

		// Progress bar renewal for the progress report.   
		pDlg->SetProgressPos((nSendAddress - nStartAddress) / TO_INT);

		// The implementation of the event.   
  		while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
			if (!pApp->PumpMessage()) {
				::PostQuitMessage(0);
				break;
			}
		}
		if(bCancel)
		{
			break;
		}
		Sleep(10);
		// I wait until next it becomes a transmission passable. 
	}
	pDlg->Done();

	return	bResult;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -