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.

iio: accel: adxl345: set the tap suppress bit permanently

Set the suppress bit feature to the double tap detection, whenever
double tap is enabled. This impedes the suppress bit dangling in any
state, and thus varying in sensitivity for double tap detection.

Any tap event is defined by a rising signal edge above threshold, i.e.
duration time starts counting; and the falling edge under threshold
within duration time, i.e. then the tap event is issued. This means
duration is used individually for each tap event.

For double tap detection after a single tap, a latency time needs to be
specified. Usually tap events, i.e. spikes above and returning below
threshold will be ignored within latency. After latency, the window
time starts counting for a second tap detection which has to happen
within a duration time.

If the suppress bit is not set, spikes within latency time are ignored.
Setting the suppress bit will invalidate the double tap function. The
sensor will thus be able to save the window time for double tap
detection, and follow a more strict definition of what signal qualifies
for a double tap.

In a summary having the suppress bit set, fewer signal spikes will be
considered as double taps. This is an optional add on to double tap,
thus a separate patch.

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
Link: https://patch.msgid.link/20250414184245.100280-5-l.rubusch@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Lothar Rubusch and committed by
Jonathan Cameron
0c2cdd1a 5b307f5a

+14
+14
drivers/iio/accel/adxl345_core.c
··· 34 34 #define ADXL345_INT2 1 35 35 36 36 #define ADXL345_REG_TAP_AXIS_MSK GENMASK(2, 0) 37 + #define ADXL345_REG_TAP_SUPPRESS_MSK BIT(3) 38 + #define ADXL345_REG_TAP_SUPPRESS BIT(3) 37 39 38 40 #define ADXL345_TAP_Z_EN BIT(0) 39 41 #define ADXL345_TAP_Y_EN BIT(1) ··· 297 295 298 296 static int adxl345_set_doubletap_en(struct adxl345_state *st, bool en) 299 297 { 298 + int ret; 299 + 300 + /* 301 + * Generally suppress detection of spikes during the latency period as 302 + * double taps here, this is fully optional for double tap detection 303 + */ 304 + ret = regmap_update_bits(st->regmap, ADXL345_REG_TAP_AXIS, 305 + ADXL345_REG_TAP_SUPPRESS_MSK, 306 + en ? ADXL345_REG_TAP_SUPPRESS : 0x00); 307 + if (ret) 308 + return ret; 309 + 300 310 return _adxl345_set_tap_int(st, ADXL345_DOUBLE_TAP, en); 301 311 } 302 312