Rohan Gurav
/
Sean_AdiSense1000_V21
ADISense1000 Version 2.1 code base
Fork of AdiSense1000_V21 by
Diff: main.cpp
- Revision:
- 33:640b6bebda17
- Parent:
- 32:262fc8aeb486
--- a/main.cpp Tue Jul 24 11:49:57 2018 +0000 +++ b/main.cpp Tue Sep 18 16:46:40 2018 +0000 @@ -62,10 +62,14 @@ #include "inc/adi_sense_log.h" #include "common/utils.h" -extern ADI_SENSE_CONFIG config; +extern ADI_SENSE_CONFIG sensor2_bridge_6w_pressure_config; + +extern ADI_SENSE_1000_LUT_DESCRIPTOR *sample_lut_desc_list[]; +extern ADI_SENSE_1000_LUT_TABLE_DATA *sample_lut_data_list[]; +extern unsigned sample_lut_num_tables; /* Change the following pointer to select any of the configurations above */ -static ADI_SENSE_CONFIG *pSelectedConfig = &config; +static ADI_SENSE_CONFIG *pSelectedConfig = &sensor2_bridge_6w_pressure_config; static ADI_SENSE_CONNECTION connectionInfo = { .type = ADI_SENSE_CONNECTION_TYPE_SPI, @@ -143,6 +147,41 @@ ADI_SENSE_LOG_ERROR("Failed to set device configuration"); return res; } + + unsigned lutBufferSize = ADI_SENSE_LUT_MAX_SIZE; + ADI_SENSE_1000_LUT *pLutBuffer = (ADI_SENSE_1000_LUT *) ::operator new (lutBufferSize); + if (pLutBuffer == NULL) + { + ADI_SENSE_LOG_ERROR("Failed to allocate memory for user-defined LUT data buffer"); + return ADI_SENSE_NO_MEM; + } + + ADI_SENSE_LOG_INFO("Assembling LUT data"); + res = adi_sense_1000_AssembleLutData(pLutBuffer, lutBufferSize, + sample_lut_num_tables, + sample_lut_desc_list, + sample_lut_data_list); + if (res != ADI_SENSE_SUCCESS) + { + ADI_SENSE_LOG_ERROR("Failed to assemble user-defined LUT data"); + return res; + } + + /* + * Write assembled user-defined Look-Up Table data structure to the device + * User-defined LUT data is not applied until adi_sense_ApplyConfigUpdates() is called. + */ + ADI_SENSE_LOG_INFO("Setting LUT data"); + res = adi_sense_1000_SetLutData(hDevice, pLutBuffer); + if (res != ADI_SENSE_SUCCESS) + { + ADI_SENSE_LOG_ERROR("Failed to set user-defined LUT data"); + return res; + } + + delete pLutBuffer; + + res = adi_sense_ApplyConfigUpdates(hDevice); if (res != ADI_SENSE_SUCCESS) {