/************************************************************************/
/* Summary	: Definitions for A/D (Analog) Module for BEDS				*/
/* Filename : adc.h														*/
/* Author	: Robert Herlien (rah)										*/
/* Project	: BEDS (Benthic Event Detection System)						*/
/* Revision : 1.0														*/
/* Created	: 10/11/2012												*/
/************************************************************************/
/* Modification History:												*/
/* 11oct2012 rah - created												*/
/************************************************************************/

#ifndef ADC_H
#define ADC_H

#define VREF					2.50
#define RAW_TO_VOLTS(n)			((float)(n) * VREF / 65536.0)
#define RAW_TO_BATTVOLTS(n)		((float)(n) * 12.11* VREF / 65536.0)
#define VOLTS_TO_BATTVOLTS(f)	(12.11*f)
#define VOLTS_TO_TEMP(f)		(100.0*(f-0.5))
#define VOLTS_TO_RH(f)			(50.0*(f-0.5))


/* ADC Channels */
#define NUM_ADC_CHANS	8

typedef enum
{ BATT_CHAN, MODEM_MIN_CHAN, EXT_PRESS_CHAN, INT_PRESS_CHAN, TEMP_CHAN, HUMIDITY_CHAN
} ADC_Chans;

#if 0
#define adcInit()							TRUE
#define	adcSample(chan)						0
#define adcSampleAvg(chan, nsamples)		0
#define	adcGetRawVolts(chan)				0.0
#define	adcEngValue(chan, counts, unitp)	0.0
#else
MBool	adcInit(void);
Nat32	adcSample(Nat32 chan);
Nat32	adcSampleAvg(Nat32 chan, Nat32 nsamples);
Flt32	adcGetRawVolts(Nat32 chan);
Flt32	adcEngValue(Nat32 chan, Nat32 counts, char **unitp);
#endif

#endif /* ADC_H */
