/*******************************************************************************
**	tserial.h -- Tattletale Model-7 TPU UART Definitions
**
**	Copyright (C) 1992 ONSET Computer Corp.  --jhg		All rights reserved.
**	
**	Monday, May 25, 1992
**	
**	THINGS NOT IMPLEMENTED YET !!!!!
**		doesn't support databits other than 8
**		doesn't support parity other than 'N'
**		doesn't support any kind of handshake
**		doesn't support break or framing error detection (need in TPU code)
**	
**	Monday, July 27, 1992 --jhg
**		added TSerOutQEmpty macro to allow testing for completion prior to
**		closing.  We cheat and use TSerByteAvail() since it does the same thing.
**	
*******************************************************************************/

#ifndef		__tserial_H
#define		__tserial_H

#include	<TT7.h>

enum {
	tsOK = 0,
	tsMemError,			/* not enough memory to open channel */
	tsAlreadyOpen		/* cant open because it is already open */
	};

		/*********************************************
		**	F U N C T I O N   P R O T O T Y P E S	**
		*********************************************/
int								/* error code, zero = success */
	TSerOpen(					/* open TPU channel for UART I/O */
		int		chan,			/* TPU channel, 0..13 */
		int		outflag,		/* zero = input, non-zero = output */
		long	qsize,			/* memory buffer size to allocate */ 
		long	baud, 			/* requested baud rate */
		int		parity,			/* 'E' = even, 'O' = odd, else none */
		int		databits,		/* 0 = 8, anything else is used directly */
		int		stopbits);		/* 0 = 1, 1 = 1, 2 = 2, ... */

int								/* error code, zero = success */
	TSerClose(					/* close an opened UART TPU channel */
		int		chan);			/* TPU channel, 0..13 */

long							/* actual settable rate */
	TSerResetBaud(				/* setup new baud rate for UART channel */
		int		chan,			/* TPU channel, 0..13 */
		long	baud); 			/* requested baud rate */

int								/* non-zero if one or more bytes available */
	TSerByteAvail(				/* test for data available from input UART */
		int		chan);			/* TPU channel, 0..13 */

int								/* next byte from input queue */
	TSerGetByte(				/* wait for and return next input byte */
		int		chan);			/* TPU channel, 0..13 */

void
	TSerInFlush(				/* flush UART input queue */
		int		chan);			/* TPU channel, 0..13 */

void
	TSerPutByte(				/* write byte to UART output queue */
		int		chan,			/* TPU channel, 0..13 */
		int		data);			/* byte to write */


#define	TSerOutQEmpty	TSerByteAvail	/* test for UART output queue empty */



#endif	/*	__tserial_H */