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

📄 nandupdatadlg.cpp

📁 wince evc nand 更新 au1200
💻 CPP
字号:
// NANDUPDATADlg.cpp : implementation file
//

#include "stdafx.h"
#include "NANDUPDATA.h"
#include "NANDUPDATADlg.h"
#include "Storemgr.h"

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

/////////////////////////////////////////////////////////////////////////////
// CNANDUPDATADlg dialog

CNANDUPDATADlg::CNANDUPDATADlg(CWnd* pParent /*=NULL*/)
	: CDialog(CNANDUPDATADlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CNANDUPDATADlg)
	m_edit1 = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CNANDUPDATADlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CNANDUPDATADlg)
	DDX_Text(pDX, IDC_EDIT1, m_edit1);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CNANDUPDATADlg, CDialog)
	//{{AFX_MSG_MAP(CNANDUPDATADlg)
	ON_BN_CLICKED(IDC_ERASE, OnErase)
	ON_BN_CLICKED(IDC_WRITE, OnWrite)
	ON_BN_CLICKED(IDC_READ, OnRead)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CNANDUPDATADlg message handlers

BOOL CNANDUPDATADlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	CenterWindow(GetDesktopWindow());	// center to the hpc screen
    //open nand flash driver
	
    hNand = OpenStore(L"NAND");
    if(hNand == INVALID_HANDLE_VALUE)
   	AfxMessageBox(TEXT("cann't open NAND FLASH driver."));
    
	//CString Str_SetValue=_T("this is test");
	//m_edit1=Str_SetValue;
	//UpdateData(false);
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}


#define IOCTL_FMD_ERASEBLOCK   0xff123458
#define IOCTL_FMD_READSECTOR   0xff123456
#define IOCTL_FMD_WRITESECTOR  0xff123457



void CNANDUPDATADlg::OnErase() 
{
	// TODO: Add your control notification handler code here
     DWORD dwReturn; 

	BOOL bSuccess = DeviceIoControl(hNand, IOCTL_FMD_ERASEBLOCK, NULL, 0, NULL, 0, &dwReturn, NULL); 
	if(!bSuccess) 
	{ 
		AfxMessageBox(TEXT(" erase  is filed."));
	}
    AfxMessageBox(TEXT(" erase is finished."));
}

void CNANDUPDATADlg::OnWrite() 
{
	// TODO: Add your control notification handler code here
	DWORD dwReturn; 
	UpdateData(true);
	
    TCHAR * p =m_edit1.GetBuffer(512);
     
	BOOL bSuccess = DeviceIoControl(hNand, IOCTL_FMD_WRITESECTOR, p, wcslen(p) , NULL, 0, &dwReturn, NULL); 
	if(!bSuccess) 
	{ 
		AfxMessageBox(TEXT(" write  is filed."));
	}
    AfxMessageBox(TEXT(" write is finished."));
}

void CNANDUPDATADlg::OnRead() 
{
	// TODO: Add your control notification handler code here
	DWORD dwReturn; 
    
    TCHAR buffer[512];
    
	BOOL bSuccess = DeviceIoControl(hNand, IOCTL_FMD_READSECTOR, NULL, 0 , buffer, 512, &dwReturn, NULL); 
	if(!bSuccess) 
	{ 
		AfxMessageBox(TEXT(" read  is filed."));
	}
    
   
	CString s(buffer);
    m_edit1=s;
	UpdateData(false);
	AfxMessageBox(TEXT(" read is finished."));

}

⌨️ 快捷键说明

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