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

📄 复件 jtag.h

📁 c8051.rar
💻 H
字号:
#if !defined(AFX_JTAG_H__2FDAC7FB_82FB_4B21_9613_33685D007824__INCLUDED_)
#define AFX_JTAG_H__2FDAC7FB_82FB_4B21_9613_33685D007824__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// jtag.h : header file
//
/*
DB25的2-9脚做为输出端,对应D0-D7
TCK,TMS,TDI脚均选择其中的某一个引脚

*/

#include "C8051.h"
#include "stdafx.h"


				


/////////////////////////////////////////////////////////////////////////////
// jtag window

class jtag : public CButton
{
// Construction
public:
	jtag();
	//TCK引脚;对PC而言,输出引脚D0-D7;以下输入输出均对于PC
	WORD m_woTCKPin;
	//TMS引脚;输出
	WORD m_woTMSPin;
	//TDI引脚;输出
	WORD m_woTDIPin;
	//TDO 引脚;输入
	WORD m_wiTDOPin;
	//TDO引脚所在的基地址偏移量
	int m_iTDOAddP;
	//电缆型号;
	int	m_iCcabletype;					
	//获得数据端口地址
	WORD m_nPort;			
	//获得要写入数据端口的值WriteValue(数据范围为0~255)
	unsigned char m_ucWriteValue;
// Attributes
public:
	//返回TDO引脚的信息
	bool TDO(void);
	//TDI引脚波形发生函数
	void TDI(bool bValue);
	//TCK函数,生成TCK,参数为TCK的高 or 低
	void TCK(bool bValue);
	//TMS函数.生产TMS信号
	void TMS(bool bValue);
// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(jtag)
	//}}AFX_VIRTUAL

// Implementation
public:
	//设置电缆
	unsigned char CableSetup();

	//------------------------------------------------------------------------------------
	// JTAG_Reset
	//------------------------------------------------------------------------------------
	// This routine places the JTAG state machine on the target system in
	// the Test Logic Reset state by strobing TCK 5 times while leaving
	// TMS high. Leaves the JTAG state machine in the Run_Test/Idle state.
	void JTAG_Reset (void);


	

	virtual ~jtag();

	// Generated message map functions


	//------------------------------------------------------------------------------------
	// FLASH_ByteRead
	//------------------------------------------------------------------------------------
	// This routine reads the byte at <addr> and stores it at the address pointed to by
	// <pdat>.
	// Returns TRUE if the operation was successful; FALSE otherwise (page read-protected).
	int FLASH_ByteRead (unsigned int addr, unsigned char *pdat);

	//------------------------------------------------------------------------------------
	// FLASH_PageErase
	//------------------------------------------------------------------------------------
	// This routine performs an erase of the page in which <addr> is contained.
	// This routine assumes that no FLASH operations are currently in progress.
	// This routine exits with no FLASH operations currently in progress.
	// Returns TRUE if the operation was successful; FALSE otherwise (page protected).
	int FLASH_PageErase (unsigned int addr);

	//------------------------------------------------------------------------------------
	// FLASH_ByteWrite
	//------------------------------------------------------------------------------------
	// This routine writes the data <dat> to FLASH at the address <addr>.
	// Returns TRUE if the operation was successful; FALSE otherwise (page
	// write-protected).
	int FLASH_ByteWrite (unsigned int addr, unsigned char dat);

	//------------------------------------------------------------------------------------
	// JTAG_IRead
	//------------------------------------------------------------------------------------
	// This routine performs an indirect read of register <ireg>, of <num_bits> in length.
	// It follows the read operation with a polling operation, and returns when the
	// operation is completed. Note: the polling implemented here refers to the JTAG
	// register read operation being completed, NOT the FLASH read operation.
	// Polling for the FLASH read operation is handled at a higher level.
	// Examples of valid indirect registers are:
	// FLCN - FLASH Control
	// FLSC - FLASH Scale
	// FLA - FLASH Address
	// FLD - FLASH Data
	// Leaves in the Run_Test/Idle state.
	unsigned long JTAG_IRead (unsigned int ireg, int num_bits);

	
	//------------------------------------------------------------------------------------
	// JTAG_IWrite
	//------------------------------------------------------------------------------------
	// This routine performs an indirect write to register <ireg>, containing <dat>, of
	// <num_bits> in length. It follows the write operation with a polling operation, and
	// returns when the operation is completed. Note: the polling implemented here refers
	// to the JTAG register write operation being completed, NOT the FLASH write operation.
	// Polling for the FLASH write operation is handled at a higher level
	// Examples of valid indirect registers are:
	// FLCN - FLASH Control
	// FLSC - FLASH Scale
	// FLA - FLASH Address
	// FLD - FLASH Data
	// Leaves in the Run_Test/Idle state.
	void JTAG_IWrite (unsigned int ireg, unsigned long dat, int num_bits);


	//------------------------------------------------------------------------------------
	// JTAG_DR_Scan
	//------------------------------------------------------------------------------------
	// This routine shifts <num_bits> of <data> into the Data Register, and returns
	// up to 32-bits of data read from the Data Register.
	// Leaves in the Run_Test/Idle state.
	// Assumes the JTAG state machine starts in the Run_Test/Idle state.
	unsigned long JTAG_DR_Scan (unsigned long dat, int num_bits);

	//------------------------------------------------------------------------------------
	// JTAG_IR_Scan
	//------------------------------------------------------------------------------------
	// This routine loads the supplied <instruction> of <num_bits> length into the JTAG
	// Instruction Register on the target system. Leaves in the Run_Test/Idle state.
	// The return value is the n-bit value read from the IR.
	// Assumes the JTAG state machine starts in the Run_Test/Idle state.
	unsigned int JTAG_IR_Scan (unsigned int instruction, int num_bits);
	//{{AFX_MSG(jtag)
		// NOTE - the ClassWizard will add and remove member functions here.
	//}}AFX_MSG
	

protected:
	DECLARE_MESSAGE_MAP()
private:



	//------------------------------------------------------------------------------------
	// JTAG_StrobeTCK
	//------------------------------------------------------------------------------------
	// This routine strobes the TCK pin (brings high then back low again)
	// on the target system.
	void JTAG_StrobeTCK(void);

};

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

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_JTAG_H__2FDAC7FB_82FB_4B21_9613_33685D007824__INCLUDED_)

⌨️ 快捷键说明

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