/************************************************************************/
/* Copyright 2002 MBARI							*/
/************************************************************************/
/* Summary  : Definitions for the OASIS3 I/O Bits			*/
/* Filename : io.h							*/
/* Author   : Robert Herlien (rah)					*/
/* Project  : OASIS Mooring Replacement (OASIS3)			*/
/* Revision: 0.1							*/
/* Created  : 10/14/2002						*/
/*									    */
/* MBARI provides this documentation and code "as is", with no warranty,    */
/* express or implied, of its quality or consistency. It is provided without*/
/* support and without obligation on the part of the Monterey Bay Aquarium  */
/* Research Institute to assist in its use, correction, modification, or    */
/* enhancement. This information should not be published or distributed to  */
/* third parties without specific written permission from MBARI.            */
/*									    */
/************************************************************************/
/* Modification History:						*/
/* 10oct2002 rah - created from OASIS io.h				*/
/************************************************************************/

#ifndef INCioh
#define INCioh	1

/****************************************/
/* Miscellaneous typedefs and defines	*/
/****************************************/
#define CPU_CLOCK	7360L		/* Clock frequency = 7.36 MHz	    */

#define TICKS_PER_SECOND 100		/* Frequency of software time base  */
#define TICK_INT_LEVEL	6		/* Interrupt level for ticker	    */

#define NSER_PORTS	8		/* 8 serial ports		    */
#define NAD_PORTS	8		/* 8 A/D ports			    */
#define CPU_SER		0		/* CPU serial port is port 0	    */
#define XON		0x11		/* Xon ASCII character		    */
#define XOFF		0x13		/* Xoff ASCII character		    */

	/* Bit definitions for "mode" word passed to ser_init()		*/
#define BAUD_MASK	0x07		/* Baud rate should be 4 LSB's, but */
					/*  we're only using 3 bits now	    */
#define PTY_MASK	0x30		/* Parity is bits 4,5		    */
#define BIT8		0x40		/* Bit 6 on for 8 bit, else 7 bit   */
#define BIT7		0		/* 7 bit characters		    */
#define STOP2		0x80		/* Bit 7 on for 2 stop bits, else 1 */
#define STOP1		0		/* 1 stop bit			    */
#define PTY_LEN_STOP	0xf0		/* Parity, stop, len in bits 4-7    */

#define NO_PTY		0		/* No parity			    */
#define EVEN_PTY	0x10		/* Even parity			    */
#define ODD_PTY		0x20		/* Odd parity			    */
#define FLOW		0x100		/* Bit 8 on for XON/XOFF flow control*/
#define ECHO		0x200		/* Bit 9 on for local echo mode	    */
#define NMODE		0xc00		/* Bits 10 & 11 are \n mode	    */
#define AUTOCR		0x400		/* 01 = Add CR before LF	    */
#define NEWCR		0x800		/* 10 = Replace newline with CR	    */
#define NOLF		0xc00		/* 11 = Don't output LF		    */

#define BAUD_75		0		/* 75 baud			    */
#define BAUD_300	1		/* 300 baud			    */
#define BAUD_1200	2		/* 1200 baud			    */
#define BAUD_2400	3		/* 2400 baud			    */
#define BAUD_4800	4		/* 4800 baud			    */
#define BAUD_9600	5		/* 9600 baud			    */
#define BAUD_19200	6		/* 19200 baud			    */
#define BAUD_38400	7		/* 38400 baud			    */


/************************************************/
/* I/O for OASIS3 controller			*/
/************************************************/


/************************************************/
/* Bit definitions for OASIS I/O		*/
/************************************************/

/****************************************/
/* Function Declarations		*/
/****************************************/

Void	ioTick(Void);
Void	ser_init(Nat16 port, Nat16 mode);
#if 0
MBool	ser_putc(Nat16 port, Byte byte);
Int16	ser_getc(Nat16 port);
Int16	ser_getn(Nat16 port, char *p, Int16 nchars);
Int16	ser_sndsts(Nat16 port);
Void	ser_flush(Nat16 port);
Void	ser_break(Nat16 port, Int16 count);
Nat16	io_atod(Nat16 channel);
Void	io_power(Word pwrbits);
Void	io_pwron(Word pwrbits);
Void	io_pwroff(Word pwrbits);
#endif
Void	io_init(Void);
#if 0
Void	io_term(Void);
#endif

#endif	/* INCioh */
