summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/input/sensors/bmi160/Kconfig121
-rw-r--r--drivers/input/sensors/bmi160/Makefile41
-rw-r--r--drivers/input/sensors/bmi160/bmi160.c18753
-rw-r--r--drivers/input/sensors/bmi160/bmi160.h11814
-rw-r--r--drivers/input/sensors/bmi160/bmi160_driver.c4021
-rw-r--r--drivers/input/sensors/bmi160/bmi160_driver.h409
-rw-r--r--drivers/input/sensors/bmi160/bmi160_i2c.c369
-rw-r--r--drivers/input/sensors/bmi160/bmi160_spi.c299
-rw-r--r--drivers/input/sensors/bmi160/bs_log.c50
-rw-r--r--drivers/input/sensors/bmi160/bs_log.h171
-rw-r--r--drivers/input/sensors/bmi160/bstclass.c238
-rw-r--r--drivers/input/sensors/bmi160/bstclass.h78
12 files changed, 36364 insertions, 0 deletions
diff --git a/drivers/input/sensors/bmi160/Kconfig b/drivers/input/sensors/bmi160/Kconfig
new file mode 100644
index 00000000..0b1feda
--- /dev/null
+++ b/drivers/input/sensors/bmi160/Kconfig
@@ -0,0 +1,121 @@
+#
+# Makefile for Bosch sensors driver.
+#
+config BOSCH_DRIVER_LOG_FUNC
+ tristate "Bosch Sensortec driver smart log function support"
+ depends on (I2C || SPI_MASTER) && SYSFS
+ help
+ If you say yes here, you get support for smart log function in Bosch Sensortec driver.
+
+config SENSORS_BMA2X2
+ tristate "BMA2x2 acceleration sensor support"
+ depends on I2C
+ help
+ If you say yes here, you get support for Bosch Sensortec's
+ acceleration sensors BMA255/BMA254/BMA355/BMA250E/BMA222E/BMA280.
+
+config SENSORS_BMA2X2_ENABLE_INT1
+ tristate "BMA2X2 acceleration sensor interrupt INT1 support"
+ depends on SENSORS_BMA2X2
+ help
+ If you say yes here, you get INT1 support for Bosch Sensortec
+ acceleration sensors BMA255/BMA250E/BMA222E/BMA280.
+ Select it will disable interrupt INT2 support
+
+config SENSORS_BMA2X2_ENABLE_INT2
+ tristate "BMA2X2 acceleration sensor interrupt INT2 support"
+ depends on SENSORS_BMA2X2 && !SENSORS_BMA2X2_ENABLE_INT1
+ help
+ If you say yes here, you get INT2 support for Bosch Sensortec
+ acceleration sensors BMA255/BMA250E/BMA222E/BMA280.
+ Can only open if you do NOT open interrupt INT1 support
+
+config SIG_MOTION
+ tristate "support significant motion sensor function"
+ depends on SENSORS_BMA2X2 && ( SENSORS_BMA2X2_ENABLE_INT1 || SENSORS_BMA2X2_ENABLE_INT2)
+ help
+ If you say yes here, if you want to support Bosch significant motion sensor function
+
+config DOUBLE_TAP
+ tristate "support double tap sensor function"
+ depends on SENSORS_BMA2X2 && ( SENSORS_BMA2X2_ENABLE_INT1 || SENSORS_BMA2X2_ENABLE_INT2)
+ help
+ If you say yes here, you get support Bosch double tap sensor function
+
+config SENSORS_BMG
+ tristate "Bosch Gyroscope Sensor Driver"
+ depends on I2C
+ help
+ If you say yes here, you get support for Bosch Sensortec's
+ gyroscope sensor drivers of BMG160/BMI055/BMI058 e.t.c.
+
+config SENSORS_BMG_FIFO
+ tristate "Bosch Gyroscope FIFO Support"
+ depends on SENSORS_BMG
+ help
+ If you say yes here, you get support for Gyroscope sensor FIFO operations.
+ Please check whether the chip supports fifo feature to open it.
+
+config SENSORS_BMI058
+ tristate "BMI058 Sensor Support"
+ depends on (SENSORS_BMG || SENSORS_BMA2X2)
+ help
+ If you say yes here, you get support for Bosch Sensortec's
+ sensor driver of BMI058.
+
+config SENSORS_YAS537
+ tristate "YAS537 Magnetic Sensor Driver"
+ depends on I2C
+ help
+ If you say yes here, you get support for YAMAHA
+ sensor YAS537 Magnetic Sensor
+
+config SENSORS_BMM050
+ tristate "BMM050 Magnetic Sensor Driver"
+ depends on I2C
+ help
+ If you say yes here, you get support for Bosch Sensortec's
+ sensor BMM050 Magnetic Sensor
+
+config SENSORS_AKM09911
+ tristate "AKM09911 Mag Sensor Driver"
+ depends on I2C
+ help
+ If you say yes here, you get support AKM09911 Sensor support.
+
+config SENSORS_AKM09912
+ tristate "AKM09912 Mag Sensor Driver"
+ depends on I2C
+ help
+ If you say yes here, you get support AKM09912 Sensor support.
+
+config SENSORS_BMA420
+ tristate "BMA4XY Sensor Support"
+ depends on I2C || SPI_MASTER
+ help
+ If you say yes here, you get support for Bosch Sensortec's sensor driver of BMA420.
+config SENSORS_BMA421
+ tristate "BMA4XY Sensor Support"
+ depends on I2C || SPI_MASTER
+ help
+ If you say yes here, you get support for Bosch Sensortec's sensor driver of BMA421.
+config SENSORS_BMA422
+ tristate "BMA4XY Sensor Support"
+ depends on I2C || SPI_MASTER
+ help
+ If you say yes here, you get support for Bosch Sensortec's sensor driver of BMA422.
+config SENSORS_BMA455
+ tristate "BMA4XY Sensor Support"
+ depends on I2C || SPI_MASTER
+ help
+ If you say yes here, you get support for Bosch Sensortec's sensor driver of BMA455.
+
+config BMA4XY_MAG_INTERFACE_SUPPORT
+tristate "BMA4XY Sensor mag interface support"
+depends on SENSORS_BMA4XY
+ help
+ If you say yes here, you get support for Bosch Sensortec's
+ sensor driver of BMA4XY with mag sensor support.
+
+
+
diff --git a/drivers/input/sensors/bmi160/Makefile b/drivers/input/sensors/bmi160/Makefile
new file mode 100644
index 00000000..0a9bb56
--- /dev/null
+++ b/drivers/input/sensors/bmi160/Makefile
@@ -0,0 +1,41 @@
+#
+# Makefile for Bosch sensor driver.
+#
+
+obj-$(CONFIG_BOSCH_DRIVER_LOG_FUNC) += bs_log.o
+obj-y += bstclass.o
+ifeq ($(CONFIG_BOSCH_DRIVER_LOG_FUNC),y)
+ EXTRA_CFLAGS += -DBOSCH_DRIVER_LOG_FUNC
+endif
+
+#obj-y += bma2x2.o
+
+ifeq ($(CONFIG_SENSORS_BMA2X2_ENABLE_INT1),y)
+ EXTRA_CFLAGS += -DBMA2X2_ENABLE_INT1
+endif
+
+ifeq ($(CONFIG_BOSCH_BMA2X2_ENABLE_INT2),y)
+ EXTRA_CFLAGS += -DBMA2X2_ENABLE_INT2
+endif
+
+#obj-y += bmg160_driver.o bmg160.o
+EXTRA_CFLAGS += -DBMG_USE_BASIC_I2C_FUNC
+
+obj-y += bmi160_driver.o bmi160.o
+ifeq ($(CONFIG_BMI160_MAG_INTERFACE_SUPPORT),y)
+ EXTRA_CFLAGS += -DBMI160_MAG_INTERFACE_SUPPORT
+endif
+ifeq ($(CONFIG_SENSORS_BMI160_ENABLE_INT1),y)
+ EXTRA_CFLAGS += -DBMI160_ENABLE_INT1
+endif
+
+ifeq ($(CONFIG_SENSORS_BMI160_ENABLE_INT2),y)
+ EXTRA_CFLAGS += -DBMI160_ENABLE_INT2
+endif
+
+obj-y += bmi160_i2c.o
+
+EXTRA_CFLAGS += -DBMI_USE_BASIC_I2C_FUNC
+
+obj-$(CONFIG_SENSORS_BMI160_SPI) += bmi160_spi.o
+
diff --git a/drivers/input/sensors/bmi160/bmi160.c b/drivers/input/sensors/bmi160/bmi160.c
new file mode 100644
index 00000000..071f7e3
--- /dev/null
+++ b/drivers/input/sensors/bmi160/bmi160.c
@@ -0,0 +1,18753 @@
+/*
+* @section LICENSE
+* (C) Copyright 2011~2018 Bosch Sensortec GmbH All Rights Reserved
+*
+* This software program is licensed subject to the GNU General
+* Public License (GPL).Version 2,June 1991,
+* available at http://www.fsf.org/copyleft/gpl.html
+
+*
+* @filename bmi160.c
+* @Date: 2015/04/02
+* @id 836294d
+* @Revision: 2.0.9 $
+*
+* Usage: Sensor Driver for BMI160 sensor
+*
+****************************************************************************
+* \section Disclaimer
+*
+* Common:
+* Bosch Sensortec products are developed for the consumer goods industry.
+* They may only be used within the parameters of the respective valid
+* product data sheet. Bosch Sensortec products are provided with the
+* express understanding that there is no warranty of fitness for a
+* particular purpose.They are not fit for use in life-sustaining,
+* safety or security sensitive systems or any system or device
+* that may lead to bodily harm or property damage if the system
+* or device malfunctions. In addition,Bosch Sensortec products are
+* not fit for use in products which interact with motor vehicle systems.
+* The resale and or use of products are at the purchasers own risk and
+* his own responsibility. The examination of fitness for the intended use
+* is the sole responsibility of the Purchaser.
+*
+* The purchaser shall indemnify Bosch Sensortec from all third party
+* claims, including any claims for incidental, or consequential damages,
+* arising from any product use not covered by the parameters of
+* the respective valid product data sheet or not approved by
+* Bosch Sensortec and reimburse Bosch Sensortec for all costs in
+* connection with such claims.
+*
+* The purchaser must monitor the market for the purchased products,
+* particularly with regard to product safety and inform Bosch Sensortec
+* without delay of all security relevant incidents.
+*
+* Engineering Samples are marked with an asterisk (*) or (e).
+* Samples may vary from the valid technical specifications of the product
+* series. They are therefore not intended or fit for resale to third
+* parties or for use in end products. Their sole purpose is internal
+* client testing. The testing of an engineering sample may in no way
+* replace the testing of a product series. Bosch Sensortec assumes
+* no liability for the use of engineering samples.
+* By accepting the engineering samples, the Purchaser agrees to indemnify
+* Bosch Sensortec from all claims arising from the use of engineering
+* samples.
+*
+* Special:
+* This software module (hereinafter called "Software") and any information
+* on application-sheets (hereinafter called "Information") is provided
+* free of charge for the sole purpose to support your application work.
+* The Software and Information is subject to the following
+* terms and conditions:
+*
+* The Software is specifically designed for the exclusive use for
+* Bosch Sensortec products by personnel who have special experience
+* and training. Do not use this Software if you do not have the
+* proper experience or training.
+*
+* This Software package is provided `` as is `` and without any expressed
+* or implied warranties,including without limitation, the implied warranties
+* of merchantability and fitness for a particular purpose.
+*
+* Bosch Sensortec and their representatives and agents deny any liability
+* for the functional impairment
+* of this Software in terms of fitness, performance and safety.
+* Bosch Sensortec and their representatives and agents shall not be liable
+* for any direct or indirect damages or injury, except as
+* otherwise stipulated in mandatory applicable law.
+*
+* The Information provided is believed to be accurate and reliable.
+* Bosch Sensortec assumes no responsibility for the consequences of use
+* of such Information nor for any infringement of patents or
+* other rights of third parties which may result from its use.
+* No license is granted by implication or otherwise under any patent or
+* patent rights of Bosch. Specifications mentioned in the Information are
+* subject to change without notice.
+**************************************************************************/
+/*! file <BMI160 >
+ brief <Sensor driver for BMI160> */
+#include "bmi160.h"
+#include <linux/kernel.h>
+
+/* user defined code to be added here ... */
+struct bmi160_t *p_bmi160;
+/* used for reading the mag trim values for compensation*/
+struct trim_data_t mag_trim;
+/* the following variable used for avoiding the selecting of auto mode
+when it is running in the manual mode of BMM150 mag interface*/
+u8 V_bmm150_maual_auto_condition_u8 = BMI160_INIT_VALUE;
+/* used for reading the AKM compensating data */
+struct bst_akm_sensitivity_data_t akm_asa_data;
+/* Assign the fifo time */
+u32 V_fifo_time_U32 = BMI160_INIT_VALUE;
+
+/* FIFO data read for 1024 bytes of data */
+u8 v_fifo_data_u8[FIFO_FRAME] = {BMI160_INIT_VALUE};
+/* YAMAHA-YAS532*/
+/* value of coeff*/
+static const int yas532_version_ac_coef[] = {YAS532_VERSION_AC_COEF_X,
+YAS532_VERSION_AC_COEF_Y1, YAS532_VERSION_AC_COEF_Y2};
+/* used for reading the yas532 calibration data*/
+struct yas532_t yas532_data;
+/* used for reading the yas537 calibration data*/
+struct yas537_t yas537_data;
+/*!
+ * @brief
+ * This function is used for initialize
+ * bus read and bus write functions
+ * assign the chip id and device address
+ * chip id is read in the register 0x00 bit from 0 to 7
+ *
+ * @param bmi160 : structure pointer
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ * @note
+ * While changing the parameter of the bmi160_t
+ * consider the following point:
+ * Changing the reference value of the parameter
+ * will changes the local copy or local reference
+ * make sure your changes will not
+ * affect the reference value of the parameter
+ * (Better case don't change the reference value of the parameter)
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_init(struct bmi160_t *bmi160)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ u8 v_pmu_data_u8 = BMI160_INIT_VALUE;
+ /* assign bmi160 ptr */
+ p_bmi160 = bmi160;
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_CHIP_ID__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ /* read Chip Id */
+ p_bmi160->chip_id = v_data_u8;
+ /* To avoid gyro wakeup it is required to write 0x00 to 0x6C*/
+ com_rslt += bmi160_write_reg(BMI160_USER_PMU_TRIGGER_ADDR,
+ &v_pmu_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ return com_rslt;
+}
+/*!
+ * @brief
+ * This API write the data to
+ * the given register
+ *
+ *
+ * @param v_addr_u8 -> Address of the register
+ * @param v_data_u8 -> The data from the register
+ * @param v_len_u8 -> no of bytes to read
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_write_reg(u8 v_addr_u8,
+u8 *v_data_u8, u8 v_len_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* write data from register*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->dev_addr,
+ v_addr_u8, v_data_u8, v_len_u8);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief
+ * This API reads the data from
+ * the given register
+ *
+ *
+ * @param v_addr_u8 -> Address of the register
+ * @param v_data_u8 -> The data from the register
+ * @param v_len_u8 -> no of bytes to read
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_reg(u8 v_addr_u8,
+u8 *v_data_u8, u8 v_len_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* Read data from register*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ v_addr_u8, v_data_u8, v_len_u8);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API used to reads the fatal error
+ * from the Register 0x02 bit 0
+ * This flag will be reset only by power-on-reset and soft reset
+ *
+ *
+ * @param v_fatal_err_u8 : The status of fatal error
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fatal_err(u8
+*v_fatal_err_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* reading the fatal error status*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_FATAL_ERR__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_fatal_err_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_FATAL_ERR);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API used to read the error code
+ * from register 0x02 bit 1 to 4
+ *
+ *
+ * @param v_err_code_u8 : The status of error codes
+ * error_code | description
+ * ------------|---------------
+ * 0x00 |no error
+ * 0x01 |ACC_CONF error (accel ODR and bandwidth not compatible)
+ * 0x02 |GYR_CONF error (Gyroscope ODR and bandwidth not compatible)
+ * 0x03 |Under sampling mode and interrupt uses pre filtered data
+ * 0x04 |reserved
+ * 0x05 |Selected trigger-readout offset in
+ * - |MAG_IF greater than selected ODR
+ * 0x06 |FIFO configuration error for header less mode
+ * 0x07 |Under sampling mode and pre filtered data as FIFO source
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_err_code(u8
+*v_err_code_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_ERR_CODE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_err_code_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_ERR_CODE);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API Reads the i2c error code from the
+ * Register 0x02 bit 5.
+ * This error occurred in I2C master detected
+ *
+ * @param v_i2c_err_code_u8 : The status of i2c fail error
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_i2c_fail_err(u8
+*v_i2c_err_code_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_I2C_FAIL_ERR__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_i2c_err_code_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_I2C_FAIL_ERR);
+ }
+ return com_rslt;
+}
+ /*!
+ * @brief This API Reads the dropped command error
+ * from the register 0x02 bit 6
+ *
+ *
+ * @param v_drop_cmd_err_u8 : The status of drop command error
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_drop_cmd_err(u8
+*v_drop_cmd_err_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(
+ p_bmi160->dev_addr,
+ BMI160_USER_DROP_CMD_ERR__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_drop_cmd_err_u8 = BMI160_GET_BITSLICE(
+ v_data_u8,
+ BMI160_USER_DROP_CMD_ERR);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the magnetometer data ready
+ * interrupt not active.
+ * It reads from the error register 0x0x2 bit 7
+ *
+ *
+ *
+ *
+ * @param v_mag_data_rdy_err_u8 : The status of mag data ready interrupt
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_dada_rdy_err(
+u8 *v_mag_data_rdy_err_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(
+ p_bmi160->dev_addr,
+ BMI160_USER_MAG_DADA_RDY_ERR__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_mag_data_rdy_err_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_MAG_DADA_RDY_ERR);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the error status
+ * from the error register 0x02 bit 0 to 7
+ *
+ * @param v_mag_data_rdy_err_u8 : The status of mag data ready interrupt
+ * @param v_fatal_er_u8r : The status of fatal error
+ * @param v_err_code_u8 : The status of error code
+ * @param v_i2c_fail_err_u8 : The status of I2C fail error
+ * @param v_drop_cmd_err_u8 : The status of drop command error
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_error_status(u8 *v_fatal_er_u8r,
+u8 *v_err_code_u8, u8 *v_i2c_fail_err_u8,
+u8 *v_drop_cmd_err_u8, u8 *v_mag_data_rdy_err_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read the error codes*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(
+ p_bmi160->dev_addr,
+ BMI160_USER_ERR_STAT__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ /* fatal error*/
+ *v_fatal_er_u8r =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_FATAL_ERR);
+ /* user error*/
+ *v_err_code_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_ERR_CODE);
+ /* i2c fail error*/
+ *v_i2c_fail_err_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_I2C_FAIL_ERR);
+ /* drop command error*/
+ *v_drop_cmd_err_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_DROP_CMD_ERR);
+ /* mag data ready error*/
+ *v_mag_data_rdy_err_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_MAG_DADA_RDY_ERR);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the magnetometer power mode from
+ * PMU status register 0x03 bit 0 and 1
+ *
+ * @param v_mag_power_mode_stat_u8 : The value of mag power mode
+ * mag_powermode | value
+ * ------------------|----------
+ * SUSPEND | 0x00
+ * NORMAL | 0x01
+ * LOW POWER | 0x02
+ *
+ *
+ * @note The power mode of mag set by the 0x7E command register
+ * @note using the function "bmi160_set_command_register()"
+ * value | mode
+ * ---------|----------------
+ * 0x18 | MAG_MODE_SUSPEND
+ * 0x19 | MAG_MODE_NORMAL
+ * 0x1A | MAG_MODE_LOWPOWER
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_power_mode_stat(u8
+*v_mag_power_mode_stat_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_MAG_POWER_MODE_STAT__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_mag_power_mode_stat_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_MAG_POWER_MODE_STAT);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the gyroscope power mode from
+ * PMU status register 0x03 bit 2 and 3
+ *
+ * @param v_gyro_power_mode_stat_u8 : The value of gyro power mode
+ * gyro_powermode | value
+ * ------------------|----------
+ * SUSPEND | 0x00
+ * NORMAL | 0x01
+ * FAST POWER UP | 0x03
+ *
+ * @note The power mode of gyro set by the 0x7E command register
+ * @note using the function "bmi160_set_command_register()"
+ * value | mode
+ * ---------|----------------
+ * 0x14 | GYRO_MODE_SUSPEND
+ * 0x15 | GYRO_MODE_NORMAL
+ * 0x17 | GYRO_MODE_FASTSTARTUP
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_power_mode_stat(u8
+*v_gyro_power_mode_stat_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_GYRO_POWER_MODE_STAT__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_gyro_power_mode_stat_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_GYRO_POWER_MODE_STAT);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the accelerometer power mode from
+ * PMU status register 0x03 bit 4 and 5
+ *
+ *
+ * @param v_accel_power_mode_stat_u8 : The value of accel power mode
+ * accel_powermode | value
+ * ------------------|----------
+ * SUSPEND | 0x00
+ * NORMAL | 0x01
+ * LOW POWER | 0x02
+ *
+ * @note The power mode of accel set by the 0x7E command register
+ * @note using the function "bmi160_set_command_register()"
+ * value | mode
+ * ---------|----------------
+ * 0x11 | ACCEL_MODE_NORMAL
+ * 0x12 | ACCEL_LOWPOWER
+ * 0x10 | ACCEL_SUSPEND
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_power_mode_stat(u8
+*v_accel_power_mode_stat_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_ACCEL_POWER_MODE_STAT__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_accel_power_mode_stat_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_ACCEL_POWER_MODE_STAT);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API switch mag interface to normal mode
+ * and confirm whether the mode switching done successfully or not
+*
+ * @return results of bus communication function and current MAG_PMU result
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_interface_normal(void)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = BMI160_INIT_VALUE;
+ /* aim to check the result of switching mag normal */
+ u8 v_try_times_u8 = BMI160_MAG_NOAMRL_SWITCH_TIMES;
+ u8 v_mag_pum_status_u8 = BMI160_INIT_VALUE;
+
+ p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+ com_rslt = bmi160_set_command_register(MAG_MODE_NORMAL);
+ p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+ while (v_try_times_u8) {
+ com_rslt = bmi160_get_mag_power_mode_stat(&v_mag_pum_status_u8);
+ if (v_mag_pum_status_u8 == MAG_INTERFACE_PMU_ENABLE)
+ break;
+ p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+ v_try_times_u8--;
+ }
+ if (v_mag_pum_status_u8 == MAG_INTERFACE_PMU_ENABLE)
+ com_rslt += SUCCESS;
+ else
+ com_rslt += E_BMI160_COMM_RES;
+
+ return com_rslt;
+}
+/*!
+ * @brief This API reads magnetometer data X values
+ * from the register 0x04 and 0x05
+ * @brief The mag sensor data read form auxiliary mag
+ *
+ * @param v_mag_x_s16 : The value of mag x
+ * @param v_sensor_select_u8 : Mag selection value
+ * value | sensor
+ * ---------|----------------
+ * 0 | BMM150
+ * 1 | AKM09911 or AKM09912
+ *
+ * @note For mag data output rate configuration use the following function
+ * @note bmi160_set_mag_output_data_rate()
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_x(s16 *v_mag_x_s16,
+u8 v_sensor_select_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ /* Array contains the mag X lSB and MSB data
+ v_data_u8[0] - LSB
+ v_data_u8[1] - MSB*/
+ u8 v_data_u8[BMI160_MAG_X_DATA_SIZE] = {BMI160_INIT_VALUE,
+ BMI160_INIT_VALUE};
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ switch (v_sensor_select_u8) {
+ case BST_BMM:
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(
+ p_bmi160->dev_addr,
+ BMI160_USER_DATA_MAG_X_LSB__REG,
+ v_data_u8, BMI160_MAG_X_DATA_LENGTH);
+ /* X axis*/
+ v_data_u8[BMI160_MAG_X_LSB_BYTE] =
+ BMI160_GET_BITSLICE(v_data_u8[BMI160_MAG_X_LSB_BYTE],
+ BMI160_USER_DATA_MAG_X_LSB);
+ *v_mag_x_s16 = (s16)
+ ((((s32)((s8)v_data_u8[BMI160_MAG_X_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_05_BITS) |
+ (v_data_u8[BMI160_MAG_X_LSB_BYTE]));
+ break;
+ case BST_AKM:
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_DATA_0_MAG_X_LSB__REG,
+ v_data_u8, BMI160_MAG_X_DATA_LENGTH);
+ *v_mag_x_s16 = (s16)
+ ((((s32)((s8)v_data_u8[BMI160_MAG_X_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
+ (v_data_u8[BMI160_MAG_X_LSB_BYTE]));
+ break;
+ default:
+ com_rslt = E_BMI160_OUT_OF_RANGE;
+ break;
+ }
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads magnetometer data Y values
+ * from the register 0x06 and 0x07
+ * @brief The mag sensor data read form auxiliary mag
+ *
+ * @param v_mag_y_s16 : The value of mag y
+ * @param v_sensor_select_u8 : Mag selection value
+ * value | sensor
+ * ---------|----------------
+ * 0 | BMM150
+ * 1 | AKM09911 or AKM09912
+ *
+ * @note For mag data output rate configuration use the following function
+ * @note bmi160_set_mag_output_data_rate()
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_y(s16 *v_mag_y_s16,
+u8 v_sensor_select_u8)
+{
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_OUT_OF_RANGE;
+ /* Array contains the mag Y lSB and MSB data
+ v_data_u8[0] - LSB
+ v_data_u8[1] - MSB*/
+ u8 v_data_u8[BMI160_MAG_Y_DATA_SIZE] = {BMI160_INIT_VALUE,
+ BMI160_INIT_VALUE};
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ switch (v_sensor_select_u8) {
+ case BST_BMM:
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(
+ p_bmi160->dev_addr,
+ BMI160_USER_DATA_MAG_Y_LSB__REG,
+ v_data_u8, BMI160_MAG_Y_DATA_LENGTH);
+ /*Y-axis lsb value shifting*/
+ v_data_u8[BMI160_MAG_Y_LSB_BYTE] =
+ BMI160_GET_BITSLICE(v_data_u8[BMI160_MAG_Y_LSB_BYTE],
+ BMI160_USER_DATA_MAG_Y_LSB);
+ *v_mag_y_s16 = (s16)
+ ((((s32)((s8)v_data_u8[BMI160_MAG_Y_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_05_BITS) |
+ (v_data_u8[BMI160_MAG_Y_LSB_BYTE]));
+ break;
+ case BST_AKM:
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(
+ p_bmi160->dev_addr,
+ BMI160_USER_DATA_2_MAG_Y_LSB__REG,
+ v_data_u8, BMI160_MAG_Y_DATA_LENGTH);
+ *v_mag_y_s16 = (s16)
+ ((((s32)((s8)v_data_u8[BMI160_MAG_Y_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
+ (v_data_u8[BMI160_MAG_Y_LSB_BYTE]));
+ break;
+ default:
+ com_rslt = E_BMI160_OUT_OF_RANGE;
+ break;
+ }
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads magnetometer data Z values
+ * from the register 0x08 and 0x09
+ * @brief The mag sensor data read form auxiliary mag
+ *
+ * @param v_mag_z_s16 : The value of mag z
+ * @param v_sensor_select_u8 : Mag selection value
+ * value | sensor
+ * ---------|----------------
+ * 0 | BMM150
+ * 1 | AKM09911 or AKM09912
+ *
+ * @note For mag data output rate configuration use the following function
+ * @note bmi160_set_mag_output_data_rate()
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_z(s16 *v_mag_z_s16,
+u8 v_sensor_select_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ /* Array contains the mag Z lSB and MSB data
+ v_data_u8[0] - LSB
+ v_data_u8[1] - MSB*/
+ u8 v_data_u8[BMI160_MAG_Z_DATA_SIZE] = {BMI160_INIT_VALUE,
+ BMI160_INIT_VALUE};
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ switch (v_sensor_select_u8) {
+ case BST_BMM:
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(
+ p_bmi160->dev_addr,
+ BMI160_USER_DATA_MAG_Z_LSB__REG,
+ v_data_u8, BMI160_MAG_Z_DATA_LENGTH);
+ /*Z-axis lsb value shifting*/
+ v_data_u8[BMI160_MAG_Z_LSB_BYTE] =
+ BMI160_GET_BITSLICE(v_data_u8[BMI160_MAG_Z_LSB_BYTE],
+ BMI160_USER_DATA_MAG_Z_LSB);
+ *v_mag_z_s16 = (s16)
+ ((((s32)((s8)v_data_u8[BMI160_MAG_Z_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_07_BITS) |
+ (v_data_u8[BMI160_MAG_Z_LSB_BYTE]));
+ break;
+ case BST_AKM:
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(
+ p_bmi160->dev_addr,
+ BMI160_USER_DATA_4_MAG_Z_LSB__REG,
+ v_data_u8, BMI160_MAG_Z_DATA_LENGTH);
+ *v_mag_z_s16 = (s16)
+ ((((s32)((s8)v_data_u8[BMI160_MAG_Z_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_08_BITS) | (
+ v_data_u8[BMI160_MAG_Z_LSB_BYTE]));
+ break;
+ default:
+ com_rslt = E_BMI160_OUT_OF_RANGE;
+ break;
+ }
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads magnetometer data RHALL values
+ * from the register 0x0A and 0x0B
+ *
+ *
+ * @param v_mag_r_s16 : The value of BMM150 r data
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_r(s16 *v_mag_r_s16)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ /* Array contains the mag R lSB and MSB data
+ v_data_u8[0] - LSB
+ v_data_u8[1] - MSB*/
+ u8 v_data_u8[BMI160_MAG_R_DATA_SIZE] = {BMI160_INIT_VALUE,
+ BMI160_INIT_VALUE};
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_DATA_6_RHALL_LSB__REG,
+ v_data_u8, BMI160_MAG_R_DATA_LENGTH);
+ /*R-axis lsb value shifting*/
+ v_data_u8[BMI160_MAG_R_LSB_BYTE] =
+ BMI160_GET_BITSLICE(v_data_u8[BMI160_MAG_R_LSB_BYTE],
+ BMI160_USER_DATA_MAG_R_LSB);
+ *v_mag_r_s16 = (s16)
+ ((((s32)((s8)v_data_u8[BMI160_MAG_R_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_06_BITS) |
+ (v_data_u8[BMI160_MAG_R_LSB_BYTE]));
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads magnetometer data X,Y,Z values
+ * from the register 0x04 to 0x09
+ *
+ * @brief The mag sensor data read form auxiliary mag
+ *
+ * @param mag : The value of mag xyz data
+ * @param v_sensor_select_u8 : Mag selection value
+ * value | sensor
+ * ---------|----------------
+ * 0 | BMM150
+ * 1 | AKM09911 or AKM09912
+ *
+ * @note For mag data output rate configuration use the following function
+ * @note bmi160_set_mag_output_data_rate()
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_xyz(
+struct bmi160_mag_t *mag, u8 v_sensor_select_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ /* Array contains the mag XYZ lSB and MSB data
+ v_data_u8[0] - X-LSB
+ v_data_u8[1] - X-MSB
+ v_data_u8[0] - Y-LSB
+ v_data_u8[1] - Y-MSB
+ v_data_u8[0] - Z-LSB
+ v_data_u8[1] - Z-MSB
+ */
+ u8 v_data_u8[BMI160_MAG_XYZ_DATA_SIZE] = {
+ BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+ BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+ BMI160_INIT_VALUE, BMI160_INIT_VALUE};
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ switch (v_sensor_select_u8) {
+ case BST_BMM:
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(
+ p_bmi160->dev_addr,
+ BMI160_USER_DATA_MAG_X_LSB__REG,
+ v_data_u8, BMI160_MAG_XYZ_DATA_LENGTH);
+ /*X-axis lsb value shifting*/
+ v_data_u8[BMI160_DATA_FRAME_MAG_X_LSB_BYTE] =
+ BMI160_GET_BITSLICE(
+ v_data_u8[BMI160_DATA_FRAME_MAG_X_LSB_BYTE],
+ BMI160_USER_DATA_MAG_X_LSB);
+ /* Data X */
+ mag->x = (s16)
+ ((((s32)((s8)v_data_u8[
+ BMI160_DATA_FRAME_MAG_X_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_05_BITS) |
+ (v_data_u8[BMI160_DATA_FRAME_MAG_X_LSB_BYTE]));
+ /* Data Y */
+ /*Y-axis lsb value shifting*/
+ v_data_u8[BMI160_DATA_FRAME_MAG_Y_LSB_BYTE] =
+ BMI160_GET_BITSLICE(
+ v_data_u8[BMI160_DATA_FRAME_MAG_Y_LSB_BYTE],
+ BMI160_USER_DATA_MAG_Y_LSB);
+ mag->y = (s16)
+ ((((s32)((s8)v_data_u8[
+ BMI160_DATA_FRAME_MAG_Y_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_05_BITS) |
+ (v_data_u8[BMI160_DATA_FRAME_MAG_Y_LSB_BYTE]));
+
+ /* Data Z */
+ /*Z-axis lsb value shifting*/
+ v_data_u8[BMI160_DATA_FRAME_MAG_Z_LSB_BYTE]
+ = BMI160_GET_BITSLICE(
+ v_data_u8[BMI160_DATA_FRAME_MAG_Z_LSB_BYTE],
+ BMI160_USER_DATA_MAG_Z_LSB);
+ mag->z = (s16)
+ ((((s32)((s8)v_data_u8[
+ BMI160_DATA_FRAME_MAG_Z_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_07_BITS) |
+ (v_data_u8[BMI160_DATA_FRAME_MAG_Z_LSB_BYTE]));
+ break;
+ case BST_AKM:
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_DATA_0_MAG_X_LSB__REG,
+ v_data_u8, BMI160_MAG_XYZ_DATA_LENGTH);
+ /* Data X */
+ mag->x = (s16)
+ ((((s32)((s8)v_data_u8[
+ BMI160_DATA_FRAME_MAG_X_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
+ (v_data_u8[BMI160_DATA_FRAME_MAG_X_LSB_BYTE]));
+ /* Data Y */
+ mag->y = ((((s32)((s8)v_data_u8[
+ BMI160_DATA_FRAME_MAG_Y_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
+ (v_data_u8[BMI160_DATA_FRAME_MAG_Y_LSB_BYTE]));
+ /* Data Z */
+ mag->z = (s16)
+ ((((s32)((s8)v_data_u8[
+ BMI160_DATA_FRAME_MAG_Z_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
+ (v_data_u8[BMI160_DATA_FRAME_MAG_Z_LSB_BYTE]));
+ break;
+ default:
+ com_rslt = E_BMI160_OUT_OF_RANGE;
+ break;
+ }
+ }
+ return com_rslt;
+}
+ /*!*
+ * @brief This API reads magnetometer data X,Y,Z,r
+ * values from the register 0x04 to 0x0B
+ *
+ * @brief The mag sensor data read form auxiliary mag
+ *
+ * @param mag : The value of mag-BMM150 xyzr data
+ *
+ * @note For mag data output rate configuration use the following function
+ * @note bmi160_set_mag_output_data_rate()
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_xyzr(
+struct bmi160_mag_xyzr_t *mag)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8[BMI160_MAG_XYZR_DATA_SIZE] = {
+ BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+ BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+ BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_DATA_MAG_X_LSB__REG,
+ v_data_u8, BMI160_MAG_XYZR_DATA_LENGTH);
+
+ /* Data X */
+ /*X-axis lsb value shifting*/
+ v_data_u8[BMI160_DATA_FRAME_MAG_X_LSB_BYTE]
+ = BMI160_GET_BITSLICE(
+ v_data_u8[BMI160_DATA_FRAME_MAG_X_LSB_BYTE],
+ BMI160_USER_DATA_MAG_X_LSB);
+ mag->x = (s16)
+ ((((s32)((s8)v_data_u8[
+ BMI160_DATA_FRAME_MAG_X_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_05_BITS)
+ | (v_data_u8[BMI160_DATA_FRAME_MAG_X_LSB_BYTE]));
+ /* Data Y */
+ /*Y-axis lsb value shifting*/
+ v_data_u8[BMI160_DATA_FRAME_MAG_Y_LSB_BYTE]
+ = BMI160_GET_BITSLICE(
+ v_data_u8[BMI160_DATA_FRAME_MAG_Y_LSB_BYTE],
+ BMI160_USER_DATA_MAG_Y_LSB);
+ mag->y = (s16)
+ ((((s32)((s8)v_data_u8[
+ BMI160_DATA_FRAME_MAG_Y_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_05_BITS)
+ | (v_data_u8[
+ BMI160_DATA_FRAME_MAG_Y_LSB_BYTE]));
+
+ /* Data Z */
+ /*Z-axis lsb value shifting*/
+ v_data_u8[BMI160_DATA_FRAME_MAG_Z_LSB_BYTE]
+ = BMI160_GET_BITSLICE(
+ v_data_u8[BMI160_DATA_FRAME_MAG_Z_LSB_BYTE],
+ BMI160_USER_DATA_MAG_Z_LSB);
+ mag->z = (s16)
+ ((((s32)((s8)v_data_u8[
+ BMI160_DATA_FRAME_MAG_Z_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_07_BITS)
+ | (v_data_u8[BMI160_DATA_FRAME_MAG_Z_LSB_BYTE]));
+
+ /* RHall */
+ /*R-axis lsb value shifting*/
+ v_data_u8[BMI160_DATA_FRAME_MAG_R_LSB_BYTE]
+ = BMI160_GET_BITSLICE(
+ v_data_u8[BMI160_DATA_FRAME_MAG_R_LSB_BYTE],
+ BMI160_USER_DATA_MAG_R_LSB);
+ mag->r = (s16)
+ ((((s32)((s8)v_data_u8[
+ BMI160_DATA_FRAME_MAG_R_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_06_BITS)
+ | (v_data_u8[BMI160_DATA_FRAME_MAG_R_LSB_BYTE]));
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads gyro data X values
+ * form the register 0x0C and 0x0D
+ *
+ *
+ *
+ *
+ * @param v_gyro_x_s16 : The value of gyro x data
+ *
+ * @note Gyro Configuration use the following function
+ * @note bmi160_set_gyro_output_data_rate()
+ * @note bmi160_set_gyro_bw()
+ * @note bmi160_set_gyro_range()
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_gyro_x(s16 *v_gyro_x_s16)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ /* Array contains the gyro X lSB and MSB data
+ v_data_u8[0] - LSB
+ v_data_u8[MSB_ONE] - MSB*/
+ u8 v_data_u8[BMI160_GYRO_X_DATA_SIZE] = {BMI160_INIT_VALUE,
+ BMI160_INIT_VALUE};
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_DATA_8_GYRO_X_LSB__REG,
+ v_data_u8, BMI160_GYRO_DATA_LENGTH);
+
+ *v_gyro_x_s16 = (s16)
+ ((((s32)((s8)v_data_u8[BMI160_GYRO_X_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+ | (v_data_u8[BMI160_GYRO_X_LSB_BYTE]));
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads gyro data Y values
+ * form the register 0x0E and 0x0F
+ *
+ *
+ *
+ *
+ * @param v_gyro_y_s16 : The value of gyro y data
+ *
+ * @note Gyro Configuration use the following function
+ * @note bmi160_set_gyro_output_data_rate()
+ * @note bmi160_set_gyro_bw()
+ * @note bmi160_set_gyro_range()
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error result of communication routines
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_gyro_y(s16 *v_gyro_y_s16)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ /* Array contains the gyro Y lSB and MSB data
+ v_data_u8[LSB_ZERO] - LSB
+ v_data_u8[MSB_ONE] - MSB*/
+ u8 v_data_u8[BMI160_GYRO_Y_DATA_SIZE] = {BMI160_INIT_VALUE,
+ BMI160_INIT_VALUE};
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read gyro y data*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_DATA_10_GYRO_Y_LSB__REG,
+ v_data_u8, BMI160_GYRO_DATA_LENGTH);
+
+ *v_gyro_y_s16 = (s16)
+ ((((s32)((s8)v_data_u8[BMI160_GYRO_Y_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+ | (v_data_u8[BMI160_GYRO_Y_LSB_BYTE]));
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads gyro data Z values
+ * form the register 0x10 and 0x11
+ *
+ *
+ *
+ *
+ * @param v_gyro_z_s16 : The value of gyro z data
+ *
+ * @note Gyro Configuration use the following function
+ * @note bmi160_set_gyro_output_data_rate()
+ * @note bmi160_set_gyro_bw()
+ * @note bmi160_set_gyro_range()
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_gyro_z(s16 *v_gyro_z_s16)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ /* Array contains the gyro Z lSB and MSB data
+ v_data_u8[LSB_ZERO] - LSB
+ v_data_u8[MSB_ONE] - MSB*/
+ u8 v_data_u8[BMI160_GYRO_Z_DATA_SIZE] = {BMI160_INIT_VALUE,
+ BMI160_INIT_VALUE};
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read gyro z data */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_DATA_12_GYRO_Z_LSB__REG,
+ v_data_u8, BMI160_GYRO_DATA_LENGTH);
+
+ *v_gyro_z_s16 = (s16)
+ ((((s32)((s8)v_data_u8[BMI160_GYRO_Z_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+ | (v_data_u8[BMI160_GYRO_Z_LSB_BYTE]));
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads gyro data X,Y,Z values
+ * from the register 0x0C to 0x11
+ *
+ *
+ *
+ *
+ * @param gyro : The value of gyro xyz
+ *
+ * @note Gyro Configuration use the following function
+ * @note bmi160_set_gyro_output_data_rate()
+ * @note bmi160_set_gyro_bw()
+ * @note bmi160_set_gyro_range()
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_gyro_xyz(struct bmi160_gyro_t *gyro)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ /* Array contains the mag XYZ lSB and MSB data
+ v_data_u8[0] - X-LSB
+ v_data_u8[1] - X-MSB
+ v_data_u8[0] - Y-LSB
+ v_data_u8[1] - Y-MSB
+ v_data_u8[0] - Z-LSB
+ v_data_u8[1] - Z-MSB
+ */
+ u8 v_data_u8[BMI160_GYRO_XYZ_DATA_SIZE] = {
+ BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+ BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+ BMI160_INIT_VALUE, BMI160_INIT_VALUE};
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read the gyro xyz data*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_DATA_8_GYRO_X_LSB__REG,
+ v_data_u8, BMI160_GYRO_XYZ_DATA_LENGTH);
+
+ /* Data X */
+ gyro->x = (s16)
+ ((((s32)((s8)v_data_u8[
+ BMI160_DATA_FRAME_GYRO_X_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+ | (v_data_u8[BMI160_DATA_FRAME_GYRO_X_LSB_BYTE]));
+ /* Data Y */
+ gyro->y = (s16)
+ ((((s32)((s8)v_data_u8[
+ BMI160_DATA_FRAME_GYRO_Y_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+ | (v_data_u8[BMI160_DATA_FRAME_GYRO_Y_LSB_BYTE]));
+
+ /* Data Z */
+ gyro->z = (s16)
+ ((((s32)((s8)v_data_u8[
+ BMI160_DATA_FRAME_GYRO_Z_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+ | (v_data_u8[BMI160_DATA_FRAME_GYRO_Z_LSB_BYTE]));
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads accelerometer data X values
+ * form the register 0x12 and 0x13
+ *
+ *
+ *
+ *
+ * @param v_accel_x_s16 : The value of accel x
+ *
+ * @note For accel configuration use the following functions
+ * @note bmi160_set_accel_output_data_rate()
+ * @note bmi160_set_accel_bw()
+ * @note bmi160_set_accel_under_sampling_parameter()
+ * @note bmi160_set_accel_range()
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_accel_x(s16 *v_accel_x_s16)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ /* Array contains the accel X lSB and MSB data
+ v_data_u8[0] - LSB
+ v_data_u8[1] - MSB*/
+ u8 v_data_u8[BMI160_ACCEL_X_DATA_SIZE] = {BMI160_INIT_VALUE,
+ BMI160_INIT_VALUE};
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_DATA_14_ACCEL_X_LSB__REG,
+ v_data_u8, BMI160_ACCEL_DATA_LENGTH);
+
+ *v_accel_x_s16 = (s16)
+ ((((s32)((s8)v_data_u8[BMI160_ACCEL_X_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+ | (v_data_u8[BMI160_ACCEL_X_LSB_BYTE]));
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads accelerometer data Y values
+ * form the register 0x14 and 0x15
+ *
+ *
+ *
+ *
+ * @param v_accel_y_s16 : The value of accel y
+ *
+ * @note For accel configuration use the following functions
+ * @note bmi160_set_accel_output_data_rate()
+ * @note bmi160_set_accel_bw()
+ * @note bmi160_set_accel_under_sampling_parameter()
+ * @note bmi160_set_accel_range()
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_accel_y(s16 *v_accel_y_s16)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ /* Array contains the accel Y lSB and MSB data
+ v_data_u8[0] - LSB
+ v_data_u8[1] - MSB*/
+ u8 v_data_u8[BMI160_ACCEL_Y_DATA_SIZE] = {BMI160_INIT_VALUE,
+ BMI160_INIT_VALUE};
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_DATA_16_ACCEL_Y_LSB__REG,
+ v_data_u8, BMI160_ACCEL_DATA_LENGTH);
+
+ *v_accel_y_s16 = (s16)
+ ((((s32)((s8)v_data_u8[BMI160_ACCEL_Y_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+ | (v_data_u8[BMI160_ACCEL_Y_LSB_BYTE]));
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads accelerometer data Z values
+ * form the register 0x16 and 0x17
+ *
+ *
+ *
+ *
+ * @param v_accel_z_s16 : The value of accel z
+ *
+ * @note For accel configuration use the following functions
+ * @note bmi160_set_accel_output_data_rate()
+ * @note bmi160_set_accel_bw()
+ * @note bmi160_set_accel_under_sampling_parameter()
+ * @note bmi160_set_accel_range()
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_accel_z(s16 *v_accel_z_s16)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ /* Array contains the accel Z lSB and MSB data
+ a_data_u8r[LSB_ZERO] - LSB
+ a_data_u8r[MSB_ONE] - MSB*/
+ u8 a_data_u8r[BMI160_ACCEL_Z_DATA_SIZE] = {
+ BMI160_INIT_VALUE, BMI160_INIT_VALUE};
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_DATA_18_ACCEL_Z_LSB__REG,
+ a_data_u8r, BMI160_ACCEL_DATA_LENGTH);
+
+ *v_accel_z_s16 = (s16)
+ ((((s32)((s8)a_data_u8r[BMI160_ACCEL_Z_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+ | (a_data_u8r[BMI160_ACCEL_Z_LSB_BYTE]));
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads accelerometer data X,Y,Z values
+ * from the register 0x12 to 0x17
+ *
+ *
+ *
+ *
+ * @param accel :The value of accel xyz
+ *
+ * @note For accel configuration use the following functions
+ * @note bmi160_set_accel_output_data_rate()
+ * @note bmi160_set_accel_bw()
+ * @note bmi160_set_accel_under_sampling_parameter()
+ * @note bmi160_set_accel_range()
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_read_accel_xyz(
+struct bmi160_accel_t *accel)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ /* Array contains the accel XYZ lSB and MSB data
+ a_data_u8r[0] - X-LSB
+ a_data_u8r[1] - X-MSB
+ a_data_u8r[0] - Y-LSB
+ a_data_u8r[1] - Y-MSB
+ a_data_u8r[0] - Z-LSB
+ a_data_u8r[1] - Z-MSB
+ */
+ u8 a_data_u8r[BMI160_ACCEL_XYZ_DATA_SIZE] = {
+ BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+ BMI160_INIT_VALUE, BMI160_INIT_VALUE,
+ BMI160_INIT_VALUE, BMI160_INIT_VALUE};
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_DATA_14_ACCEL_X_LSB__REG,
+ a_data_u8r, BMI160_ACCEL_XYZ_DATA_LENGTH);
+
+ /* Data X */
+ accel->x = (s16)
+ ((((s32)((s8)a_data_u8r[
+ BMI160_DATA_FRAME_ACCEL_X_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+ | (a_data_u8r[BMI160_DATA_FRAME_ACCEL_X_LSB_BYTE]));
+ /* Data Y */
+ accel->y = (s16)
+ ((((s32)((s8)a_data_u8r[
+ BMI160_DATA_FRAME_ACCEL_Y_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+ | (a_data_u8r[BMI160_DATA_FRAME_ACCEL_Y_LSB_BYTE]));
+
+ /* Data Z */
+ accel->z = (s16)
+ ((((s32)((s8)a_data_u8r[
+ BMI160_DATA_FRAME_ACCEL_Z_MSB_BYTE]))
+ << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+ | (a_data_u8r[BMI160_DATA_FRAME_ACCEL_Z_LSB_BYTE]));
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads sensor_time from the register
+ * 0x18 to 0x1A
+ *
+ *
+ * @param v_sensor_time_u32 : The value of sensor time
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_sensor_time(u32 *v_sensor_time_u32)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ /* Array contains the sensor time it is 32 bit data
+ a_data_u8r[0] - sensor time
+ a_data_u8r[1] - sensor time
+ a_data_u8r[0] - sensor time
+ */
+ u8 a_data_u8r[BMI160_SENSOR_TIME_DATA_SIZE] = {BMI160_INIT_VALUE,
+ BMI160_INIT_VALUE, BMI160_INIT_VALUE};
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_SENSORTIME_0_SENSOR_TIME_LSB__REG,
+ a_data_u8r, BMI160_SENSOR_TIME_LENGTH);
+
+ *v_sensor_time_u32 = (u32)
+ ((((u32)a_data_u8r[BMI160_SENSOR_TIME_MSB_BYTE])
+ << BMI160_SHIFT_BIT_POSITION_BY_16_BITS)
+ |(((u32)a_data_u8r[BMI160_SENSOR_TIME_XLSB_BYTE])
+ << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
+ | (a_data_u8r[BMI160_SENSOR_TIME_LSB_BYTE]));
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the Gyroscope self test
+ * status from the register 0x1B bit 1
+ *
+ *
+ * @param v_gyro_selftest_u8 : The value of gyro self test status
+ * value | status
+ * ---------|----------------
+ * 0 | Gyroscope self test is running or failed
+ * 1 | Gyroscope self test completed successfully
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_selftest(u8
+*v_gyro_selftest_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_STAT_GYRO_SELFTEST_OK__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_gyro_selftest_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_STAT_GYRO_SELFTEST_OK);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the status of
+ * mag manual interface operation form the register 0x1B bit 2
+ *
+ *
+ *
+ * @param v_mag_manual_stat_u8 : The value of mag manual operation status
+ * value | status
+ * ---------|----------------
+ * 0 | Indicates no manual magnetometer
+ * - | interface operation is ongoing
+ * 1 | Indicates manual magnetometer
+ * - | interface operation is ongoing
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_manual_operation_stat(u8
+*v_mag_manual_stat_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read manual operation*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_STAT_MAG_MANUAL_OPERATION__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_mag_manual_stat_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_STAT_MAG_MANUAL_OPERATION);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the fast offset compensation
+ * status form the register 0x1B bit 3
+ *
+ *
+ * @param v_foc_rdy_u8 : The status of fast compensation
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_rdy(u8
+*v_foc_rdy_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read the FOC status*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_STAT_FOC_RDY__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_foc_rdy_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_STAT_FOC_RDY);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API Reads the nvm_rdy status from the
+ * resister 0x1B bit 4
+ *
+ *
+ * @param v_nvm_rdy_u8 : The value of NVM ready status
+ * value | status
+ * ---------|----------------
+ * 0 | NVM write operation in progress
+ * 1 | NVM is ready to accept a new write trigger
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_nvm_rdy(u8
+*v_nvm_rdy_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read the nvm ready status*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_STAT_NVM_RDY__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_nvm_rdy_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_STAT_NVM_RDY);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the status of mag data ready
+ * from the register 0x1B bit 5
+ * The status get reset when one mag data register is read out
+ *
+ * @param v_data_rdy_u8 : The value of mag data ready status
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_data_rdy_mag(u8
+*v_data_rdy_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_STAT_DATA_RDY_MAG__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_data_rdy_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_STAT_DATA_RDY_MAG);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the status of gyro data ready form the
+ * register 0x1B bit 6
+ * The status get reset when gyro data register read out
+ *
+ *
+ * @param v_data_rdy_u8 : The value of gyro data ready
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_data_rdy(u8
+*v_data_rdy_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_STAT_DATA_RDY_GYRO__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_data_rdy_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_STAT_DATA_RDY_GYRO);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the status of accel data ready form the
+ * register 0x1B bit 7
+ * The status get reset when accel data register read out
+ *
+ *
+ * @param v_data_rdy_u8 : The value of accel data ready status
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_data_rdy(u8
+*v_data_rdy_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /*reads the status of accel data ready*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_STAT_DATA_RDY_ACCEL__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_data_rdy_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_STAT_DATA_RDY_ACCEL);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the step detector interrupt status
+ * from the register 0x1C bit 0
+ * flag is associated with a specific interrupt function.
+ * It is set when the single tab interrupt triggers. The
+ * setting of INT_LATCH controls if the interrupt
+ * signal and hence the
+ * respective interrupt flag will be
+ * permanently latched, temporarily latched
+ * or not latched.
+ *
+ *
+ *
+ *
+ * @param v_step_intr_u8 : The status of step detector interrupt
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_step_intr(u8
+*v_step_intr_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_0_STEP_INTR__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_step_intr_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_0_STEP_INTR);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the
+ * significant motion interrupt status
+ * from the register 0x1C bit 1
+ * flag is associated with a specific interrupt function.
+ * It is set when the single tab interrupt triggers. The
+ * setting of INT_LATCH controls if the interrupt
+ * signal and hence the
+ * respective interrupt flag will be
+ * permanently latched, temporarily latched
+ * or not latched.
+ *
+ *
+ *
+ *
+ *
+ * @param v_significant_intr_u8 : The status of step
+ * motion interrupt
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_significant_intr(u8
+*v_significant_intr_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_0_SIGNIFICANT_INTR__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_significant_intr_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_0_SIGNIFICANT_INTR);
+ }
+ return com_rslt;
+}
+ /*!
+ * @brief This API reads the any motion interrupt status
+ * from the register 0x1C bit 2
+ * flag is associated with a specific interrupt function.
+ * It is set when the single tab interrupt triggers. The
+ * setting of INT_LATCH controls if the interrupt
+ * signal and hence the
+ * respective interrupt flag will be
+ * permanently latched, temporarily latched
+ * or not latched.
+ *
+ *
+ *
+ * @param v_any_motion_intr_u8 : The status of any-motion interrupt
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_any_motion_intr(u8
+*v_any_motion_intr_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_0_ANY_MOTION__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_any_motion_intr_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_0_ANY_MOTION);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the power mode trigger interrupt status
+ * from the register 0x1C bit 3
+ * flag is associated with a specific interrupt function.
+ * It is set when the single tab interrupt triggers. The
+ * setting of INT_LATCH controls if the interrupt
+ * signal and hence the
+ * respective interrupt flag will be
+ * permanently latched, temporarily latched
+ * or not latched.
+ *
+ *
+ *
+ *
+ *
+ * @param v_pmu_trigger_intr_u8 : The status of power mode trigger interrupt
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_pmu_trigger_intr(u8
+*v_pmu_trigger_intr_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_0_PMU_TRIGGER__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_pmu_trigger_intr_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_0_PMU_TRIGGER);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the double tab status
+ * from the register 0x1C bit 4
+ * flag is associated with a specific interrupt function.
+ * It is set when the single tab interrupt triggers. The
+ * setting of INT_LATCH controls if the interrupt
+ * signal and hence the
+ * respective interrupt flag will be
+ * permanently latched, temporarily latched
+ * or not latched.
+ *
+ *
+ *
+ *
+ * @param v_double_tap_intr_u8 :The status of double tab interrupt
+ *
+ * @note Double tap interrupt can be configured by the following functions
+ * @note INTERRUPT MAPPING
+ * @note bmi160_set_intr_double_tap()
+ * @note AXIS MAPPING
+ * @note bmi160_get_stat2_tap_first_x()
+ * @note bmi160_get_stat2_tap_first_y()
+ * @note bmi160_get_stat2_tap_first_z()
+ * @note DURATION
+ * @note bmi160_set_intr_tap_durn()
+ * @note THRESHOLD
+ * @note bmi160_set_intr_tap_thres()
+ * @note TAP QUIET
+ * @note bmi160_set_intr_tap_quiet()
+ * @note TAP SHOCK
+ * @note bmi160_set_intr_tap_shock()
+ * @note TAP SOURCE
+ * @note bmi160_set_intr_tap_source()
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_double_tap_intr(u8
+*v_double_tap_intr_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_0_DOUBLE_TAP_INTR__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_double_tap_intr_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_0_DOUBLE_TAP_INTR);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the single tab status
+ * from the register 0x1C bit 5
+ * flag is associated with a specific interrupt function.
+ * It is set when the single tab interrupt triggers. The
+ * setting of INT_LATCH controls if the interrupt
+ * signal and hence the
+ * respective interrupt flag will be
+ * permanently latched, temporarily latched
+ * or not latched.
+ *
+ *
+ *
+ *
+ * @param v_single_tap_intr_u8 :The status of single tap interrupt
+ *
+ * @note Single tap interrupt can be configured by the following functions
+ * @note INTERRUPT MAPPING
+ * @note bmi160_set_intr_single_tap()
+ * @note AXIS MAPPING
+ * @note bmi160_get_stat2_tap_first_x()
+ * @note bmi160_get_stat2_tap_first_y()
+ * @note bmi160_get_stat2_tap_first_z()
+ * @note DURATION
+ * @note bmi160_set_intr_tap_durn()
+ * @note THRESHOLD
+ * @note bmi160_set_intr_tap_thres()
+ * @note TAP QUIET
+ * @note bmi160_set_intr_tap_quiet()
+ * @note TAP SHOCK
+ * @note bmi160_set_intr_tap_shock()
+ * @note TAP SOURCE
+ * @note bmi160_set_intr_tap_source()
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_single_tap_intr(u8
+*v_single_tap_intr_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_0_SINGLE_TAP_INTR__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_single_tap_intr_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_0_SINGLE_TAP_INTR);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the orient status
+ * from the register 0x1C bit 6
+ * flag is associated with a specific interrupt function.
+ * It is set when the orient interrupt triggers. The
+ * setting of INT_LATCH controls if the
+ * interrupt signal and hence the
+ * respective interrupt flag will be
+ * permanently latched, temporarily latched
+ * or not latched.
+ *
+ *
+ *
+ *
+ * @param v_orient_intr_u8 : The status of orient interrupt
+ *
+ * @note For orient interrupt configuration use the following functions
+ * @note STATUS
+ * @note bmi160_get_stat0_orient_intr()
+ * @note AXIS MAPPING
+ * @note bmi160_get_stat3_orient_xy()
+ * @note bmi160_get_stat3_orient_z()
+ * @note bmi160_set_intr_orient_axes_enable()
+ * @note INTERRUPT MAPPING
+ * @note bmi160_set_intr_orient()
+ * @note INTERRUPT OUTPUT
+ * @note bmi160_set_intr_orient_ud_enable()
+ * @note THETA
+ * @note bmi160_set_intr_orient_theta()
+ * @note HYSTERESIS
+ * @note bmi160_set_intr_orient_hyst()
+ * @note BLOCKING
+ * @note bmi160_set_intr_orient_blocking()
+ * @note MODE
+ * @note bmi160_set_intr_orient_mode()
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_orient_intr(u8
+*v_orient_intr_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_0_ORIENT__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_orient_intr_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_0_ORIENT);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the flat interrupt status
+ * from the register 0x1C bit 7
+ * flag is associated with a specific interrupt function.
+ * It is set when the flat interrupt triggers. The
+ * setting of INT_LATCH controls if the
+ * interrupt signal and hence the
+ * respective interrupt flag will be
+ * permanently latched, temporarily latched
+ * or not latched.
+ *
+ *
+ *
+ *
+ * @param v_flat_intr_u8 : The status of flat interrupt
+ *
+ * @note For flat configuration use the following functions
+ * @note STATS
+ * @note bmi160_get_stat0_flat_intr()
+ * @note bmi160_get_stat3_flat()
+ * @note INTERRUPT MAPPING
+ * @note bmi160_set_intr_flat()
+ * @note THETA
+ * @note bmi160_set_intr_flat_theta()
+ * @note HOLD TIME
+ * @note bmi160_set_intr_flat_hold()
+ * @note HYSTERESIS
+ * @note bmi160_set_intr_flat_hyst()
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_flat_intr(u8
+*v_flat_intr_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_0_FLAT__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_flat_intr_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_0_FLAT);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the high_g interrupt status
+ * from the register 0x1D bit 2
+ * flag is associated with a specific interrupt function.
+ * It is set when the high g interrupt triggers. The
+ * setting of INT_LATCH controls if the interrupt signal and hence the
+ * respective interrupt flag will be permanently
+ * latched, temporarily latched
+ * or not latched.
+ *
+ *
+ *
+ *
+ * @param v_high_g_intr_u8 : The status of high_g interrupt
+ *
+ * @note High_g interrupt configured by following functions
+ * @note STATUS
+ * @note bmi160_get_stat1_high_g_intr()
+ * @note AXIS MAPPING
+ * @note bmi160_get_stat3_high_g_first_x()
+ * @note bmi160_get_stat3_high_g_first_y()
+ * @note bmi160_get_stat3_high_g_first_z()
+ * @note SIGN MAPPING
+ * @note bmi160_get_stat3_high_g_first_sign()
+ * @note INTERRUPT MAPPING
+ * @note bmi160_set_intr_high_g()
+ * @note HYSTERESIS
+ * @note bmi160_set_intr_high_g_hyst()
+ * @note DURATION
+ * @note bmi160_set_intr_high_g_durn()
+ * @note THRESHOLD
+ * @note bmi160_set_intr_high_g_thres()
+ * @note SOURCE
+ * @note bmi160_set_intr_low_high_source()
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_high_g_intr(u8
+*v_high_g_intr_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_1_HIGH_G_INTR__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_high_g_intr_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_1_HIGH_G_INTR);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the low g interrupt status
+ * from the register 0x1D bit 3
+ * flag is associated with a specific interrupt function.
+ * It is set when the low g interrupt triggers. The
+ * setting of INT_LATCH controls if the interrupt signal and hence the
+ * respective interrupt flag will be
+ * permanently latched, temporarily latched
+ * or not latched.
+ *
+ *
+ *
+ *
+ * @param v_low_g_intr_u8 : The status of low_g interrupt
+ *
+ * @note Low_g interrupt configured by following functions
+ * @note STATUS
+ * @note bmi160_get_stat1_low_g_intr()
+ * @note INTERRUPT MAPPING
+ * @note bmi160_set_intr_low_g()
+ * @note SOURCE
+ * @note bmi160_set_intr_low_high_source()
+ * @note DURATION
+ * @note bmi160_set_intr_low_g_durn()
+ * @note THRESHOLD
+ * @note bmi160_set_intr_low_g_thres()
+ * @note HYSTERESIS
+ * @note bmi160_set_intr_low_g_hyst()
+ * @note MODE
+ * @note bmi160_set_intr_low_g_mode()
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_low_g_intr(u8
+*v_low_g_intr_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_1_LOW_G_INTR__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_low_g_intr_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_1_LOW_G_INTR);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads data ready interrupt status
+ * from the register 0x1D bit 4
+ * flag is associated with a specific interrupt function.
+ * It is set when the data ready interrupt triggers. The
+ * setting of INT_LATCH controls if the interrupt signal and hence the
+ * respective interrupt flag will be
+ * permanently latched, temporarily latched
+ * or not latched.
+ *
+ *
+ *
+ *
+ * @param v_data_rdy_intr_u8 : The status of data ready interrupt
+ *
+ * @note Data ready interrupt configured by following functions
+ * @note STATUS
+ * @note bmi160_get_stat1_data_rdy_intr()
+ * @note INTERRUPT MAPPING
+ * @note bmi160_set_intr_data_rdy()
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_data_rdy_intr(u8
+*v_data_rdy_intr_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_1_DATA_RDY_INTR__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_data_rdy_intr_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_1_DATA_RDY_INTR);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads data ready FIFO full interrupt status
+ * from the register 0x1D bit 5
+ * flag is associated with a specific interrupt function.
+ * It is set when the FIFO full interrupt triggers. The
+ * setting of INT_LATCH controls if the
+ * interrupt signal and hence the
+ * respective interrupt flag will
+ * be permanently latched, temporarily latched
+ * or not latched.
+ *
+ *
+ *
+ *
+ * @param v_fifo_full_intr_u8 : The status of fifo full interrupt
+ *
+ * @note FIFO full interrupt can be configured by following functions
+ * @note bmi160_set_intr_fifo_full()
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_fifo_full_intr(u8
+*v_fifo_full_intr_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_1_FIFO_FULL_INTR__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_fifo_full_intr_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_1_FIFO_FULL_INTR);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads data
+ * ready FIFO watermark interrupt status
+ * from the register 0x1D bit 6
+ * flag is associated with a specific interrupt function.
+ * It is set when the FIFO watermark interrupt triggers. The
+ * setting of INT_LATCH controls if the
+ * interrupt signal and hence the
+ * respective interrupt flag will be
+ * permanently latched, temporarily latched
+ * or not latched.
+ *
+ *
+ *
+ *
+ * @param v_fifo_wm_intr_u8 : The status of fifo water mark interrupt
+ *
+ * @note FIFO full interrupt can be configured by following functions
+ * @note bmi160_set_intr_fifo_wm()
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_fifo_wm_intr(u8
+*v_fifo_wm_intr_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_1_FIFO_WM_INTR__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_fifo_wm_intr_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_1_FIFO_WM_INTR);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads data ready no motion interrupt status
+ * from the register 0x1D bit 7
+ * flag is associated with a specific interrupt function.
+ * It is set when the no motion interrupt triggers. The
+ * setting of INT_LATCH controls if the interrupt signal and hence the
+ * respective interrupt flag will be permanently
+ * latched, temporarily latched
+ * or not latched.
+ *
+ *
+ *
+ *
+ * @param v_nomotion_intr_u8 : The status of no motion interrupt
+ *
+ * @note No motion interrupt can be configured by following function
+ * @note STATUS
+ * @note bmi160_get_stat1_nomotion_intr()
+ * @note INTERRUPT MAPPING
+ * @note bmi160_set_intr_nomotion()
+ * @note DURATION
+ * @note bmi160_set_intr_slow_no_motion_durn()
+ * @note THRESHOLD
+ * @note bmi160_set_intr_slow_no_motion_thres()
+ * @note SLOW/NO MOTION SELECT
+ * @note bmi160_set_intr_slow_no_motion_select()
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_nomotion_intr(u8
+*v_nomotion_intr_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read the no motion interrupt*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_1_NOMOTION_INTR__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_nomotion_intr_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_1_NOMOTION_INTR);
+ }
+ return com_rslt;
+}
+/*!
+ *@brief This API reads the status of any motion first x
+ * from the register 0x1E bit 0
+ *
+ *
+ *@param v_anymotion_first_x_u8 : The status of any motion first x interrupt
+ * value | status
+ * -----------|-------------
+ * 0 | not triggered
+ * 1 | triggered by x axis
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_any_motion_first_x(u8
+*v_anymotion_first_x_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read the any motion first x interrupt*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_X__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_anymotion_first_x_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_X);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the status of any motion first y interrupt
+ * from the register 0x1E bit 1
+ *
+ *
+ *
+ *@param v_any_motion_first_y_u8 : The status of any motion first y interrupt
+ * value | status
+ * -----------|-------------
+ * 0 | not triggered
+ * 1 | triggered by y axis
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_any_motion_first_y(u8
+*v_any_motion_first_y_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read the any motion first y interrupt*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Y__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_any_motion_first_y_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Y);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the status of any motion first z interrupt
+ * from the register 0x1E bit 2
+ *
+ *
+ *
+ *
+ *@param v_any_motion_first_z_u8 : The status of any motion first z interrupt
+ * value | status
+ * -----------|-------------
+ * 0 | not triggered
+ * 1 | triggered by y axis
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_any_motion_first_z(u8
+*v_any_motion_first_z_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read the any motion first z interrupt*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Z__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_any_motion_first_z_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Z);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the any motion sign status from the
+ * register 0x1E bit 3
+ *
+ *
+ *
+ *
+ * @param v_anymotion_sign_u8 : The status of any motion sign
+ * value | sign
+ * -----------|-------------
+ * 0 | positive
+ * 1 | negative
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_any_motion_sign(u8
+*v_anymotion_sign_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read any motion sign interrupt status */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_2_ANY_MOTION_SIGN__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_anymotion_sign_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_2_ANY_MOTION_SIGN);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the any motion tap first x status from the
+ * register 0x1E bit 4
+ *
+ *
+ *
+ *
+ * @param v_tap_first_x_u8 :The status of any motion tap first x
+ * value | status
+ * -----------|-------------
+ * 0 | not triggered
+ * 1 | triggered by x axis
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_tap_first_x(u8
+*v_tap_first_x_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read tap first x interrupt status */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_2_TAP_FIRST_X__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_tap_first_x_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_2_TAP_FIRST_X);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the tap first y interrupt status from the
+ * register 0x1E bit 5
+ *
+ *
+ *
+ *
+ * @param v_tap_first_y_u8 :The status of tap first y interrupt
+ * value | status
+ * -----------|-------------
+ * 0 | not triggered
+ * 1 | triggered by y axis
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_tap_first_y(u8
+*v_tap_first_y_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read tap first y interrupt status */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_2_TAP_FIRST_Y__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_tap_first_y_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_2_TAP_FIRST_Y);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the tap first z interrupt status from the
+ * register 0x1E bit 6
+ *
+ *
+ *
+ *
+ * @param v_tap_first_z_u8 :The status of tap first z interrupt
+ * value | status
+ * -----------|-------------
+ * 0 | not triggered
+ * 1 | triggered by z axis
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_tap_first_z(u8
+*v_tap_first_z_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read tap first z interrupt status */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_2_TAP_FIRST_Z__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_tap_first_z_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_2_TAP_FIRST_Z);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the tap sign status from the
+ * register 0x1E bit 7
+ *
+ *
+ *
+ *
+ * @param v_tap_sign_u8 : The status of tap sign
+ * value | sign
+ * -----------|-------------
+ * 0 | positive
+ * 1 | negative
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_tap_sign(u8
+*v_tap_sign_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read tap_sign interrupt status */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_2_TAP_SIGN__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_tap_sign_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_2_TAP_SIGN);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the high_g first x status from the
+ * register 0x1F bit 0
+ *
+ *
+ *
+ *
+ * @param v_high_g_first_x_u8 :The status of high_g first x
+ * value | status
+ * -----------|-------------
+ * 0 | not triggered
+ * 1 | triggered by x axis
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_high_g_first_x(u8
+*v_high_g_first_x_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read highg_x interrupt status */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_X__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_high_g_first_x_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_X);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the high_g first y status from the
+ * register 0x1F bit 1
+ *
+ *
+ *
+ *
+ * @param v_high_g_first_y_u8 : The status of high_g first y
+ * value | status
+ * -----------|-------------
+ * 0 | not triggered
+ * 1 | triggered by y axis
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_high_g_first_y(u8
+*v_high_g_first_y_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read highg_y interrupt status */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Y__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_high_g_first_y_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Y);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the high_g first z status from the
+ * register 0x1F bit 3
+ *
+ *
+ *
+ *
+ * @param v_high_g_first_z_u8 : The status of high_g first z
+ * value | status
+ * -----------|-------------
+ * 0 | not triggered
+ * 1 | triggered by z axis
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_high_g_first_z(u8
+*v_high_g_first_z_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read highg_z interrupt status */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Z__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_high_g_first_z_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Z);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the high sign status from the
+ * register 0x1F bit 3
+ *
+ *
+ *
+ *
+ * @param v_high_g_sign_u8 :The status of high sign
+ * value | sign
+ * -----------|-------------
+ * 0 | positive
+ * 1 | negative
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_high_g_sign(u8
+*v_high_g_sign_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read highg_sign interrupt status */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_3_HIGH_G_SIGN__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_high_g_sign_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_3_HIGH_G_SIGN);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the status of orient_xy plane
+ * from the register 0x1F bit 4 and 5
+ *
+ *
+ * @param v_orient_xy_u8 :The status of orient_xy plane
+ * value | status
+ * -----------|-------------
+ * 0x00 | portrait upright
+ * 0x01 | portrait upside down
+ * 0x02 | landscape left
+ * 0x03 | landscape right
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_orient_xy(u8
+*v_orient_xy_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read orient plane xy interrupt status */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_3_ORIENT_XY__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_orient_xy_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_3_ORIENT_XY);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the status of orient z plane
+ * from the register 0x1F bit 6
+ *
+ *
+ * @param v_orient_z_u8 :The status of orient z
+ * value | status
+ * -----------|-------------
+ * 0x00 | upward looking
+ * 0x01 | downward looking
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_orient_z(u8
+*v_orient_z_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read orient z plane interrupt status */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_3_ORIENT_Z__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_orient_z_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_3_ORIENT_Z);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the flat status from the register
+ * 0x1F bit 7
+ *
+ *
+ * @param v_flat_u8 : The status of flat interrupt
+ * value | status
+ * -----------|-------------
+ * 0x00 | non flat
+ * 0x01 | flat position
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_flat(u8
+*v_flat_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read flat interrupt status */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_INTR_STAT_3_FLAT__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_flat_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_STAT_3_FLAT);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the temperature of the sensor
+ * from the register 0x21 bit 0 to 7
+ *
+ *
+ *
+ * @param v_temp_s16 : The value of temperature
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_temp(s16
+*v_temp_s16)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ /* Array contains the temperature lSB and MSB data
+ v_data_u8[0] - LSB
+ v_data_u8[1] - MSB*/
+ u8 v_data_u8[BMI160_TEMP_DATA_SIZE] = {BMI160_INIT_VALUE,
+ BMI160_INIT_VALUE};
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read temperature data */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_TEMP_LSB_VALUE__REG, v_data_u8,
+ BMI160_TEMP_DATA_LENGTH);
+ *v_temp_s16 =
+ (s16)(((s32)((s8) (v_data_u8[BMI160_TEMP_MSB_BYTE]) <<
+ BMI160_SHIFT_BIT_POSITION_BY_08_BITS))
+ | v_data_u8[BMI160_TEMP_LSB_BYTE]);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the of the sensor
+ * form the register 0x23 and 0x24 bit 0 to 7 and 0 to 2
+ * @brief this byte counter is updated each time a complete frame
+ * was read or writtern
+ *
+ *
+ * @param v_fifo_length_u32 : The value of fifo byte counter
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_fifo_length(u32 *v_fifo_length_u32)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ /* Array contains the fifo length data
+ v_data_u8[0] - fifo length
+ v_data_u8[1] - fifo length*/
+ u8 a_data_u8r[BMI160_FIFO_DATA_SIZE] = {BMI160_INIT_VALUE,
+ BMI160_INIT_VALUE};
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read fifo length*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_FIFO_BYTE_COUNTER_LSB__REG, a_data_u8r,
+ BMI160_FIFO_DATA_LENGTH);
+
+ a_data_u8r[BMI160_FIFO_LENGTH_MSB_BYTE] =
+ BMI160_GET_BITSLICE(
+ a_data_u8r[BMI160_FIFO_LENGTH_MSB_BYTE],
+ BMI160_USER_FIFO_BYTE_COUNTER_MSB);
+
+ *v_fifo_length_u32 =
+ (u32)(((u32)((u8) (
+ a_data_u8r[BMI160_FIFO_LENGTH_MSB_BYTE]) <<
+ BMI160_SHIFT_BIT_POSITION_BY_08_BITS))
+ | a_data_u8r[BMI160_FIFO_LENGTH_LSB_BYTE]);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the fifo data of the sensor
+ * from the register 0x24
+ * @brief Data format depends on the setting of register FIFO_CONFIG
+ *
+ *
+ *
+ * @param v_fifodata_u8 : Pointer holding the fifo data
+ * @param fifo_length_u16 : The value of fifo length maximum
+ * 1024
+ *
+ * @note For reading FIFO data use the following functions
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_fifo_data(
+u8 *v_fifodata_u8, u16 v_fifo_length_u16)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read fifo data*/
+ com_rslt =
+ p_bmi160->BMI160_BURST_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_FIFO_DATA__REG,
+ v_fifodata_u8, v_fifo_length_u16);
+
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to get the
+ * accel output date rate form the register 0x40 bit 0 to 3
+ *
+ *
+ * @param v_output_data_rate_u8 :The value of accel output date rate
+ * value | output data rate
+ * -------|--------------------------
+ * 0 | BMI160_ACCEL_OUTPUT_DATA_RATE_RESERVED
+ * 1 | BMI160_ACCEL_OUTPUT_DATA_RATE_0_78HZ
+ * 2 | BMI160_ACCEL_OUTPUT_DATA_RATE_1_56HZ
+ * 3 | BMI160_ACCEL_OUTPUT_DATA_RATE_3_12HZ
+ * 4 | BMI160_ACCEL_OUTPUT_DATA_RATE_6_25HZ
+ * 5 | BMI160_ACCEL_OUTPUT_DATA_RATE_12_5HZ
+ * 6 | BMI160_ACCEL_OUTPUT_DATA_RATE_25HZ
+ * 7 | BMI160_ACCEL_OUTPUT_DATA_RATE_50HZ
+ * 8 | BMI160_ACCEL_OUTPUT_DATA_RATE_100HZ
+ * 9 | BMI160_ACCEL_OUTPUT_DATA_RATE_200HZ
+ * 10 | BMI160_ACCEL_OUTPUT_DATA_RATE_400HZ
+ * 11 | BMI160_ACCEL_OUTPUT_DATA_RATE_800HZ
+ * 12 | BMI160_ACCEL_OUTPUT_DATA_RATE_1600HZ
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_output_data_rate(
+u8 *v_output_data_rate_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read the accel output data rate*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_output_data_rate_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to set the
+ * accel output date rate form the register 0x40 bit 0 to 3
+ *
+ *
+ * @param v_output_data_rate_u8 :The value of accel output date rate
+ * value | output data rate
+ * -------|--------------------------
+ * 0 | BMI160_ACCEL_OUTPUT_DATA_RATE_RESERVED
+ * 1 | BMI160_ACCEL_OUTPUT_DATA_RATE_0_78HZ
+ * 2 | BMI160_ACCEL_OUTPUT_DATA_RATE_1_56HZ
+ * 3 | BMI160_ACCEL_OUTPUT_DATA_RATE_3_12HZ
+ * 4 | BMI160_ACCEL_OUTPUT_DATA_RATE_6_25HZ
+ * 5 | BMI160_ACCEL_OUTPUT_DATA_RATE_12_5HZ
+ * 6 | BMI160_ACCEL_OUTPUT_DATA_RATE_25HZ
+ * 7 | BMI160_ACCEL_OUTPUT_DATA_RATE_50HZ
+ * 8 | BMI160_ACCEL_OUTPUT_DATA_RATE_100HZ
+ * 9 | BMI160_ACCEL_OUTPUT_DATA_RATE_200HZ
+ * 10 | BMI160_ACCEL_OUTPUT_DATA_RATE_400HZ
+ * 11 | BMI160_ACCEL_OUTPUT_DATA_RATE_800HZ
+ * 12 | BMI160_ACCEL_OUTPUT_DATA_RATE_1600HZ
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_output_data_rate(
+u8 v_output_data_rate_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* accel output data rate selection */
+ if ((v_output_data_rate_u8 != BMI160_INIT_VALUE) &&
+ (v_output_data_rate_u8 <= BMI160_MAX_ACCEL_OUTPUT_DATA_RATE)) {
+ /* write accel output data rate */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE,
+ v_output_data_rate_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(
+ p_bmi160->dev_addr,
+ BMI160_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ } else {
+ com_rslt = E_BMI160_OUT_OF_RANGE;
+ }
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to get the
+ * accel bandwidth from the register 0x40 bit 4 to 6
+ * @brief bandwidth parameter determines filter configuration(acc_us=0)
+ * and averaging for under sampling mode(acc_us=1)
+ *
+ *
+ * @param v_bw_u8 : The value of accel bandwidth
+ *
+ * @note accel bandwidth depends on under sampling parameter
+ * @note under sampling parameter cab be set by the function
+ * "BMI160_SET_ACCEL_UNDER_SAMPLING_PARAMETER"
+ *
+ * @note Filter configuration
+ * accel_us | Filter configuration
+ * -----------|---------------------
+ * 0x00 | OSR4 mode
+ * 0x01 | OSR2 mode
+ * 0x02 | normal mode
+ * 0x03 | CIC mode
+ * 0x04 | Reserved
+ * 0x05 | Reserved
+ * 0x06 | Reserved
+ * 0x07 | Reserved
+ *
+ * @note accel under sampling mode
+ * accel_us | Under sampling mode
+ * -----------|---------------------
+ * 0x00 | no averaging
+ * 0x01 | average 2 samples
+ * 0x02 | average 4 samples
+ * 0x03 | average 8 samples
+ * 0x04 | average 16 samples
+ * 0x05 | average 32 samples
+ * 0x06 | average 64 samples
+ * 0x07 | average 128 samples
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_bw(u8 *v_bw_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read the accel bandwidth */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_ACCEL_CONFIG_ACCEL_BW__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_bw_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_ACCEL_CONFIG_ACCEL_BW);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to set the
+ * accel bandwidth from the register 0x40 bit 4 to 6
+ * @brief bandwidth parameter determines filter configuration(acc_us=0)
+ * and averaging for under sampling mode(acc_us=1)
+ *
+ *
+ * @param v_bw_u8 : The value of accel bandwidth
+ *
+ * @note accel bandwidth depends on under sampling parameter
+ * @note under sampling parameter cab be set by the function
+ * "BMI160_SET_ACCEL_UNDER_SAMPLING_PARAMETER"
+ *
+ * @note Filter configuration
+ * accel_us | Filter configuration
+ * -----------|---------------------
+ * 0x00 | OSR4 mode
+ * 0x01 | OSR2 mode
+ * 0x02 | normal mode
+ * 0x03 | CIC mode
+ * 0x04 | Reserved
+ * 0x05 | Reserved
+ * 0x06 | Reserved
+ * 0x07 | Reserved
+ *
+ * @note accel under sampling mode
+ * accel_us | Under sampling mode
+ * -----------|---------------------
+ * 0x00 | no averaging
+ * 0x01 | average 2 samples
+ * 0x02 | average 4 samples
+ * 0x03 | average 8 samples
+ * 0x04 | average 16 samples
+ * 0x05 | average 32 samples
+ * 0x06 | average 64 samples
+ * 0x07 | average 128 samples
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_bw(u8 v_bw_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* select accel bandwidth*/
+ if (v_bw_u8 <= BMI160_MAX_ACCEL_BW) {
+ /* write accel bandwidth*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_ACCEL_CONFIG_ACCEL_BW__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_ACCEL_CONFIG_ACCEL_BW,
+ v_bw_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(
+ p_bmi160->dev_addr,
+ BMI160_USER_ACCEL_CONFIG_ACCEL_BW__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ } else {
+ com_rslt = E_BMI160_OUT_OF_RANGE;
+ }
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to get the accel
+ * under sampling parameter form the register 0x40 bit 7
+ *
+ *
+ *
+ *
+ * @param v_accel_under_sampling_u8 : The value of accel under sampling
+ * value | under_sampling
+ * ----------|---------------
+ * 0x01 | BMI160_ENABLE
+ * 0x00 | BMI160_DISABLE
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_under_sampling_parameter(
+u8 *v_accel_under_sampling_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read the accel under sampling parameter */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_accel_under_sampling_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to set the accel
+ * under sampling parameter form the register 0x40 bit 7
+ *
+ *
+ *
+ *
+ * @param v_accel_under_sampling_u8 : The value of accel under sampling
+ * value | under_sampling
+ * ----------|---------------
+ * 0x01 | BMI160_ENABLE
+ * 0x00 | BMI160_DISABLE
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_under_sampling_parameter(
+u8 v_accel_under_sampling_u8)
+{
+/* variable used for return the status of communication result*/
+BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ if (v_accel_under_sampling_u8 <= BMI160_MAX_UNDER_SAMPLING) {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ /* write the accel under sampling parameter */
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING,
+ v_accel_under_sampling_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(
+ p_bmi160->dev_addr,
+ BMI160_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ } else {
+ com_rslt = E_BMI160_OUT_OF_RANGE;
+ }
+}
+return com_rslt;
+}
+/*!
+ * @brief This API is used to get the ranges
+ * (g values) of the accel from the register 0x41 bit 0 to 3
+ *
+ *
+ *
+ *
+ * @param v_range_u8 : The value of accel g range
+ * value | g_range
+ * ----------|-----------
+ * 0x03 | BMI160_ACCEL_RANGE_2G
+ * 0x05 | BMI160_ACCEL_RANGE_4G
+ * 0x08 | BMI160_ACCEL_RANGE_8G
+ * 0x0C | BMI160_ACCEL_RANGE_16G
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_range(
+u8 *v_range_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read the accel range*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_ACCEL_RANGE__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_range_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_ACCEL_RANGE);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to set the ranges
+ * (g values) of the accel from the register 0x41 bit 0 to 3
+ *
+ *
+ *
+ *
+ * @param v_range_u8 : The value of accel g range
+ * value | g_range
+ * ----------|-----------
+ * 0x03 | BMI160_ACCEL_RANGE_2G
+ * 0x05 | BMI160_ACCEL_RANGE_4G
+ * 0x08 | BMI160_ACCEL_RANGE_8G
+ * 0x0C | BMI160_ACCEL_RANGE_16G
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_range(u8 v_range_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ if ((v_range_u8 == BMI160_ACCEL_RANGE0) ||
+ (v_range_u8 == BMI160_ACCEL_RANGE1) ||
+ (v_range_u8 == BMI160_ACCEL_RANGE3) ||
+ (v_range_u8 == BMI160_ACCEL_RANGE4)) {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_ACCEL_RANGE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(
+ v_data_u8, BMI160_USER_ACCEL_RANGE,
+ v_range_u8);
+ /* write the accel range*/
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(
+ p_bmi160->dev_addr,
+ BMI160_USER_ACCEL_RANGE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ } else {
+ com_rslt = E_BMI160_OUT_OF_RANGE;
+ }
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to get the
+ * gyroscope output data rate from the register 0x42 bit 0 to 3
+ *
+ *
+ *
+ *
+ * @param v_output_data_rate_u8 :The value of gyro output data rate
+ * value | gyro output data rate
+ * -----------|-----------------------------
+ * 0x00 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ * 0x01 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ * 0x02 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ * 0x03 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ * 0x04 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ * 0x05 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ * 0x06 | BMI160_GYRO_OUTPUT_DATA_RATE_25HZ
+ * 0x07 | BMI160_GYRO_OUTPUT_DATA_RATE_50HZ
+ * 0x08 | BMI160_GYRO_OUTPUT_DATA_RATE_100HZ
+ * 0x09 | BMI160_GYRO_OUTPUT_DATA_RATE_200HZ
+ * 0x0A | BMI160_GYRO_OUTPUT_DATA_RATE_400HZ
+ * 0x0B | BMI160_GYRO_OUTPUT_DATA_RATE_800HZ
+ * 0x0C | BMI160_GYRO_OUTPUT_DATA_RATE_1600HZ
+ * 0x0D | BMI160_GYRO_OUTPUT_DATA_RATE_3200HZ
+ * 0x0E | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ * 0x0F | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_output_data_rate(
+u8 *v_output_data_rate_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read the gyro output data rate*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_GYRO_CONFIG_OUTPUT_DATA_RATE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_output_data_rate_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_GYRO_CONFIG_OUTPUT_DATA_RATE);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to set the
+ * gyroscope output data rate from the register 0x42 bit 0 to 3
+ *
+ *
+ *
+ *
+ * @param v_output_data_rate_u8 :The value of gyro output data rate
+ * value | gyro output data rate
+ * -----------|-----------------------------
+ * 0x00 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ * 0x01 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ * 0x02 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ * 0x03 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ * 0x04 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ * 0x05 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ * 0x06 | BMI160_GYRO_OUTPUT_DATA_RATE_25HZ
+ * 0x07 | BMI160_GYRO_OUTPUT_DATA_RATE_50HZ
+ * 0x08 | BMI160_GYRO_OUTPUT_DATA_RATE_100HZ
+ * 0x09 | BMI160_GYRO_OUTPUT_DATA_RATE_200HZ
+ * 0x0A | BMI160_GYRO_OUTPUT_DATA_RATE_400HZ
+ * 0x0B | BMI160_GYRO_OUTPUT_DATA_RATE_800HZ
+ * 0x0C | BMI160_GYRO_OUTPUT_DATA_RATE_1600HZ
+ * 0x0D | BMI160_GYRO_OUTPUT_DATA_RATE_3200HZ
+ * 0x0E | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ * 0x0F | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_output_data_rate(
+u8 v_output_data_rate_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* select the gyro output data rate*/
+ if ((v_output_data_rate_u8 < BMI160_OUTPUT_DATA_RATE6) &&
+ (v_output_data_rate_u8 != BMI160_INIT_VALUE)
+ && (v_output_data_rate_u8 != BMI160_OUTPUT_DATA_RATE1)
+ && (v_output_data_rate_u8 != BMI160_OUTPUT_DATA_RATE2)
+ && (v_output_data_rate_u8 != BMI160_OUTPUT_DATA_RATE3)
+ && (v_output_data_rate_u8 != BMI160_OUTPUT_DATA_RATE4)
+ && (v_output_data_rate_u8 != BMI160_OUTPUT_DATA_RATE5)
+ && (v_output_data_rate_u8 != BMI160_OUTPUT_DATA_RATE6)
+ && (v_output_data_rate_u8 != BMI160_OUTPUT_DATA_RATE7)) {
+ /* write the gyro output data rate */
+ com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+ (p_bmi160->dev_addr,
+ BMI160_USER_GYRO_CONFIG_OUTPUT_DATA_RATE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_GYRO_CONFIG_OUTPUT_DATA_RATE,
+ v_output_data_rate_u8);
+ com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
+ (p_bmi160->dev_addr,
+ BMI160_USER_GYRO_CONFIG_OUTPUT_DATA_RATE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ } else {
+ com_rslt = E_BMI160_OUT_OF_RANGE;
+ }
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to get the
+ * data of gyro from the register 0x42 bit 4 to 5
+ *
+ *
+ *
+ *
+ * @param v_bw_u8 : The value of gyro bandwidth
+ * value | gyro bandwidth
+ * ----------|----------------
+ * 0x00 | BMI160_GYRO_OSR4_MODE
+ * 0x01 | BMI160_GYRO_OSR2_MODE
+ * 0x02 | BMI160_GYRO_NORMAL_MODE
+ * 0x03 | BMI160_GYRO_CIC_MODE
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_bw(u8 *v_bw_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read gyro bandwidth*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_GYRO_CONFIG_BW__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_bw_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_GYRO_CONFIG_BW);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to set the
+ * data of gyro from the register 0x42 bit 4 to 5
+ *
+ *
+ *
+ *
+ * @param v_bw_u8 : The value of gyro bandwidth
+ * value | gyro bandwidth
+ * ----------|----------------
+ * 0x00 | BMI160_GYRO_OSR4_MODE
+ * 0x01 | BMI160_GYRO_OSR2_MODE
+ * 0x02 | BMI160_GYRO_NORMAL_MODE
+ * 0x03 | BMI160_GYRO_CIC_MODE
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_bw(u8 v_bw_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ if (v_bw_u8 <= BMI160_MAX_GYRO_BW) {
+ /* write the gyro bandwidth*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_GYRO_CONFIG_BW__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_GYRO_CONFIG_BW, v_bw_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(
+ p_bmi160->dev_addr,
+ BMI160_USER_GYRO_CONFIG_BW__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ } else {
+ com_rslt = E_BMI160_OUT_OF_RANGE;
+ }
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads the range
+ * of gyro from the register 0x43 bit 0 to 2
+ *
+ * @param v_range_u8 : The value of gyro range
+ * value | range
+ * ----------|-------------------------------
+ * 0x00 | BMI160_GYRO_RANGE_2000_DEG_SEC
+ * 0x01 | BMI160_GYRO_RANGE_1000_DEG_SEC
+ * 0x02 | BMI160_GYRO_RANGE_500_DEG_SEC
+ * 0x03 | BMI160_GYRO_RANGE_250_DEG_SEC
+ * 0x04 | BMI160_GYRO_RANGE_125_DEG_SEC
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_range(u8 *v_range_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read the gyro range */
+ com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+ (p_bmi160->dev_addr,
+ BMI160_USER_GYRO_RANGE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_range_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_GYRO_RANGE);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API set the range
+ * of gyro from the register 0x43 bit 0 to 2
+ *
+ * @param v_range_u8 : The value of gyro range
+ * value | range
+ * ----------|-------------------------------
+ * 0x00 | BMI160_GYRO_RANGE_2000_DEG_SEC
+ * 0x01 | BMI160_GYRO_RANGE_1000_DEG_SEC
+ * 0x02 | BMI160_GYRO_RANGE_500_DEG_SEC
+ * 0x03 | BMI160_GYRO_RANGE_250_DEG_SEC
+ * 0x04 | BMI160_GYRO_RANGE_125_DEG_SEC
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_range(u8 v_range_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ if (v_range_u8 <= BMI160_MAX_GYRO_RANGE) {
+ /* write the gyro range value */
+ com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
+ (p_bmi160->dev_addr,
+ BMI160_USER_GYRO_RANGE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_GYRO_RANGE,
+ v_range_u8);
+ com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
+ (p_bmi160->dev_addr,
+ BMI160_USER_GYRO_RANGE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ } else {
+ com_rslt = E_BMI160_OUT_OF_RANGE;
+ }
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to get the
+ * output data rate of magnetometer from the register 0x44 bit 0 to 3
+ *
+ *
+ *
+ *
+ * @param v_output_data_rat_u8e : The value of mag output data rate
+ * value | mag output data rate
+ * ---------|---------------------------
+ * 0x00 |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED
+ * 0x01 |BMI160_MAG_OUTPUT_DATA_RATE_0_78HZ
+ * 0x02 |BMI160_MAG_OUTPUT_DATA_RATE_1_56HZ
+ * 0x03 |BMI160_MAG_OUTPUT_DATA_RATE_3_12HZ
+ * 0x04 |BMI160_MAG_OUTPUT_DATA_RATE_6_25HZ
+ * 0x05 |BMI160_MAG_OUTPUT_DATA_RATE_12_5HZ
+ * 0x06 |BMI160_MAG_OUTPUT_DATA_RATE_25HZ
+ * 0x07 |BMI160_MAG_OUTPUT_DATA_RATE_50HZ
+ * 0x08 |BMI160_MAG_OUTPUT_DATA_RATE_100HZ
+ * 0x09 |BMI160_MAG_OUTPUT_DATA_RATE_200HZ
+ * 0x0A |BMI160_MAG_OUTPUT_DATA_RATE_400HZ
+ * 0x0B |BMI160_MAG_OUTPUT_DATA_RATE_800HZ
+ * 0x0C |BMI160_MAG_OUTPUT_DATA_RATE_1600HZ
+ * 0x0D |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED0
+ * 0x0E |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED1
+ * 0x0F |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED2
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_output_data_rate(
+u8 *v_output_data_rat_u8e)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read the mag data output rate*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_MAG_CONFIG_OUTPUT_DATA_RATE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_output_data_rat_u8e = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_MAG_CONFIG_OUTPUT_DATA_RATE);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to set the
+ * output data rate of magnetometer from the register 0x44 bit 0 to 3
+ *
+ *
+ *
+ *
+ * @param v_output_data_rat_u8e : The value of mag output data rate
+ * value | mag output data rate
+ * ---------|---------------------------
+ * 0x00 |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED
+ * 0x01 |BMI160_MAG_OUTPUT_DATA_RATE_0_78HZ
+ * 0x02 |BMI160_MAG_OUTPUT_DATA_RATE_1_56HZ
+ * 0x03 |BMI160_MAG_OUTPUT_DATA_RATE_3_12HZ
+ * 0x04 |BMI160_MAG_OUTPUT_DATA_RATE_6_25HZ
+ * 0x05 |BMI160_MAG_OUTPUT_DATA_RATE_12_5HZ
+ * 0x06 |BMI160_MAG_OUTPUT_DATA_RATE_25HZ
+ * 0x07 |BMI160_MAG_OUTPUT_DATA_RATE_50HZ
+ * 0x08 |BMI160_MAG_OUTPUT_DATA_RATE_100HZ
+ * 0x09 |BMI160_MAG_OUTPUT_DATA_RATE_200HZ
+ * 0x0A |BMI160_MAG_OUTPUT_DATA_RATE_400HZ
+ * 0x0B |BMI160_MAG_OUTPUT_DATA_RATE_800HZ
+ * 0x0C |BMI160_MAG_OUTPUT_DATA_RATE_1600HZ
+ * 0x0D |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED0
+ * 0x0E |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED1
+ * 0x0F |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED2
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_output_data_rate(
+u8 v_output_data_rat_u8e)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* select the mag data output rate*/
+ if ((v_output_data_rat_u8e
+ <= BMI160_MAX_ACCEL_OUTPUT_DATA_RATE)
+ && (v_output_data_rat_u8e
+ != BMI160_OUTPUT_DATA_RATE0)
+ && (v_output_data_rat_u8e
+ != BMI160_OUTPUT_DATA_RATE6)
+ && (v_output_data_rat_u8e
+ != BMI160_OUTPUT_DATA_RATE7)) {
+ /* write the mag data output rate*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_MAG_CONFIG_OUTPUT_DATA_RATE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_MAG_CONFIG_OUTPUT_DATA_RATE,
+ v_output_data_rat_u8e);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(
+ p_bmi160->dev_addr,
+ BMI160_USER_MAG_CONFIG_OUTPUT_DATA_RATE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ } else {
+ com_rslt = E_BMI160_OUT_OF_RANGE;
+ }
+ }
+ return com_rslt;
+}
+ /*!
+ * @brief This API is used to read Down sampling
+ * for gyro (2**downs_gyro) in the register 0x45 bit 0 to 2
+ *
+ *
+ *
+ *
+ * @param v_fifo_down_gyro_u8 :The value of gyro fifo down
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_down_gyro(
+u8 *v_fifo_down_gyro_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read the gyro fifo down*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_FIFO_DOWN_GYRO__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_fifo_down_gyro_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_FIFO_DOWN_GYRO);
+ }
+ return com_rslt;
+}
+ /*!
+ * @brief This API is used to set Down sampling
+ * for gyro (2**downs_gyro) in the register 0x45 bit 0 to 2
+ *
+ *
+ *
+ *
+ * @param v_fifo_down_gyro_u8 :The value of gyro fifo down
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_down_gyro(
+u8 v_fifo_down_gyro_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* write the gyro fifo down*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_FIFO_DOWN_GYRO__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(
+ v_data_u8,
+ BMI160_USER_FIFO_DOWN_GYRO,
+ v_fifo_down_gyro_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(
+ p_bmi160->dev_addr,
+ BMI160_USER_FIFO_DOWN_GYRO__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to read gyro fifo filter data
+ * from the register 0x45 bit 3
+ *
+ *
+ *
+ * @param v_gyro_fifo_filter_data_u8 :The value of gyro filter data
+ * value | gyro_fifo_filter_data
+ * ------------|-------------------------
+ * 0x00 | Unfiltered data
+ * 0x01 | Filtered data
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_fifo_filter_data(
+u8 *v_gyro_fifo_filter_data_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read the gyro fifo filter data */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_FIFO_FILTER_GYRO__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_gyro_fifo_filter_data_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_FIFO_FILTER_GYRO);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to set gyro fifo filter data
+ * from the register 0x45 bit 3
+ *
+ *
+ *
+ * @param v_gyro_fifo_filter_data_u8 :The value of gyro filter data
+ * value | gyro_fifo_filter_data
+ * ------------|-------------------------
+ * 0x00 | Unfiltered data
+ * 0x01 | Filtered data
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_fifo_filter_data(
+u8 v_gyro_fifo_filter_data_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ if (v_gyro_fifo_filter_data_u8
+ <= BMI160_MAX_VALUE_FIFO_FILTER) {
+ /* write the gyro fifo filter data */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_FIFO_FILTER_GYRO__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(
+ v_data_u8,
+ BMI160_USER_FIFO_FILTER_GYRO,
+ v_gyro_fifo_filter_data_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(
+ p_bmi160->dev_addr,
+ BMI160_USER_FIFO_FILTER_GYRO__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ } else {
+ com_rslt = E_BMI160_OUT_OF_RANGE;
+ }
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to read Down sampling
+ * for accel (2*downs_accel) from the register 0x45 bit 4 to 6
+ *
+ *
+ *
+ *
+ * @param v_fifo_down_u8 :The value of accel fifo down
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_down_accel(
+u8 *v_fifo_down_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read the accel fifo down data */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_FIFO_DOWN_ACCEL__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_fifo_down_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_FIFO_DOWN_ACCEL);
+ }
+ return com_rslt;
+}
+ /*!
+ * @brief This API is used to set Down sampling
+ * for accel (2*downs_accel) from the register 0x45 bit 4 to 6
+ *
+ *
+ *
+ *
+ * @param v_fifo_down_u8 :The value of accel fifo down
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_down_accel(
+u8 v_fifo_down_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* write the accel fifo down data */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_FIFO_DOWN_ACCEL__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_FIFO_DOWN_ACCEL, v_fifo_down_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(
+ p_bmi160->dev_addr,
+ BMI160_USER_FIFO_DOWN_ACCEL__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to read accel fifo filter data
+ * from the register 0x45 bit 7
+ *
+ *
+ *
+ * @param v_accel_fifo_filter_u8 :The value of accel filter data
+ * value | accel_fifo_filter_data
+ * ------------|-------------------------
+ * 0x00 | Unfiltered data
+ * 0x01 | Filtered data
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_fifo_filter_data(
+u8 *v_accel_fifo_filter_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read the accel fifo filter data */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_FIFO_FILTER_ACCEL__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_accel_fifo_filter_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_FIFO_FILTER_ACCEL);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to set accel fifo filter data
+ * from the register 0x45 bit 7
+ *
+ *
+ *
+ * @param v_accel_fifo_filter_u8 :The value of accel filter data
+ * value | accel_fifo_filter_data
+ * ------------|-------------------------
+ * 0x00 | Unfiltered data
+ * 0x01 | Filtered data
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_fifo_filter_data(
+u8 v_accel_fifo_filter_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ if (v_accel_fifo_filter_u8 <= BMI160_MAX_VALUE_FIFO_FILTER) {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_FIFO_FILTER_ACCEL__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ /* write accel fifo filter data */
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_FIFO_FILTER_ACCEL,
+ v_accel_fifo_filter_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(
+ p_bmi160->dev_addr,
+ BMI160_USER_FIFO_FILTER_ACCEL__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ } else {
+ com_rslt = E_BMI160_OUT_OF_RANGE;
+ }
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to Trigger an interrupt
+ * when FIFO contains water mark level from the register 0x46 bit 0 to 7
+ *
+ *
+ *
+ * @param v_fifo_wm_u8 : The value of fifo water mark level
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_wm(
+u8 *v_fifo_wm_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read the fifo water mark level*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_FIFO_WM__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_fifo_wm_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_FIFO_WM);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to Trigger an interrupt
+ * when FIFO contains water mark level from the register 0x46 bit 0 to 7
+ *
+ *
+ *
+ * @param v_fifo_wm_u8 : The value of fifo water mark level
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_wm(
+u8 v_fifo_wm_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* write the fifo water mark level*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_FIFO_WM__REG,
+ &v_fifo_wm_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads fifo sensor time
+ * frame after the last valid data frame form the register 0x47 bit 1
+ *
+ *
+ *
+ *
+ * @param v_fifo_time_enable_u8 : The value of sensor time
+ * value | fifo sensor time
+ * ------------|-------------------------
+ * 0x00 | do not return sensortime frame
+ * 0x01 | return sensortime frame
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_time_enable(
+u8 *v_fifo_time_enable_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read the fifo sensor time*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_FIFO_TIME_ENABLE__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_fifo_time_enable_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_FIFO_TIME_ENABLE);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API set fifo sensor time
+ * frame after the last valid data frame form the register 0x47 bit 1
+ *
+ *
+ *
+ *
+ * @param v_fifo_time_enable_u8 : The value of sensor time
+ * value | fifo sensor time
+ * ------------|-------------------------
+ * 0x00 | do not return sensortime frame
+ * 0x01 | return sensortime frame
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_time_enable(
+u8 v_fifo_time_enable_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ if (v_fifo_time_enable_u8 <= BMI160_MAX_VALUE_FIFO_TIME) {
+ /* write the fifo sensor time*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_FIFO_TIME_ENABLE__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_FIFO_TIME_ENABLE,
+ v_fifo_time_enable_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(
+ p_bmi160->dev_addr,
+ BMI160_USER_FIFO_TIME_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ } else {
+ com_rslt = E_BMI160_OUT_OF_RANGE;
+ }
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads FIFO tag interrupt2 enable status
+ * from the resister 0x47 bit 2
+ *
+ * @param v_fifo_tag_intr2_u8 : The value of fifo tag interrupt
+ * value | fifo tag interrupt
+ * ----------|-------------------
+ * 0x01 | BMI160_ENABLE
+ * 0x00 | BMI160_DISABLE
+ *
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_tag_intr2_enable(
+u8 *v_fifo_tag_intr2_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read the fifo tag interrupt2*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_FIFO_TAG_INTR2_ENABLE__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_fifo_tag_intr2_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_FIFO_TAG_INTR2_ENABLE);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API set FIFO tag interrupt2 enable status
+ * from the resister 0x47 bit 2
+ *
+ * @param v_fifo_tag_intr2_u8 : The value of fifo tag interrupt
+ * value | fifo tag interrupt
+ * ----------|-------------------
+ * 0x01 | BMI160_ENABLE
+ * 0x00 | BMI160_DISABLE
+ *
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_tag_intr2_enable(
+u8 v_fifo_tag_intr2_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ if (v_fifo_tag_intr2_u8 <= BMI160_MAX_VALUE_FIFO_INTR) {
+ /* write the fifo tag interrupt2*/
+ com_rslt = bmi160_set_input_enable(1,
+ v_fifo_tag_intr2_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_FIFO_TAG_INTR2_ENABLE__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_FIFO_TAG_INTR2_ENABLE,
+ v_fifo_tag_intr2_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(
+ p_bmi160->dev_addr,
+ BMI160_USER_FIFO_TAG_INTR2_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ } else {
+ com_rslt = E_BMI160_OUT_OF_RANGE;
+ }
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API get FIFO tag interrupt1 enable status
+ * from the resister 0x47 bit 3
+ *
+ * @param v_fifo_tag_intr1_u8 :The value of fifo tag interrupt1
+ * value | fifo tag interrupt
+ * ----------|-------------------
+ * 0x01 | BMI160_ENABLE
+ * 0x00 | BMI160_DISABLE
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_tag_intr1_enable(
+u8 *v_fifo_tag_intr1_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read fifo tag interrupt*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_FIFO_TAG_INTR1_ENABLE__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_fifo_tag_intr1_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_FIFO_TAG_INTR1_ENABLE);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API set FIFO tag interrupt1 enable status
+ * from the resister 0x47 bit 3
+ *
+ * @param v_fifo_tag_intr1_u8 :The value of fifo tag interrupt1
+ * value | fifo tag interrupt
+ * ----------|-------------------
+ * 0x01 | BMI160_ENABLE
+ * 0x00 | BMI160_DISABLE
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_tag_intr1_enable(
+u8 v_fifo_tag_intr1_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ if (v_fifo_tag_intr1_u8 <= BMI160_MAX_VALUE_FIFO_INTR) {
+ /* write the fifo tag interrupt*/
+ com_rslt = bmi160_set_input_enable(BMI160_INIT_VALUE,
+ v_fifo_tag_intr1_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_FIFO_TAG_INTR1_ENABLE__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_FIFO_TAG_INTR1_ENABLE,
+ v_fifo_tag_intr1_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(
+ p_bmi160->dev_addr,
+ BMI160_USER_FIFO_TAG_INTR1_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ } else {
+ com_rslt = E_BMI160_OUT_OF_RANGE;
+ }
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API reads FIFO frame
+ * header enable from the register 0x47 bit 4
+ *
+ * @param v_fifo_header_u8 :The value of fifo header
+ * value | fifo header
+ * ----------|-------------------
+ * 0x01 | BMI160_ENABLE
+ * 0x00 | BMI160_DISABLE
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_header_enable(
+u8 *v_fifo_header_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read fifo header */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_FIFO_HEADER_ENABLE__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_fifo_header_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_FIFO_HEADER_ENABLE);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API set FIFO frame
+ * header enable from the register 0x47 bit 4
+ *
+ * @param v_fifo_header_u8 :The value of fifo header
+ * value | fifo header
+ * ----------|-------------------
+ * 0x01 | BMI160_ENABLE
+ * 0x00 | BMI160_DISABLE
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_header_enable(
+u8 v_fifo_header_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ if (v_fifo_header_u8 <= BMI160_MAX_VALUE_FIFO_HEADER) {
+ /* write the fifo header */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_FIFO_HEADER_ENABLE__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_FIFO_HEADER_ENABLE,
+ v_fifo_header_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(
+ p_bmi160->dev_addr,
+ BMI160_USER_FIFO_HEADER_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ } else {
+ com_rslt = E_BMI160_OUT_OF_RANGE;
+ }
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to read stored
+ * magnetometer data in FIFO (all 3 axes) from the register 0x47 bit 5
+ *
+ * @param v_fifo_mag_u8 : The value of fifo mag enble
+ * value | fifo mag
+ * ----------|-------------------
+ * 0x00 | no magnetometer data is stored
+ * 0x01 | magnetometer data is stored
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_mag_enable(
+u8 *v_fifo_mag_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read the fifo mag enable*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_FIFO_MAG_ENABLE__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_fifo_mag_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_FIFO_MAG_ENABLE);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to set stored
+ * magnetometer data in FIFO (all 3 axes) from the register 0x47 bit 5
+ *
+ * @param v_fifo_mag_u8 : The value of fifo mag enble
+ * value | fifo mag
+ * ----------|-------------------
+ * 0x00 | no magnetometer data is stored
+ * 0x01 | magnetometer data is stored
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_mag_enable(
+u8 v_fifo_mag_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ if (v_fifo_mag_u8 <= BMI160_MAX_VALUE_FIFO_MAG) {
+ /* write the fifo mag enable*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC
+ (p_bmi160->dev_addr,
+ BMI160_USER_FIFO_MAG_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 =
+ BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_FIFO_MAG_ENABLE,
+ v_fifo_mag_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC
+ (p_bmi160->dev_addr,
+ BMI160_USER_FIFO_MAG_ENABLE__REG,
+ &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ } else {
+ com_rslt = E_BMI160_OUT_OF_RANGE;
+ }
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to read stored
+ * accel data in FIFO (all 3 axes) from the register 0x47 bit 6
+ *
+ * @param v_fifo_accel_u8 : The value of fifo accel enble
+ * value | fifo accel
+ * ----------|-------------------
+ * 0x00 | no accel data is stored
+ * 0x01 | accel data is stored
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_accel_enable(
+u8 *v_fifo_accel_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read the accel fifo enable*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_FIFO_ACCEL_ENABLE__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_fifo_accel_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_FIFO_ACCEL_ENABLE);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to set stored
+ * accel data in FIFO (all 3 axes) from the register 0x47 bit 6
+ *
+ * @param v_fifo_accel_u8 : The value of fifo accel enble
+ * value | fifo accel
+ * ----------|-------------------
+ * 0x00 | no accel data is stored
+ * 0x01 | accel data is stored
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_accel_enable(
+u8 v_fifo_accel_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ if (v_fifo_accel_u8 <= BMI160_MAX_VALUE_FIFO_ACCEL) {
+ /* write the fifo mag enables*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_FIFO_ACCEL_ENABLE__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_FIFO_ACCEL_ENABLE, v_fifo_accel_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(
+ p_bmi160->dev_addr,
+ BMI160_USER_FIFO_ACCEL_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ } else {
+ com_rslt = E_BMI160_OUT_OF_RANGE;
+ }
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to read stored
+ * gyro data in FIFO (all 3 axes) from the resister 0x47 bit 7
+ *
+ *
+ * @param v_fifo_gyro_u8 : The value of fifo gyro enble
+ * value | fifo gyro
+ * ----------|-------------------
+ * 0x00 | no gyro data is stored
+ * 0x01 | gyro data is stored
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_gyro_enable(
+u8 *v_fifo_gyro_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read fifo gyro enable */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_FIFO_GYRO_ENABLE__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_fifo_gyro_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_FIFO_GYRO_ENABLE);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to set stored
+ * gyro data in FIFO (all 3 axes) from the resister 0x47 bit 7
+ *
+ *
+ * @param v_fifo_gyro_u8 : The value of fifo gyro enble
+ * value | fifo gyro
+ * ----------|-------------------
+ * 0x00 | no gyro data is stored
+ * 0x01 | gyro data is stored
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_gyro_enable(
+u8 v_fifo_gyro_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ if (v_fifo_gyro_u8 <= BMI160_MAX_VALUE_FIFO_GYRO) {
+ /* write fifo gyro enable*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_FIFO_GYRO_ENABLE__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_FIFO_GYRO_ENABLE, v_fifo_gyro_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(
+ p_bmi160->dev_addr,
+ BMI160_USER_FIFO_GYRO_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ } else {
+ com_rslt = E_BMI160_OUT_OF_RANGE;
+ }
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to read
+ * I2C device address of auxiliary mag from the register 0x4B bit 1 to 7
+ *
+ *
+ *
+ *
+ * @param v_i2c_device_addr_u8 : The value of mag I2C device address
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_i2c_device_addr(
+u8 *v_i2c_device_addr_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read the mag I2C device address*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_I2C_DEVICE_ADDR__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_i2c_device_addr_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_I2C_DEVICE_ADDR);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to set
+ * I2C device address of auxiliary mag from the register 0x4B bit 1 to 7
+ *
+ *
+ *
+ *
+ * @param v_i2c_device_addr_u8 : The value of mag I2C device address
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_i2c_device_addr(
+u8 v_i2c_device_addr_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* write the mag I2C device address*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_I2C_DEVICE_ADDR__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_I2C_DEVICE_ADDR,
+ v_i2c_device_addr_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(
+ p_bmi160->dev_addr,
+ BMI160_USER_I2C_DEVICE_ADDR__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to read
+ * Burst data length (1,2,6,8 byte) from the register 0x4C bit 0 to 1
+ *
+ *
+ *
+ *
+ * @param v_mag_burst_u8 : The data of mag burst read lenth
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_burst(
+u8 *v_mag_burst_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read mag burst mode length*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_MAG_BURST__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_mag_burst_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_MAG_BURST);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to set
+ * Burst data length (1,2,6,8 byte) from the register 0x4C bit 0 to 1
+ *
+ *
+ *
+ *
+ * @param v_mag_burst_u8 : The data of mag burst read lenth
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_burst(
+u8 v_mag_burst_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* write mag burst mode length*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_MAG_BURST__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 =
+ BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_MAG_BURST, v_mag_burst_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(
+ p_bmi160->dev_addr,
+ BMI160_USER_MAG_BURST__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to read
+ * trigger-readout offset in units of 2.5 ms. If set to zero,
+ * the offset is maximum, i.e. after readout a trigger
+ * is issued immediately. from the register 0x4C bit 2 to 5
+ *
+ *
+ *
+ *
+ * @param v_mag_offset_u8 : The value of mag offset
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_offset(
+u8 *v_mag_offset_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_MAG_OFFSET__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_mag_offset_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_MAG_OFFSET);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to set
+ * trigger-readout offset in units of 2.5 ms. If set to zero,
+ * the offset is maximum, i.e. after readout a trigger
+ * is issued immediately. from the register 0x4C bit 2 to 5
+ *
+ *
+ *
+ *
+ * @param v_mag_offset_u8 : The value of mag offset
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_offset(
+u8 v_mag_offset_u8)
+{
+/* variable used for return the status of communication result*/
+BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_MAG_OFFSET__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 =
+ BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_MAG_OFFSET, v_mag_offset_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_MAG_OFFSET__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ }
+return com_rslt;
+}
+/*!
+ * @brief This API is used to read
+ * Enable register access on MAG_IF[2] or MAG_IF[3] writes.
+ * This implies that the DATA registers are not updated with
+ * magnetometer values. Accessing magnetometer requires
+ * the magnetometer in normal mode in PMU_STATUS.
+ * from the register 0x4C bit 7
+ *
+ *
+ *
+ * @param v_mag_manual_u8 : The value of mag manual enable
+ * value | mag manual
+ * ----------|-------------------
+ * 0x01 | BMI160_ENABLE
+ * 0x00 | BMI160_DISABLE
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_manual_enable(
+u8 *v_mag_manual_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read mag manual */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_MAG_MANUAL_ENABLE__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_mag_manual_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_MAG_MANUAL_ENABLE);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to set
+ * Enable register access on MAG_IF[2] or MAG_IF[3] writes.
+ * This implies that the DATA registers are not updated with
+ * magnetometer values. Accessing magnetometer requires
+ * the magnetometer in normal mode in PMU_STATUS.
+ * from the register 0x4C bit 7
+ *
+ *
+ *
+ * @param v_mag_manual_u8 : The value of mag manual enable
+ * value | mag manual
+ * ----------|-------------------
+ * 0x01 | BMI160_ENABLE
+ * 0x00 | BMI160_DISABLE
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_manual_enable(
+u8 v_mag_manual_u8)
+{
+/* variable used for return the status of communication result*/
+BMI160_RETURN_FUNCTION_TYPE com_rslt = BMI160_INIT_VALUE;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* write the mag manual*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_MAG_MANUAL_ENABLE__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+ if (com_rslt == SUCCESS) {
+ /* set the bit of mag manual enable*/
+ v_data_u8 =
+ BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_MAG_MANUAL_ENABLE, v_mag_manual_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_MAG_MANUAL_ENABLE__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ if (com_rslt == SUCCESS)
+ p_bmi160->mag_manual_enable = v_mag_manual_u8;
+ else
+ p_bmi160->mag_manual_enable = E_BMI160_COMM_RES;
+ }
+return com_rslt;
+}
+/*!
+ * @brief This API is used to read data
+ * magnetometer address to read from the register 0x4D bit 0 to 7
+ * @brief It used to provide mag read address of auxiliary mag
+ *
+ *
+ *
+ *
+ * @param v_mag_read_addr_u8 : The value of address need to be read
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_read_addr(
+u8 *v_mag_read_addr_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read the written address*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_READ_ADDR__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_mag_read_addr_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_READ_ADDR);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to set
+ * magnetometer write address from the register 0x4D bit 0 to 7
+ * @brief mag write address writes the address of auxiliary mag to write
+ *
+ *
+ *
+ * @param v_mag_read_addr_u8:
+ * The data of auxiliary mag address to write data
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_read_addr(
+u8 v_mag_read_addr_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* write the mag read address*/
+ com_rslt =
+ p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_READ_ADDR__REG, &v_mag_read_addr_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to read
+ * magnetometer write address from the register 0x4E bit 0 to 7
+ * @brief mag write address writes the address of auxiliary mag to write
+ *
+ *
+ *
+ * @param v_mag_write_addr_u8:
+ * The data of auxiliary mag address to write data
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_write_addr(
+u8 *v_mag_write_addr_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* read the address of last written */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_WRITE_ADDR__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_mag_write_addr_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_WRITE_ADDR);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to set
+ * magnetometer write address from the register 0x4E bit 0 to 7
+ * @brief mag write address writes the address of auxiliary mag to write
+ *
+ *
+ *
+ * @param v_mag_write_addr_u8:
+ * The data of auxiliary mag address to write data
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_write_addr(
+u8 v_mag_write_addr_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* write the data of mag address to write data */
+ com_rslt =
+ p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_WRITE_ADDR__REG, &v_mag_write_addr_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to read magnetometer write data
+ * form the resister 0x4F bit 0 to 7
+ * @brief This writes the data will be wrote to mag
+ *
+ *
+ *
+ * @param v_mag_write_data_u8: The value of mag data
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_write_data(
+u8 *v_mag_write_data_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_WRITE_DATA__REG, &v_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_mag_write_data_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_WRITE_DATA);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to set magnetometer write data
+ * form the resister 0x4F bit 0 to 7
+ * @brief This writes the data will be wrote to mag
+ *
+ *
+ *
+ * @param v_mag_write_data_u8: The value of mag data
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+*/
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_write_data(
+u8 v_mag_write_data_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ com_rslt =
+ p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->dev_addr,
+ BMI160_USER_WRITE_DATA__REG, &v_mag_write_data_u8,
+ BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to read
+ * interrupt enable from the register 0x50 bit 0 to 7
+ *
+ *
+ *
+ *
+ * @param v_enable_u8 : Value to decided to select interrupt
+ * v_enable_u8 | interrupt
+ * ---------------|---------------
+ * 0 | BMI160_ANY_MOTION_X_ENABLE
+ * 1 | BMI160_ANY_MOTION_Y_ENABLE
+ * 2 | BMI160_ANY_MOTION_Z_ENABLE
+ * 3 | BMI160_DOUBLE_TAP_ENABLE
+ * 4 | BMI160_SINGLE_TAP_ENABLE
+ * 5 | BMI160_ORIENT_ENABLE
+ * 6 | BMI160_FLAT_ENABLE
+ *
+ * @param v_intr_enable_zero_u8 : The interrupt enable value
+ * value | interrupt enable
+ * ----------|-------------------
+ * 0x01 | BMI160_ENABLE
+ * 0x00 | BMI160_DISABLE
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_enable_0(
+u8 v_enable_u8, u8 *v_intr_enable_zero_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ /* select interrupt to read*/
+ switch (v_enable_u8) {
+ case BMI160_ANY_MOTION_X_ENABLE:
+ /* read the any motion interrupt x data */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_intr_enable_zero_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE);
+ break;
+ case BMI160_ANY_MOTION_Y_ENABLE:
+ /* read the any motion interrupt y data */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_intr_enable_zero_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE);
+ break;
+ case BMI160_ANY_MOTION_Z_ENABLE:
+ /* read the any motion interrupt z data */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_intr_enable_zero_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE);
+ break;
+ case BMI160_DOUBLE_TAP_ENABLE:
+ /* read the double tap interrupt data */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_intr_enable_zero_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE);
+ break;
+ case BMI160_SINGLE_TAP_ENABLE:
+ /* read the single tap interrupt data */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_intr_enable_zero_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE);
+ break;
+ case BMI160_ORIENT_ENABLE:
+ /* read the orient interrupt data */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+ dev_addr, BMI160_USER_INTR_ENABLE_0_ORIENT_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_intr_enable_zero_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_ENABLE_0_ORIENT_ENABLE);
+ break;
+ case BMI160_FLAT_ENABLE:
+ /* read the flat interrupt data */
+ com_rslt =
+ p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+ dev_addr, BMI160_USER_INTR_ENABLE_0_FLAT_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_intr_enable_zero_u8 =
+ BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_ENABLE_0_FLAT_ENABLE);
+ break;
+ default:
+ com_rslt = E_BMI160_OUT_OF_RANGE;
+ break;
+ }
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to set
+ * interrupt enable from the register 0x50 bit 0 to 7
+ *
+ *
+ *
+ *
+ * @param v_enable_u8 : Value to decided to select interrupt
+ * v_enable_u8 | interrupt
+ * ---------------|---------------
+ * 0 | BMI160_ANY_MOTION_X_ENABLE
+ * 1 | BMI160_ANY_MOTION_Y_ENABLE
+ * 2 | BMI160_ANY_MOTION_Z_ENABLE
+ * 3 | BMI160_DOUBLE_TAP_ENABLE
+ * 4 | BMI160_SINGLE_TAP_ENABLE
+ * 5 | BMI160_ORIENT_ENABLE
+ * 6 | BMI160_FLAT_ENABLE
+ *
+ * @param v_intr_enable_zero_u8 : The interrupt enable value
+ * value | interrupt enable
+ * ----------|-------------------
+ * 0x01 | BMI160_ENABLE
+ * 0x00 | BMI160_DISABLE
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_enable_0(
+u8 v_enable_u8, u8 v_intr_enable_zero_u8)
+{
+/* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+u8 v_data_u8 = BMI160_INIT_VALUE;
+/* check the p_bmi160 structure as NULL*/
+if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ switch (v_enable_u8) {
+ case BMI160_ANY_MOTION_X_ENABLE:
+ /* write any motion x*/
+ com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+ dev_addr, BMI160_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE,
+ v_intr_enable_zero_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ break;
+ case BMI160_ANY_MOTION_Y_ENABLE:
+ /* write any motion y*/
+ com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+ dev_addr, BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE,
+ v_intr_enable_zero_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ break;
+ case BMI160_ANY_MOTION_Z_ENABLE:
+ /* write any motion z*/
+ com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+ dev_addr, BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE,
+ v_intr_enable_zero_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ break;
+ case BMI160_DOUBLE_TAP_ENABLE:
+ /* write double tap*/
+ com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+ dev_addr, BMI160_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE,
+ v_intr_enable_zero_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ break;
+ case BMI160_SINGLE_TAP_ENABLE:
+ /* write single tap */
+ com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+ dev_addr, BMI160_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE,
+ v_intr_enable_zero_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ break;
+ case BMI160_ORIENT_ENABLE:
+ /* write orient interrupt*/
+ com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+ dev_addr, BMI160_USER_INTR_ENABLE_0_ORIENT_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_ENABLE_0_ORIENT_ENABLE,
+ v_intr_enable_zero_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_0_ORIENT_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ break;
+ case BMI160_FLAT_ENABLE:
+ /* write flat interrupt*/
+ com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+ dev_addr, BMI160_USER_INTR_ENABLE_0_FLAT_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_ENABLE_0_FLAT_ENABLE,
+ v_intr_enable_zero_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_0_FLAT_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ break;
+ default:
+ com_rslt = E_BMI160_OUT_OF_RANGE;
+ break;
+ }
+}
+return com_rslt;
+}
+/*!
+ * @brief This API is used to read
+ * interrupt enable byte1 from the register 0x51 bit 0 to 6
+ * @brief It read the high_g_x,high_g_y,high_g_z,low_g_enable
+ * data ready, fifo full and fifo water mark.
+ *
+ *
+ *
+ * @param v_enable_u8 : The value of interrupt enable
+ * @param v_enable_u8 : Value to decided to select interrupt
+ * v_enable_u8 | interrupt
+ * ---------------|---------------
+ * 0 | BMI160_HIGH_G_X_ENABLE
+ * 1 | BMI160_HIGH_G_Y_ENABLE
+ * 2 | BMI160_HIGH_G_Z_ENABLE
+ * 3 | BMI160_LOW_G_ENABLE
+ * 4 | BMI160_DATA_RDY_ENABLE
+ * 5 | BMI160_FIFO_FULL_ENABLE
+ * 6 | BMI160_FIFO_WM_ENABLE
+ *
+ * @param v_intr_enable_1_u8 : The interrupt enable value
+ * value | interrupt enable
+ * ----------|-------------------
+ * 0x01 | BMI160_ENABLE
+ * 0x00 | BMI160_DISABLE
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_enable_1(
+u8 v_enable_u8, u8 *v_intr_enable_1_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ switch (v_enable_u8) {
+ case BMI160_HIGH_G_X_ENABLE:
+ /* read high_g_x interrupt*/
+ com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_intr_enable_1_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE);
+ break;
+ case BMI160_HIGH_G_Y_ENABLE:
+ /* read high_g_y interrupt*/
+ com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_intr_enable_1_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE);
+ break;
+ case BMI160_HIGH_G_Z_ENABLE:
+ /* read high_g_z interrupt*/
+ com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_intr_enable_1_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE);
+ break;
+ case BMI160_LOW_G_ENABLE:
+ /* read low_g interrupt */
+ com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+ dev_addr, BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_intr_enable_1_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE);
+ break;
+ case BMI160_DATA_RDY_ENABLE:
+ /* read data ready interrupt */
+ com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_1_DATA_RDY_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_intr_enable_1_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_ENABLE_1_DATA_RDY_ENABLE);
+ break;
+ case BMI160_FIFO_FULL_ENABLE:
+ /* read fifo full interrupt */
+ com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_intr_enable_1_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE);
+ break;
+ case BMI160_FIFO_WM_ENABLE:
+ /* read fifo water mark interrupt */
+ com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_1_FIFO_WM_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ *v_intr_enable_1_u8 = BMI160_GET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_ENABLE_1_FIFO_WM_ENABLE);
+ break;
+ default:
+ com_rslt = E_BMI160_OUT_OF_RANGE;
+ break;
+ }
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to set
+ * interrupt enable byte1 from the register 0x51 bit 0 to 6
+ * @brief It read the high_g_x,high_g_y,high_g_z,low_g_enable
+ * data ready, fifo full and fifo water mark.
+ *
+ *
+ *
+ * @param v_enable_u8 : The value of interrupt enable
+ * @param v_enable_u8 : Value to decided to select interrupt
+ * v_enable_u8 | interrupt
+ * ---------------|---------------
+ * 0 | BMI160_HIGH_G_X_ENABLE
+ * 1 | BMI160_HIGH_G_Y_ENABLE
+ * 2 | BMI160_HIGH_G_Z_ENABLE
+ * 3 | BMI160_LOW_G_ENABLE
+ * 4 | BMI160_DATA_RDY_ENABLE
+ * 5 | BMI160_FIFO_FULL_ENABLE
+ * 6 | BMI160_FIFO_WM_ENABLE
+ *
+ * @param v_intr_enable_1_u8 : The interrupt enable value
+ * value | interrupt enable
+ * ----------|-------------------
+ * 0x01 | BMI160_ENABLE
+ * 0x00 | BMI160_DISABLE
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_enable_1(
+u8 v_enable_u8, u8 v_intr_enable_1_u8)
+{
+ /* variable used for return the status of communication result*/
+ BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+ u8 v_data_u8 = BMI160_INIT_VALUE;
+ /* check the p_bmi160 structure as NULL*/
+ if (p_bmi160 == BMI160_NULL) {
+ return E_BMI160_NULL_PTR;
+ } else {
+ switch (v_enable_u8) {
+ case BMI160_HIGH_G_X_ENABLE:
+ /* write high_g_x interrupt*/
+ com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE,
+ v_intr_enable_1_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ break;
+ case BMI160_HIGH_G_Y_ENABLE:
+ /* write high_g_y interrupt*/
+ com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE,
+ v_intr_enable_1_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ break;
+ case BMI160_HIGH_G_Z_ENABLE:
+ /* write high_g_z interrupt*/
+ com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE,
+ v_intr_enable_1_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ break;
+ case BMI160_LOW_G_ENABLE:
+ /* write low_g interrupt*/
+ com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE,
+ v_intr_enable_1_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ break;
+ case BMI160_DATA_RDY_ENABLE:
+ /* write data ready interrupt*/
+ com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_1_DATA_RDY_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_ENABLE_1_DATA_RDY_ENABLE,
+ v_intr_enable_1_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_1_DATA_RDY_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ break;
+ case BMI160_FIFO_FULL_ENABLE:
+ /* write fifo full interrupt*/
+ com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE,
+ v_intr_enable_1_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ break;
+ case BMI160_FIFO_WM_ENABLE:
+ /* write fifo water mark interrupt*/
+ com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
+ dev_addr, BMI160_USER_INTR_ENABLE_1_FIFO_WM_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ if (com_rslt == SUCCESS) {
+ v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
+ BMI160_USER_INTR_ENABLE_1_FIFO_WM_ENABLE,
+ v_intr_enable_1_u8);
+ com_rslt +=
+ p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
+ dev_addr,
+ BMI160_USER_INTR_ENABLE_1_FIFO_WM_ENABLE__REG,
+ &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+ }
+ break;
+ default:
+ com_rslt = E_BMI160_OUT_OF_RANGE;
+ break;
+ }
+ }
+ return com_rslt;
+}
+/*!
+ * @brief This API is used to read
+ * interrupt enable byte2 from the register bit 0x52 bit 0 to 3
+ * @brief It reads no motion x,y and z
+ *
+ *
+ *
+ * @param v_enable_u8: The value of interrupt enable
+ * v_enable_u8 | interrupt
+ * ---------------|---------------
+ * 0 | BMI160_NOMOTION_X_ENABLE
+ * 1 | BMI160_NOMOTION_Y_ENABLE
+ * 2 | BMI160_NOMOTION_Z_ENABLE
+ *
+ * @param v_intr_enable_2_u8 : The interrupt enable value
+ * value | interrupt enable
+ * ----------|-------------------
+ * 0x01 | BMI160_ENABLE
+ * 0x00 | BMI160_DISABLE
+ *
+ *
+ *
+ * @return results of bus communication function
+ * @retval 0 -> Success
+ * @retval -1 -> Error
+ *
+ *
+ */
+BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_enable_2(