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

📄 config_page1.cpp.svn-base

📁 vc环境下编译的一个对USB设备进行烧录的驱动程序
💻 SVN-BASE
📖 第 1 页 / 共 3 页
字号:
// Config_Page1.cpp : implementation file
//

#include "stdafx.h"
#include "burnNAND.h"
#include "Config_Page1.h"
#include "burn.h"

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

/////////////////////////////////////////////////////////////////////////////
// CConfig_Page1 property page


extern configuration config;
extern char Current_DirectoryBuffer[MAX_PATH];


extern TCHAR * ConverPathToAbsolute(TCHAR *path);

extern UINT hex2int(const char *str);


extern download_file download_resource[MAX_DOWNLOAD_FILES];
extern int download_resource_count;

extern download_file download_files[MAX_DOWNLOAD_FILES];
extern int download_files_count;


IMPLEMENT_DYNCREATE(CConfig_Page1, CPropertyPage)

CConfig_Page1::CConfig_Page1() : CPropertyPage(CConfig_Page1::IDD)
{
	//{{AFX_DATA_INIT(CConfig_Page1)
	//}}AFX_DATA_INIT
	init = FALSE;
}

CConfig_Page1::~CConfig_Page1()
{
}

void CConfig_Page1::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CConfig_Page1)
	DDX_Control(pDX, IDC_LIST_REGISTER, m_list_register);
	DDX_Control(pDX, IDC_LIST_IMAGE, m_list_image);
	DDX_Control(pDX, IDC_LIST_FORMAT, m_list_format);
	DDX_Control(pDX, IDC_LIST_FILE, m_list_file);
	DDX_Control(pDX, IDC_LIST_ERASE, m_list_erase);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CConfig_Page1, CPropertyPage)
	//{{AFX_MSG_MAP(CConfig_Page1)
	ON_BN_CLICKED(IDC_BUTTON_BROWSE, OnButtonBrowse)
	ON_BN_CLICKED(IDC_BUTTON_BROWSE_NANDBOOT, OnButtonBrowseNandboot)
	ON_BN_CLICKED(IDC_CHECK_NANDBOOT, OnCheckNandboot)
	ON_BN_CLICKED(IDC_BUTTON_BROWSE_BIOS, OnButtonBrowseBios)
	ON_BN_CLICKED(IDC_CHECK_COM, OnCheckCom)
	ON_EN_CHANGE(IDC_EDIT_EQUIPMENT_COUNT, OnChangeEditEquipmentCount)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CConfig_Page1 message handlers

BOOL CConfig_Page1::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
	// TODO: Add extra initialization here

	ListView_SetExtendedListViewStyle(m_list_register.m_hWnd, LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT); 
	ListView_SetExtendedListViewStyle(m_list_file.m_hWnd, LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT); 
	ListView_SetExtendedListViewStyle(m_list_erase.m_hWnd, LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT); 
	ListView_SetExtendedListViewStyle(m_list_format.m_hWnd, LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT); 
	ListView_SetExtendedListViewStyle(m_list_image.m_hWnd, LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT); 


	m_list_register.InsertColumn(0, "序号", LVCFMT_LEFT, 40);
	m_list_register.InsertColumn(1, "寄存器地址", LVCFMT_LEFT, 90);
	m_list_register.InsertColumn(2, "寄存器值", LVCFMT_LEFT, 90);
	
	m_list_file.InsertColumn(0, "序号", LVCFMT_LEFT, 40);
	m_list_file.InsertColumn(1, "是否比较", LVCFMT_LEFT, 70);
    m_list_file.SetSubItemPopItem(1, T_POP_CMBBOX, "是|否|");
	m_list_file.InsertColumn(2, "下载位置", LVCFMT_LEFT, 70);
    m_list_file.SetSubItemPopItem(2, T_POP_CMBBOX, "NANDFLASH|NORFLASH|S-FLASH|U-DISK|");
	m_list_file.InsertColumn(3, "文件在PC路径", LVCFMT_LEFT, 120);
    m_list_file.SetSubItemPopItem(3, T_POP_MENU, "下载文件|下载目录|");
	m_list_file.InsertColumn(4, "文件下载到U盘路径", LVCFMT_LEFT, 120);
	m_list_file.InsertColumn(5, "文件运行地址", LVCFMT_LEFT, 120);
	m_list_file.InsertColumn(6, "文件下载到Flash起始地址", LVCFMT_LEFT, 120);
	m_list_file.InsertColumn(7, "文件下载到Flash结束地址", LVCFMT_LEFT, 120);
	m_list_file.InsertColumn(8, "文件备份到flash的起始位置", LVCFMT_LEFT, 120);
	m_list_file.InsertColumn(9, "文件备份到flash的结束位置", LVCFMT_LEFT, 120);
	

	m_list_erase.InsertColumn(0, "序号", LVCFMT_LEFT, 40);
    m_list_erase.InsertColumn(1, "擦除介质", LVCFMT_LEFT, 70);
	m_list_erase.InsertColumn(2, "擦除起始地址", LVCFMT_LEFT, 80);
	m_list_erase.InsertColumn(3, "擦除结束地址", LVCFMT_LEFT, 80);


	m_list_format.InsertColumn(0, "序号", LVCFMT_LEFT, 40);
	m_list_format.InsertColumn(1, "盘符", LVCFMT_LEFT, 40);
    m_list_format.InsertColumn(2, "用户盘", LVCFMT_LEFT, 60);
    m_list_format.SetSubItemPopItem(2, T_POP_CMBBOX, "是|否|");
    m_list_format.InsertColumn(3, "资料信息", LVCFMT_LEFT, 60);
    m_list_format.SetSubItemPopItem(3, T_POP_CMBBOX, "NORMAL|CHECK|READONLY|");
    m_list_format.InsertColumn(4, "分区属性", LVCFMT_LEFT, 60);
    m_list_format.SetSubItemPopItem(4, T_POP_CMBBOX, "MMI|MMIBACKUP|UNSTANDARD|UNSTANDARDBACKUP|STANDARD|FAKE|");
	m_list_format.InsertColumn(5, "格式化起始地址", LVCFMT_LEFT, 90);
	m_list_format.InsertColumn(6, "格式化结束地址", LVCFMT_LEFT, 90);

	m_list_image.InsertColumn(0, "序号", LVCFMT_LEFT, 40);
	m_list_image.InsertColumn(1, "盘符", LVCFMT_LEFT, 40);
	m_list_image.InsertColumn(2, "文件在PC路径", LVCFMT_LEFT, 90);
	m_list_image.InsertColumn(3, "磁盘中文件总大小", LVCFMT_LEFT, 90);

#ifndef DOWNLOAD_FAT_IMAGE
	m_list_image.ShowWindow(SW_HIDE);
#else
	m_list_format.ShowWindow(SW_HIDE);
#endif//DOWNLOAD_FAT_IMAGE

	SetConfigItem();

	init = TRUE;

	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CConfig_Page1::OnButtonBrowse() 
{
	// TODO: Add your control notification handler code here

	extern HINSTANCE _hInstance;
				
	OPENFILENAME ofn;
	TCHAR pstrFileName[260] = {0}, pstrTitleName[260] = {0};
	
	TCHAR szFilter[] =	TEXT ("BIN Files (*.bin;*.nb0)\0*.bin;*.nb0\0")  \
		TEXT ("All Files (*.*)\0*.*\0\0") ;
	
	memset ( &ofn, 0, sizeof ( ofn ) );
	
	ofn.lStructSize       = sizeof (OPENFILENAME) ;
	ofn.hInstance         = _hInstance ;
	ofn.hwndOwner         = GetSafeHwnd();
	ofn.lpstrFilter       = szFilter;
	ofn.nMaxFile          = MAX_PATH ;
	ofn.lpstrDefExt       = TEXT ("bin") ;
	ofn.lpstrFile         = pstrFileName ;
	ofn.Flags             = OFN_FILEMUSTEXIST; 
	
	
	if(GetOpenFileName (&ofn))
	{
		TCHAR * relative_path = pstrFileName;

		if((relative_path = strstr(pstrFileName, Current_DirectoryBuffer)) != NULL)
		{
			relative_path = pstrFileName + strlen(Current_DirectoryBuffer) + 1;
			SetDlgItemText(IDC_EDIT_LOADFILE_PATH, relative_path);
		}
		else
			SetDlgItemText(IDC_EDIT_LOADFILE_PATH, pstrFileName);				
	}
	
}

bool CConfig_Page1::Get_ConfigData()
{
	CString str;
	CString strPro;

	GetDlgItemText(IDC_EDIT_MOBILE_TYPE, strPro);

	if(strPro.GetLength() > 254)
	{
		strncpy(config.mobile_type, strPro, 254);
		config.mobile_type[254] = '\0';
	}
	else
	{
		strcpy(config.mobile_type, strPro);
	}
	
	if(config.bNandBoot)
	{
		GetDlgItemText(IDC_EDIT_NANDBOOT_PATH, str);
		strcpy(config.nandboot_path, str);

        GetDlgItemText(IDC_EDIT_BIOS_PATH, str);
        strcpy(config.bios_path, str);

		//GetDlgItemText(IDC_EDIT_MAIN_VERSION, str);
		//config.bios_main_version = atoi(str);

		//GetDlgItemText(IDC_EDIT_SUB_VERSION, str);
		//config.bios_sub_version = atoi(str);

        config.bios_main_version = MAIN_VERSION;
        config.bios_sub_version = SUB_VERSION;
        config.bios_sub1_version = SUB1_VERSION;

		GetDlgItemText(IDC_EDIT_BIOS_START_ADDRESS, str);
		config.bios_start_address = hex2int(str);

		GetDlgItemText(IDC_EDIT_BIOS_END_ADDRESS, str);
		config.bios_end_address = hex2int(str);

        GetDlgItemText(IDC_EDIT_BIOS_BACKUP_START_ADDRESS, str);
        config.bios_backup_start_address = hex2int(str);

        GetDlgItemText(IDC_EDIT_BIOS_BACKUP_END_ADDRESS, str);
        config.bios_backup_end_address = hex2int(str);

		GetDlgItemText(IDC_EDIT_BIOS_RUN_ADDRESS, str);
		config.bios_run_address = hex2int(str);
	}
	
	GetDlgItemText(IDC_EDIT_EQUIPMENT_COUNT, str);
	config.equipment_count = atoi(str);	

    int check = ((CButton *)GetDlgItem(IDC_CHECK_COM))->GetCheck();
	if(check)
	{
		config.bOpenCom = true;
	}
	else
	{
		config.bOpenCom = false;
	}

    if(config.bOpenCom)
    {
        GetDlgItemText(IDC_EDIT_COM_COUNT, str);
	    config.com_count = atoi(str);

        if(config.com_count > config.equipment_count || config.com_count <= 0)
        {
            MessageBox("串口数输入范围 0 ~ 16,且不能大于设备数", NULL, MB_OK);
            return false;
        }
	    
	    GetDlgItemText(IDC_EDIT_BASE_COM, str);
	    config.base_com = atoi(str);
	    
	    GetDlgItemText(IDC_EDIT_BAUDRATE, str);
	    config.BaudRate = atoi(str);	    
    }
	
	GetDlgItemText(IDC_EDIT_BASE_COM, str);
	config.base_com = atoi(str);
	
	GetDlgItemText(IDC_EDIT_BAUDRATE, str);
	config.BaudRate = atoi(str);
	
	
	GetDlgItemText(IDC_EDIT_MEMORY_TYPE, str);
	
	if(str == "SRAM")
		config.memory_type = MEMORY_TYPE_SRAM;
	else
		config.memory_type = MEMORY_TYPE_SDRAM;
	
	
	GetDlgItemText(IDC_EDIT_LOADFILE_PATH, str);
	strcpy(config.loadfile_path, str);
	
	GetDlgItemText(IDC_EDIT_LOADFILE_DESTINATION_ADDRESS, str);
	config.loadfile_destination_address = hex2int(str);

	GetDlgItemText(IDC_EDIT_RESOURCE_PATH, str);
//	strcpy(config.resource_path, str);
	
	int count = m_list_file.GetItemCount();

	config.download_file_count = count;
	if(config.download_files != NULL)
		free(config.download_files);
	config.download_files = (download_file * )malloc(sizeof(download_file) * config.download_file_count);
	
	memset(config.download_files, 0, sizeof(download_file) * config.download_file_count);
	
	
	for(int i = 0; i < count; i++)
	{
		str = m_list_file.GetItemText(i, 1);

		if(str == "是")
		{
			config.download_files[i].compare = TRUE;
		}
		else
		{
			config.download_files[i].compare = FALSE;
		}

		m_list_file.GetItemText(i, 3, config.download_files[i].file_pc_path, 255);

		str = m_list_file.GetItemText(i, 2);
		
		if(str == "NANDFLASH")
		{
			config.download_files[i].download_type = DOWNLOAD_TO_NANDFLASH;
			str = m_list_file.GetItemText(i, 6);
			config.download_files[i].start_destination_address = hex2int(str);
			
			str = m_list_file.GetItemText(i, 7);
			config.download_files[i].end_destination_address = hex2int(str);
			
			str = m_list_file.GetItemText(i, 8);
			config.download_files[i].backup_start_destination_address = hex2int(str);
			
			str =  m_list_file.GetItemText(i, 9);
			config.download_files[i].backup_end_destination_address = hex2int(str);
		}
		else if(str == "NORFLASH")
		{
			config.download_files[i].download_type = DOWNLOAD_TO_NORFLASH;
			str = m_list_file.GetItemText(i, 6);
			config.download_files[i].start_destination_address = hex2int(str);
			
			str = m_list_file.GetItemText(i, 7);
			config.download_files[i].end_destination_address = hex2int(str);
		}
		else if(str == "S-FLASH")
		{
			config.download_files[i].download_type = DOWNLOAD_TO_SFLASH;
			str = m_list_file.GetItemText(i, 6);
			config.download_files[i].start_destination_address = hex2int(str);
			
			str = m_list_file.GetItemText(i, 7);
			config.download_files[i].end_destination_address = hex2int(str);
		}
		else
		{
			config.download_files[i].download_type = DOWNLOAD_TO_U;

⌨️ 快捷键说明

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