C, C++ source code driver software for the Maxim Integrated MAX31725, MAX31726 thermostat : The MAX31725, MAX31726 temperature sensors provides temperature measurements with an accuracy of up to +-0.5°C. Extended format allows for high temperature readings up to 150°C. The MAX31725 can operate in a low powered mode by utilizing the shutdown and one-shot mode. MAX31725 supports two-wire serial, I2C bus communications in an 8-pin TQDFN 3x3 mm package.
Dependents: MAX31725_High_Temperature_Accurate_IC
max31725.h@24:b4fdbbe79036, 2019-04-17 (annotated)
- Committer:
- phonemacro
- Date:
- Wed Apr 17 21:28:29 2019 +0000
- Revision:
- 24:b4fdbbe79036
- Parent:
- 23:3fa31b45fa1a
update comment
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
phonemacro | 20:c9805b01e814 | 1 | /******************************************************************************* |
phonemacro | 20:c9805b01e814 | 2 | * Copyright (C) 2019 Maxim Integrated Products, Inc., All Rights Reserved. |
phonemacro | 20:c9805b01e814 | 3 | * |
phonemacro | 20:c9805b01e814 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
phonemacro | 20:c9805b01e814 | 5 | * copy of this software and associated documentation files (the "Software"), |
phonemacro | 20:c9805b01e814 | 6 | * to deal in the Software without restriction, including without limitation |
phonemacro | 20:c9805b01e814 | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
phonemacro | 20:c9805b01e814 | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
phonemacro | 20:c9805b01e814 | 9 | * Software is furnished to do so, subject to the following conditions: |
phonemacro | 20:c9805b01e814 | 10 | * |
phonemacro | 20:c9805b01e814 | 11 | * The above copyright notice and this permission notice shall be included |
phonemacro | 20:c9805b01e814 | 12 | * in all copies or substantial portions of the Software. |
phonemacro | 20:c9805b01e814 | 13 | * |
phonemacro | 20:c9805b01e814 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
phonemacro | 20:c9805b01e814 | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
phonemacro | 20:c9805b01e814 | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
phonemacro | 20:c9805b01e814 | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
phonemacro | 20:c9805b01e814 | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
phonemacro | 20:c9805b01e814 | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
phonemacro | 20:c9805b01e814 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
phonemacro | 20:c9805b01e814 | 21 | * |
phonemacro | 20:c9805b01e814 | 22 | * Except as contained in this notice, the name of Maxim Integrated |
phonemacro | 20:c9805b01e814 | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
phonemacro | 20:c9805b01e814 | 24 | * Products, Inc. Branding Policy. |
phonemacro | 20:c9805b01e814 | 25 | * |
phonemacro | 20:c9805b01e814 | 26 | * The mere transfer of this software does not imply any licenses |
phonemacro | 20:c9805b01e814 | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
phonemacro | 20:c9805b01e814 | 28 | * trademarks, maskwork rights, or any other form of intellectual |
phonemacro | 20:c9805b01e814 | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
phonemacro | 20:c9805b01e814 | 30 | * ownership rights. |
phonemacro | 20:c9805b01e814 | 31 | ******************************************************************************* |
phonemacro | 20:c9805b01e814 | 32 | * @file MAX31725.h |
phonemacro | 20:c9805b01e814 | 33 | ******************************************************************************* |
phonemacro | 20:c9805b01e814 | 34 | */ |
phonemacro | 20:c9805b01e814 | 35 | #ifndef MAX31725_H |
phonemacro | 20:c9805b01e814 | 36 | #define MAX31725_H |
phonemacro | 20:c9805b01e814 | 37 | #include "mbed.h" |
phonemacro | 20:c9805b01e814 | 38 | |
phonemacro | 20:c9805b01e814 | 39 | #define MAX31725_NO_ERROR 0 |
phonemacro | 20:c9805b01e814 | 40 | #define MAX31725_ERROR -1 |
phonemacro | 20:c9805b01e814 | 41 | |
phonemacro | 20:c9805b01e814 | 42 | #define MAX31725_REG_TEMPERATURE 0X00 |
phonemacro | 20:c9805b01e814 | 43 | #define MAX31725_REG_CONFIGURATION 0X01 |
phonemacro | 20:c9805b01e814 | 44 | #define MAX31725_REG_THYST_LOW_TRIP 0X02 |
phonemacro | 20:c9805b01e814 | 45 | #define MAX31725_REG_TOS_HIGH_TRIP 0X03 |
phonemacro | 20:c9805b01e814 | 46 | #define MAX31725_REG_MAX 0X03 |
phonemacro | 20:c9805b01e814 | 47 | |
phonemacro | 20:c9805b01e814 | 48 | #define WAIT_MARGIN (0.0000) |
phonemacro | 20:c9805b01e814 | 49 | #define MAX31725_WAIT_CONV_TIME (.050+WAIT_MARGIN) |
phonemacro | 20:c9805b01e814 | 50 | |
phonemacro | 20:c9805b01e814 | 51 | #define MAX31725_CFG_CONTINUOUS (0X00 << 0) |
phonemacro | 20:c9805b01e814 | 52 | #define MAX31725_CFG_SHUTDOWN (0X01 << 0) |
phonemacro | 20:c9805b01e814 | 53 | |
phonemacro | 20:c9805b01e814 | 54 | #define MAX31725_CFG_COMPARATOR_MODE (0X00 << 1) |
phonemacro | 20:c9805b01e814 | 55 | #define MAX31725_CFG_INTERRUPT_MODE (0X01 << 1) |
phonemacro | 20:c9805b01e814 | 56 | |
phonemacro | 20:c9805b01e814 | 57 | #define MAX31725_CFG_OS_POLARITY_ACT_LOW (0x00 << 2) |
phonemacro | 20:c9805b01e814 | 58 | #define MAX31725_CFG_OS_POLARITY_ACT_HIGH (0x01 << 2) |
phonemacro | 20:c9805b01e814 | 59 | |
phonemacro | 20:c9805b01e814 | 60 | #define MAX31725_CFG_FAULT_FILTER_1 (0x00 << 3) |
phonemacro | 20:c9805b01e814 | 61 | #define MAX31725_CFG_FAULT_FILTER_2 (0x01 << 3) |
phonemacro | 20:c9805b01e814 | 62 | #define MAX31725_CFG_FAULT_FILTER_4 (0x02 << 3) |
phonemacro | 20:c9805b01e814 | 63 | #define MAX31725_CFG_FAULT_FILTER_6 (0x03 << 3) |
phonemacro | 20:c9805b01e814 | 64 | |
phonemacro | 20:c9805b01e814 | 65 | #define MAX31725_CFG_NORMAL_FORMAT (0x00 << 5) |
phonemacro | 20:c9805b01e814 | 66 | #define MAX31725_CFG_EXTENDED_FORMAT (0x01 << 5) /* add 64°C to temperature */ |
phonemacro | 20:c9805b01e814 | 67 | #define MAX31725_EXTENDED_FORMAT_OFFSET (64.0f) |
phonemacro | 20:c9805b01e814 | 68 | #define MAX31725_CFG_TIMEOUT_ENABLE (0X00 << 6) |
phonemacro | 20:c9805b01e814 | 69 | #define MAX31725_CFG_TIMEOUT_DISABLE (0X01 << 6) |
phonemacro | 20:c9805b01e814 | 70 | #define MAX31725_CFG_ONE_SHOT_START (0X01 << 7) |
phonemacro | 20:c9805b01e814 | 71 | |
phonemacro | 23:3fa31b45fa1a | 72 | /* A1 A2 A3 */ |
phonemacro | 23:3fa31b45fa1a | 73 | #define MAX31725_I2C_SLAVE_ADR_00 (0x90 >> 1) /* GND GND GND */ |
phonemacro | 23:3fa31b45fa1a | 74 | #define MAX31725_I2C_SLAVE_ADR_01 (0x92 >> 1) /* GND GND VDD */ |
phonemacro | 23:3fa31b45fa1a | 75 | #define MAX31725_I2C_SLAVE_ADR_02 (0x82 >> 1) /* GND GND SCL */ |
phonemacro | 23:3fa31b45fa1a | 76 | #define MAX31725_I2C_SLAVE_ADR_03 (0x80 >> 1) /* GND GND SDA */ |
phonemacro | 23:3fa31b45fa1a | 77 | #define MAX31725_I2C_SLAVE_ADR_04 (0x94 >> 1) /* GND VDD GND */ |
phonemacro | 23:3fa31b45fa1a | 78 | |
phonemacro | 23:3fa31b45fa1a | 79 | #define MAX31725_I2C_SLAVE_ADR_05 (0x96 >> 1) /* GND VDD VDD */ |
phonemacro | 23:3fa31b45fa1a | 80 | #define MAX31725_I2C_SLAVE_ADR_06 (0x86 >> 1) /* GND VDD SCL */ |
phonemacro | 23:3fa31b45fa1a | 81 | #define MAX31725_I2C_SLAVE_ADR_07 (0x84 >> 1) /* GND VDD SDA */ |
phonemacro | 23:3fa31b45fa1a | 82 | #define MAX31725_I2C_SLAVE_ADR_08 (0xB4 >> 1) /* GND SCL GND */ |
phonemacro | 23:3fa31b45fa1a | 83 | #define MAX31725_I2C_SLAVE_ADR_09 (0xB6 >> 1) /* GND SCL VDD */ |
phonemacro | 23:3fa31b45fa1a | 84 | |
phonemacro | 23:3fa31b45fa1a | 85 | #define MAX31725_I2C_SLAVE_ADR_10 (0xA6 >> 1) /* GND SCL SCL */ |
phonemacro | 23:3fa31b45fa1a | 86 | #define MAX31725_I2C_SLAVE_ADR_11 (0xA4 >> 1) /* GND SCL SDA */ |
phonemacro | 23:3fa31b45fa1a | 87 | #define MAX31725_I2C_SLAVE_ADR_12 (0xB0 >> 1) /* GND SDA GND */ |
phonemacro | 23:3fa31b45fa1a | 88 | #define MAX31725_I2C_SLAVE_ADR_13 (0xB2 >> 1) /* GND SDA VDD */ |
phonemacro | 23:3fa31b45fa1a | 89 | #define MAX31725_I2C_SLAVE_ADR_14 (0xA2 >> 1) /* GND SDA SCL */ |
phonemacro | 23:3fa31b45fa1a | 90 | |
phonemacro | 23:3fa31b45fa1a | 91 | #define MAX31725_I2C_SLAVE_ADR_15 (0xA0 >> 1) /* GND SDA SDA */ |
phonemacro | 23:3fa31b45fa1a | 92 | #define MAX31725_I2C_SLAVE_ADR_16 (0x98 >> 1) /* VDD GND GND */ |
phonemacro | 23:3fa31b45fa1a | 93 | #define MAX31725_I2C_SLAVE_ADR_17 (0x9A >> 1) /* VDD GND VDD */ |
phonemacro | 23:3fa31b45fa1a | 94 | #define MAX31725_I2C_SLAVE_ADR_18 (0x8A >> 1) /* VDD GND SCL */ |
phonemacro | 23:3fa31b45fa1a | 95 | #define MAX31725_I2C_SLAVE_ADR_19 (0x88 >> 1) /* VDD GND SDA */ |
phonemacro | 23:3fa31b45fa1a | 96 | |
phonemacro | 23:3fa31b45fa1a | 97 | #define MAX31725_I2C_SLAVE_ADR_20 (0x9C >> 1) /* VDD VDD GND */ |
phonemacro | 23:3fa31b45fa1a | 98 | #define MAX31725_I2C_SLAVE_ADR_21 (0x9E >> 1) /* VDD VDD VDD */ |
phonemacro | 23:3fa31b45fa1a | 99 | #define MAX31725_I2C_SLAVE_ADR_22 (0x8E >> 1) /* VDD VDD SCL */ |
phonemacro | 23:3fa31b45fa1a | 100 | #define MAX31725_I2C_SLAVE_ADR_23 (0x8C >> 1) /* VDD VDD SDA */ |
phonemacro | 23:3fa31b45fa1a | 101 | #define MAX31725_I2C_SLAVE_ADR_24 (0xBC >> 1) /* VDD SCL GND */ |
phonemacro | 23:3fa31b45fa1a | 102 | |
phonemacro | 23:3fa31b45fa1a | 103 | #define MAX31725_I2C_SLAVE_ADR_25 (0xBE >> 1) /* VDD SCL VDD */ |
phonemacro | 23:3fa31b45fa1a | 104 | #define MAX31725_I2C_SLAVE_ADR_26 (0xAE >> 1) /* VDD SCL SCL */ |
phonemacro | 23:3fa31b45fa1a | 105 | #define MAX31725_I2C_SLAVE_ADR_27 (0xAC >> 1) /* VDD SCL SDA */ |
phonemacro | 23:3fa31b45fa1a | 106 | #define MAX31725_I2C_SLAVE_ADR_28 (0xB8 >> 1) /* VDD SDA GND */ |
phonemacro | 23:3fa31b45fa1a | 107 | #define MAX31725_I2C_SLAVE_ADR_29 (0xBA >> 1) /* VDD SDA VDD */ |
phonemacro | 23:3fa31b45fa1a | 108 | |
phonemacro | 23:3fa31b45fa1a | 109 | #define MAX31725_I2C_SLAVE_ADR_30 (0xAA >> 1) /* VDD SDA SCL */ |
phonemacro | 23:3fa31b45fa1a | 110 | #define MAX31725_I2C_SLAVE_ADR_31 (0xA8 >> 1) /* VDD SDA SDA */ |
phonemacro | 22:692515ac2bb7 | 111 | |
phonemacro | 22:692515ac2bb7 | 112 | |
phonemacro | 23:3fa31b45fa1a | 113 | #define MAX31726_I2C_SLAVE_ADR_00 (0x98 >> 1) /* GND GND */ |
phonemacro | 23:3fa31b45fa1a | 114 | #define MAX31726_I2C_SLAVE_ADR_01 (0x9A >> 1) /* GND VDD */ |
phonemacro | 23:3fa31b45fa1a | 115 | #define MAX31726_I2C_SLAVE_ADR_02 (0x8A >> 1) /* GND SCL */ |
phonemacro | 23:3fa31b45fa1a | 116 | #define MAX31726_I2C_SLAVE_ADR_03 (0x88 >> 1) /* GND SDA */ |
phonemacro | 23:3fa31b45fa1a | 117 | #define MAX31726_I2C_SLAVE_ADR_04 (0x9C >> 1) /* VDD GND */ |
phonemacro | 22:692515ac2bb7 | 118 | |
phonemacro | 23:3fa31b45fa1a | 119 | #define MAX31726_I2C_SLAVE_ADR_05 (0x9E >> 1) /* VDD VDD */ |
phonemacro | 23:3fa31b45fa1a | 120 | #define MAX31726_I2C_SLAVE_ADR_06 (0x8E >> 1) /* VDD SCL */ |
phonemacro | 23:3fa31b45fa1a | 121 | #define MAX31726_I2C_SLAVE_ADR_07 (0x8C >> 1) /* VDD SDA */ |
phonemacro | 23:3fa31b45fa1a | 122 | #define MAX31726_I2C_SLAVE_ADR_08 (0xBC >> 1) /* SCL GND */ |
phonemacro | 23:3fa31b45fa1a | 123 | #define MAX31726_I2C_SLAVE_ADR_09 (0xBE >> 1) /* SCL VDD */ |
phonemacro | 22:692515ac2bb7 | 124 | |
phonemacro | 23:3fa31b45fa1a | 125 | #define MAX31726_I2C_SLAVE_ADR_10 (0xAE >> 1) /* SCL SCL */ |
phonemacro | 23:3fa31b45fa1a | 126 | #define MAX31726_I2C_SLAVE_ADR_11 (0xAC >> 1) /* SCL SDA */ |
phonemacro | 23:3fa31b45fa1a | 127 | #define MAX31726_I2C_SLAVE_ADR_12 (0xB8 >> 1) /* SDA GND */ |
phonemacro | 23:3fa31b45fa1a | 128 | #define MAX31726_I2C_SLAVE_ADR_13 (0xBA >> 1) /* SDA VDD */ |
phonemacro | 23:3fa31b45fa1a | 129 | #define MAX31726_I2C_SLAVE_ADR_14 (0xAA >> 1) /* SDA SCL */ |
phonemacro | 22:692515ac2bb7 | 130 | |
phonemacro | 23:3fa31b45fa1a | 131 | #define MAX31726_I2C_SLAVE_ADR_15 (0xA8 >> 1) /* SDA SDA */ |
phonemacro | 22:692515ac2bb7 | 132 | |
phonemacro | 20:c9805b01e814 | 133 | |
phonemacro | 20:c9805b01e814 | 134 | #define MAX31725_CF_LSB (0.00390625F) |
phonemacro | 20:c9805b01e814 | 135 | |
phonemacro | 20:c9805b01e814 | 136 | /** @union max31725_raw_data |
phonemacro | 20:c9805b01e814 | 137 | * @brief union data structure for byte word manipulations |
phonemacro | 20:c9805b01e814 | 138 | */ |
phonemacro | 20:c9805b01e814 | 139 | union max31725_raw_data { |
phonemacro | 20:c9805b01e814 | 140 | struct { |
phonemacro | 20:c9805b01e814 | 141 | uint8_t lsb; |
phonemacro | 20:c9805b01e814 | 142 | uint8_t msb; |
phonemacro | 20:c9805b01e814 | 143 | }; |
phonemacro | 20:c9805b01e814 | 144 | struct { |
phonemacro | 20:c9805b01e814 | 145 | uint16_t magnitude_bits:15; |
phonemacro | 20:c9805b01e814 | 146 | uint16_t sign_bit:1; |
phonemacro | 20:c9805b01e814 | 147 | }; |
phonemacro | 20:c9805b01e814 | 148 | uint16_t uwrd; |
phonemacro | 20:c9805b01e814 | 149 | int16_t swrd; |
phonemacro | 20:c9805b01e814 | 150 | }; |
phonemacro | 20:c9805b01e814 | 151 | |
phonemacro | 20:c9805b01e814 | 152 | #endif/* MAX31875_H */ |