1 /* 2 * Copyright (c) 2020 Innoseis BV 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef ZEPHYR_DRIVERS_SENSOR_TMP112_TMP112_H_ 8 #define ZEPHYR_DRIVERS_SENSOR_TMP112_TMP112_H_ 9 10 #include <zephyr/device.h> 11 #include <zephyr/sys/util.h> 12 13 #define TMP112_REG_TEMPERATURE 0x00 14 #define TMP112_DATA_INVALID_BIT (BIT(1) | BIT(2)) 15 #define TMP112_DATA_EXTENDED (BIT(0)) 16 #define TMP112_DATA_EXTENDED_SHIFT 3 17 #define TMP112_DATA_NORMAL_SHIFT 4 18 19 20 #define TMP112_REG_CONFIG 0x01 21 #define TMP112_CONFIG_EM BIT(4) 22 23 #define TMP112_ALERT_EN_BIT BIT(5) 24 #define TMP112_CONV_RATE_SHIFT 6 25 #define TMP112_CONV_RATE_MASK (BIT_MASK(2) << TMP112_CONV_RATE_SHIFT) 26 #define TMP112_CONV_RATE_025 0 27 #define TMP112_CONV_RATE_1000 1 28 #define TMP112_CONV_RATE_4 2 29 #define TMP112_CONV_RATE_8 3 30 31 #define TMP112_CONV_RATE(cr) ((cr) << TMP112_CONV_RATE_SHIFT) 32 33 #define TMP112_CONV_RES_SHIFT 13 34 #define TMP112_CONV_RES_MASK (BIT_MASK(2) << TMP112_CONV_RES_SHIFT) 35 36 #define TMP112_ONE_SHOT BIT(15) 37 38 #define TMP112_REG_TLOW 0x02 39 #define TMP112_REG_THIGH 0x03 40 41 /* scale in micro degrees Celsius */ 42 #define TMP112_TEMP_SCALE 62500 43 44 /* RAW min/max temperature values - LSB=TMP112_TEMP_SCALE */ 45 /* 128C */ 46 #define TMP112_TEMP_MAX 2047 47 /* -55C */ 48 #define TMP112_TEMP_MIN -880 49 /* 150C */ 50 #define TMP112_TEMP_MAX_EM 2400 51 /* -55C */ 52 #define TMP112_TEMP_MIN_EM TMP112_TEMP_MIN 53 54 struct tmp112_data { 55 int16_t sample; 56 uint16_t config_reg; 57 }; 58 59 struct tmp112_config { 60 const struct i2c_dt_spec bus; 61 uint8_t cr; 62 int32_t t_low_micro_c; 63 int32_t t_high_micro_c; 64 bool extended_mode : 1; 65 }; 66 67 #endif 68