/****************************************************************************/
/* Copyright 2003-2011 MBARI						    */
/****************************************************************************/
/* Summary  : Definitions for the BEDS I/O Bits				    */
/* Filename : io.h							    */
/* Author   : Robert Herlien (rah)					    */
/* Project  : Benthic Event Detection System (BEDS)			    */
/* Revision : 1.0							    */
/* Created  : 10/14/2011 from Respirometer io.h				    */
/*									    */
/* 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:						    */
/* 14oct2011 rah - created from Respirometer io.c			    */
/* 10oct2002 rah - created from OASIS io.c				    */
/* $Log$
 */
/****************************************************************************/

#ifndef INCioh
#define INCioh	1

/****************************************/
/* Miscellaneous typedefs and defines	*/
/****************************************/
#define CPU_CLOCK	16000L		/* Clock frequency = 16 MHz	    */

#define TICKS_PER_SECOND 100		/* Frequency of software time base  */
#define MS_PER_TICK	(1000/TICKS_PER_SECOND)
#define TICK_INT_LEVEL	6		/* Interrupt level for ticker	    */
#define RTC_INT_LEVEL	3		/* Interrupt level for RTC	    */
#define WDT_INT_LEVEL	2		/* Level for tickling WDT during cmds*/

#define RTC_TICKS_PER_O3_TICK (40000/TICKS_PER_SECOND)
#define RTC_TICKS_PER_SECOND   40000
#define RTC_TICKS_PER_MS       40

#define WAIT_FOREVER	INT32_MAX

#define NAD_PORTS	8		/* Number of A/D ports		    */
#define AD_SCALE	(2.5/65536.0)	/* Scale factor for A/D cnts->volts */

#ifndef RECIPE_PROTO
/****** TPU Pin Usage for BEDS Motherboard ******/
	// AD_REF_SHDN_PIN 22 (TPU1) defined in cf2defs.h
#define MPU_PWR_EN	23		/* TPU2				*/
#define SENSOR_PWR_EN	24		/* TPU3				*/
#define MODEM_PWR_EN	25		/* TPU4				*/
#define UMPL_ON_PIN	26		/* TPU5, software indicator for umplOnTimer*/
#define MPU_IRQ_PIN	27		/* TPU6				*/
#define CLK_INT_PIN 	28		/* TPU7, SW indicator of clk int*/
#define AUX_TX_OFF	29		/* TPU8				*/
#define AUX_RX_EN	30		/* TPU9				*/
#define PKT_SEND_PIN	31		/* TPU10 SW indicator sending pkt for teapot*/
#define I2C_IO		32		/* TPU11 SW indicator doing I2C IO*/
					/* TPU12, 13 used for aux serial*/
#define MODEM_INT_PIN	35		/* TPU14, SW indicator modem adc int*/
#define SLEEP_PIN	37		/* TPU15 SW indicator sleeping	*/

#else

/****** TPU Pin Usage for RecipeCard Prototype *****/
#define CLK_INT_PIN 	22		/* TPU1, SW indicator of clk int*/
#define I2C_IO		23		/* TPU2 SW indicator doing I2C IO*/
#define MPU_IRQ_PIN	24		/* TPU3				*/
#define SENSOR_PWR_EN	25		/* Unused, but defined for debugging*/
#define MODEM_PWR_EN	25		/* Unused, but defined for debugging*/
#define MODEM_INT_PIN	25		/* TPU4, SW indicator modem adc int*/
#define PKT_SEND_PIN	25		/* TPU4 SW indicator sending pkt for teapot*/
#define UMPL_ON_PIN	26		/* TPU5, software indicator for umplOnTimer*/
#define SLEEP_PIN	27		/* TPU6 SW indicator sleeping	*/
	// AD_REF_SHDN_PIN 28 (TPU7) defined in ads8344.h
#define AUX_TX_OFF	29		/* TPU8				*/
#define AUX_RX_EN	30		/* TPU9				*/
					/* TPU10, 11 used for serial to modem pwr*/
					/* TPU12, 13 used for aux serial*/
#define LED1_PIN	35		/* TPU14			*/
#define LED2_PIN	37		/* TPU15			*/

#endif


/****************************************/
/* Function Declarations		*/
/****************************************/

Nat32	ioGetTick(Void);
Void	ioInit(Void);
Void	altSerEnable(MBool en);
Void	ioNavPwr(MBool on);
Void	ioSensorPwr(MBool on);
MBool	ioCheckMPUInt(void);
WhatWokeUs ioSleep(Nat32 sleepTicks);

#endif	/* INCioh */
