summaryrefslogtreecommitdiff
path: root/libsensors_iio/src/SWGyroscopeUncalibrated.cpp
diff options
context:
space:
mode:
authorBaixing Tan <baixingx.tan@intel.com>2015-03-25 11:16:57 +0800
committerZhengyin Qian <qianzy@google.com>2015-07-28 12:19:18 -0700
commit049ab1da89d389f05870f7e30d585ecfc14524dd (patch)
tree37bd50571b00976df97cc10e64e6be66c1e5c422 /libsensors_iio/src/SWGyroscopeUncalibrated.cpp
parent0d5f99879a2ed5026cee26374d18d0e878ed0e13 (diff)
downloadsensors-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/SWGyroscopeUncalibrated.cpp')
-rw-r--r--libsensors_iio/src/SWGyroscopeUncalibrated.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/libsensors_iio/src/SWGyroscopeUncalibrated.cpp b/libsensors_iio/src/SWGyroscopeUncalibrated.cpp
new file mode 100644
index 0000000..55e8bfe
--- /dev/null
+++ b/libsensors_iio/src/SWGyroscopeUncalibrated.cpp
@@ -0,0 +1,49 @@
+/*
+ * STMicroelectronics Gyroscope Uncalibrated Sensor Class
+ *
+ * Copyright 2013-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 "SWGyroscopeUncalibrated.h"
+
+SWGyroscopeUncalibrated::SWGyroscopeUncalibrated(const char *name, int handle, int pipe_data_fd) :
+ SWSensorBaseWithPollrate(name, handle, SENSOR_TYPE_GYROSCOPE_UNCALIBRATED,
+ pipe_data_fd, true, true, true, true)
+{
+ sensor_t_data.stringType = SENSOR_STRING_TYPE_GYROSCOPE_UNCALIBRATED;
+ sensor_t_data.flags = SENSOR_FLAG_CONTINUOUS_MODE;
+
+ type_dependencies[SENSOR_BASE_DEPENDENCY_0] = SENSOR_TYPE_GYROSCOPE;
+ type_sensor_need_trigger = SENSOR_TYPE_GYROSCOPE;
+}
+
+SWGyroscopeUncalibrated::~SWGyroscopeUncalibrated()
+{
+
+}
+
+void SWGyroscopeUncalibrated::TriggerEventReceived()
+{
+ int data_remaining;
+ SensorBaseData gyro_data;
+
+ do {
+ data_remaining = GetLatestValidDataFromDependency(SENSOR_BASE_DEPENDENCY_0, &gyro_data);
+ if (data_remaining < 0)
+ return;
+
+ memcpy(sensor_event.uncalibrated_gyro.uncalib, gyro_data.raw, num_data_axis * sizeof(float));
+ memcpy(sensor_event.uncalibrated_gyro.bias, gyro_data.offset, num_data_axis * sizeof(float));
+ sensor_event.timestamp = gyro_data.timestamp;
+
+ SWSensorBaseWithPollrate::WriteDataToPipe();
+ SWSensorBaseWithPollrate::ProcessData(&gyro_data);
+ } while (data_remaining > 0);
+}