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.
Dependents: MAX31725_High_Temperature_Accurate_IC
max31725_cpp.h
00001 /******************************************************************************* 00002 * Copyright (C) 2019 Maxim Integrated Products, Inc., All Rights Reserved. 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a 00005 * copy of this software and associated documentation files (the "Software"), 00006 * to deal in the Software without restriction, including without limitation 00007 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00008 * and/or sell copies of the Software, and to permit persons to whom the 00009 * Software is furnished to do so, subject to the following conditions: 00010 * 00011 * The above copyright notice and this permission notice shall be included 00012 * in all copies or substantial portions of the Software. 00013 * 00014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00015 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00016 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00017 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES 00018 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00019 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00020 * OTHER DEALINGS IN THE SOFTWARE. 00021 * 00022 * Except as contained in this notice, the name of Maxim Integrated 00023 * Products, Inc. shall not be used except as stated in the Maxim Integrated 00024 * Products, Inc. Branding Policy. 00025 * 00026 * The mere transfer of this software does not imply any licenses 00027 * of trade secrets, proprietary technology, copyrights, patents, 00028 * trademarks, maskwork rights, or any other form of intellectual 00029 * property whatsoever. Maxim Integrated Products, Inc. retains all 00030 * ownership rights. 00031 ******************************************************************************* 00032 * @file max31725_cpp.h 00033 ******************************************************************************* 00034 */ 00035 #ifndef MAX31725_CPP_H 00036 #define MAX31725_CPP_H 00037 #include "mbed.h" 00038 00039 00040 /** 00041 * @brief Digital thermometer, thermostat, temperature sensor. 00042 * @version 1.0000.0002 00043 * 00044 * @details The MAX31725, MAX31726 temperature sensors 00045 * provides accurate temperature measurements. 00046 * Extended format allows for high temperature readings up to 150°C. 00047 * The MAX31725 can operate in a low powered mode by utilizing 00048 * the shutdown and one-shot mode. 00049 * 8-pin TQDFN 3x3 mm package 00050 * Accuracy is +-0.5°C from -40°C to +105°C (-40°F to +221°). 00051 * Operating temperature: -55°C to +150°C (-67°F to +302°). 00052 * VDD: 2.5V to 3.7V. 00053 * 00054 * @code 00055 * #include "mbed.h" 00056 * #include "max32630fthr.h" 00057 * #include "max31725.h" 00058 * #include "USBSerial.h" 00059 * MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); 00060 * I2C i2cBus(P3_4, P3_5); 00061 * int main() 00062 * { 00063 * float temperature; 00064 * DigitalOut rLED(LED1, LED_OFF); 00065 * DigitalOut gLED(LED2, LED_OFF); 00066 * DigitalOut bLED(LED3, LED_OFF); 00067 * gLED = LED_ON; 00068 * MAX31725 temp_sensor(i2cBus, MAX31725_I2C_SLAVE_ADR_00); 00069 * i2cBus.frequency(400000); 00070 * temperature = 00071 * temp_sensor.read_reg_as_temperature(MAX31725_REG_TEMPERATURE); 00072 * printf("Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", 00073 * temperature, temp_sensor.celsius_to_fahrenheit(temperature)); 00074 * } 00075 * @endcode 00076 */ 00077 00078 class MAX31725 00079 { 00080 public: 00081 00082 /**********************************************************//** 00083 * @brief Constructor for MAX31725 Class. 00084 * 00085 * @details Allows user to use existing I2C object 00086 * 00087 * On Entry: 00088 * @param[in] i2c_bus - pointer to existing I2C object 00089 * @param[in] i2c_adrs - 7-bit slave address of MAX31725 00090 * 00091 * On Exit: 00092 * 00093 * @return None 00094 **************************************************************/ 00095 MAX31725(I2C &i2c_bus, uint8_t slave_address); 00096 00097 /**********************************************************//** 00098 * @brief Default destructor for MAX31725 Class. 00099 * 00100 * @details Destroys I2C object if owner 00101 * 00102 * On Entry: 00103 * 00104 * On Exit: 00105 * 00106 * @return None 00107 **************************************************************/ 00108 ~MAX31725(); 00109 00110 /** 00111 * @brief Read register of device at slave address 00112 * @param[out] value - Read data on success 00113 * @return 0 on success, negative number on failure 00114 */ 00115 int read_cfg_reg(uint8_t *value); 00116 00117 /** 00118 * @brief Read register of device at slave address 00119 * @param[out] value - Read data on success 00120 * @param reg - Register address 00121 * @return 0 on success, negative number on failure 00122 */ 00123 int read_reg16(int16_t *value, char reg); 00124 00125 /** 00126 * @brief Reads the temperature registers 00127 * @param reg - the address of the temperature register 00128 * @return temperature in degrees Celsius 00129 */ 00130 float read_reg_as_temperature(uint8_t reg); 00131 00132 /** 00133 * @brief Writes to the configuration register 00134 * @param cfg - configurate word 00135 * @return 0 on success, negative number on failure 00136 */ 00137 int write_cfg_reg(uint8_t cfg); 00138 00139 /** 00140 * @brief Writes to the THYST register 00141 * @param temperature - the temperature in Celsius degrees 00142 * @return 0 on success, negative number on failure 00143 */ 00144 int write_trip_low_thyst(float temperature); 00145 00146 /** 00147 * @brief Writes to the TOS register 00148 * @param temperature - the temperature in Celsius degrees 00149 * @return 0 on success, negative number on failure 00150 */ 00151 int write_trip_high_tos(float temperature); 00152 00153 /** 00154 * @brief Converts Celsius degrees to Fahrenheit 00155 * @param temp_c - the temperature in Celsius degrees 00156 * @return temperature in Celsius degrees 00157 */ 00158 float celsius_to_fahrenheit(float temp_c); 00159 00160 protected: 00161 /** 00162 * @brief Write a value to a register 00163 * @param value - value to write to the register 00164 * @param reg - register address 00165 * @return 0 on success, negative number on failure 00166 */ 00167 int write_reg16(int16_t value, char reg); 00168 00169 private: 00170 /** @var m_i2c 00171 * @brief I2C object 00172 */ 00173 I2C &m_i2c; 00174 /** @var m_write_address, m_read_address 00175 * @brief I2C address 00176 */ 00177 uint8_t m_write_address, m_read_address; 00178 /** @var m_extended_format 00179 * @brief Extended format, add 64°C to the temperature reading 00180 */ 00181 uint32_t max31725_extended_format; 00182 00183 }; 00184 00185 #endif/* MAX31725_CPP_H */
Generated on Sat Jul 16 2022 08:00:57 by
