//*****************************************************************************
//*****************************************************************************
//  FILENAME:  UART_HOST.h
//  Version: 5.1, Updated on 2004/07/29 at 17:48:41
//  Generated by PSoC Designer ver 4.2  b1013 : 02 September, 2004
//
//  DESCRIPTION:  UART User Module C Language interface file for the
//                22/24/25/26/27xxx PSoC family of devices.
//-----------------------------------------------------------------------------
//      Copyright (c) Cypress MicroSystems 2000-2003. All Rights Reserved.
//*****************************************************************************
//*****************************************************************************

// include the global header file
#include <m8c.h>

#define UART_HOST_RXBUF_ENABLE 0

//-------------------------------------------------
// Prototypes of the UART_HOST API.
//-------------------------------------------------

#if ( UART_HOST_RXBUF_ENABLE )
extern char UART_HOST_aRxBuffer[];
extern BYTE UART_HOST_bRxCnt;
extern BYTE UART_HOST_fStatus;
#endif



// Create pragmas to support proper argument and return value passing

#pragma fastcall16  UART_HOST_SetTxIntMode
#pragma fastcall16  UART_HOST_EnableInt
#pragma fastcall16  UART_HOST_DisableInt
#pragma fastcall16  UART_HOST_Start
#pragma fastcall16  UART_HOST_Stop
#pragma fastcall16  UART_HOST_SendData
#pragma fastcall16  UART_HOST_bReadTxStatus
#pragma fastcall16  UART_HOST_bReadRxData
#pragma fastcall16  UART_HOST_bReadRxStatus
#pragma fastcall16  UART_HOST_PutSHexByte
#pragma fastcall16  UART_HOST_PutSHexInt
#pragma fastcall16  UART_HOST_CPutString
#pragma fastcall16  UART_HOST_PutString
#pragma fastcall16  UART_HOST_PutChar
#pragma fastcall16  UART_HOST_Write
#pragma fastcall16  UART_HOST_CWrite

#pragma fastcall16  UART_HOST_cGetChar
#pragma fastcall16  UART_HOST_cReadChar
#pragma fastcall16  UART_HOST_iReadChar
#pragma fastcall16  UART_HOST_IntCntl
#pragma fastcall16  UART_HOST_TxIntMode
#pragma fastcall16  UART_HOST_PutCRLF

#if ( UART_HOST_RXBUF_ENABLE )
#pragma fastcall16  UART_HOST_CmdReset
#pragma fastcall16  UART_HOST_bCmdCheck
#pragma fastcall16  UART_HOST_bErrCheck
#pragma fastcall16  UART_HOST_bCmdLength
#pragma fastcall16  UART_HOST_szGetParam
#pragma fastcall16  UART_HOST_szGetRestOfParams
#endif

//**************************************************
// Prototypes of UART API. For a definition of
// functions see UART_HOST.inc.
//**************************************************
extern void  UART_HOST_SetTxIntMode(BYTE bTxIntMode);
extern void  UART_HOST_EnableInt(void);
extern void  UART_HOST_DisableInt(void);
extern void  UART_HOST_Start(BYTE bParitySetting);
extern void  UART_HOST_Stop(void);
extern void  UART_HOST_SendData(BYTE bTxData);
extern BYTE  UART_HOST_bReadTxStatus(void);
extern BYTE  UART_HOST_bReadRxData(void);
extern BYTE  UART_HOST_bReadRxStatus(void);

// High level TX functions
extern void   UART_HOST_CPutString(const BYTE * szRomString);
extern void   UART_HOST_PutString(BYTE * szRamString);
extern void   UART_HOST_PutChar(CHAR cData);
extern void   UART_HOST_Write(BYTE * szRamString, BYTE bCount);
extern void   UART_HOST_CWrite(const BYTE * szRomString, INT iCount);
extern void   UART_HOST_PutSHexByte(BYTE bValue);
extern void   UART_HOST_PutSHexInt(INT iValue);
extern void   UART_HOST_PutCRLF(void);
extern void   UART_HOST_TxIntMode(BYTE bMask);

// High level RX functions
extern CHAR         UART_HOST_cGetChar(void);
extern CHAR         UART_HOST_cReadChar(void);
extern INT          UART_HOST_iReadChar(void);

extern void         UART_HOST_IntCntl(BYTE bMask);

#if ( UART_HOST_RXBUF_ENABLE )
extern void   UART_HOST_CmdReset(void);
extern BYTE   UART_HOST_bCmdCheck(void);
extern BYTE   UART_HOST_bErrCheck(void);
extern BYTE   UART_HOST_bCmdLength(void);
extern BYTE * UART_HOST_szGetParam(void);
extern BYTE * UART_HOST_szGetRestOfParams(void);
#endif

//-------------------------------------------------
// Defines for UART_HOST API's.
//-------------------------------------------------

//------------------------------------
// Transmitter Interrupt masks
//------------------------------------
#define UART_HOST_TX_INT_MASK:                     (0x04)
#define UART_HOST_TX_INT_REG:                      (0x0e1) 
#define UART_HOST_RX_INT_MASK:                     (0x08) 
#define UART_HOST_RX_INT_REG:                      (0x0e1) 

//------------------------------------
//  Parity masks
//------------------------------------
#define  UART_HOST_PARITY_NONE        0x00
#define  UART_HOST_PARITY_EVEN        0x02
#define  UART_HOST_PARITY_ODD         0x06
//------------------------------------
//  Transmitter Status Register masks
//------------------------------------
#define  UART_HOST_TX_COMPLETE        0x20
#define  UART_HOST_TX_BUFFER_EMPTY    0x10

//------------------------------------
//  Receiver Status Register masks
//------------------------------------
#define  UART_HOST_RX_ACTIVE          0x10
#define  UART_HOST_RX_COMPLETE        0x08
#define  UART_HOST_RX_REG_FULL        0x08
#define  UART_HOST_RX_PARITY_ERROR    0x80
#define  UART_HOST_RX_OVERRUN_ERROR   0x40
#define  UART_HOST_RX_FRAMING_ERROR   0x20
#define  UART_HOST_RX_ERROR           0xE0
#define  UART_HOST_RX_NO_ERROR        0xE0          // This symbol is deprecated and will removed in the future

#define  UART_HOST_RX_NO_DATA         0x01

#define  UART_HOST_RX_BUF_ERROR           0xF0  // Mask for any Rx that may occur.
#define  UART_HOST_RX_BUF_OVERRUN         0x10  // This indicates the software buffer has
                                                           // been over run.
#define  UART_HOST_RX_BUF_CMDTERM         0x01  // Command terminator has been received.


//-------------------------------------------------
// Register Address Constants for UART_HOST
//-------------------------------------------------

#pragma ioport  UART_HOST_TX_CONTROL_REG:   0x02b           // Control register
BYTE            UART_HOST_TX_CONTROL_REG;
#pragma ioport  UART_HOST_TX_SHIFT_REG: 0x028               // TX Shift Register register
BYTE            UART_HOST_TX_SHIFT_REG;
#pragma ioport  UART_HOST_TX_BUFFER_REG:    0x029               // TX Buffer Register
BYTE            UART_HOST_TX_BUFFER_REG;
#pragma ioport  UART_HOST_TX_FUNC_REG:  0x128               // Function register
BYTE            UART_HOST_TX_FUNC_REG;
#pragma ioport  UART_HOST_TX_INPUT_REG: 0x129               // Input register
BYTE            UART_HOST_TX_INPUT_REG;
#pragma ioport  UART_HOST_TX_OUTPUT_REG:    0x12a           // Output register
BYTE            UART_HOST_TX_OUTPUT_REG;
#pragma ioport  UART_HOST_RX_CONTROL_REG:   0x02f           // Control register
BYTE            UART_HOST_RX_CONTROL_REG;
#pragma ioport  UART_HOST_RX_SHIFT_REG: 0x02c               // RX Shift Register register
BYTE            UART_HOST_RX_SHIFT_REG;
#pragma ioport  UART_HOST_RX_BUFFER_REG:    0x02e               // RX Buffer Register
BYTE            UART_HOST_RX_BUFFER_REG;
#pragma ioport  UART_HOST_RX_FUNC_REG:  0x12c               // Function register
BYTE            UART_HOST_RX_FUNC_REG;
#pragma ioport  UART_HOST_RX_INPUT_REG: 0x12d               // Input register
BYTE            UART_HOST_RX_INPUT_REG;
#pragma ioport  UART_HOST_RX_OUTPUT_REG:    0x12e           // Output register
BYTE            UART_HOST_RX_OUTPUT_REG;

// Interrupt control
#define UART_HOST_ENABLE_RX_INT  0x01
#define UART_HOST_ENABLE_TX_INT  0x02
#define UART_HOST_DISABLE_RX_INT 0x00
#define UART_HOST_DISABLE_TX_INT 0x00

#define UART_HOST_INT_MODE_TX_REG_EMPTY 0x00
#define UART_HOST_INT_MODE_TX_COMPLETE  0x01





//-------------------------------------------
//       WARNING WARNING WARNING
// The following defines and function prototypes
// are for backwards compatibility only and
// should not be used for new designs.
//-------------------------------------------
#pragma fastcall16  bUART_HOST_ReadTxStatus
#pragma fastcall16  bUART_HOST_ReadRxData
#pragma fastcall16  bUART_HOST_ReadRxStatus
extern BYTE  bUART_HOST_ReadTxStatus(void);
extern BYTE  bUART_HOST_ReadRxData(void);
extern BYTE  bUART_HOST_ReadRxStatus(void);
//------------------------------------
//  Parity masks
//------------------------------------
#define  UART_PARITY_NONE        0x00
#define  UART_PARITY_EVEN        0x02
#define  UART_PARITY_ODD         0x06

//------------------------------------
//  Transmitter Status Register masks
//------------------------------------
#define  UART_TX_COMPLETE        0x20
#define  UART_TX_BUFFER_EMPTY    0x10

//------------------------------------
//  Receiver Status Register masks
//------------------------------------
#define  UART_RX_ACTIVE          0x10
#define  UART_RX_COMPLETE        0x08
#define  UART_RX_PARITY_ERROR    0x80
#define  UART_RX_OVERRUN_ERROR   0x40
#define  UART_RX_FRAMING_ERROR   0x20
#define  UART_RX_NO_ERROR        0xE0

//-------------------------------------------
//             END WARNING
//-------------------------------------------
// end of file UART_HOST.h
