

#include  <stdio.h>

#include  <stdlib.h>

#include  <dos.h>

#include  <conio.h>

#include  <math.h>



/* -------------------------------------------------------------------- */



#define   UCHAR     unsigned char

#define   WORD      unsigned short

#define   DWORD     unsigned long



#define   TIGER100   0xE1590002

#define   TIGER320   0xE1590001

#define   Oxford_old 0x14159504

#define   Oxford_new 0x14159501



/* -------------------------------------------------------------------- */

// Error Codes

#define   VXC_NoError                 0

#define   VXC_InvalidBaudrate         1

#define   VXC_InvalidDataFormat       2

#define   VXC_TimeOut                 3

#define   VXC_ChecksumError           4

#define   VXC_DriverHandleError       5

#define   VXC_DriverCallError         6

#define   VXC_FindBoardError          7

#define   VXC_ExceedBoardNumber       8

#define   VXC_NotFoundBoard           9







/* -------------------------------------------------------------------- */



#ifdef __cplusplus 

extern "C" {

#endif



float VXC_FloatSub2( float fA, float fB );

short VXC_ShortSub2( short nA, short nB );



WORD VXC_GetDriverVersion( WORD *wDriverVersion );

WORD VXC_DriverInit( WORD *wTotalCardsFound );

WORD VXC_DriverClose( void );



WORD VXC_GetCardInfo( WORD wCardNo, WORD *wConfigAddr, DWORD *wCardType, WORD *wCardSwitchID, 

                      WORD *wNumberOfPorts, WORD *wUartStride, WORD *wIrq );

WORD VXC_GetPortInfo( WORD wCardNo, WORD wPortAddr[] );

WORD VXC_GetCardName( DWORD wCardType, char szCardName[] );



int VXC_OpenCom( WORD wCom_ID_Address, DWORD dwBaudRate, char szDataFormat[], WORD *wCOM_Handle );

int VXC_OpenComLowSpeed( WORD wCom_ID_Address, DWORD dwBaudRate, char szDataFormat[], WORD *wCOM_Handle );

int VXC_CloseCom( WORD wCom_Handle );



int VXC_SendChar( WORD wCom_Handle, int ch,  WORD wTimeout );

int VXC_ReceiveChar( WORD wCom_Handle, int *ch, WORD wTimeout );



int VXC_SendBuffer( WORD wCom_Handle, char sSendBuffer[], DWORD dwLength, WORD wTimeout );

int VXC_ReceiveBuffer( WORD wCom_Handle, char sReceiveBuffer[], DWORD dwLength, WORD wTimeout );



int VXC_SendCmd( WORD wCom_Handl, char cSendCmd[], DWORD dwLength, WORD wTimeout );

int VXC_ReceiveCmd( WORD wCom_Handl, char cSendCmd[], DWORD dwLength, WORD wTimeout );



WORD VXC_SetLed( WORD wConfigAddr, WORD wOnOff );



DWORD  _inpd( WORD port );



/* 1 or '1' : Enable Debug Print

   others   : Disable Debug Print */

void   VXC_SetDebugMode( UCHAR bMode );

void   _outpd( WORD port, DWORD data );



#ifdef __cplusplus 

}

#endif



/* -------------------------------------------------------------------- */

/*************** for Microsoft C Compiler ****************/



#ifdef _MSC_VER

/* MSC inp returns byte, inpw returns word */

/* TC  inportb returns byte, inport returns word */

/* Now, it is unified to use inpb, inpw, inpd, outpb, outpw, outpd */

#define inportb     inp

#define outportb    outp

#define inport      inpw

#define outport     outpw

#define inportw     inpw

#define outportw    outpw

#define inpd        _inpd

#define outpd       _outpd

#define inpb        inp

#define outpb       outp

#define enable      _enable

#define disable     _disable

#define setvect     _dos_setvect

#define sleep       delay1

#define delay       delay1



#else     // for BC and TC



/* Now, it is unified to use inpb, inpw, inpd, outpb, outpw, outpd */

//#define inp       inportb

//#define inpw      inport

#define   inpb      inportb

#define   inpd      _inpd

//#define outp      outportb

//#define outpw     outport

#define   outpb     outportb

#define   outpd     _outpd

#endif



/* -------------------------------------------------------------------- */

/* Values */



#define VXC_LOW_SPEED         0x00

#define VXC_HIGH_SPEED        0x02

#define VXC_LED_OFF           0x00 // Off all output state

#define VXC_LED_ON            0x80 // Aux7 for LED On

#define VXC_112A_LED_ON       0x20 // Aux5 for LED On



/* -------------------------------------------------------------------- */



#define VXC_THR   0   /* Transmitter Holding Register, tx buffer */

#define VXC_RBR   0   /* Receiver Buffer Register, rx buffer */

#define VXC_DLL   0   /* Baud LSB */

#define VXC_DLH   1   /* Baud MSB */

#define VXC_IER   1   /* Interrupt Enable Register */

#define VXC_FCR   2   /* FIFO Control Register */

#define VXC_IIR   2   /* Interrupt Identification Register  */

#define VXC_LCR   3   /* Linear Control Register */

#define VXC_DFR   3   /* Data Format Register */

#define VXC_MCR   4   /* Modem Control Register */

#define VXC_LSR   5   /* Linear Status Register */

#define VXC_MSR   6   /* Modem Status Register */



/* -------------------------------------------------------------------- */







