AdiSense1000_V21 MBED API

Fork of AdiSense1000 by PoC_Team

Committer:
kevin1990
Date:
Mon Sep 25 14:45:20 2017 +0000
Revision:
5:dbb2b71a59ed
Parent:
3:3796776e2c27
Child:
7:4dbae381f693
v0.2 Updates

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kevin1990 5:dbb2b71a59ed 1 /*
kevin1990 3:3796776e2c27 2 ******************************************************************************
kevin1990 5:dbb2b71a59ed 3 * file: main.cpp
kevin1990 3:3796776e2c27 4 *-----------------------------------------------------------------------------
kevin1990 3:3796776e2c27 5 *
kevin1990 3:3796776e2c27 6 Copyright (c) 2017 Emutex Ltd. / Analog Devices, Inc.
kevin1990 3:3796776e2c27 7
kevin1990 3:3796776e2c27 8 All rights reserved.
kevin1990 3:3796776e2c27 9
kevin1990 3:3796776e2c27 10 Redistribution and use in source and binary forms, with or without modification,
kevin1990 3:3796776e2c27 11 are permitted provided that the following conditions are met:
kevin1990 3:3796776e2c27 12 - Redistributions of source code must retain the above copyright notice,
kevin1990 3:3796776e2c27 13 this list of conditions and the following disclaimer.
kevin1990 3:3796776e2c27 14 - Redistributions in binary form must reproduce the above copyright notice,
kevin1990 3:3796776e2c27 15 this list of conditions and the following disclaimer in the documentation
kevin1990 3:3796776e2c27 16 and/or other materials provided with the distribution.
kevin1990 3:3796776e2c27 17 - Modified versions of the software must be conspicuously marked as such.
kevin1990 3:3796776e2c27 18 - This software is licensed solely and exclusively for use with processors
kevin1990 3:3796776e2c27 19 manufactured by or for Analog Devices, Inc.
kevin1990 3:3796776e2c27 20 - This software may not be combined or merged with other code in any manner
kevin1990 3:3796776e2c27 21 that would cause the software to become subject to terms and conditions
kevin1990 3:3796776e2c27 22 which differ from those listed here.
kevin1990 3:3796776e2c27 23 - Neither the name of Analog Devices, Inc. nor the names of its
kevin1990 3:3796776e2c27 24 contributors may be used to endorse or promote products derived
kevin1990 3:3796776e2c27 25 from this software without specific prior written permission.
kevin1990 3:3796776e2c27 26 - The use of this software may or may not infringe the patent rights of one
kevin1990 3:3796776e2c27 27 or more patent holders. This license does not release you from the
kevin1990 3:3796776e2c27 28 requirement that you obtain separate licenses from these patent holders
kevin1990 3:3796776e2c27 29 to use this software.
kevin1990 3:3796776e2c27 30
kevin1990 3:3796776e2c27 31 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. AND CONTRIBUTORS "AS IS" AND ANY
kevin1990 3:3796776e2c27 32 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
kevin1990 3:3796776e2c27 33 TITLE, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
kevin1990 3:3796776e2c27 34 NO EVENT SHALL ANALOG DEVICES, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
kevin1990 3:3796776e2c27 35 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE OR CONSEQUENTIAL DAMAGES
kevin1990 3:3796776e2c27 36 (INCLUDING, BUT NOT LIMITED TO, DAMAGES ARISING OUT OF CLAIMS OF INTELLECTUAL
kevin1990 3:3796776e2c27 37 PROPERTY RIGHTS INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
kevin1990 3:3796776e2c27 38 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
kevin1990 3:3796776e2c27 39 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
kevin1990 3:3796776e2c27 40 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
kevin1990 3:3796776e2c27 41 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
kevin1990 3:3796776e2c27 42 *
kevin1990 3:3796776e2c27 43 *****************************************************************************/
kevin1990 3:3796776e2c27 44 /******************************************************************************/
kevin1990 3:3796776e2c27 45 /* Include Files */
kevin1990 3:3796776e2c27 46 /******************************************************************************/
kevin1990 3:3796776e2c27 47 #include "mbed.h"
kevin1990 3:3796776e2c27 48 #include "inc/adisense1000.h"
kevin1990 3:3796776e2c27 49
kevin1990 5:dbb2b71a59ed 50 /*!
kevin1990 5:dbb2b71a59ed 51 ******************************************************************************
kevin1990 5:dbb2b71a59ed 52 * @file: main.cpp
kevin1990 5:dbb2b71a59ed 53 * @brief: Setup the following channels listed below to configure a burst of 5
kevin1990 5:dbb2b71a59ed 54 * cycles to occur every 30 seconds.
kevin1990 5:dbb2b71a59ed 55 * The time allocated to each individual cycle is 3 seconds
kevin1990 5:dbb2b71a59ed 56 */
kevin1990 3:3796776e2c27 57
kevin1990 5:dbb2b71a59ed 58 #define BITP_VALID_DATA (7)
kevin1990 5:dbb2b71a59ed 59 #define SAMPLES_PER_CHANNEL (10)
kevin1990 5:dbb2b71a59ed 60 #define NUM_CHANNELS (9)
kevin1990 5:dbb2b71a59ed 61 #define CYCLE_TIME (3)
kevin1990 5:dbb2b71a59ed 62 #define NUM_CYCLES_PER_FILL (5)
kevin1990 5:dbb2b71a59ed 63 #define MULTI_CYCLE_FILL_INTERVAL (30)
kevin1990 5:dbb2b71a59ed 64
kevin1990 5:dbb2b71a59ed 65 void setupCJC0(void); /* RTD 2-wire PT100 */
kevin1990 5:dbb2b71a59ed 66 void setupCJC1(void); /* RTD 2-wire PT100 */
kevin1990 5:dbb2b71a59ed 67 void setupSENSOR0(void); /* RTD 2-wire PT100 */
kevin1990 5:dbb2b71a59ed 68 void setupSENSOR1(void); /* Thermocouple Type-K (compensation: CJC1) */
kevin1990 5:dbb2b71a59ed 69 void setupSENSOR2(void); /* Thermocouple Type-T (compensation: CJC0) */
kevin1990 5:dbb2b71a59ed 70 void setupSENSOR3(void); /* Thermocouple Type-J (compensation: CJC0) */
kevin1990 5:dbb2b71a59ed 71 void setupVOLTAGE(void); /* Honeywell Pressure (HSCMRNN1.6BAAA3) */
kevin1990 5:dbb2b71a59ed 72 void setupCURRENT(void); /* Honeywell Pressure (PX2CN2XX100PACH) */
kevin1990 5:dbb2b71a59ed 73 void setupI2C0(void); /* Honeywell Humidity (HIH8000 Series) */
kevin1990 3:3796776e2c27 74
kevin1990 3:3796776e2c27 75 Serial pc(PA_11, PA_12, 115200);
kevin1990 3:3796776e2c27 76
kevin1990 3:3796776e2c27 77 ADI_Channel_Config_t CJC0;
kevin1990 5:dbb2b71a59ed 78 ADI_Channel_Config_t CJC1;
kevin1990 3:3796776e2c27 79 ADI_Channel_Config_t SENSOR0;
kevin1990 5:dbb2b71a59ed 80 ADI_Channel_Config_t SENSOR1;
kevin1990 5:dbb2b71a59ed 81 ADI_Channel_Config_t SENSOR2;
kevin1990 5:dbb2b71a59ed 82 ADI_Channel_Config_t SENSOR3;
kevin1990 5:dbb2b71a59ed 83 ADI_Channel_Config_t VOLTAGE;
kevin1990 5:dbb2b71a59ed 84 ADI_Channel_Config_t CURRENT;
kevin1990 5:dbb2b71a59ed 85 ADI_Channel_Config_t I2C0;
kevin1990 3:3796776e2c27 86
kevin1990 3:3796776e2c27 87 int main() {
kevin1990 3:3796776e2c27 88 uint8_t chStatus = 0;
kevin1990 3:3796776e2c27 89 uint16_t deviceID = 0;
kevin1990 3:3796776e2c27 90 uint32_t rawSample = 0;
kevin1990 5:dbb2b71a59ed 91 float processed = 0;
kevin1990 3:3796776e2c27 92 bool validSample = 0;
kevin1990 5:dbb2b71a59ed 93 bool waitUntilReady = true;
kevin1990 3:3796776e2c27 94 ADI_CORE_Status_t devStatus;
kevin1990 3:3796776e2c27 95 ADI_SENSE_RESULT retValue;
kevin1990 3:3796776e2c27 96
kevin1990 3:3796776e2c27 97 pc.printf("\r\n\r\n\r\n\r\n");
kevin1990 3:3796776e2c27 98
kevin1990 3:3796776e2c27 99 retValue = ADISense1000_Open();
kevin1990 3:3796776e2c27 100 pc.printf("Host - Device Comms Opened with return: %d\r\n", retValue);
kevin1990 3:3796776e2c27 101
kevin1990 5:dbb2b71a59ed 102 pc.printf("Resetting ADI Sense 1000 device, please wait...\r\n");
kevin1990 5:dbb2b71a59ed 103 retValue = ADISense1000_Reset(waitUntilReady);
kevin1990 5:dbb2b71a59ed 104 pc.printf("Reset device with return: %d\r\n", retValue);
kevin1990 5:dbb2b71a59ed 105
kevin1990 3:3796776e2c27 106 retValue = ADISense1000_GetID(&deviceID);
kevin1990 3:3796776e2c27 107 pc.printf("Read device ID 0x%lx with return %d\r\n", deviceID, retValue);
kevin1990 3:3796776e2c27 108
kevin1990 3:3796776e2c27 109 retValue = ADISense1000_GetStatus(&devStatus);
kevin1990 3:3796776e2c27 110 pc.printf("Read Status 0x%lx with return %d\r\n", devStatus, retValue);
kevin1990 3:3796776e2c27 111
kevin1990 5:dbb2b71a59ed 112 ADI_CORE_Mode_t modeReg;
kevin1990 5:dbb2b71a59ed 113 modeReg.Conversion_Mode = CORE_MODE_MULTICYCLE;
kevin1990 5:dbb2b71a59ed 114 modeReg.Drdy_Mode = CORE_MODE_DRDY_PER_FIFO_FILL;
kevin1990 5:dbb2b71a59ed 115
kevin1990 5:dbb2b71a59ed 116 retValue = ADISense1000_ConfigureModule(modeReg);
kevin1990 3:3796776e2c27 117 pc.printf("Configure Module with return %d\r\n", retValue);
kevin1990 3:3796776e2c27 118
kevin1990 5:dbb2b71a59ed 119 ADI_CORE_Cycle_Control_t cycleControlReg;
kevin1990 5:dbb2b71a59ed 120 cycleControlReg.Cycle_Time = CYCLE_TIME;
kevin1990 5:dbb2b71a59ed 121 cycleControlReg.Cycle_Time_Units = CORE_CYCLE_CONTROL_SECONDS;
kevin1990 5:dbb2b71a59ed 122
kevin1990 5:dbb2b71a59ed 123 ADI_CORE_Fifo_Num_Cycles_t fifoNumCyclesReg;
kevin1990 5:dbb2b71a59ed 124 fifoNumCyclesReg.Fifo_Num_Cycles = NUM_CYCLES_PER_FILL;
kevin1990 5:dbb2b71a59ed 125
kevin1990 5:dbb2b71a59ed 126 ADI_CORE_Multi_Cycle_Rate_t multiCycleRateReg;
kevin1990 5:dbb2b71a59ed 127 multiCycleRateReg.Multi_Cycle_Rate = MULTI_CYCLE_FILL_INTERVAL;
kevin1990 5:dbb2b71a59ed 128
kevin1990 5:dbb2b71a59ed 129 retValue = ADISense1000_ConfigureCycleIntervals(cycleControlReg,
kevin1990 5:dbb2b71a59ed 130 fifoNumCyclesReg,
kevin1990 5:dbb2b71a59ed 131 multiCycleRateReg);
kevin1990 5:dbb2b71a59ed 132 pc.printf("Configure Cycle Intervals with return %d\r\n", retValue);
kevin1990 3:3796776e2c27 133
kevin1990 3:3796776e2c27 134 setupCJC0();
kevin1990 3:3796776e2c27 135 pc.printf("\r\nStart CJC0 Channel Config \r\n");
kevin1990 3:3796776e2c27 136 retValue = ADISense1000_ConfigureChannel(ADI_SENSE_CJC0, &CJC0);
kevin1990 3:3796776e2c27 137 pc.printf("Channel setup complete with return: %d\r\n", retValue);
kevin1990 3:3796776e2c27 138
kevin1990 5:dbb2b71a59ed 139 setupCJC1();
kevin1990 5:dbb2b71a59ed 140 pc.printf("\r\nStart CJC1 Channel Config \r\n");
kevin1990 5:dbb2b71a59ed 141 retValue = ADISense1000_ConfigureChannel(ADI_SENSE_CJC1, &CJC1);
kevin1990 5:dbb2b71a59ed 142 pc.printf("Channel setup complete with return: %d\r\n", retValue);
kevin1990 5:dbb2b71a59ed 143
kevin1990 3:3796776e2c27 144 setupSENSOR0();
kevin1990 3:3796776e2c27 145 pc.printf("\r\nStart SENSOR0 Channel Config \r\n");
kevin1990 3:3796776e2c27 146 retValue = ADISense1000_ConfigureChannel(ADI_SENSE_SENSOR_0, &SENSOR0);
kevin1990 3:3796776e2c27 147 pc.printf("Channel setup complete with return: %d\r\n", retValue);
kevin1990 3:3796776e2c27 148
kevin1990 5:dbb2b71a59ed 149 setupSENSOR1();
kevin1990 5:dbb2b71a59ed 150 pc.printf("\r\nStart SENSOR1 Channel Config \r\n");
kevin1990 5:dbb2b71a59ed 151 retValue = ADISense1000_ConfigureChannel(ADI_SENSE_SENSOR_1, &SENSOR1);
kevin1990 5:dbb2b71a59ed 152 pc.printf("Channel setup complete with return: %d\r\n", retValue);
kevin1990 5:dbb2b71a59ed 153
kevin1990 5:dbb2b71a59ed 154 setupSENSOR2();
kevin1990 5:dbb2b71a59ed 155 pc.printf("\r\nStart SENSOR2 Channel Config \r\n");
kevin1990 5:dbb2b71a59ed 156 retValue = ADISense1000_ConfigureChannel(ADI_SENSE_SENSOR_2, &SENSOR2);
kevin1990 5:dbb2b71a59ed 157 pc.printf("Channel setup complete with return: %d\r\n", retValue);
kevin1990 5:dbb2b71a59ed 158
kevin1990 5:dbb2b71a59ed 159 setupSENSOR3();
kevin1990 5:dbb2b71a59ed 160 pc.printf("\r\nStart SENSOR3 Channel Config \r\n");
kevin1990 5:dbb2b71a59ed 161 retValue = ADISense1000_ConfigureChannel(ADI_SENSE_SENSOR_3, &SENSOR3);
kevin1990 5:dbb2b71a59ed 162 pc.printf("Channel setup complete with return: %d\r\n", retValue);
kevin1990 5:dbb2b71a59ed 163
kevin1990 5:dbb2b71a59ed 164 setupVOLTAGE();
kevin1990 5:dbb2b71a59ed 165 pc.printf("\r\nStart VOLTAGE Channel Config \r\n");
kevin1990 5:dbb2b71a59ed 166 retValue = ADISense1000_ConfigureChannel(ADI_SENSE_V_MEASURE, &VOLTAGE);
kevin1990 5:dbb2b71a59ed 167 pc.printf("Channel setup complete with return: %d\r\n", retValue);
kevin1990 5:dbb2b71a59ed 168
kevin1990 5:dbb2b71a59ed 169 setupCURRENT();
kevin1990 5:dbb2b71a59ed 170 pc.printf("\r\nStart CURRENT Channel Config \r\n");
kevin1990 5:dbb2b71a59ed 171 retValue = ADISense1000_ConfigureChannel(ADI_SENSE_I_MEASURE, &CURRENT);
kevin1990 5:dbb2b71a59ed 172 pc.printf("Channel setup complete with return: %d\r\n", retValue);
kevin1990 5:dbb2b71a59ed 173
kevin1990 5:dbb2b71a59ed 174 setupI2C0();
kevin1990 5:dbb2b71a59ed 175 pc.printf("\r\nStart I2C0 Channel Config \r\n");
kevin1990 5:dbb2b71a59ed 176 retValue = ADISense1000_ConfigureChannel(ADI_SENSE_DIG_SENSOR_0, &I2C0);
kevin1990 5:dbb2b71a59ed 177 pc.printf("Channel setup complete with return: %d\r\n", retValue);
kevin1990 5:dbb2b71a59ed 178
kevin1990 5:dbb2b71a59ed 179 ADI_CORE_Power_Config_t powerConfig;
kevin1990 5:dbb2b71a59ed 180
kevin1990 5:dbb2b71a59ed 181 powerConfig.Power_Mode_ADC = 3; /* Full power */
kevin1990 5:dbb2b71a59ed 182 powerConfig.Power_Mode_MCU = 0; /* not yet defined */
kevin1990 5:dbb2b71a59ed 183
kevin1990 5:dbb2b71a59ed 184 retValue = ADISense1000_StartMeasurement(powerConfig, CORE_COMMAND_CONVERT_WITH_RAW);
kevin1990 3:3796776e2c27 185 pc.printf("Measurement started with return: %d\r\n\r\n", retValue);
kevin1990 3:3796776e2c27 186
kevin1990 5:dbb2b71a59ed 187 /* In multi-cycle mode, a burst of measurement cycles will be executed at cycle intervals,
kevin1990 5:dbb2b71a59ed 188 and then the burst is repeated at the multi-cycle interval */
kevin1990 5:dbb2b71a59ed 189 while (true) {
kevin1990 3:3796776e2c27 190
kevin1990 5:dbb2b71a59ed 191 pc.printf("\r\n\r\nWaiting for next multi-cycle fill to complete...\r\n\r\n");
kevin1990 5:dbb2b71a59ed 192 /* Wait for the next cycle to complete */
kevin1990 5:dbb2b71a59ed 193 while(!ADISense1000_SampleReady()) {
kevin1990 5:dbb2b71a59ed 194 }
kevin1990 3:3796776e2c27 195
kevin1990 3:3796776e2c27 196
kevin1990 5:dbb2b71a59ed 197 for(unsigned i=0; i<(SAMPLES_PER_CHANNEL*NUM_CHANNELS*NUM_CYCLES_PER_FILL); i++)
kevin1990 5:dbb2b71a59ed 198 {
kevin1990 5:dbb2b71a59ed 199 /* Read data from the enabled channels */
kevin1990 5:dbb2b71a59ed 200 retValue = ADISense1000_GetData(&rawSample, &processed, &chStatus);
kevin1990 5:dbb2b71a59ed 201 validSample = (chStatus >> BITP_VALID_DATA)&0x01;
kevin1990 5:dbb2b71a59ed 202 pc.printf("-%s- :: Sample # %2d Channel # %2d :: -%s- :: Raw %8d :: Processed %.7f\r\n",
kevin1990 5:dbb2b71a59ed 203 ((retValue>0) ? "ERROR" : "OK") , (i+1), (chStatus&0x0f), (validSample ? "VALID" : "INVALID"), rawSample, processed);
kevin1990 5:dbb2b71a59ed 204 }
kevin1990 3:3796776e2c27 205 }
kevin1990 3:3796776e2c27 206
kevin1990 3:3796776e2c27 207 }
kevin1990 3:3796776e2c27 208
kevin1990 3:3796776e2c27 209
kevin1990 3:3796776e2c27 210 void setupCJC0(void)
kevin1990 3:3796776e2c27 211 {
kevin1990 5:dbb2b71a59ed 212 CJC0.Count.Channel_Count = SAMPLES_PER_CHANNEL - 1;
kevin1990 3:3796776e2c27 213 CJC0.Count.Channel_Enable = 1;
kevin1990 3:3796776e2c27 214
kevin1990 3:3796776e2c27 215 CJC0.Type.Sensor_Type = CORE_SENSOR_TYPE_SENSOR_RTD_2W_PT100;
kevin1990 3:3796776e2c27 216 CJC0.Type.Sensor_Category = CORE_SENSOR_TYPE_ANALOG;
kevin1990 3:3796776e2c27 217
kevin1990 3:3796776e2c27 218 CJC0.Details.CJC_Publish = 1;
kevin1990 3:3796776e2c27 219 CJC0.Details.Vbias = 0;
kevin1990 3:3796776e2c27 220 CJC0.Details.Reference_Buffer_Disable = 0;
kevin1990 3:3796776e2c27 221 CJC0.Details.Reference_Select = CORE_SENSOR_DETAILS_REF_RINT1;
kevin1990 3:3796776e2c27 222 CJC0.Details.PGA_Gain = 3; /* G=8 */
kevin1990 3:3796776e2c27 223
kevin1990 3:3796776e2c27 224 CJC0.Excitation.IOUT_Excitation_Current = 4; /* 500uA */
kevin1990 3:3796776e2c27 225 CJC0.Excitation.IOUT0_Disable = 0;
kevin1990 3:3796776e2c27 226
kevin1990 3:3796776e2c27 227 CJC0.FilterSelect.ADC_Filter_Type = CORE_FILTER_SELECT_FIR;
kevin1990 3:3796776e2c27 228 CJC0.FilterSelect.ADC_FIR_Sel = 3; /* 25 SPS */;
kevin1990 3:3796776e2c27 229 }
kevin1990 3:3796776e2c27 230
kevin1990 3:3796776e2c27 231
kevin1990 5:dbb2b71a59ed 232 void setupCJC1(void)
kevin1990 5:dbb2b71a59ed 233 {
kevin1990 5:dbb2b71a59ed 234 CJC1.Count.Channel_Count = SAMPLES_PER_CHANNEL - 1;
kevin1990 5:dbb2b71a59ed 235 CJC1.Count.Channel_Enable = 1;
kevin1990 5:dbb2b71a59ed 236
kevin1990 5:dbb2b71a59ed 237 CJC1.Type.Sensor_Type = CORE_SENSOR_TYPE_SENSOR_RTD_2W_PT100;
kevin1990 5:dbb2b71a59ed 238 CJC1.Type.Sensor_Category = CORE_SENSOR_TYPE_ANALOG;
kevin1990 5:dbb2b71a59ed 239
kevin1990 5:dbb2b71a59ed 240 CJC1.Details.CJC_Publish = 1;
kevin1990 5:dbb2b71a59ed 241 CJC1.Details.Vbias = 0;
kevin1990 5:dbb2b71a59ed 242 CJC1.Details.Reference_Buffer_Disable = 0;
kevin1990 5:dbb2b71a59ed 243 CJC1.Details.Reference_Select = CORE_SENSOR_DETAILS_REF_RINT1;
kevin1990 5:dbb2b71a59ed 244 CJC1.Details.PGA_Gain = 3; /* G=8 */
kevin1990 5:dbb2b71a59ed 245
kevin1990 5:dbb2b71a59ed 246 CJC1.Excitation.IOUT_Excitation_Current = 4; /* 500uA */
kevin1990 5:dbb2b71a59ed 247 CJC1.Excitation.IOUT0_Disable = 0;
kevin1990 5:dbb2b71a59ed 248
kevin1990 5:dbb2b71a59ed 249 CJC1.FilterSelect.ADC_Filter_Type = CORE_FILTER_SELECT_FIR;
kevin1990 5:dbb2b71a59ed 250 CJC1.FilterSelect.ADC_FIR_Sel = 3; /* 25 SPS */;
kevin1990 5:dbb2b71a59ed 251 }
kevin1990 5:dbb2b71a59ed 252
kevin1990 5:dbb2b71a59ed 253
kevin1990 3:3796776e2c27 254 void setupSENSOR0(void)
kevin1990 3:3796776e2c27 255 {
kevin1990 5:dbb2b71a59ed 256 SENSOR0.Count.Channel_Count = SAMPLES_PER_CHANNEL - 1;
kevin1990 3:3796776e2c27 257 SENSOR0.Count.Channel_Enable = 1;
kevin1990 3:3796776e2c27 258
kevin1990 5:dbb2b71a59ed 259 SENSOR0.Type.Sensor_Type = CORE_SENSOR_TYPE_SENSOR_RTD_2W_PT100;
kevin1990 3:3796776e2c27 260 SENSOR0.Type.Sensor_Category = CORE_SENSOR_TYPE_ANALOG;
kevin1990 3:3796776e2c27 261
kevin1990 5:dbb2b71a59ed 262 SENSOR0.Details.Vbias = 0;
kevin1990 5:dbb2b71a59ed 263 SENSOR0.Details.Reference_Buffer_Disable = 0;
kevin1990 5:dbb2b71a59ed 264 SENSOR0.Details.Reference_Select = CORE_SENSOR_DETAILS_REF_RINT1;
kevin1990 5:dbb2b71a59ed 265 SENSOR0.Details.PGA_Gain = 3; /* G=8 */
kevin1990 3:3796776e2c27 266
kevin1990 5:dbb2b71a59ed 267 SENSOR0.Excitation.IOUT_Excitation_Current = 4; /* 500uA */
kevin1990 5:dbb2b71a59ed 268 SENSOR0.Excitation.IOUT0_Disable = 0;
kevin1990 3:3796776e2c27 269
kevin1990 3:3796776e2c27 270 SENSOR0.FilterSelect.ADC_Filter_Type = CORE_FILTER_SELECT_FIR;
kevin1990 3:3796776e2c27 271 SENSOR0.FilterSelect.ADC_FIR_Sel = 3; /* 25 SPS */;
kevin1990 3:3796776e2c27 272 }
kevin1990 3:3796776e2c27 273
kevin1990 5:dbb2b71a59ed 274
kevin1990 5:dbb2b71a59ed 275 void setupSENSOR1(void)
kevin1990 5:dbb2b71a59ed 276 {
kevin1990 5:dbb2b71a59ed 277 SENSOR1.Count.Channel_Count = SAMPLES_PER_CHANNEL - 1;
kevin1990 5:dbb2b71a59ed 278 SENSOR1.Count.Channel_Enable = 1;
kevin1990 5:dbb2b71a59ed 279
kevin1990 5:dbb2b71a59ed 280 SENSOR1.Type.Sensor_Type = CORE_SENSOR_TYPE_SENSOR_THERMOCOUPLE_K;
kevin1990 5:dbb2b71a59ed 281 SENSOR1.Type.Sensor_Category = CORE_SENSOR_TYPE_ANALOG;
kevin1990 5:dbb2b71a59ed 282
kevin1990 5:dbb2b71a59ed 283 SENSOR1.Details.Vbias = 1;
kevin1990 5:dbb2b71a59ed 284 SENSOR1.Details.Reference_Buffer_Disable = 1;
kevin1990 5:dbb2b71a59ed 285 SENSOR1.Details.Compensation_Channel = 1; /* CJC1 */
kevin1990 5:dbb2b71a59ed 286 SENSOR1.Details.Reference_Select = CORE_SENSOR_DETAILS_REF_INT;
kevin1990 5:dbb2b71a59ed 287 SENSOR1.Details.PGA_Gain = 5; /* G=32 */
kevin1990 5:dbb2b71a59ed 288
kevin1990 5:dbb2b71a59ed 289 SENSOR1.FilterSelect.ADC_Filter_Type = CORE_FILTER_SELECT_FIR;
kevin1990 5:dbb2b71a59ed 290 SENSOR1.FilterSelect.ADC_FIR_Sel = 3; /* 25 SPS */;
kevin1990 5:dbb2b71a59ed 291 }
kevin1990 5:dbb2b71a59ed 292
kevin1990 5:dbb2b71a59ed 293
kevin1990 5:dbb2b71a59ed 294 void setupSENSOR2(void)
kevin1990 3:3796776e2c27 295 {
kevin1990 5:dbb2b71a59ed 296 SENSOR2.Count.Channel_Count = SAMPLES_PER_CHANNEL - 1;
kevin1990 5:dbb2b71a59ed 297 SENSOR2.Count.Channel_Enable = 1;
kevin1990 5:dbb2b71a59ed 298
kevin1990 5:dbb2b71a59ed 299 SENSOR2.Type.Sensor_Type = CORE_SENSOR_TYPE_SENSOR_THERMOCOUPLE_T;
kevin1990 5:dbb2b71a59ed 300 SENSOR2.Type.Sensor_Category = CORE_SENSOR_TYPE_ANALOG;
kevin1990 5:dbb2b71a59ed 301
kevin1990 5:dbb2b71a59ed 302 SENSOR2.Details.Vbias = 1;
kevin1990 5:dbb2b71a59ed 303 SENSOR2.Details.Reference_Buffer_Disable = 1;
kevin1990 5:dbb2b71a59ed 304 SENSOR2.Details.Compensation_Channel = 0; /* CJC0 */
kevin1990 5:dbb2b71a59ed 305 SENSOR2.Details.Reference_Select = CORE_SENSOR_DETAILS_REF_INT;
kevin1990 5:dbb2b71a59ed 306 SENSOR2.Details.PGA_Gain = 5; /* G=32 */
kevin1990 3:3796776e2c27 307
kevin1990 5:dbb2b71a59ed 308 SENSOR2.FilterSelect.ADC_Filter_Type = CORE_FILTER_SELECT_FIR;
kevin1990 5:dbb2b71a59ed 309 SENSOR2.FilterSelect.ADC_FIR_Sel = 3; /* 25 SPS */;
kevin1990 5:dbb2b71a59ed 310 }
kevin1990 5:dbb2b71a59ed 311
kevin1990 5:dbb2b71a59ed 312
kevin1990 5:dbb2b71a59ed 313 void setupSENSOR3(void)
kevin1990 5:dbb2b71a59ed 314 {
kevin1990 5:dbb2b71a59ed 315 SENSOR3.Count.Channel_Count = SAMPLES_PER_CHANNEL - 1;
kevin1990 5:dbb2b71a59ed 316 SENSOR3.Count.Channel_Enable = 1;
kevin1990 5:dbb2b71a59ed 317
kevin1990 5:dbb2b71a59ed 318 SENSOR3.Type.Sensor_Type = CORE_SENSOR_TYPE_SENSOR_THERMOCOUPLE_J;
kevin1990 5:dbb2b71a59ed 319 SENSOR3.Type.Sensor_Category = CORE_SENSOR_TYPE_ANALOG;
kevin1990 3:3796776e2c27 320
kevin1990 5:dbb2b71a59ed 321 SENSOR3.Details.Vbias = 1;
kevin1990 5:dbb2b71a59ed 322 SENSOR3.Details.Reference_Buffer_Disable = 1;
kevin1990 5:dbb2b71a59ed 323 SENSOR3.Details.Compensation_Channel = 0; /* CJC0 */
kevin1990 5:dbb2b71a59ed 324 SENSOR3.Details.Reference_Select = CORE_SENSOR_DETAILS_REF_INT;
kevin1990 5:dbb2b71a59ed 325 SENSOR3.Details.PGA_Gain = 5; /* G=32 */
kevin1990 5:dbb2b71a59ed 326
kevin1990 5:dbb2b71a59ed 327 SENSOR3.FilterSelect.ADC_Filter_Type = CORE_FILTER_SELECT_FIR;
kevin1990 5:dbb2b71a59ed 328 SENSOR3.FilterSelect.ADC_FIR_Sel = 3; /* 25 SPS */;
kevin1990 5:dbb2b71a59ed 329 }
kevin1990 5:dbb2b71a59ed 330
kevin1990 5:dbb2b71a59ed 331
kevin1990 5:dbb2b71a59ed 332 void setupVOLTAGE(void)
kevin1990 5:dbb2b71a59ed 333 {
kevin1990 5:dbb2b71a59ed 334 VOLTAGE.Count.Channel_Count = SAMPLES_PER_CHANNEL - 1;
kevin1990 5:dbb2b71a59ed 335 VOLTAGE.Count.Channel_Enable = 1;
kevin1990 5:dbb2b71a59ed 336
kevin1990 5:dbb2b71a59ed 337 VOLTAGE.Type.Sensor_Type = CORE_SENSOR_TYPE_SENSOR_VOLTAGE_PRESSURE1;
kevin1990 5:dbb2b71a59ed 338 VOLTAGE.Type.Sensor_Category = CORE_SENSOR_TYPE_ANALOG;
kevin1990 5:dbb2b71a59ed 339
kevin1990 5:dbb2b71a59ed 340 VOLTAGE.Details.Vbias = 0;
kevin1990 5:dbb2b71a59ed 341 VOLTAGE.Details.Reference_Buffer_Disable = 1;
kevin1990 5:dbb2b71a59ed 342 VOLTAGE.Details.Reference_Select = CORE_SENSOR_DETAILS_REF_INT;
kevin1990 5:dbb2b71a59ed 343 VOLTAGE.Details.PGA_Gain = 1; /* G=2 */
kevin1990 5:dbb2b71a59ed 344
kevin1990 5:dbb2b71a59ed 345 VOLTAGE.FilterSelect.ADC_Filter_Type = CORE_FILTER_SELECT_FIR;
kevin1990 5:dbb2b71a59ed 346 VOLTAGE.FilterSelect.ADC_FIR_Sel = 3; /* 25 SPS */;
kevin1990 5:dbb2b71a59ed 347 }
kevin1990 5:dbb2b71a59ed 348
kevin1990 5:dbb2b71a59ed 349
kevin1990 5:dbb2b71a59ed 350 void setupCURRENT(void)
kevin1990 5:dbb2b71a59ed 351 {
kevin1990 5:dbb2b71a59ed 352 CURRENT.Count.Channel_Count = SAMPLES_PER_CHANNEL - 1;
kevin1990 5:dbb2b71a59ed 353 CURRENT.Count.Channel_Enable = 1;
kevin1990 5:dbb2b71a59ed 354
kevin1990 5:dbb2b71a59ed 355 CURRENT.Type.Sensor_Type = CORE_SENSOR_TYPE_SENSOR_CURRENT_PRESSURE1;
kevin1990 5:dbb2b71a59ed 356 CURRENT.Type.Sensor_Category = CORE_SENSOR_TYPE_ANALOG;
kevin1990 5:dbb2b71a59ed 357
kevin1990 5:dbb2b71a59ed 358 CURRENT.Details.Vbias = 0;
kevin1990 5:dbb2b71a59ed 359 CURRENT.Details.Reference_Buffer_Disable = 1;
kevin1990 5:dbb2b71a59ed 360 CURRENT.Details.Reference_Select = CORE_SENSOR_DETAILS_REF_INT;
kevin1990 5:dbb2b71a59ed 361 CURRENT.Details.PGA_Gain = 1; /* G=2 */
kevin1990 5:dbb2b71a59ed 362
kevin1990 5:dbb2b71a59ed 363 CURRENT.FilterSelect.ADC_Filter_Type = CORE_FILTER_SELECT_FIR;
kevin1990 5:dbb2b71a59ed 364 CURRENT.FilterSelect.ADC_FIR_Sel = 3; /* 25 SPS */;
kevin1990 5:dbb2b71a59ed 365 }
kevin1990 5:dbb2b71a59ed 366
kevin1990 5:dbb2b71a59ed 367
kevin1990 5:dbb2b71a59ed 368 void setupI2C0(void)
kevin1990 5:dbb2b71a59ed 369 {
kevin1990 5:dbb2b71a59ed 370 I2C0.Count.Channel_Count = SAMPLES_PER_CHANNEL - 1;
kevin1990 5:dbb2b71a59ed 371 I2C0.Count.Channel_Enable = 1;
kevin1990 5:dbb2b71a59ed 372
kevin1990 5:dbb2b71a59ed 373 I2C0.Type.Sensor_Type = CORE_SENSOR_TYPE_I2C_PRESSURE1;
kevin1990 5:dbb2b71a59ed 374 I2C0.Type.Sensor_Category = CORE_SENSOR_TYPE_I2C;
kevin1990 5:dbb2b71a59ed 375
kevin1990 5:dbb2b71a59ed 376 I2C0.DigitalAddress.Digital_Sensor_Address = 0x27;
kevin1990 3:3796776e2c27 377 }
kevin1990 2:625a45555a85 378