Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

docs: iio: adxl345: update event attributes and scaling math

Update the documentation to reflect the recent driver additions for
event scaling and the double tap threshold value, alongside correcting
existing technical errors in scale calculations.

Key changes:
- Fix the 62.5 g/LSB typo to 62.5 mg/LSB and add SI unit conversion.
- Correct decimal precision of in_accel_scale and
in_accel_scale_available to match the actual SI unit (m/s^2)
values reported by the driver.
- Document the newly generated event scale attributes in the ABI table
(e.g., in_accel_mag_rising_scale, in_accel_gesture_singletap_scale).
- Document the newly exposed in_accel_gesture_doubletap_value attribute.
- Add a sysfs example showing how to read and interpret the newly
implemented event scale factor.

Suggested-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Taha Ed-Dafili <0rayn.dev@gmail.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Taha Ed-Dafili and committed by
Jonathan Cameron
d6bd0e27 9fb00770

+37 -14
+37 -14
Documentation/iio/adxl345.rst
··· 13 13 * `ADXL375 <https://www.analog.com/ADXL375>`_ 14 14 15 15 The ADXL345 is a general-purpose, low-power, 3-axis accelerometer with selectable 16 - measurement ranges. The ADXL345 supports the ±2 g, ±4 g, ±8 g, and ±16 g ranges. 16 + measurement ranges. The ADXL345 supports the following ranges: 17 + 18 + - ±2g (approx. ±19.61 m/s^2) 19 + - ±4g (approx. ±39.23 m/s^2) 20 + - ±8g (approx. ±78.45 m/s^2) 21 + - ±16g (approx. ±156.91 m/s^2) 17 22 18 23 2. Device Attributes 19 24 ==================== ··· 99 94 +---------------------------------------------+---------------------------------------------+ 100 95 | in_accel_gesture_doubletap_reset_timeout | Double tap window in [us] | 101 96 +---------------------------------------------+---------------------------------------------+ 97 + | in_accel_gesture_doubletap_scale | Double tap gesture threshold scale. | 98 + +---------------------------------------------+---------------------------------------------+ 102 99 | in_accel_gesture_doubletap_tap2_min_delay | Double tap latency in [us] | 100 + +---------------------------------------------+---------------------------------------------+ 101 + | in_accel_gesture_doubletap_value | Double tap threshold value | 102 + +---------------------------------------------+---------------------------------------------+ 103 + | in_accel_gesture_singletap_scale | Single tap gesture threshold scale. | 103 104 +---------------------------------------------+---------------------------------------------+ 104 105 | in_accel_gesture_singletap_timeout | Single tap duration in [us] | 105 106 +---------------------------------------------+---------------------------------------------+ 106 - | in_accel_gesture_singletap_value | Single tap threshold value in 62.5/LSB | 107 + | in_accel_gesture_singletap_value | Single tap threshold value | 107 108 +---------------------------------------------+---------------------------------------------+ 108 109 | in_accel_mag_adaptive_falling_period | AC coupled inactivity time in seconds | 109 110 +---------------------------------------------+---------------------------------------------+ 110 - | in_accel_mag_adaptive_falling_value | AC coupled inactivity threshold in 62.5/LSB | 111 + | in_accel_mag_adaptive_falling_scale | AC coupled inactivity threshold scale. | 112 + +---------------------------------------------+---------------------------------------------+ 113 + | in_accel_mag_adaptive_falling_value | AC coupled inactivity threshold | 111 114 +---------------------------------------------+---------------------------------------------+ 112 115 | in_accel_mag_adaptive_rising_en | Enable AC coupled activity on X axis | 113 116 +---------------------------------------------+---------------------------------------------+ 114 - | in_accel_mag_adaptive_rising_value | AC coupled activity threshold in 62.5/LSB | 117 + | in_accel_mag_adaptive_rising_scale | AC coupled activity threshold scale. | 118 + +---------------------------------------------+---------------------------------------------+ 119 + | in_accel_mag_adaptive_rising_value | AC coupled activity threshold | 115 120 +---------------------------------------------+---------------------------------------------+ 116 121 | in_accel_mag_falling_period | Inactivity time in seconds | 117 122 +---------------------------------------------+---------------------------------------------+ 118 - | in_accel_mag_falling_value | Inactivity threshold value in 62.5/LSB | 123 + | in_accel_mag_falling_scale | DC coupled inactivity threshold scale. | 124 + +---------------------------------------------+---------------------------------------------+ 125 + | in_accel_mag_falling_value | Inactivity threshold value | 119 126 +---------------------------------------------+---------------------------------------------+ 120 127 | in_accel_mag_rising_en | Enable activity detection on X axis | 121 128 +---------------------------------------------+---------------------------------------------+ 122 - | in_accel_mag_rising_value | Activity threshold value in 62.5/LSB | 129 + | in_accel_mag_rising_scale | DC coupled activity threshold scale. | 130 + +---------------------------------------------+---------------------------------------------+ 131 + | in_accel_mag_rising_value | Activity threshold value | 123 132 +---------------------------------------------+---------------------------------------------+ 124 133 | in_accel_x&y&z_mag_adaptive_falling_en | Enable AC coupled inactivity on all axes | 125 134 +---------------------------------------------+---------------------------------------------+ ··· 159 140 appropriate activity and inactivity thresholds by scaling the default values 160 141 based on the ratio of the previous range to the new one. The resulting threshold 161 142 will never be zero and will always fall between 1 and 255, corresponding to up 162 - to 62.5 g/LSB as specified in the datasheet. However, you can override these 163 - estimated thresholds by setting explicit values. 143 + to 62.5 mg/LSB (0.612915 m/s^2/LSB) as specified in the datasheet. However, 144 + you can override these estimated thresholds by setting explicit values. 164 145 165 146 When **activity** and **inactivity** events are enabled, the driver 166 147 automatically manages hysteresis behavior by setting the **link** and ··· 289 270 .. code-block:: bash 290 271 291 272 root:/sys/bus/iio/devices/iio:device0> cat ./in_accel_scale 292 - 0.478899 273 + 0.004789 293 274 root:/sys/bus/iio/devices/iio:device0> cat ./in_accel_scale_available 294 - 0.478899 0.957798 1.915595 3.831190 275 + 0.004789 0.009578 0.019156 0.038312 295 276 296 - root:/sys/bus/iio/devices/iio:device0> echo 1.915595 > ./in_accel_scale 277 + root:/sys/bus/iio/devices/iio:device0> echo 0.019156 > ./in_accel_scale 297 278 root:/sys/bus/iio/devices/iio:device0> cat ./in_accel_scale 298 - 1.915595 279 + 0.019156 299 280 300 281 Set output data rate (ODR): 301 282 ··· 331 312 332 313 root:/sys/bus/iio/devices/iio:device0> echo 24 > ./buffer0/length 333 314 334 - ## AC coupled activity, threshold [62.5/LSB] 315 + ## Check the event scale factor (0.0625 * 9.80665) 316 + root:/sys/bus/iio/devices/iio:device0> cat ./events/in_accel_gesture_doubletap_scale 317 + 0.612915 318 + 319 + ## AC coupled activity, threshold [0.612915 m/s^2/LSB] 335 320 root:/sys/bus/iio/devices/iio:device0> echo 6 > ./events/in_accel_mag_adaptive_rising_value 336 321 337 - ## AC coupled inactivity, threshold, [62.5/LSB] 322 + ## AC coupled inactivity, threshold, [0.612915 m/s^2/LSB] 338 323 root:/sys/bus/iio/devices/iio:device0> echo 4 > ./events/in_accel_mag_adaptive_falling_value 339 324 340 325 ## AC coupled inactivity, time [s]