Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of AdiSense1000 by
Diff: main.cpp
- Revision:
- 35:cc01f0766fc2
- Parent:
- 28:4eb837cd71df
--- a/main.cpp Thu May 17 10:34:45 2018 +0100 +++ b/main.cpp Fri Aug 17 15:46:16 2018 +0000 @@ -62,32 +62,14 @@ #include "inc/adi_sense_log.h" #include "common/utils.h" -extern ADI_SENSE_CONFIG cjc0_thermistor_10k_ntc_config; -extern ADI_SENSE_CONFIG sensor0_rtd_2w_pt100_config; -extern ADI_SENSE_CONFIG sensor0_microphone_config; -extern ADI_SENSE_CONFIG sensor0_diode_2c_config; -extern ADI_SENSE_CONFIG sensor1_typeK_cjc1_config; -extern ADI_SENSE_CONFIG sensor1_rtd_3w_pt100_config; -extern ADI_SENSE_CONFIG sensor1_diode_3c_config; -extern ADI_SENSE_CONFIG sensor2_typeT_cjc0_config; -extern ADI_SENSE_CONFIG sensor2_bridge_6w_pressure_config; -extern ADI_SENSE_CONFIG sensor3_typeJ_cjc0_config; -extern ADI_SENSE_CONFIG sensor3_thermistor_10k_ntc_config; -extern ADI_SENSE_CONFIG voltage_honeywellPressure_config; -extern ADI_SENSE_CONFIG current_honeywellPressure_config; -extern ADI_SENSE_CONFIG i2c0_honeywellHumidicon_config; -extern ADI_SENSE_CONFIG i2c0_sensirionSHT3X_config; -extern ADI_SENSE_CONFIG i2c0_onsemiNOA1305_config; -extern ADI_SENSE_CONFIG spi0_honeywellTrustability_config; -extern ADI_SENSE_CONFIG spi0_adiAdxl362_config; -extern ADI_SENSE_CONFIG spi0_adiAdxl355_config; -extern ADI_SENSE_CONFIG uart_cozirCO2_config; -extern ADI_SENSE_CONFIG multichannel_continuous_config; -extern ADI_SENSE_CONFIG multichannel_multicycle_config; -extern ADI_SENSE_CONFIG multichannel_singlecycle_config; +extern ADI_SENSE_CONFIG babyseat_conf; +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 = &sensor0_rtd_2w_pt100_config; +static ADI_SENSE_CONFIG *pSelectedConfig = &babyseat_conf; static ADI_SENSE_CONNECTION connectionInfo = { .type = ADI_SENSE_CONNECTION_TYPE_SPI, @@ -154,6 +136,42 @@ } while (! bDeviceReady); ADI_SENSE_LOG_INFO("ADI Sense device ready"); + /* + * Assemble the list of user-defined Look-Up Tables from sample_lut_data.c + * into the single contiguous data format required by the device. + */ + 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; /* * Write configuration settings to the device registers. * Settings are not applied until adi_sense_ApplyConfigUpdates() is called.