?? jtag.h
字號:
// jtag.h: interface for the jtag class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_JTAG_H__FF9AF16B_35A2_45B7_8CC4_0AF96A5187FB__INCLUDED_)
#define AFX_JTAG_H__FF9AF16B_35A2_45B7_8CC4_0AF96A5187FB__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "C8051.h"
#include "stdafx.h"
class jtag
{
// Construction
public:
jtag();
//電纜型號;
int m_iCcabletype;
//獲得數據端口地址
WORD m_nPort;
//FLASHCON 的最高位,=1 說明讀取高的128字節,否則讀取flash
unsigned char ucFCONBIT7;
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(jtag)
//}}AFX_VIRTUAL
// Implementation
public:
//選擇CPU型號
int SelectCPU(unsigned int uiCouType);
void ResetCpu();
//得到CPU ID 號
unsigned long JtagGetIDCode();
//設置電纜
unsigned char CableSetup(unsigned char ucCabtype);
//------------------------------------------------------------------------------------
// 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 long 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 long 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 long 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);
//{{AFX_MSG(jtag)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
protected:
//返回TDO引腳的信息
bool TDO(void);
//TDI引腳波形發生函數
void TDI(bool bValue);
//TCK函數,生成TCK,參數為TCK的高 or 低
void TCK(bool bValue);
//TMS函數.生產TMS信號
void TMS(bool bValue);
//TCK引腳;對PC而言,輸出引腳D0-D7;以下輸入輸出均對于PC
WORD m_woTCKPin;
//TMS引腳;輸出
WORD m_woTMSPin;
//TDI引腳;輸出
WORD m_woTDIPin;
//TDO 引腳;輸入
WORD m_wiTDOPin;
//TDO引腳所在的基地址偏移量
int m_iTDOAddP;
//獲得要寫入數據端口的值WriteValue,數據口(DB25)(數據范圍為0~255)
unsigned char m_ucWriteValue;
//TDO引腳輸出是否顛倒;
bool b_TDONoInv;
int FLCN_LEN; // 8 // number of bits in FLASHCON
int FLD_RDLEN; //10 // number of bits in an FLASHDAT read
int FLD_WRLEN; //8 // number of bits in an FLASHDAT write
int FLA_LEN ; //16 // number of bits in FLASHADR
int FLSC_LEN; //8 // number of bits in FLASHSCL
private:
//------------------------------------------------------------------------------------
// JTAG_StrobeTCK
//------------------------------------------------------------------------------------
// This routine strobes the TCK pin (brings high then back low again)
// on the target system.
void JTAG_StrobeTCK(void);
//------------------------------------------------------------------------------------
// 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);
};
#endif // !defined(AFX_JTAG_H__FF9AF16B_35A2_45B7_8CC4_0AF96A5187FB__INCLUDED_)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -