1 /*
2  * Copyright (c) 2019 Centaur Analytics, Inc
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef ZEPHYR_DRIVERS_SENSOR_TMP116_TMP116_H_
8 #define ZEPHYR_DRIVERS_SENSOR_TMP116_TMP116_H_
9 
10 #include <zephyr/sys/util_macro.h>
11 
12 #define TMP116_REG_TEMP		0x0
13 #define TMP116_REG_CFGR		0x1
14 #define TMP116_REG_HIGH_LIM		0x2
15 #define TMP116_REG_LOW_LIM		0x3
16 #define TMP116_REG_EEPROM_UL		0x4
17 #define TMP116_REG_EEPROM1		0x5
18 #define TMP116_REG_EEPROM2		0x6
19 #define TMP116_REG_EEPROM3		0x7
20 #define TMP117_REG_TEMP_OFFSET		0x7
21 #define TMP116_REG_EEPROM4		0x8
22 #define TMP116_REG_DEVICE_ID		0xF
23 
24 #define TMP116_RESOLUTION		78125       /* in tens of uCelsius*/
25 #define TMP116_RESOLUTION_DIV		10000000
26 
27 #define TMP116_DEVICE_ID		0x1116
28 #define TMP117_DEVICE_ID		0x0117
29 
30 #define TMP116_CFGR_AVG			(BIT(5) | BIT(6))
31 #define TMP116_CFGR_CONV		(BIT(7) | BIT(8) | BIT(9))
32 #define TMP116_CFGR_MODE		(BIT(10) | BIT(11))
33 #define TMP116_CFGR_DATA_READY  BIT(13)
34 #define TMP116_EEPROM_UL_UNLOCK BIT(15)
35 #define TMP116_EEPROM_UL_BUSY   BIT(14)
36 
37 #define TMP116_AVG_1_SAMPLE		0
38 #define TMP116_AVG_8_SAMPLES	BIT(5)
39 #define TMP116_AVG_32_SAMPLES	BIT(6)
40 #define TMP116_AVG_64_SAMPLES	(BIT(5) | BIT(6))
41 #define TMP116_MODE_CONTINUOUS	0
42 #define TMP116_MODE_SHUTDOWN	BIT(10)
43 #define TMP116_MODE_ONE_SHOT	(BIT(10) | BIT(11))
44 
45 struct tmp116_data {
46 	uint16_t sample;
47 	uint16_t id;
48 };
49 
50 struct tmp116_dev_config {
51 	struct i2c_dt_spec bus;
52 	uint16_t odr;
53 };
54 
55 #endif /*  ZEPHYR_DRIVERS_SENSOR_TMP116_TMP116_H_ */
56