#ifndef INITS_DEFINED
#define INITS_DEFINED	7F03

#include		"science.h"
#include		"engineer.h"

/*  struct setup_variables
 *
 *  Keeps all of the state information describing the logger.  This includes
 *  hardware states (e.g., amplifier gains on the science channel inputs) and
 *  software states (e.g., how often we should sample the science inputs)
 *
*/
//  REVIEW
//  the value of 8 is hardcoded here to maintain compatibility with old eeprom writes
//  we are currently using only 4 
struct setup_variables  {
	long eng_rate[N_ENG_CHANNELS];	//  Conversion rate to use with each of the engineering channels.
									//  This is actually the number of seconds between conversions. 
									//  If this number is 0, the channel is not ever sampled.



	float science_rate;		//  Number of samples per second for science channels;  this is used
							//  to init the A/D converter;  all four channels are sampled at the
							//  same rate.
							
	float science_gain[N_SCI_CHANNELS];
							//  The gain on the science channels may be set to 2.5 or 25
							//  Each channel is individually controllable.

	int science_chans;		//  Bit pattern specifies which channels are to be monitored
	                        //  LSB = channel 0, ...; a set bit is monitored
	                        
	int trigger_chans;      //  Bit pattern specifies which channels are to be considered
	                        //  when calculating the triggering.  non-zero bits indicate that
	                        //  triggering is enabled for this channel.  LSB = channel 0, ...
	                        //  The software currently calculates triggering for all channels,
	                        //	Any channel which triggers causing all active channels to be
	                        //  saved.
	float t_STA;			//  length of short term average in seconds; same for all channels
	float t_LTA;			//  length of long term average in seconds; same for all channels
	float trigger_level[N_SCI_CHANNELS];	//  ratio of STA/LTA which causes a trigger
	float post_event_time;	//  length of post event data in seconds
	float pre_event_time;	//  length of pre-event time in seconds
	
	long min_disk_write;	//  minimum number of points to write to disk; choose this so
							//  so as to save power
	short science_n_to_average;
							//  Number of science data samples to average together before
							//  using the data.  This is a convenient way to adjust the sample
							//  rate.
	long tick_offset;		//  used to init the timer routines
};
extern struct setup_variables setup_data;

int eeprom_read_setup_data (short address);
int eeprom_write_setup_data (short address);
void eeprom_set_default_setup_data (void);
//  The next routine is normally used only during debugging
//  or setup to print out the current state
void eeprom_print_setup_data (void);
//  Tests eeprom data to verify that it is at least approximately correct
short eeprom_verify_setup_data (void);

#endif

