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

📄 smt.h

📁 GM5621原代码
💻 H
字号:
/*
   $Workfile:   smt.h  $
   $Revision:   1.1  $
   $Date:   Jan 12 2006 04:46:30  $
*/

//******************************************************************
//
//      Copyright (C) 2003.  GENESIS MICROCHIP INC.
// All rights reserved.  No part of this program may be reproduced
//
//   Genesis Microchip Inc., 165 Commerce Valley Dr. West
//      Thornhill, Ontario, Canada, L3T 7V8
//
//================================================================
//
// MODULE:      smt.h
//
//******************************************************************
#ifndef _SMT_H_
#define _SMT_H_

#if USE_SMT
#include "inc\all.h"

#define DEBUG_SMT 			0

#define CMD_SMTProtocol		0xFE	//From Cortez Recieve and send SMT messages.
#define SMT_Message			0xFE	//Insam, Recieve and send SMT messages.


#if USE_ACM_3D
 #define SMT_MAX_BUF_SIZE 40
#else
 #define SMT_MAX_BUF_SIZE 1
#endif

/*
typedef struct gmt_MsgStruct_s
{
   BYTE  len; // length of this command packet
   BYTE  cmd;
   BYTE BUF[254];
} gmt_MsgStruct;
*/

//*************************************************************************
//	Defines from Streaming Message Transport protocol document
//*************************************************************************
#define  CM_TM_BIT			BIT0	// Control/Transport message flag
#define  EVEN_ODD_BIT		BIT1	// Even/Odd message count
#define  MORE_DATA_BIT		BIT2	// More Data Pending flag for Transport message
#define  YES_NO_MORE_DATA		BIT2	// More Data Pending flag for Transport message

#ifndef  MAX_TRANSACTION_NUMBER
#define  MAX_TRANSACTION_NUMBER  1 
#endif
#define  SMT_TRANSACTION_TIMEOUT 10 // unit: in 100ms, 1 second in total

// Low-level SMT protocol commands and responses
#define  OPEN_TRANSACTION_CMD    0
#define  TRANSACTION_OPENED      1
#define  CLOSE_TRANSACTION_CMD   2
#define  TRANSACTION_CLOSED      3
#define  RE_TRANSMIT_CMD         4
#define  FAILED                  5
#define  BUSY_PROCESSING         6
#define  GET_STATUS_CMD          7

//******************************************************************************
//  T Y P E    D E F I N I T I O N S
//******************************************************************************

// Hi-level protocol commands for example
typedef enum HiLevelSMTCommandEnum
{
   IDLE_CMD = 10,
   RAM_WRITE_CMD,
   RAM_READ_CMD,
   REG_READ_CMD,
   REG_WRITE_CMD,
} HiLevelSMTCommandType;

typedef enum ErrorsOfSMTEnum
{
   GENERIC_ER,
   TRANS_ID_ER,
   CHECK_SUM_ER,
   CORRUPT_MSG_ER
} ErrorsOfSMTType;

typedef struct SMT_MsgPktStruct     // SMT messages struct
{
   BYTE  len;
   BYTE  cmd;
   BYTE  msgType;
   BYTE  control;
   BYTE  msgpkt[];
}MsgPacket_t;

typedef struct SMT_TransactionStruct   // SMT Transactions Struct
{
   BYTE  ID;
	WORD  Port;
   WORD  BuffSize;
   BYTE far *Bp_Buff;
   WORD  W_Count;
   BYTE  B_Status;
   BYTE  B_CurCmd;
	BYTE  B_TmrNum;
	BYTE  Ba_Buff[SMT_MAX_BUF_SIZE];    //added since ACM3D
}SMT_TransactionStruct_t;


//******************************************************************************
//  G L O B A L    F U N C T I O N S
//******************************************************************************
extern void SMT_SendStatusSMT(BYTE msgpkt[], BYTE comm_use, BYTE EvOdd);
extern void SMT_SendFailed(BYTE comm_use, BYTE EvOdd, BYTE B_Reason);
extern void SMT_SendReTransmit(BYTE TransID, BYTE comm_use, BYTE EvOdd, WORD W_Delay_ms);

extern BYTE SMT_MessageHandler(MsgPacket_t * message, BYTE comm_use);
extern BYTE SMT_GetBuffer(BYTE  B_TransactionID,  BYTE far * far * Bp_Buff, WORD W_Size);


// Support SMT
extern SMT_TransactionStruct_t SMT_TransArray[MAX_TRANSACTION_NUMBER];
extern gmt_MsgStruct  OutMsg;

#if DEBUG_SMT
extern BYTE SMTDebug[];
extern BYTE SMTCnt;
extern BYTE SMTCNT(void);
//
// MACROs
//
#define SMTINIT 		(SMTCnt=0)
#define SMTDEBUG 		(SMTDebug[SMTCNT()])
#define SMTCHECKSUM(a) (SMTDebug[SMTCNT()] = a)

#else  //if DEBUG_SMT=0

extern BYTE tmpSMTDebug;
#define SMTINIT
#define   SMTDEBUG    tmpSMTDebug
#define SMTCHECKSUM(a)

#endif

//*************************************************************************
// Important. 
// This enum must be the same for all Genesis chips to keep consistency
//*************************************************************************
typedef enum SMT_Port
{
	SMTPORT_ACC16 = 0,	// ACC 16 dedicated SMT Port ID
	SMTPORT_ACM3 = 1,	// ACM3 dedicated SMT Port ID
	MAX_SMTPORT
} SMT_Port_t;

typedef BYTE (far * FPT_SMT_MsgHandler)(MsgPacket_t *message, BYTE comm_use);

typedef struct SMT_PortMapping
{
	SMT_Port_t	PortID;
	FPT_SMT_MsgHandler Fp_SMT_MsgHandler;
} SMT_PortMapping_t;

// PortID <-> Handler mapping
extern SMT_PortMapping_t ROM SMT_Port2HandlerTable[];

enum 
{
	FIRST_REQUEST = 0,
	NEXT_REQUEST = 1,
	NO_MEMORY = 0xFF,
};
#endif

#endif   // _SMT_H_

⌨️ 快捷键说明

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