/*! ***************************************************************************** @file: AD5940Main.c @author: ADI @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 BIA_Pro_Example * @{ */ #include "ad5940.h" #include "AD5940.h" #include #include "string.h" #include "math.h" #include "BodyImpedance-HiZ_Electrodes.h" #define APPBUFF_SIZE 512 uint32_t AppBuff[APPBUFF_SIZE]; #define REAL_IMAG 0 #define MAG_PAHSE 1 #define REAL_IMAG_OR_MAG_PAHSE MAG_PAHSE /*SKR you can chose what you want to print*/ /* 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; fImpCar_Type *pImp = (fImpCar_Type*)pData; AppBIACtrl(BIACTRL_GETFREQ, &freq); printf("Freq:%.2f, ", freq); /*Process data*/ #if REAL_IMAG_OR_MAG_PAHSE == REAL_IMAG for(int i=0;iAdcClkFreq = 32000000.0; /*DO NOT MODIFY*/ /*High Power Mode and external Xtal.*/ pBIACfg->SeqStartAddr = 0; pBIACfg->MaxSeqLen = 512; /** @todo add checker in function */ pBIACfg->RcalVal = 10000.0; pBIACfg->DftNum = DFTNUM_16384; pBIACfg->NumOfData = -1; /* Never stop until you stop it mannually by AppBIACtrl() function */ pBIACfg->BiaODR = 2.5; /* ODR(Sample Rate) 20Hz */ pBIACfg->FifoThresh = 12; /*SKR: this parameter needs to be changed... but it should not be visible*/ /* 4 */ pBIACfg->ADCSinc3Osr = ADCSINC3OSR_2; pBIACfg->SinFreq = 50000.0; /*50kHz */ pBIACfg->SweepCfg.SweepEn = bFALSE; pBIACfg->SweepCfg.SweepStart = 10000; pBIACfg->SweepCfg.SweepStop = 150000.0; pBIACfg->SweepCfg.SweepPoints = 100; pBIACfg->SweepCfg.SweepLog = bTRUE; } 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 */ /*SKR this needs to be invisible by the final user*/ AppBIACtrl(BIACTRL_START, 0); /* Control BIA measurment to start. Second parameter has no meaning with this command. */ while(1) { /* Check if interrupt flag which will be set when interrupt occured. */ 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 measurment to start. Second parameter has no meaning with this command. */ } } } /** * @} * @} * */