/* NOTE:  This file was MODIFIED on 9/13/2004 RCM */

/* some typedefs used by D-Bug12 */

typedef char * Address;
typedef int Boolean;
typedef unsigned char Byte;

typedef enum Vect {
	UserPortHKWU = 7,
	UserPortJKWU = 8,
	USERAtoD = 9,
	UserSCI1 = 10,
	UserSCI0 = 11,
	UserSPI0 = 12,
	UserTimerCh0 = 13,
	UserTimerCh1 = 14,
	UserTimerCh2 = 15,
	UserTimerCh3 = 16,
	UserTimerCh4 = 17,
	UserTimerCh5 = 18,
	UserTimerCh6 = 19,
	UserTimerCh7 = 20,
	UserPAccOvf = 21,
	UserPAccEdge = 22,
	UserTimerOvf = 23,
	UserRTI = 24,
	UserIRQ = 25,
	UserXIRQ = 26,
	UserSWI = 27,
	UserTrap = 28,
	RAMVectAddr = -1 };


/* structure that defines the functions in D-Bug12's user accessable      */
/* function table.  Also provides a function prototype for each function  */
/* Documentation for each of these functions can be found in Application  */
/* Note AN1280  */

/* NOTE that the parameter passing order for CodeWarrior is different     */
/* than assumed by DB12:  CodeWarrior pushes the parameters from left     */
/* to right, rather than the customary C language right to left, EXCEPT   */
/* for functions with a variable number of arguments, which are passed    */
/* using the right to left pushes.                                        */

/* To make this difference easier to handle, there are several macro      */
/* defines given below which take care of the parameter order implicitly. */  

typedef struct {
	void (*DB12main)(void);
	int (*DB12getchar)(void);
	int (*DB12putchar)(int);
	int (*DB12printf)(const char *, ...);

/*	int (*GetCmdLine)(char *CmdLineStr, int CmdLineLen); */
	int (*CWGetCmdLine)(int CmdLineLen, char *CmdLineStr);
	
/*	char * (*sscanhex)(char *HexStr, unsigned int *BinNum); */
	char * (*CWsscanhex)(unsigned int *BinNum, char *HexStr);
	
	int (*DB12isxdigit)(int c);
	int (*DB12toupper)(int c);
	int (*DB12isalpha)(int c);
	unsigned int (*DB12strlen)(const char *cs);
	
/*	char * (*DB12strcpy)(char *s1, char *s2); */
	char * (*CWDB12strcpy)(char *s2, char *s1);

	void (*out2hex)(unsigned int num);
	void (*out4hex)(unsigned int num);
	
/*	int (*SetUserVector)(int VectNum, Address UserAddress); */
  int (*CWSetUserVector)(Address UserAddress,int VectNum); 
	
/*  Boolean (*WriteEEByte)(Address EEAddress, Byte EEData);   */
  Boolean (*CWWriteEEByte)(Byte EEData, Address EEAddress);
	
	int (*EraseEE)(void);
	
/*	int (*ReadMem)(Address StartAddress, Byte *MemDataP, unsigned int NumBytes);  */
	int (*CWReadMem)(unsigned int NumBytes, Byte *MemDataP, Address StartAddress);
	
/*	int (*WriteMem)(Address StartAddress, Byte *MemDataP, unsigned int NumBytes); */
	int (*CWWriteMem)(unsigned int NumBytes, Byte *MemDataP, Address StartAddress);
	
	} UserFN, * UserFNP;

/* defines a pointer to the start of D-Bug12's user accessable functable */

#define DBug12FNP ((UserFNP)0xf680)


/* The following #defines are used to provide for portability and avoid a linker */
/* conflict with the standard library functions of the same name.  No #define is */
/* included for DB12main() since all C programs must contain a main() function */

#define printf DB12printf
#define getchar DB12getchar
#define putchar DB12putchar
#define isxdigit DB12isxdigit
#define toupper DB12toupper
#define isalpha DB12isalpha
#define strlen DB12strlen
#define strcpy DB12strcpy

/* defines to exchange parameter order (CodeWarrior calling convention */
#define SetUserVector(b,a) CWSetUserVector(a,b)
#define GetCmdLine(b,a)    CWGetCmdLine(a,b)
#define sscanhex(b,a)      CWsscanhex(a,b)
#define DB12strcpy(b,a)    CWDB12strcpy(a,b)
#define WriteEEByte(b,a)   CWWriteEEByte(a,b)
#define ReadMem(c,b,a)     CWReadMem(a,b,c)
#define WriteMem(c,b,a)    CWWriteMem(a,b,c)