OSDN Git Service

Sensor HAL: Allow orientation and hysteresis config
authorsrinivas pandruvada <srinivas.pandruvada@intel.com>
Wed, 29 Aug 2012 20:15:26 +0000 (13:15 -0700)
committerMattias Pettersson <mattias.pettersson@intel.com>
Wed, 4 Dec 2013 14:13:11 +0000 (15:13 +0100)
This patch adds defines for orientation and hysteresis, so
that they can be modified to tune for individual platform.
It is initializing hysteresis to 0 and orientation values to
-1.

Change-Id: I086945a73f482bfc08f3baf12ce836c7b40d4ae6
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@intel.com>
bigcore/libsensors/SensorConfig.h
common/libsensors/SensorIIODev.cpp

index 67b8479..124c5e0 100644 (file)
@@ -145,16 +145,31 @@ inline float convert_from_vtf_format(int size, int exponent, unsigned int value)
     }
 }
 
+// Platform sensor orientatation
+#define DEF_ORIENT_ACCEL_X                   -1
+#define DEF_ORIENT_ACCEL_Y                   -1
+#define DEF_ORIENT_ACCEL_Z                   -1
+
+#define DEF_ORIENT_GYRO_X                   -1
+#define DEF_ORIENT_GYRO_Y                   -1
+#define DEF_ORIENT_GYRO_Z                   -1
+
 // G to m/s2
 #define CONVERT_FROM_VTF16(s,d,x)      (convert_from_vtf_format(s,d,x))
-#define CONVERT_A_G_VTF16E14_X(s,d,x)  (convert_from_vtf_format(s,d,x)*GRAVITY)
-#define CONVERT_A_G_VTF16E14_Y(s,d,x)  (convert_from_vtf_format(s,d,x)*GRAVITY)
-#define CONVERT_A_G_VTF16E14_Z(s,d,x)  (convert_from_vtf_format(s,d,x)*GRAVITY)
+#define CONVERT_A_G_VTF16E14_X(s,d,x)  (DEF_ORIENT_ACCEL_X *\
+                                        convert_from_vtf_format(s,d,x)*GRAVITY)
+#define CONVERT_A_G_VTF16E14_Y(s,d,x)  (DEF_ORIENT_ACCEL_Y *\
+                                        convert_from_vtf_format(s,d,x)*GRAVITY)
+#define CONVERT_A_G_VTF16E14_Z(s,d,x)  (DEF_ORIENT_ACCEL_Z *\
+                                        convert_from_vtf_format(s,d,x)*GRAVITY)
 
 // Degree/sec to radian/sec
-#define CONVERT_G_D_VTF16E14_X(s,d,x)  (convert_from_vtf_format(s,d,x) * ((float)M_PI/180.0f))
-#define CONVERT_G_D_VTF16E14_Y(s,d,x)  (convert_from_vtf_format(s,d,x) * ((float)M_PI/180.0f))
-#define CONVERT_G_D_VTF16E14_Z(s,d,x)  (convert_from_vtf_format(s,d,x) * ((float)M_PI/180.0f))
+#define CONVERT_G_D_VTF16E14_X(s,d,x)  (DEF_ORIENT_GYRO_X *\
+                                        convert_from_vtf_format(s,d,x) * ((float)M_PI/180.0f))
+#define CONVERT_G_D_VTF16E14_Y(s,d,x)  (DEF_ORIENT_GYRO_Y *\
+                                        convert_from_vtf_format(s,d,x) * ((float)M_PI/180.0f))
+#define CONVERT_G_D_VTF16E14_Z(s,d,x)  (DEF_ORIENT_GYRO_Z *\
+                                        convert_from_vtf_format(s,d,x) * ((float)M_PI/180.0f))
 
 // Milli gauss to micro tesla
 #define CONVERT_M_MG_VTF16E14_X(s,d,x) (convert_from_vtf_format(s,d,x)/10)
index 0238951..38c28c5 100644 (file)
@@ -21,6 +21,7 @@
 
 static const std::string IIO_DIR = "/sys/bus/iio/devices";
 static const int DEF_BUFFER_LEN = 2;
+static const int DEF_HYST_VALUE = 0;
 
 SensorIIODev::SensorIIODev(const std::string& dev_name, const std::string& units,
                            const std::string& exponent,
@@ -126,7 +127,7 @@ int SensorIIODev::enable(int enabled)
             goto err_ret;
         if (DeviceActivate(GetDeviceNumber(), 1) < 0)
             goto err_ret;
-        if (DeviceSetSensitivity(GetDeviceNumber(), 1) < 0)
+        if (DeviceSetSensitivity(GetDeviceNumber(), DEF_HYST_VALUE) < 0)
             goto err_ret;
         if (AllocateRxBuffer() < 0)
             goto err_ret;