SDMP_IOT / Mbed OS AdiSense1000_SmartBabySeat

Fork of Babyseat_NewFirmware_copy_sean by Ross O'Halloran

Committer:
giancarloDotta
Date:
Wed Jul 18 19:01:56 2018 +0000
Branch:
gd_dbg2142
Revision:
32:119f86d3d9ed
Parent:
31:de49744b57a6
Testing for bug #2142 unexpected wdt rst

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kevin1990 15:78f3f517417f 1 /*
Dan O'Donovan 27:567abf893938 2 CONFIDENTIAL AND PROPRIETARY INFORMATION
Dan O'Donovan 27:567abf893938 3
Dan O'Donovan 27:567abf893938 4 Copyright (c) 2018 Emutex Ltd. All rights reserved.
Dan O'Donovan 27:567abf893938 5 This software and documentation contain confidential and
Dan O'Donovan 27:567abf893938 6 proprietary information that is the property of
Dan O'Donovan 27:567abf893938 7 Emutex Ltd. The software and documentation are
Dan O'Donovan 27:567abf893938 8 furnished under a license agreement and may be used
Dan O'Donovan 27:567abf893938 9 or copied only in accordance with the terms of the license
Dan O'Donovan 27:567abf893938 10 agreement. No part of the software and documentation
Dan O'Donovan 27:567abf893938 11 may be reproduced, transmitted, or translated, in any
Dan O'Donovan 27:567abf893938 12 form or by any means, electronic, mechanical, manual,
Dan O'Donovan 27:567abf893938 13 optical, or otherwise, without prior written permission
Dan O'Donovan 27:567abf893938 14 of Emutex Ltd., or as expressly provided by the license agreement.
Dan O'Donovan 27:567abf893938 15 Reverse engineering is prohibited, and reproduction,
Dan O'Donovan 27:567abf893938 16 disclosure or use without specific written authorization
Dan O'Donovan 27:567abf893938 17 of Emutex Ltd. is strictly forbidden.
kevin1990 15:78f3f517417f 18 *
danodonovan 23:2adb6216b001 19 Copyright 2017 (c) Analog Devices, Inc.
kevin1990 15:78f3f517417f 20
kevin1990 15:78f3f517417f 21 All rights reserved.
kevin1990 15:78f3f517417f 22
danodonovan 23:2adb6216b001 23 Redistribution and use in source and binary forms, with or without
danodonovan 23:2adb6216b001 24 modification, are permitted provided that the following conditions are met:
danodonovan 23:2adb6216b001 25 - Redistributions of source code must retain the above copyright
danodonovan 23:2adb6216b001 26 notice, this list of conditions and the following disclaimer.
danodonovan 23:2adb6216b001 27 - Redistributions in binary form must reproduce the above copyright
danodonovan 23:2adb6216b001 28 notice, this list of conditions and the following disclaimer in
danodonovan 23:2adb6216b001 29 the documentation and/or other materials provided with the
danodonovan 23:2adb6216b001 30 distribution.
kevin1990 15:78f3f517417f 31 - Neither the name of Analog Devices, Inc. nor the names of its
kevin1990 15:78f3f517417f 32 contributors may be used to endorse or promote products derived
kevin1990 15:78f3f517417f 33 from this software without specific prior written permission.
danodonovan 23:2adb6216b001 34 - The use of this software may or may not infringe the patent rights
danodonovan 23:2adb6216b001 35 of one or more patent holders. This license does not release you
danodonovan 23:2adb6216b001 36 from the requirement that you obtain separate licenses from these
danodonovan 23:2adb6216b001 37 patent holders to use this software.
danodonovan 23:2adb6216b001 38 - Use of the software either in source or binary form, must be run
danodonovan 23:2adb6216b001 39 on or directly connected to an Analog Devices Inc. component.
kevin1990 15:78f3f517417f 40
danodonovan 23:2adb6216b001 41 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
danodonovan 23:2adb6216b001 42 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
danodonovan 23:2adb6216b001 43 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
danodonovan 23:2adb6216b001 44 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
danodonovan 23:2adb6216b001 45 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
danodonovan 23:2adb6216b001 46 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
danodonovan 23:2adb6216b001 47 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
danodonovan 23:2adb6216b001 48 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
danodonovan 23:2adb6216b001 49 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
danodonovan 23:2adb6216b001 50 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
kevin1990 15:78f3f517417f 51 *
kevin1990 15:78f3f517417f 52 *****************************************************************************/
Dan O'Donovan 27:567abf893938 53 /*!
Dan O'Donovan 27:567abf893938 54 ******************************************************************************
Dan O'Donovan 27:567abf893938 55 * @file:
Dan O'Donovan 27:567abf893938 56 *-----------------------------------------------------------------------------
Dan O'Donovan 27:567abf893938 57 *
Dan O'Donovan 27:567abf893938 58 */
kevin1990 15:78f3f517417f 59 #include "mbed.h"
Dan O'Donovan 31:de49744b57a6 60 #include "adi_sense_api.h"
Dan O'Donovan 31:de49744b57a6 61 #include "adi_sense_1000/adi_sense_1000_api.h"
Dan O'Donovan 31:de49744b57a6 62 #include "adi_sense_log.h"
kevin1990 15:78f3f517417f 63 #include "common/utils.h"
Dan O'Donovan 31:de49744b57a6 64 #include "common/platform.h"
kevin1990 15:78f3f517417f 65
kevin1990 29:57edca10d78c 66 extern ADI_SENSE_CONFIG cjc0_thermistor_10k_ntc_config;
kevin1990 15:78f3f517417f 67 extern ADI_SENSE_CONFIG sensor0_rtd_2w_pt100_config;
Dan O'Donovan 27:567abf893938 68 extern ADI_SENSE_CONFIG sensor0_microphone_config;
Dan O'Donovan 27:567abf893938 69 extern ADI_SENSE_CONFIG sensor0_diode_2c_config;
kevin1990 15:78f3f517417f 70 extern ADI_SENSE_CONFIG sensor1_typeK_cjc1_config;
kevin1990 15:78f3f517417f 71 extern ADI_SENSE_CONFIG sensor1_rtd_3w_pt100_config;
Dan O'Donovan 27:567abf893938 72 extern ADI_SENSE_CONFIG sensor1_diode_3c_config;
kevin1990 15:78f3f517417f 73 extern ADI_SENSE_CONFIG sensor2_typeT_cjc0_config;
kevin1990 15:78f3f517417f 74 extern ADI_SENSE_CONFIG sensor2_bridge_6w_pressure_config;
kevin1990 15:78f3f517417f 75 extern ADI_SENSE_CONFIG sensor3_typeJ_cjc0_config;
kevin1990 15:78f3f517417f 76 extern ADI_SENSE_CONFIG sensor3_thermistor_10k_ntc_config;
kevin1990 15:78f3f517417f 77 extern ADI_SENSE_CONFIG voltage_honeywellPressure_config;
kevin1990 15:78f3f517417f 78 extern ADI_SENSE_CONFIG current_honeywellPressure_config;
kevin1990 15:78f3f517417f 79 extern ADI_SENSE_CONFIG i2c0_honeywellHumidicon_config;
kevin1990 15:78f3f517417f 80 extern ADI_SENSE_CONFIG i2c0_sensirionSHT3X_config;
Dan O'Donovan 27:567abf893938 81 extern ADI_SENSE_CONFIG i2c0_onsemiNOA1305_config;
kevin1990 15:78f3f517417f 82 extern ADI_SENSE_CONFIG spi0_honeywellTrustability_config;
kevin1990 15:78f3f517417f 83 extern ADI_SENSE_CONFIG spi0_adiAdxl362_config;
Dan O'Donovan 27:567abf893938 84 extern ADI_SENSE_CONFIG spi0_adiAdxl355_config;
kevin1990 29:57edca10d78c 85 extern ADI_SENSE_CONFIG uart_cozirCO2_config;
kevin1990 15:78f3f517417f 86 extern ADI_SENSE_CONFIG multichannel_continuous_config;
kevin1990 15:78f3f517417f 87 extern ADI_SENSE_CONFIG multichannel_multicycle_config;
kevin1990 15:78f3f517417f 88 extern ADI_SENSE_CONFIG multichannel_singlecycle_config;
giancarloDotta 32:119f86d3d9ed 89 extern ADI_SENSE_CONFIG multichannel_singlecycle_config_dam;
kevin1990 15:78f3f517417f 90
kevin1990 15:78f3f517417f 91 /* Change the following pointer to select any of the configurations above */
giancarloDotta 32:119f86d3d9ed 92 //static ADI_SENSE_CONFIG *pSelectedConfig = &sensor0_rtd_2w_pt100_config;
giancarloDotta 32:119f86d3d9ed 93 static ADI_SENSE_CONFIG *pSelectedConfig = &multichannel_singlecycle_config_dam;
Dan O'Donovan 31:de49744b57a6 94 static ADI_SENSE_CONNECTION connectionInfo = PLATFORM_CONNECTION_INFO;
kevin1990 15:78f3f517417f 95
giancarloDotta 32:119f86d3d9ed 96 #define RES_SIZE 500
giancarloDotta 32:119f86d3d9ed 97
giancarloDotta 32:119f86d3d9ed 98 typedef struct __attribute__((packed, aligned(1))) {
giancarloDotta 32:119f86d3d9ed 99 uint16_t type : 2;
giancarloDotta 32:119f86d3d9ed 100 uint16_t fs : 10;
giancarloDotta 32:119f86d3d9ed 101 uint16_t padding : 4;
giancarloDotta 32:119f86d3d9ed 102 } FILTER_CH;
giancarloDotta 32:119f86d3d9ed 103
giancarloDotta 32:119f86d3d9ed 104 typedef struct __attribute__((packed, aligned(1))) {
giancarloDotta 32:119f86d3d9ed 105 FILTER_CH data[4];
giancarloDotta 32:119f86d3d9ed 106 uint8_t fails;
giancarloDotta 32:119f86d3d9ed 107 } FILTER_DATA;
giancarloDotta 32:119f86d3d9ed 108 FILTER_DATA result[RES_SIZE] = {0};
giancarloDotta 32:119f86d3d9ed 109
giancarloDotta 32:119f86d3d9ed 110
giancarloDotta 32:119f86d3d9ed 111 FILTER_DATA getRandomFilterData()
giancarloDotta 32:119f86d3d9ed 112 {
giancarloDotta 32:119f86d3d9ed 113 static int counter = 89;
giancarloDotta 32:119f86d3d9ed 114 const uint8_t fails[] = {88, 130, 253, 91, 94, 97, 98,100,101, 31,34,37,40};
giancarloDotta 32:119f86d3d9ed 115 const int n = sizeof(fails)/sizeof(uint8_t);
giancarloDotta 32:119f86d3d9ed 116 FILTER_DATA fd = {0};
giancarloDotta 32:119f86d3d9ed 117 // int all1 = 0;//rand() % 2;
giancarloDotta 32:119f86d3d9ed 118 int all1 = rand() % 2;
giancarloDotta 32:119f86d3d9ed 119 all1 = 0;
giancarloDotta 32:119f86d3d9ed 120 for (int ch=2; ch<6; ++ch) {
giancarloDotta 32:119f86d3d9ed 121 fd.data[ch-2].type = all1 * rand()%3+1;
giancarloDotta 32:119f86d3d9ed 122 if (fd.data[ch-2].type == 1) {
giancarloDotta 32:119f86d3d9ed 123 fd.data[ch-2].fs = ch == 2? fails[counter % n] : 1;//*/(rand() & 0xFF) +1;
giancarloDotta 32:119f86d3d9ed 124 } else {
giancarloDotta 32:119f86d3d9ed 125 fd.data[ch-2].fs = 1;
giancarloDotta 32:119f86d3d9ed 126 }
giancarloDotta 32:119f86d3d9ed 127 }
giancarloDotta 32:119f86d3d9ed 128 counter++;
giancarloDotta 32:119f86d3d9ed 129 return fd;
giancarloDotta 32:119f86d3d9ed 130 }
giancarloDotta 32:119f86d3d9ed 131
giancarloDotta 32:119f86d3d9ed 132
giancarloDotta 32:119f86d3d9ed 133 void setFilterData(FILTER_DATA fd)
giancarloDotta 32:119f86d3d9ed 134 {
giancarloDotta 32:119f86d3d9ed 135 for (int ch=2; ch<6; ++ch) {
giancarloDotta 32:119f86d3d9ed 136 ADI_SENSE_1000_ADC_FILTER_CONFIG *filter;
giancarloDotta 32:119f86d3d9ed 137 filter = &pSelectedConfig->adisense1000.channels[ch].adcChannelConfig.filter;
giancarloDotta 32:119f86d3d9ed 138 filter->type = (ADI_SENSE_1000_ADC_FILTER_TYPE)(fd.data[ch-2].type);
giancarloDotta 32:119f86d3d9ed 139 filter->fs = fd.data[ch-2].fs;
giancarloDotta 32:119f86d3d9ed 140 }
giancarloDotta 32:119f86d3d9ed 141 pSelectedConfig->adisense1000.power.powerMode = ADI_SENSE_1000_POWER_MODE_LOW;
giancarloDotta 32:119f86d3d9ed 142 }
giancarloDotta 32:119f86d3d9ed 143
giancarloDotta 32:119f86d3d9ed 144
giancarloDotta 32:119f86d3d9ed 145 void printFilterData(FILTER_DATA fd, int colourLimit, int idx)
giancarloDotta 32:119f86d3d9ed 146 {
giancarloDotta 32:119f86d3d9ed 147 char colour[16] = "";
giancarloDotta 32:119f86d3d9ed 148 if (colourLimit) {
giancarloDotta 32:119f86d3d9ed 149 strncpy(colour, fd.fails == colourLimit? HRED_TEXT"" :
giancarloDotta 32:119f86d3d9ed 150 (fd.fails == 0? HGREEN_TEXT"" : YELLOW_TEXT""), 15);
giancarloDotta 32:119f86d3d9ed 151 adi_sense_Print(colour);
giancarloDotta 32:119f86d3d9ed 152 }
giancarloDotta 32:119f86d3d9ed 153 if (idx >= 0) {
giancarloDotta 32:119f86d3d9ed 154 adi_sense_Print("%04d: ", idx);
giancarloDotta 32:119f86d3d9ed 155 }
giancarloDotta 32:119f86d3d9ed 156 if (colourLimit)
giancarloDotta 32:119f86d3d9ed 157 adi_sense_Print("fails:%d/%d ", fd.fails, colourLimit);
giancarloDotta 32:119f86d3d9ed 158 for (int ch=2; ch<6; ch++) {
giancarloDotta 32:119f86d3d9ed 159 adi_sense_Print("%4d ", fd.data[ch-2].type == 1? fd.data[ch-2].fs : -fd.data[ch-2].type);
giancarloDotta 32:119f86d3d9ed 160 }
giancarloDotta 32:119f86d3d9ed 161 adi_sense_Print("\r\n"NORMAL_TEXT);
giancarloDotta 32:119f86d3d9ed 162 }
giancarloDotta 32:119f86d3d9ed 163
giancarloDotta 32:119f86d3d9ed 164
giancarloDotta 32:119f86d3d9ed 165 ADI_SENSE_RESULT initDevice(ADI_SENSE_DEVICE_HANDLE hDevice,
giancarloDotta 32:119f86d3d9ed 166 const FILTER_DATA *fd)
kevin1990 15:78f3f517417f 167 {
kevin1990 15:78f3f517417f 168 ADI_SENSE_RESULT res;
Dan O'Donovan 27:567abf893938 169 ADI_SENSE_STATUS status;
Dan O'Donovan 30:119ff4f3aef6 170 bool bDeviceReady;
kevin1990 15:78f3f517417f 171
kevin1990 15:78f3f517417f 172 /*
kevin1990 15:78f3f517417f 173 * Reset the given ADI Sense device....
kevin1990 15:78f3f517417f 174 */
kevin1990 15:78f3f517417f 175 ADI_SENSE_LOG_INFO("Resetting ADI Sense device, please wait...");
kevin1990 15:78f3f517417f 176 res = adi_sense_Reset(hDevice);
giancarloDotta 32:119f86d3d9ed 177 if (res != ADI_SENSE_SUCCESS) {
kevin1990 15:78f3f517417f 178 ADI_SENSE_LOG_ERROR("Failed to reset device");
kevin1990 15:78f3f517417f 179 return res;
kevin1990 15:78f3f517417f 180 }
kevin1990 15:78f3f517417f 181 /*
kevin1990 15:78f3f517417f 182 * ...and wait until the device is ready.
kevin1990 15:78f3f517417f 183 */
kevin1990 15:78f3f517417f 184 do {
kevin1990 15:78f3f517417f 185 wait_ms(100);
kevin1990 15:78f3f517417f 186 res = adi_sense_GetDeviceReadyState(hDevice, &bDeviceReady);
giancarloDotta 32:119f86d3d9ed 187 if (res != ADI_SENSE_SUCCESS) {
kevin1990 15:78f3f517417f 188 ADI_SENSE_LOG_ERROR("Failed to get device ready-state");
kevin1990 15:78f3f517417f 189 return res;
kevin1990 15:78f3f517417f 190 }
kevin1990 15:78f3f517417f 191 } while (! bDeviceReady);
kevin1990 15:78f3f517417f 192 ADI_SENSE_LOG_INFO("ADI Sense device ready");
kevin1990 15:78f3f517417f 193
kevin1990 15:78f3f517417f 194 /*
kevin1990 15:78f3f517417f 195 * Write configuration settings to the device registers.
kevin1990 15:78f3f517417f 196 * Settings are not applied until adi_sense_ApplyConfigUpdates() is called.
kevin1990 15:78f3f517417f 197 */
giancarloDotta 32:119f86d3d9ed 198
giancarloDotta 32:119f86d3d9ed 199 ADI_SENSE_LOG_INFO(HBLUE_TEXT"Setting device configuration");
giancarloDotta 32:119f86d3d9ed 200 setFilterData(*fd);
giancarloDotta 32:119f86d3d9ed 201 printFilterData(*fd, 0, -1);
giancarloDotta 32:119f86d3d9ed 202
kevin1990 15:78f3f517417f 203 res = adi_sense_SetConfig(hDevice, pSelectedConfig);
giancarloDotta 32:119f86d3d9ed 204 if (res != ADI_SENSE_SUCCESS) {
kevin1990 15:78f3f517417f 205 ADI_SENSE_LOG_ERROR("Failed to set device configuration");
kevin1990 15:78f3f517417f 206 return res;
kevin1990 15:78f3f517417f 207 }
kevin1990 15:78f3f517417f 208 res = adi_sense_ApplyConfigUpdates(hDevice);
giancarloDotta 32:119f86d3d9ed 209 if (res != ADI_SENSE_SUCCESS) {
kevin1990 15:78f3f517417f 210 ADI_SENSE_LOG_ERROR("Failed to apply device configuration");
kevin1990 15:78f3f517417f 211 return res;
kevin1990 15:78f3f517417f 212 }
Dan O'Donovan 27:567abf893938 213 /*
Dan O'Donovan 27:567abf893938 214 * Check device status after updating the configuration
Dan O'Donovan 27:567abf893938 215 */
Dan O'Donovan 27:567abf893938 216 res = adi_sense_GetStatus(hDevice, &status);
giancarloDotta 32:119f86d3d9ed 217 if (res != ADI_SENSE_SUCCESS) {
Dan O'Donovan 27:567abf893938 218 ADI_SENSE_LOG_ERROR("Failed to retrieve device status");
Dan O'Donovan 27:567abf893938 219 return res;
Dan O'Donovan 27:567abf893938 220 }
Dan O'Donovan 27:567abf893938 221 if (status.deviceStatus &
giancarloDotta 32:119f86d3d9ed 222 (ADI_SENSE_DEVICE_STATUS_ERROR | ADI_SENSE_DEVICE_STATUS_ALERT)) {
Dan O'Donovan 27:567abf893938 223 utils_printStatus(&status);
Dan O'Donovan 27:567abf893938 224 }
giancarloDotta 32:119f86d3d9ed 225 return ADI_SENSE_SUCCESS;
giancarloDotta 32:119f86d3d9ed 226 }
giancarloDotta 32:119f86d3d9ed 227
giancarloDotta 32:119f86d3d9ed 228
giancarloDotta 32:119f86d3d9ed 229 int main()
giancarloDotta 32:119f86d3d9ed 230 {
giancarloDotta 32:119f86d3d9ed 231 ADI_SENSE_RESULT res;
giancarloDotta 32:119f86d3d9ed 232 ADI_SENSE_DEVICE_HANDLE hDevice;
giancarloDotta 32:119f86d3d9ed 233 ADI_SENSE_MEASUREMENT_MODE eMeasurementMode = ADI_SENSE_MEASUREMENT_MODE_NORMAL;
giancarloDotta 32:119f86d3d9ed 234 FILTER_DATA fd = {
giancarloDotta 32:119f86d3d9ed 235 .fails = 0,
giancarloDotta 32:119f86d3d9ed 236 .data = {
giancarloDotta 32:119f86d3d9ed 237 {1, 120, 0},
giancarloDotta 32:119f86d3d9ed 238 {2, 120, 0},
giancarloDotta 32:119f86d3d9ed 239 {3, 120, 0},
giancarloDotta 32:119f86d3d9ed 240 {1, 4, 0},
giancarloDotta 32:119f86d3d9ed 241 }
giancarloDotta 32:119f86d3d9ed 242 };
giancarloDotta 32:119f86d3d9ed 243
giancarloDotta 32:119f86d3d9ed 244 fd = getRandomFilterData();
giancarloDotta 32:119f86d3d9ed 245 /*
giancarloDotta 32:119f86d3d9ed 246 * Open an ADI Sense device instance.
giancarloDotta 32:119f86d3d9ed 247 */
giancarloDotta 32:119f86d3d9ed 248 res = adi_sense_Open(0, &connectionInfo, &hDevice);
giancarloDotta 32:119f86d3d9ed 249 if (res != ADI_SENSE_SUCCESS) {
giancarloDotta 32:119f86d3d9ed 250 ADI_SENSE_LOG_ERROR("Failed to open device instance");
giancarloDotta 32:119f86d3d9ed 251 return res;
giancarloDotta 32:119f86d3d9ed 252 }
kevin1990 15:78f3f517417f 253
giancarloDotta 32:119f86d3d9ed 254 ADI_SENSE_LOG_INFO(" ");
giancarloDotta 32:119f86d3d9ed 255 ADI_SENSE_LOG_INFO(" ");
giancarloDotta 32:119f86d3d9ed 256 ADI_SENSE_LOG_INFO(" ");
giancarloDotta 32:119f86d3d9ed 257 ADI_SENSE_LOG_INFO(" ");
giancarloDotta 32:119f86d3d9ed 258 ADI_SENSE_LOG_INFO(HGREEN_TEXT"------------------------- ----------");
giancarloDotta 32:119f86d3d9ed 259 ADI_SENSE_LOG_INFO(HGREEN_TEXT"OPENING ADISENSE DEVICE 0 ----------");
giancarloDotta 32:119f86d3d9ed 260 ADI_SENSE_LOG_INFO(HGREEN_TEXT"------------------------- ----------");
giancarloDotta 32:119f86d3d9ed 261 ADI_SENSE_LOG_INFO(" ");
giancarloDotta 32:119f86d3d9ed 262 ADI_SENSE_LOG_INFO(" ");
giancarloDotta 32:119f86d3d9ed 263
giancarloDotta 32:119f86d3d9ed 264 int cfgCount = 0;
giancarloDotta 32:119f86d3d9ed 265 int repetitionCount = 0;
giancarloDotta 32:119f86d3d9ed 266 const int maxRepetitions = 1;
giancarloDotta 32:119f86d3d9ed 267
giancarloDotta 32:119f86d3d9ed 268 ADI_SENSE_LOG_INFO(HBLUE_TEXT"GD bugfix#2142-24 4xRTD4 SensorN LOW power seqOfFails burst=1 300 filter Result table");//gd
giancarloDotta 32:119f86d3d9ed 269
giancarloDotta 32:119f86d3d9ed 270 do {
giancarloDotta 32:119f86d3d9ed 271 res = initDevice(hDevice, &fd);
giancarloDotta 32:119f86d3d9ed 272 if (res)
giancarloDotta 32:119f86d3d9ed 273 return res;
giancarloDotta 32:119f86d3d9ed 274 /*
giancarloDotta 32:119f86d3d9ed 275 * Kick off the measurement cycle here
giancarloDotta 32:119f86d3d9ed 276 */
giancarloDotta 32:119f86d3d9ed 277 ADI_SENSE_LOG_INFO(HBLUE_TEXT"GD-24 Run %d:%d",cfgCount+1, repetitionCount+1);
giancarloDotta 32:119f86d3d9ed 278 res = utils_runMeasurement(hDevice, eMeasurementMode);
giancarloDotta 32:119f86d3d9ed 279 ADI_SENSE_LOG_INFO("back from %d",repetitionCount+1);
giancarloDotta 32:119f86d3d9ed 280 if (res) {
giancarloDotta 32:119f86d3d9ed 281 fd.fails++;
giancarloDotta 32:119f86d3d9ed 282 ADI_SENSE_LOG_ERROR("Failed at %d:%d with error %d. Fail %d/%d",
giancarloDotta 32:119f86d3d9ed 283 cfgCount+1, repetitionCount+1, res, fd.fails, maxRepetitions);
giancarloDotta 32:119f86d3d9ed 284 }
giancarloDotta 32:119f86d3d9ed 285
giancarloDotta 32:119f86d3d9ed 286 if (++repetitionCount >= maxRepetitions) {
giancarloDotta 32:119f86d3d9ed 287 int fails = 0;
giancarloDotta 32:119f86d3d9ed 288 int oks = 0;
giancarloDotta 32:119f86d3d9ed 289 result[cfgCount] = fd;
giancarloDotta 32:119f86d3d9ed 290 for (int idx=0; idx<=cfgCount; idx++) {
giancarloDotta 32:119f86d3d9ed 291 printFilterData(result[idx], maxRepetitions, idx);
giancarloDotta 32:119f86d3d9ed 292 fails += result[idx].fails >= maxRepetitions? 1 : 0;
giancarloDotta 32:119f86d3d9ed 293 oks += result[idx].fails == 0? 1 : 0;
giancarloDotta 32:119f86d3d9ed 294 }
giancarloDotta 32:119f86d3d9ed 295 ADI_SENSE_LOG_INFO("Total=%d, fails=%.2f%%, semiFails=%.2f%%, oks=%.2f%%",
giancarloDotta 32:119f86d3d9ed 296 cfgCount+1, 100.0*fails/(cfgCount+1),
giancarloDotta 32:119f86d3d9ed 297 100.0*(cfgCount+1-fails-oks)/(cfgCount+1),
giancarloDotta 32:119f86d3d9ed 298 100.0*oks/(cfgCount+1));
giancarloDotta 32:119f86d3d9ed 299 repetitionCount = 0;
giancarloDotta 32:119f86d3d9ed 300 fd = getRandomFilterData();
giancarloDotta 32:119f86d3d9ed 301 cfgCount++;
giancarloDotta 32:119f86d3d9ed 302 }
giancarloDotta 32:119f86d3d9ed 303
giancarloDotta 32:119f86d3d9ed 304 } while (cfgCount < RES_SIZE);
giancarloDotta 32:119f86d3d9ed 305
giancarloDotta 32:119f86d3d9ed 306 ADI_SENSE_LOG_INFO("End of loop %d", cfgCount);
kevin1990 15:78f3f517417f 307
kevin1990 15:78f3f517417f 308 /*
kevin1990 15:78f3f517417f 309 * Clean up and exit
kevin1990 15:78f3f517417f 310 */
kevin1990 15:78f3f517417f 311 res = adi_sense_Close(hDevice);
giancarloDotta 32:119f86d3d9ed 312 if (res != ADI_SENSE_SUCCESS) {
kevin1990 15:78f3f517417f 313 ADI_SENSE_LOG_ERROR("Failed to close device instance");
kevin1990 15:78f3f517417f 314 return res;
kevin1990 15:78f3f517417f 315 }
kevin1990 15:78f3f517417f 316
kevin1990 15:78f3f517417f 317 return 0;
kevin1990 15:78f3f517417f 318 }