DS7505 C, C++ driver source code: The DS7505 low-voltage (1.7V to 3.7V) digital thermometer and thermostat provides 9 to 12-bit digital temperature readings over a -55°C to +125°C range with +-0.5°C accuracy in the 0°C (32°F) to +70°C (158°F) range.
Dependents: DS7505_Temperature_Sensor_Low_Power
Diff: ds7505.h
- Revision:
- 25:93287f99d225
diff -r b4fdbbe79036 -r 93287f99d225 ds7505.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ds7505.h Sat Apr 27 09:50:48 2019 +0000 @@ -0,0 +1,103 @@ +/******************************************************************************* +* Copyright (C) 2019 Maxim Integrated Products, Inc., All Rights Reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included +* in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES +* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Except as contained in this notice, the name of Maxim Integrated +* Products, Inc. shall not be used except as stated in the Maxim Integrated +* Products, Inc. Branding Policy. +* +* The mere transfer of this software does not imply any licenses +* of trade secrets, proprietary technology, copyrights, patents, +* trademarks, maskwork rights, or any other form of intellectual +* property whatsoever. Maxim Integrated Products, Inc. retains all +* ownership rights. +******************************************************************************* +* @file DS7505.h +******************************************************************************* +*/ +#ifndef DS7505_H +#define DS7505_H +#include "mbed.h" + +#define DS7505_NO_ERROR 0 +#define DS7505_ERROR -1 + +#define DS7505_REG_TEMPERATURE 0X00 +#define DS7505_REG_CONFIGURATION 0X01 +#define DS7505_REG_THYST_LOW_TRIP 0X02 +#define DS7505_REG_TOS_HIGH_TRIP 0X03 +#define DS7505_REG_MAX 0X03 + +#define WAIT_MARGIN (0.0000) +#define DS7505_WAIT_CONV_TIME (.050+WAIT_MARGIN) + +#define DS7505_CFG_CONTINUOUS (0X00 << 0) +#define DS7505_CFG_SHUTDOWN (0X01 << 0) + +#define DS7505_CFG_COMPARATOR_MODE (0X00 << 1) +#define DS7505_CFG_INTERRUPT_MODE (0X01 << 1) + +#define DS7505_CFG_OS_POLARITY_ACT_LOW (0x00 << 2) +#define DS7505_CFG_OS_POLARITY_ACT_HIGH (0x01 << 2) + +#define DS7505_CFG_FAULT_FILTER_1 (0x00 << 3) +#define DS7505_CFG_FAULT_FILTER_2 (0x01 << 3) +#define DS7505_CFG_FAULT_FILTER_4 (0x02 << 3) +#define DS7505_CFG_FAULT_FILTER_6 (0x03 << 3) +#define DS7505_CFG_RESOLUTION_9BIT (0x00 << 5) +#define DS7505_CFG_RESOLUTION_10BIT (0x00 << 5) +#define DS7505_CFG_RESOLUTION_11BIT (0x00 << 5) +#define DS7505_CFG_RESOLUTION_12BIT (0x00 << 5) +#define DS7505_CFG_NV_BUSY (0X01 << 7) + +#define WAIT_MARGIN (0.000) +#define DS7505_WAIT_CONV_TIME_9BIT (0.025+WAIT_MARGIN) +#define DS7505_WAIT_CONV_TIME_10BIT (0.050+2*WAIT_MARGIN) +#define DS7505_WAIT_CONV_TIME_11BIT (0.100+4*WAIT_MARGIN) +#define DS7505_WAIT_CONV_TIME_12BIT (0.200+8*WAIT_MARGIN) + +#define DS7505_I2C_SLAVE_ADR_00 (0x90 >> 1) // code uses the 7 bit address +#define DS7505_I2C_SLAVE_ADR_01 (0x92 >> 1) +#define DS7505_I2C_SLAVE_ADR_02 (0x94 >> 1) +#define DS7505_I2C_SLAVE_ADR_03 (0x96 >> 1) +#define DS7505_I2C_SLAVE_ADR_04 (0x98 >> 1) +#define DS7505_I2C_SLAVE_ADR_05 (0x9A >> 1) +#define DS7505_I2C_SLAVE_ADR_06 (0x9C >> 1) +#define DS7505_I2C_SLAVE_ADR_07 (0x9E >> 1) + +#define DS7505_CF_LSB (0.00390625F) + +/** @union ds7505_raw_data + * @brief union data structure for byte word manipulations + */ +union ds7505_raw_data { + struct { + uint8_t lsb; + uint8_t msb; + }; + struct { + uint16_t magnitude_bits:15; + uint16_t sign_bit:1; + }; + uint16_t uwrd; + int16_t swrd; +}; + +#endif/* MAX31875_H */ \ No newline at end of file