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

📄 saveini.cpp

📁 M16C Flash Starter Software Ver.2.0.0.46 Source Files.zip是瑞萨的M16C系列单片机的flash烧写程序。
💻 CPP
字号:
// SaveIni.cpp: CSaveIni class  Implementation
//
// 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 "stdafx.h"
#include "M16Cflsh.h"
#include "SaveIni.h"

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

#define INI_FILE	"M16Cflsh.ini"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CSaveIni::CSaveIni()
{

}

CSaveIni::~CSaveIni()
{

}

//////////////////////////////////////////////////////////////////////

	// A communication param is updated.
void CSaveIni::SetComm(DWORD dwBaudRate, BYTE btByteSize, BYTE btStopBits, BYTE btParity)
{
	m_structComm.dwBaudRate = dwBaudRate;
	m_structComm.btByteSize = btByteSize;
	m_structComm.btStopBits = btStopBits;
	m_structComm.btParity = btParity;
}

	// Get communication param.
void CSaveIni::GetComm(DWORD* dwBaudRate, BYTE* btByteSize, BYTE* btStopBits, BYTE* btParity)
{
	*dwBaudRate = m_structComm.dwBaudRate;
	*btByteSize = m_structComm.btByteSize;
	*btStopBits = m_structComm.btStopBits;
	*btParity = m_structComm.btParity;
}

	// Save communication param.
void CSaveIni::SaveComm(void)
{
	CString strSection = "Last Comm State";
	CString strItem;
	CWinApp* pApp = AfxGetApp();

	strItem = "Baundrate";
	pApp->WriteProfileInt(strSection, strItem, m_structComm.dwBaudRate);
	strItem = "Byte";
	pApp->WriteProfileInt(strSection, strItem, m_structComm.btByteSize);
	strItem = "Stop Bit";
	pApp->WriteProfileInt(strSection, strItem, m_structComm.btStopBits);
	strItem = "Parity";
	pApp->WriteProfileInt(strSection, strItem, m_structComm.btParity);
}

	// Load communication param.
const COMM* CSaveIni::LoadComm(void)
{
	CString strSection = "Last Comm State";
	CString strItem;
	CWinApp* pApp = AfxGetApp();

	strItem = "Baundrate";
	m_structComm.dwBaudRate = pApp->GetProfileInt(strSection, strItem, 0);
	if(0 == m_structComm.dwBaudRate)
	{
		return NULL;
	}
	strItem = "Byte";
	m_structComm.btByteSize = pApp->GetProfileInt(strSection, strItem, 0);
	if(0 == m_structComm.btByteSize)
	{
		return NULL;
	}
	strItem = "Stop Bit";
	m_structComm.btStopBits = pApp->GetProfileInt(strSection, strItem, -1);
	if(-1 == m_structComm.btStopBits)
	{
		return NULL;
	}
	strItem = "Parity";
	m_structComm.btParity = pApp->GetProfileInt(strSection, strItem, -1);
	if(-1 == m_structComm.btParity)
	{
		return NULL;
	}

	return &m_structComm;
}
	// A Start condition is updated.
void CSaveIni::SetDType(CString D_Type)
{
	m_str_D_Type = D_Type;
}
void CSaveIni::SetZType(CString Z_Type)
{
	m_str_Z_Type = Z_Type;
}

	// Get Start condition.
void CSaveIni::GetDType(CString* D_Type)
{
	*D_Type = m_str_D_Type;
}
void CSaveIni::GetZType(CString* Z_Type)
{
	*Z_Type = m_str_Z_Type;
}
	// Save Start condition.
void CSaveIni::SaveDType(void)
{
	CString strSection = "mode_info";
	CString strItem;
	CWinApp* pApp = AfxGetApp();

	strItem = "Default_Type";
	pApp->WriteProfileString(strSection, strItem, m_str_D_Type);
//	printf("D_Type = %s \n",m_str_D_Type);
}
void CSaveIni::SaveZType(void)
{
	CString strSection = "mode_info";
	CString strItem;
	CWinApp* pApp = AfxGetApp();

	strItem = "First_data";
	pApp->WriteProfileString(strSection, strItem, m_str_Z_Type);
	printf("Z_Type = %s \n",m_str_Z_Type);
}

	// Load communication param.
const CString* CSaveIni::LoadDType(void)
{
	CString strSection = "mode_info";
	CString strItem;
	CWinApp* pApp = AfxGetApp();

	strItem = "Default_Type";
	m_str_D_Type = pApp->GetProfileString(strSection, strItem);
//	if( !(strcmp(m_str_D_Type ,"-a")))
//	{
//		m_str_D_Type = "-a";
//	}
//	printf("D_TYPE = %s\n",m_str_D_Type);	
	return &m_str_D_Type;
}
const CString* CSaveIni::LoadZType(void)
{
	CString strSection = "mode_info";
	CString strItem;
	CWinApp* pApp = AfxGetApp();

	strItem = "First_data";
	m_str_Z_Type = pApp->GetProfileString(strSection, strItem);
	printf("Z_TYPE = %s\n",m_str_Z_Type);	
	
	return &m_str_Z_Type;
}
//
DWORD CSaveIni::GetReadTimeout(DWORD defTimeout)
{
	return AfxGetApp()->GetProfileInt("timeout", "pageread", defTimeout);
}

⌨️ 快捷键说明

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