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.
MAX31856.h
00001 /******************************************************************//** 00002 * @file MAX31856.h 00003 * 00004 * @author Devin Alexander 00005 * 00006 * @version 1.0 00007 * 00008 * Started: SEPTEMBER 14th 2017 00009 * 00010 * Updated: 00011 * 00012 * @brief Header file for MAX31856 class 00013 * 00014 *********************************************************************** 00015 * 00016 * @copyright 00017 * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved. 00018 * 00019 * Permission is hereby granted, free of charge, to any person obtaining a 00020 * copy of this software and associated documentation files (the "Software"), 00021 * to deal in the Software without restriction, including without limitation 00022 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00023 * and/or sell copies of the Software, and to permit persons to whom the 00024 * Software is furnished to do so, subject to the following conditions: 00025 * 00026 * The above copyright notice and this permission notice shall be included 00027 * in all copies or substantial portions of the Software. 00028 * 00029 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00030 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00031 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00032 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES 00033 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00034 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00035 * OTHER DEALINGS IN THE SOFTWARE. 00036 * 00037 * Except as contained in this notice, the name of Maxim Integrated 00038 * Products, Inc. shall not be used except as stated in the Maxim Integrated 00039 * Products, Inc. Branding Policy. 00040 * 00041 * The mere transfer of this software does not imply any licenses 00042 * of trade secrets, proprietary technology, copyrights, patents, 00043 * trademarks, maskwork rights, or any other form of intellectual 00044 * property whatsoever. Maxim Integrated Products, Inc. retains all 00045 * ownership rights. 00046 **********************************************************************/ 00047 00048 00049 #ifndef MAX31856_h 00050 #define MAX31856_h 00051 #include "mbed.h" 00052 00053 //***************************************************************************** 00054 //Define all the addresses of the registers in the MAX31856 00055 //***************************************************************************** 00056 #define ADDRESS_CR0_READ 0x00 //Factory Default 00h 00057 #define ADDRESS_CR0_WRITE 0x80 00058 #define ADDRESS_CR1_READ 0x01 //Factory Default 03h 00059 #define ADDRESS_CR1_WRITE 0x81 00060 #define ADDRESS_MASK_READ 0x02 //Factory Default FFh 00061 #define ADDRESS_MASK_WRITE 0x82 00062 #define ADDRESS_CJHF_READ 0x03 //Factory Default 7Fh 00063 #define ADDRESS_CJHF_WRITE 0x83 00064 #define ADDRESS_CJLF_READ 0x04 //Factory Default C0h 00065 #define ADDRESS_CJLF_WRITE 0x84 00066 #define ADDRESS_LTHFTH_READ 0x05 //Factory Default 7Fh 00067 #define ADDRESS_LTHFTH_WRITE 0x85 00068 #define ADDRESS_LTHFTL_READ 0x06 //Factory Default FFh 00069 #define ADDRESS_LTHFTL_WRITE 0x86 00070 #define ADDRESS_LTLFTH_READ 0x07 //Factory Default 80h 00071 #define ADDRESS_LTLFTH_WRITE 0x87 00072 #define ADDRESS_LTLFTL_READ 0x08 //Factory Default 00h 00073 #define ADDRESS_LTLFTL_WRITE 0x88 00074 #define ADDRESS_CJTO_READ 0x09 //Factory Default 00h 00075 #define ADDRESS_CJTO_WRITE 0x89 00076 #define ADDRESS_CJTH_READ 0x0A //Factory Default 00h 00077 #define ADDRESS_CJTH_WRITE 0x8A 00078 #define ADDRESS_CJTL_READ 0x0B //Factory Default 00h 00079 #define ADDRESS_CJTL_WRITE 0x8B 00080 #define ADDRESS_LTCBH_READ 0x0C 00081 #define ADDRESS_LTCBM_READ 0x0D 00082 #define ADDRESS_LTCBL_READ 0x0E 00083 #define ADDRESS_SR_READ 0x0F 00084 00085 //***************************************************************************** 00086 //Define parameters for control register zero (CR0) 00087 //***************************************************************************** 00088 #define CR0_CONV_MODE_NORMALLY_OFF 0x00 //Power On Default value 00089 #define CR0_CONV_MODE_NORMALLY_ON 0x80 00090 00091 #define CR0_1_SHOT_MODE_NO_CONVERSION 0x00 //defaults to this value 00092 #define CR0_1_SHOT_MODE_ONE_CONVERSION 0x40 //^ 00093 00094 #define CR0_OC_DETECT_DISABLED 0x00 00095 #define CR0_OC_DETECT_ENABLED_R_LESS_5k 0x10 00096 #define CR0_OC_DETECT_ENABLED_TC_LESS_2ms 0x20 00097 #define CR0_OC_DETECT_ENABLED_TC_MORE_2ms 0x30 00098 00099 #define CR0_COLD_JUNC_ENABLE 0x00 //Power On Default value 00100 #define CR0_COLD_JUNC_DISABLE 0x08 //speed of conversion is sped up by 25ms when this optionis selected (Disable the cold junc) 00101 00102 #define CR0_FAULT_MODE_COMPARATOR 0x00 //Power On Default value 00103 #define CR0_FAULT_MODE_INTERUPT 0x04 00104 00105 #define CR0_FAULTCLR_DEFAULT_VAL 0x00 //defaults to this value 00106 #define CR0_FAULTCLR_RETURN_FAULTS_TO_ZERO 0x02 //^ 00107 00108 #define CR0_FILTER_OUT_60Hz 0x00 //Preset value 00109 #define CR0_FILTER_OUT_50Hz 0x01 //^ 00110 00111 00112 //***************************************************************************** 00113 //Define parameters for control register one (CR1) 00114 //***************************************************************************** 00115 #define CR1_AVG_TC_SAMPLES_1 0x00 //Power on default value 00116 #define CR1_AVG_TC_SAMPLES_2 0x10 00117 #define CR1_AVG_TC_SAMPLES_4 0x20 00118 #define CR1_AVG_TC_SAMPLES_8 0x30 00119 #define CR1_AVG_TC_SAMPLES_16 0x40 00120 00121 // Define which type of thermocouple the MAX31856 is using. This is for lineariztion purposes 00122 #define CR1_TC_TYPE_B 0x00 00123 #define CR1_TC_TYPE_E 0x01 00124 #define CR1_TC_TYPE_J 0x02 00125 #define CR1_TC_TYPE_K 0x03 //Power on default value 00126 #define CR1_TC_TYPE_N 0x04 00127 #define CR1_TC_TYPE_R 0x05 00128 #define CR1_TC_TYPE_S 0x06 00129 #define CR1_TC_TYPE_T 0x07 00130 #define CR1_TC_TYPE_VOLT_MODE_GAIN_8 0x08 00131 #define CR1_TC_TYPE_VOLT_MODE_GAIN_32 0x0C 00132 00133 //***************************************************************************** 00134 //Define parameters for the mask register (MASK) 00135 //***************************************************************************** 00136 #define MASK_CJ_FAULT_THRESHOLD_HIGH 0x20 00137 #define MASK_CJ_FAULT_THRESHOLD_LOW 0x10 00138 #define MASK_TC_FAULT_THRESHOLD_HIGH 0x08 00139 #define MASK_TC_FAULT_THRESHOLD_LOW 0x04 00140 #define MASK_OVER_UNDER_VOLT_FAULT 0x02 00141 #define MASK_OPEN_CIRCUIT_FAULT 0x01 00142 00143 //***************************************************************************** 00144 //If these defined values are &= (bitwise ANDed) with the contents of a register, it will reset the bits pertaing to the specific bitfields to zero 00145 //***************************************************************************** 00146 #define CR0_CLEAR_BITS_7 ~(0x80) 00147 #define CR0_CLEAR_BITS_6 ~(0x40) 00148 #define CR0_CLEAR_BITS_5_4 ~(0x30) 00149 #define CR0_CLEAR_BITS_3 ~(0x08) 00150 #define CR0_CLEAR_BITS_2 ~(0x04) 00151 #define CR0_CLEAR_BITS_1 ~(0x02) 00152 #define CR0_CLEAR_BITS_0 ~(0x01) 00153 00154 #define CR1_CLEAR_BITS_6_4 ~(0x70) 00155 #define CR1_CLEAR_BITS_3_0 ~(0x0F) 00156 00157 #define MASK_CLEAR_BITS_5 ~(0x20) 00158 #define MASK_CLEAR_BITS_4 ~(0x10) 00159 #define MASK_CLEAR_BITS_3 ~(0x08) 00160 #define MASK_CLEAR_BITS_2 ~(0x04) 00161 #define MASK_CLEAR_BITS_1 ~(0x02) 00162 #define MASK_CLEAR_BITS_0 ~(0x01) 00163 00164 //***************************************************************************** 00165 ///Parameters that are used throughout the library 00166 //***************************************************************************** 00167 #define TC_MAX_VAL_FAULT 1800 00168 #define TC_MIN_VAL_FAULT -210 00169 #define CJ_MAX_VAL_FAULT 125 00170 #define CJ_MIN_VAL_FAULT -55 00171 00172 00173 00174 /** 00175 * @brief Library for the MAX31856\n 00176 * The MAX31856 thermocouple temperature sensor accurately measures temperature 00177 * and provides a vast amount of features such as: 00178 * //FEATURE 00179 * //FEATURE 00180 * //FEATURE 00181 * //FEATURE 00182 * //FEATURE 00183 * //FEATURE 00184 * Communication is through an SPI-compatible interface. 00185 * 00186 * @code 00187 * #include "mbed.h" 00188 * #include "MAX31856.h" 00189 * 00190 * 00191 * // Hardware serial port 00192 * Serial serial(USBTX, USBRX); 00193 * 00194 * //SPI communications 00195 * SPI spi(SPIO MOSI,SPIO MISO,SPIO SCK); 00196 * 00197 * //Thermocouples 00198 * MAX31856 Thermocouple1(spi, CHIPSELECT); 00199 * 00200 * 00201 * int main(void) 00202 * { 00203 * float temperature_TC_1, temperature_CJ_1; 00204 * while(true) 00205 * { 00206 * temperature_TC_1=Thermocouple1.readTC(); 00207 * temperature_CJ_1=Thermocouple1.readCJ(); 00208 * serial.printf("MAX31856 TC = %f Celsius MAX31856 CJ = %f Celsius \n\r",temperature_TC_1,temperature_CJ_1); 00209 * wait(1.0); 00210 * } 00211 * } 00212 * @endcode 00213 */ 00214 00215 00216 00217 /** Please see pages 18-26 in the MAX31856 data sheet to see what register bit masks are needed to be set 00218 to achieve functionality desired. The data sheet can be found at 00219 00220 *** https://datasheets.maximintegrated.com/en/ds/MAX31856.pdf *** 00221 */ 00222 00223 00224 /** 00225 * MAX31856 Class 00226 */ 00227 class MAX31856 00228 { 00229 00230 public: 00231 //***************************************************************************** 00232 //Constructor and Destructor for the class 00233 //***************************************************************************** 00234 /** 00235 * @brief Constructor to create MAX31856 object with SPI information as well as preconfiguration parameter settings in configuration registers Zero and One 00236 * @param _spi - Reference to SPI object 00237 * @param _ncs - Chip Select for SPI comunications with the oject 00238 * @param _type - Type of thermocouple used 00239 * @param _fltr - Feature of the MAX31856 to filter out either 50Hz/60Hz from signal 00240 * @param _samples - How many samples are averaged for one conversion 00241 * @param _conversion_mode - Choose between always on and making conversions and off in between requests for a reading 00242 */ 00243 MAX31856(SPI& _spi, PinName _ncs, uint8_t _type=CR1_TC_TYPE_K, uint8_t _fltr=CR0_FILTER_OUT_60Hz, uint8_t _samples=CR1_AVG_TC_SAMPLES_1, uint8_t _conversion_mode=CR0_CONV_MODE_NORMALLY_OFF); 00244 00245 00246 /** @brief Destructor */ 00247 ~MAX31856(void); 00248 00249 00250 //***************************************************************************** 00251 //Temperature Functions 00252 //***************************************************************************** 00253 /** 00254 * @brief Requests read of the thermocouple temperature 00255 * @return float of the converted thermocouple reading based on current configurations 00256 */ 00257 float readTC(); 00258 00259 00260 /** 00261 * @brief Requests read of the cold junction temperature 00262 * @return float of the converted artificial cold junction reading based on current configurations 00263 */ 00264 float readCJ(); 00265 00266 00267 //***************************************************************************** 00268 //Functions for register CR0 00269 //***************************************************************************** 00270 /** 00271 * @brief Sets bits in the configuration register zero for setting the rate of conversions 00272 * @param val \li CR0_CONV_MODE_NORMALLY_OFF (Power On Default value) 00273 * \li CR0_CONV_MODE_NORMALLY_ON 00274 * @return \li 1 on success 00275 * \li 0 if there is an incorrect parameter that is passed in as parameter val 00276 */ 00277 bool setConversionMode(uint8_t val); 00278 00279 00280 /** 00281 * @brief Sets bits in the configuration register zero for enabling one conversion to take place 00282 * @param val \li CR0_1_SHOT_MODE_NO_CONVERSION (Power On Default value) 00283 * \li CR0_1_SHOT_MODE_ONE_CONVERSION (This bit self clears itself to default back to CR0_1_SHOT_MODE_NO_CONVERSION after singular conversion takes place) 00284 * @return \li 1 on success 00285 * \li 0 if there is an incorrect parameter that is passed in as parameter val 00286 */ 00287 bool setOneShotMode(uint8_t val); 00288 00289 00290 /** 00291 * @brief Sets bits in the configuration register zero for configuring open circuit fault detection 00292 * @param val \li CR0_OC_DETECT_DISABLED (Power On Default value) 00293 * \li CR0_OC_DETECT_ENABLED_R_LESS_5k 00294 * \li CR0_OC_DETECT_ENABLED_TC_LESS_2ms 00295 * \li CR0_OC_DETECT_ENABLED_TC_MORE_2ms 00296 * @return \li 1 on success 00297 * \li 0 if there is an incorrect parameter that is passed in as parameter val 00298 */ 00299 bool setOpenCircuitFaultDetection(uint8_t val); 00300 00301 00302 /** 00303 * @brief Sets bits in the configuration register zero for disabling or enabling the Cold Junction 00304 * @param val \li CR0_COLD_JUNC_ENABLE (Power On Default value) 00305 * \li CR0_COLD_JUNC_DISABLE 00306 * @return \li 1 on success 00307 * \li 0 if there is an incorrect parameter that is passed in as parameter val 00308 */ 00309 bool setColdJunctionDisable(uint8_t val); 00310 00311 00312 /** 00313 * @brief Sets bits in the configuration register zero for setting fault mode status 00314 * @param val \li CR0_FAULT_MODE_COMPARATOR (Power On Default value) 00315 * \li CR0_FAULT_MODE_INTERUPT 00316 * @return \li 1 on success 00317 * \li 0 if there is an incorrect parameter that is passed in as parameter val 00318 */ 00319 bool setFaultMode(uint8_t val); 00320 00321 00322 /** 00323 * @brief Sets bits in the configuration register zero for clearing fault status 00324 * @param val \li CR0_FAULTCLR_DEFAULT_VAL (Power On Default value) 00325 * \li CR0_FAULTCLR_RETURN_FAULTS_TO_ZERO (This bit self clears itself to default back to CR0_FAULTCLR_DEFAULT_VAL after fault status is cleared) 00326 * @return \li 1 on success 00327 * \li 0 if there is an incorrect parameter that is passed in as parameter val 00328 */ 00329 bool setFaultStatusClear(uint8_t val); 00330 00331 00332 /** 00333 * @brief Sets bits in the configuration register zero for setting which of the two filter modes either 50Hz or 60Hz cancelation 00334 * @param val \li CR0_FILTER_OUT_60Hz (Power On Default value) 00335 * \li CR0_FILTER_OUT_50Hz 00336 * @return \li 1 on success 00337 * \li 0 if there is an incorrect parameter that is passed in as parameter val 00338 */ 00339 bool setEmiFilterFreq(uint8_t val); 00340 00341 00342 //***************************************************************************** 00343 //Functions for register CR1 00344 //***************************************************************************** 00345 /** 00346 * @brief Sets bits in the configuration register one for setting how many readings are taken 00347 * @param val \li CR1_AVG_TC_SAMPLES_1 (Power On Default value) 00348 * \li CR1_AVG_TC_SAMPLES_2 00349 * \li CR1_AVG_TC_SAMPLES_4 00350 * \li CR1_AVG_TC_SAMPLES_8 00351 * \li CR1_AVG_TC_SAMPLES_16 00352 * @return \li 1 on success 00353 * \li 0 if there is an incorrect parameter that is passed in as parameter val 00354 */ 00355 bool setNumSamplesAvg(uint8_t val); 00356 00357 00358 /** 00359 * @brief Sets bits in the configuration register one for setting which thermocouple type is going to be programmed into the MAX31856 for linearization of thermovoltage produced and temperature 00360 * @param val \li CR1_TC_TYPE_B 00361 * \li CR1_TC_TYPE_E 00362 * \li CR1_TC_TYPE_J 00363 * \li CR1_TC_TYPE_K (Power On Default value) 00364 * \li CR1_TC_TYPE_N 00365 * \li CR1_TC_TYPE_R 00366 * \li CR1_TC_TYPE_S 00367 * \li CR1_TC_TYPE_T 00368 * \li CR1_TC_TYPE_VOLT_MODE_GAIN_8 00369 * \li CR1_TC_TYPE_VOLT_MODE_GAIN_32 00370 * @return \li 1 on success 00371 * \li 0 if there is an incorrect parameter that is passed in as parameter val 00372 */ 00373 bool setThermocoupleType(uint8_t val); 00374 00375 00376 //***************************************************************************** 00377 //Functions for register MASK 00378 //***************************************************************************** 00379 /** 00380 * @brief Sets bits in the configuration register one for setting fault masks 00381 * @param val \li MASK_CJ_FAULT_THRESHOLD_HIGH 00382 * \li MASK_CJ_FAULT_THRESHOLD_LOW 00383 * \li MASK_TC_FAULT_THRESHOLD_HIGH 00384 * \li MASK_TC_FAULT_THRESHOLD_LOW 00385 * \li MASK_OVER_UNDER_VOLT_FAULT 00386 * \li MASK_OPEN_CIRCUIT_FAULT 00387 * @param enable \li 0 for disabling the mask in whichever option is selcted in parameter val 00388 * \li 1 for enabling the mask in whichever option is selcted in parameter val 00389 * @return \li 1 on success 00390 * \li 0 if there is an incorrect parameter that is passed in as parameter val 00391 */ 00392 bool setFaultMasks(uint8_t val, bool enable); 00393 00394 00395 /** 00396 * @brief Sets bits in the configuration register one for setting thresholds that corespond to the fault mask settings 00397 * @param val \li MASK_CJ_FAULT_THRESHOLD_HIGH 00398 * \li MASK_CJ_FAULT_THRESHOLD_LOW 00399 * \li MASK_TC_FAULT_THRESHOLD_HIGH 00400 * \li MASK_TC_FAULT_THRESHOLD_LOW 00401 * @param temperature value that you want to program into a threshold register for temperatre 00402 * @return return value that was programmed into the threshold register 00403 */ 00404 bool setFaultThresholds(uint8_t val, float temperature); 00405 00406 00407 //***************************************************************************** 00408 //Check Fault Status Functions 00409 //***************************************************************************** 00410 /** 00411 * @brief Check the fault stautus register to see if there is anything wrong with range of thermocouple temperature 00412 * whether outside opperating temperatures or if above/below thresholds that are set 00413 * @return \li 0 if no faults are present 00414 * \li 1 if Thermocouple temp is higher than the threshold 00415 * \li 2 if Thermocouple temp is lower than the threshold 00416 * \li 3 if Thermocouple temp is outside operating range of termocouple type 00417 * \li 4 if Thermocouple temp is higher than the threshold && is outside operating range of termocouple type 00418 * \li 5 if Thermocouple temp is lower than the threshold && is outside operating range of termocouple type 00419 */ 00420 uint8_t checkFaultsThermocoupleThresholds(); 00421 00422 00423 /** 00424 * @brief Check the fault stautus register to see if there is anything wrong with range of cold junction temperature 00425 * whether outside opperating temperatures or if above/below thresholds that are set 00426 * @return \li 0 if no faults are present 00427 * \li 1 if Cold Junction temp is higher than the threshold 00428 * \li 2 if Cold Junction temp is lower than the threshold 00429 * \li 3 if Cold Junction temp is outside operating range of termocouple type 00430 * \li 4 if Cold Junction temp is higher than the threshold && is outside operating range of termocouple type 00431 * \li 5 if Cold Junction temp is lower than the threshold && is outside operating range of termocouple type 00432 */ 00433 uint8_t checkFaultsColdJunctionThresholds(); 00434 00435 00436 /** 00437 * @brief Check the fault stautus register to see if there is anything wrong with thermocouple connection to the MAX31856 00438 * @return \li 1 if no faults are present 00439 * \li 0 if there is a fault and there needs to be information printed to the console to help diagnose issues 00440 */ 00441 bool checkFaultsThermocoupleConnection(); 00442 00443 00444 //***************************************************************************** 00445 //General Functions 00446 //***************************************************************************** 00447 /** 00448 * @brief This function is to read current contents of register, manipulate the contents, then rewrite the specific register\n 00449 * \li Read the value of a register from contents of register matching the parameter read_address 00450 * \li Clear the bits needed to be changed by bitwise ANDing the read value with the 8 bit parameter clear_bits 00451 * \li Set the bits of interest in the 8 bit value by bitwise ORing the value from step two with parameter val 00452 * \li Rewrite to the register with the new 8 bit value to the register with the address with parameter write_address 00453 * @param read_address - Address of register to read the data before it's changed 00454 * @param write_address - Address of register to rewrite the changed data 00455 * @param clear_bits - Parameter that is 00456 * @param val - Bitfield that contains bits related to function specific settings 00457 * @return \li 1 on success 00458 */ 00459 bool registerReadWriteByte(uint8_t read_address, uint8_t write_address, int clear_bits, uint8_t val); 00460 00461 00462 /** 00463 * @brief This function is to read current contents of register, manipulate the contents, then rewrite the specific register\n 00464 * \li Read the value of a register from contents of register matching the parameter read_address 00465 * \li Clear the bits needed to be changed by bitwise ANDing the read value with the 8 bit parameter clear_bits 00466 * \li Set the bits of interest in the 8 bit value by bitwise ORing the value from step two with parameter val 00467 * \li Write to the register with the new 8 bit value to the register with the address with parameter write_address 00468 * @param write_address - Address of register to rewrite the changed data 00469 * @param val - Byte of information that is going to be written to the regitser with the address that matches the parameter write_address 00470 * @return \li 1 on success 00471 */ 00472 bool registerWriteByte(uint8_t write_address, uint8_t val); 00473 00474 00475 /** 00476 * @brief This function is to read current contents of register by passing in the address of the read address and return contents of the register 00477 * @param read_address - Address of register to read data from 00478 * @return \li byte contained in the address 00479 */ 00480 uint8_t registerReadByte(uint8_t read_address); 00481 00482 00483 /** 00484 * @brief This function is to read current contents of register by passing in the address of the read address and return contents of the register 00485 * @param temperature - Float of value to offest the value of the cold junction offset by (must be between -8°C to +7.9375°C) 00486 * @return \li 1 on successfully updated coldjunction offset 00487 * \li 0 if parameter temperature does not fall between range -8°C to +7.9375°C 00488 */ 00489 bool coldJunctionOffset(float temperature); 00490 00491 00492 private: 00493 00494 //***************************************************************************** 00495 //Private Functions 00496 //***************************************************************************** 00497 /** @brief Writes the chip seleect pin low to begin SPI communications */ 00498 void spiEnable(); 00499 00500 00501 /** @brief Writes the chip seleect pin high to end SPI communications */ 00502 void spiDisable(); 00503 00504 /** @brief Calculates minimum wait time for a conversion to take place */ 00505 void calculateDelayTime(); 00506 00507 00508 //***************************************************************************** 00509 //Private Members 00510 //***************************************************************************** 00511 /// SPI object 00512 SPI& spi; 00513 00514 /// Chip select pin for SPI communications 00515 DigitalOut ncs; 00516 00517 /// Number of samples the thermocouple is configured to average 00518 uint8_t samples; 00519 00520 /// 0=thermocouple is set to one of 8 thermocouple types and 1=Thermocouple is configured to report in voltage mode 00521 bool voltage_mode; 00522 00523 /// 0=60Hz and 1=50Hz 00524 bool filter_mode; 00525 00526 /// 0=MAX31856 is off, so no conversion is taking place currently and 1=Always On and converting 00527 bool conversion_mode; 00528 00529 /// 0=cold junction is disabled and 1=cold junction is enabled 00530 bool cold_junction_enabled; 00531 00532 ///Define a return val for all boolean functions 00533 bool return_val; 00534 00535 ///Used to figure out when a new conversion is ready to go 00536 uint32_t lastReadTime; 00537 00538 ///How many conversions have taken place since conversion mode was switched into auto mode 00539 ///Also this value should be 0 if the mode is in oneshot mode 00540 uint32_t thermocouple_conversion_count; 00541 00542 ///time in milliseconds that is needed minimum for a new conversion to take place 00543 uint32_t conversion_time; 00544 }; 00545 00546 #endif /* __MAX31856_H_ */
Generated on Sat Jul 16 2022 11:04:06 by
1.7.2