@@ -393,17 +393,17 @@ static const unsigned int kx022a_odrs[] = {
393
393
* (range / 2^bits) * g = (range / 2^bits) * 9.80665 m/s^2
394
394
* => KX022A uses 16 bit (HiRes mode - assume the low 8 bits are zeroed
395
395
* in low-power mode(?) )
396
- * => +/-2G => 4 / 2^16 * 9,80665 * 10^6 (to scale to micro)
397
- * => +/-2G - 598.550415
398
- * +/-4G - 1197.10083
399
- * +/-8G - 2394.20166
400
- * +/-16G - 4788.40332
396
+ * => +/-2G => 4 / 2^16 * 9,80665
397
+ * => +/-2G - 0.000598550415
398
+ * +/-4G - 0.00119710083
399
+ * +/-8G - 0.00239420166
400
+ * +/-16G - 0.00478840332
401
401
*/
402
402
static const int kx022a_scale_table [][2 ] = {
403
- { 598 , 550415 },
404
- { 1197 , 100830 },
405
- { 2394 , 201660 },
406
- { 4788 , 403320 },
403
+ { 0 , 598550 },
404
+ { 0 , 1197101 },
405
+ { 0 , 2394202 },
406
+ { 0 , 4788403 },
407
407
};
408
408
409
409
static int kx022a_read_avail (struct iio_dev * indio_dev ,
@@ -422,7 +422,7 @@ static int kx022a_read_avail(struct iio_dev *indio_dev,
422
422
* vals = (const int * )kx022a_scale_table ;
423
423
* length = ARRAY_SIZE (kx022a_scale_table ) *
424
424
ARRAY_SIZE (kx022a_scale_table [0 ]);
425
- * type = IIO_VAL_INT_PLUS_MICRO ;
425
+ * type = IIO_VAL_INT_PLUS_NANO ;
426
426
return IIO_AVAIL_LIST ;
427
427
default :
428
428
return - EINVAL ;
@@ -485,6 +485,20 @@ static int kx022a_turn_on_unlock(struct kx022a_data *data)
485
485
return ret ;
486
486
}
487
487
488
+ static int kx022a_write_raw_get_fmt (struct iio_dev * idev ,
489
+ struct iio_chan_spec const * chan ,
490
+ long mask )
491
+ {
492
+ switch (mask ) {
493
+ case IIO_CHAN_INFO_SCALE :
494
+ return IIO_VAL_INT_PLUS_NANO ;
495
+ case IIO_CHAN_INFO_SAMP_FREQ :
496
+ return IIO_VAL_INT_PLUS_MICRO ;
497
+ default :
498
+ return - EINVAL ;
499
+ }
500
+ }
501
+
488
502
static int kx022a_write_raw (struct iio_dev * idev ,
489
503
struct iio_chan_spec const * chan ,
490
504
int val , int val2 , long mask )
@@ -629,7 +643,7 @@ static int kx022a_read_raw(struct iio_dev *idev,
629
643
630
644
kx022a_reg2scale (regval , val , val2 );
631
645
632
- return IIO_VAL_INT_PLUS_MICRO ;
646
+ return IIO_VAL_INT_PLUS_NANO ;
633
647
}
634
648
635
649
return - EINVAL ;
@@ -856,6 +870,7 @@ static int kx022a_fifo_flush(struct iio_dev *idev, unsigned int samples)
856
870
static const struct iio_info kx022a_info = {
857
871
.read_raw = & kx022a_read_raw ,
858
872
.write_raw = & kx022a_write_raw ,
873
+ .write_raw_get_fmt = & kx022a_write_raw_get_fmt ,
859
874
.read_avail = & kx022a_read_avail ,
860
875
861
876
.validate_trigger = iio_validate_own_trigger ,
0 commit comments