18
18
19
19
LOG_MODULE_REGISTER (TMP112 , CONFIG_SENSOR_LOG_LEVEL );
20
20
21
- static int tmp112_reg_read (const struct tmp112_config * cfg ,
22
- uint8_t reg , uint16_t * val )
21
+ static int tmp112_reg_read (const struct tmp112_config * cfg , uint8_t reg , uint16_t * val )
23
22
{
24
23
if (i2c_burst_read_dt (& cfg -> bus , reg , (uint8_t * )val , sizeof (* val )) < 0 ) {
25
24
return - EIO ;
@@ -30,8 +29,7 @@ static int tmp112_reg_read(const struct tmp112_config *cfg,
30
29
return 0 ;
31
30
}
32
31
33
- static int tmp112_reg_write (const struct tmp112_config * cfg ,
34
- uint8_t reg , uint16_t val )
32
+ static int tmp112_reg_write (const struct tmp112_config * cfg , uint8_t reg , uint16_t val )
35
33
{
36
34
uint8_t buf [3 ];
37
35
@@ -41,14 +39,12 @@ static int tmp112_reg_write(const struct tmp112_config *cfg,
41
39
return i2c_write_dt (& cfg -> bus , buf , sizeof (buf ));
42
40
}
43
41
44
- static uint16_t set_config_flags (struct tmp112_data * data , uint16_t mask ,
45
- uint16_t value )
42
+ static uint16_t set_config_flags (struct tmp112_data * data , uint16_t mask , uint16_t value )
46
43
{
47
44
return (data -> config_reg & ~mask ) | (value & mask );
48
45
}
49
46
50
- static int tmp112_update_config (const struct device * dev , uint16_t mask ,
51
- uint16_t val )
47
+ static int tmp112_update_config (const struct device * dev , uint16_t mask , uint16_t val )
52
48
{
53
49
int rc ;
54
50
struct tmp112_data * data = dev -> data ;
@@ -62,10 +58,8 @@ static int tmp112_update_config(const struct device *dev, uint16_t mask,
62
58
return rc ;
63
59
}
64
60
65
- static int tmp112_attr_set (const struct device * dev ,
66
- enum sensor_channel chan ,
67
- enum sensor_attribute attr ,
68
- const struct sensor_value * val )
61
+ static int tmp112_attr_set (const struct device * dev , enum sensor_channel chan ,
62
+ enum sensor_attribute attr , const struct sensor_value * val )
69
63
{
70
64
uint16_t value ;
71
65
uint16_t cr ;
@@ -136,8 +130,7 @@ static int tmp112_attr_set(const struct device *dev,
136
130
return 0 ;
137
131
}
138
132
139
- static int tmp112_sample_fetch (const struct device * dev ,
140
- enum sensor_channel chan )
133
+ static int tmp112_sample_fetch (const struct device * dev , enum sensor_channel chan )
141
134
{
142
135
struct tmp112_data * drv_data = dev -> data ;
143
136
const struct tmp112_config * cfg = dev -> config ;
@@ -150,18 +143,15 @@ static int tmp112_sample_fetch(const struct device *dev,
150
143
}
151
144
152
145
if (val & TMP112_DATA_EXTENDED ) {
153
- drv_data -> sample = arithmetic_shift_right ((int16_t )val ,
154
- TMP112_DATA_EXTENDED_SHIFT );
146
+ drv_data -> sample = arithmetic_shift_right ((int16_t )val , TMP112_DATA_EXTENDED_SHIFT );
155
147
} else {
156
- drv_data -> sample = arithmetic_shift_right ((int16_t )val ,
157
- TMP112_DATA_NORMAL_SHIFT );
148
+ drv_data -> sample = arithmetic_shift_right ((int16_t )val , TMP112_DATA_NORMAL_SHIFT );
158
149
}
159
150
160
151
return 0 ;
161
152
}
162
153
163
- static int tmp112_channel_get (const struct device * dev ,
164
- enum sensor_channel chan ,
154
+ static int tmp112_channel_get (const struct device * dev , enum sensor_channel chan ,
165
155
struct sensor_value * val )
166
156
{
167
157
struct tmp112_data * drv_data = dev -> data ;
@@ -194,23 +184,22 @@ int tmp112_init(const struct device *dev)
194
184
return - EINVAL ;
195
185
}
196
186
197
- data -> config_reg = TMP112_CONV_RATE (cfg -> cr ) | TMP112_CONV_RES_MASK
198
- | (cfg -> extended_mode ? TMP112_CONFIG_EM : 0 );
187
+ data -> config_reg = TMP112_CONV_RATE (cfg -> cr ) | TMP112_CONV_RES_MASK |
188
+ (cfg -> extended_mode ? TMP112_CONFIG_EM : 0 );
199
189
200
190
return tmp112_update_config (dev , 0 , 0 );
201
191
}
202
192
203
-
204
- #define TMP112_INST (inst ) \
205
- static struct tmp112_data tmp112_data_##inst; \
206
- static const struct tmp112_config tmp112_config_##inst = { \
207
- .bus = I2C_DT_SPEC_INST_GET(inst), \
208
- .cr = DT_INST_ENUM_IDX(inst, conversion_rate), \
209
- .extended_mode = DT_INST_PROP(inst, extended_mode), \
210
- }; \
211
- \
212
- SENSOR_DEVICE_DT_INST_DEFINE(inst, tmp112_init, NULL, &tmp112_data_##inst, \
213
- &tmp112_config_##inst, POST_KERNEL, \
214
- CONFIG_SENSOR_INIT_PRIORITY, &tmp112_driver_api);
193
+ #define TMP112_INST (inst ) \
194
+ static struct tmp112_data tmp112_data_##inst; \
195
+ static const struct tmp112_config tmp112_config_##inst = { \
196
+ .bus = I2C_DT_SPEC_INST_GET(inst), \
197
+ .cr = DT_INST_ENUM_IDX(inst, conversion_rate), \
198
+ .extended_mode = DT_INST_PROP(inst, extended_mode), \
199
+ }; \
200
+ \
201
+ SENSOR_DEVICE_DT_INST_DEFINE(inst, tmp112_init, NULL, &tmp112_data_##inst, \
202
+ &tmp112_config_##inst, POST_KERNEL, \
203
+ CONFIG_SENSOR_INIT_PRIORITY, &tmp112_driver_api);
215
204
216
205
DT_INST_FOREACH_STATUS_OKAY (TMP112_INST )
0 commit comments