Bumped Mbed FW version to 01.20.0080

Committer:
ADIJake
Date:
Mon Apr 01 11:09:52 2019 +0000
Revision:
0:85855ecd3257
Child:
5:0728bde67bdb
Initial Commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ADIJake 0:85855ecd3257 1 /*
ADIJake 0:85855ecd3257 2 Copyright 2018 (c) Analog Devices, Inc.
ADIJake 0:85855ecd3257 3
ADIJake 0:85855ecd3257 4 All rights reserved.
ADIJake 0:85855ecd3257 5
ADIJake 0:85855ecd3257 6 Redistribution and use in source and binary forms, with or without
ADIJake 0:85855ecd3257 7 modification, are permitted provided that the following conditions are met:
ADIJake 0:85855ecd3257 8 - Redistributions of source code must retain the above copyright
ADIJake 0:85855ecd3257 9 notice, this list of conditions and the following disclaimer.
ADIJake 0:85855ecd3257 10 - Redistributions in binary form must reproduce the above copyright
ADIJake 0:85855ecd3257 11 notice, this list of conditions and the following disclaimer in
ADIJake 0:85855ecd3257 12 the documentation and/or other materials provided with the
ADIJake 0:85855ecd3257 13 distribution.
ADIJake 0:85855ecd3257 14 - Neither the name of Analog Devices, Inc. nor the names of its
ADIJake 0:85855ecd3257 15 contributors may be used to endorse or promote products derived
ADIJake 0:85855ecd3257 16 from this software without specific prior written permission.
ADIJake 0:85855ecd3257 17 - The use of this software may or may not infringe the patent rights
ADIJake 0:85855ecd3257 18 of one or more patent holders. This license does not release you
ADIJake 0:85855ecd3257 19 from the requirement that you obtain separate licenses from these
ADIJake 0:85855ecd3257 20 patent holders to use this software.
ADIJake 0:85855ecd3257 21 - Use of the software either in source or binary form, must be run
ADIJake 0:85855ecd3257 22 on or directly connected to an Analog Devices Inc. component.
ADIJake 0:85855ecd3257 23
ADIJake 0:85855ecd3257 24 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
ADIJake 0:85855ecd3257 25 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
ADIJake 0:85855ecd3257 26 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
ADIJake 0:85855ecd3257 27 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
ADIJake 0:85855ecd3257 28 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
ADIJake 0:85855ecd3257 29 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
ADIJake 0:85855ecd3257 30 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
ADIJake 0:85855ecd3257 31 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
ADIJake 0:85855ecd3257 32 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
ADIJake 0:85855ecd3257 33 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
ADIJake 0:85855ecd3257 34 *
ADIJake 0:85855ecd3257 35 Copyright 2017 (c) Analog Devices, Inc.
ADIJake 0:85855ecd3257 36
ADIJake 0:85855ecd3257 37 All rights reserved.
ADIJake 0:85855ecd3257 38
ADIJake 0:85855ecd3257 39 Redistribution and use in source and binary forms, with or without
ADIJake 0:85855ecd3257 40 modification, are permitted provided that the following conditions are met:
ADIJake 0:85855ecd3257 41 - Redistributions of source code must retain the above copyright
ADIJake 0:85855ecd3257 42 notice, this list of conditions and the following disclaimer.
ADIJake 0:85855ecd3257 43 - Redistributions in binary form must reproduce the above copyright
ADIJake 0:85855ecd3257 44 notice, this list of conditions and the following disclaimer in
ADIJake 0:85855ecd3257 45 the documentation and/or other materials provided with the
ADIJake 0:85855ecd3257 46 distribution.
ADIJake 0:85855ecd3257 47 - Neither the name of Analog Devices, Inc. nor the names of its
ADIJake 0:85855ecd3257 48 contributors may be used to endorse or promote products derived
ADIJake 0:85855ecd3257 49 from this software without specific prior written permission.
ADIJake 0:85855ecd3257 50 - The use of this software may or may not infringe the patent rights
ADIJake 0:85855ecd3257 51 of one or more patent holders. This license does not release you
ADIJake 0:85855ecd3257 52 from the requirement that you obtain separate licenses from these
ADIJake 0:85855ecd3257 53 patent holders to use this software.
ADIJake 0:85855ecd3257 54 - Use of the software either in source or binary form, must be run
ADIJake 0:85855ecd3257 55 on or directly connected to an Analog Devices Inc. component.
ADIJake 0:85855ecd3257 56
ADIJake 0:85855ecd3257 57 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
ADIJake 0:85855ecd3257 58 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
ADIJake 0:85855ecd3257 59 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
ADIJake 0:85855ecd3257 60 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
ADIJake 0:85855ecd3257 61 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
ADIJake 0:85855ecd3257 62 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
ADIJake 0:85855ecd3257 63 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
ADIJake 0:85855ecd3257 64 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
ADIJake 0:85855ecd3257 65 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
ADIJake 0:85855ecd3257 66 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
ADIJake 0:85855ecd3257 67 *
ADIJake 0:85855ecd3257 68 *****************************************************************************/
ADIJake 0:85855ecd3257 69 /*!
ADIJake 0:85855ecd3257 70 ******************************************************************************
ADIJake 0:85855ecd3257 71 * @file:
ADIJake 0:85855ecd3257 72 *-----------------------------------------------------------------------------
ADIJake 0:85855ecd3257 73 *
ADIJake 0:85855ecd3257 74 */
ADIJake 0:85855ecd3257 75 #include "mbed.h"
ADIJake 0:85855ecd3257 76 #include "adi_sense_api.h"
ADIJake 0:85855ecd3257 77 #include "adi_sense_1000/adi_sense_1000_api.h"
ADIJake 0:85855ecd3257 78 #include "adi_sense_log.h"
ADIJake 0:85855ecd3257 79 #include "common/utils.h"
ADIJake 0:85855ecd3257 80 #include "common/platform.h"
ADIJake 0:85855ecd3257 81
ADIJake 0:85855ecd3257 82 extern ADI_SENSE_CONFIG cjc0_thermistor_10k_ntc_config;
ADIJake 0:85855ecd3257 83 extern ADI_SENSE_CONFIG sensor0_rtd_2w_pt100_config;
ADIJake 0:85855ecd3257 84 extern ADI_SENSE_CONFIG sensor0_microphone_config;
ADIJake 0:85855ecd3257 85 extern ADI_SENSE_CONFIG sensor0_diode_2c_config;
ADIJake 0:85855ecd3257 86 extern ADI_SENSE_CONFIG sensor0_typeK_cjc0_config;
ADIJake 0:85855ecd3257 87 extern ADI_SENSE_CONFIG sensor1_rtd_3w_pt100_config;
ADIJake 0:85855ecd3257 88 extern ADI_SENSE_CONFIG sensor1_diode_3c_config;
ADIJake 0:85855ecd3257 89 extern ADI_SENSE_CONFIG sensor2_typeT_cjc0_config;
ADIJake 0:85855ecd3257 90 extern ADI_SENSE_CONFIG sensor2_bridge_6w_pressure_config;
ADIJake 0:85855ecd3257 91 extern ADI_SENSE_CONFIG sensor3_typeJ_cjc0_config;
ADIJake 0:85855ecd3257 92 extern ADI_SENSE_CONFIG sensor3_thermistor_10k_ntc_config;
ADIJake 0:85855ecd3257 93 extern ADI_SENSE_CONFIG voltage_honeywellPressure_config;
ADIJake 0:85855ecd3257 94 extern ADI_SENSE_CONFIG current_honeywellPressure_config;
ADIJake 0:85855ecd3257 95 extern ADI_SENSE_CONFIG i2c0_honeywellHumidicon_config;
ADIJake 0:85855ecd3257 96 extern ADI_SENSE_CONFIG i2c0_sensirionSHT3X_config;
ADIJake 0:85855ecd3257 97 extern ADI_SENSE_CONFIG i2c0_onsemiNOA1305_config;
ADIJake 0:85855ecd3257 98 extern ADI_SENSE_CONFIG spi0_honeywellTrustability_config;
ADIJake 0:85855ecd3257 99 extern ADI_SENSE_CONFIG spi0_adiAdxl362_config;
ADIJake 0:85855ecd3257 100 extern ADI_SENSE_CONFIG spi0_adiAdxl355_config;
ADIJake 0:85855ecd3257 101 extern ADI_SENSE_CONFIG uart_cozirCO2_config;
ADIJake 0:85855ecd3257 102 extern ADI_SENSE_CONFIG multichannel_continuous_config;
ADIJake 0:85855ecd3257 103 extern ADI_SENSE_CONFIG multichannel_multicycle_config;
ADIJake 0:85855ecd3257 104 extern ADI_SENSE_CONFIG multichannel_singlecycle_config;
ADIJake 0:85855ecd3257 105
ADIJake 0:85855ecd3257 106 /* Change the following pointer to select any of the configurations above */
ADIJake 0:85855ecd3257 107 static ADI_SENSE_CONFIG *pSelectedConfig = &sensor0_typeK_cjc0_config;
ADIJake 0:85855ecd3257 108
ADIJake 0:85855ecd3257 109 static ADI_SENSE_CONNECTION connectionInfo = PLATFORM_CONNECTION_INFO;
ADIJake 0:85855ecd3257 110
ADIJake 0:85855ecd3257 111 int main()
ADIJake 0:85855ecd3257 112 {
ADIJake 0:85855ecd3257 113 ADI_SENSE_RESULT res;
ADIJake 0:85855ecd3257 114 ADI_SENSE_STATUS status;
ADIJake 0:85855ecd3257 115 ADI_SENSE_DEVICE_HANDLE hDevice;
ADIJake 0:85855ecd3257 116 ADI_SENSE_MEASUREMENT_MODE eMeasurementMode = ADI_SENSE_MEASUREMENT_MODE_NORMAL;
ADIJake 0:85855ecd3257 117 bool bDeviceReady;
ADIJake 0:85855ecd3257 118
ADIJake 0:85855ecd3257 119 /*
ADIJake 0:85855ecd3257 120 * Open an ADI Sense device instance.
ADIJake 0:85855ecd3257 121 */
ADIJake 0:85855ecd3257 122 res = adi_sense_Open(0, &connectionInfo, &hDevice);
ADIJake 0:85855ecd3257 123 if (res != ADI_SENSE_SUCCESS)
ADIJake 0:85855ecd3257 124 {
ADIJake 0:85855ecd3257 125 ADI_SENSE_LOG_ERROR("Failed to open device instance");
ADIJake 0:85855ecd3257 126 return res;
ADIJake 0:85855ecd3257 127 }
ADIJake 0:85855ecd3257 128
ADIJake 0:85855ecd3257 129 /*
ADIJake 0:85855ecd3257 130 * Reset the given ADI Sense device....
ADIJake 0:85855ecd3257 131 */
ADIJake 0:85855ecd3257 132 ADI_SENSE_LOG_INFO("Resetting ADI Sense device, please wait...");
ADIJake 0:85855ecd3257 133 res = adi_sense_Reset(hDevice);
ADIJake 0:85855ecd3257 134 if (res != ADI_SENSE_SUCCESS)
ADIJake 0:85855ecd3257 135 {
ADIJake 0:85855ecd3257 136 ADI_SENSE_LOG_ERROR("Failed to reset device");
ADIJake 0:85855ecd3257 137 return res;
ADIJake 0:85855ecd3257 138 }
ADIJake 0:85855ecd3257 139 /*
ADIJake 0:85855ecd3257 140 * ...and wait until the device is ready.
ADIJake 0:85855ecd3257 141 */
ADIJake 0:85855ecd3257 142 do {
ADIJake 0:85855ecd3257 143 wait_ms(100);
ADIJake 0:85855ecd3257 144 res = adi_sense_GetDeviceReadyState(hDevice, &bDeviceReady);
ADIJake 0:85855ecd3257 145 if (res != ADI_SENSE_SUCCESS)
ADIJake 0:85855ecd3257 146 {
ADIJake 0:85855ecd3257 147 ADI_SENSE_LOG_ERROR("Failed to get device ready-state");
ADIJake 0:85855ecd3257 148 return res;
ADIJake 0:85855ecd3257 149 }
ADIJake 0:85855ecd3257 150 } while (! bDeviceReady);
ADIJake 0:85855ecd3257 151 ADI_SENSE_LOG_INFO("ADI Sense device ready");
ADIJake 0:85855ecd3257 152
ADIJake 0:85855ecd3257 153 /*
ADIJake 0:85855ecd3257 154 * Write configuration settings to the device registers.
ADIJake 0:85855ecd3257 155 * Settings are not applied until adi_sense_ApplyConfigUpdates() is called.
ADIJake 0:85855ecd3257 156 */
ADIJake 0:85855ecd3257 157 ADI_SENSE_LOG_INFO("Setting device configuration");
ADIJake 0:85855ecd3257 158 res = adi_sense_SetConfig(hDevice, pSelectedConfig);
ADIJake 0:85855ecd3257 159 if (res != ADI_SENSE_SUCCESS)
ADIJake 0:85855ecd3257 160 {
ADIJake 0:85855ecd3257 161 ADI_SENSE_LOG_ERROR("Failed to set device configuration");
ADIJake 0:85855ecd3257 162 return res;
ADIJake 0:85855ecd3257 163 }
ADIJake 0:85855ecd3257 164 res = adi_sense_ApplyConfigUpdates(hDevice);
ADIJake 0:85855ecd3257 165 if (res != ADI_SENSE_SUCCESS)
ADIJake 0:85855ecd3257 166 {
ADIJake 0:85855ecd3257 167 ADI_SENSE_LOG_ERROR("Failed to apply device configuration");
ADIJake 0:85855ecd3257 168 return res;
ADIJake 0:85855ecd3257 169 }
ADIJake 0:85855ecd3257 170 /*
ADIJake 0:85855ecd3257 171 * Check device status after updating the configuration
ADIJake 0:85855ecd3257 172 */
ADIJake 0:85855ecd3257 173 res = adi_sense_GetStatus(hDevice, &status);
ADIJake 0:85855ecd3257 174 if (res != ADI_SENSE_SUCCESS)
ADIJake 0:85855ecd3257 175 {
ADIJake 0:85855ecd3257 176 ADI_SENSE_LOG_ERROR("Failed to retrieve device status");
ADIJake 0:85855ecd3257 177 return res;
ADIJake 0:85855ecd3257 178 }
ADIJake 0:85855ecd3257 179 if (status.deviceStatus &
ADIJake 0:85855ecd3257 180 (ADI_SENSE_DEVICE_STATUS_ERROR | ADI_SENSE_DEVICE_STATUS_ALERT))
ADIJake 0:85855ecd3257 181 {
ADIJake 0:85855ecd3257 182 utils_printStatus(&status);
ADIJake 0:85855ecd3257 183 }
ADIJake 0:85855ecd3257 184
ADIJake 0:85855ecd3257 185 /*
ADIJake 0:85855ecd3257 186 * Kick off the measurement cycle here
ADIJake 0:85855ecd3257 187 */
ADIJake 0:85855ecd3257 188 ADI_SENSE_LOG_INFO("Configuration completed, starting measurement cycles");
ADIJake 0:85855ecd3257 189 utils_runMeasurement(hDevice, eMeasurementMode);
ADIJake 0:85855ecd3257 190
ADIJake 0:85855ecd3257 191 /*
ADIJake 0:85855ecd3257 192 * Clean up and exit
ADIJake 0:85855ecd3257 193 */
ADIJake 0:85855ecd3257 194 res = adi_sense_Close(hDevice);
ADIJake 0:85855ecd3257 195 if (res != ADI_SENSE_SUCCESS)
ADIJake 0:85855ecd3257 196 {
ADIJake 0:85855ecd3257 197 ADI_SENSE_LOG_ERROR("Failed to close device instance");
ADIJake 0:85855ecd3257 198 return res;
ADIJake 0:85855ecd3257 199 }
ADIJake 0:85855ecd3257 200
ADIJake 0:85855ecd3257 201 return 0;
ADIJake 0:85855ecd3257 202 }
ADIJake 0:85855ecd3257 203