All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jagath Jog J <jagathjog1996@gmail.com>
To: dan@dlrobertson.com, jic23@kernel.org, andy.shevchenko@gmail.com
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v5 01/10] iio: accel: bma400: Fix the scale min and max macro values
Date: Thu,  5 May 2022 19:00:12 +0530	[thread overview]
Message-ID: <20220505133021.22362-2-jagathjog1996@gmail.com> (raw)
In-Reply-To: <20220505133021.22362-1-jagathjog1996@gmail.com>

Changing the scale macro values to match the bma400 sensitivity
for 1 LSB of all the available ranges.

Fixes: 465c811f1f20 ("iio: accel: Add driver for the BMA400")
Signed-off-by: Jagath Jog J <jagathjog1996@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/iio/accel/bma400.h | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/accel/bma400.h b/drivers/iio/accel/bma400.h
index c4c8d74155c2..80330c7ce17f 100644
--- a/drivers/iio/accel/bma400.h
+++ b/drivers/iio/accel/bma400.h
@@ -83,8 +83,27 @@
 #define BMA400_ACC_ODR_MIN_WHOLE_HZ 25
 #define BMA400_ACC_ODR_MIN_HZ       12
 
-#define BMA400_SCALE_MIN            38357
-#define BMA400_SCALE_MAX            306864
+/*
+ * BMA400_SCALE_MIN macro value represents m/s^2 for 1 LSB before
+ * converting to micro values for +-2g range.
+ *
+ * For +-2g - 1 LSB = 0.976562 milli g = 0.009576 m/s^2
+ * For +-4g - 1 LSB = 1.953125 milli g = 0.019153 m/s^2
+ * For +-16g - 1 LSB = 7.8125 milli g = 0.076614 m/s^2
+ *
+ * The raw value which is used to select the different ranges is determined
+ * by the first bit set position from the scale value, so BMA400_SCALE_MIN
+ * should be odd.
+ *
+ * Scale values for +-2g, +-4g, +-8g and +-16g are populated into bma400_scales
+ * array by left shifting BMA400_SCALE_MIN.
+ * e.g.:
+ * To select +-2g = 9577 << 0 = raw value to write is 0.
+ * To select +-8g = 9577 << 2 = raw value to write is 2.
+ * To select +-16g = 9577 << 3 = raw value to write is 3.
+ */
+#define BMA400_SCALE_MIN            9577
+#define BMA400_SCALE_MAX            76617
 
 #define BMA400_NUM_REGULATORS       2
 #define BMA400_VDD_REGULATOR        0
-- 
2.17.1


  reply	other threads:[~2022-05-05 13:30 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-05 13:30 [PATCH v5 00/10] iio: accel: bma400: Add buffer, step and activity/inactivity Jagath Jog J
2022-05-05 13:30 ` Jagath Jog J [this message]
2022-05-05 13:30 ` [PATCH v5 02/10] iio: accel: bma400: Reordering of header files Jagath Jog J
2022-05-05 13:30 ` [PATCH v5 03/10] iio: accel: bma400: conversion to device-managed function Jagath Jog J
2022-05-05 13:30 ` [PATCH v5 04/10] iio: accel: bma400: Add triggered buffer support Jagath Jog J
2022-05-05 13:30 ` [PATCH v5 05/10] iio: accel: bma400: Add separate channel for step counter Jagath Jog J
2022-05-07 16:09   ` Jonathan Cameron
2022-05-05 13:30 ` [PATCH v5 06/10] iio: accel: bma400: Add step change event Jagath Jog J
2022-05-05 13:30 ` [PATCH v5 07/10] iio: accel: bma400: Add activity recognition support Jagath Jog J
2022-05-05 13:30 ` [PATCH v5 08/10] iio: accel: bma400: Add support for activity and inactivity events Jagath Jog J
2022-05-07 16:13   ` Jonathan Cameron
2022-05-05 13:30 ` [PATCH v5 09/10] iio: Add channel for tap and new modifiers for single and double tap Jagath Jog J
2022-05-07 16:24   ` Jonathan Cameron
2022-05-09  5:11     ` Jagath Jog J
2022-05-05 13:30 ` [PATCH v5 10/10] iio: accel: bma400: Add support for single and double tap events Jagath Jog J

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220505133021.22362-2-jagathjog1996@gmail.com \
    --to=jagathjog1996@gmail.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=dan@dlrobertson.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.