📄 fbtcmain.h
字号:
/*******************************************************************************
* Copyright 2004-2005 - Software Design Solutions, Inc. All rights reserved.
*
* Portions of this work have been provided under license with Texas
* Instruments Inc.
*
* $RCSfile: FBTCMain.h,v $
* $Revision: 1.8 $
*
* FlashBurn Target Component main routine, implementing the host/target
* interface
******************************************************************************/
#ifndef _FBTCMAIN_H
#define _FBTCMAIN_H
#include "type.h"
#include "TargetConfig.h"
/**
* Comm. Protocol Version in force when this FBTC was created.
* Increment if the protocol changes, even if this software did not change.
* For Protocol Version ID, see the Exchange Communications Protocol document.
* v1 - original version
* v2 - added the Query Edit Flash Permission command
* and expanded msg data buffer to 768 8-bit bytes.
* v3 - added the Query Max Data Buffer Bytes command.
* and revised the comm. scheme to eliminate RTDX.
* v4 - SDS Inc. product release. Added FBTC_GET_ERASE_ESTIMATE and
* FBTC_GET_FLASH_ADDRS.
* C55x now gets and sets base address as words, not bytes
*/
#define COMMPROTOCOLVERSION 0x4
/**
* Indexes to and sizes of various parts of a command in this version of the
* protocol
*/
/* Size of the command */
#define CMDSIZEBYTES 2
/* Size of arguments */
#define ARGSIZEBYTES 30
/* Index of command */
#define CMDINDEX 0
/* Index of the first argument - cmd takes 2 bytes */
#define ARGINDEX (2 / BYTESPERMAU)
/* Index of the first data item */
#define DATAINDEX (ARGINDEX + ARGSIZEBYTES / BYTESPERMAU)
/**
* Predefined Status Codes for returning to Host processor.
*/
#define CMDOK 0x0
#define UNEXP_DATA_LENGTH 0x1
#define ILL_DATA_VAL 0x2
#define CMD_NOT_DONE 0x3
/**
* FlashBurn command IDs
*/
typedef enum
{
FBTC_NOP = 0x0000,
FBTC_GET_PROTOCOL_VERSION = 0x0001,
FBTC_GET_STATUS = 0x0002,
FBTC_ERASE = 0x0003,
FBTC_GET_BASE_ADDR = 0x0004,
FBTC_READ = 0x0005,
FBTC_READ_BLOCK = 0x0006,
FBTC_WRITE_BEGIN = 0x0007,
FBTC_WRITE_CONTINUE = 0x0008,
FBTC_GET_CHECKSUM = 0x0009,
FBTC_USER_DATA = 0x000a,
FBTC_GET_FLASHSIZE = 0x000b,
FBTC_SET_BASE_ADDR = 0x000c,
FBTC_SET_FLASHSIZE = 0x000d,
FBTC_GET_FBTC_VERSION = 0x000e,
FBTC_GET_FLASH_EDIT_PERM = 0x000f,
FBTC_GET_MAX_BLOCKSIZE = 0x0010,
FBTC_GET_ERASE_ESTIMATE = 0x0011,
FBTC_GET_FLASH_ADDRS = 0x0012
} FBTC_COMMAND_TYPE;
/**
* External declaration for the global message buffer
*/
extern MSG_DATA_TYPE theMessage[];
/**
* Commands for setting and getting portions of a message
*/
/**
* Store a command ID into the command buffer
*
* @param [in] cmd - Command ID to store
*
* @post - The command ID is stored in the buffer
*/
void SetCmd(u16 cmd);
/**
* Get a command ID from the command buffer
*
* @return - The command ID from the command buffer
*/
u16 GetCmd(void);
/**
* Set an argument in the command buffer
*
* @param [in] index - Argument index, 0..15
* @param [in] val - Value for the argument
*
* @post - Command buffer contains the given argument
*/
void SetArg(int index, u16 val);
/**
* Get an argument value from the command buffer
*
* @param [in] index - Index of the argument value to retrieve, 0..15
*
* @return - The argument value
*/
u16 GetArg(int index);
/**
* Get a pointer to the entire command message buffer
*
* @return - Pointer to the command message buffer
*/
MSG_DATA_TYPE *GetMessagePtr(void);
/**
* Get a pointer to the data portion of the message
*
* @return - Pointer to the data portion of the command message buffer
*/
MSG_DATA_TYPE *GetDataPtr(void);
/**
* Get the data item at the given index within the data
*
* @param [in] index - Zero based index within the data portion of the command
*
* @return - Data at the given index
*/
MSG_DATA_TYPE GetData(int index);
/**
* Set the data item at the given index within the data
*
* @param [in] index - Zero based index within the data portion of the command
* @param [in] val - Value for the data to set
*
* @post - Data at the given index is set
*/
void SetData(int index, MSG_DATA_TYPE val);
/**
* Create a U32 value from two U16 values
*
* @param [in] hi - U16 value for MSB
* @param [in] lo - U16 value for LSB
*
* @return The 32 bit value
*/
u32 U16toU32(u16 lo, u16 hi);
#endif /* FBTCMAIN_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -