Ross O'Halloran / Mbed OS AdiSense1000_SmartBabySeat

Fork of AdiSense1000_SmartBabySeat by SDMP_IOT

Branch:
v2.0
Revision:
29:57edca10d78c
Parent:
27:567abf893938
Child:
30:119ff4f3aef6
--- a/common/utils.c	Mon Mar 26 20:28:05 2018 +0100
+++ b/common/utils.c	Tue May 22 13:45:24 2018 +0100
@@ -26,6 +26,8 @@
             ADI_SENSE_LOG_INFO("\tActive Configuration Errors - ATTENTION REQUIRED");
         if (pStatus->deviceStatus & ADI_SENSE_DEVICE_STATUS_LUT_ERROR)
             ADI_SENSE_LOG_INFO("\tActive Look-Up Table Errors - ATTENTION REQUIRED");
+        if (pStatus->deviceStatus & ADI_SENSE_DEVICE_STATUS_EXT_FLASH_ERROR)
+            ADI_SENSE_LOG_INFO("\tActive External Flash Errors - ATTENTION REQUIRED");
 
         if (pStatus->deviceStatus & ADI_SENSE_DEVICE_STATUS_ERROR)
         {
@@ -49,14 +51,6 @@
                     ADI_SENSE_LOG_INFO("\t\t\tSupply Monitor fault detected");
                 if (pStatus->diagnosticsStatus & ADI_SENSE_DIAGNOSTICS_STATUS_SUPPLY_CAP_ERROR)
                     ADI_SENSE_LOG_INFO("\t\t\tSupply Regulator Capacitor fault detected");
-                if (pStatus->diagnosticsStatus & ADI_SENSE_DIAGNOSTICS_STATUS_AINM_UV_ERROR)
-                    ADI_SENSE_LOG_INFO("\t\t\tNegative Analog Input Under-Voltage fault detected");
-                if (pStatus->diagnosticsStatus & ADI_SENSE_DIAGNOSTICS_STATUS_AINM_OV_ERROR)
-                    ADI_SENSE_LOG_INFO("\t\t\tNegative Analog Input Over-Voltage fault detected");
-                if (pStatus->diagnosticsStatus & ADI_SENSE_DIAGNOSTICS_STATUS_AINP_UV_ERROR)
-                    ADI_SENSE_LOG_INFO("\t\t\tPositive Analog Input Under-Voltage fault detected");
-                if (pStatus->diagnosticsStatus & ADI_SENSE_DIAGNOSTICS_STATUS_AINP_OV_ERROR)
-                    ADI_SENSE_LOG_INFO("\t\t\tPositive Analog Input Over-Voltage fault detected");
                 if (pStatus->diagnosticsStatus & ADI_SENSE_DIAGNOSTICS_STATUS_CONVERSION_ERROR)
                     ADI_SENSE_LOG_INFO("\t\t\tInternal ADC Conversions fault detected");
                 if (pStatus->diagnosticsStatus & ADI_SENSE_DIAGNOSTICS_STATUS_CALIBRATION_ERROR)
@@ -101,10 +95,6 @@
                     ADI_SENSE_LOG_INFO("\t\t\tSensor Not Ready alert detected");
                 if (pStatus->channelAlerts[i] & ADI_SENSE_CHANNEL_ALERT_COMP_NOT_READY)
                     ADI_SENSE_LOG_INFO("\t\t\tCompensation Channel Not Ready alert detected");
-                if (pStatus->channelAlerts[i] & ADI_SENSE_CHANNEL_ALERT_UNDER_VOLTAGE)
-                    ADI_SENSE_LOG_INFO("\t\t\tUnder Voltage alert detected");
-                if (pStatus->channelAlerts[i] & ADI_SENSE_CHANNEL_ALERT_OVER_VOLTAGE)
-                    ADI_SENSE_LOG_INFO("\t\t\tOver Voltage alert detected");
                 if (pStatus->channelAlerts[i] & ADI_SENSE_CHANNEL_ALERT_LUT_UNDER_RANGE)
                     ADI_SENSE_LOG_INFO("\t\t\tUnder Look-Up Table Range alert detected");
                 if (pStatus->channelAlerts[i] & ADI_SENSE_CHANNEL_ALERT_LUT_OVER_RANGE)
@@ -289,47 +279,47 @@
         while (! (bDataReady || bError))
             ;
 
-        if (bError)
-            break;
-
-        /*
-         * Get data samples from the measurement cycle, if no error has occurred
-         */
-        bDataReady = false;
-        res = adi_sense_GetData(hDevice, eMeasurementMode, pSampleBuffer,
-                                nBytesPerSample, nSamplesPerDataready,
-                                &nReturned);
-        if (res != ADI_SENSE_SUCCESS)
+        if (!bError)
         {
-            if (res == ADI_SENSE_INCOMPLETE)
+            /*
+             * Get data samples from the measurement cycle, if no error has occurred
+             */
+            bDataReady = false;
+            res = adi_sense_GetData(hDevice, eMeasurementMode, pSampleBuffer,
+                                    nBytesPerSample, nSamplesPerDataready,
+                                    &nReturned);
+            if (res != ADI_SENSE_SUCCESS)
             {
-                /*
-                 * This is expected in cases where cycleSkipCount may
-                 * be non-zero for some channels, resulting in
-                 * variable-length sequences
-                 */
-                ADI_SENSE_LOG_DEBUG("Retrieved %u of %u requested data samples",
-                                    nReturned, nSamplesPerDataready);
-            }
-            else
-            {
-                ADI_SENSE_LOG_WARN("Failed to get data samples from device");
-                return res;
+                if (res == ADI_SENSE_INCOMPLETE)
+                {
+                    /*
+                     * This is expected in cases where cycleSkipCount may
+                     * be non-zero for some channels, resulting in
+                     * variable-length sequences
+                     */
+                    ADI_SENSE_LOG_DEBUG("Retrieved %u of %u requested data samples",
+                                        nReturned, nSamplesPerDataready);
+                }
+                else
+                {
+                    ADI_SENSE_LOG_WARN("Failed to get data samples from device");
+                    return res;
+                }
             }
+
+            /*
+             * Display the data samples.
+             *
+             * NOTE: this requires a sufficient idle time between subsequent
+             * DATAREADY pulses to allow printing to occur.  Otherwise,
+             * subsequent samples may be missed if not retrieved promptly when
+             * the next DATAREADY assertion occurs.
+             */
+            utils_printSamples(pSampleBuffer, nReturned, eMeasurementMode);
+            nSampleCount += nReturned;
         }
 
         /*
-         * Display the data samples.
-         *
-         * NOTE: this requires a sufficient idle time between subsequent
-         * DATAREADY pulses to allow printing to occur.  Otherwise,
-         * subsequent samples may be missed if not retrieved promptly when
-         * the next DATAREADY assertion occurs.
-         */
-        utils_printSamples(pSampleBuffer, nReturned, eMeasurementMode);
-        nSampleCount += nReturned;
-
-        /*
          * Check and print device status if errors/alerts have been triggered
          */
         if (bError || bAlert)