• Linus Walleij's avatar
    iio: accel: kxsd9: Add triggered buffer handling · 0427a106
    Linus Walleij authored
    As is custom with all modern sensors, add a clever burst mode
    that will just stream out values from the sensor and provide it
    to userspace to do the proper offsetting and scaling.
    
    This is the result when tested with an HRTimer trigger:
    
    $ generic_buffer -a -c 10 -n kxsd9 -t foo
    /sys/bus/iio/devices/iio:device1 foo
    0.371318 0.718680 9.869872 1795.000000 97545896129
    -0.586922 0.179670 9.378775 2398.000000 97555864721
    -0.299450 0.179670 10.348992 2672.000000 97565874055
    0.371318 0.335384 11.103606 2816.000000 97575883240
    0.179670 0.574944 10.540640 2847.000000 97585862351
    0.335384 0.754614 9.953718 2840.000000 97595872425
    0.179670 0.754614 10.732288 2879.000000 97605882351
    0.000000 0.754614 10.348992 2872.000000 97615891832
    -0.730658 0.574944 9.570422 2831.000000 97625871536
    0.000000 1.137910 10.732288 2872.000000 97635881610
    
    Columns shown are x, y, z acceleration, so a positive acceleration
    of ~9.81 (shaky due to bad calibration) along the z axis. The
    fourth column is the AUX IN which is floating on this system,
    it seems to float up to the 2.85V VDD voltage.
    
    To be able to cleanup the triggered buffer, we need to add .remove()
    callbacks to the I2C and SPI subdrivers and call back into an
    exported .remove() callback in the core.
    Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
    Tested-by: default avatarJonathan Cameron <jic23@kernel.org>
    Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
    0427a106
kxsd9.c 6.96 KB