[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aHYFMf8QGDNt-5Nf@smile.fi.intel.com>
Date: Tue, 15 Jul 2025 10:37:21 +0300
From: Andy Shevchenko <andriy.shevchenko@...el.com>
To: Gustavo Silva <gustavograzs@...il.com>
Cc: Alex Lanzano <lanzano.alex@...il.com>,
Jonathan Cameron <jic23@...nel.org>,
David Lechner <dlechner@...libre.com>,
Nuno Sá <nuno.sa@...log.com>,
Andy Shevchenko <andy@...nel.org>, linux-iio@...r.kernel.org,
linux-kernel@...r.kernel.org, Lothar Rubusch <l.rubusch@...il.com>
Subject: Re: [PATCH v4 3/3] iio: imu: bmi270: add support for motion events
On Fri, Jul 11, 2025 at 08:36:03PM -0300, Gustavo Silva wrote:
> Any-motion event can be enabled on a per-axis basis and triggers a
> combined event when motion is detected on any axis.
>
> No-motion event is triggered if the rate of change on all axes falls
> below a specified threshold for a configurable duration. A fake channel
> is used to report this event.
>
> Threshold and duration can be configured from userspace.
...
> +/* 9.81 * 1000000 m/s^2 */
> +#define BMI270_G_MEGA_M_S_2 9810000
I thought this is MICRO...
...
> +#define BMI270_INT_MICRO_TO_RAW(val, val2, scale) \
> + ((val) * (scale) + ((val2) * (scale)) / MEGA)
Side note: Perhaps good candidate to have it in math.h
(AFAIR there are more users of the same.)
> +#define BMI270_RAW_TO_MICRO(raw, scale) \
> + ((((raw) % (scale)) * MEGA) / scale)
...
> +static ssize_t bmi270_show_accel_value_avail(struct device *dev,
> + struct device_attribute *attr,
> + char *buf)
> +{
> + struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> + struct bmi270_data *data = iio_priv(indio_dev);
> + int ret, scale, uscale;
> + unsigned int step, max;
> +
> + ret = bmi270_get_scale(data, IIO_ACCEL, &scale, &uscale);
> + if (ret)
> + return ret;
> +
> + max = BMI270_G_MEGA_M_S_2 / uscale;
...as here we divide 10^6/10^-6 semantically speaking.
> + step = max / BMI270_MOTION_THRES_FULL_SCALE;
> +
> + return sysfs_emit(buf, "[0 %u %u]\n", step, max);
> +}
Is this already documented in ABI?
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists