mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
Added motion sense task to Clapper and Glimmer. This task samples the accelerometers and calculate a lid angle. Note that as the machine is rotated towards the hinge angle aligning with gravity, the lid calculation becomes less trustworthy. Added a math_util file to hold various mathematical functions useful for calculating lid angle that may be helpful in other places. For each board with accelerometers we need to define some orientation specific data in board.c. There is a calibration procedure through the EC console that can be enabled by defining CONFIG_ACCEL_CALIBRATE. The calibration procedure can help determine the orientation data required. For debugging purposes there is a console command to regularly print to the EC console the accelerometer data and derived lid angle. The console command can be enabled by defining CONFIG_CMD_LID_ANGLE. BUG=none Original-BUG=chrome-os-partner:24703 BRANCH=rambi TEST=Ran the calibration procedure on a Glimmer unit, and then rotated the machine in space. Verified that the lid angle calculated roughly matched actual lid angle. Original-Change-Id: I63a5e384b7f6b628b4ea01de49843355fb8d6ebe Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/184783 Reviewed-by: Randall Spangler <rspangler@chromium.org> Signed-off-by: Alec Berg <alecaberg@chromium.org> (cherry picked from commit efb07945a5159fa0e7a746c666b2519ebdca9c22) Conflicts: board/clapper/board.c board/clapper/ec.tasklist board/glimmer/board.c board/glimmer/ec.tasklist Change-Id: Ibc492ef5c11e7084e87f01338c4d7775f9a08c18 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/187433 Reviewed-by: Randall Spangler <rspangler@chromium.org>
44 lines
1.3 KiB
C
44 lines
1.3 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_ACCELEROMETER_H
|
|
#define __CROS_EC_ACCELEROMETER_H
|
|
|
|
/* Header file for accelerometer drivers. */
|
|
|
|
/* This array must be defined in board.c. */
|
|
extern const int accel_addr[];
|
|
|
|
/* This enum must be defined in board.h. */
|
|
enum accel_id;
|
|
|
|
/* Number of counts from accelerometer that represents 1G acceleration. */
|
|
#define ACCEL_G 1024
|
|
|
|
/**
|
|
* 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.
|
|
*
|
|
* @param id Target accelerometer
|
|
* @param x_acc Pointer to store X-axis acceleration (in counts).
|
|
* @param y_acc Pointer to store Y-axis acceleration (in counts).
|
|
* @param z_acc Pointer to store Z-axis acceleration (in counts).
|
|
*
|
|
* @return EC_SUCCESS if successful, non-zero if error.
|
|
*/
|
|
int accel_read(enum accel_id id, int *x_acc, int *y_acc, int *z_acc);
|
|
|
|
/**
|
|
* Initiailze accelerometers.
|
|
*
|
|
* @param id Target accelerometer
|
|
*
|
|
* @return EC_SUCCESS if successful, non-zero if error.
|
|
*/
|
|
int accel_init(enum accel_id id);
|
|
|
|
#endif /* __CROS_EC_ACCELEROMETER_H */
|