/*! ***************************************************************************** @file: AD5940Main.c @author: $Author: nxu2 $ @brief: Used to control specific application and further process data. @version: $Revision: 766 $ @date: $Date: 2017-08-21 14:09:35 +0100 (Mon, 21 Aug 2017) $ ----------------------------------------------------------------------------- Copyright (c) 2017-2019 Analog Devices, Inc. All Rights Reserved. This software is proprietary to Analog Devices, Inc. and its licensors. By using this software you agree to the terms of the associated Analog Devices Software License Agreement. *****************************************************************************/ #include "ad5940.h" #include "AD5940.h" #include #include "string.h" #include "math.h" #include "Amperometric.h" #define APPBUFF_SIZE 1000 uint32_t AppBuff[APPBUFF_SIZE]; float LFOSCFreq; /* It's your choice here how to do with the data. Here is just an example to print them to UART */ int32_t AMPShowResult(float *pData, uint32_t DataCount) { /* Print data*/ for(int i=0;iWuptClkFreq = LFOSCFreq; /* Configure general parameters */ pAMPCfg->SeqStartAddr = 0; pAMPCfg->MaxSeqLen = 512; /* @todo add checker in function */ pAMPCfg->RcalVal = 10000.0; pAMPCfg->NumOfData = -1; /* Never stop until you stop it manually by AppAMPCtrl() function */ /* Configure measurement parameters */ pAMPCfg->AmpODR = 1; /* Time between samples in seconds */ pAMPCfg->FifoThresh = 4; /* Number of measurements before alerting host microcontroller */ pAMPCfg->SensorBias = 0; /* Sensor bias voltage between reference and sense electrodes*/ pAMPCfg->LptiaRtiaSel = LPTIARTIA_1K; pAMPCfg->LpTiaRl = LPTIARLOAD_10R; pAMPCfg->Vzero = 1100; /* Vzero voltage. Voltage on Sense electrode. Unit is mV*/ pAMPCfg->ADCRefVolt = 1.82; /* Measure voltage on Vref_1V8 pin */ } void AD5940_Main(void) { uint32_t temp; AD5940PlatformCfg(); AD5940AMPStructInit(); /* Configure your parameters in this function */ AppAMPInit(AppBuff, APPBUFF_SIZE); /* Initialize AMP application. Provide a buffer, which is used to store sequencer commands */ AppAMPCtrl(AMPCTRL_START, 0); /* Control AMP measurement to start. Second parameter has no meaning with this command. */ while(1) { /* Check if interrupt flag which will be set when interrupt occurred. */ if(AD5940_GetMCUIntFlag()) { AD5940_ClrMCUIntFlag(); /* Clear this flag */ temp = APPBUFF_SIZE; AppAMPISR(AppBuff, &temp); /* Deal with it and provide a buffer to store data we got */ AMPShowResult((float*)AppBuff, temp); /* Show the results to UART */ } } }