C code and C++ library, driver software for Maxim Integrated DS1775, DS75 thermometer and thermostat temperature sensor. Code supports continuous or shut-down/standby, hysteresis, alarm limits, comparator or interrupt mode, fault filtering, and active low/high. Compact 5-pin SOT23 packaging

Dependents:   DS1775_Digital_Thermostat_Temperature

Committer:
phonemacro
Date:
Wed Apr 10 18:07:50 2019 +0000
Revision:
20:cf75ff9e5560
Parent:
19:ccd43cedfd47
remove extra waits in conversion

Who changed what in which revision?

UserRevisionLine numberNew contents of line
phonemacro 8:b2d4c71268aa 1 /*******************************************************************************
phonemacro 8:b2d4c71268aa 2 * Copyright (C) 2019 Maxim Integrated Products, Inc., All Rights Reserved.
phonemacro 8:b2d4c71268aa 3 *
phonemacro 8:b2d4c71268aa 4 * Permission is hereby granted, free of charge, to any person obtaining a
phonemacro 8:b2d4c71268aa 5 * copy of this software and associated documentation files (the "Software"),
phonemacro 8:b2d4c71268aa 6 * to deal in the Software without restriction, including without limitation
phonemacro 8:b2d4c71268aa 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
phonemacro 8:b2d4c71268aa 8 * and/or sell copies of the Software, and to permit persons to whom the
phonemacro 8:b2d4c71268aa 9 * Software is furnished to do so, subject to the following conditions:
phonemacro 8:b2d4c71268aa 10 *
phonemacro 8:b2d4c71268aa 11 * The above copyright notice and this permission notice shall be included
phonemacro 8:b2d4c71268aa 12 * in all copies or substantial portions of the Software.
phonemacro 8:b2d4c71268aa 13 *
phonemacro 8:b2d4c71268aa 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
phonemacro 8:b2d4c71268aa 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
phonemacro 8:b2d4c71268aa 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
phonemacro 8:b2d4c71268aa 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
phonemacro 8:b2d4c71268aa 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
phonemacro 8:b2d4c71268aa 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
phonemacro 8:b2d4c71268aa 20 * OTHER DEALINGS IN THE SOFTWARE.
phonemacro 8:b2d4c71268aa 21 *
phonemacro 8:b2d4c71268aa 22 * Except as contained in this notice, the name of Maxim Integrated
phonemacro 8:b2d4c71268aa 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
phonemacro 8:b2d4c71268aa 24 * Products, Inc. Branding Policy.
phonemacro 8:b2d4c71268aa 25 *
phonemacro 8:b2d4c71268aa 26 * The mere transfer of this software does not imply any licenses
phonemacro 8:b2d4c71268aa 27 * of trade secrets, proprietary technology, copyrights, patents,
phonemacro 8:b2d4c71268aa 28 * trademarks, maskwork rights, or any other form of intellectual
phonemacro 8:b2d4c71268aa 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
phonemacro 8:b2d4c71268aa 30 * ownership rights.
phonemacro 8:b2d4c71268aa 31 *******************************************************************************
phonemacro 8:b2d4c71268aa 32 * @file DS1775.h
phonemacro 8:b2d4c71268aa 33 *******************************************************************************
phonemacro 8:b2d4c71268aa 34 */
phonemacro 8:b2d4c71268aa 35 #ifndef DS1775_H
phonemacro 8:b2d4c71268aa 36 #define DS1775_H
phonemacro 8:b2d4c71268aa 37 #include "mbed.h"
phonemacro 8:b2d4c71268aa 38
phonemacro 8:b2d4c71268aa 39 #define DS1775_NO_ERROR 0
phonemacro 8:b2d4c71268aa 40 #define DS1775_ERROR -1
phonemacro 8:b2d4c71268aa 41
phonemacro 8:b2d4c71268aa 42 #define DS1775_REG_TEMPERATURE 0X00
phonemacro 8:b2d4c71268aa 43 #define DS1775_REG_CONFIGURATION 0X01
phonemacro 8:b2d4c71268aa 44 #define DS1775_REG_THYST_LOW_TRIP 0X02
phonemacro 8:b2d4c71268aa 45 #define DS1775_REG_TOS_HIGH_TRIP 0X03
phonemacro 8:b2d4c71268aa 46 #define DS1775_REG_MAX 0X03
phonemacro 8:b2d4c71268aa 47
phonemacro 20:cf75ff9e5560 48 #define WAIT_MARGIN (0.0000)
phonemacro 15:449134e4b43f 49 #define DS1775_WAIT_CONV_TIME_9BIT (0.1875+WAIT_MARGIN)
phonemacro 15:449134e4b43f 50 #define DS1775_WAIT_CONV_TIME_10BIT (0.375+2*WAIT_MARGIN)
phonemacro 15:449134e4b43f 51 #define DS1775_WAIT_CONV_TIME_11BIT (0.750+4*WAIT_MARGIN)
phonemacro 15:449134e4b43f 52 #define DS1775_WAIT_CONV_TIME_12BIT (1.5+8*WAIT_MARGIN)
phonemacro 8:b2d4c71268aa 53
phonemacro 15:449134e4b43f 54 #define DS75_WAIT_CONV_TIME_9BIT (0.12+WAIT_MARGIN)
phonemacro 15:449134e4b43f 55 #define DS75_WAIT_CONV_TIME_10BIT (0.3+2*WAIT_MARGIN)
phonemacro 15:449134e4b43f 56 #define DS75_WAIT_CONV_TIME_11BIT (0.6+4*WAIT_MARGIN)
phonemacro 15:449134e4b43f 57 #define DS75_WAIT_CONV_TIME_12BIT (1.2+8*WAIT_MARGIN)
phonemacro 13:5726f1d1404c 58
phonemacro 9:315236fb3c6a 59 #define DS1775_CFG_CONTINUOUS (0X00 << 0)
phonemacro 9:315236fb3c6a 60 #define DS1775_CFG_SHUTDOWN (0X01 << 0)
phonemacro 9:315236fb3c6a 61
phonemacro 9:315236fb3c6a 62 #define DS1775_CFG_COMPARATOR_MODE (0X00 << 1)
phonemacro 9:315236fb3c6a 63 #define DS1775_CFG_INTERRUPT_MODE (0X01 << 1)
phonemacro 9:315236fb3c6a 64
phonemacro 9:315236fb3c6a 65 #define DS1775_CFG_OS_POLARITY_ACT_LOW (0x00 << 2)
phonemacro 9:315236fb3c6a 66 #define DS1775_CFG_OS_POLARITY_ACT_HIGH (0x01 << 2)
phonemacro 9:315236fb3c6a 67
phonemacro 9:315236fb3c6a 68 #define DS1775_CFG_FAULT_FILTER_1 (0x00 << 3)
phonemacro 9:315236fb3c6a 69 #define DS1775_CFG_FAULT_FILTER_2 (0x01 << 3)
phonemacro 9:315236fb3c6a 70 #define DS1775_CFG_FAULT_FILTER_4 (0x02 << 3)
phonemacro 9:315236fb3c6a 71 #define DS1775_CFG_FAULT_FILTER_6 (0x03 << 3)
phonemacro 8:b2d4c71268aa 72
phonemacro 8:b2d4c71268aa 73 #define DS1775_CFG_RESOLUTION_9BIT (0x00 << 5)
phonemacro 8:b2d4c71268aa 74 #define DS1775_CFG_RESOLUTION_10BIT (0x01 << 5)
phonemacro 8:b2d4c71268aa 75 #define DS1775_CFG_RESOLUTION_11BIT (0x02 << 5)
phonemacro 8:b2d4c71268aa 76 #define DS1775_CFG_RESOLUTION_12BIT (0x03 << 5)
phonemacro 8:b2d4c71268aa 77
phonemacro 8:b2d4c71268aa 78 #define DS1775_I2C_SLAVE_ADR_R0 (0x90 >> 1) // code uses the 7 bit address
phonemacro 8:b2d4c71268aa 79 #define DS1775_I2C_SLAVE_ADR_R1 (0x92 >> 1)
phonemacro 8:b2d4c71268aa 80 #define DS1775_I2C_SLAVE_ADR_R2 (0x94 >> 1)
phonemacro 8:b2d4c71268aa 81 #define DS1775_I2C_SLAVE_ADR_R3 (0x96 >> 1)
phonemacro 8:b2d4c71268aa 82 #define DS1775_I2C_SLAVE_ADR_R4 (0x98 >> 1)
phonemacro 8:b2d4c71268aa 83 #define DS1775_I2C_SLAVE_ADR_R5 (0x9A >> 1)
phonemacro 8:b2d4c71268aa 84 #define DS1775_I2C_SLAVE_ADR_R6 (0x9C >> 1)
phonemacro 8:b2d4c71268aa 85 #define DS1775_I2C_SLAVE_ADR_R7 (0x9E >> 1)
phonemacro 8:b2d4c71268aa 86
phonemacro 10:03645de9c017 87 #define DS1775_CF_LSB (0.00390625F)
phonemacro 8:b2d4c71268aa 88
phonemacro 8:b2d4c71268aa 89 /** @union ds1775_raw_data
phonemacro 8:b2d4c71268aa 90 * @brief union data structure for byte word manipulations
phonemacro 8:b2d4c71268aa 91 */
phonemacro 8:b2d4c71268aa 92 union ds1775_raw_data {
phonemacro 8:b2d4c71268aa 93 struct {
phonemacro 8:b2d4c71268aa 94 uint8_t lsb;
phonemacro 8:b2d4c71268aa 95 uint8_t msb;
phonemacro 8:b2d4c71268aa 96 };
phonemacro 8:b2d4c71268aa 97 struct {
phonemacro 8:b2d4c71268aa 98 uint16_t magnitude_bits:15;
phonemacro 8:b2d4c71268aa 99 uint16_t sign_bit:1;
phonemacro 8:b2d4c71268aa 100 };
phonemacro 8:b2d4c71268aa 101 uint16_t uwrd;
phonemacro 8:b2d4c71268aa 102 int16_t swrd;
phonemacro 8:b2d4c71268aa 103 };
phonemacro 8:b2d4c71268aa 104
phonemacro 8:b2d4c71268aa 105 #endif/* MAX31875_H */