/****************************************************************************/
/* Copyright 2014 MBARI                                                     */
/* MBARI Proprietary Information. All rights reserved.                      */
/* Written 30jan2014, Robert Herlien (rah)				    */
/****************************************************************************/

#ifndef MISC_H
#define MISC_H

#include <mb.h>
#include <adc.h>

#define SW_REV_HIGH	1
#define SW_REV_LOW	5

#define FIRST_COIL   1
#define TOTAL_COILS  9

#define SERIAL_NUM	0x0010
#define SOFTWARE_REV	0x0011
#define SYS_STATUS	0x0012
#define GF_NUM_SAMPS	0x0013
#define GF_SAMP_PERIOD	0x0014
#define GF_IGNORE_SAMPS	0x0015
#define GF_CTRL		0x0016
#define GF_SEQ		0x0017
#define GF_CHAN		0x0018
#define GF_RESULT_START	0x0019
#define NUM_GF_CHANS	6
#define H2O_SENSE	0x001f
#define GF_NORM_END	4
#define GF_TEST_CHAN	5
#define GF_TEST_END	6

#define MISC_START	SERIAL_NUM
#define MISC_END	H2O_SENSE

#define GF_START	GF_NUM_SAMPS
#define GF_END		(GF_RESULT_START + NUM_GF_CHANS - 1)

#define REG_INPUT_START 1000
#define REG_INPUT_NREGS 4

#define REG_HOLDING_START MISC_START
#define REG_HOLDING_MAX ADC_HOLDING_END


/********** Functions ***************/

unsigned int	miscRegRead(unsigned int address);
eMBErrorCode	miscRegWrite(unsigned int address, unsigned int val);
void		miscInit(void);

#endif
