/*! ***************************************************************************** @file: AD5940Main.c @author: Neo Xu @brief: Used to control specific application and process data. ----------------------------------------------------------------------------- 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. *****************************************************************************/ /** * @addtogroup AD5940_System_Examples * @{ * @defgroup BioElec_Example * @{ */ #include "ad5940.h" #include "AD5940.h" #include #include "string.h" #include "math.h" #include "BodyImpedance.h" #define APPBUFF_SIZE 512 uint32_t AppBuff[APPBUFF_SIZE]; /* It's your choice here how to do with the data. Here is just an example to print them to UART */ int32_t BIAShowResult(uint32_t *pData, uint32_t DataCount) { float freq; fImpPol_Type *pImp = (fImpPol_Type*)pData; AppBIACtrl(BIACTRL_GETFREQ, &freq); printf("Freq:%.2f ", freq); /*Process data*/ for(int i=0;iSeqStartAddr = 0; pBIACfg->MaxSeqLen = 512; /** @todo add checker in function */ pBIACfg->RcalVal = 10000.0; pBIACfg->DftNum = DFTNUM_8192; pBIACfg->NumOfData = -1; /* Never stop until you stop it manually by AppBIACtrl() function */ pBIACfg->BiaODR = 20; /* ODR(Sample Rate) 20Hz */ pBIACfg->FifoThresh = 4; /* 4 */ pBIACfg->ADCSinc3Osr = ADCSINC3OSR_2; } void AD5940_Main(void) { static uint32_t IntCount; static uint32_t count; uint32_t temp; AD5940PlatformCfg(); AD5940BIAStructInit(); /* Configure your parameters in this function */ AppBIAInit(AppBuff, APPBUFF_SIZE); /* Initialize BIA application. Provide a buffer, which is used to store sequencer commands */ AppBIACtrl(BIACTRL_START, 0); /* Control BIA 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()) { IntCount++; AD5940_ClrMCUIntFlag(); /* Clear this flag */ temp = APPBUFF_SIZE; AppBIAISR(AppBuff, &temp); /* Deal with it and provide a buffer to store data we got */ BIAShowResult(AppBuff, temp); /* Show the results to UART */ if(IntCount == 240) { IntCount = 0; //AppBIACtrl(BIACTRL_SHUTDOWN, 0); } } count++; if(count > 1000000) { count = 0; //AppBIAInit(0, 0); /* Re-initialize BIA application. Because sequences are ready, no need to provide a buffer, which is used to store sequencer commands */ //AppBIACtrl(BIACTRL_START, 0); /* Control BIA measurement to start. Second parameter has no meaning with this command. */ } } } /** * @} * @} * */