// File: RampTest.h
#ifndef _RAMPTEST_H_
#define _RAMPTEST_H_
#include "ad5940.h"
#include <stdio.h>
#include "string.h"
#include "math.h"

#define ALIGIN_VOLT2LSB     0
#define DAC12BITVOLT_1LSB   (2200.0f/4095)  //mV
#define DAC6BITVOLT_1LSB    (DAC12BITVOLT_1LSB*64)  //mV

typedef struct
{
  BoolFlag  bParaChanged;
  uint32_t  SeqStartAddr;
  uint32_t  MaxSeqLen;
  uint32_t  SeqStartAddrCal;
  uint32_t  MaxSeqLenCal;
  float     LFOSCClkFreq;
  float     SysClkFreq;
  float     AdcClkFreq;
  float     RcalVal;
  float     ADCRefVolt;
  BoolFlag  bTestFinished;
  float     RampStartVolt;
  float     RampPeakVolt;
  float     VzeroStart;
  float     VzeroPeak;
  uint32_t  StepNumber;
  uint32_t  RampDuration;
  float     SampleDelay;
  uint32_t  LPTIARtiaSel;
  uint32_t  LPTIARloadSel;
  uint32_t  LpTiaRf;        /* Added LPF Resistor Configuration */
  float     ExternalRtiaValue;
  uint32_t  AdcPgaGain;
  uint8_t   ADCSinc3Osr;
  uint32_t  FifoThresh;
  BoolFlag  RAMPInited;
  fImpPol_Type  RtiaValue;
  SEQInfo_Type  InitSeqInfo;
  SEQInfo_Type  ADCSeqInfo;
  BoolFlag      bFirstDACSeq;
  SEQInfo_Type  DACSeqInfo;
  uint32_t  CurrStepPos;
  float     DACCodePerStep;
  float     CurrRampCode;
  uint32_t  CurrVzeroCode;
  BoolFlag  bDACCodeInc;
  BoolFlag  StopRequired;
  enum _RampState{RAMP_STATE0 = 0, RAMP_STATE1, RAMP_STATE2, RAMP_STATE3, RAMP_STATE4, RAMP_STOP} RampState;
  BoolFlag  bRampOneDir;
  BoolFlag  ShortRe0Se0; /* Short RE0 to SE0 */
}AppRAMPCfg_Type;

#define APPCTRL_START          0
#define APPCTRL_STOPNOW        1
#define APPCTRL_STOPSYNC       2
#define APPCTRL_SHUTDOWN       3

AD5940Err AppRAMPInit(uint32_t *pBuffer, uint32_t BufferSize);
AD5940Err AppRAMPGetCfg(void *pCfg);
AD5940Err AppRAMPISR(void *pBuff, uint32_t *pCount);
AD5940Err AppRAMPCtrl(uint32_t Command, void *pPara);

#endif