mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
MOTIONSENSE_CMD_DUMP is deprecated, replaced with MOTIONSENSE_CMD_GET_DATA Also use vector_3_t instead of x,y,z ectool motionsense commands only work with newer firmware, to handle a dynamic number of sensors. - The host sends the number of sensor it has allocated space for. - If 0, the EC just sends the number of sensors available - Otherwise returns sensor information up to the limit imposed by the host. Remove MOTIONSENSE_GET_STATUS: not needed. It is only useful for LPC, to guarantee atomicity of the data. Remove MOTIONSENSE_GET_DATA: not needed since we increase the version number of MOTIONSENSE command. BUG=chrome-os-partner:31071,chromium:430792 BRANCH=ToT TEST=Compile. On a firmware that support the new command: /usr/sbin/ectool --name=cros_sh motionsense Motion sensing active Sensor 0: 92 15 1030 Sensor 1: -94 -63 718 /usr/sbin/ectool --name=cros_sh motionsense active 0 On a machine with older firmware (samus), check these functions are not working anymore. Change-Id: I64b62afff96670fb93457760d43d4e64e26e029f Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/226880 Reviewed-by: Alec Berg <alecaberg@chromium.org>
94 lines
3.1 KiB
C
94 lines
3.1 KiB
C
/* Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#ifndef __CROS_EC_ACCELGYRO_H
|
|
#define __CROS_EC_ACCELGYRO_H
|
|
|
|
#include "motion_sense.h"
|
|
|
|
/* Header file for accelerometer / gyro drivers. */
|
|
|
|
/* Number of counts from accelerometer that represents 1G acceleration. */
|
|
#define ACCEL_G 1024
|
|
|
|
struct accelgyro_drv {
|
|
/**
|
|
* Initialize accelerometers.
|
|
* @s Pointer to sensor data pointer. Sensor data will be
|
|
* allocated on success.
|
|
* @return EC_SUCCESS if successful, non-zero if error.
|
|
*/
|
|
int (*init)(const struct motion_sensor_t *s);
|
|
|
|
/**
|
|
* Read all three accelerations of an accelerometer. Note that all
|
|
* three accelerations come back in counts, where ACCEL_G can be used
|
|
* to convert counts to engineering units.
|
|
* @s Pointer to sensor data.
|
|
* @v Vector to store acceleration (in units of counts).
|
|
* @return EC_SUCCESS if successful, non-zero if error.
|
|
*/
|
|
int (*read)(const struct motion_sensor_t *s, vector_3_t v);
|
|
|
|
/**
|
|
* Setter and getter methods for the sensor range. The sensor range
|
|
* defines the maximum value that can be returned from read(). As the
|
|
* range increases, the resolution gets worse.
|
|
* @s Pointer to sensor data.
|
|
* @range Range (Units are +/- G's for accel, +/- deg/s for gyro)
|
|
* @rnd Rounding flag. If true, it rounds up to nearest valid
|
|
* value. Otherwise, it rounds down.
|
|
* @return EC_SUCCESS if successful, non-zero if error.
|
|
*/
|
|
int (*set_range)(const struct motion_sensor_t *s,
|
|
int range,
|
|
int rnd);
|
|
int (*get_range)(const struct motion_sensor_t *s,
|
|
int *range);
|
|
|
|
/**
|
|
* Setter and getter methods for the sensor resolution.
|
|
* @s Pointer to sensor data.
|
|
* @range Resolution (Units are number of bits)
|
|
* param rnd Rounding flag. If true, it rounds up to nearest valid
|
|
* value. Otherwise, it rounds down.
|
|
* @return EC_SUCCESS if successful, non-zero if error.
|
|
*/
|
|
int (*set_resolution)(const struct motion_sensor_t *s,
|
|
int res,
|
|
int rnd);
|
|
int (*get_resolution)(const struct motion_sensor_t *s,
|
|
int *res);
|
|
|
|
/**
|
|
* Setter and getter methods for the sensor output data range. As the
|
|
* ODR increases, the LPF roll-off frequency also increases.
|
|
* @s Pointer to sensor data.
|
|
* @rate Output data rate (units are milli-Hz)
|
|
* @rnd Rounding flag. If true, it rounds up to nearest valid
|
|
* value. Otherwise, it rounds down.
|
|
* @return EC_SUCCESS if successful, non-zero if error.
|
|
*/
|
|
int (*set_data_rate)(const struct motion_sensor_t *s,
|
|
int rate,
|
|
int rnd);
|
|
int (*get_data_rate)(const struct motion_sensor_t *s,
|
|
int *rate);
|
|
|
|
#ifdef CONFIG_ACCEL_INTERRUPTS
|
|
/**
|
|
* Setup a one-time accel interrupt. If the threshold is low enough, the
|
|
* interrupt may trigger due simply to noise and not any real motion.
|
|
* If the threshold is 0, the interrupt will fire immediately.
|
|
* @s Pointer to sensor data.
|
|
* @threshold Threshold for interrupt in units of counts.
|
|
*/
|
|
int (*set_interrupt)(const struct motion_sensor_t *s,
|
|
unsigned int threshold);
|
|
#endif
|
|
};
|
|
|
|
#endif /* __CROS_EC_ACCELGYRO_H */
|