1 /*
2  * Copyright (c) 2024 Bittium Corporation
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef ZEPHYR_DRIVERS_SENSOR_TMP435_H_
8 #define ZEPHYR_DRIVERS_SENSOR_TMP435_H_
9 
10 #define TMP435_CONF_REG_1         0x03
11 #define TMP435_CONF_REG_1_DATA    0xc4
12 /* [7]=1 ALERT Masked, [6]=1 Shut Down (one shot mode), [2]=1 −55 C to +150 C */
13 #define TMP435_CONF_REG_2         0x1a
14 #define TMP435_CONF_REG_2_REN     0x10 /* [4]=1 External channel 1 enabled */
15 #define TMP435_CONF_REG_2_RC      0x04 /* [2]=1 Resistance correction enabled */
16 #define TMP435_CONF_REG_2_DATA    0x08 /* [3]=1 Local channel enabled */
17 #define TMP435_BETA_RANGE_REG     0x25
18 #define TMP435_STATUS_REG         0x02
19 #define TMP435_STATUS_REG_BUSY    0x80 /* conv not ready */
20 #define TMP435_SOFTWARE_RESET_REG 0xfc
21 #define TMP435_ONE_SHOT_START_REG 0x0f
22 #define TMP435_LOCAL_TEMP_H_REG   0x00
23 #define TMP435_LOCAL_TEMP_L_REG   0x15
24 #define TMP435_REMOTE_TEMP_H_REG  0x01
25 #define TMP435_REMOTE_TEMP_L_REG  0x10
26 
27 #define TMP435_CONV_LOOP_LIMIT 50   /* max 50*10 ms */
28 #define TMP435_FRACTION_INC    0x80 /* 0.5000 */
29 
30 static const int32_t tmp435_temp_offset = -64;
31 
32 struct tmp435_data {
33 	int32_t temp_die;     /* Celsius degrees */
34 	int32_t temp_ambient; /* Celsius degrees */
35 };
36 
37 struct tmp435_config {
38 	struct i2c_dt_spec i2c;
39 	bool external_channel;
40 	bool resistance_correction;
41 	uint8_t beta_compensation;
42 };
43 
44 #endif /* ZEPHYR_DRIVERS_SENSOR_TMP435_H_ */
45