LM77 Temperature sensor with I2C interface. Provides temperature in celsius and fahrenheit. The device also supports temperature alerts.

Dependents:   mbed_HP03SA_LM77

Committer:
wim
Date:
Sat Jan 10 19:10:40 2015 +0000
Revision:
0:8e812deb9f66
First version of LM77 library.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wim 0:8e812deb9f66 1 /* mbed LM77 Library, for an I2C Temperature sensor
wim 0:8e812deb9f66 2 * Copyright (c) 2015, v01: WH, Initial version
wim 0:8e812deb9f66 3 *
wim 0:8e812deb9f66 4 * The LM77 is a digital temperature sensor and thermal window comparator with an I2C Serial Bus interface.
wim 0:8e812deb9f66 5 * The open-drain Interrupt (INT) output becomes active whenever temperature goes outside a programmable window,
wim 0:8e812deb9f66 6 * while a separate Critical Temperature Alarm (T_CRIT_A) output becomes active when the temperature exceeds a
wim 0:8e812deb9f66 7 * programmable critical limit. The INT output can operate in either a comparator or event mode, while the T_CRIT_A
wim 0:8e812deb9f66 8 * output operates in comparator mode only. The host can program both the upper and lower limits of the window as
wim 0:8e812deb9f66 9 * well as the critical temperature limit. Programmable hysterisis as well as a fault queue are available to minimize
wim 0:8e812deb9f66 10 * false tripping. Two pins (A0, A1) are available for address selection. The sensor powers up with default thresholds
wim 0:8e812deb9f66 11 * of 2°C THYST, 10°C TLOW, 64°C THIGH, and 80°C T_CRIT.
wim 0:8e812deb9f66 12 *
wim 0:8e812deb9f66 13 * Permission is hereby granted, free of charge, to any person obtaining a copy
wim 0:8e812deb9f66 14 * of this software and associated documentation files (the "Software"), to deal
wim 0:8e812deb9f66 15 * in the Software without restriction, including without limitation the rights
wim 0:8e812deb9f66 16 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
wim 0:8e812deb9f66 17 * copies of the Software, and to permit persons to whom the Software is
wim 0:8e812deb9f66 18 * furnished to do so, subject to the following conditions:
wim 0:8e812deb9f66 19 *
wim 0:8e812deb9f66 20 * The above copyright notice and this permission notice shall be included in
wim 0:8e812deb9f66 21 * all copies or substantial portions of the Software.
wim 0:8e812deb9f66 22 *
wim 0:8e812deb9f66 23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
wim 0:8e812deb9f66 24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
wim 0:8e812deb9f66 25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
wim 0:8e812deb9f66 26 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
wim 0:8e812deb9f66 27 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
wim 0:8e812deb9f66 28 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
wim 0:8e812deb9f66 29 * THE SOFTWARE.
wim 0:8e812deb9f66 30 */
wim 0:8e812deb9f66 31
wim 0:8e812deb9f66 32 #ifndef MBED_LM77_H
wim 0:8e812deb9f66 33 #define MBED_LM77_H
wim 0:8e812deb9f66 34
wim 0:8e812deb9f66 35 #include "mbed.h"
wim 0:8e812deb9f66 36
wim 0:8e812deb9f66 37 /** An interface for the LM77 I2C temperature sensor
wim 0:8e812deb9f66 38 *
wim 0:8e812deb9f66 39 * @code
wim 0:8e812deb9f66 40 * #include "mbed.h"
wim 0:8e812deb9f66 41 * #include "LM77.h"
wim 0:8e812deb9f66 42 *
wim 0:8e812deb9f66 43 * // I2C Communication
wim 0:8e812deb9f66 44 * I2C i2c(p28,p27); // SDA, SCL
wim 0:8e812deb9f66 45 *
wim 0:8e812deb9f66 46 * // Serial Communication*
wim 0:8e812deb9f66 47 * Serial pc(USBTX,USBRX);
wim 0:8e812deb9f66 48 *
wim 0:8e812deb9f66 49 * //Create an LM77 object at the default address (LM77_SA0)
wim 0:8e812deb9f66 50 * LM77 sensor(&i2c);
wim 0:8e812deb9f66 51 *
wim 0:8e812deb9f66 52 * int main() {
wim 0:8e812deb9f66 53 * pc.printf("Hello World!\n");
wim 0:8e812deb9f66 54 * if (lm77.getStatus()) {
wim 0:8e812deb9f66 55 * pc.printf("LM77 status = Ok\n\r");
wim 0:8e812deb9f66 56 *
wim 0:8e812deb9f66 57 * pc.printf("Critical Alert temperature from LM77 is %.1f [C]\r\n", lm77.getCritAlertTemp());
wim 0:8e812deb9f66 58 * pc.printf("Low Alert temperature from LM77 is %.1f [C]\r\n", lm77.getLowAlertTemp());
wim 0:8e812deb9f66 59 * pc.printf("High Alert temperature from LM77 is %.1f [C]\r\n", lm77.getHighAlertTemp());
wim 0:8e812deb9f66 60 * pc.printf("Alert Hysteresis from LM77 is %.1f [C]\r\n", lm77.getAlertHyst());
wim 0:8e812deb9f66 61 * wait(1.0);
wim 0:8e812deb9f66 62 *
wim 0:8e812deb9f66 63 *#define CA 95.0f
wim 0:8e812deb9f66 64 *#define LA 8.0f
wim 0:8e812deb9f66 65 *#define HA 15.0f
wim 0:8e812deb9f66 66 *#define HY 3.0f
wim 0:8e812deb9f66 67 * lm77.setCritAlertTemp(CA);
wim 0:8e812deb9f66 68 * lm77.setLowAlertTemp(LA);
wim 0:8e812deb9f66 69 * lm77.setHighAlertTemp(HA);
wim 0:8e812deb9f66 70 * lm77.setAlertHyst(HY);
wim 0:8e812deb9f66 71 *
wim 0:8e812deb9f66 72 * while(1) {
wim 0:8e812deb9f66 73 *
wim 0:8e812deb9f66 74 * // Show Temperature LM77
wim 0:8e812deb9f66 75 * //pc.printf("Ambient temperature from LM77 is %.1f [C]\r\n", (float) lm77.getTemperatureInt() / 10.0f);
wim 0:8e812deb9f66 76 * pc.printf("Ambient temperature from LM77 is %.1f [C]\r\n", lm77.getTemperature());
wim 0:8e812deb9f66 77 * wait(1.0);
wim 0:8e812deb9f66 78 * } // while
wim 0:8e812deb9f66 79 * }
wim 0:8e812deb9f66 80 * else {
wim 0:8e812deb9f66 81 * pc.printf("LM77 status = not Ok\n\r");
wim 0:8e812deb9f66 82 * } //if
wim 0:8e812deb9f66 83 * }
wim 0:8e812deb9f66 84 * @endcode
wim 0:8e812deb9f66 85 */
wim 0:8e812deb9f66 86
wim 0:8e812deb9f66 87 // Device I2C Slave addresses
wim 0:8e812deb9f66 88 #define LM77_SA0 0x90
wim 0:8e812deb9f66 89 #define LM77_SA1 0x92
wim 0:8e812deb9f66 90 #define LM77_SA2 0x94
wim 0:8e812deb9f66 91 #define LM77_SA3 0x96
wim 0:8e812deb9f66 92
wim 0:8e812deb9f66 93 //I2C register addresses
wim 0:8e812deb9f66 94 #define LM77_REG_TEMP 0x00
wim 0:8e812deb9f66 95 #define LM77_REG_CONF 0x01
wim 0:8e812deb9f66 96 #define LM77_REG_THYST 0x02
wim 0:8e812deb9f66 97 #define LM77_REG_TCRIT 0x03
wim 0:8e812deb9f66 98 #define LM77_REG_TLOW 0x04
wim 0:8e812deb9f66 99 #define LM77_REG_THIGH 0x05
wim 0:8e812deb9f66 100
wim 0:8e812deb9f66 101 //Temp Register
wim 0:8e812deb9f66 102 #define LM77_FLAG_LOW 0x01
wim 0:8e812deb9f66 103 #define LM77_FLAG_HIGH 0x02
wim 0:8e812deb9f66 104 #define LM77_FLAG_CRIT 0x04
wim 0:8e812deb9f66 105
wim 0:8e812deb9f66 106 #define LM77_FLAG_MSK 0x07
wim 0:8e812deb9f66 107
wim 0:8e812deb9f66 108 //Config Register
wim 0:8e812deb9f66 109 #define LM77_PWR_ON 0x00
wim 0:8e812deb9f66 110 #define LM77_PWR_DWN 0x01
wim 0:8e812deb9f66 111 #define LM77_INT_CMP 0x00
wim 0:8e812deb9f66 112 #define LM77_INT_EVENT 0x02
wim 0:8e812deb9f66 113 #define LM77_POL_TCRIT_L 0x00
wim 0:8e812deb9f66 114 #define LM77_POL_TCRIT_H 0x04
wim 0:8e812deb9f66 115 #define LM77_POL_INT_L 0x00
wim 0:8e812deb9f66 116 #define LM77_POL_INT_H 0x08
wim 0:8e812deb9f66 117 #define LM77_FQU_1 0x00
wim 0:8e812deb9f66 118 #define LM77_FQU_4 0x10
wim 0:8e812deb9f66 119
wim 0:8e812deb9f66 120 #define LM77_PWR_MSK 0x01
wim 0:8e812deb9f66 121 #define LM77_INT_MSK 0x02
wim 0:8e812deb9f66 122 #define LM77_POL_TCRIT_MSK 0x04
wim 0:8e812deb9f66 123 #define LM77_POL_INT_MSK 0x08
wim 0:8e812deb9f66 124 #define LM77_FQU_MSK 0x10
wim 0:8e812deb9f66 125
wim 0:8e812deb9f66 126 /** Create an LM77 Class instance
wim 0:8e812deb9f66 127 *
wim 0:8e812deb9f66 128 */
wim 0:8e812deb9f66 129 class LM77 {
wim 0:8e812deb9f66 130
wim 0:8e812deb9f66 131 public:
wim 0:8e812deb9f66 132
wim 0:8e812deb9f66 133 /** Represents the power mode of the LM77
wim 0:8e812deb9f66 134 */
wim 0:8e812deb9f66 135 enum PowerMode {
wim 0:8e812deb9f66 136 POWER_NORMAL, /**< Chip is enabled and samples every 100ms */
wim 0:8e812deb9f66 137 POWER_SHUTDOWN /**< Chip is in low-power shutdown mode */
wim 0:8e812deb9f66 138 };
wim 0:8e812deb9f66 139
wim 0:8e812deb9f66 140 /** Represents INT pin mode of the LM77
wim 0:8e812deb9f66 141 */
wim 0:8e812deb9f66 142 enum IntMode {
wim 0:8e812deb9f66 143 INT_COMPARATOR, /**< INT pin asserted when temp exceeds an alert threshold, and de-asserted when temp crosses alert hysteresis threshold or when LM77 is read. It will be re-asserted when condition is still true after reading. */
wim 0:8e812deb9f66 144 INT_EVENT /**< INT pin asserted when temp reaches an alert threshold or threshold +/- hysteris and only de-asserted when a register has been read. It will be re-asserted when next event occurs. */
wim 0:8e812deb9f66 145 };
wim 0:8e812deb9f66 146
wim 0:8e812deb9f66 147 /** Represents Pin polarity of the LM77
wim 0:8e812deb9f66 148 */
wim 0:8e812deb9f66 149 enum PinPolarity {
wim 0:8e812deb9f66 150 ACTIVE_LOW, /**< Pin is a logic low when asserted, and a logic high when de-asserted */
wim 0:8e812deb9f66 151 ACTIVE_HIGH /**< Pin is a logic high when asserted, and a logic low when de-asserted */
wim 0:8e812deb9f66 152 };
wim 0:8e812deb9f66 153
wim 0:8e812deb9f66 154 /** Represents OS pin fault queue length of the LM77
wim 0:8e812deb9f66 155 */
wim 0:8e812deb9f66 156 enum FaultQueue {
wim 0:8e812deb9f66 157 FAULT_QUEUE_1, /**< Pins and flags are asserted after 1 fault */
wim 0:8e812deb9f66 158 FAULT_QUEUE_4, /**< Pins and flags are asserted after 4 consecutive faults */
wim 0:8e812deb9f66 159 };
wim 0:8e812deb9f66 160
wim 0:8e812deb9f66 161
wim 0:8e812deb9f66 162 /** Create an LM77 device instance
wim 0:8e812deb9f66 163 *
wim 0:8e812deb9f66 164 * @param i2c I2C Bus
wim 0:8e812deb9f66 165 * @param char deviceAddress I2C slaveaddress (defaults to LM77_SA0).
wim 0:8e812deb9f66 166 */
wim 0:8e812deb9f66 167 LM77(I2C *i2c, char deviceAddress = LM77_SA0);
wim 0:8e812deb9f66 168
wim 0:8e812deb9f66 169
wim 0:8e812deb9f66 170 /** Get the current power mode of the LM77
wim 0:8e812deb9f66 171 *
wim 0:8e812deb9f66 172 * @returns The current power mode as a PowerMode enum.
wim 0:8e812deb9f66 173 */
wim 0:8e812deb9f66 174 LM77::PowerMode getPowerMode();
wim 0:8e812deb9f66 175
wim 0:8e812deb9f66 176 /** Set the power mode of the LM77
wim 0:8e812deb9f66 177 *
wim 0:8e812deb9f66 178 * @param mode The new power mode as a PowerMode enum.
wim 0:8e812deb9f66 179 */
wim 0:8e812deb9f66 180 void setPowerMode(PowerMode mode);
wim 0:8e812deb9f66 181
wim 0:8e812deb9f66 182 /** Get the current INT pin mode of the LM77
wim 0:8e812deb9f66 183 * Reset value is INT_COMPARATOR
wim 0:8e812deb9f66 184 *
wim 0:8e812deb9f66 185 * @returns The current INT pin mode as an IntMode enum.
wim 0:8e812deb9f66 186 */
wim 0:8e812deb9f66 187 LM77::IntMode getIntMode();
wim 0:8e812deb9f66 188
wim 0:8e812deb9f66 189 /** Set the INT pin mode of the LM77
wim 0:8e812deb9f66 190 *
wim 0:8e812deb9f66 191 * @param mode The new INT pin mode as an IntMode enum.
wim 0:8e812deb9f66 192 */
wim 0:8e812deb9f66 193 void setIntMode(IntMode mode);
wim 0:8e812deb9f66 194
wim 0:8e812deb9f66 195 /** Get the current INT pin polarity of the LM77
wim 0:8e812deb9f66 196 * Reset value is ACTIVE_LOW
wim 0:8e812deb9f66 197 *
wim 0:8e812deb9f66 198 * @returns The current INT pin polarity as an PinPolarity enum.
wim 0:8e812deb9f66 199 */
wim 0:8e812deb9f66 200 LM77::PinPolarity getIntPolarity();
wim 0:8e812deb9f66 201
wim 0:8e812deb9f66 202 /** Set the INT pin polarity of the LM77
wim 0:8e812deb9f66 203 *
wim 0:8e812deb9f66 204 * @param polarity The new INT pin polarity as an PinPolarity enum.
wim 0:8e812deb9f66 205 */
wim 0:8e812deb9f66 206 void setIntPolarity(PinPolarity polarity);
wim 0:8e812deb9f66 207
wim 0:8e812deb9f66 208 /** Get the current T_CRIT_A pin polarity of the LM77
wim 0:8e812deb9f66 209 * Reset value is ACTIVE_LOW
wim 0:8e812deb9f66 210 *
wim 0:8e812deb9f66 211 * @returns The current T_CRIT_A pin polarity as an PinPolarity enum.
wim 0:8e812deb9f66 212 */
wim 0:8e812deb9f66 213 LM77::PinPolarity getTCritPolarity();
wim 0:8e812deb9f66 214
wim 0:8e812deb9f66 215 /** Set the T_CRIT_A pin polarity of the LM77
wim 0:8e812deb9f66 216 *
wim 0:8e812deb9f66 217 * @param polarity The new T_CRIT_A pin polarity as an PinPolarity enum.
wim 0:8e812deb9f66 218 */
wim 0:8e812deb9f66 219 void setTCritPolarity(PinPolarity polarity);
wim 0:8e812deb9f66 220
wim 0:8e812deb9f66 221
wim 0:8e812deb9f66 222 /** Get the current pin and flag fault queue length of the LM77
wim 0:8e812deb9f66 223 * Reset value is FAULT_QUEUE_1, Pins and flags are asserted after 1 fault
wim 0:8e812deb9f66 224 *
wim 0:8e812deb9f66 225 * @returns The current pin and flag fault queue length as an FaultQueue enum.
wim 0:8e812deb9f66 226 */
wim 0:8e812deb9f66 227 LM77::FaultQueue getFaultQueue();
wim 0:8e812deb9f66 228
wim 0:8e812deb9f66 229 /** Set the pin and flag fault queue length of the LM77
wim 0:8e812deb9f66 230 *
wim 0:8e812deb9f66 231 * @param queue The new pin and flag fault queue length as an FaultQueue enum.
wim 0:8e812deb9f66 232 */
wim 0:8e812deb9f66 233 void setFaultQueue(FaultQueue queue);
wim 0:8e812deb9f66 234
wim 0:8e812deb9f66 235 /** Get the current critical alert temperature threshold of the LM77
wim 0:8e812deb9f66 236 * Reset value is 80.0 °C.
wim 0:8e812deb9f66 237 *
wim 0:8e812deb9f66 238 * @returns The current crtitcal alert temperature threshold in °C.
wim 0:8e812deb9f66 239 */
wim 0:8e812deb9f66 240 float getCritAlertTemp();
wim 0:8e812deb9f66 241
wim 0:8e812deb9f66 242 /** Set the Critical alert temperature threshold of the LM77
wim 0:8e812deb9f66 243 * Reset value is 80.0 °C.
wim 0:8e812deb9f66 244 *
wim 0:8e812deb9f66 245 * @param temp The new Critical alert temperature threshold in °C.
wim 0:8e812deb9f66 246 */
wim 0:8e812deb9f66 247 void setCritAlertTemp(float temp);
wim 0:8e812deb9f66 248
wim 0:8e812deb9f66 249
wim 0:8e812deb9f66 250 /** Get the current Low temperature alert threshold of the LM77
wim 0:8e812deb9f66 251 * Reset value is 10.0 °C.
wim 0:8e812deb9f66 252 *
wim 0:8e812deb9f66 253 * @returns The current Low temperature alert threshold in °C.
wim 0:8e812deb9f66 254 */
wim 0:8e812deb9f66 255 float getLowAlertTemp();
wim 0:8e812deb9f66 256
wim 0:8e812deb9f66 257 /** Set the current Low temperature alert threshold of the LM77
wim 0:8e812deb9f66 258 * Reset value is 10.0 °C.
wim 0:8e812deb9f66 259 *
wim 0:8e812deb9f66 260 * @param temp The new Low alert temperature threshold in °C.
wim 0:8e812deb9f66 261 */
wim 0:8e812deb9f66 262 void setLowAlertTemp(float temp);
wim 0:8e812deb9f66 263
wim 0:8e812deb9f66 264
wim 0:8e812deb9f66 265 /** Get the current High temperature alert threshold of the LM77
wim 0:8e812deb9f66 266 * Reset value is 64.0 °C.
wim 0:8e812deb9f66 267 *
wim 0:8e812deb9f66 268 * @returns The current High temperature alert threshold in °C.
wim 0:8e812deb9f66 269 */
wim 0:8e812deb9f66 270 float getHighAlertTemp();
wim 0:8e812deb9f66 271
wim 0:8e812deb9f66 272 /** Set the High temperature alert threshold of the LM77
wim 0:8e812deb9f66 273 * Reset value is 64.0 °C.
wim 0:8e812deb9f66 274 *
wim 0:8e812deb9f66 275 * @param temp The new High temperature alert threshold in °C.
wim 0:8e812deb9f66 276 */
wim 0:8e812deb9f66 277 void setHighAlertTemp(float temp);
wim 0:8e812deb9f66 278
wim 0:8e812deb9f66 279
wim 0:8e812deb9f66 280 /** Get the current alert temperature hysteresis of the LM77
wim 0:8e812deb9f66 281 * Reset value is 2.0 °C.
wim 0:8e812deb9f66 282 *
wim 0:8e812deb9f66 283 * @returns The current alert temperature hysteresis in °C.
wim 0:8e812deb9f66 284 */
wim 0:8e812deb9f66 285 float getAlertHyst();
wim 0:8e812deb9f66 286
wim 0:8e812deb9f66 287 /** Set the alert temperature hysteresis of the LM77
wim 0:8e812deb9f66 288 * Reset value is 2.0 °C.
wim 0:8e812deb9f66 289 *
wim 0:8e812deb9f66 290 * @param temp The new alert temperature hysteris in °C.
wim 0:8e812deb9f66 291 */
wim 0:8e812deb9f66 292 void setAlertHyst(float temp);
wim 0:8e812deb9f66 293
wim 0:8e812deb9f66 294 /** Get Temperature as Int in °Celsius x 10
wim 0:8e812deb9f66 295 *
wim 0:8e812deb9f66 296 * @return int Temperature in °Celsius x 10
wim 0:8e812deb9f66 297 */
wim 0:8e812deb9f66 298 int getTemperatureInt(void);
wim 0:8e812deb9f66 299
wim 0:8e812deb9f66 300 /** Get Temperature as float in °Celsius
wim 0:8e812deb9f66 301 *
wim 0:8e812deb9f66 302 * @return float Temperature in °Celsius
wim 0:8e812deb9f66 303 */
wim 0:8e812deb9f66 304 float getTemperature(void);
wim 0:8e812deb9f66 305
wim 0:8e812deb9f66 306 /** Get the Alert flags of the LM77
wim 0:8e812deb9f66 307 *
wim 0:8e812deb9f66 308 * @returns The current Alert flags as int.
wim 0:8e812deb9f66 309 */
wim 0:8e812deb9f66 310 int getAlertFlags(void);
wim 0:8e812deb9f66 311
wim 0:8e812deb9f66 312
wim 0:8e812deb9f66 313 #ifdef MBED_OPERATORS
wim 0:8e812deb9f66 314 /** A shorthand for Temperature()
wim 0:8e812deb9f66 315 *
wim 0:8e812deb9f66 316 * @returns The current temperature measurement in °C.
wim 0:8e812deb9f66 317 */
wim 0:8e812deb9f66 318 operator float();
wim 0:8e812deb9f66 319 #endif
wim 0:8e812deb9f66 320
wim 0:8e812deb9f66 321 /** Convert Temperature from °Celsius into °Fahrenheit
wim 0:8e812deb9f66 322 *
wim 0:8e812deb9f66 323 * @param float celsius in °Celsius
wim 0:8e812deb9f66 324 * @return float temperature in °Fahrenheit
wim 0:8e812deb9f66 325 */
wim 0:8e812deb9f66 326 float celsiusToFahrenheit(float celsius);
wim 0:8e812deb9f66 327
wim 0:8e812deb9f66 328
wim 0:8e812deb9f66 329 /** Get Status
wim 0:8e812deb9f66 330 *
wim 0:8e812deb9f66 331 * @return bool Sensor ready
wim 0:8e812deb9f66 332 */
wim 0:8e812deb9f66 333 bool getStatus(void);
wim 0:8e812deb9f66 334
wim 0:8e812deb9f66 335 private:
wim 0:8e812deb9f66 336 //Member variables
wim 0:8e812deb9f66 337 I2C* _i2c;
wim 0:8e812deb9f66 338 char _slaveAddress;
wim 0:8e812deb9f66 339
wim 0:8e812deb9f66 340 //Member methods
wim 0:8e812deb9f66 341 /** Read 8 bit value from register
wim 0:8e812deb9f66 342 *
wim 0:8e812deb9f66 343 * @param reg Index of register
wim 0:8e812deb9f66 344 * @return data value from register
wim 0:8e812deb9f66 345 */
wim 0:8e812deb9f66 346 char _readReg8(char reg);
wim 0:8e812deb9f66 347
wim 0:8e812deb9f66 348 /** Write 8 bit value to register
wim 0:8e812deb9f66 349 *
wim 0:8e812deb9f66 350 * @param reg Index of register
wim 0:8e812deb9f66 351 * @param data value to write
wim 0:8e812deb9f66 352 */
wim 0:8e812deb9f66 353 void _writeReg8(char reg, char data);
wim 0:8e812deb9f66 354
wim 0:8e812deb9f66 355 /** Read 16 bit value from register
wim 0:8e812deb9f66 356 * Used for Critical temp threshold, Low and High temp threshold window and Hysteresis
wim 0:8e812deb9f66 357 *
wim 0:8e812deb9f66 358 * @param reg Index of register
wim 0:8e812deb9f66 359 * @return data value from register
wim 0:8e812deb9f66 360 */
wim 0:8e812deb9f66 361 int16_t _readReg16(char reg);
wim 0:8e812deb9f66 362
wim 0:8e812deb9f66 363 /** Write 16 bit value to register
wim 0:8e812deb9f66 364 * Used for Critical temp threshold, Low and High temp threshold window and Hysteresis
wim 0:8e812deb9f66 365 *
wim 0:8e812deb9f66 366 * @param reg Index of register
wim 0:8e812deb9f66 367 * @param data value to write
wim 0:8e812deb9f66 368 */
wim 0:8e812deb9f66 369 void _writeReg16(char, int16_t data);
wim 0:8e812deb9f66 370
wim 0:8e812deb9f66 371 /** Get Temperature as float in °Celsius
wim 0:8e812deb9f66 372 * Used for Critical temp threshold, Low and High temp threshold window and Hysteresis
wim 0:8e812deb9f66 373 *
wim 0:8e812deb9f66 374 * @param reg Index of register to read temp value
wim 0:8e812deb9f66 375 * @return float Temperature in °Celsius
wim 0:8e812deb9f66 376 */
wim 0:8e812deb9f66 377 float _readTempHelper(char reg);
wim 0:8e812deb9f66 378
wim 0:8e812deb9f66 379 /** Set Temperature as float in °Celsius
wim 0:8e812deb9f66 380 * Used for Critical temp threshold, Low and High temp threshold window and Hysteresis
wim 0:8e812deb9f66 381 *
wim 0:8e812deb9f66 382 * @param reg Index of register to write temp value
wim 0:8e812deb9f66 383 * @param temp float Temperature value in °Celsius
wim 0:8e812deb9f66 384 */
wim 0:8e812deb9f66 385 void _writeTempHelper(char reg, float temp);
wim 0:8e812deb9f66 386 };
wim 0:8e812deb9f66 387
wim 0:8e812deb9f66 388 #endif