/*
 Data acquisition structures and constants
 
 Copyright (c) 2008 Dimtel, Inc., All Rights Reserved

 $Id: dacq.h,v 1.1.1.1 2009/06/02 20:25:59 dim Exp $
 $Date: 2009/06/02 20:25:59 $
 $Author: dim $
 $Revision: 1.1.1.1 $
 $Log: dacq.h,v $
 Revision 1.1.1.1  2009/06/02 20:25:59  dim
 Initial import


*/

#ifndef _DACQ_H_
#define _DACQ_H_

#include <pthread.h>

#define ADC_LENGTH       4096
#define LPF_LENGTH 	 10
#define GET_DEMUX(a) 	 (4 + 2*a)

/* Wait for acquisitions shorter than this */
#define T_ACQ_WAIT_MAX	30.0
/* Wait for this many uS*/
#define T_ACQ_WAIT	5000

typedef struct acq_data
{
  short adc[4][ADC_LENGTH];
  unsigned int *data;
  char new;
} acq_data;

#define TRIG_NEW	0x1
#define TRIG_PROC	0x2
#define T_PROC_WAIT	100000

typedef struct proc_data
{
  char   trigger, first, scale_update;
  double us_per_sample;
  double alpha;
  short adc[4][ADC_LENGTH];
  float tsc[ADC_LENGTH];
  double mag[4][ADC_LENGTH/2+1], mag_old[4][ADC_LENGTH/2+1];
  float  freq[ADC_LENGTH/2+1];
  
  struct link *db_adc[4];
  struct link *db_mag[4];
  struct link *db_tsc, *db_freq;
  
  pthread_mutex_t data_mutex;
} proc_data;

#endif /* _DACQ_H_ */
