diff options
author | Robert Collins <rcollins@nvidia.com> | 2010-11-23 13:54:32 -0800 |
---|---|---|
committer | Dan Willemsen <dwillemsen@nvidia.com> | 2011-11-30 21:46:33 -0800 |
commit | df3ec81e193b55c04362ab2fbbf4611a4f41947c (patch) | |
tree | 7101dae0c47e60860c5f1367fa75f9a8ec93e530 /drivers/misc/mpu3050/mlsl-kernel.c | |
parent | 2816bee2242d6fa34586dc8043d239c2d1fd8bd6 (diff) |
[ARM/tegra] Integrate Accelerometer source code files.
Inegrate MPL libraries and the following sensors:
Accelerometers:
kxtf9
Compi:
ak8975
Original-Change-Id: I450b5b7ff018249a19bb23b78e722e9a355b7bd8
Reviewed-on: http://git-master/r/11803
Tested-by: Robert R Collins <rcollins@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Rebase-Id: R76e2da39a90190d176552fdb11aab2009964023f
Diffstat (limited to 'drivers/misc/mpu3050/mlsl-kernel.c')
-rwxr-xr-x | drivers/misc/mpu3050/mlsl-kernel.c | 171 |
1 files changed, 171 insertions, 0 deletions
diff --git a/drivers/misc/mpu3050/mlsl-kernel.c b/drivers/misc/mpu3050/mlsl-kernel.c new file mode 100755 index 000000000000..4b9494f1d919 --- /dev/null +++ b/drivers/misc/mpu3050/mlsl-kernel.c @@ -0,0 +1,171 @@ +/* + $License: + Copyright (C) 2010 InvenSense Corporation, All Rights Reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + $ + */ +/******************************************************************************* + * + * $Id: mlsl-kernel.c 3863 2010-10-08 22:05:31Z nroyer $ + * + ******************************************************************************/ + +#include "mlsl.h" +#include "mpu-i2c.h" + +/* ------------ */ +/* - Defines. - */ +/* ------------ */ + +/* ---------------------- */ +/* - Types definitions. - */ +/* ---------------------- */ + +/* --------------------- */ +/* - Function p-types. - */ +/* --------------------- */ + +/** + * @brief used to open the I2C or SPI serial port. + * This port is used to send and receive data to the MPU device. + * @param portNum + * The COM port number associated with the device in use. + * @return ML_SUCCESS if successful, a non-zero error code otherwise. + */ +tMLError MLSLSerialOpen(char const *port, mlsl_handle_t * sl_handle) +{ + return ML_SUCCESS; +} + +/** + * @brief used to reset any buffering the driver may be doing + * @return ML_SUCCESS if successful, a non-zero error code otherwise. + */ +tMLError MLSLSerialReset(mlsl_handle_t sl_handle) +{ + return ML_SUCCESS; +} + +/** + * @brief used to close the I2C or SPI serial port. + * This port is used to send and receive data to the MPU device. + * @return ML_SUCCESS if successful, a non-zero error code otherwise. + */ +tMLError MLSLSerialClose(mlsl_handle_t sl_handle) +{ + return ML_SUCCESS; +} + +/** + * @brief used to read a single byte of data. + * This should be sent by I2C or SPI. + * + * @param slaveAddr I2C slave address of device. + * @param registerAddr Register address to read. + * @param data Single byte of data to read. + * + * @return ML_SUCCESS if the command is successful, an error code otherwise. + */ +tMLError MLSLSerialWriteSingle(mlsl_handle_t sl_handle, + unsigned char slaveAddr, + unsigned char registerAddr, unsigned char data) +{ + return sensor_i2c_write_register((struct i2c_adapter *)sl_handle, + slaveAddr, registerAddr, data); + +} + +/** + * @brief used to read multiple bytes of data. + * This should be sent by I2C or SPI. + * + * @param slaveAddr I2C slave address of device. + * @param registerAddr Register address to read. + * @param length Length of burst data. + * @param data Pointer to block of data. + * + * @return Zero if the command is successful; an error code otherwise + */ +tMLError MLSLSerialRead(mlsl_handle_t sl_handle, + unsigned char slaveAddr, + unsigned char registerAddr, + unsigned short length, unsigned char *data) +{ + return sensor_i2c_read((struct i2c_adapter *)sl_handle, + slaveAddr, registerAddr, length, data); +} + +/** + * @brief used to write multiple bytes of data. + * This should be sent by I2C or SPI. + * + * @param slaveAddr I2C slave address of device. + * @param length Length of burst data. + * @param data Pointer to block of data. First byte is the + * register address to write. + * + * @return ML_SUCCESS if successful, a non-zero error code otherwise. + */ +tMLError MLSLSerialWrite(mlsl_handle_t sl_handle, + unsigned char slaveAddr, + unsigned short length, unsigned char const *data) +{ + return sensor_i2c_write((struct i2c_adapter *)sl_handle, + slaveAddr, length, data); +} + +/** + * @brief used to read multiple bytes of data. + * This should be sent by I2C or SPI. + * + * @param slaveAddr I2C slave address of device. + * @param registerAddr Register address to read. + * @param length Length of burst data. + * @param data Pointer to block of data. + * + * @return Zero if the command is successful; an error code otherwise + */ +tMLError MLSLSerialReadMem(mlsl_handle_t sl_handle, + unsigned char slaveAddr, + unsigned short memAddr, + unsigned short length, unsigned char *data) +{ + return mpu_memory_read((struct i2c_adapter *)sl_handle, + slaveAddr, memAddr, length, data); +} + +/** + * @brief used to write multiple bytes of data. + * This should be sent by I2C or SPI. + * + * @param slaveAddr I2C slave address of device. + * @param length Length of burst data. + * @param data Pointer to block of data. First byte is the + * register address to write. + * + * @return ML_SUCCESS if successful, a non-zero error code otherwise. + */ +tMLError MLSLSerialWriteMem(mlsl_handle_t sl_handle, + unsigned char slaveAddr, + unsigned short mem_addr, + unsigned short length, unsigned char const *data) +{ + return mpu_memory_write((struct i2c_adapter *)sl_handle, + slaveAddr, mem_addr, length, data); +} + +/***********************/ + /** @} *//* defgroup */ +/*********************/ |