James Reynolds / AD594x Driver
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Impedance.h Source File

Impedance.h

Go to the documentation of this file.
00001 /*!
00002  *****************************************************************************
00003  @file:    Impedance.h
00004  @author:  Neo XU
00005  @brief:   4-wire/2-wire impedance measurement header file.
00006  -----------------------------------------------------------------------------
00007 
00008 Copyright (c) 2017-2019 Analog Devices, Inc. All Rights Reserved.
00009 
00010 This software is proprietary to Analog Devices, Inc. and its licensors.
00011 By using this software you agree to the terms of the associated
00012 Analog Devices Software License Agreement.
00013  
00014 *****************************************************************************/
00015 #ifndef _IMPEDANCESEQUENCES_H_
00016 #define _IMPEDANCESEQUENCES_H_
00017 
00018 #ifdef __cplusplus
00019 extern "C" {
00020 #endif
00021 #include "ad5940.h"
00022 #include <stdio.h>
00023 #include "string.h"
00024 #include "math.h"
00025 
00026 typedef struct
00027 {
00028 /* Common configurations for all kinds of Application. */
00029   BoolFlag bParaChanged;        /* Indicate to generate sequence again. It's auto cleared by AppBIAInit */
00030   uint32_t SeqStartAddr;        /* Initialaztion sequence start address in SRAM of AD5940  */
00031   uint32_t MaxSeqLen;           /* Limit the maximum sequence.   */
00032   uint32_t SeqStartAddrCal;     /* Measurement sequence start address in SRAM of AD5940 */
00033   uint32_t MaxSeqLenCal;
00034 /* Application related parameters */ 
00035   float ImpODR;                 /*  */
00036   int32_t NumOfData;            /* By default it's '-1'. If you want the engine stops after get NumofData, then set the value here. Otherwise, set it to '-1' which means never stop. */
00037   float WuptClkFreq;            /* The clock frequency of Wakeup Timer in Hz. Typically it's 32kHz. Leave it here in case we calibrate clock in software method */
00038   float SysClkFreq;             /* The real frequency of system clock */
00039   float AdcClkFreq;             /* The real frequency of ADC clock */
00040   float RcalVal;                /* Rcal value in Ohm */
00041   /* Switch Configuration */
00042   uint32_t DswitchSel;
00043   uint32_t PswitchSel;
00044   uint32_t NswitchSel;
00045   uint32_t TswitchSel;
00046   uint32_t PwrMod;              /* Control Chip power mode(LP/HP) */
00047   uint32_t HstiaRtiaSel;        /* Use internal RTIA, select from RTIA_INT_200, RTIA_INT_1K, RTIA_INT_5K, RTIA_INT_10K, RTIA_INT_20K, RTIA_INT_40K, RTIA_INT_80K, RTIA_INT_160K */
00048   uint32_t ExcitBufGain;        /* Select from  EXCTBUFGAIN_2, EXCTBUFGAIN_0P25 */     
00049   uint32_t HsDacGain;           /* Select from  HSDACGAIN_1, HSDACGAIN_0P2 */
00050   uint32_t HsDacUpdateRate;
00051   float DacVoltPP;              /* DAC output voltage in mV peak to peak. Maximum value is 800mVpp. Peak to peak voltage  */
00052   float BiasVolt;               /* The excitation signal is DC+AC. This parameter decides the DC value in mV unit. 0.0mV means no DC bias.*/
00053   float SinFreq;                /* Frequency of excitation signal */
00054   uint32_t DftNum;              /* DFT number */
00055   uint32_t DftSrc;              /* DFT Source */
00056   BoolFlag HanWinEn;            /* Enable Hanning window */
00057   uint32_t AdcPgaGain;          /* PGA Gain select from GNPGA_1, GNPGA_1_5, GNPGA_2, GNPGA_4, GNPGA_9 !!! We must ensure signal is in range of +-1.5V which is limited by ADC input stage */   
00058   uint8_t ADCSinc3Osr;
00059   uint8_t ADCSinc2Osr;  
00060   uint8_t ADCAvgNum;
00061   /* Sweep Function Control */
00062   SoftSweepCfg_Type SweepCfg;
00063   uint32_t FifoThresh;           /* FIFO threshold. Should be N*4 */
00064 /* Private variables for internal usage */
00065 /* Private variables for internal usage */
00066   float SweepCurrFreq;
00067   float SweepNextFreq;
00068   float FreqofData;                         /* The frequency of latest data sampled */
00069   BoolFlag IMPInited;                       /* If the program run firstly, generated sequence commands */
00070   SEQInfo_Type InitSeqInfo;
00071   SEQInfo_Type MeasureSeqInfo;
00072   BoolFlag StopRequired;          /* After FIFO is ready, stop the measurement sequence */
00073   uint32_t FifoDataCount;         /* Count how many times impedance have been measured */
00074 }AppIMPCfg_Type;
00075 
00076 #define IMPCTRL_START          0
00077 #define IMPCTRL_STOPNOW        1
00078 #define IMPCTRL_STOPSYNC       2
00079 #define IMPCTRL_GETFREQ        3   /* Get Current frequency of returned data from ISR */
00080 #define IMPCTRL_SHUTDOWN       4   /* Note: shutdown here means turn off everything and put AFE to hibernate mode. The word 'SHUT DOWN' is only used here. */
00081 
00082 
00083 int32_t AppIMPInit(uint32_t *pBuffer, uint32_t BufferSize);
00084 int32_t AppIMPGetCfg(void *pCfg);
00085 int32_t AppIMPISR (void *pBuff, uint32_t *pCount);
00086 int32_t AppIMPCtrl(uint32_t Command, void *pPara);
00087 
00088 #ifdef __cplusplus
00089 }
00090 #endif
00091 #endif