/****************************************************************************/
/* Copyright 2002 MBARI							*/
/****************************************************************************/
/* Summary  : Main Routine for OASIS Mooring Controller                     */
/* Filename : oasis.c                                                       */
/* 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 oasis.c				*/
/****************************************************************************/

#include <mbariTypes.h>			/* MBARI type definitions	    */
#include <mbariConst.h>			/* MBARI constants		    */
#include <oasis.h>			/* OASIS controller definitions	    */
#include <io.h>				/* OASIS I/O definitions	    */
//#include <task.h>			/* OASIS task dispatcher	    */
#include <cfxbios.h>			/* Persistor BIOS definitions	    */
#include <cfxpico.h>			/* Persistor PicoDOS definitions    */
#include <stdio.h>


/********************************/
/*	External Functions	*/
/********************************/

Extern Void	io_init(Void);		/* Initialize I/O module	    */


/********************************/
/*	External Data		*/
/********************************/

//Extern Reg Word		error;		/* Error vector			    */
Extern volatile Nat32	tick;		/* 10 ms ticker			    */
//Extern Reg TimeOfDay	tod;		/* Current time in TimeOfDay format */
//Extern Reg DateTime	dttm;		/* Current date & time in DateTime  */
//Extern Reg Byte		localHour;	/* Hour of day (0 - 23) in local time*/
//Extern Nat16		pwr_perm;	/* Devices to leave powered on	    */
//Extern Nat16		radio_tmout;	/* Timeout for radio reset	    */
//Extern LstHead		drv_list;	/* Driver list header		    */
//Extern Nat16		deploymentMode;	/* Non-zero if in deployment mode   */
//Extern Nat16		logStatus;	/* Log on power up/down		    */


/********************************/
/*	Global Data		*/
/********************************/

//Global Reg MBool	ext_wake;	/* TRUE if woke by /wake pin	    */
//Global Nat16		sys_init;	/* Set to MAGIC at system init	    */
//Global TimeOfDay	radio_time;	/* Last time user connected on radio*/
					/*  (set in userif.c, used here)    */

const char * const	signon = "\nOASIS R5.0\n";


/********************************/
/*	Module Local Data	*/
/********************************/

//MLocal Nat16		sys_pwrdown;	/* Set to MAGIC to show pwrd down OK*/
//MLocal TimeOfDay	alarm_time;	/* Time to sync for setting alarm   */
//MLocal Byte		didSync;	/* Did midnight sync		    */

#ifdef WATCHDOG
// This definition is the key to using the WDT
MLocal short	CustomSYPCR = WDT6_5s | HaltMonEnable | BusMonEnable | BMT32;
#endif

    
/************************************************************************/
/* Function    : oasis_init						*/
/* Purpose     : Initialize OASIS controller				*/
/* Inputs      : None							*/
/* Outputs     : None							*/
/************************************************************************/
	Void
oasis_init( Void )
{
    io_init();				/* Init I/O system, starts watchdog*/

} /* oasis_init() */


/************************************************************************/
/* Function    : main							*/
/* Purpose     : Main entry point					*/
/* Inputs      : None							*/
/* Outputs     : None							*/
/* Comments    : Never returns						*/
/************************************************************************/
Void main( int argc, char **argv)
{
  printf("OASIS test program\n\n");

  oasis_init();			/* Initialize			   */

  do
  {
    printf("Tick = %lu.  Hit char to continue, ctrl-C to end\n", tick);

  } while(cgetc() != 3);

  printf("Got ctrl-C.  Goodbye\n");

} /* _main() */
