/************************************************************************/
/* Copyright 2000-2018 MBARI											*/
/************************************************************************/
/* Summary	: Definitions for BEDS controller using PIC32MX470			*/
/* Filename : beds.h													*/
/* Author	: Robert Herlien (rah)										*/
/* Project	: Benthic Event Detection System (BEDS)						*/
/* Revision : 1.0														*/
/* Created	: 04/16/2012												*/
/*																			*/
/* 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:												*/
/* 16apr2012 rah - created from OASIS oasis.h							*/
/* 13feb2018 rah - created from BEDS beds.h on Persistor CF2			*/
/************************************************************************/

#ifndef INCbedsh
#define INCbedsh		1

#include <mbariTypes.h>
#include <mbariConst.h>
#include <xc.h>					/* PIC32 register def'ns				*/

#define DEBUG					// Comment this out to turn off debug msgs
#ifdef DEBUG
#define DBG(X)	X				// Example: DBG( printf("Hello world\n") )
#else
#define DBG(X)					// Nothing
#endif

//#define DEBUG_MODEM
//#define MODEM_ON_TPU			/* define to run acoustic modem from TPU port*/
//#define DEBUG_I2C				/* define to debug I2C I/O				*/
//#define DEBUG_PKT_SEND		/* define to debug pkt send on Teapot app*/
#define DEBUG_TIME
//#define DEBUG_CONTINUE_DATA	/* TRUE to continue watch and event files*/
//#define DEBUG_CONFIG


#define NumberOf(arr)			((sizeof(arr) / sizeof(arr[0])))

#define Offset(ptr_type,field)	((Nat32)&(((ptr_type)0)->field))
#define OffsetOf(s_type,field)	Offset(s_type *,field)
#define deblank(s)				while(isspace(*s)) ((s)++)
#define _to_upper(_c)			(isalpha(_c) ? (_c) & 0x5f : (_c))

  
/****************************************/
/*		Time Constants					*/
/****************************************/

#define YEAR0			70				/* Start year for TimeOfDay			*/
#define SECS_PER_DAY	86400L			/* Seconds per day					*/


/****************************************/
/* Miscellaneous typedefs and defines	*/
/****************************************/

/* Error Codes */
typedef int		Errno;			/* Error number return code					*/
typedef int		CmdRtn;			/* Return code from user command			*/
typedef int		Parm_t;			/* User parameters							*/

#ifndef ERROR					/* ERROR and OK defined in <const.h>		*/
#define ERROR			(-1)	/* ERROR return code, same as <const.h>		*/
#define OK				0		/* OK return code, same as <const.h>		*/
#endif

#define TMOUT			(-2)	/* User timeout							*/
#define ABORT			(-3)	/* User abort							*/


/* Declarations of various function pointers	*/
typedef void	vsFunc(short);	
typedef vsFunc	*vsfptr;
typedef short	svFunc(void);
typedef svFunc	*svfptr;
typedef short	ssFunc(short);
typedef ssFunc	*ssfptr;

/* Additional error codes not in _cfx_errors.h.	 Numbers start where _cfx_errors stops	*/
#define ESRCH			 37		/* No such process */
#define EINTR			 38		/* Interrupted system call */
#define E2BIG			 39		/* Argument list too long */
#define ENOEXEC			 40		/* Exec format error */
#define ECHILD			 41		/* No child processes */

#endif	/* INCbedsh */
