/****************************************************************************/
/* Copyright 2016 MBARI.                                                    */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/

#ifndef _UART1_H
#define _UART1_H

#include "typedefs.h"

/* Speed of the UART1 module */
#define BAUD_RATE_UART1	19200L

/* Speed of the UART2 module */
#define BAUD_RATE_UART2	19200L

/*---------------------------------------------------------------------------
  MACRO: True if the serial ports input buffer contains received data
---------------------------------------------------------------------------*/
#define mIsU1RXDataAvailable() (U1STAbits.URXDA)

#define RxFifoSz (32)  //Number of characters in the Fifo ring buffer
extern unsigned char RxFifo[]; // The static FIFO allocated in interrupts.c
extern unsigned char *RxPutPt; //    Pointer of where to put next char in SCI1 FIFO
extern unsigned char *RxGetPt; //    Pointer of where to get next char from SCI1 FIFO
                      // FIFO is empty if PutPt=GetPt 
                      // FIFO is full  if PutPt+1=GetPt

//function declaration
void vInitU1 ( void );
void vInitU2 ( void );
void ClearRxFifo (void);
void vPutCharU ( unsigned short cChar , int chan);
void vPutStrU ( char* pcStr, int chan );
CHAR cGetCharU( int chan );
int RxStr(int maxchar,char *buf,int ms_to1,int ms_bet); //read RxD1 to LF
int RxStr2(int maxchar,char *buf,int ms_to1,int ms_bet); //read RxD2 to LF
int UI_parse (int ms);
#endif
