Re: [PATCH v6 1/3] iio: mma8452: add freefall detection for Freescale's accelerometers

From: Martin Kepplinger
Date: Fri Jan 22 2016 - 12:14:43 EST


Am 2016-01-16 um 15:35 schrieb Martin Kepplinger:
> This adds freefall event detection to the supported devices. It adds
> the in_accel_x&y&z_mag_falling_en iio event attribute, which activates
> freefall mode.
>
> In freefall mode, the current acceleration magnitude (AND combination
> of all axis values) is compared to the specified threshold.
> If it falls under the threshold (in_accel_mag_falling_value),
> the appropriate IIO event code is generated.
>
> This is what the sysfs "events" directory for these devices looks
> like after this change:
>
> -rw-r--r-- 4096 Oct 23 08:45 in_accel_mag_falling_period
> -rw-r--r-- 4096 Oct 23 08:45 in_accel_mag_falling_value
> -rw-r--r-- 4096 Oct 23 08:45 in_accel_mag_rising_period
> -rw-r--r-- 4096 Oct 23 08:45 in_accel_mag_rising_value
> -r--r--r-- 4096 Oct 23 08:45 in_accel_scale
> -rw-r--r-- 4096 Oct 23 08:45 in_accel_x&y&z_mag_falling_en
> -rw-r--r-- 4096 Oct 23 08:45 in_accel_x_mag_rising_en
> -rw-r--r-- 4096 Oct 23 08:45 in_accel_y_mag_rising_en
> -rw-r--r-- 4096 Oct 23 08:45 in_accel_z_mag_rising_en
>
> Signed-off-by: Martin Kepplinger <martin.kepplinger@xxxxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Christoph Muellner <christoph.muellner@xxxxxxxxxxxxxxxxxxxxx>
> ---
> revision history
> ----------------
> v1:
> initial post
> v2:
> build all from correct event and channel spec structs
> v3:
> rising and falling are treated as equal now. Until last time, I had
> misunderstood the iio events' user API definition. This works and
> values always reflect the current state of operation.
> v4:
> fix error that caused a build warning
> v5:
> changes according to Peter's review
> v6:
> changes according to Jonathan's review:
> improve set_freefall_mode(); fix error case
>
>

Any more thoughts, advice or objections on this?

thanks
martin