📄 cmd.h
字号:
/*****************************************************************/
/* Copyright (c) Texas Instruments, Incorporated 2000 */
/*****************************************************************/
/******************************************************************************/
/* CMD.H - CMD interpreter routines */
/* */
/* This module implements the command interpreter on the DSK board */
/* */
/* MACRO FUNCTIONS: */
/* */
/* FUNCTIONS: */
/* */
/* */
/******************************************************************************/
#ifndef _CMD_H_
#define _CMD_H_
/*****************************************************************************/
/* INCLUDES */
/*****************************************************************************/
#include <type.h>
#include <board.h> // macros common to all modules
/*****************************************************************************/
/* DEFINES */
/*****************************************************************************/
#undef OK
#define OK 0
#undef ERROR
#define ERROR -1
#define DSK_CMD_MSG_SIZE 32
#define DSK_MAX_CMDS 20
/*****************************************************************************/
/* ENUMS */
/*****************************************************************************/
//Commands understood by command intepreter
//CMD_GPx are commands reserved for general purpose use.
//Use the cmd_set routine to map a function to this command.
typedef enum
{
CMD_MEM, //memory access
CMD_FLASH, //flash operation
CMD_IO, //I/O operation
CMD_GP0, //general purpose command 0
CMD_GP1, //general purpose command 1
CMD_GP2, //general purpose command 2
CMD_GP3, //general purpose command 3
CMD_GP4, //general purpose command 4
CMD_GP5, //general purpose command 5
CMD_GP6, //general purpose command 6
CMD_GP7, //general purpose command 7
CMD_GP8, //general purpose command 8
CMD_GP10, //general purpose command 9
CMD_GP11, //general purpose command 9
CMD_GP12, //general purpose command 9
CMD_GP13, //general purpose command 9
CMD_GP14, //general purpose command 9
CMD_GP15, //general purpose command 9
CMD_GP16, //general purpose command 9
CMD_GP17 //general purpose command 9
} DskCmd, *PDskCmd;
typedef enum
{
CMD_DONE = 1, //command successfully completed
CMD_IN_PROGRESS = 2, //command execution in progress
CMD_UNKNOWN = 3, //unknown command
CMD_ERROR = -1 //command failed
} DskCmdStatus, *PDskCmdStatus;
typedef enum
{
MEM_READ = 1,
MEM_WRITE = 2
} MemCmd, *PMemCmd;
typedef enum
{
FLASH_ERASE = 1,
FLASH_WRITE = 2
} FlashCmd, *PFlashCmd;
typedef enum
{
IO_READ = 1,
IO_WRITE = 2
} IoCmd, *PIoCmd;
/*****************************************************************************/
/* Structures */
/*****************************************************************************/
//This is the structure of the shared memory used between the command
//interpreter and the host.
//cmd: Command to execute. set to 0 upon completion of command.
//status: Indicates completion status, ERROR=-1, OK=0.
//data: memory allocated for general use
typedef struct _DskMsg {
int cmd;
DskCmdStatus status;
u16 data[DSK_CMD_MSG_SIZE];
} DskMsg, *PDskMsg;
typedef int (*CmdFunc)(void);
/*****************************************************************************/
/* PUBLIC FUNCTION PROTOTYPES */
/*****************************************************************************/
/*****************************************************************************/
/* int cmd_init(void) */
/* */
/* This routine performs required initialization and default configuration. */
/* */
/* Parameters: */
/* - None */
/* */
/* Return: */
/* - OK success */
/* - ERROR failure */
/* */
/* Notes: */
/* */
/*****************************************************************************/
int cmd_init(void);
/*****************************************************************************/
/* int cmd_set(DskCmd dskCmd_, CmdFunc func) */
/* */
/* This routine associates a function to one of the general purpose */
/* commands. */
/* */
/* Parameters: */
/* - dskCmd_ - enumerated cmd */
/* - func - Command handler */
/* */
/* Return: */
/* - OK success */
/* - ERROR failure */
/* */
/* Notes: */
/* */
/*****************************************************************************/
int cmd_set(DskCmd cmd_, CmdFunc func);
/*****************************************************************************/
/* int cmd_reset(DskCmd dskCmd_) */
/* */
/* This routine removes the association of a function to the specified */
/* general purpose commands. */
/* */
/* Parameters: */
/* - None */
/* */
/* Return: */
/* - OK success */
/* - ERROR failure */
/* */
/* Notes: */
/* */
/*****************************************************************************/
int cmd_reset(DskCmd dskCmd_);
/*****************************************************************************/
/* int cmd_run(void) */
/* */
/* This routine runs the command interpreter. */
/* */
/* Parameters: */
/* - None */
/* */
/* Return: */
/* - OK success */
/* - ERROR failure */
/* */
/* Notes: */
/* */
/*****************************************************************************/
int cmd_run();
/*****************************************************************************/
/* DskMsg* cmd_shared_mem(void) */
/* */
/* This returns a pointer to the shared memory */
/* */
/* Parameters: */
/* - None */
/* */
/* Return: */
/* - Shared memory address if successful */
/* - NULL on failure */
/* */
/* Notes: */
/* */
/*****************************************************************************/
DskMsg* cmd_shared_mem();
/*****************************************************************************/
/* int cmd_interpreter_disable(void) */
/* */
/* This disables the command interpreter by unhooking the _cmd_isr routine. */
/* */
/* Parameters: */
/* - None */
/* */
/* Return: */
/* - OK success */
/* - ERROR failure */
/* */
/* Notes: */
/* */
/*****************************************************************************/
int cmd_interpreter_disable();
/*****************************************************************************/
/* int cmd_interpreter_enable(void) */
/* */
/* This enables the command interpreter by hooking the _cmd_isr routine to */
/* CPU interrupt 3 */
/* */
/* Parameters: */
/* - None */
/* */
/* Return: */
/* - OK success */
/* - ERROR failure */
/* */
/* Notes: */
/* */
/*****************************************************************************/
int cmd_interpreter_enable();
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -