@@ -236,6 +236,22 @@ static int lis2dw12_set_power_mode(const struct device *dev,
236
236
return lis2dw12_write_reg (ctx , LIS2DW12_CTRL1 , & regval , 1 );
237
237
}
238
238
239
+ static int lis2dw12_set_low_noise (const struct device * dev ,
240
+ bool low_noise )
241
+ {
242
+ const struct lis2dw12_device_config * cfg = dev -> config ;
243
+ stmdev_ctx_t * ctx = (stmdev_ctx_t * )& cfg -> ctx ;
244
+ lis2dw12_ctrl6_t ctrl6 ;
245
+ int ret ;
246
+
247
+ ret = lis2dw12_read_reg (ctx , LIS2DW12_CTRL6 , (uint8_t * )& ctrl6 , 1 );
248
+ if (ret < 0 ) {
249
+ return ret ;
250
+ }
251
+ ctrl6 .low_noise = low_noise ;
252
+ return lis2dw12_write_reg (ctx , LIS2DW12_CTRL6 , (uint8_t * )& ctrl6 , 1 );
253
+ }
254
+
239
255
static int lis2dw12_init (const struct device * dev )
240
256
{
241
257
const struct lis2dw12_device_config * cfg = dev -> config ;
@@ -271,8 +287,16 @@ static int lis2dw12_init(const struct device *dev)
271
287
272
288
/* set power mode */
273
289
LOG_DBG ("power-mode is %d" , cfg -> pm );
274
- if (lis2dw12_set_power_mode (dev , cfg -> pm )) {
275
- return - EIO ;
290
+ ret = lis2dw12_set_power_mode (dev , cfg -> pm );
291
+ if (ret < 0 ) {
292
+ return ret ;
293
+ }
294
+
295
+ LOG_DBG ("low noise is %d" , cfg -> low_noise );
296
+ ret = lis2dw12_set_low_noise (dev , cfg -> low_noise );
297
+ if (ret < 0 ) {
298
+ LOG_ERR ("Failed to configure low_noise" );
299
+ return ret ;
276
300
}
277
301
278
302
/* set default odr to 12.5Hz acc */
@@ -293,9 +317,10 @@ static int lis2dw12_init(const struct device *dev)
293
317
lis2dw12_filter_bandwidth_set (ctx , cfg -> bw_filt );
294
318
295
319
#ifdef CONFIG_LIS2DW12_TRIGGER
296
- if (lis2dw12_init_interrupt (dev ) < 0 ) {
320
+ ret = lis2dw12_init_interrupt (dev );
321
+ if (ret < 0 ) {
297
322
LOG_ERR ("Failed to initialize interrupts" );
298
- return - EIO ;
323
+ return ret ;
299
324
}
300
325
#endif /* CONFIG_LIS2DW12_TRIGGER */
301
326
@@ -367,6 +392,7 @@ static int lis2dw12_init(const struct device *dev)
367
392
.pm = DT_INST_PROP(inst, power_mode), \
368
393
.range = DT_INST_PROP(inst, range), \
369
394
.bw_filt = DT_INST_PROP(inst, bw_filt), \
395
+ .low_noise = DT_INST_PROP(inst, low_noise), \
370
396
LIS2DW12_CONFIG_TAP(inst) \
371
397
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, irq_gpios), \
372
398
(LIS2DW12_CFG_IRQ(inst)), ()) \
@@ -392,6 +418,7 @@ static int lis2dw12_init(const struct device *dev)
392
418
.pm = DT_INST_PROP(inst, power_mode), \
393
419
.range = DT_INST_PROP(inst, range), \
394
420
.bw_filt = DT_INST_PROP(inst, bw_filt), \
421
+ .low_noise = DT_INST_PROP(inst, low_noise), \
395
422
LIS2DW12_CONFIG_TAP(inst) \
396
423
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, irq_gpios), \
397
424
(LIS2DW12_CFG_IRQ(inst)), ()) \
0 commit comments