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

📄 testselectdlg.cpp

📁 系统通过JTAG接口烧结挂接在LXFXP2 上的s29gl256N的FLASH的代码,
💻 CPP
字号:
// TestSelectDlg.cpp : implementation file
//

#include "stdafx.h"
#include "FlashWrite.h"
#include "TestSelectDlg.h"
#include "Jtag_operates.h"
#include "LXFXP2.h"

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

/////////////////////////////////////////////////////////////////////////////
// CTestSelectDlg dialog


CTestSelectDlg::CTestSelectDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CTestSelectDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CTestSelectDlg)
	m_LPT_RST = FALSE;
	m_LPT_TCK = FALSE;
	m_LPT_TDI = FALSE;
	m_LPT_TMS = FALSE;
	m_CPUAddress = 0;
	m_CPUData = 0;
	m_FlashCS = FALSE;
	m_FlashRd = FALSE;
	m_FlashWr = FALSE;
	//}}AFX_DATA_INIT
}


void CTestSelectDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTestSelectDlg)
	DDX_Check(pDX, IDC_LPT_RST, m_LPT_RST);
	DDX_Check(pDX, IDC_LPT_TCK, m_LPT_TCK);
	DDX_Check(pDX, IDC_LPT_TDI, m_LPT_TDI);
	DDX_Check(pDX, IDC_LPT_TMS, m_LPT_TMS);
	DDX_Text(pDX, IDC_CPU_ADDRESS, m_CPUAddress);
	DDX_Text(pDX, IDC_CPU_DATA, m_CPUData);
	DDX_Check(pDX, IDC_FLASH_CS, m_FlashCS);
	DDX_Check(pDX, IDC_FLASH_RD, m_FlashRd);
	DDX_Check(pDX, IDC_FLASH_WR, m_FlashWr);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CTestSelectDlg, CDialog)
	//{{AFX_MSG_MAP(CTestSelectDlg)
	ON_BN_CLICKED(IDC_MUTI_JTAG_SEND, OnMutiJtagSend)
	ON_BN_CLICKED(IDC_SINGLE_JTAG_SEND, OnSingleJtagSend)
	ON_BN_CLICKED(IDC_PPORT_TEST, OnPportTest)
	ON_BN_CLICKED(IDC_MUTI_CPUSEND, OnMutiCpusend)
	ON_BN_CLICKED(IDC_SINGLE_CPUSEND, OnSingleCpusend)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTestSelectDlg message handlers

void CTestSelectDlg::OnMutiJtagSend() 
{
	int DataBeSend = 0;
	int cycle      = 1000;
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);

    if(!lpt_address)
	{
		test_port(false);
	}

    DataBeSend = m_LPT_TDI*64+m_LPT_RST*4 + m_LPT_TMS*2+m_LPT_TCK;

	while(cycle)
	{
        OUTB(lpt_address, DataBeSend);        //TCK low
		cycle--;
	}
}

void CTestSelectDlg::OnSingleJtagSend() 
{
	int DataBeSend = 0;
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);

	if(!lpt_address)
	{
		test_port(false);
	}
    /***********************************************************
     *一般并口有5个寄存器,如下:
     *   --------------------------------------------------------
     *   |名  称   | 地址偏移 | 读  写  |大  小 | 功  能        |
     *   |------------------------------------------------------|
     *   |ecpAFifo | 0x000    | W-R/W   |大小   |地址寄存器     |
     *   |------------------------------------------------------|
     *   |dsr      | 0x001    | R       |字节   |状态寄存器     |
     *   |------------------------------------------------------|
     *   |dcr      | 0x002    | R/W     |字节   |控制寄存器     | 
     *   |------------------------------------------------------|
     *   |ecpDFifo | 0x400    | R/W     |双字节 |数据寄存器     |        
     *   |------------------------------------------------------|
     *   |ecr      | 0x402    | R/W     |字节   |扩展控制寄存器 |
     *   |------------------------------------------------------|    
     *
     * 地址、数据寄存器
     *  |------------------------------------------------
     *  | 位    | 0  | 1  | 2  | 3  | 4  | 5  | 6  | 7  | 
     *  |------------------------------------------------
     *  |意义   | D0 | D1 | D2 | D3 | D4 | D5 | D6 | D7 | 
     *  |------------------------------------------------
     *  |对应脚 |PIN2|PIN3|PIN4|PIN5|PIN6|PIN7|PIN8|PIN9|    
     *  |------------------------------------------------
     *
     * 状态寄存器
     *  |--------------------------------------------------------------
     *  | 位    | 0  | 1  | 2  | 3   | 4       | 5       | 6   |   7  | 
     *  |--------------------------------------------------------------
     *  |意义   |保留|保留|IRQ |ERROR|Select IN|Paper Out|ACK  |Busy  | 
     *  |--------------------------------------------------------------
     *  |对应脚 | 无 | 无 | 无 | P15 |PIN13    |  PIN12  |PIN10|PIN11 |     
     *  |--------------------------------------------------------------
     *********************************************************/ 

     // Output pins (LPT driving)
     // LPT D3      Pin 5  and TDI  (bit 3 lptaddress )
     // LPT D2      Pin 4  and TCK  (bit 2 lptaddress )
     // LPT D1      Pin 3  and TMS  (bit 1 lptaddress )
     // LPT D0      Pin 2  and TRST (bit 0 lptaddress )
     //
     // Input pin (S3C4510 board drives)
     // LPT BUSY    Pin 11 and TDO  (bit 7 lptaddress + 1)

    //std jtag pin connect
    //    13         SELECTED         11      TDO  (bit 4 lptaddress + 1)
    //    8          DATA6             5      TDI
    //    4          DATA2             3      nTRT    
    //    3          DATA1             7      TMS
    //    2          DATA0             9      TCK
    
    DataBeSend = m_LPT_TDI*64+m_LPT_RST*4 + m_LPT_TMS*2+m_LPT_TCK;
    OUTB(lpt_address, DataBeSend);        //TCK low
}

void CTestSelectDlg::OnPportTest() 
{
	// TODO: Add your control notification handler code here
	test_port(true);
}

void CTestSelectDlg::OnMutiCpusend() 
{
	int DataBeSend = 0;
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);

	if(!lpt_address)
	{
		test_port(false);
	}
    
	LXFXP2_bus2_test(m_FlashCS, m_FlashRd, m_FlashWr, m_CPUAddress,m_CPUData);
}

void CTestSelectDlg::OnSingleCpusend() 
{
	int DataBeSend = 0;

	int cycle = 1000;
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);

	if(!lpt_address)
	{
		test_port(false);
	}

	while(cycle)
	{
       	LXFXP2_bus2_test(m_FlashCS, m_FlashRd, m_FlashWr, m_CPUAddress,m_CPUData);
		//TCK low
		cycle--;
	}    

}

⌨️ 快捷键说明

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