summaryrefslogtreecommitdiffstats
path: root/libsensors/mlsdk/platform/include/i2c.h
diff options
context:
space:
mode:
authorKyle Repinski <repinski23@gmail.com>2015-12-02 12:32:39 -0600
committerZiyan <jaraidaniel@gmail.com>2016-01-17 22:41:00 +0100
commit153b50ec9714ff4ba6ce083ca0d49fd31658ce15 (patch)
tree8dab0e630a39552385d42a266ba39dfdaf837752 /libsensors/mlsdk/platform/include/i2c.h
parentb8515d8e0376e300ed17598f0288fad0e6ae0d89 (diff)
downloaddevice_samsung_tuna-153b50ec9714ff4ba6ce083ca0d49fd31658ce15.zip
device_samsung_tuna-153b50ec9714ff4ba6ce083ca0d49fd31658ce15.tar.gz
device_samsung_tuna-153b50ec9714ff4ba6ce083ca0d49fd31658ce15.tar.bz2
sensors: Merge invensense HAL into main tuna HAL.
Since these are both in our device tree now, there's no need to have them be separated. This saves about 14KB of space as well. Change-Id: Ibfcd7da4b30bb261586ecd9373e6fd4a343e0e06
Diffstat (limited to 'libsensors/mlsdk/platform/include/i2c.h')
-rw-r--r--libsensors/mlsdk/platform/include/i2c.h133
1 files changed, 133 insertions, 0 deletions
diff --git a/libsensors/mlsdk/platform/include/i2c.h b/libsensors/mlsdk/platform/include/i2c.h
new file mode 100644
index 0000000..c3002d5
--- /dev/null
+++ b/libsensors/mlsdk/platform/include/i2c.h
@@ -0,0 +1,133 @@
+/*
+ $License:
+ Copyright 2011 InvenSense, Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ $
+ */
+/*******************************************************************************
+ *
+ * $Id: i2c.h 5629 2011-06-11 03:13:08Z mcaramello $
+ *
+ *******************************************************************************/
+
+#ifndef _I2C_H
+#define _I2C_H
+
+#include "mltypes.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ------------ */
+/* - Defines. - */
+/* ------------ */
+
+/* - Error Codes. - */
+
+#define I2C_SUCCESS 0
+#define I2C_ERROR 1
+
+/* ---------- */
+/* - Enums. - */
+/* ---------- */
+
+/* --------------- */
+/* - Structures. - */
+/* --------------- */
+
+#define I2C_RBUFF_MAX 128
+#define I2C_RBUFF_SIZE 17
+
+#ifdef BB_I2C
+#define I2C_RBUFF_DYNAMIC 0
+#else
+#define I2C_RBUFF_DYNAMIC 1
+#endif
+
+typedef struct {
+
+ HANDLE i2cHndl;
+ HANDLE hDevice; // handle to the drive to be examined
+
+ MLU8 readBuffer[1024];
+ MLU8 writeBuffer[1024];
+
+ MLU16 rBuffRIndex;
+ MLU16 rBuffWIndex;
+#if !I2C_RBUFF_DYNAMIC
+ MLU8 rBuff[I2C_RBUFF_MAX][I2C_RBUFF_SIZE];
+#else
+ MLU8 *rBuff;
+#endif
+ MLU16 rBuffMax;
+ MLU16 rBuffNumBytes;
+
+ MLU8 runThread;
+ MLU8 autoProcess;
+
+} I2C_Vars_t;
+
+/* --------------------- */
+/* - Function p-types. - */
+/* --------------------- */
+
+#if (defined(BB_I2C))
+void set_i2c_open_bind_cb(int (*func)(unsigned int i2c_slave_addr));
+void set_i2c_open_cb(int (*func)(const char *dev, int rw));
+void set_i2c_close_cb(int (*func)(int fd));
+void set_i2c_lltransfer_cb(int (*func)(int fd, int client_addr, const char *write_buf, unsigned int write_len,
+ char *read_buf, unsigned int read_len ));
+void set_i2c_write_register_cb(int (*func)(int fd, int client_addr, unsigned char reg, unsigned char value));
+void set_i2c_read_register_cb(unsigned char (*func)(int fd, int client_addr, unsigned char reg));
+void set_i2c_dump_register_cb(int (*func)(int fd, int client_addr, unsigned char start_reg, unsigned char *buff, int len));
+
+int _i2c_write_register(int fd, int client_addr, unsigned char reg, unsigned char value);
+unsigned char _i2c_read_register (int fd, int client_addr, unsigned char reg);
+int i2c_lltransfer (int fd, int client_addr, const char *write_buf, unsigned int write_len,
+ char *read_buf, unsigned int read_len );
+int i2c_write_register(int fd, int client_addr, unsigned char reg, unsigned char value);
+unsigned char i2c_read_register (int fd, int client_addr, unsigned char reg);
+int i2c_dump_register (int fd, int client_addr, unsigned char start_reg, unsigned char *buff, int len);
+int i2c_open (const char *dev, int rw);
+int i2c_close (int fd);
+int i2c_open_bind (unsigned int i2c_slave_addr);
+#endif
+
+int I2COpen (unsigned char autoProcess, unsigned char createThread);
+int I2CClose (void);
+int I2CDeviceIoControl(void);
+int I2CRead (void);
+int I2CWrite (void);
+int I2CSetBufferSize (unsigned short bufferSize);
+int I2CBufferUpdate (void);
+int I2CHandler (void);
+int I2CReadBuffer (unsigned short cnt, unsigned char bufferMode, unsigned char *rBuff);
+int I2CEmptyBuffer (void);
+int I2CPktsInBuffer (unsigned short *pktsInBuffer);
+int I2CCreateMutex (void);
+int I2CLockMutex (void);
+int I2CUnlockMutex (void);
+
+int I2CWriteBurst (unsigned char slaveAddr, unsigned char registerAddr, unsigned short length, unsigned char *data);
+int I2CReadBurst (unsigned char slaveAddr, unsigned char registerAddr, unsigned short length, unsigned char *data);
+
+int I2COpenBB (void);
+int I2CCloseBB (int i2cHandle);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _TEMPLATE_H */