/************************************************************************/
/* Copyright 2003-2012 MBARI						*/
/************************************************************************/
/* Summary  : Definitions for the SPI I/O Bits for BEDS controller      */
/* Filename : spi.c							*/
/* Author   : Robert Herlien (rah)					*/
/* Project  : Benthic Event Detection System (BEDS)			*/
/* Revision: 1.0							*/
/* Created  : 10/17/2011 from Respirometer spi.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:						*/
/* 10jan2003 rah - created						*/
/* 08dec2008 rah - modified for respirometer controller			*/ 
/* 17oct2011 rah - modified for BEDS					*/
/************************************************************************/

#ifndef INCspih
#define INCspih	1


/************************************************/
/* Definitions for SPI Slots for BEDS controller*/
/************************************************/

#define ADSLOT		NMPCS3		/* SPI slot for ADC		*/
#define RTCSLOT		NMPCS2		/* SPI slot for DS3234 RTC	*/

typedef enum				/* Registers for DS3234 RTC chip*/	
{					
    RTC_SEC = 0, RTC_MIN, RTC_HOUR, RTC_WDAY, RTC_MDAY, RTC_MON, RTC_YEAR,
    RTC_ALM1_SEC, RTC_ALM1_MIN, RTC_ALM1_HOUR, RTC_ALM1_DAY,
    RTC_ALM2_MIN, RTC_ALM2_HOUR, RTC_ALM2_DAY,
    RTC_CTRL, RTC_CTRLSTAT, RTC_XTAL_AGING,
    RTC_TEMP, RTC_TEMPL, RTC_TEMPCTRL,
    RTC_RSVD1, RTC_RSVD2, RTC_RSVD3, RTC_RSVD4,
    RTC_ADDR, RTC_DATA
} RTCRegs;

/****************************************/
/* Function Declarations		*/
/****************************************/

Void	spiInit(Void);
Int16	spiReadRTCReg(Nat16 addr);
Int16	spiWriteRTCReg(Nat16 addr, Nat16 wdat);
Int16	spiReadMultRTCRegs(Nat16 addr, Nat16 numRegs, Nat16 *result);
Int16	spiWriteMultRTCRegs(Nat16 addr, Nat16 numRegs, Nat16 *wdat);

#endif	/* INCspih */
