diff options
author | Baixing Tan <baixingx.tan@intel.com> | 2015-03-25 11:16:57 +0800 |
---|---|---|
committer | Zhengyin Qian <qianzy@google.com> | 2015-07-28 12:19:18 -0700 |
commit | 049ab1da89d389f05870f7e30d585ecfc14524dd (patch) | |
tree | 37bd50571b00976df97cc10e64e6be66c1e5c422 /libsensors_iio/src/TiltSensor.cpp | |
parent | 0d5f99879a2ed5026cee26374d18d0e878ed0e13 (diff) | |
download | sensors-049ab1da89d389f05870f7e30d585ecfc14524dd.tar.gz |
Original code get from ST for lsm6ds3 sensor base on iio subsystem
Add original SensorHAL_IIO_v3.1.0 for lsm6ds3 sensor
Change-Id: Iebd049a36696f9b1f09049cc8672ed260c12cdf7
Tracked-On: https://jira01.devtools.intel.com/browse/MARVIN-175
Signed-off-by: Baixing Tan <baixingx.tan@intel.com>
Reviewed-on: https://android.intel.com:443/346267
Diffstat (limited to 'libsensors_iio/src/TiltSensor.cpp')
-rw-r--r-- | libsensors_iio/src/TiltSensor.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/libsensors_iio/src/TiltSensor.cpp b/libsensors_iio/src/TiltSensor.cpp new file mode 100644 index 0000000..67e0e79 --- /dev/null +++ b/libsensors_iio/src/TiltSensor.cpp @@ -0,0 +1,48 @@ +/* + * STMicroelectronics Tilt Sensor Class + * + * Copyright 2014-2015 STMicroelectronics Inc. + * Author: Denis Ciocca - <denis.ciocca@st.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"). + */ + +#include <fcntl.h> +#include <assert.h> +#include <signal.h> + +#include "TiltSensor.h" + +TiltSensor::TiltSensor(HWSensorBaseCommonData *data, const char *name, int handle, + int pipe_data_fd, float power_consumption) : + HWSensorBase(data, name, handle, SENSOR_TYPE_TILT_DETECTOR, 0, + pipe_data_fd, power_consumption) +{ + sensor_t_data.stringType = SENSOR_STRING_TYPE_TILT_DETECTOR; + sensor_t_data.flags = SENSOR_FLAG_SPECIAL_REPORTING_MODE | SENSOR_FLAG_WAKE_UP; + sensor_t_data.resolution = 1.0f; + sensor_t_data.maxRange = 1.0f; + + num_data_axis = SENSOR_BASE_0AXIS; +} + +TiltSensor::~TiltSensor() +{ + +} + +int TiltSensor::SetDelay(int __attribute__((unused))handle, + int64_t __attribute__((unused))period_ns, + int64_t __attribute__((unused))timeout) +{ + return 0; +} + +void TiltSensor::ProcessEvent(struct iio_event_data *event_data) +{ + sensor_event.data[0] = 1.0f; + sensor_event.timestamp = event_data->timestamp; + + HWSensorBase::WriteDataToPipe(); + HWSensorBase::ProcessEvent(event_data); +} |