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.
OPT3101_Calibration.cpp
00001 /*! 00002 * \file OPT3101device_Calibration.cpp 00003 * \author Karthik Rajagopal <krthik@ti.com> 00004 * \version 0.9 00005 * 00006 * \section COPYRIGHT 00007 * TEXAS INSTRUMENTS TEXT FILE LICENSE 00008 * Copyright (c) 2018 Texas Instruments Incorporated 00009 * All rights reserved not granted herein. 00010 * Limited License. 00011 * Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive license under copyrights and patents it now or hereafter owns or controls to make, have made, use, import, offer to sell and sell ("Utilize") this software subject to the terms herein. With respect to the foregoing patent license, such license is granted solely to the extent that any such patent is necessary to Utilize the software alone. The patent license shall not apply to any combinations which include this software, other than combinations with devices manufactured by or for TI (“TI Devices”). No hardware patent is licensed hereunder. 00012 * Redistributions must preserve existing copyright notices and reproduce this license (including the above copyright notice and the disclaimer and (if applicable) source code license limitations below) in the documentation and/or other materials provided with the distribution 00013 * Redistribution and use in binary form, without modification, are permitted provided that the following conditions are met: 00014 * * No reverse engineering, decompilation, or disassembly of this software is permitted with respect to any software provided in binary form. 00015 * * any redistribution and use are licensed by TI for use only with TI Devices. 00016 * * Nothing shall obligate TI to provide you with source code for the software licensed and provided to you in object code. 00017 * If software source code is provided to you, modification and redistribution of the source code are permitted provided that the following conditions are met: 00018 * * any redistribution and use of the source code, including any resulting derivative works, are licensed by TI for use only with TI Devices. 00019 * * any redistribution and use of any object code compiled from the source code and any resulting derivative works, are licensed by TI for use only with TI Devices. 00020 * Neither the name of Texas Instruments Incorporated nor the names of its suppliers may be used to endorse or promote products derived from this software without specific prior written permission. 00021 * DISCLAIMER. 00022 * THIS SOFTWARE IS PROVIDED BY TI AND TI’S LICENSORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL TI AND TI’S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00023 * 00024 * \section DESCRIPTION 00025 * The file contains methods definitions for top level calibration methods for OPT3101::device 00026 */ 00027 00028 #include "OPT3101device.h " 00029 00030 void OPT3101::device::calibrationSession_firstTimeBringUp() { 00031 /// <b>Algorithm of the method is as follows</b> 00032 this->reset(); ///* Resets the device calling OPT3101::device::reset method 00033 host.printf("INFO::Writing Initialization sequence I2C registers\r\n"); 00034 this->initialize(); ///* Initializes the OPT3101 device by calling OPT3101::device::initialize method 00035 this->measureAndCorrectInternalCrosstalk(&this->calibration->internalCrosstalk[0]); ///* Calls method OPT3101::device::measureAndCorrectInternalCrosstalk with argument OPT3101::calibrationC::internalCrosstalk 00036 this->calibration->internalCrosstalk[0].printHeader(); ///* Calls the method OPT3101::crosstalkC::report for debug and data analysis 00037 this->calibration->internalCrosstalk[0].print(); ///* Calls the method OPT3101::crosstalkC::report for debug and data analysis 00038 host.printf("\r\n"); 00039 // The folowing step is to perfrom illum crosstalk measurements 00040 this->measureIllumCrosstalkSet(); 00041 this->loadIllumCrosstalkSet(); 00042 this->measurePhaseOffsetSet(); 00043 this->loadPhaseOffsetSet(); 00044 host.printf("INFO::Completed First Time bring up\r\n"); 00045 00046 00047 } 00048 00049 void OPT3101::device::calibrationSession_perUnitFactoryCalibrationWriteRegisterDataToNonVolatileMemory(bool DEBUG_dry_run) 00050 { 00051 uint16_t c0; 00052 uint8_t regStore[11], c1; 00053 uint32_t data; 00054 uint8_t datar; 00055 00056 /// <b>Algorithm of the method is as follows</b> 00057 if (!this->calibration->EEPROM_connected){///* Method returns without doing any operation when the device configuration flag OPT3101::device::EEPROM_connected is false. User needs to implement their own function if no EEPROM is present 00058 host.printfSetColor(0b110); 00059 host.printf("WARN::NO EEPROM connected to h/w.\r\n"); 00060 host.printfSetColor(0xFF); 00061 host.printf("INFO::Listing all registers to be written to host non-volatile memory\r\n"); 00062 host.printfSetColor(0b001); 00063 host.printf("regAddr,regValues\r\n"); 00064 for(c0=0;c0<this->calibration->registerAddressListSize;c0++){ 00065 data=host.readI2C(this->calibration->registerAddressList[c0]); 00066 host.printf(" 0x%02x,",this->calibration->registerAddressList[c0]); 00067 host.printf(" 0x%06lx\r\n",data); 00068 } 00069 host.printfSetColor(0xFF); 00070 host.printf("INFO::User is expected to program these values to non-volatile memory in host\r\n"); 00071 return; 00072 } 00073 regStore[0] = this->reg.tsens_slave0.read(); 00074 regStore[1] = this->reg.i2c_en.read(); 00075 regStore[2] = this->reg.i2c_num_tran.read(); 00076 regStore[3] = this->reg.i2c_rw.read(); 00077 regStore[4] = this->reg.i2c_num_bytes_tran1.read(); ///* Critical registers which are modified in this method are read from the h/w and temporarily bufferd to local variables. 00078 regStore[5] = this->reg.en_tx_switch.read(); 00079 regStore[6] = this->reg.sel_tx_ch.read(); 00080 regStore[7] = this->reg.frame_vd_trig.read(); 00081 regStore[8] = this->reg.en_processor_values.read(); 00082 regStore[9] = this->reg.en_sequencer.read(); 00083 regStore[10] = this->reg.en_adaptive_hdr.read(); 00084 00085 this->reg.tsens_slave0 = 0x50; 00086 this->reg.i2c_num_tran = 0; 00087 this->reg.i2c_rw = 0; 00088 this->reg.frame_vd_trig = 0; 00089 this->reg.i2c_num_bytes_tran1 = 1; ///* OPT3101 device is configured to write desired data though the SDA_M/SCL_M lines to the connected external EEPROM 00090 this->reg.en_tx_switch = 0; 00091 this->reg.sel_tx_ch = 0; 00092 this->reg.i2c_en = 1; 00093 this->reg.en_processor_values = 0; 00094 this->reg.en_sequencer = 0; 00095 this->reg.en_adaptive_hdr = 0; 00096 // This portions clears all the element in EEPROM to 0xFF 00097 if(!DEBUG_dry_run) { 00098 host.printf("INFO::Clearing EEPROM contents\r\n"); 00099 for (c0 = 0; c0 < 256; c0++) 00100 this->writeDataToEEPROM((uint8_t) c0, 0xFF); ///* Erases the EEPROM with 0xFF data in all lcoations. 00101 } else { 00102 host.printf("INFO::Dry Run, Skipped Clear EEPROM contents\r\n"); 00103 } 00104 00105 for (c0 = 0; c0 < this->calibration->registerAddressListSize; c0++) { 00106 if(!DEBUG_dry_run) 00107 this->writeDataToEEPROM( (uint8_t) ((c0&0xFF)<<2), this->calibration->registerAddressList[c0]); 00108 data = host.readI2C(this->calibration->registerAddressList[c0]); ///* Reads all the registers from the list OPT3101::calibrationC::registerAddressList from h/w and writes the address and data to the connected external EEPROM 00109 host.printf("INFO::Writing reg:0x%02x ",this->calibration->registerAddressList[c0]); 00110 host.printf("data:0x%06lx to EEPROM\r\n",data); 00111 if(!DEBUG_dry_run) { 00112 for (c1 = 0; c1<3; c1++){ 00113 this->writeDataToEEPROM((uint8_t) ((((uint8_t)(c0&0xFF))<<2)+c1+1), (uint8_t) ((data >> ((c1 << 3)) & 0xFF))); 00114 } 00115 } 00116 } 00117 00118 this->reg.tsens_slave0 = regStore[0]; 00119 this->reg.i2c_num_tran = regStore[2]; 00120 this->reg.i2c_rw = regStore[3]; 00121 this->reg.i2c_num_bytes_tran1 = regStore[4]; ///* Restores the device state to the same state as before entering this method from the buffered local variables 00122 this->reg.en_tx_switch = regStore[5]; 00123 this->reg.sel_tx_ch = regStore[6]; 00124 this->reg.frame_vd_trig = regStore[6]; 00125 this->reg.i2c_en = regStore[1]; 00126 this->reg.en_processor_values = regStore[8]; 00127 this->reg.en_sequencer = regStore[9]; 00128 this->reg.en_adaptive_hdr = regStore[10]; 00129 } 00130 00131 void OPT3101::device::readAndPrintEEPROMContents(bool rawFormat) 00132 { 00133 /* This section will be updated in the next revision of the SDK 00134 * uint8_t c1; 00135 uint16_t c0; 00136 uint8_t regStore[8],data[4]; 00137 /// <b>Algorithm of the method is as follows</b> 00138 if (!this->calibration->EEPROM_connected) ///* Method returns without doing any operation when the device configuration flag OPT3101::device::EEPROM_connected is false. User needs to implement their own function if no EEPROM is present 00139 return; 00140 regStore[0] = this->reg.tsens_slave0.read(); 00141 regStore[1] = this->reg.i2c_en.read(); 00142 regStore[2] = this->reg.i2c_num_tran.read(); 00143 regStore[3] = this->reg.i2c_rw.read(); 00144 regStore[4] = this->reg.i2c_num_bytes_tran1.read(); ///* Critical registers which are modified in this method are read from the h/w and temporarily bufferd to local variables. 00145 regStore[5] = this->reg.en_tx_switch.read(); 00146 regStore[6] = this->reg.sel_tx_ch.read(); 00147 regStore[7] = this->reg.frame_vd_trig.read(); 00148 00149 this->reg.tsens_slave0 = 0x50; 00150 this->reg.i2c_num_tran = 0; 00151 this->reg.i2c_rw = 1; 00152 this->reg.i2c_num_bytes_tran1 = 0; ///* OPT3101 device is configured to read desired data though the SDA_M/SCL_M lines to the connected external EEPROM 00153 this->reg.en_tx_switch = 0; 00154 this->reg.frame_vd_trig = 0; 00155 this->reg.sel_tx_ch = 0; 00156 this->reg.i2c_en = 1; 00157 00158 // This portions reads the data from the EERPOM and displays the same 00159 for (c0 = 0; c0 < 256; c0++){ 00160 host.printf("S:0x%02x,",c0); 00161 host.printf("0x%02x\r\n",this->readDataFromEEPROM((uint8_t) c0)); ///* Erases the EEPROM with 0xFF data in all lcoations. 00162 } 00163 00164 for (c0 = 0; c0 < 64; c0++) { 00165 for(c1=0;c1<4;c1++){ 00166 data[c1] = this->readDataFromEEPROM((c0<<2)+c1); ///* Reads the data from EEPROM For all locations. 00167 if(rawFormat) 00168 host.printf("INFO::Loc:0x%02x Data:0x%02x\r\n",(c0<<2)+c1,data[c1]); 00169 } 00170 if(!rawFormat){ 00171 host.printf("INFO:: regAddr:0x%02x regData:0x",data[0]); 00172 for(c1=1;c1<4;c1++) 00173 host.printf("%02x",data[c1]); 00174 host.printf("\r\n"); 00175 } 00176 } 00177 00178 this->reg.tsens_slave0 = regStore[0]; 00179 this->reg.i2c_en = regStore[1]; 00180 this->reg.i2c_num_tran = regStore[2]; 00181 this->reg.i2c_rw = regStore[3]; 00182 this->reg.i2c_num_bytes_tran1 = regStore[4]; ///* Restores the device state to the same state as before entering this method from the buffered local variables 00183 this->reg.en_tx_switch = regStore[5]; 00184 this->reg.sel_tx_ch = regStore[6]; 00185 this->reg.frame_vd_trig = regStore[6]; 00186 */ 00187 00188 } 00189 00190 void OPT3101::device::calibrationSession_perDesignTx2IllumXtalkCorrection() { 00191 /// <b>Algorithm of the method is as follows</b> 00192 this->reset(); ///* Resets the device calling OPT3101::device::reset method 00193 this->initialize(); ///* Initializes the OPT3101 device by calling OPT3101::device::initialize method 00194 this->measureAndCorrectInternalCrosstalk(&this->calibration->internalCrosstalk[0]); ///* Calls method OPT3101::device::measureAndCorrectInternalCrosstalk with argument OPT3101::calibrationC::internalCrosstalk 00195 ///* Ensure all calibrations are zeroed. 00196 this->reg.use_xtalk_reg_illum = 0; 00197 this->reg.en_temp_xtalk_corr = 0; 00198 this->reg.en_temp_corr = 0; 00199 this->reg.en_phase_corr = 0; 00200 this->reg.amb_phase_corr_pwl_coeff0 = 0; 00201 this->reg.amb_phase_corr_pwl_coeff1 = 0; 00202 this->reg.amb_phase_corr_pwl_coeff2 = 0; 00203 this->reg.amb_phase_corr_pwl_coeff3 = 0; 00204 OPT3101::crosstalkC illumXtalk; ///* Declares temporary variable of OPT3101::crosstalkC class to hold internal crosstalk data across temperature, TX channel and register settings 00205 ///* print header for data table 00206 host.printf(" I,rS,rI,rD"); 00207 illumXtalk.printHeader(); 00208 ///* print baseline original xtalk 00209 host.printf("-%02d,%02d,%02d,%02d,",0,-1,-1,-1); 00210 this->measureIllumCrosstalk(&illumXtalk, 2, 1 ? 'h' : 'l'); ///* Calls method OPT3101::device::measureIllumCrosstalk with temporary variable of OPT3101::crosstalkC class 00211 illumXtalk.print(); ///* Calls OPT3101::crosstalkC::report method to report the crosstalk on screen 00212 ///* enable current on tx2 00213 this->reg.EN_CTALK_FB_CLK=1; 00214 this->reg.EN_CALIB_CLK=1; 00215 this->reg.calib_curr1_en_I=1; 00216 ///* loop through all currents and print rest of the data as shown below 00217 for(uint8_t scale = 0; scale < 4; scale++) { 00218 for(uint8_t current = 0; current < 16; current++) { 00219 for(uint8_t direction = 0; direction < 2; direction++) { 00220 ///* set current on tx2 00221 this->reg.calib_curr1_gain_sel=scale; //2 bits 00222 this->reg.calib_curr1_DAC_I=current; //4 bits 00223 this->reg.calib_curr1_inv_CLK_I=direction; //1 bit 00224 ///* print current 00225 if(direction==0) 00226 host.printf("-%02d,%02d,%02d,%02d,",current*(scale+1),scale,current,direction); 00227 else 00228 host.printf("+%02d,%02d,%02d,%02d,",current*(scale+1),scale,current,direction); 00229 // tx2,hdr1 00230 this->measureIllumCrosstalk(&illumXtalk, 2, 1 ? 'h' : 'l'); ///* Calls method OPT3101::device::measureIllumCrosstalk with temporary variable of OPT3101::crosstalkC class 00231 illumXtalk.print(); ///* Calls OPT3101::crosstalkC::report method to report the crosstalk on screen 00232 } 00233 } 00234 } 00235 } 00236 00237 void OPT3101::device::calibrationSession_perDesignCalibrationCrosstalkTemp() { 00238 uint8_t c0, c1; 00239 uint16_t count; 00240 /// <b>Algorithm of the method is as follows</b> 00241 OPT3101::crosstalkC illumXtalk; ///* Declares temporary variable of OPT3101::crosstalkC class to hold internal crosstalk data across temperature, TX channel and register settings 00242 this->reset(); ///* Resets the device calling OPT3101::device::reset method 00243 this->initialize(); ///* Initializes the OPT3101 device by calling OPT3101::device::initialize method 00244 this->measureAndCorrectInternalCrosstalk(&this->calibration->internalCrosstalk[0]); ///* Calls method OPT3101::device::measureAndCorrectInternalCrosstalk with argument OPT3101::calibrationC::internalCrosstalk 00245 envController.setTargetToInfinity_OR_coverPhotodiode(); ///* Calls the method environmentalController::setTargetToInfinity_OR_coverPhotodiode , which is expected to set the environment so as to be able to measure illumination crosstalk 00246 envController.setChamberTemperature(70); ///* Calls the method environmentalController::setChamberTemperature , which is expected to set the chamber to desired temperature 00247 00248 host.printf("Count,TX ,HDR,"); 00249 illumXtalk.printHeader(); 00250 for (count = 0; count<TEMP_CYCLE_TOTAL_NUMBER_OF_DATA_POINTS_PER_SETTING; count++) { ///* Loops through total number of points to be data printed 00251 // Loop to iterate over all TX channels 00252 for (c0 = 0; c0 < 3; c0++) { ///* Loops though all the valid TX channel and register set configurations 00253 if (this->configurationFlags_isTXChannelActive[c0]) { // Checking is TX channel is active for this profile 00254 for (c1 = 0; c1 < 2; c1++) { // Loop to iterate over the H/L registers 00255 if (this->configurationFlags_isRegisterSetActive[c1]) { // Checking if registers are active for this profile 00256 this->measureIllumCrosstalk(&illumXtalk, c0, c1 ? 'h' : 'l'); ///* Calls method OPT3101::device::measureIllumCrosstalk with temporary variable of OPT3101::crosstalkC class 00257 host.printf("%05d, %d, %d,",count,c0,c1); 00258 illumXtalk.print(); ///* Calls OPT3101::crosstalkC::report method to report the crosstalk on screen 00259 } 00260 } 00261 } 00262 } 00263 host.sleep(TEMP_CYCLE_DELAY_IN_SECONDS_BETWEEN_DATA_POINTS<<10); 00264 } 00265 } 00266 00267 void OPT3101::device::calibrationSession_perDesignCalibrationPhaseTemp() { 00268 /// <b>Algorithm of the method is as follows</b> 00269 uint8_t c0, c1; 00270 OPT3101::frameData data; 00271 uint16_t count; 00272 uint16_t refDistanceInCodes; 00273 OPT3101::phaseOffsetC phaseOffset; ///* Declares temporary variable of OPT3101::phaseOffsetC class to hold phase offset data across temperature, TX channel and register settings 00274 uint32_t refDistanceInMM; 00275 this->reset(); ///* Resets the device calling OPT3101::device::reset method 00276 this->initialize(); ///* Initializes the OPT3101 device by calling OPT3101::device::initialize method 00277 this->measureAndCorrectInternalCrosstalk(&this->calibration->internalCrosstalk[0]); ///* Calls method OPT3101::device::measureAndCorrectInternalCrosstalk with argument OPT3101::calibrationC::internalCrosstalk 00278 this->loadIllumCrosstalkSet(true); 00279 00280 this->manuallySetIllumCrosstalkTempCoffs(); 00281 this->loadIllumCrosstalkTempCoffSet(); 00282 00283 envController.manuallySetReferenceDistances(); 00284 00285 00286 // Loop to iterate over all TX channels 00287 for (c0 = 0; c0 < 3; c0++) { ///* Loops though all the valid TX channel and register set configurations 00288 if (this->configurationFlags_isTXChannelActive[c0]) { // Checking is TX channel is active for this profile 00289 for (c1 = 0; c1 < 2; c1++) { // Loop to iterate over the H/L registers 00290 if (this->configurationFlags_isRegisterSetActive[c1]) { // Checking if registers are active for this profile 00291 refDistanceInMM = envController.refDistancesInMM[c0][c1]; ///* <b>Warning</b> User is expected to select and set reference distance so that the amplitude of the system for this particular TX and register set configurations measures between 16K and 24K. Default is set to 0 in the SDK 00292 envController.setTargetDistance(refDistanceInMM); ///* Calls environmentalController::setTargetDistance method with the specified distance 00293 envController.setChamberTemperature(70); ///* Calls the method environmentalController::setChamberTemperature , which is expected to set the chamber to desired temperature 00294 refDistanceInCodes = (refDistanceInMM * 4477) >> 10; ///* Converts the reference distance specified in codes related to OPT3101::frameData::phase ADC codes 00295 host.printf("DataCt,TX,HDR,"); 00296 phaseOffset.data.printHeader(); 00297 for (count = 0; count < TEMP_CYCLE_TOTAL_NUMBER_OF_DATA_POINTS_PER_SETTING; count++) { ///* Loops through chamber temperature settings to get temp coff 00298 host.printf("%06d, %d, %d,",count,c0,c1); 00299 this->measurePhaseOffset(&phaseOffset, c0, c1 ? 'h' : 'l', refDistanceInCodes, 0); 00300 phaseOffset.data.print(); 00301 host.sleep(TEMP_CYCLE_DELAY_IN_SECONDS_BETWEEN_DATA_POINTS<<10); 00302 } 00303 } 00304 } 00305 } 00306 } 00307 } 00308 00309 void OPT3101::device::calibrationSession_perDesignCalibrationPhaseAmbient() { 00310 /// <b>Algorithm of the method is as follows</b> 00311 uint8_t c0, c1; 00312 OPT3101::frameData data; 00313 uint16_t count; 00314 uint16_t refDistanceInCodes; 00315 OPT3101::phaseOffsetC phaseOffset; ///* Declares temporary variable of OPT3101::phaseOffsetC class to hold phase offset data across temperature, TX channel and register settings 00316 uint32_t refDistanceInMM; 00317 bool breakFlag; 00318 00319 /// <b>Algorithm of the method is as follows</b> 00320 00321 this->reset(); ///* Resets the device calling OPT3101::device::reset method 00322 this->initialize(); ///* Initializes the OPT3101 device by calling OPT3101::device::initialize method 00323 this->measureAndCorrectInternalCrosstalk(&this->calibration->internalCrosstalk[0]); ///* Calls method OPT3101::device::measureAndCorrectInternalCrosstalk with argument OPT3101::calibrationC::internalCrosstalk 00324 this->manuallySetIllumCrosstalkTempCoffs(); 00325 this->manuallySetPhaseTempCoffs(); 00326 00327 this->loadIllumCrosstalkSet(true); 00328 this->loadIllumCrosstalkTempCoffSet(); 00329 00330 this->loadPhaseOffsetSet(true); 00331 this->loadPhaseOffsetTempCoffSet(); 00332 envController.manuallySetReferenceDistances(); 00333 00334 breakFlag = false; 00335 // Loop to iterate over all TX channels 00336 for (c0 = 0; c0 < 3; c0++) { ///* Loops though all the valid TX channel and register set configurations 00337 if (this->configurationFlags_isTXChannelActive[c0]) { // Checking is TX channel is active for this profile 00338 for (c1 = 0; c1 < 2; c1++) { // Loop to iterate over the H/L registers 00339 c1 = 0; 00340 c0 = 1; 00341 if (this->configurationFlags_isRegisterSetActive[c1]) { // Checking if registers are active for this profile 00342 refDistanceInMM = envController.refDistancesInMM[c0][c1]; ///* <b>Warning</b> User is expected to select and set reference distance so that the amplitude of the system for this particular TX and register set configurations measures between 16K and 24K. Default is set to 0 in the SDK 00343 envController.setTargetDistance(refDistanceInMM); ///* Calls environmentalController::setTargetDistance method with the specified distance 00344 envController.setAmbientLight(0); ///* Calls the method environmentalController::setChamberTemperature , which is expected to set the chamber to desired temperature 00345 refDistanceInCodes = (refDistanceInMM * 4477) >> 10; ///* Converts the reference distance specified in codes related to OPT3101::frameData::phase ADC codes 00346 host.printf("DataCt,TX,HDR,"); 00347 phaseOffset.data.printHeader(); 00348 for (count = 0; count < TEMP_CYCLE_TOTAL_NUMBER_OF_DATA_POINTS_PER_SETTING; count++) { ///* Loops through chamber temperature settings to get temp coff 00349 host.printf("%06d, %d, %d,",count,c0,c1); 00350 this->measurePhaseOffset(&phaseOffset, c0, c1 ? 'h' : 'l', refDistanceInCodes, 0); 00351 phaseOffset.data.print(); 00352 host.sleep(TEMP_CYCLE_DELAY_IN_SECONDS_BETWEEN_DATA_POINTS<<10); 00353 } 00354 breakFlag = true; ///* Since Phase ambient coff is required to be done only for one TX configuration the the method breaks from the loop after 1 ambient sweep 00355 break; // This is required only for one TX and 1 of the registers since this is property of photo diode. 00356 // Measure and populate Ambient Coefficients 00357 } 00358 if (breakFlag) 00359 break; 00360 } 00361 if (breakFlag) 00362 break; 00363 } 00364 if (breakFlag) 00365 break; 00366 } 00367 } 00368 00369 void OPT3101::device::calibrationSession_perUnitFactoryCalibration() 00370 { 00371 00372 this->reset(); ///* Resets the device calling OPT3101::device::reset method 00373 00374 host.printf("INFO::Writing Initialization sequence I2C registers\r\n"); 00375 this->initialize(); ///* Initializes the OPT3101 device by calling OPT3101::device::initialize method 00376 host.printf("INFO::Device Initialization Completed\r\n"); 00377 this->measureAndCorrectInternalCrosstalk(&this->calibration->internalCrosstalk[0]); ///* Calls method OPT3101::device::measureAndCorrectInternalCrosstalk with argument OPT3101::calibrationC::internalCrosstalk 00378 this->calibration->internalCrosstalk[0].report(); ///* Calls the method OPT3101::crosstalkC::report for debug and data analysis 00379 00380 this->manuallySetIllumCrosstalkTempCoffs(); 00381 this->manuallySetPhaseTempCoffs(); 00382 this->manuallySetPhaseAmbientCoffs(); 00383 00384 this->measureIllumCrosstalkSet(false); 00385 this->loadIllumCrosstalkSet(false); ///* Calls the OPT3101::device::loadIllumCrosstalkSet with false argument so that method to load all illum crosstalk settings from the OPT3101::device::crosstalk::illumCrosstalk member 00386 this->loadIllumCrosstalkTempCoffSet(); 00387 00388 this->measurePhaseOffsetSet(false); 00389 this->loadPhaseOffsetSet(false); ///* Calls the OPT3101::device::loadPhaseOffsetSet method with false argument so as to load all the phase offset registers from the OPT3101::device::calibration::phaseOffset instance instead of files 00390 this->loadPhaseOffsetTempCoffSet(); 00391 00392 this->loadPhaseAmbientCoffSet(); ///* Calls the OPT3101::device::loadPhaseAmbientCoffSet method to load all the phase offset temp coff 00393 00394 this->calibrationSession_perUnitFactoryCalibrationWriteRegisterDataToNonVolatileMemory(); ///* Calls the OPT3101::device::calibrationSession_perUnitFactoryCalibrationWriteRegisterDataToNonVolatileMemory to store the calibration data to a non-volatile memory 00395 } 00396 00397 void OPT3101::device::perUnitFactoryUpdateIllumXtalk () 00398 { 00399 00400 this->reset(); ///* Resets the device calling OPT3101::device::reset method 00401 00402 host.printf("INFO::Writing Initialization sequence I2C registers\r\n"); 00403 this->initialize(); ///* Initializes the OPT3101 device by calling OPT3101::device::initialize method 00404 host.printf("INFO::Device Initialization Completed\r\n"); 00405 this->measureAndCorrectInternalCrosstalk(&this->calibration->internalCrosstalk[0]); ///* Calls method OPT3101::device::measureAndCorrectInternalCrosstalk with argument OPT3101::calibrationC::internalCrosstalk 00406 this->calibration->internalCrosstalk[0].report(); ///* Calls the method OPT3101::crosstalkC::report for debug and data analysis 00407 00408 this->measureIllumCrosstalkSet(false); 00409 this->loadIllumCrosstalkSet(false); ///* Calls the OPT3101::device::loadIllumCrosstalkSet with false argument so that method to load all illum crosstalk settings from the OPT3101::device::crosstalk::illumCrosstalk member 00410 00411 this->calibrationSession_perUnitFactoryCalibrationWriteRegisterDataToNonVolatileMemory(); ///* Calls the OPT3101::device::calibrationSession_perUnitFactoryCalibrationWriteRegisterDataToNonVolatileMemory to store the calibration data to a non-volatile memory 00412 } 00413
Generated on Sun Jul 17 2022 05:22:03 by
