zephyr icon indicating copy to clipboard operation
zephyr copied to clipboard

LIS2DH tap interrupt never fires

Open MaxMaeder opened this issue 2 months ago • 20 comments

Describe the bug I've modified the lis2dh sample to detect taps, and I can't get it to detect anything, as in my handler never fires.

Please also mention any information which could help others to understand the problem you're facing:

  • What target platform are you using? nrf9160
  • What have you tried to diagnose or workaround this issue? I have tried to use different device DT configurations, such as specifying anym-on-int1. I've also tried to narrow down the issue in the driver source code, but have yet to find it.

I've also tried incorporating changes proposed by #71229, with no luck.

To Reproduce

CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
CONFIG_I2C=y
CONFIG_SENSOR=y
CONFIG_LIS2DH=y
CONFIG_LIS2DH_TRIGGER_GLOBAL_THREAD=y
#include <stdio.h>
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/drivers/sensor.h>

static void trigger_handler(const struct device *dev,
                            const struct sensor_trigger *trig)
{
    printf("TRIG\n");
}

int main(void)
{
    const struct device *sensor = DEVICE_DT_GET(DT_ALIAS(accel0));

    if (sensor == NULL || !device_is_ready(sensor))
    {
        printf("Could not get accel0 device\n");
        return -ENODEV;
    }

    struct sensor_trigger trig;
    int rc;

    trig.type = SENSOR_TRIG_TAP;
    rc = sensor_trigger_set(sensor, &trig, trigger_handler);
    if (rc != 0)
    {
        printf("Failed to set trigger: %d\n", rc);
        return rc;
    }

    printf("Waiting for triggers\n");
    while (true)
    {
        k_sleep(K_MSEC(2000));
    }

    return 0;
}

Build, run, and see error (no output on taps).

Expected behavior "TRIG" printed every time sensor tapped.

Impact Unable to use the sensor for my intended application.

Environment (please complete the following information): MacOS Nordic SDK v2.6.0, latest

Additional context Original PR which implemented feature: #62498 Reached out to PR author, no longer has access to code where he used tap interrupt. @avisconti I know you approved the original PR, mind having a look?

MaxMaeder avatar Apr 16 '24 16:04 MaxMaeder