Files
OpenCellular/include/motion_sense.h
Gwendal Grignou a9a9ae1abc driver: Use common data structure to store default accel values
Move structure used by lms6ds0 to motion_sense.h,
so that bosh driver can use the same mechanism.
Use code to avoid reading chip range when reading data.

BUG=none
BRANCH=none
TEST=Check Bosh driver is working as expected.

Change-Id: Id8b5bb8735e479a122ef32ab9a400fba189d7488
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/270453
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-05-12 23:35:51 +00:00

87 lines
2.0 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.
*/
/* Header for motion_sense.c */
#ifndef __CROS_EC_MOTION_SENSE_H
#define __CROS_EC_MOTION_SENSE_H
#include "chipset.h"
#include "common.h"
#include "ec_commands.h"
#include "gpio.h"
#include "math_util.h"
enum sensor_state {
SENSOR_NOT_INITIALIZED = 0,
SENSOR_INITIALIZED = 1,
SENSOR_INIT_ERROR = 2
};
#define SENSOR_ACTIVE_S5 CHIPSET_STATE_SOFT_OFF
#define SENSOR_ACTIVE_S3 CHIPSET_STATE_SUSPEND
#define SENSOR_ACTIVE_S0 CHIPSET_STATE_ON
#define SENSOR_ACTIVE_S0_S3 (SENSOR_ACTIVE_S3 | SENSOR_ACTIVE_S0)
#define SENSOR_ACTIVE_S0_S3_S5 (SENSOR_ACTIVE_S0_S3 | SENSOR_ACTIVE_S5)
struct motion_data_t {
int odr;
int range;
};
struct motion_sensor_t {
/* RO fields */
uint32_t active_mask;
char *name;
enum motionsensor_chip chip;
enum motionsensor_type type;
enum motionsensor_location location;
const struct accelgyro_drv *drv;
struct mutex *mutex;
void *drv_data;
uint8_t i2c_addr;
const matrix_3x3_t *rot_standard_ref;
/* Default configuration parameters, RO only */
struct motion_data_t default_config;
/* Run-Time configuration parameters */
struct motion_data_t runtime_config;
/* state parameters */
enum sensor_state state;
enum chipset_state_mask active;
vector_3_t raw_xyz;
vector_3_t xyz;
};
/* Defined at board level. */
extern struct motion_sensor_t motion_sensors[];
extern const unsigned int motion_sensor_count;
/*
* Priority of the motion sense resume/suspend hooks, to be sure associated
* hooks are scheduled properly.
*/
#define MOTION_SENSE_HOOK_PRIO (HOOK_PRIO_DEFAULT)
#ifdef CONFIG_ACCEL_INTERRUPTS
/**
* Interrupt function for lid accelerometer.
*
* @param signal GPIO signal that caused interrupt
*/
void accel_int_lid(enum gpio_signal signal);
/**
* Interrupt function for base accelerometer.
*
* @param signal GPIO signal that caused interrupt
*/
void accel_int_base(enum gpio_signal signal);
#endif
#endif /* __CROS_EC_MOTION_SENSE_H */