Explorar o código

Upgrade to v3.5.0

Bosch Sensortec %!s(int64=8) %!d(string=hai) anos
pai
achega
d28f5e22f4
Modificáronse 7 ficheiros con 6626 adicións e 32764 borrados
  1. 519 58
      README.md
  2. 4467 19983
      bmi160.c
  3. 389 11666
      bmi160.h
  4. 1205 0
      bmi160_defs.h
  5. 0 839
      bmi160_support.c
  6. 0 218
      bmi160_support.h
  7. 46 0
      changelog.md

+ 519 - 58
README.md

@@ -1,60 +1,521 @@
+# BMI160 sensor API
+## Introduction
+This package contains the Bosch Sensortec's BMI160 sensor driver (sensor API)
 
-CONTENTS OF THIS FILE
-=======================
-	* Introduction
-	* Version
-	* Integration details
-	* Driver files information
-	* Supported sensor interface
-	* Copy right
-
-
-INTRODUCTION
-===============
-	- This package contains the Bosch Sensortec MEMS BMI160 sensor driver (sensor API)
-	- The sensor driver package includes bmi160.h, bmi160.c, bmi160_support.h and bmi160_support.c files
-
-VERSION
-=========
-	- Version of bmi160 sensor driver is:
-		* bmi160.c 		- V2.2.1
-		* bmi160.h 		- V2.2.1
-		* bmi160_support.c 	- V1.1.4
-		* bmi160_support.h 	- V1.1.2
-
-INTEGRATION DETAILS
-=====================
-	- Integrate bmi160.h and bmi160.c file in to your project.
-	- The bmi160_support.c and bmi160_support.h file contains only examples for API use cases, so it is not required to integrate into project.
-
-DRIVER FILES INFORMATION
-===========================
-	bmi160.h
-	-----------
-		* This header file has the register address definition, constant definitions, data type definition and supported sensor driver calls declarations.
-
-	 bmi160.c
-	------------
-		* This file contains the implementation for the sensor driver APIs.
-
-	 bmi160_support.c
-	----------------------
-		* This file shall be used as an user guidance, here you can find samples of
-    			* Initialize the sensor with I2C/SPI communication
-        				- Add your code to the SPI and/or I2C bus read and bus write functions.
-            					- Return value can be chosen by yourself
-           					- API just passes that value to your application code
-        				- Add your code to the delay function
-        				- Change I2C address accordingly in bmi160.h
-   			* Different running modes(use cases) of BMI160 
-			* Interrupt configuration
-
-SUPPORTED SENSOR INTERFACE
-====================================
-	- This BMI160 sensor driver supports SPI and I2C interfaces
-
-
-COPYRIGHT
-===========
-	- Copyright (C) 2016 - 2017 Bosch Sensortec GmbH
+The sensor driver package includes bmi160.h, bmi160.c and bmi160_defs.h files
 
+## Version
+File | Version | Date
+-----|---------|-----
+bmi160.c |   3.5.0    |   13 Apr 2017
+bmi160.h |   3.5.0   |    13 Apr 2017
+bmi160_defs.h |   3.5.0    |   13 Apr 2017
+
+## Integration details
+* Integrate bmi160.h, bmi160_defs.h and bmi160.c file in to your project.
+* Include the bmi160.h file in your code like below.
+``` c
+#include "bmi160.h"
+```
+
+## File information
+* bmi160_defs.h : This header file has the constants, macros and datatype declarations.
+* bmi160.h : This header file contains the declarations of the sensor driver APIs.
+* bmi160.c : This source file contains the definitions of the sensor driver APIs.
+
+## Supported sensor interface
+* SPI 4-wire
+* I2C
+
+## Usage guide
+### Initializing the sensor
+To initialize the sensor, you will first need to create a device structure. You 
+can do this by creating an instance of the structure bmi160_dev. Then go on to 
+fill in the various parameters as shown below.
+
+#### Example for SPI 4-Wire
+``` c
+struct bmi160_dev sensor;
+
+/* You may assign a chip select identifier to be handled later */
+sensor.id = 0;
+sensor.interface = BMI160_SPI_INTF;
+sensor.read = user_spi_read;
+sensor.write = user_spi_write;
+sensor.delay_ms = user_delay_ms;
+
+
+int8_t rslt = BMI160_OK;
+rslt = bmi160_init(&sensor);
+/* After the above function call, accel_cfg and gyro_cfg parameters in the device 
+structure are set with default values, found in the datasheet of the sensor */
+```
+
+#### Example for I2C
+``` c
+struct bmi160_dev sensor;
+
+sensor.id = BMI160_I2C_ADDR;
+sensor.interface = BMI160_I2C_INTF;
+sensor.read = user_i2c_read;
+sensor.write = user_i2c_write;
+sensor.delay_ms = user_delay_ms;
+
+int8_t rslt = BMI160_OK;
+rslt = bmi160_init(&sensor);
+/* After the above function call, accel and gyro parameters in the device structure 
+are set with default values, found in the datasheet of the sensor */
+```
+
+### Configuring accel and gyro sensor
+#### Example for configuring accel and gyro sensors in normal mode
+``` c
+
+int8_t rslt = BMI160_OK;
+
+/* Select the Output data rate, range of accelerometer sensor */
+sensor.accel_cfg.odr = BMI160_ACCEL_ODR_1600HZ;
+sensor.accel_cfg.range = BMI160_ACCEL_RANGE_2G;
+sensor.accel_cfg.bw = BMI160_ACCEL_BW_NORMAL_AVG4;
+
+/* Select the power mode of accelerometer sensor */
+sensor.accel_cfg.power = BMI160_ACCEL_NORMAL_MODE;
+
+/* Select the Output data rate, range of Gyroscope sensor */
+sensor.gyro_cfg.odr = BMI160_GYRO_ODR_3200HZ;
+sensor.gyro_cfg.range = BMI160_GYRO_RANGE_2000_DPS;
+sensor.gyro_cfg.bw = BMI160_GYRO_BW_NORMAL_MODE;
+
+/* Select the power mode of Gyroscope sensor */
+sensor.gyro_cfg.power = BMI160_GYRO_NORMAL_MODE; 
+
+/* Set the sensor configuration */
+rslt = bmi160_set_sens_conf(&sensor);
+```
+
+### Reading sensor data
+#### Example for reading sensor data
+``` c
+
+int8_t rslt = BMI160_OK;
+struct bmi160_sensor_data accel;
+struct bmi160_sensor_data gyro;
+
+/* To read only Accel data */
+rslt = bmi160_get_sensor_data(BMI160_ACCEL_SEL, &accel, NULL, &sensor);
+
+/* To read only Gyro data */
+rslt = bmi160_get_sensor_data(BMI160_GYRO_SEL, NULL, &gyro, &sensor);
+
+/* To read both Accel and Gyro data */
+bmi160_get_sensor_data((BMI160_ACCEL_SEL | BMI160_GYRO_SEL), &accel, &gyro, &sensor);
+
+/* To read Accel data along with time */
+rslt = bmi160_get_sensor_data((BMI160_ACCEL_SEL | BMI160_TIME_SEL) , &accel, NULL, &sensor);
+
+/* To read Gyro data along with time */
+rslt = bmi160_get_sensor_data((BMI160_GYRO_SEL | BMI160_TIME_SEL), NULL, &gyro, &sensor);
+
+/* To read both Accel and Gyro data along with time*/
+bmi160_get_sensor_data((BMI160_ACCEL_SEL | BMI160_GYRO_SEL | BMI160_TIME_SEL), &accel, &gyro, &sensor);
+```
+
+### Setting the power mode of sensors
+#### Example for setting power mode of accel and gyro
+``` c
+
+int8_t rslt = BMI160_OK;
+
+/* Select the power mode */
+sensor.accel_cfg.power = BMI160_ACCEL_SUSPEND_MODE; 
+sensor.gyro_cfg.power = BMI160_GYRO_FASTSTARTUP_MODE; 
+
+/*  Set the Power mode  */
+rslt = bmi160_set_power_mode(&sensor);
+
+/* Select the power mode */
+sensor.accel_cfg.power = BMI160_ACCEL_NORMAL_MODE;
+sensor.gyro_cfg.power = BMI160_GYRO_NORMAL_MODE; 
+
+/*  Set the Power mode  */
+rslt = bmi160_set_power_mode(&sensor);
+
+```
+
+### Reading sensor data register
+#### Example for reading Chip Address
+``` c
+
+int8_t rslt = BMI160_OK;
+uint8_t reg_addr = BMI160_CHIP_ID_ADDR;
+uint8_t data;
+uint16_t len = 1;
+rslt = bmi160_get_regs(reg_addr, &data, len, &sensor);
+```
+
+
+### Writing to sensor data register
+#### Example for writing data to any motion threshold register
+``` c
+
+int8_t rslt = BMI160_OK;
+uint8_t reg_addr = BMI160_INT_MOTION_1_ADDR;
+uint8_t data = 20;
+uint16_t len = 1;
+rslt = bmi160_set_regs(reg_addr, &data, len, &sensor);
+```
+
+### Resetting the device using soft-reset
+#### Example for writing soft-reset command to command register
+``` c
+
+int8_t rslt = BMI160_OK;
+rslt = bmi160_soft_reset(&sensor);
+```
+
+
+### Configuring interrupts for sensors
+To configure the sensor interrupts, you will first need to create an interrupt 
+structure. You can do this by creating an instance of the structure bmi160_intr_sett.
+Then go on to fill in the various parameters as shown below
+
+
+### Configuring Any-motion Interrupt
+#### Example for configuring Any-motion Interrupt
+Note:- User can check the currently active interrupt(any-motion or sig-motion) by checking the **any_sig_sel** of bmi160_dev structure.
+``` c
+
+struct bmi160_intr_sett int_config;
+
+/* Select the Interrupt channel/pin */
+int_config.int_channel = BMI160_INT_CHANNEL_1;// Interrupt channel/pin 1
+
+/* Select the Interrupt type */
+int_config.int_type = BMI160_ACC_ANY_MOTION_INT;// Choosing Any motion interrupt
+
+/* Select the interrupt channel/pin settings */
+int_config.int_pin_sett.output_en = BMI160_ENABLE;// Enabling interrupt pins to act as output pin
+int_config.int_pin_sett.output_mode = BMI160_DISABLE;// Choosing push-pull mode for interrupt pin
+int_config.int_pin_sett.output_type = BMI160_DISABLE;// Choosing active low output
+int_config.int_pin_sett.edge_ctrl = BMI160_ENABLE;// Choosing edge triggered output
+int_config.int_pin_sett.input_en = BMI160_DISABLE;// Disabling interrupt pin to act as input
+int_config.int_pin_sett.latch_dur = BMI160_LATCH_DUR_NONE;// non-latched output
+
+/* Select the Any-motion interrupt parameters */
+int_config.int_type_cfg.acc_any_motion_int.anymotion_en = BMI160_ENABLE;// 1- Enable the any-motion, 0- disable any-motion 
+int_config.int_type_cfg.acc_any_motion_int.anymotion_x = BMI160_ENABLE;// Enabling x-axis for any motion interrupt
+int_config.int_type_cfg.acc_any_motion_int.anymotion_y = BMI160_ENABLE;// Enabling y-axis for any motion interrupt
+int_config.int_type_cfg.acc_any_motion_int.anymotion_z = BMI160_ENABLE;// Enabling z-axis for any motion interrupt
+int_config.int_type_cfg.acc_any_motion_int.anymotion_dur = 0;// any-motion duration
+int_config.int_type_cfg.acc_any_motion_int.anymotion_thr = 20;// (2-g range) -> (slope_thr) * 3.91 mg, (4-g range) -> (slope_thr) * 7.81 mg, (8-g range) ->(slope_thr) * 15.63 mg, (16-g range) -> (slope_thr) * 31.25 mg 
+
+/* Set the Any-motion interrupt */
+bmi160_set_intr_config(&int_config, &sensor); /* sensor is an instance of the structure bmi160_dev  */
+
+```
+### Configuring Flat Interrupt
+#### Example for configuring Flat Interrupt
+``` c
+
+struct bmi160_intr_sett int_config;
+
+/* Select the Interrupt channel/pin */
+int_config.int_channel = BMI160_INT_CHANNEL_1;// Interrupt channel/pin 1
+
+/* Select the Interrupt type */
+int_config.int_type = BMI160_ACC_FLAT_INT;// Choosing flat interrupt
+
+/* Select the interrupt channel/pin settings */
+int_config.int_pin_sett.output_en = BMI160_ENABLE;// Enabling interrupt pins to act as output pin
+int_config.int_pin_sett.output_mode = BMI160_DISABLE;// Choosing push-pull mode for interrupt pin
+int_config.int_pin_sett.output_type = BMI160_DISABLE;// Choosing active low output
+int_config.int_pin_sett.edge_ctrl = BMI160_ENABLE;// Choosing edge triggered output
+int_config.int_pin_sett.input_en = BMI160_DISABLE;// Disabling interrupt pin to act as input
+int_config.int_pin_sett.latch_dur = BMI160_LATCH_DUR_NONE;// non-latched output
+
+/* Select the Flat interrupt parameters */
+int_config.int_type_cfg.acc_flat_int.flat_en = BMI160_ENABLE;// 1-enable, 0-disable the flat interrupt
+int_config.int_type_cfg.acc_flat_int.flat_theta = 8;// threshold for detection of flat position in range from 0° to 44.8°.
+int_config.int_type_cfg.acc_flat_int.flat_hy = 1;// Flat hysteresis
+int_config.int_type_cfg.acc_flat_int.flat_hold_time = 1;// Flat hold time (0 -> 0 ms, 1 -> 640 ms, 2 -> 1280 ms, 3 -> 2560 ms)
+
+/* Set the Flat interrupt */
+bmi160_set_intr_config(&int_config, &sensor); /* sensor is an instance of the structure bmi160_dev */
+
+```
+
+
+### Configuring Step Detector Interrupt
+#### Example for configuring Step Detector Interrupt
+``` c
+
+struct bmi160_intr_sett int_config;
+
+/* Select the Interrupt channel/pin */
+int_config.int_channel = BMI160_INT_CHANNEL_1;// Interrupt channel/pin 1
+
+/* Select the Interrupt type */
+int_config.int_type = BMI160_STEP_DETECT_INT;// Choosing Step Detector interrupt
+
+/* Select the interrupt channel/pin settings */
+int_config.int_pin_sett.output_en = BMI160_ENABLE;// Enabling interrupt pins to act as output pin
+int_config.int_pin_sett.output_mode = BMI160_DISABLE;// Choosing push-pull mode for interrupt pin
+int_config.int_pin_sett.output_type = BMI160_ENABLE;// Choosing active High output
+int_config.int_pin_sett.edge_ctrl = BMI160_ENABLE;// Choosing edge triggered output
+int_config.int_pin_sett.input_en = BMI160_DISABLE;// Disabling interrupt pin to act as input
+int_config.int_pin_sett.latch_dur =BMI160_LATCH_DUR_NONE;// non-latched output
+
+/* Select the Step Detector interrupt parameters, Kindly use the recommended settings for step detector */
+int_config.int_type_cfg.acc_step_detect_int.step_detector_mode = BMI160_STEP_DETECT_NORMAL;
+int_config.int_type_cfg.acc_step_detect_int.step_detector_en = BMI160_ENABLE;// 1-enable, 0-disable the step detector
+
+/* Set the Step Detector interrupt */
+bmi160_set_intr_config(&int_config, &sensor); /* sensor is an instance of the structure bmi160_dev */
+
+```
+
+### Configuring Step counter
+To configure the step counter, user need to configure the step detector interrupt as described in above section.
+After configuring step detector, see the below code snippet for user space & ISR
+
+### User space
+``` c
+int8_t rslt = BMI160_OK;
+uint8_t step_enable = 1;//enable the step counter
+
+rslt = bmi160_set_step_counter(step_enable,  &sensor);
+```
+
+### ISR
+``` c
+int8_t rslt = BMI160_OK;
+uint16_t step_count = 0;//stores the step counter value
+
+rslt = bmi160_read_step_counter(&step_count,  &sensor);
+```
+### Configuring the auxiliary sensor BMM150
+It is assumend that secondary interface of bmi160 has external pull-up resistor in order to access the auxiliary sensor bmm150.
+
+### Accessing auxiliary BMM150 with BMM150 APIs via BMI160 secondary interface.
+
+## Integration details 
+* Integrate the souce codes of BMM150 and BMI160 in project.
+* Include the bmi160.h and bmm150.h file in your code like below.
+* It is mandatory to initialize the bmi160 device structure for primary interface and auxiliary sensor settings.
+* Create two wrapper functions , user_aux_read and user_aux_write in order to match the signature as mentioned below.
+* Invoke the "bmi160_aux_init" API to initialise the secondary interface in BMI160.
+* Invoke the "bmm150_init" API to initialise the BMM150 sensor.
+* Now we can use the BMM150 sensor APIs to access the BMM150 via BMI160.
+
+``` c
+/* main.c file */
+#include "bmi160.h"
+#include "bmm150.h"
+```
+### Initialization of auxiliary sensor BMM150
+```
+
+/* main.c file */
+struct bmm150_dev bmm150;
+
+/* function declaration */
+int8_t user_aux_read(uint8_t id, uint8_t reg_addr, uint8_t *aux_data, uint16_t len);
+int8_t user_aux_write(uint8_t id, uint8_t reg_addr, uint8_t *aux_data, uint16_t len);
+
+/* Configure device structure for auxiliary sensor parameter */
+sensor.aux_cfg.aux_sensor_enable = 1; // auxiliary sensor enable
+sensor.aux_cfg.aux_i2c_addr = BMI160_AUX_BMM150_I2C_ADDR; // auxiliary sensor address
+sensor.aux_cfg.manual_enable = 1; // setup mode enable
+sensor.aux_cfg.aux_rd_burst_len = 2;// burst read of 2 byte
+
+/* Configure the BMM150 device structure by 
+mapping user_aux_read and user_aux_write */
+bmm150.read = user_aux_read;
+bmm150.write = user_aux_write;
+bmm150.id = BMM150_DEFAULT_I2C_ADDRESS; 
+/* Ensure that sensor.aux_cfg.aux_i2c_addr = bmm150.id
+   for proper sensor operation */
+bmm150.delay_ms = delay_ms;
+bmm150.interface = BMM150_I2C_INTF;
+
+/* Initialize the auxiliary sensor interface */
+rslt = bmi160_aux_init(&sensor);
+
+/* Auxiliary sensor is enabled and can be accessed from this point */
+
+/* Configure the desired settings in auxiliary BMM150 sensor 
+ * using the bmm150 APIs */
+
+/* Initialising the bmm150 sensor */
+rslt = bmm150_init(&bmm150);
+
+/* Set the power mode and preset mode to enable Mag data sampling */
+bmm150.settings.pwr_mode = BMM150_NORMAL_MODE;
+rslt = bmm150_set_op_mode(&bmm150);
+
+bmm150.settings.preset_mode= BMM150_PRESETMODE_LOWPOWER;
+rslt = bmm150_set_presetmode(&bmm150);
+
+```
+### Wrapper functions
+```
+
+/*wrapper function to match the signature of bmm150.read */
+int8_t user_aux_read(uint8_t id, uint8_t reg_addr, uint8_t *aux_data, uint16_t len)
+{
+	int8_t rslt;
+	
+	/* Discarding the parameter id as it is redundant*/
+        rslt = bmi160_aux_read(reg_addr, aux_data, len, &bmi160);
+
+	return rslt;
+}
+
+/*wrapper function to match the signature of bmm150.write */
+int8_t user_aux_write(uint8_t id, uint8_t reg_addr, uint8_t *aux_data, uint16_t len)
+{
+	int8_t rslt;
+	
+	/* Discarding the parameter id as it is redundant */
+	rslt = bmi160_aux_write(reg_addr, aux_data, len, &bmi160);
+
+	return rslt;
+}
+
+```
+
+### Initialization of auxiliary BMM150 in auto mode
+Any sensor whose data bytes are less than or equal to 8 bytes can be synchronized with the BMI160 
+and read out of Accelerometer + Gyroscope + Auxiliary sensor data of that instance is possible
+which helps in creating less latency fusion data
+
+```
+/* Initialize the Auxiliary BMM150 following the above code 
+   until setting the power mode and preset mode */
+
+	/* In BMM150 Mag data starts from register address 0x42 */
+	uint8_t aux_addr = 0x42;
+	/* Buffer to store the Mag data from 0x42 to 0x48 */	
+	uint8_t mag_data[8] = {0};
+	
+	uint8_t index;
+		
+	/* Set the auxiliary sensor to auto mode */
+	rslt = bmi160_set_aux_auto_mode(&aux_addr, &sensor);
+	
+	/* Configure the Auxiliary sensor either in auto/manual modes and set the 
+	polling frequency for the Auxiliary interface */	
+	sensor.aux_cfg.aux_odr = 8; /* Represents polling rate in 100 Hz*/
+	rslt = bmi160_config_aux_mode(&sensor)
+
+	/* Reading data from BMI160 data registers */
+	rslt = bmi160_read_aux_data_auto_mode(mag_data, &sensor);
+
+	printf("\n RAW DATA ");
+	for(index = 0 ; index < 8 ; index++)
+	{
+		printf("\n MAG DATA[index] : %d ", index,mag_data[index]);
+	}
+	
+	/* Compensating the raw mag data available from the BMM150 API */
+	rslt = bmm150_aux_mag_data(mag_data,&bmm150);
+	
+	printf("\n COMPENSATED DATA ");
+	printf("\n MAG DATA X : %d Y : %d Z : %d", bmm150.data.x, bmm150.data.y, bmm150.data.z);
+	
+
+```
+## Self-test  
+#### Example for performing accel self test
+```
+/* Call the "bmi160_init" API as a prerequisite before performing self test
+ * since invoking self-test will reset the sensor */
+
+	rslt = bmi160_perform_self_test(BMI160_ACCEL_ONLY, sen);
+	/* Utilize the enum BMI160_GYRO_ONLY instead of BMI160_ACCEL_ONLY
+	   to perform self test for gyro */
+	if (rslt == BMI160_OK) {
+		printf("\n ACCEL SELF TEST RESULT SUCCESS);
+	} else {
+		printf("\n ACCEL SELF TEST RESULT FAIL);
+	}
+```
+
+
+## FIFO 
+#### Example for reading FIFO and extracting Gyro data in Header mode
+```
+/* An example to read the Gyro data in header mode along with sensor time (if available)
+ * Configure the gyro sensor as prerequisite and follow the below example to read and
+ * obtain the gyro data from FIFO */
+int8_t fifo_gyro_header_time_data(struct bmi160_dev *dev)
+{
+	int8_t rslt = 0;
+
+	/* Declare memory to store the raw FIFO buffer information */
+	uint8_t fifo_buff[300];
+	
+	/* Modify the FIFO buffer instance and link to the device instance */
+	struct bmi160_fifo_frame fifo_frame;
+	fifo_frame.data = fifo_buff;
+	fifo_frame.length = 300;
+	dev->fifo = &fifo_frame;
+	uint16_t index = 0;
+	
+	/* Declare instances of the sensor data structure to store the parsed FIFO data */
+	struct bmi160_sensor_data gyro_data[42]; // 300 bytes / ~7bytes per frame ~ 42 data frames
+	uint8_t gyro_frames_req = 42; 
+	uint8_t gyro_index;
+	
+	/* Configure the sensor's FIFO settings */
+	rslt = bmi160_set_fifo_config(BMI160_FIFO_GYRO | BMI160_FIFO_HEADER | BMI160_FIFO_TIME,
+					BMI160_ENABLE, dev);
+					
+	if (rslt == BMI160_OK) {
+		/* At ODR of 100 Hz ,1 frame gets updated in 1/100 = 0.01s
+		i.e. for 42 frames we need 42 * 0.01 = 0.42s = 420ms delay */
+		dev->delay_ms(420); 
+	
+		/* Read data from the sensor's FIFO and store it the FIFO buffer,"fifo_buff" */
+		printf("\n USER REQUESTED FIFO LENGTH : %d\n",dev->fifo->length);
+		rslt = bmi160_get_fifo_data(dev);
+
+		if (rslt == BMI160_OK) {
+			printf("\n AVAILABLE FIFO LENGTH : %d\n",dev->fifo->length);
+			/* Print the raw FIFO data */
+			for (index = 0; index < dev->fifo->length; index++) {
+				printf("\n FIFO DATA INDEX[%d] = %d", index,
+					dev->fifo->data[index]);
+			}
+			/* Parse the FIFO data to extract gyro data from the FIFO buffer */
+			printf("\n REQUESTED GYRO DATA FRAMES : %d\n ",gyro_frames_req);
+			rslt = bmi160_extract_gyro(gyro_data, &gyro_frames_req, dev);
+
+			if (rslt == BMI160_OK) {
+				printf("\n AVAILABLE GYRO DATA FRAMES : %d\n ",gyro_frames_req);
+				
+				/* Print the parsed gyro data from the FIFO buffer */
+				for (gyro_index = 0; gyro_index < gyro_frames_req; gyro_index++) {
+					printf("\nFIFO GYRO FRAME[%d]",gyro_index);
+					printf("\nGYRO X-DATA : %d \t Y-DATA : %d \t Z-DATA : %d"
+						,gyro_data[gyro_index].x ,gyro_data[gyro_index].y
+						,gyro_data[gyro_index].z);
+				}
+				/* Print the special FIFO frame data like sensortime */
+				printf("\n SENSOR TIME DATA : %d \n",dev->fifo->sensor_time);
+				printf("SKIPPED FRAME COUNT : %d",dev->fifo->skipped_frame_count);
+			} else {
+				printf("\n Gyro data extraction failed");
+			}
+		} else {
+			printf("\n Reading FIFO data failed");
+		}
+	} else {
+		printf("\n Setting FIFO configuration failed");
+	}
+
+	return rslt;
+}
+```
+
+## Copyright (C) 2016 - 2017 Bosch Sensortec GmbH

+ 4467 - 19983
bmi160.c

@@ -1,20791 +1,5275 @@
-/*
-****************************************************************************
-* Copyright (C) 2016 Bosch Sensortec GmbH
-*
-* bmi160.c
-* Date: 2016/06/27
-* Revision: 2.2.1 $
-*
-* Usage: Sensor Driver for BMI160 sensor
-*
-****************************************************************************
-* License:
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-*
-*   Redistributions of source code must retain the above copyright
-*   notice, this list of conditions and the following disclaimer.
-*
-*   Redistributions in binary form must reproduce the above copyright
-*   notice, this list of conditions and the following disclaimer in the
-*   documentation and/or other materials provided with the distribution.
-*
-*   Neither the name of the copyright holder nor the names of the
-*   contributors may be used to endorse or promote products derived from
-*   this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
-* OR CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-* OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO,
-* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-* ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
-*
-* The information provided is believed to be accurate and reliable.
-* The copyright holder 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 the copyright holder.
-**************************************************************************/
-
-/*! file BMI160
-    @brief Sensor driver for BMI160 */
+/**
+ * Copyright (C) 2015 - 2016 Bosch Sensortec GmbH
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of the copyright holder nor the names of the
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
+ *
+ * The information provided is believed to be accurate and reliable.
+ * The copyright holder 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 the copyright holder.
+ *
+ * @file    bmi160.c
+ * @date    13 Apr 2017
+ * @version 3.5.0
+ * @brief
+ *
+ */
+
+/*!
+ * @defgroup bmi160
+ * @brief
+ * @{*/
 
 #include "bmi160.h"
 
-struct bmi160_t *p_bmi160;
-/* Used for reading the Mag trim values for compensation*/
-struct trim_data_t mag_trim;
-/* the following variable is used for avoiding the selecting of auto mode
-when it is running in the manual mode of BMM150 Mag interface*/
-u8 bmm150_manual_auto_condition_u8_g;
-/*Power mode monitoring variable used to introduce delays after primary
-interface write in low power and suspend modes of sensor */
-u8 bmi160_power_mode_status_u8_g;
-/* FIFO data read for 1024 bytes of data */
-#ifdef FIFO_ENABLE
-static u8 v_fifo_data_u8[FIFO_FRAME];
-struct bmi160_mag_fifo_data_t mag_data;
-#endif
-/* YAMAHA-YAS532*/
-/* value of coefficient*/
-#ifdef YAS532
-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;
-struct yas532_vector fifo_xyz_data;
-#endif
-#ifdef YAS537
-/* used for reading the yas537 calibration data*/
-struct yas537_t yas537_data;
-struct yas_vector fifo_vector_xyz;
+/*********************************************************************/
+/* Static function declarations */
+
 /*!
- *	@brief This function is used to process the
- *	YAMAHA YAS537 xy1y2 raw data
+ * @brief This API configures the pins to fire the
+ * interrupt signal when it occurs.
+ *
+ * @param[in] int_config  : Structure instance of bmi160_int_settg.
+ * @param[in] dev         : Structure instance of bmi160_dev.
  *
- *	@param xy1y2: The value of raw xy1y2 data
- *	@param xyz: The value of  xyz data
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error.
+ */
+static int8_t set_intr_pin_config(const struct bmi160_int_settg *int_config,  const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API sets the any-motion interrupt of the sensor.
+ * This interrupt occurs when accel values exceeds preset threshold
+ * for a certain period of time.
  *
+ * @param[in] int_config  : Structure instance of bmi160_int_settg.
+ * @param[in] dev         : Structure instance of bmi160_dev.
  *
- *	@return None
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error.
+ */
+static int8_t set_accel_any_motion_int(struct bmi160_int_settg *int_config, struct bmi160_dev *dev);
+
+/*!
+ * @brief This API sets tap interrupts.Interrupt is fired when
+ * tap movements happen.
  *
+ * @param[in] int_config  : Structure instance of bmi160_int_settg.
+ * @param[in] dev         : Structure instance of bmi160_dev.
  *
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error.
  */
-static void xy1y2_to_xyz(u16 *xy1y2, s32 *xyz);
+static int8_t set_accel_tap_int(struct bmi160_int_settg *int_config, const struct bmi160_dev *dev);
+
 /*!
- *	@brief This function is used to detect whether the mag
- *  data obtained is valid or not
+ * @brief This API sets the data ready interrupt for both accel and gyro.
+ * This interrupt occurs when new accel and gyro data come.
  *
+ * @param[in] int_config  : Structure instance of bmi160_int_settg.
+ * @param[in] dev         : Structure instance of bmi160_dev.
  *
- *	@param v_cur_u16: The value of current Mag data
- *  @param v_last_u16: The value of last Mag data
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error.
+ */
+static int8_t set_accel_gyro_data_ready_int(const struct bmi160_int_settg *int_config,
+						const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API sets the significant motion interrupt of the sensor.This
+ * interrupt occurs when there is change in user location.
  *
+ * @param[in] int_config  : Structure instance of bmi160_int_settg.
+ * @param[in] dev         : Structure instance of bmi160_dev.
+
  *
- *	@return result of magnetic field data's validity
- *	@retval 0 -> VALID DATA
- *	@retval 1 -> INVALID DATA
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error.
+ */
+static int8_t set_accel_sig_motion_int(struct bmi160_int_settg *int_config, struct bmi160_dev *dev);
+
+/*!
+ * @brief This API sets the no motion/slow motion interrupt of the sensor.
+ * Slow motion is similar to any motion interrupt.No motion interrupt
+ * occurs when slope bet. two accel values falls below preset threshold
+ * for preset duration.
  *
+ * @param[in] int_config  : Structure instance of bmi160_int_settg.
+ * @param[in] dev         : Structure instance of bmi160_dev.
  *
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error.
  */
-static BMI160_RETURN_FUNCTION_TYPE invalid_magnetic_field(
-u16 *v_cur_u16, u16 *v_last_u16);
-#endif
-#if defined AKM09911 || defined AKM09912
-/* used to read the AKM compensating data */
-struct bst_akm_sensitivity_data_t akm_asa_data;
-#endif
-struct bmi160_mag_xyz_s32_t processed_data;
+static int8_t set_accel_no_motion_int(struct bmi160_int_settg *int_config, const struct bmi160_dev *dev);
 
+/*!
+ * @brief This API sets the step detection interrupt.This interrupt
+ * occurs when the single step causes accel values to go above
+ * preset threshold.
+ *
+ * @param[in] int_config  : Structure instance of bmi160_int_settg.
+ * @param[in] dev         : Structure instance of bmi160_dev.
+ *
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error.
+ */
+static int8_t set_accel_step_detect_int(struct bmi160_int_settg *int_config, const struct bmi160_dev *dev);
 
 /*!
- *	@brief
- *	This API is used to 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
+ * @brief This API sets the orientation interrupt of the sensor.This
+ * interrupt occurs when there is orientation change in the sensor
+ * with respect to gravitational field vector g.
  *
- *	@param bmi160 : structure pointer of bmi160 instance
+ * @param[in] int_config  : Structure instance of bmi160_int_settg.
+ * @param[in] dev         : Structure instance of bmi160_dev.
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error.
+ */
+static int8_t set_accel_orientation_int(struct bmi160_int_settg *int_config, const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API sets the flat interrupt of the sensor.This interrupt
+ * occurs in case of flat orientation
  *
- *	@note
- *	While changing the parameter of the bmi160_t
- *	consider the following points:
- *	Changing the reference value of the parameter
- *	will change the local copy or local reference
- *	make sure your changes will not
- *	affect the reference value of the parameter
- *	(Better don't change the reference value of the parameter)
+ * @param[in] int_config  : Structure instance of bmi160_int_settg.
+ * @param[in] dev         : Structure instance of bmi160_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_init(struct bmi160_t *bmi160)
-{
-	/* variable used to 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 pointer */
-	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);
-	/* store the chip id which is read from the sensor */
-	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;
-}
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error.
+ */
+static int8_t set_accel_flat_detect_int(struct bmi160_int_settg *int_config, const struct bmi160_dev *dev);
+
 /*!
- * @brief
- *	This API writes the data to
- *	the given register
+ * @brief This API sets the low-g interrupt of the sensor.This interrupt
+ * occurs during free-fall.
  *
+ * @param[in] int_config  : Structure instance of bmi160_int_settg.
+ * @param[in] dev         : Structure instance of bmi160_dev.
  *
- *	@param v_addr_u8 -> Address of the register
- *	@param v_data_u8 -> The data to write to the register
- *	@param v_len_u8 -> no of bytes to write
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error.
+ */
+static int8_t set_accel_low_g_int(struct bmi160_int_settg *int_config, const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API sets the high-g interrupt of the sensor.The interrupt
+ * occurs if the absolute value of acceleration data of any enabled axis
+ * exceeds the programmed threshold and the sign of the value does not
+ * change for a preset duration.
  *
+ * @param[in] int_config  : Structure instance of bmi160_int_settg.
+ * @param[in] dev         : Structure instance of bmi160_dev.
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error.
+ */
+static int8_t set_accel_high_g_int(struct bmi160_int_settg *int_config, const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API sets the default configuration parameters of accel & gyro.
+ * Also maintain the previous state of configurations.
  *
+ * @param[in] dev         : Structure instance of bmi160_dev.
  *
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error.
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_write_reg(u8 v_addr_u8,
-u8 *v_data_u8, u8 v_len_u8)
-{
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* check the p_bmi160 structure for NULL pointer assignment*/
-	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);
-
-			/*Accel and Gyro power mode check*/
-			if (bmi160_power_mode_status_u8_g !=
-			BMI160_NORMAL_MODE)
-				/*interface idle time delay */
-				p_bmi160->delay_msec(
-				BMI160_GEN_READ_WRITE_DELAY);
-		}
-	return com_rslt;
-}
+static void default_param_settg(struct bmi160_dev *dev);
 /*!
- * @brief
- *	This API reads the data from
- *	the given register
+ * @brief This API is used to validate the device structure pointer for
+ * null conditions.
  *
+ * @param[in] dev         : Structure instance of bmi160_dev.
  *
- *	@param v_addr_u8 -> Address of the register
- *	@param v_data_u8 -> The data read from the register
- *	@param v_len_u8 -> no of bytes to read
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error.
+ */
+static int8_t null_ptr_check(const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API set the accel configuration.
  *
+ * @param[in] dev         : Structure instance of bmi160_dev.
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error.
+ */
+static int8_t set_accel_conf(struct bmi160_dev *dev);
+
+ /*!
+ * @brief This API check the accel configuration.
  *
+ * @param[in] data        : Pointer to store the updated accel config.
+ * @param[in] dev         : Structure instance of bmi160_dev.
  *
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error.
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_reg(u8 v_addr_u8,
-u8 *v_data_u8, u8 v_len_u8)
-{
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* check the p_bmi160 structure for NULL pointer assignment*/
-	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;
-}
+static int8_t check_accel_config(uint8_t *data, const struct bmi160_dev *dev);
+
+ /*!
+  * @brief This API process the accel odr.
+  *
+  * @param[in] dev         : Structure instance of bmi160_dev.
+  *
+  * @return Result of API execution status
+  * @retval zero -> Success / -ve value -> Error.
+  */
+static int8_t process_accel_odr(uint8_t *data, const struct bmi160_dev *dev);
+
+ /*!
+  * @brief This API process the accel bandwidth.
+  *
+  * @param[in] dev         : Structure instance of bmi160_dev.
+  *
+  * @return Result of API execution status
+  * @retval zero -> Success / -ve value -> Error.
+  */
+static int8_t process_accel_bw(uint8_t *data, const struct bmi160_dev *dev);
+
+ /*!
+  * @brief This API process the accel range.
+  *
+  * @param[in] dev         : Structure instance of bmi160_dev.
+  *
+  * @return Result of API execution status
+  * @retval zero -> Success / -ve value -> Error.
+  */
+static int8_t process_accel_range(uint8_t *data, const struct bmi160_dev *dev);
+
 /*!
- *	@brief This API is used to read the fatal error
- *	from the register 0x02 bit 0
- *	This flag will be reset only by power-on-reset and soft reset
+ * @brief This API checks the invalid settings for ODR & Bw for Accel and Gyro.
+ * @param[in] dev         : Structure instance of bmi160_dev.
  *
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error.
+ */
+static int8_t check_invalid_settg(const struct bmi160_dev *dev);
+
+ /*!
+ * @brief This API set the gyro configuration.
  *
- *  @param v_fatal_err_u8 : The status of fatal error
+ * @param[in] dev         : Structure instance of bmi160_dev.
  *
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error.
+ */
+static int8_t set_gyro_conf(struct bmi160_dev *dev);
+
+ /*!
+ * @brief This API check the gyro configuration.
  *
+ * @param[in] data        : Pointer to store the updated gyro config.
+ * @param[in] dev         : Structure instance of bmi160_dev.
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error.
+ */
+static int8_t check_gyro_config(uint8_t *data, const struct bmi160_dev *dev);
+
+ /*!
+  * @brief This API process the gyro odr.
+  *
+  * @param[in] dev         : Structure instance of bmi160_dev.
+  *
+  * @return Result of API execution status
+  * @retval zero -> Success / -ve value -> Error.
+  */
+static int8_t process_gyro_odr(uint8_t *data, const struct bmi160_dev *dev);
+
+ /*!
+  * @brief This API process the gyro bandwidth.
+  *
+  * @param[in] dev         : Structure instance of bmi160_dev.
+  *
+  * @return Result of API execution status
+  * @retval zero -> Success / -ve value -> Error.
+  */
+static int8_t process_gyro_bw(uint8_t *data, const struct bmi160_dev *dev);
+
+ /*!
+  * @brief This API process the gyro range.
+  *
+  * @param[in] dev         : Structure instance of bmi160_dev.
+  *
+  * @return Result of API execution status
+  * @retval zero -> Success / -ve value -> Error.
+  */
+static int8_t process_gyro_range(uint8_t *data, const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API sets the accel power mode.
  *
+ * @param[in] dev         : Structure instance of bmi160_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_fatal_err(u8
-*v_fatal_err_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read 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;
-}
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error.
+ */
+static int8_t set_accel_pwr(struct bmi160_dev *dev);
+
 /*!
- *	@brief This API is used to read the error code
- *	from register 0x02 bit 1 to 4
- *
+ * @brief This API process the undersampling setting of Accel.
  *
- *  @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 (Gyro 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 is greater than
- *		|selected ODR
- *	0x06	|FIFO configuration error for header less mode
- *	0x07	|Under sampling mode and pre filtered data as FIFO source
+ * @param[in] dev         : Structure instance of bmi160_dev.
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error.
+ */
+static int8_t process_under_sampling(uint8_t *data,
+	const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API sets the gyro power mode.
  *
+ * @param[in] dev         : Structure instance of bmi160_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_err_code(u8
-*v_err_code_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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;
-}
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error.
+ */
+static int8_t set_gyro_pwr(struct bmi160_dev *dev);
+
 /*!
- *	@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
+ * @brief This API reads accel data along with sensor time if time is requested
+ * by user. Kindly refer the user guide(README.md) for more info.
  *
+ * @param[in] len    : len to read no of bytes
+ * @param[out] accel    : Structure pointer to store accel data
+ * @param[in] dev       : Structure instance of bmi160_dev.
  *
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t get_accel_data(uint8_t len, struct bmi160_sensor_data *accel, const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API reads accel data along with sensor time if time is requested
+ * by user. Kindly refer the user guide(README.md) for more info.
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @param[in] len    : len to read no of bytes
+ * @param[out] gyro    : Structure pointer to store accel data
+ * @param[in] dev       : Structure instance of bmi160_dev.
  *
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t get_gyro_data(uint8_t len, struct bmi160_sensor_data *gyro, const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API reads accel and gyro data along with sensor time
+ * if time is requested by user.
+ * Kindly refer the user guide(README.md) for more info.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_i2c_fail_err(u8
-*v_i2c_err_code_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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[in] len    : len to read no of bytes
+ * @param[out] accel    : Structure pointer to store accel data
+ * @param[out] gyro    : Structure pointer to store accel data
+ * @param[in] dev       : Structure instance of bmi160_dev.
  *
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t get_accel_gyro_data(uint8_t len, struct bmi160_sensor_data *accel, struct bmi160_sensor_data *gyro,
+					const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API enables the any-motion interrupt for accel.
  *
- *  @param v_drop_cmd_err_u8 : The status of dropped command error
+ * @param[in] any_motion_int_cfg   : Structure instance of
+ *				     bmi160_acc_any_mot_int_cfg.
+ * @param[in] dev		   : Structure instance of bmi160_dev.
  *
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t enable_accel_any_motion_int(const struct bmi160_acc_any_mot_int_cfg *any_motion_int_cfg,
+						struct bmi160_dev *dev);
+
+/*!
+ * @brief This API disable the sig-motion interrupt.
  *
+ * @param[in] dev	: Structure instance of bmi160_dev.
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t disable_sig_motion_int(const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API maps the INT pin to any-motion or
+ * sig-motion interrupt.
  *
+ * @param[in] int_config	: Structure instance of bmi160_int_settg.
+ * @param[in] dev		: Structure instance of bmi160_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_drop_cmd_err(u8
-*v_drop_cmd_err_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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;
-}
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t map_int_pin_to_sig_any_motion(
+	const struct bmi160_int_settg *int_config,
+	const struct bmi160_dev *dev);
+
 /*!
- *	@brief This API reads the Mag data ready
- *	error interrupt
- *	It reads from the error register 0x02 bit 7
- *
+ * @brief This API configure the source of data(filter & pre-filter)
+ * for any-motion interrupt.
  *
+ * @param[in] any_motion_int_cfg  : Structure instance of
+ *				    bmi160_acc_any_mot_int_cfg.
+ * @param[in] dev		  : Structure instance of bmi160_dev.
  *
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t config_any_motion_src(const struct bmi160_acc_any_mot_int_cfg *any_motion_int_cfg,
+					const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API configure the duration and threshold of
+ * any-motion interrupt.
  *
- *  @param v_mag_data_rdy_err_u8 : The status of Mag data ready error interrupt
+ * @param[in] any_motion_int_cfg  : Structure instance of
+ *				    bmi160_acc_any_mot_int_cfg.
+ * @param[in] dev		  : Structure instance of bmi160_dev.
  *
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t config_any_dur_threshold(const struct bmi160_acc_any_mot_int_cfg *any_motion_int_cfg,
+					const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API configure necessary setting of any-motion interrupt.
  *
+ * @param[in] int_config	   : Structure instance of bmi160_int_settg.
+ * @param[in] any_motion_int_cfg   : Structure instance of
+ *				     bmi160_acc_any_mot_int_cfg.
+ * @param[in] dev		   : Structure instance of bmi160_dev.
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t config_any_motion_int_settg(const struct bmi160_int_settg *int_config,
+					const struct bmi160_acc_any_mot_int_cfg *any_motion_int_cfg,
+					const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API enable the data ready interrupt.
  *
+ * @param[in] dev		: Structure instance of bmi160_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_data_rdy_err(
-u8 *v_mag_data_rdy_err_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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_DATA_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_DATA_RDY_ERR);
-		}
-	return com_rslt;
-}
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t enable_data_ready_int(const struct bmi160_dev *dev);
+
 /*!
- *	@brief This API reads the error status
- *	from the error register 0x02 bit 0 to 7
+ * @brief This API maps the data ready interrupt to INT pin as per selection.
  *
- *  @param v_mag_data_rdy_err_u8 : The status of Mag data ready interrupt
- *  @param v_fatal_err_u8 : 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
+ * @param[in] int_config	: Structure instance of bmi160_int_settg.
+ * @param[in] dev		: Structure instance of bmi160_dev.
  *
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t map_data_ready_int(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API enables the no motion/slow motion interrupt.
  *
+ * @param[in] no_mot_int_cfg	: Structure instance of
+ *				  bmi160_acc_no_motion_int_cfg.
+ * @param[in] dev		: Structure instance of bmi160_dev.
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t enable_no_motion_int(const struct bmi160_acc_no_motion_int_cfg *no_mot_int_cfg,
+					const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API configure the interrupt PIN setting for
+ * no motion/slow motion interrupt.
  *
+ * @param[in] int_config	: structure instance of bmi160_int_settg.
+ * @param[in] no_mot_int_cfg	: Structure instance of
+ *				  bmi160_acc_no_motion_int_cfg.
+ * @param[in] dev		: Structure instance of bmi160_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_error_status(u8 *v_fatal_err_u8,
-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 to 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 for NULL pointer assignment*/
-	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_err_u8 =
-			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_DATA_RDY_ERR);
-		}
-	return com_rslt;
-}
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t config_no_motion_int_settg(const struct bmi160_int_settg *int_config,
+					const struct bmi160_acc_no_motion_int_cfg *no_mot_int_cfg,
+					const struct bmi160_dev *dev);
+
 /*!
- *	@brief This API reads the Mag power mode from
- *	PMU status register 0x03 bit 0 and 1
+ * @brief This API maps the INT pin to no motion/slow interrupt.
  *
- *  @param v_mag_power_mode_stat_u8 : The value of Mag power mode
- *	mag_powermode    |   value
- * ------------------|----------
- *    SUSPEND        |   0x00
- *    NORMAL         |   0x01
- *   LOW POWER       |   0x02
+ * @param[in] int_config	: Structure instance of bmi160_int_settg.
+ * @param[in] dev		: Structure instance of bmi160_dev.
  *
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t map_int_pin_to_no_motion(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API configure the source of interrupt for no motion.
  *
- * @note The power mode of Mag is set by the 0x7E command register
- * using the function "bmi160_set_command_register()"
- *  value    |   mode
- *  ---------|----------------
- *   0x18    | MAG_MODE_SUSPEND
- *   0x19    | MAG_MODE_NORMAL
- *   0x1A    | MAG_MODE_LOWPOWER
+ * @param[in] no_mot_int_cfg	: Structure instance of
+ *				  bmi160_acc_no_motion_int_cfg.
+ * @param[in] dev		: Structure instance of bmi160_dev.
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t config_no_motion_data_src(const struct bmi160_acc_no_motion_int_cfg *no_mot_int_cfg,
+					const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API configure the duration and threshold of
+ * no motion/slow motion interrupt along with selection of no/slow motion.
  *
+ * @param[in] no_mot_int_cfg	: Structure instance of
+ *				  bmi160_acc_no_motion_int_cfg.
+ * @param[in] dev		: Structure instance of bmi160_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_power_mode_stat(u8
-*v_mag_power_mode_stat_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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;
-}
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t config_no_motion_dur_thr(const struct bmi160_acc_no_motion_int_cfg *no_mot_int_cfg,
+					const struct bmi160_dev *dev);
+
 /*!
- *	@brief This API reads the Gyro power mode from
- *	PMU status register 0x03 bit 2 and 3
+ * @brief This API enables the sig-motion motion interrupt.
  *
- *  @param v_gyro_power_mode_stat_u8 :	The value of gyro power mode
- *	gyro_powermode   |   value
- * ------------------|----------
- *    SUSPEND        |   0x00
- *    NORMAL         |   0x01
- *   FAST POWER UP   |   0x03
+ * @param[in] sig_mot_int_cfg	: Structure instance of
+ *				  bmi160_acc_sig_mot_int_cfg.
+ * @param[in] dev		: Structure instance of bmi160_dev.
  *
- * @note The power mode of gyro is set by the 0x7E command register
- * 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
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t enable_sig_motion_int(const struct bmi160_acc_sig_mot_int_cfg *sig_mot_int_cfg, struct bmi160_dev *dev);
+
+/*!
+ * @brief This API configure the interrupt PIN setting for
+ * significant motion interrupt.
  *
+ * @param[in] int_config	: Structure instance of bmi160_int_settg.
+ * @param[in] sig_mot_int_cfg	: Structure instance of
+ *				  bmi160_acc_sig_mot_int_cfg.
+ * @param[in] dev		: Structure instance of bmi160_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_power_mode_stat(u8
-*v_gyro_power_mode_stat_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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;
-}
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t config_sig_motion_int_settg(const struct bmi160_int_settg *int_config,
+					const struct bmi160_acc_sig_mot_int_cfg *sig_mot_int_cfg,
+					const struct bmi160_dev *dev);
+
 /*!
- *	@brief This API reads the Accel power mode from
- *	PMU status register 0x03 bit 4 and 5
+ * @brief This API configure the source of data(filter & pre-filter)
+ * for sig motion interrupt.
  *
+ * @param[in] sig_mot_int_cfg	: Structure instance of
+ *				  bmi160_acc_sig_mot_int_cfg.
+ * @param[in] dev		: Structure instance of bmi160_dev.
  *
- *  @param v_accel_power_mode_stat_u8 :	The value of Accel power mode
- *	accel_powermode  |   value
- * ------------------|----------
- *    SUSPEND        |   0x00
- *    NORMAL         |   0x01
- *  LOW POWER        |   0x02
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t config_sig_motion_data_src(const struct bmi160_acc_sig_mot_int_cfg *sig_mot_int_cfg,
+					const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API configure the threshold, skip and proof time of
+ * sig motion interrupt.
  *
- * @note The power mode of Accel is set by the 0x7E command register
- * using the function "bmi160_set_command_register()"
- *  value    |   mode
- *  ---------|----------------
- *   0x11    | ACCEL_MODE_NORMAL
- *   0x12    | ACCEL_LOWPOWER
- *   0x10    | ACCEL_SUSPEND
+ * @param[in] sig_mot_int_cfg	: Structure instance of
+ *				  bmi160_acc_sig_mot_int_cfg.
+ * @param[in] dev		: Structure instance of bmi160_dev.
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t config_sig_dur_threshold(const struct bmi160_acc_sig_mot_int_cfg *sig_mot_int_cfg,
+					const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API enables the step detector interrupt.
  *
+ * @param[in] step_detect_int_cfg	: Structure instance of
+ *					  bmi160_acc_step_detect_int_cfg.
+ * @param[in] dev			: Structure instance of bmi160_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_power_mode_stat(u8
-*v_accel_power_mode_stat_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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;
-}
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t enable_step_detect_int(const struct bmi160_acc_step_detect_int_cfg *step_detect_int_cfg,
+					const struct bmi160_dev *dev);
+
 /*!
- *	@brief This API switches the Mag interface to normal mode
- *	and confirm whether the mode switching is done successfully or not
+ * @brief This API maps the INT pin to low-g or step detector interrupt.
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @param[in] int_config	: Structure instance of bmi160_int_settg.
+ * @param[in] dev		: Structure instance of bmi160_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_interface_normal(void)
-{
-	/* variable used to 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_NORMAL_SWITCH_TIMES;
-	u8 v_mag_pmu_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 != 0) {
-		com_rslt = bmi160_get_mag_power_mode_stat(&v_mag_pmu_status_u8);
-		if (v_mag_pmu_status_u8 == MAG_INTERFACE_PMU_ENABLE)
-			break;
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		v_try_times_u8--;
-	}
-	if (v_mag_pmu_status_u8 == MAG_INTERFACE_PMU_ENABLE)
-		com_rslt += SUCCESS;
-	else
-		com_rslt += E_BMI160_COMM_RES;
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t map_int_pin_to_low_step_detect(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev);
 
-	return com_rslt;
-}
 /*!
- *	@brief This API reads Mag data X values
- *	from the register 0x04 and 0x05
- *	@brief The Mag sensor data read from auxiliary mag
+ * @brief This API configure the step detector parameter.
  *
- *  @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
+ * @param[in] step_detect_int_cfg	: Structure instance of
+ *					  bmi160_acc_step_detect_int_cfg.
+ * @param[in] dev			: Structure instance of bmi160_dev.
  *
- *	@note For Mag output data rate configuration use the following function
- *	bmi160_set_mag_output_data_rate()
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t config_step_detect(const struct bmi160_acc_step_detect_int_cfg *step_detect_int_cfg,
+					const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API enables the single/double tap interrupt.
  *
+ * @param[in] int_config	: Structure instance of bmi160_int_settg.
+ * @param[in] dev		: Structure instance of bmi160_dev.
  *
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t enable_tap_int(const struct bmi160_int_settg *int_config,
+				const struct bmi160_acc_tap_int_cfg *tap_int_cfg,
+				const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API configure the interrupt PIN setting for
+ * tap interrupt.
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @param[in] int_config	: Structure instance of bmi160_int_settg.
+ * @param[in] tap_int_cfg	: Structure instance of bmi160_acc_tap_int_cfg.
+ * @param[in] dev		: Structure instance of bmi160_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_x(s16 *v_mag_x_s16,
-u8 v_sensor_select_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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;
-}
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t config_tap_int_settg(const struct bmi160_int_settg *int_config,
+					const struct bmi160_acc_tap_int_cfg *tap_int_cfg,
+					const struct bmi160_dev *dev);
+
 /*!
- *	@brief This API reads Mag data Y values
- *	from the register 0x06 and 0x07
- *	@brief The Mag sensor data read from 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
+ * @brief This API maps the INT pin to single or double tap interrupt.
  *
- *	@note For Mag output data rate configuration use the following function
- *	bmi160_set_mag_output_data_rate()
+ * @param[in] int_config	: Structure instance of bmi160_int_settg.
+ * @param[in] dev		: Structure instance of bmi160_dev.
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t map_int_pin_to_tap(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API configure the source of data(filter & pre-filter)
+ * for tap interrupt.
  *
+ * @param[in] tap_int_cfg	: Structure instance of bmi160_acc_tap_int_cfg.
+ * @param[in] dev		: Structure instance of bmi160_dev.
  *
-*/
-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 for NULL pointer assignment*/
-	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;
-}
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t config_tap_data_src(const struct bmi160_acc_tap_int_cfg *tap_int_cfg, const struct bmi160_dev *dev);
+
 /*!
- *	@brief This API reads Mag data Z values
- *	from the register 0x08 and 0x09
- *	@brief The Mag sensor data read from 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
+ * @brief This API configure the  parameters of tap interrupt.
+ * Threshold, quite, shock, and duration.
  *
- *	@note For Mag output data rate configuration use the following function
- *	bmi160_set_mag_output_data_rate()
+ * @param[in] int_config	: Structure instance of bmi160_int_settg.
+ * @param[in] tap_int_cfg	: Structure instance of bmi160_acc_tap_int_cfg.
+ * @param[in] dev		: structure instance of bmi160_dev.
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t config_tap_param(const struct bmi160_int_settg *int_config,
+				const struct bmi160_acc_tap_int_cfg *tap_int_cfg,
+				const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API enable the external mode configuration.
  *
+ * @param[in] dev	: Structure instance of bmi160_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_z(s16 *v_mag_z_s16,
-u8 v_sensor_select_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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;
-}
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t config_sec_if(const struct bmi160_dev *dev);
+
 /*!
- *	@brief This API reads Mag data RHALL values
- *	from the register 0x0A and 0x0B
- *
+ * @brief This API configure the ODR of the auxiliary sensor.
  *
- *  @param v_mag_r_s16 : The value of BMM150 r data
+ * @param[in] dev	: Structure instance of bmi160_dev.
  *
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t config_aux_odr(const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API maps the actual burst read length set by user.
  *
+ * @param[in] len	: Pointer to store the read length.
+ * @param[in] dev	: Structure instance of bmi160_dev.
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t map_read_len(uint16_t *len, const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API configure the settings of auxiliary sensor.
  *
+ * @param[in] dev	: Structure instance of bmi160_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_r(s16 *v_mag_r_s16)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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;
-}
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t config_aux_settg(const struct bmi160_dev *dev);
+
 /*!
- *	@brief This API reads Mag data X,Y,Z values
- *	from the register 0x04 to 0x09
- *
- *	@brief The Mag sensor data read from auxiliary mag
+ * @brief This API extract the read data from auxiliary sensor.
  *
- *  @param Mag : The value of Mag xyz data
- *  @param v_sensor_select_u8 : Mag selection value
- *  value    |   sensor
- *  ---------|----------------
- *   0       | BMM150
- *   1       | AKM09911 or AKM09912
+ * @param[in] map_len	  : burst read value.
+ * @param[in] reg_addr	  : Address of register to read.
+ * @param[in] aux_data	  : Pointer to store the read data.
+ * @param[in] len	  : length to read the data.
+ * @param[in] dev         : Structure instance of bmi160_dev.
+ * @note : Refer user guide for detailed info.
  *
- *	@note For Mag output data 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 to 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 for NULL pointer assignment*/
-	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 Mag data X,Y,Z,r
- *	values from the register 0x04 to 0x0B.
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error
+ */
+static int8_t extract_aux_read(uint16_t map_len, uint8_t reg_addr, uint8_t *aux_data, uint16_t len,
+				const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API enables the orient interrupt.
  *
- *	@brief The Mag sensor data read from auxiliary mag.
+ * @param[in] orient_int_cfg : Structure instance of bmi160_acc_orient_int_cfg.
+ * @param[in] dev	     : Structure instance of bmi160_dev.
  *
- *	@param Mag : The value of mag-BMM150 xyzr data.
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t enable_orient_int(const struct bmi160_acc_orient_int_cfg *orient_int_cfg, const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API maps the INT pin to orientation interrupt.
  *
- *	@note For Mag data output rate configuration use the following function
- *	@note bmi160_set_mag_output_data_rate().
+ * @param[in] int_config	: Structure instance of bmi160_int_settg.
+ * @param[in] dev		: structure instance of bmi160_dev.
  *
- *	@return results of bus communication function.
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t map_int_pin_to_orient(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API configure the necessary setting of orientation interrupt.
  *
+ * @param[in] orient_int_cfg : Structure instance of bmi160_acc_orient_int_cfg.
+ * @param[in] dev	     : structure instance of bmi160_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_xyzr(
-struct bmi160_mag_xyzr_t *mag)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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;
-}
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t config_orient_int_settg(const struct bmi160_acc_orient_int_cfg *orient_int_cfg,
+					const struct bmi160_dev *dev);
+
 /*!
- *	@brief This API reads gyro data X values
- *	from the register 0x0C and 0x0D.
+ * @brief This API enables the flat interrupt.
  *
- *	@param v_gyro_x_s16 : The value of gyro x data.
+ * @param[in] flat_int	: Structure instance of bmi160_acc_flat_detect_int_cfg.
+ * @param[in] dev		: structure instance of bmi160_dev.
  *
- *	@note Gyro configuration use the following functions.
- *	@note bmi160_set_gyro_output_data_rate()
- *	@note bmi160_set_gyro_bw()
- *	@note bmi160_set_gyro_range()
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t enable_flat_int(const struct bmi160_acc_flat_detect_int_cfg *flat_int, const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API maps the INT pin to flat interrupt.
  *
- *	@return results of bus communication function.
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @param[in] int_config	: Structure instance of bmi160_int_settg.
+ * @param[in] dev		: structure instance of bmi160_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_gyro_x(s16 *v_gyro_x_s16)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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;
-}
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t map_int_pin_to_flat(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev);
+
 /*!
- *	@brief This API reads gyro data Y values
- *	from the register 0x0E and 0x0F.
+ * @brief This API configure the necessary setting of flat interrupt.
  *
- *	@param v_gyro_y_s16 : The value of gyro y data.
+ * @param[in] flat_int	: Structure instance of bmi160_acc_flat_detect_int_cfg.
+ * @param[in] dev	: structure instance of bmi160_dev.
  *
- *	@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 Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t config_flat_int_settg(const struct bmi160_acc_flat_detect_int_cfg *flat_int,
+					const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API enables the Low-g interrupt.
  *
- *	@return results of bus communication function.
- *	@retval 0 -> Success
- *	@retval -1 -> Error result of communication routines
+ * @param[in] low_g_int	: Structure instance of bmi160_acc_low_g_int_cfg.
+ * @param[in] dev	: structure instance of bmi160_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_gyro_y(s16 *v_gyro_y_s16)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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;
-}
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t enable_low_g_int(const struct bmi160_acc_low_g_int_cfg *low_g_int, const struct bmi160_dev *dev);
+
 /*!
- *	@brief This API reads gyro data Z values
- *	from the register 0x10 and 0x11.
+ * @brief This API configure the source of data(filter & pre-filter) for low-g interrupt.
  *
- *	@param v_gyro_z_s16 : The value of gyro z data.
+ * @param[in] low_g_int	: Structure instance of bmi160_acc_low_g_int_cfg.
+ * @param[in] dev	: structure instance of bmi160_dev.
  *
- *	@note Gyro configuration use the following functions.
- *	@note bmi160_set_gyro_output_data_rate()
- *	@note bmi160_set_gyro_bw()
- *	@note bmi160_set_gyro_range()
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t config_low_g_data_src(const struct bmi160_acc_low_g_int_cfg *low_g_int, const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API configure the necessary setting of low-g interrupt.
  *
- *	@return results of the bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @param[in] low_g_int	: Structure instance of bmi160_acc_low_g_int_cfg.
+ * @param[in] dev	: structure instance of bmi160_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_gyro_z(s16 *v_gyro_z_s16)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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;
-}
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t config_low_g_int_settg(const struct bmi160_acc_low_g_int_cfg *low_g_int,  const struct bmi160_dev *dev);
+
 /*!
- *	@brief This API reads gyro data X,Y,Z values
- *	from the register 0x0C to 0x11.
+ * @brief This API enables the high-g interrupt.
  *
- *	@param gyro : The value of gyro xyz.
+ * @param[in] high_g_int_cfg : Structure instance of bmi160_acc_high_g_int_cfg.
+ * @param[in] dev	     : structure instance of bmi160_dev.
  *
- *	@note Gyro configuration use the following functions.
- *	@note bmi160_set_gyro_output_data_rate()
- *	@note bmi160_set_gyro_bw()
- *	@note bmi160_set_gyro_range()
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t enable_high_g_int(const struct bmi160_acc_high_g_int_cfg *high_g_int_cfg, const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API maps the INT pin to High-g interrupt.
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @param[in] int_config	: Structure instance of bmi160_int_settg.
+ * @param[in] dev		: structure instance of bmi160_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_gyro_xyz(struct bmi160_gyro_t *gyro)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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;
-}
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t map_int_pin_to_high_g(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev);
+
 /*!
- *	@brief This API reads the Accel data for X axis
- *	from the register 0x12 and 0x13.
+ * @brief This API configure the source of data(filter & pre-filter)
+ * for high-g interrupt.
  *
- *	@param v_accel_x_s16 : The value of Accel x axis.
+ * @param[in] high_g_int_cfg : Structure instance of bmi160_acc_high_g_int_cfg.
+ * @param[in] dev	     : structure instance of bmi160_dev.
  *
- *	@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 Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t config_high_g_data_src(const struct bmi160_acc_high_g_int_cfg *high_g_int_cfg,
+					const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API configure the necessary setting of high-g interrupt.
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @param[in] high_g_int_cfg : Structure instance of bmi160_acc_high_g_int_cfg.
+ * @param[in] dev	     : structure instance of bmi160_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_accel_x(s16 *v_accel_x_s16)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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;
-}
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t config_high_g_int_settg(const struct bmi160_acc_high_g_int_cfg *high_g_int_cfg,
+					const struct bmi160_dev *dev);
+
 /*!
- *	@brief This API reads Accel data for Y axis
- *	from the register 0x14 and 0x15.
+ * @brief This API configure the behavioural setting of interrupt pin.
  *
- *	@param v_accel_y_s16 : The value of Accel y axis.
+ * @param[in] int_config	: Structure instance of bmi160_int_settg.
+ * @param[in] dev		: structure instance of bmi160_dev.
  *
- *	@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 Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t config_int_out_ctrl(const struct bmi160_int_settg *int_config,  const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API configure the mode(input enable, latch or non-latch) of interrupt pin.
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @param[in] int_config	: Structure instance of bmi160_int_settg.
+ * @param[in] dev		: structure instance of bmi160_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_accel_y(s16 *v_accel_y_s16)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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;
-}
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t config_int_latch(const struct bmi160_int_settg *int_config,  const struct bmi160_dev *dev);
+
 /*!
- *	@brief This API reads Accel data Z values
- *	from the register 0x16 and 0x17.
+ * @brief This API performs the self test for accelerometer of BMI160
  *
- *	@param v_accel_z_s16 : The value of Accel z axis.
+ * @param[in] dev	: structure instance of bmi160_dev.
  *
- *	@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 Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t perform_accel_self_test(struct bmi160_dev *dev);
+
+/*!
+ * @brief This API enables to perform the accel self test by setting proper
+ * configurations to facilitate accel self test
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @param[in] dev	: structure instance of bmi160_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_accel_z(s16 *v_accel_z_s16)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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;
-}
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t enable_accel_self_test(struct bmi160_dev *dev);
+
 /*!
- *	@brief This API reads Accel data X,Y,Z values
- *	from the register 0x12 to 0x17.
+ * @brief This API performs accel self test with positive excitation
  *
- *	@param Accel :The value of Accel xyz axis.
+ * @param[in] accel_pos	: Structure pointer to store accel data
+ *                        for positive excitation
+ * @param[in] dev	: structure instance of bmi160_dev
  *
- *	@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 Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t accel_self_test_positive_excitation(struct bmi160_sensor_data *accel_pos, const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API performs accel self test with negative excitation
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @param[in] accel_neg	: Structure pointer to store accel data
+ *                        for negative excitation
+ * @param[in] dev	: structure instance of bmi160_dev
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_accel_xyz(
-struct bmi160_accel_t *accel)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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;
-}
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t accel_self_test_negative_excitation(struct bmi160_sensor_data *accel_neg, const struct bmi160_dev *dev);
+
 /*!
- *	@brief This API reads sensor_time from the register
- *	0x18 to 0x1A.
+ * @brief This API validates the accel self test results
  *
- *	@param v_sensor_time_u32 : The value of sensor time.
+ * @param[in] accel_pos	: Structure pointer to store accel data
+ *                        for positive excitation
+ * @param[in] accel_neg	: Structure pointer to store accel data
+ *                        for negative excitation
  *
- *	@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 to 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 for NULL pointer assignment*/
-	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;
-}
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error / +ve value -> Self test fail
+ */
+static int8_t validate_accel_self_test(const struct bmi160_sensor_data *accel_pos,
+					const struct bmi160_sensor_data *accel_neg);
+
 /*!
- *	@brief This API reads sensor_time, Accel data, gyro data from the
- *	register 0x0C to 0x1A.
+ * @brief This API performs the self test for gyroscope of BMI160
  *
- *	@param accel_gyro_sensortime_select : to select the configuration
- *  value    |   output
- *  ---------|----------------
- *   0       | Accel data and Sensor time
- *   1       | Accel data ,Gyro data and Sensor time
+ * @param[in] dev	: structure instance of bmi160_dev.
  *
- *	@param accel_gyro_sensor_time : the value of Accel data, gyro data and
- *	sensor time data
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t perform_gyro_self_test(const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API enables the self test bit to trigger self test for gyro
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @param[in] dev	: structure instance of bmi160_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_accel_gyro_sensor_time(
-	u8 accel_gyro_sensortime_select,
-struct bmi160_sensortime_accel_gyro_data *accel_gyro_sensor_time)
-{
-		u8 a_data_u8r[BMI160_GYRO_ACCEL_SENSORTIME_DATA_SIZE];
-		BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-
-		switch (accel_gyro_sensortime_select) {
-		case BMI160_ACCEL_SENSORTIME_DATA:
-			com_rslt = p_bmi160->BMI160_BURST_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_DATA_14_ACCEL_X_LSB__REG, a_data_u8r,
-			BMI160_ACCEL_SENSORTIME_DATA_SIZE);
-			/* Accel Data X */
-			accel_gyro_sensor_time->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]));
-			/* Accel Data Y */
-			accel_gyro_sensor_time->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]));
-			/* Accel Data Z */
-			accel_gyro_sensor_time->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]));
-			/* Sensor time data */
-			accel_gyro_sensor_time->v_sensor_time_u32 = (u32)((
-			((u32)a_data_u8r[BMI160_DATA_FRAME_ACCEL_Z_MSB_BYTE+3])
-			<< BMI160_SHIFT_BIT_POSITION_BY_16_BITS)|
-			(((u32)a_data_u8r[BMI160_DATA_FRAME_ACCEL_Z_MSB_BYTE+2])
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-			| (a_data_u8r[BMI160_DATA_FRAME_ACCEL_Z_MSB_BYTE+1]));
-			break;
-
-		case BMI160_GYRO_ACCEL_SENSORTIME_DATA:
-			com_rslt = p_bmi160->BMI160_BURST_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_DATA_8_GYRO_X_LSB__REG, a_data_u8r,
-			BMI160_GYRO_ACCEL_SENSORTIME_DATA_SIZE);
-			/* Gyro Data X */
-			accel_gyro_sensor_time->gyro.x = (s16)((((s32)((s8)
-			a_data_u8r[BMI160_DATA_FRAME_GYRO_X_MSB_BYTE]))
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-			| (a_data_u8r[BMI160_DATA_FRAME_GYRO_X_LSB_BYTE]));
-			/* Gyro Data Y */
-			accel_gyro_sensor_time->gyro.y = (s16)((((s32)
-			((s8)a_data_u8r[BMI160_DATA_FRAME_GYRO_Y_MSB_BYTE]))
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-			| (a_data_u8r[BMI160_DATA_FRAME_GYRO_Y_LSB_BYTE]));
-			/* Gyro Data Z */
-			accel_gyro_sensor_time->gyro.z = (s16)((((s32)
-			((s8)a_data_u8r[BMI160_DATA_FRAME_GYRO_Z_MSB_BYTE]))
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-			| (a_data_u8r[BMI160_DATA_FRAME_GYRO_Z_LSB_BYTE]));
-			/* Accel Data X */
-			accel_gyro_sensor_time->accel.x = (s16)((((s32)
-			((s8)a_data_u8r[BMI160_DATA_FRAME_GYRO_Z_MSB_BYTE+2]))
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-			| (a_data_u8r[BMI160_DATA_FRAME_GYRO_Z_MSB_BYTE+1]));
-			/* Accel Data Y */
-			accel_gyro_sensor_time->accel.y = (s16)((((s32)
-			((s8)a_data_u8r[BMI160_DATA_FRAME_GYRO_Z_MSB_BYTE+4]))
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-			| (a_data_u8r[BMI160_DATA_FRAME_GYRO_Z_MSB_BYTE+3]));
-			/* Accel Data Z */
-			accel_gyro_sensor_time->accel.z = (s16)((((s32)
-			((s8)a_data_u8r[BMI160_DATA_FRAME_GYRO_Z_MSB_BYTE+6]))
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-			| (a_data_u8r[BMI160_DATA_FRAME_GYRO_Z_MSB_BYTE+5]));
-			/* Sensor time data */
-			accel_gyro_sensor_time->v_sensor_time_u32 = (u32)
-			((((u32)a_data_u8r[BMI160_DATA_FRAME_GYRO_Z_MSB_BYTE+9])
-			<< BMI160_SHIFT_BIT_POSITION_BY_16_BITS)
-			|(((u32)a_data_u8r[BMI160_DATA_FRAME_GYRO_Z_MSB_BYTE+8])
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-			| (a_data_u8r[BMI160_DATA_FRAME_GYRO_Z_MSB_BYTE+7]));
-			break;
-
-		}
-	return com_rslt;
-
-}
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t enable_gyro_self_test(const struct bmi160_dev *dev);
 
 /*!
- *	@brief This API reads the Gyro self test
- *	status from the register 0x1B bit 1
- *
- *  @param v_gyro_selftest_u8 : The value of gyro self test status
- *  value    |   status
- *  ---------|----------------
- *   0       | Gyro self test is running or failed
- *   1       | Gyro self test completed successfully
+ * @brief This API validates the self test results of gyro
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @param[in] dev	: structure instance of bmi160_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_selftest(u8
-*v_gyro_selftest_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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;
-}
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t validate_gyro_self_test(const struct bmi160_dev *dev);
+
 /*!
- *	@brief This API reads the status of
- *	mag manual interface operation from the register 0x1B bit 2.
- *
- *  @param v_mag_manual_stat_u8 : The value of Mag manual operation status
- *  value    |   status
- *  ---------|----------------
- *   0       | Indicates no manual Mag
- *   -       | interface operation is ongoing
- *   1       | Indicates manual Mag
- *   -       | interface operation is ongoing
+ *  @brief This API sets FIFO full interrupt of the sensor.This interrupt
+ *  occurs when the FIFO is full and the next full data sample would cause
+ *  a FIFO overflow, which may delete the old samples.
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @param[in] int_config	: Structure instance of bmi160_int_settg.
+ * @param[in] dev		: structure instance of bmi160_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_manual_operation_stat(u8
-*v_mag_manual_stat_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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;
-}
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t set_fifo_full_int(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev);
+
 /*!
- *	@brief This API reads the fast offset compensation
- *	status from the register 0x1B bit 3
- *
+ * @brief This enable the FIFO full interrupt engine.
  *
- *  @param v_foc_rdy_u8 : The status of fast compensation
+ * @param[in] int_config	: Structure instance of bmi160_int_settg.
+ * @param[in] dev		: structure instance of bmi160_dev.
  *
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t enable_fifo_full_int(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API maps the INT pin to FIFO FULL interrupt.
  *
+ * @param[in] int_config	: Structure instance of bmi160_int_settg.
+ * @param[in] dev		: structure instance of bmi160_dev.
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t map_int_pin_to_fifo_full(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev);
+
+/*!
+ *  @brief This API sets FIFO watermark interrupt of the sensor.The FIFO
+ *  watermark interrupt is fired, when the FIFO fill level is above a fifo
+ *  watermark.
  *
+ * @param[in] int_config	: Structure instance of bmi160_int_settg.
+ * @param[in] dev		: structure instance of bmi160_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_rdy(u8
-*v_foc_rdy_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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;
-}
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t set_fifo_watermark_int(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev);
 
 /*!
- *	@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
+ * @brief This enable the FIFO watermark interrupt engine.
  *
- *  @param v_data_rdy_u8 : The value of Mag data ready status
+ * @param[in] int_config	: Structure instance of bmi160_int_settg.
+ * @param[in] dev		: structure instance of bmi160_dev.
  *
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t enable_fifo_wtm_int(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API maps the INT pin to FIFO watermark interrupt.
  *
+ * @param[in] int_config	: Structure instance of bmi160_int_settg.
+ * @param[in] dev		: structure instance of bmi160_dev.
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static int8_t map_int_pin_to_fifo_wtm(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev);
+
+/*!
+ * @brief This API is used to reset the FIFO related configurations
+ *  in the fifo_frame structure.
  *
+ * @param[in] dev		: structure instance of bmi160_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_data_rdy_mag(u8
-*v_data_rdy_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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;
-}
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static void reset_fifo_data_structure(const struct bmi160_dev *dev);
+
 /*!
- *	@brief This API reads the status of gyro data ready from the
- *	register 0x1B bit 6
- *	The status get reset when gyro data register read out
+ *  @brief This API is used to read number of bytes filled
+ *  currently in FIFO buffer.
  *
+ *  @param[in] bytes_to_read  : Number of bytes available in FIFO at the
+ *                              instant which is obtained from FIFO counter.
+ *  @param[in] dev            : Structure instance of bmi160_dev.
  *
- *	@param v_data_rdy_u8 :	The value of gyro data ready
+ *  @return Result of API execution status
+ *  @retval zero -> Success / -ve value -> Error.
+ *  @retval Any non zero value -> Fail
  *
+ */
+static int8_t get_fifo_byte_counter(uint16_t *bytes_to_read, struct bmi160_dev const *dev);
+
+/*!
+ *  @brief This API is used to compute the number of bytes of accel FIFO data
+ *  which is to be parsed in header-less mode
  *
+ *  @param[out] data_index        : The start index for parsing data
+ *  @param[out] data_read_length  : Number of bytes to be parsed
+ *  @param[in]  acc_frame_count   : Number of accelerometer frames to be read
+ *  @param[in]  dev               : Structure instance of bmi160_dev.
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ */
+static void get_accel_len_to_parse(uint16_t *data_index, uint16_t *data_read_length, const uint8_t *acc_frame_count,
+					const struct bmi160_dev *dev);
+
+/*!
+ *  @brief This API is used to parse the accelerometer data from the
+ *  FIFO data in both header mode and header-less mode.
+ *  It updates the idx value which is used to store the index of
+ *  the current data byte which is parsed.
+ *
+ *  @param[in,out] acc		: structure instance of sensor data
+ *  @param[in,out] idx		: Index value of number of bytes parsed
+ *  @param[in,out] acc_idx	: Index value of accelerometer data
+ *                                (x,y,z axes) frames parsed
+ *  @param[in] frame_info       : It consists of either fifo_data_enable
+ *                                parameter in header-less mode or
+ *                                frame header data in header mode
+ *  @param[in] dev		: structure instance of bmi160_dev.
+ *
+ *  @return Result of API execution status
+ *  @retval zero -> Success  / -ve value -> Error
+ */
+static void unpack_accel_frame(struct bmi160_sensor_data *acc, uint16_t *idx, uint8_t *acc_idx, uint8_t frame_info,
+				const struct bmi160_dev *dev);
+
+/*!
+ *  @brief This API is used to parse the accelerometer data from the
+ *  FIFO data and store it in the instance of the structure bmi160_sensor_data.
  *
+ * @param[in,out] accel_data	    : structure instance of sensor data
+ * @param[in,out] data_start_index  : Index value of number of bytes parsed
+ * @param[in] dev		    : structure instance of bmi160_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_data_rdy(u8
-*v_data_rdy_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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;
-}
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
+ */
+static void unpack_accel_data(struct bmi160_sensor_data *accel_data, uint16_t data_start_index,
+				const struct bmi160_dev *dev);
+
 /*!
- *	@brief This API reads the status of Accel data ready from the
- *	register 0x1B bit 7
- *	The status get reset when Accel data register is read
+ *  @brief This API is used to parse the accelerometer data from the
+ *  FIFO data in header mode.
  *
+ *  @param[in,out] accel_data	 : Structure instance of sensor data
+ *  @param[in,out] accel_length  : Number of accelerometer frames
+ *  @param[in] dev               : Structure instance of bmi160_dev.
  *
- *	@param v_data_rdy_u8 :	The value of Accel data ready status
+ *  @return Result of API execution status
+ *  @retval zero -> Success  / -ve value -> Error
+ */
+static void extract_accel_header_mode(struct bmi160_sensor_data *accel_data, uint8_t *accel_length,
+					const struct bmi160_dev *dev);
+
+/*!
+ *  @brief This API computes the number of bytes of gyro FIFO data
+ *  which is to be parsed in header-less mode
  *
+ *  @param[out] data_index       : The start index for parsing data
+ *  @param[out] data_read_length : No of bytes to be parsed from FIFO buffer
+ *  @param[in] gyro_frame_count  : Number of Gyro data frames to be read
+ *  @param[in] dev               : Structure instance of bmi160_dev.
+ */
+static void get_gyro_len_to_parse(uint16_t *data_index, uint16_t *data_read_length, const uint8_t *gyro_frame_count,
+					const struct bmi160_dev *dev);
+
+/*!
+ *  @brief This API is used to parse the gyroscope's data from the
+ *  FIFO data in both header mode and header-less mode.
+ *  It updates the idx value which is used to store the index of
+ *  the current data byte which is parsed.
+ *
+ *  @param[in,out] gyro		: structure instance of sensor data
+ *  @param[in,out] idx		: Index value of number of bytes parsed
+ *  @param[in,out] gyro_idx	: Index value of gyro data
+ *                                (x,y,z axes) frames parsed
+ *  @param[in] frame_info       : It consists of either fifo_data_enable
+ *                                parameter in header-less mode or
+ *                                frame header data in header mode
+ *  @param[in] dev		: structure instance of bmi160_dev.
+ *
+ *  @return Result of API execution status
+ *  @retval zero -> Success  / -ve value -> Error
+ */
+static void unpack_gyro_frame(struct bmi160_sensor_data *gyro, uint16_t *idx, uint8_t *gyro_idx, uint8_t frame_info,
+				const struct bmi160_dev *dev);
+
+
+/*!
+ *  @brief This API is used to parse the gyro data from the
+ *  FIFO data and store it in the instance of the structure bmi160_sensor_data.
  *
+ *  @param[in,out] gyro_data         : structure instance of sensor data
+ *  @param[in,out] data_start_index  : Index value of number of bytes parsed
+ *  @param[in] dev		     : structure instance of bmi160_dev.
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ *  @return Result of API execution status
+ *  @retval zero -> Success  / -ve value -> Error
+ */
+static void unpack_gyro_data(struct bmi160_sensor_data *gyro_data, uint16_t data_start_index,
+				const struct bmi160_dev *dev);
+
+/*!
+ *  @brief This API is used to parse the gyro data from the
+ *  FIFO data in header mode.
  *
+ *  @param[in,out] gyro_data	 : Structure instance of sensor data
+ *  @param[in,out] gyro_length   : Number of gyro frames
+ *  @param[in] dev               : Structure instance of bmi160_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_data_rdy(u8
-*v_data_rdy_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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;
-}
+ *  @return Result of API execution status
+ *  @retval zero -> Success  / -ve value -> Error
+ */
+static void extract_gyro_header_mode(struct bmi160_sensor_data *gyro_data, uint8_t *gyro_length,
+					const struct bmi160_dev *dev);
+
 /*!
- *	@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 the interrupt
- *	signal and hence the
- *	respective interrupt flag will be
- *	permanently latched, temporarily latched
- *	or not latched.
- *
+ *  @brief This API checks the presence of non-valid frames in the read fifo data.
  *
+ *  @param[in,out] data_index	 : The index of the current data to
+ *                                be parsed from fifo data
+ *  @param[in] dev               : Structure instance of bmi160_dev.
  *
+ *  @return Result of API execution status
+ *  @retval zero -> Success  / -ve value -> Error
+ */
+static void check_frame_validity(uint16_t *data_index, const struct bmi160_dev *dev);
+
+/*!
+ *  @brief This API is used to move the data index ahead of the
+ *  current_frame_length parameter when unnecessary FIFO data appears while
+ *  extracting the user specified data.
  *
- *  @param v_step_intr_u8 : The status of step detector interrupt
+ *  @param[in,out] data_index       : Index of the FIFO data which
+ *                                  is to be moved ahead of the
+ *                                  current_frame_length
+ *  @param[in] current_frame_length : Number of bytes in a particular frame
+ *  @param[in] dev                  : Structure instance of bmi160_dev.
  *
+ *  @return Result of API execution status
+ *  @retval zero -> Success  / -ve value -> Error
+ */
+static void move_next_frame(uint16_t *data_index, uint8_t current_frame_length, const struct bmi160_dev *dev);
+
+/*!
+ *  @brief This API is used to parse and store the sensor time from the
+ *  FIFO data in the structure instance dev.
  *
+ *  @param[in,out] data_index : Index of the FIFO data which
+ *                             has the sensor time.
+ *  @param[in] dev        : Structure instance of bma4_dev.
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ *  @return Result of API execution status
+ *  @retval zero -> Success  / -ve value -> Error
+ */
+static void unpack_sensortime_frame(uint16_t *data_index, const struct bmi160_dev *dev);
+
+/*!
+ *  @brief This API is used to parse and store the skipped_frame_count from
+ *  the FIFO data in the structure instance dev.
  *
+ *  @param[in,out] data_index       : Index of the FIFO data which
+ *                                    has the skipped frame count.
+ *  @param[in] dev              : Structure instance of bma4_dev.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_step_intr(u8
-*v_step_intr_u8)
+ *  @return Result of API execution status
+ *  @retval zero -> Success  / -ve value -> Error
+ */
+static void unpack_skipped_frame(uint16_t *data_index, const struct bmi160_dev *dev);
+
+/*********************** User function definitions ****************************/
+
+/*!
+ * @brief This API reads the data from the given register address
+ * of sensor.
+ */
+int8_t bmi160_get_regs(uint8_t reg_addr, uint8_t *data, uint16_t len, const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	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;
+	int8_t rslt = BMI160_OK;
+	/* Null-pointer check */
+	if ((dev == NULL) || (dev->read == NULL)) {
+		rslt = BMI160_E_NULL_PTR;
+	} else {
+		/* Configuring reg_addr for SPI Interface */
+		if (dev->interface == BMI160_SPI_INTF)
+			reg_addr = (reg_addr | BMI160_SPI_RD_MASK);
+
+		rslt = dev->read(dev->id, reg_addr, data, len);
+		/* Kindly refer section 3.2.4 of data-sheet*/
+		dev->delay_ms(1);
+		if (rslt != BMI160_OK)
+			rslt = BMI160_E_COM_FAIL;
+	}
+
+	return 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 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)
+ * @brief This API writes the given data to the register address
+ * of sensor.
+ */
+int8_t bmi160_set_regs(uint8_t reg_addr, uint8_t *data, uint16_t len, const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	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);
+	int8_t rslt = BMI160_OK;
+	uint8_t count = 0;
+	/* Null-pointer check */
+	if ((dev == NULL) || (dev->write == NULL)) {
+		rslt = BMI160_E_NULL_PTR;
+	} else {
+		/* Configuring reg_addr for SPI Interface */
+		if (dev->interface == BMI160_SPI_INTF)
+			reg_addr = (reg_addr & BMI160_SPI_WR_MASK);
+
+		if ((dev->prev_accel_cfg.power == BMI160_ACCEL_NORMAL_MODE) ||
+			(dev->prev_gyro_cfg.power == BMI160_GYRO_NORMAL_MODE)) {
+
+			rslt = dev->write(dev->id, reg_addr, data, len);
+			/* Kindly refer section 3.2.4 of data-sheet*/
+			dev->delay_ms(1);
+		} else {
+			/*Burst write is not allowed in
+			suspend & low power mode */
+			for (; count < len; count++) {
+				rslt = dev->write(dev->id, reg_addr, &data[count], 1);
+				reg_addr++;
+				/* Kindly refer section 3.2.4 of data-sheet*/
+				dev->delay_ms(1);
+			}
 		}
-	return com_rslt;
+
+		if (rslt != BMI160_OK)
+			rslt = BMI160_E_COM_FAIL;
+	}
+
+	return 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 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 to 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 for NULL pointer assignment*/
-	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 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 to 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 for NULL pointer assignment*/
-	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 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 to 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 for NULL pointer assignment*/
-	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 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 to 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 for NULL pointer assignment*/
-	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 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 to 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 for NULL pointer assignment*/
-	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 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 to 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 for NULL pointer assignment*/
-	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 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 to 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 for NULL pointer assignment*/
-	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 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 to 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 for NULL pointer assignment*/
-	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 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 to 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 for NULL pointer assignment*/
-	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;
-}
-#ifdef FIFO_ENABLE
-/*!
- *	@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 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 to 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 for NULL pointer assignment*/
-	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 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 to 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 for NULL pointer assignment*/
-	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;
-}
-#endif
-/*!
- *	@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 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 to 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 for NULL pointer assignment*/
-	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 to 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 for NULL pointer assignment*/
-	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 to 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 for NULL pointer assignment*/
-	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 to 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 for NULL pointer assignment*/
-	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 to 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 for NULL pointer assignment*/
-	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 to 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 for NULL pointer assignment*/
-	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 to 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 for NULL pointer assignment*/
-	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 to 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 for NULL pointer assignment*/
-	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 to 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 for NULL pointer assignment*/
-	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 to 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 for NULL pointer assignment*/
-	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 to 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 for NULL pointer assignment*/
-	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 to 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 for NULL pointer assignment*/
-	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 g sign status from the
- *	register 0x1F bit 3
- *
- *
- *
- *
- *  @param v_high_g_sign_u8 :The status of high g 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 to 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 for NULL pointer assignment*/
-	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 to 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 for NULL pointer assignment*/
-	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 to 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 for NULL pointer assignment*/
-	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 to 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 for NULL pointer assignment*/
-	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 to 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 for NULL pointer assignment*/
-	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;
-}
-#ifdef FIFO_ENABLE
-/*!
- *	@brief This API reads the FIFO length of the sensor
- *	from the register 0x23 and 0x24 bit 0 to 7 and 0 to 2
- *	@brief this byte counter is updated each time a complete frame
- *	is read or written
- *
- *
- *  @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 to 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 for NULL pointer assignment*/
-	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 v_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 to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* check the p_bmi160 structure for NULL pointer assignment*/
-	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;
-}
-#endif
-/*!
- *	@brief This API is used to get the
- *	Accel output data rate from 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 to 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 for NULL pointer assignment*/
-	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 from 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
- *
- *  @param  v_accel_bw_u8 :The value of Accel selected Accel bandwidth
- *  value |  output data rate
- * -------|--------------------------
- *    0   |  BMI160_ACCEL_OSR4_AVG1
- *    1   |  BMI160_ACCEL_OSR2_AVG2
- *    2   |  BMI160_ACCEL_NORMAL_AVG4
- *    3   |  BMI160_ACCEL_CIC_AVG8
- *    4   |  BMI160_ACCEL_RES_AVG2
- *    5   |  BMI160_ACCEL_RES_AVG4
- *    6   |  BMI160_ACCEL_RES_AVG8
- *    7   |  BMI160_ACCEL_RES_AVG16
- *    8   |  BMI160_ACCEL_RES_AVG32
- *    9   |  BMI160_ACCEL_RES_AVG64
- *    10  |  BMI160_ACCEL_RES_AVG128
- *
- *
- *
- *
- *
- *	@note Verify the Accel bandwidth before setting the
- *  output data rate
- *  bandwidth  | output data rate |  under sampling
- *-------------|------------------|----------------
- *   OSR4      |  12.5 TO 1600    |   0
- *   OSR2      |  12.5 TO 1600    |   0
- *  NORMAL     |  12.5 TO 1600    |   0
- *   CIC       |  12.5 TO 1600    |   0
- *   AVG2      |  0.78 TO 400     |   1
- *   AVG4      |  0.78 TO 200     |   1
- *   AVG8      |  0.78 TO 100     |   1
- *   AVG16     |  0.78 TO 50      |   1
- *   AVG32     |  0.78 TO 25      |   1
- *   AVG64     |  0.78 TO 12.5    |   1
- *   AVG128    |  0.78 TO 6.25    |   1
- *
- *	@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, u8 v_accel_bw_u8)
-{
-	/* variable used to 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_odr_u8 = BMI160_INIT_VALUE;
-	u8 v_assign_bw = BMI160_ASSIGN_DATA;
-	/* check the p_bmi160 structure for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		if ((v_accel_bw_u8 >= BMI160_ACCEL_RES_AVG2) &&
-		(v_accel_bw_u8 <= BMI160_ACCEL_RES_AVG128)) {
-			/* enable the under sampling*/
-			com_rslt = bmi160_set_accel_under_sampling_parameter(
-			BMI160_US_ENABLE);
-		} else if (((v_accel_bw_u8 > BMI160_ACCEL_OSR4_AVG1) &&
-		(v_accel_bw_u8 <= BMI160_ACCEL_CIC_AVG8))
-		|| (v_accel_bw_u8 == BMI160_ACCEL_OSR4_AVG1)) {
-			/* disable the under sampling*/
-			com_rslt = bmi160_set_accel_under_sampling_parameter(
-			BMI160_US_DISABLE);
-		}
-		/* assign the output data rate*/
-		switch (v_accel_bw_u8) {
-		case BMI160_ACCEL_RES_AVG2:
-			if (v_output_data_rate_u8
-			 >= BMI160_ACCEL_OUTPUT_DATA_RATE_0_78HZ
-			&& v_output_data_rate_u8
-			 <= BMI160_ACCEL_OUTPUT_DATA_RATE_400HZ) {
-				v_odr_u8 = v_output_data_rate_u8;
-				v_assign_bw = SUCCESS;
-			 } else {
-				com_rslt = E_BMI160_OUT_OF_RANGE;
-			 }
-		break;
-		case BMI160_ACCEL_RES_AVG4:
-			if (v_output_data_rate_u8
-			>= BMI160_ACCEL_OUTPUT_DATA_RATE_0_78HZ
-			&& v_output_data_rate_u8
-			<= BMI160_ACCEL_OUTPUT_DATA_RATE_200HZ) {
-				v_odr_u8 = v_output_data_rate_u8;
-				v_assign_bw = SUCCESS;
-			 } else {
-				com_rslt = E_BMI160_OUT_OF_RANGE;
-			 }
-		break;
-		case BMI160_ACCEL_RES_AVG8:
-			if (v_output_data_rate_u8
-			>= BMI160_ACCEL_OUTPUT_DATA_RATE_0_78HZ
-			&& v_output_data_rate_u8
-			 <= BMI160_ACCEL_OUTPUT_DATA_RATE_100HZ) {
-				v_odr_u8 = v_output_data_rate_u8;
-				v_assign_bw = SUCCESS;
-			 } else {
-				com_rslt = E_BMI160_OUT_OF_RANGE;
-			 }
-		break;
-		case BMI160_ACCEL_RES_AVG16:
-			if (v_output_data_rate_u8
-			>= BMI160_ACCEL_OUTPUT_DATA_RATE_0_78HZ
-			&& v_output_data_rate_u8
-			 <= BMI160_ACCEL_OUTPUT_DATA_RATE_50HZ) {
-				v_odr_u8 = v_output_data_rate_u8;
-				v_assign_bw = SUCCESS;
-			 } else {
-				com_rslt = E_BMI160_OUT_OF_RANGE;
-			 }
-		break;
-		case BMI160_ACCEL_RES_AVG32:
-			if (v_output_data_rate_u8
-			>= BMI160_ACCEL_OUTPUT_DATA_RATE_0_78HZ
-			&& v_output_data_rate_u8
-			<= BMI160_ACCEL_OUTPUT_DATA_RATE_25HZ) {
-				v_odr_u8 = v_output_data_rate_u8;
-				v_assign_bw = SUCCESS;
-			 } else {
-				com_rslt = E_BMI160_OUT_OF_RANGE;
-			 }
-		break;
-		case BMI160_ACCEL_RES_AVG64:
-		if (v_output_data_rate_u8
-		 >= BMI160_ACCEL_OUTPUT_DATA_RATE_0_78HZ
-		&& v_output_data_rate_u8
-		<= BMI160_ACCEL_OUTPUT_DATA_RATE_12_5HZ) {
-			v_odr_u8 = v_output_data_rate_u8;
-			v_assign_bw = SUCCESS;
-		 } else {
-			com_rslt = E_BMI160_OUT_OF_RANGE;
-		 }
-		break;
-		case BMI160_ACCEL_RES_AVG128:
-			if (v_output_data_rate_u8
-			>= BMI160_ACCEL_OUTPUT_DATA_RATE_0_78HZ
-			&& v_output_data_rate_u8
-			<= BMI160_ACCEL_OUTPUT_DATA_RATE_6_25HZ) {
-				v_odr_u8 = v_output_data_rate_u8;
-				v_assign_bw = SUCCESS;
-			 } else {
-				com_rslt = E_BMI160_OUT_OF_RANGE;
-			 }
-		break;
-		case BMI160_ACCEL_OSR4_AVG1:
-			if ((v_output_data_rate_u8
-			>= BMI160_ACCEL_OUTPUT_DATA_RATE_12_5HZ)
-			&& (v_output_data_rate_u8
-			<= BMI160_ACCEL_OUTPUT_DATA_RATE_1600HZ)) {
-				v_odr_u8 = v_output_data_rate_u8;
-				v_assign_bw = SUCCESS;
-			 } else {
-				com_rslt = E_BMI160_OUT_OF_RANGE;
-			 }
-		break;
-		case BMI160_ACCEL_OSR2_AVG2:
-			if ((v_output_data_rate_u8
-			>= BMI160_ACCEL_OUTPUT_DATA_RATE_12_5HZ)
-			&& (v_output_data_rate_u8
-			<= BMI160_ACCEL_OUTPUT_DATA_RATE_1600HZ)) {
-				v_odr_u8 = v_output_data_rate_u8;
-				v_assign_bw = SUCCESS;
-			 } else {
-				com_rslt = E_BMI160_OUT_OF_RANGE;
-			 }
-		break;
-		case BMI160_ACCEL_NORMAL_AVG4:
-			if ((v_output_data_rate_u8
-			>= BMI160_ACCEL_OUTPUT_DATA_RATE_12_5HZ)
-			&& (v_output_data_rate_u8
-			<= BMI160_ACCEL_OUTPUT_DATA_RATE_1600HZ)) {
-				v_odr_u8 = v_output_data_rate_u8;
-				v_assign_bw = SUCCESS;
-			 } else {
-				com_rslt = E_BMI160_OUT_OF_RANGE;
-			 }
-		break;
-		case BMI160_ACCEL_CIC_AVG8:
-			if ((v_output_data_rate_u8
-			>= BMI160_ACCEL_OUTPUT_DATA_RATE_12_5HZ)
-			&& (v_output_data_rate_u8
-			<= BMI160_ACCEL_OUTPUT_DATA_RATE_1600HZ)) {
-				v_odr_u8 = v_output_data_rate_u8;
-				v_assign_bw = SUCCESS;
-			 } else {
-				com_rslt = E_BMI160_OUT_OF_RANGE;
-			 }
-		break;
-		default:
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-		break;
-		}
-		if (v_assign_bw == SUCCESS) {
-			/* 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_odr_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);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		} 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 to 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 for NULL pointer assignment*/
-	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 to 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 for NULL pointer assignment*/
-	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);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-		}
-	}
-	return com_rslt;
-}
-/*!
- *	@brief This API is used to get the Accel
- *	under sampling parameter from 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 to 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 for NULL pointer assignment*/
-	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 from 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 to 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 for NULL pointer assignment*/
-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);
-
-			/*Accel and Gyro power mode check*/
-			if (bmi160_power_mode_status_u8_g !=
-			BMI160_NORMAL_MODE)
-				/*interface idle time delay */
-				p_bmi160->delay_msec(
-				BMI160_GEN_READ_WRITE_DELAY);
-		}
-	} else {
-	com_rslt = E_BMI160_OUT_OF_RANGE;
-	}
-}
-return com_rslt;
-}
-/*!
- *	@brief This API is used to get the range
- *	(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 to 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 for NULL pointer assignment*/
-	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 range
- *	(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 to 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 for NULL pointer assignment*/
-	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);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-		}
-	}
-	return com_rslt;
-}
-/*!
- *	@brief This API is used to get the
- *	Gyro 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 to 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 for NULL pointer assignment*/
-	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
- *	Gyro 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 to 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 for NULL pointer assignment*/
-	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);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-		}
-	}
-	return com_rslt;
-}
-/*!
- *	@brief This API is used to get the
- *	bandwidth 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 to 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 for NULL pointer assignment*/
-	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
- *	bandwidth 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 to 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 for NULL pointer assignment*/
-	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);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		} 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 to 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 for NULL pointer assignment*/
-	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 sets 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 to 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 for NULL pointer assignment*/
-	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);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-		}
-	}
-	return com_rslt;
-}
-/*!
- *	@brief This API is used to get the
- *	output data rate of Mag from the register 0x44 bit 0 to 3
- *
- *
- *
- *
- *  @param  v_output_data_rate_u8 : 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_rate_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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_rate_u8 = 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 Mag from the register 0x44 bit 0 to 3
- *
- *
- *
- *
- *  @param  v_output_data_rate_u8 : 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_rate_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		/* select the Mag data output rate*/
-		if ((v_output_data_rate_u8
-		<= BMI160_MAX_ACCEL_OUTPUT_DATA_RATE)
-		&& (v_output_data_rate_u8
-		!= BMI160_OUTPUT_DATA_RATE0)
-		&& (v_output_data_rate_u8
-		!=  BMI160_OUTPUT_DATA_RATE6)
-		&& (v_output_data_rate_u8
-		!=  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_rate_u8);
-				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);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-		}
-	}
-	return com_rslt;
-}
-#ifdef FIFO_ENABLE
- /*!
- *	@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 to 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 for NULL pointer assignment*/
-	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 to 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 for NULL pointer assignment*/
-	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 to 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 for NULL pointer assignment*/
-	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 to 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 for NULL pointer assignment*/
-	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 to 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 for NULL pointer assignment*/
-	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 to 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 for NULL pointer assignment*/
-	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 accel_fifo_filter_u8 :The value of Accel filter data
- *  value      |  accel_fifo_filter_u8
- * ------------|-------------------------
- *    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 *accel_fifo_filter_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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);
-			*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 to 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 for NULL pointer assignment*/
-	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 to 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 for NULL pointer assignment*/
-	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 to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* check the p_bmi160 structure for NULL pointer assignment*/
-	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 from 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 to 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 for NULL pointer assignment*/
-	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 sets FIFO sensor time
- *	frame after the last valid data frame from 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 to 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 for NULL pointer assignment*/
-	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 register 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 to 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 for NULL pointer assignment*/
-	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 sets FIFO tag interrupt2 enable status
- *	from the register 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 to 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 for NULL pointer assignment*/
-	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);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-		}
-	}
-	return com_rslt;
-}
-/*!
- *	@brief This API reads FIFO tag interrupt1 enable status
- *	from the register 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 to 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 for NULL pointer assignment*/
-	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 sets FIFO tag interrupt1 enable status
- *	from the register 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 to 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 for NULL pointer assignment*/
-	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);
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		} 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 to 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 for NULL pointer assignment*/
-	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 sets 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 to 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 for NULL pointer assignment*/
-	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 check whether
- *	Mag data in FIFO (all 3 axes) or not from the
- *	register 0x47 bit 5
- *
- *  @param v_fifo_mag_u8 : The value of FIFO Mag enable
- *	value    | FIFO mag
- * ----------|-------------------
- *  0x00     |  no Mag data is stored
- *  0x01     |  Mag 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 to 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 for NULL pointer assignment*/
-	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 enable
- *	Mag data in FIFO (all 3 axes) from the register 0x47 bit 5
- *
- *  @param v_fifo_mag_u8 : The value of FIFO Mag enable
- *	value    | FIFO mag
- * ----------|-------------------
- *  0x00     |  no Mag data is stored
- *  0x01     |  Mag 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 to 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 for NULL pointer assignment*/
-	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 check whether
- *	Accel data is stored in FIFO (all 3 axes) or not from the
- *	register 0x47 bit 6
- *
- *  @param v_fifo_accel_u8 : The value of FIFO Accel enable
- *	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 to 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 for NULL pointer assignment*/
-	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 enable
- *	Accel data in FIFO (all 3 axes) from the register 0x47 bit 6
- *
- *  @param v_fifo_accel_u8 : The value of FIFO Accel enable
- *	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 to 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 for NULL pointer assignment*/
-	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 check whether
- *	gyro data is stored in FIFO (all 3 axes) or not from the
- *	register 0x47 bit 7
- *
- *
- *  @param v_fifo_gyro_u8 : The value of FIFO gyro enable
- *	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 to 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 for NULL pointer assignment*/
-	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 enable
- *	gyro data in FIFO (all 3 axes) from the register 0x47 bit 7
- *
- *
- *  @param v_fifo_gyro_u8 : The value of FIFO gyro enable
- *	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 to 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 for NULL pointer assignment*/
-	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;
-}
-#endif
-/*!
- *	@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 to 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 for NULL pointer assignment*/
-	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 to 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 for NULL pointer assignment*/
-	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);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		}
-	return com_rslt;
-}
-/*!
- *	@brief This API is used to read the
- *	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 length
- *
- *
- *
- *	@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 to 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 for NULL pointer assignment*/
-	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 length
- *
- *
- *
- *	@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 to 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 for NULL pointer assignment*/
-	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);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		}
-	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 to 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 for NULL pointer assignment*/
-	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 the
- *	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 to 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 for NULL pointer assignment*/
-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);
-
-			/*Accel and Gyro power mode check*/
-			if (bmi160_power_mode_status_u8_g !=
-			BMI160_NORMAL_MODE)
-				/*interface idle time delay */
-				p_bmi160->delay_msec(
-				BMI160_GEN_READ_WRITE_DELAY);
-		}
-	}
-return com_rslt;
-}
-/*!
- *	@brief This API is used to read the
- *	Enable register access on MAG_IF[2] or MAG_IF[3].
- *	This implies that the DATA registers are not updated with
- *	Mag values. Accessing Mag requires
- *	the Mag 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 to 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 for NULL pointer assignment*/
-	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 the
- *	Enable register access of MAG_IF[2] or MAG_IF[3].
- *	This implies that the DATA registers are not updated with
- *	Mag values. Accessing Mag requires
- *	the Mag 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 to 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 for NULL pointer assignment*/
-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);
-
-			/*Accel and Gyro power mode check*/
-			if (bmi160_power_mode_status_u8_g !=
-			BMI160_NORMAL_MODE)
-				/*interface idle time delay */
-				p_bmi160->delay_msec(
-				BMI160_GEN_READ_WRITE_DELAY);
-		}
-		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 get the
- *	Mag read address from the register 0x4D bit 0 to 7
- *	@brief 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 to 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 for NULL pointer assignment*/
-	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
- *	Mag read address from the register 0x4D bit 0 to 7
- *	@brief address where data will be read from auxiliary mag
- *
- *
- *
- *  @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 to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* check the p_bmi160 structure for NULL pointer assignment*/
-	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);
-
-			/*Accel and Gyro power mode check*/
-			if (bmi160_power_mode_status_u8_g !=
-			BMI160_NORMAL_MODE)
-				/*interface idle time delay */
-				p_bmi160->delay_msec(
-				BMI160_GEN_READ_WRITE_DELAY);
-		}
-	return com_rslt;
-}
-/*!
- *	@brief This API is used to read
- *	Mag write address from the register 0x4E bit 0 to 7
- *	@brief write address where data will be written in Mag
- *
- *
- *
- *  @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 to 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 for NULL pointer assignment*/
-	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
- *	Mag write address from the register 0x4E bit 0 to 7
- *	@brief this is the address in Mag where the data will be written
- *
- *
- *
- *  @param  v_mag_write_addr_u8:
- *	The address which the data will be written to
- *
- *
- *	@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 to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* check the p_bmi160 structure for NULL pointer assignment*/
-	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);
-
-			/*Accel and Gyro power mode check*/
-			if (bmi160_power_mode_status_u8_g !=
-			BMI160_NORMAL_MODE)
-				/*interface idle time delay */
-				p_bmi160->delay_msec(
-				BMI160_GEN_READ_WRITE_DELAY);
-		}
-	return com_rslt;
-}
-/*!
- *	@brief This API is used to read Mag write data
- *	from the register 0x4F bit 0 to 7
- *	@brief The data will be written 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 to 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 for NULL pointer assignment*/
-	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 Mag write data
- *	from the register 0x4F bit 0 to 7
- *	@brief The data will be written 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 to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* check the p_bmi160 structure for NULL pointer assignment*/
-	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);
-
-			/*Accel and Gyro power mode check*/
-			if (bmi160_power_mode_status_u8_g !=
-			BMI160_NORMAL_MODE)
-				/*interface idle time delay */
-				p_bmi160->delay_msec(
-				BMI160_GEN_READ_WRITE_DELAY);
-		}
-	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 which selects the 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 to 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 for NULL pointer assignment*/
-	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 which selects the 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 to 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 for NULL pointer assignment*/
-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;
-	}
-	/*Accel and Gyro power mode check */
-	if (bmi160_power_mode_status_u8_g != BMI160_NORMAL_MODE)
-			/*interface idle time delay */
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-}
-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 which selects 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 to 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 for NULL pointer assignment*/
-	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 select the 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 to 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 for NULL pointer assignment*/
-	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;
-		}
-		/*Accel and Gyro power mode check*/
-		if (bmi160_power_mode_status_u8_g != BMI160_NORMAL_MODE)
-			/*interface idle time delay */
-			p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-
-	}
-	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(
-u8 v_enable_u8, u8 *v_intr_enable_2_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		switch (v_enable_u8) {
-		case BMI160_NOMOTION_X_ENABLE:
-			/* read no motion x */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr,
-			BMI160_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_enable_2_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE);
-			break;
-		case BMI160_NOMOTION_Y_ENABLE:
-			/* read no motion y */
-			com_rslt =
-			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr,
-			BMI160_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_enable_2_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE);
-			break;
-		case BMI160_NOMOTION_Z_ENABLE:
-			/* read no motion z */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr,
-			BMI160_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_enable_2_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE);
-			break;
-		default:
-			com_rslt = E_BMI160_OUT_OF_RANGE;
-			break;
-		}
-	}
-	return com_rslt;
-}
-/*!
- *	@brief  This API is used to set
- *	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_set_intr_enable_2(
-u8 v_enable_u8, u8 v_intr_enable_2_u8)
-{
-/* variable used to 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 for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-	} else {
-	switch (v_enable_u8) {
-	case BMI160_NOMOTION_X_ENABLE:
-		/* write no motion x */
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-		dev_addr,
-		BMI160_USER_INTR_ENABLE_2_NOMOTION_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_2_NOMOTION_X_ENABLE,
-			v_intr_enable_2_u8);
-			com_rslt +=
-			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-			dev_addr,
-			BMI160_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		}
-		break;
-	case BMI160_NOMOTION_Y_ENABLE:
-		/* write no motion y */
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-		dev_addr,
-		BMI160_USER_INTR_ENABLE_2_NOMOTION_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_2_NOMOTION_Y_ENABLE,
-			v_intr_enable_2_u8);
-			com_rslt +=
-			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-			dev_addr,
-			BMI160_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		}
-		break;
-	case BMI160_NOMOTION_Z_ENABLE:
-		/* write no motion z */
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-		dev_addr,
-		BMI160_USER_INTR_ENABLE_2_NOMOTION_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_2_NOMOTION_Z_ENABLE,
-			v_intr_enable_2_u8);
-			com_rslt +=
-			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-			dev_addr,
-			BMI160_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		}
-		break;
-	default:
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-		break;
-	}
-	/*Accel and Gyro power mode check*/
-	if (bmi160_power_mode_status_u8_g != BMI160_NORMAL_MODE)
-		/*interface idle time delay */
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-}
-return com_rslt;
-}
- /*!
- *	@brief This API is used to read
- *	interrupt enable step detector interrupt from
- *	the register bit 0x52 bit 3
- *
- *
- *
- *
- *	@param v_step_intr_u8 : The value of step detector interrupt enable
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_step_detector_enable(
-u8 *v_step_intr_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read the step detector interrupt*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr,
-			BMI160_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_step_intr_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE);
-		}
-	return com_rslt;
-}
- /*!
- *	@brief This API is used to set
- *	interrupt enable step detector interrupt from
- *	the register bit 0x52 bit 3
- *
- *
- *
- *
- *	@param v_step_intr_u8 : The value of step detector interrupt enable
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_step_detector_enable(
-u8 v_step_intr_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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_ENABLE_2_STEP_DETECTOR_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_2_STEP_DETECTOR_ENABLE,
-			v_step_intr_u8);
-			com_rslt +=
-			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-			dev_addr,
-			BMI160_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-			/*Accel and Gyro power mode check*/
-			if (bmi160_power_mode_status_u8_g !=
-			BMI160_NORMAL_MODE)
-				/*interface idle time delay */
-				p_bmi160->delay_msec(
-				BMI160_GEN_READ_WRITE_DELAY);
-		}
-	}
-	return com_rslt;
-}
-/*!
- *	@brief  This API reads trigger condition of interrupt1
- *	and interrupt2 pin from the register 0x53
- *	@brief interrupt1 - bit 0
- *	@brief interrupt2 - bit 4
- *
- *  @param v_channel_u8: The value of edge trigger selection
- *   v_channel_u8  |   Edge trigger
- *  ---------------|---------------
- *       0         | BMI160_INTR1_EDGE_CTRL
- *       1         | BMI160_INTR2_EDGE_CTRL
- *
- *	@param v_intr_edge_ctrl_u8 : The value of edge trigger enable
- *	value    | interrupt enable
- * ----------|-------------------
- *  0x01     |  BMI160_EDGE
- *  0x00     |  BMI160_LEVEL
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_edge_ctrl(
-u8 v_channel_u8, u8 *v_intr_edge_ctrl_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		switch (v_channel_u8) {
-		case BMI160_INTR1_EDGE_CTRL:
-			/* read the edge trigger interrupt1*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR1_EDGE_CTRL__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_edge_ctrl_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR1_EDGE_CTRL);
-			break;
-		case BMI160_INTR2_EDGE_CTRL:
-			/* read the edge trigger interrupt2*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR2_EDGE_CTRL__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_edge_ctrl_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR2_EDGE_CTRL);
-			break;
-		default:
-			com_rslt = E_BMI160_OUT_OF_RANGE;
-			break;
-		}
-	}
-	return com_rslt;
-}
-/*!
- *	@brief  This API configures trigger condition of interrupt1
- *	and interrupt2 pin from the register 0x53
- *	@brief interrupt1 - bit 0
- *	@brief interrupt2 - bit 4
- *
- *  @param v_channel_u8: The value of edge trigger selection
- *   v_channel_u8  |   Edge trigger
- *  ---------------|---------------
- *       0         | BMI160_INTR1_EDGE_CTRL
- *       1         | BMI160_INTR2_EDGE_CTRL
- *
- *	@param v_intr_edge_ctrl_u8 : The value of edge trigger enable
- *	value    | interrupt enable
- * ----------|-------------------
- *  0x01     |  BMI160_EDGE
- *  0x00     |  BMI160_LEVEL
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_edge_ctrl(
-u8 v_channel_u8, u8 v_intr_edge_ctrl_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		switch (v_channel_u8) {
-		case BMI160_INTR1_EDGE_CTRL:
-			/* write the edge trigger interrupt1*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR1_EDGE_CTRL__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_INTR1_EDGE_CTRL,
-				v_intr_edge_ctrl_u8);
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-				dev_addr, BMI160_USER_INTR1_EDGE_CTRL__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			}
-			break;
-		case BMI160_INTR2_EDGE_CTRL:
-			/* write the edge trigger interrupt2*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR2_EDGE_CTRL__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_INTR2_EDGE_CTRL,
-				v_intr_edge_ctrl_u8);
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-				dev_addr, BMI160_USER_INTR2_EDGE_CTRL__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			}
-			break;
-		default:
-			com_rslt = E_BMI160_OUT_OF_RANGE;
-			break;
-		}
-		/*Accel and Gyro power mode check*/
-		if (bmi160_power_mode_status_u8_g != BMI160_NORMAL_MODE)
-			/*interface idle time delay */
-			p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	}
-	return com_rslt;
-}
-/*!
- *	@brief  This API is used to get the configure level condition of
- *	interrupt1 and interrupt2 pin from the register 0x53
- *	@brief interrupt1 - bit 1
- *	@brief interrupt2 - bit 5
- *
- *  @param v_channel_u8: The value of level condition selection
- *   v_channel_u8  |   level selection
- *  ---------------|---------------
- *       0         | BMI160_INTR1_LEVEL
- *       1         | BMI160_INTR2_LEVEL
- *
- *	@param v_intr_level_u8 : The value of level of interrupt enable
- *	value    | Behaviour
- * ----------|-------------------
- *  0x01     |  BMI160_LEVEL_HIGH
- *  0x00     |  BMI160_LEVEL_LOW
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_level(
-u8 v_channel_u8, u8 *v_intr_level_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		switch (v_channel_u8) {
-		case BMI160_INTR1_LEVEL:
-			/* read the interrupt1 level*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR1_LEVEL__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_level_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR1_LEVEL);
-			break;
-		case BMI160_INTR2_LEVEL:
-			/* read the interrupt2 level*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR2_LEVEL__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_level_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR2_LEVEL);
-			break;
-		default:
-			com_rslt = E_BMI160_OUT_OF_RANGE;
-			break;
-		}
-	}
-	return com_rslt;
-}
-/*!
- *	@brief  This API is used to set the configure level condition of
- *	interrupt1 and interrupt2 pin from the register 0x53
- *	@brief interrupt1 - bit 1
- *	@brief interrupt2 - bit 5
- *
- *  @param v_channel_u8: The value of level condition selection
- *   v_channel_u8  |   level selection
- *  ---------------|---------------
- *       0         | BMI160_INTR1_LEVEL
- *       1         | BMI160_INTR2_LEVEL
- *
- *	@param v_intr_level_u8 : The value of level of interrupt enable
- *	value    | Behaviour
- * ----------|-------------------
- *  0x01     |  BMI160_LEVEL_HIGH
- *  0x00     |  BMI160_LEVEL_LOW
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_level(
-u8 v_channel_u8, u8 v_intr_level_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		switch (v_channel_u8) {
-		case BMI160_INTR1_LEVEL:
-			/* write the interrupt1 level*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR1_LEVEL__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_INTR1_LEVEL, v_intr_level_u8);
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-				dev_addr, BMI160_USER_INTR1_LEVEL__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			}
-			break;
-		case BMI160_INTR2_LEVEL:
-			/* write the interrupt2 level*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR2_LEVEL__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_INTR2_LEVEL, v_intr_level_u8);
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-				dev_addr, BMI160_USER_INTR2_LEVEL__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			}
-			break;
-		default:
-			com_rslt = E_BMI160_OUT_OF_RANGE;
-			break;
-		}
-		/*Accel and Gyro power mode check*/
-		if (bmi160_power_mode_status_u8_g != BMI160_NORMAL_MODE)
-			/*interface idle time delay */
-			p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	}
-	return com_rslt;
-}
-/*!
- *	@brief  This API is used to get configured output enable of interrupt1
- *	and interrupt2 from the register 0x53
- *	@brief interrupt1 - bit 2
- *	@brief interrupt2 - bit 6
- *
- *
- *  @param v_channel_u8: The value of output type enable selection
- *   v_channel_u8  |   level selection
- *  ---------------|---------------
- *       0         | BMI160_INTR1_OUTPUT_TYPE
- *       1         | BMI160_INTR2_OUTPUT_TYPE
- *
- *	@param v_intr_output_type_u8 :
- *	The value of output type of interrupt enable
- *	value    | Behaviour
- * ----------|-------------------
- *  0x01     |  BMI160_OPEN_DRAIN
- *  0x00     |  BMI160_PUSH_PULL
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_output_type(
-u8 v_channel_u8, u8 *v_intr_output_type_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		switch (v_channel_u8) {
-		case BMI160_INTR1_OUTPUT_TYPE:
-			/* read the output type of interrupt1*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR1_OUTPUT_TYPE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_output_type_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR1_OUTPUT_TYPE);
-			break;
-		case BMI160_INTR2_OUTPUT_TYPE:
-			/* read the output type of interrupt2*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR2_OUTPUT_TYPE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_output_type_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR2_OUTPUT_TYPE);
-			break;
-		default:
-			com_rslt = E_BMI160_OUT_OF_RANGE;
-			break;
-		}
-	}
-	return com_rslt;
-}
-/*!
- *	@brief  This API is used to set output enable of interrupt1
- *	and interrupt2 from the register 0x53
- *	@brief interrupt1 - bit 2
- *	@brief interrupt2 - bit 6
- *
- *
- *  @param v_channel_u8: The value of output type enable selection
- *   v_channel_u8  |   level selection
- *  ---------------|---------------
- *       0         | BMI160_INTR1_OUTPUT_TYPE
- *       1         | BMI160_INTR2_OUTPUT_TYPE
- *
- *	@param v_intr_output_type_u8 :
- *	The value of output type of interrupt enable
- *	value    | Behaviour
- * ----------|-------------------
- *  0x01     |  BMI160_OPEN_DRAIN
- *  0x00     |  BMI160_PUSH_PULL
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_output_type(
-u8 v_channel_u8, u8 v_intr_output_type_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		switch (v_channel_u8) {
-		case BMI160_INTR1_OUTPUT_TYPE:
-			/* write the output type of interrupt1*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR1_OUTPUT_TYPE__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_INTR1_OUTPUT_TYPE,
-				v_intr_output_type_u8);
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-				dev_addr, BMI160_USER_INTR1_OUTPUT_TYPE__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			}
-			break;
-		case BMI160_INTR2_OUTPUT_TYPE:
-			/* write the output type of interrupt2*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR2_OUTPUT_TYPE__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_INTR2_OUTPUT_TYPE,
-				v_intr_output_type_u8);
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-				dev_addr, BMI160_USER_INTR2_OUTPUT_TYPE__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			}
-			break;
-		default:
-			com_rslt = E_BMI160_OUT_OF_RANGE;
-			break;
-		}
-		/*Accel and Gyro power mode check*/
-		if (bmi160_power_mode_status_u8_g != BMI160_NORMAL_MODE)
-			/*interface idle time delay */
-			p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	}
-	return com_rslt;
-}
- /*!
- *	@brief This API is used to get the output enable for interrupt1
- *	and interrupt2 pin from the register 0x53
- *	@brief interrupt1 - bit 3
- *	@brief interrupt2 - bit 7
- *
- *  @param v_channel_u8: The value of output enable selection
- *   v_channel_u8  |   level selection
- *  ---------------|---------------
- *       0         | BMI160_INTR1_OUTPUT_ENABLE
- *       1         | BMI160_INTR2_OUTPUT_ENABLE
- *
- *	@param v_output_enable_u8 :
- *	The value of output enable of interrupt enable
- *	value    | Behaviour
- * ----------|-------------------
- *  0x01     |  INTERRUPT OUTPUT ENABLED
- *  0x00     |  INTERRUPT OUTPUT DISABLED
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_output_enable(
-u8 v_channel_u8, u8 *v_output_enable_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		switch (v_channel_u8) {
-		case BMI160_INTR1_OUTPUT_ENABLE:
-			/* read the output enable of interrupt1*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR1_OUTPUT_ENABLE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_output_enable_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR1_OUTPUT_ENABLE);
-			break;
-		case BMI160_INTR2_OUTPUT_ENABLE:
-			/* read the output enable of interrupt2*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR2_OUTPUT_EN__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_output_enable_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR2_OUTPUT_EN);
-			break;
-		default:
-			com_rslt = E_BMI160_OUT_OF_RANGE;
-			break;
-		}
-	}
-	return com_rslt;
-}
- /*!
- *	@brief This API is used to set the Output enable for interrupt1
- *	and interrupt2 pin from the register 0x53
- *	@brief interrupt1 - bit 3
- *	@brief interrupt2 - bit 7
- *
- *  @param v_channel_u8: The value of output enable selection
- *   v_channel_u8  |   level selection
- *  ---------------|---------------
- *       0         | BMI160_INTR1_OUTPUT_ENABLE
- *       1         | BMI160_INTR2_OUTPUT_ENABLE
- *
- *	@param v_output_enable_u8 :
- *	The value of output enable of interrupt enable
- *	value    | Behaviour
- * ----------|-------------------
- *  0x01     |  INTERRUPT OUTPUT ENABLED
- *  0x00     |  INTERRUPT OUTPUT DISABLED
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_output_enable(
-u8 v_channel_u8, u8 v_output_enable_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		switch (v_channel_u8) {
-		case BMI160_INTR1_OUTPUT_ENABLE:
-			/* write the output enable of interrupt1*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR1_OUTPUT_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_INTR1_OUTPUT_ENABLE,
-				v_output_enable_u8);
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-				dev_addr, BMI160_USER_INTR1_OUTPUT_ENABLE__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			}
-		break;
-		case BMI160_INTR2_OUTPUT_ENABLE:
-			/* write the output enable of interrupt2*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR2_OUTPUT_EN__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_INTR2_OUTPUT_EN,
-				v_output_enable_u8);
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-				dev_addr, BMI160_USER_INTR2_OUTPUT_EN__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			}
-		break;
-		default:
-			com_rslt = E_BMI160_OUT_OF_RANGE;
-		break;
-		}
-		/*Accel and Gyro power mode check*/
-		if (bmi160_power_mode_status_u8_g != BMI160_NORMAL_MODE)
-			/*interface idle time delay */
-			p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	}
-	return com_rslt;
-}
-/*!
-*	@brief This API is used to get the latch duration
-*	from the register 0x54 bit 0 to 3
-*	@brief This latch selection is not applicable for data ready,
-*	orientation and flat interrupts.
-*
-*
-*
-*  @param v_latch_intr_u8 : The value of latch duration
-*	Latch Duration                      |     value
-* --------------------------------------|------------------
-*    BMI160_LATCH_DUR_NONE              |      0x00
-*    BMI160_LATCH_DUR_312_5_MICRO_SEC   |      0x01
-*    BMI160_LATCH_DUR_625_MICRO_SEC     |      0x02
-*    BMI160_LATCH_DUR_1_25_MILLI_SEC    |      0x03
-*    BMI160_LATCH_DUR_2_5_MILLI_SEC     |      0x04
-*    BMI160_LATCH_DUR_5_MILLI_SEC       |      0x05
-*    BMI160_LATCH_DUR_10_MILLI_SEC      |      0x06
-*    BMI160_LATCH_DUR_20_MILLI_SEC      |      0x07
-*    BMI160_LATCH_DUR_40_MILLI_SEC      |      0x08
-*    BMI160_LATCH_DUR_80_MILLI_SEC      |      0x09
-*    BMI160_LATCH_DUR_160_MILLI_SEC     |      0x0A
-*    BMI160_LATCH_DUR_320_MILLI_SEC     |      0x0B
-*    BMI160_LATCH_DUR_640_MILLI_SEC     |      0x0C
-*    BMI160_LATCH_DUR_1_28_SEC          |      0x0D
-*    BMI160_LATCH_DUR_2_56_SEC          |      0x0E
-*    BMI160_LATCHED                     |      0x0F
-*
-*
-*
-*	@return results of bus communication function
-*	@retval 0 -> Success
-*	@retval -1 -> Error
-*
-*
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_latch_intr(
-u8 *v_latch_intr_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read the latch duration value */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_LATCH__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_latch_intr_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_LATCH);
-		}
-	return com_rslt;
-}
-/*!
-*	@brief This API is used to set the latch duration
-*	from the register 0x54 bit 0 to 3
-*	@brief This latch selection is not applicable for data ready,
-*	orientation and flat interrupts.
-*
-*
-*
-*  @param v_latch_intr_u8 : The value of latch duration
-*	Latch Duration                      |     value
-* --------------------------------------|------------------
-*    BMI160_LATCH_DUR_NONE              |      0x00
-*    BMI160_LATCH_DUR_312_5_MICRO_SEC   |      0x01
-*    BMI160_LATCH_DUR_625_MICRO_SEC     |      0x02
-*    BMI160_LATCH_DUR_1_25_MILLI_SEC    |      0x03
-*    BMI160_LATCH_DUR_2_5_MILLI_SEC     |      0x04
-*    BMI160_LATCH_DUR_5_MILLI_SEC       |      0x05
-*    BMI160_LATCH_DUR_10_MILLI_SEC      |      0x06
-*    BMI160_LATCH_DUR_20_MILLI_SEC      |      0x07
-*    BMI160_LATCH_DUR_40_MILLI_SEC      |      0x08
-*    BMI160_LATCH_DUR_80_MILLI_SEC      |      0x09
-*    BMI160_LATCH_DUR_160_MILLI_SEC     |      0x0A
-*    BMI160_LATCH_DUR_320_MILLI_SEC     |      0x0B
-*    BMI160_LATCH_DUR_640_MILLI_SEC     |      0x0C
-*    BMI160_LATCH_DUR_1_28_SEC          |      0x0D
-*    BMI160_LATCH_DUR_2_56_SEC          |      0x0E
-*    BMI160_LATCHED                     |      0x0F
-*
-*
-*
-*	@return results of bus communication function
-*	@retval 0 -> Success
-*	@retval -1 -> Error
-*
-*
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_latch_intr(u8 v_latch_intr_u8)
-{
-	u8 v_data_u8 = BMI160_INIT_VALUE;
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* check the p_bmi160 structure for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		if (v_latch_intr_u8 <= BMI160_MAX_LATCH_INTR) {
-			/* write the latch duration value */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_LATCH__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_LATCH, v_latch_intr_u8);
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-				dev_addr, BMI160_USER_INTR_LATCH__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-		}
-	}
-	return com_rslt;
-}
-/*!
- *	@brief API is used to get input enable for interrupt1
- *	and interrupt2 pin from the register 0x54
- *	@brief interrupt1 - bit 4
- *	@brief interrupt2 - bit 5
- *
- *  @param v_channel_u8: The value of input enable selection
- *   v_channel_u8  |   input selection
- *  ---------------|---------------
- *       0         | BMI160_INTR1_INPUT_ENABLE
- *       1         | BMI160_INTR2_INPUT_ENABLE
- *
- *	@param v_input_en_u8 :
- *	The value of input enable of interrupt enable
- *	value    | Behaviour
- * ----------|-------------------
- *  0x01     |  BMI160_INPUT_ENABLED
- *  0x00     |  BMI160_INPUT_DISABLED
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_input_enable(
-u8 v_channel_u8, u8 *v_input_en_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		switch (v_channel_u8) {
-		/* read input enable of interrupt1 and interrupt2*/
-		case BMI160_INTR1_INPUT_ENABLE:
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR1_INPUT_ENABLE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_input_en_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR1_INPUT_ENABLE);
-			break;
-		case BMI160_INTR2_INPUT_ENABLE:
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR2_INPUT_ENABLE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_input_en_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR2_INPUT_ENABLE);
-			break;
-		default:
-			com_rslt = E_BMI160_OUT_OF_RANGE;
-			break;
-		}
-	}
-	return com_rslt;
-}
-/*!
- *	@brief API is used to set input enable for interrupt1
- *	and interrupt2 pin from the register 0x54
- *	@brief interrupt1 - bit 4
- *	@brief interrupt2 - bit 5
- *
- *  @param v_channel_u8: The value of input enable selection
- *   v_channel_u8  |   input selection
- *  ---------------|---------------
- *       0         | BMI160_INTR1_INPUT_ENABLE
- *       1         | BMI160_INTR2_INPUT_ENABLE
- *
- *	@param v_input_en_u8 :
- *	The value of input enable of interrupt enable
- *	value    | Behaviour
- * ----------|-------------------
- *  0x01     |  BMI160_INPUT_ENABLED
- *  0x00     |  BMI160_INPUT_DISABLED
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_input_enable(
-u8 v_channel_u8, u8 v_input_en_u8)
-{
-/* variable used to 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 for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-	} else {
-	switch (v_channel_u8) {
-	/* write input enable of interrup1 and interrupt2*/
-	case BMI160_INTR1_INPUT_ENABLE:
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-		dev_addr, BMI160_USER_INTR1_INPUT_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_INTR1_INPUT_ENABLE, v_input_en_u8);
-			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR1_INPUT_ENABLE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		}
-	break;
-	case BMI160_INTR2_INPUT_ENABLE:
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-		dev_addr, BMI160_USER_INTR2_INPUT_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_INTR2_INPUT_ENABLE, v_input_en_u8);
-			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR2_INPUT_ENABLE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		}
-	break;
-	default:
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-	break;
-	}
-	/*Accel and Gyro power mode check */
-	if (bmi160_power_mode_status_u8_g != BMI160_NORMAL_MODE)
-		/*interface idle time delay */
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-}
-return com_rslt;
-}
- /*!
- *	@brief This API reads the Low g interrupt which is mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 0 in the register 0x55
- *	@brief interrupt2 bit 0 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of low_g selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_LOW_G
- *       1         | BMI160_INTR2_MAP_LOW_G
- *
- *	@param v_intr_low_g_u8 : The value of low_g enable
- *	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_low_g(
-u8 v_channel_u8, u8 *v_intr_low_g_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		switch (v_channel_u8) {
-		/* read the low_g interrupt */
-		case BMI160_INTR1_MAP_LOW_G:
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_LOW_G__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_low_g_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_MAP_0_INTR1_LOW_G);
-			break;
-		case BMI160_INTR2_MAP_LOW_G:
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_LOW_G__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_low_g_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_MAP_2_INTR2_LOW_G);
-			break;
-		default:
-			com_rslt = E_BMI160_OUT_OF_RANGE;
-			break;
-		}
-	}
-	return com_rslt;
-}
- /*!
- *	@brief This API sets the Low g interrupt to be mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 0 in the register 0x55
- *	@brief interrupt2 bit 0 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of low_g selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_LOW_G
- *       1         | BMI160_INTR2_MAP_LOW_G
- *
- *	@param v_intr_low_g_u8 : The value of low_g enable
- *	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_low_g(
-u8 v_channel_u8, u8 v_intr_low_g_u8)
-{
-/* variable used to 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_step_cnt_stat_u8 = BMI160_INIT_VALUE;
-u8 v_step_det_stat_u8 = BMI160_INIT_VALUE;
-
-/* check the p_bmi160 structure for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-	} else {
-	/* check the step detector interrupt enable status*/
-	com_rslt = bmi160_get_step_detector_enable(&v_step_det_stat_u8);
-	/* disable the step detector interrupt */
-	if (v_step_det_stat_u8 != BMI160_INIT_VALUE)
-		com_rslt += bmi160_set_step_detector_enable(BMI160_INIT_VALUE);
-	/* check the step counter interrupt enable status*/
-	com_rslt += bmi160_get_step_counter_enable(&v_step_cnt_stat_u8);
-	/* disable the step counter interrupt */
-	if (v_step_cnt_stat_u8 != BMI160_INIT_VALUE)
-			com_rslt += bmi160_set_step_counter_enable(
-			BMI160_INIT_VALUE);
-	switch (v_channel_u8) {
-	/* write the low_g interrupt*/
-	case BMI160_INTR1_MAP_LOW_G:
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-		dev_addr, BMI160_USER_INTR_MAP_0_INTR1_LOW_G__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_MAP_0_INTR1_LOW_G, v_intr_low_g_u8);
-			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_LOW_G__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		}
-		break;
-	case BMI160_INTR2_MAP_LOW_G:
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-		dev_addr, BMI160_USER_INTR_MAP_2_INTR2_LOW_G__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_MAP_2_INTR2_LOW_G, v_intr_low_g_u8);
-			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_LOW_G__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		}
-		break;
-	default:
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-		break;
-	}
-	/*Accel and Gyro power mode check */
-		if (bmi160_power_mode_status_u8_g != BMI160_NORMAL_MODE)
-			/*interface idle time delay */
-			p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-}
-return com_rslt;
-}
-/*!
- *	@brief This API reads the HIGH g interrupt which is mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 1 in the register 0x55
- *	@brief interrupt2 bit 1 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of high_g selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_HIGH_G
- *       1         | BMI160_INTR2_MAP_HIGH_G
- *
- *	@param v_intr_high_g_u8 : The value of high_g enable
- *	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_high_g(
-u8 v_channel_u8, u8 *v_intr_high_g_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		/* read the high_g interrupt*/
-		switch (v_channel_u8) {
-		case BMI160_INTR1_MAP_HIGH_G:
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_HIGH_G__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_high_g_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_MAP_0_INTR1_HIGH_G);
-		break;
-		case BMI160_INTR2_MAP_HIGH_G:
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_HIGH_G__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_high_g_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_MAP_2_INTR2_HIGH_G);
-		break;
-		default:
-			com_rslt = E_BMI160_OUT_OF_RANGE;
-			break;
-		}
-	}
-	return com_rslt;
-}
-/*!
- *	@brief This API writes the HIGH g interrupt to be mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 1 in the register 0x55
- *	@brief interrupt2 bit 1 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of high_g selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_HIGH_G
- *       1         | BMI160_INTR2_MAP_HIGH_G
- *
- *	@param v_intr_high_g_u8 : The value of high_g enable
- *	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_high_g(
-u8 v_channel_u8, u8 v_intr_high_g_u8)
-{
-/* variable used to 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 for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-	} else {
-	switch (v_channel_u8) {
-	/* write the high_g interrupt*/
-	case BMI160_INTR1_MAP_HIGH_G:
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-		dev_addr, BMI160_USER_INTR_MAP_0_INTR1_HIGH_G__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_MAP_0_INTR1_HIGH_G, v_intr_high_g_u8);
-			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_HIGH_G__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		}
-	break;
-	case BMI160_INTR2_MAP_HIGH_G:
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-		dev_addr, BMI160_USER_INTR_MAP_2_INTR2_HIGH_G__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_MAP_2_INTR2_HIGH_G, v_intr_high_g_u8);
-			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_HIGH_G__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		}
-	break;
-	default:
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-	break;
-	}
-	/*Accel and Gyro power mode check */
-	if (bmi160_power_mode_status_u8_g != BMI160_NORMAL_MODE)
-		/*interface idle time delay */
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-}
-return com_rslt;
-}
-/*!
- *	@brief This API reads the Any motion interrupt which is mapped to
- *	interrupt1 and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 2 in the register 0x55
- *	@brief interrupt2 bit 2 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of any motion selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_ANY_MOTION
- *       1         | BMI160_INTR2_MAP_ANY_MOTION
- *
- *	@param v_intr_any_motion_u8 : The value of any motion enable
- *	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_any_motion(
-u8 v_channel_u8, u8 *v_intr_any_motion_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		switch (v_channel_u8) {
-		/* read the any motion interrupt */
-		case BMI160_INTR1_MAP_ANY_MOTION:
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_any_motion_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION);
-		break;
-		case BMI160_INTR2_MAP_ANY_MOTION:
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_any_motion_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION);
-		break;
-		default:
-			com_rslt = E_BMI160_OUT_OF_RANGE;
-		break;
-		}
-	}
-	return com_rslt;
-}
-/*!
- *	@brief This API writes the Any motion interrupt
- *	to be mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 2 in the register 0x55
- *	@brief interrupt2 bit 2 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of any motion selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_ANY_MOTION
- *       1         | BMI160_INTR2_MAP_ANY_MOTION
- *
- *	@param v_intr_any_motion_u8 : The value of any motion enable
- *	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_any_motion(
-u8 v_channel_u8, u8 v_intr_any_motion_u8)
-{
-/* variable used to return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-u8 sig_mot_stat = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-	} else {
-	/* read the status of significant motion interrupt */
-	com_rslt = bmi160_get_intr_significant_motion_select(&sig_mot_stat);
-	/* disable the significant motion interrupt */
-	if (sig_mot_stat != BMI160_INIT_VALUE)
-		com_rslt += bmi160_set_intr_significant_motion_select(
-		BMI160_INIT_VALUE);
-	switch (v_channel_u8) {
-	/* write the any motion interrupt */
-	case BMI160_INTR1_MAP_ANY_MOTION:
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-		dev_addr, BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__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_MAP_0_INTR1_ANY_MOTION,
-			v_intr_any_motion_u8);
-			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		}
-	break;
-	case BMI160_INTR2_MAP_ANY_MOTION:
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-		dev_addr, BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__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_MAP_2_INTR2_ANY_MOTION,
-			v_intr_any_motion_u8);
-			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		}
-	break;
-	default:
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-	break;
-	}
-	/*Accel and Gyro power mode check */
-	if (bmi160_power_mode_status_u8_g != BMI160_NORMAL_MODE)
-		/*interface idle time delay */
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-}
-return com_rslt;
-}
-/*!
- *	@brief This API reads the No motion interrupt
- *	which is  mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 3 in the register 0x55
- *	@brief interrupt2 bit 3 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of no motion selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_NOMO
- *       1         | BMI160_INTR2_MAP_NOMO
- *
- *	@param v_intr_nomotion_u8 : The value of no motion enable
- *	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_nomotion(
-u8 v_channel_u8, u8 *v_intr_nomotion_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		switch (v_channel_u8) {
-		/* read the no motion interrupt*/
-		case BMI160_INTR1_MAP_NOMO:
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_NOMOTION__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_nomotion_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_MAP_0_INTR1_NOMOTION);
-			break;
-		case BMI160_INTR2_MAP_NOMO:
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_NOMOTION__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_nomotion_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_MAP_2_INTR2_NOMOTION);
-			break;
-		default:
-			com_rslt = E_BMI160_OUT_OF_RANGE;
-			break;
-		}
-	}
-	return com_rslt;
-}
-/*!
- *	@brief This API configures the No motion interrupt
- *	to be mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 3 in the register 0x55
- *	@brief interrupt2 bit 3 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of no motion selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_NOMO
- *       1         | BMI160_INTR2_MAP_NOMO
- *
- *	@param v_intr_nomotion_u8 : The value of no motion enable
- *	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_nomotion(
-u8 v_channel_u8, u8 v_intr_nomotion_u8)
-{
-/* variable used to 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 for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-	} else {
-	switch (v_channel_u8) {
-	/* write the no motion interrupt*/
-	case BMI160_INTR1_MAP_NOMO:
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-		dev_addr, BMI160_USER_INTR_MAP_0_INTR1_NOMOTION__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_MAP_0_INTR1_NOMOTION,
-			v_intr_nomotion_u8);
-			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_NOMOTION__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		}
-		break;
-	case BMI160_INTR2_MAP_NOMO:
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-		dev_addr, BMI160_USER_INTR_MAP_2_INTR2_NOMOTION__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_MAP_2_INTR2_NOMOTION,
-			v_intr_nomotion_u8);
-			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_NOMOTION__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		}
-		break;
-	default:
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-		break;
-	}
-	/*Accel and Gyro power mode check */
-	if (bmi160_power_mode_status_u8_g != BMI160_NORMAL_MODE)
-		/*interface idle time delay */
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-}
-return com_rslt;
-}
-/*!
- *	@brief This API reads the Double Tap interrupt
- *	which is mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 4 in the register 0x55
- *	@brief interrupt2 bit 4 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of double tap interrupt selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_DOUBLE_TAP
- *       1         | BMI160_INTR2_MAP_DOUBLE_TAP
- *
- *	@param v_intr_double_tap_u8 : The value of double tap enable
- *	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_double_tap(
-u8 v_channel_u8, u8 *v_intr_double_tap_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		switch (v_channel_u8) {
-		case BMI160_INTR1_MAP_DOUBLE_TAP:
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_DOUBLE_TAP__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_double_tap_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_MAP_0_INTR1_DOUBLE_TAP);
-			break;
-		case BMI160_INTR2_MAP_DOUBLE_TAP:
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_DOUBLE_TAP__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_double_tap_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_MAP_2_INTR2_DOUBLE_TAP);
-			break;
-		default:
-			com_rslt = E_BMI160_OUT_OF_RANGE;
-			break;
-		}
-	}
-	return com_rslt;
-}
-/*!
- *	@brief This API configures the Double Tap interrupt
- *	to be mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 4 in the register 0x55
- *	@brief interrupt2 bit 4 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of double tap interrupt selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_DOUBLE_TAP
- *       1         | BMI160_INTR2_MAP_DOUBLE_TAP
- *
- *	@param v_intr_double_tap_u8 : The value of double tap enable
- *	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_double_tap(
-u8 v_channel_u8, u8 v_intr_double_tap_u8)
-{
-/* variable used to 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 for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-	} else {
-	switch (v_channel_u8) {
-	/* set the double tap interrupt */
-	case BMI160_INTR1_MAP_DOUBLE_TAP:
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-		dev_addr, BMI160_USER_INTR_MAP_0_INTR1_DOUBLE_TAP__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_MAP_0_INTR1_DOUBLE_TAP,
-			v_intr_double_tap_u8);
-			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_DOUBLE_TAP__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		}
-		break;
-	case BMI160_INTR2_MAP_DOUBLE_TAP:
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-		dev_addr, BMI160_USER_INTR_MAP_2_INTR2_DOUBLE_TAP__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_MAP_2_INTR2_DOUBLE_TAP,
-			v_intr_double_tap_u8);
-			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_DOUBLE_TAP__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		}
-		break;
-	default:
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-		break;
-	}
-	/*Accel and Gyro power mode check */
-	if (bmi160_power_mode_status_u8_g != BMI160_NORMAL_MODE)
-		/*interface idle time delay */
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-}
-return com_rslt;
-}
-/*!
- *	@brief This API reads the Single Tap interrupt
- *	which is mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 5 in the register 0x55
- *	@brief interrupt2 bit 5 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of single tap interrupt selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_SINGLE_TAP
- *       1         | BMI160_INTR2_MAP_SINGLE_TAP
- *
- *	@param v_intr_single_tap_u8 : The value of single tap  enable
- *	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_single_tap(
-u8 v_channel_u8, u8 *v_intr_single_tap_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		switch (v_channel_u8) {
-		/* reads the single tap interrupt*/
-		case BMI160_INTR1_MAP_SINGLE_TAP:
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_SINGLE_TAP__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_single_tap_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_MAP_0_INTR1_SINGLE_TAP);
-			break;
-		case BMI160_INTR2_MAP_SINGLE_TAP:
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_SINGLE_TAP__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_single_tap_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_MAP_2_INTR2_SINGLE_TAP);
-			break;
-		default:
-			com_rslt = E_BMI160_OUT_OF_RANGE;
-			break;
-		}
-	}
-	return com_rslt;
-}
-/*!
- *	@brief This API configures the Single Tap interrupt
- *	to be mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 5 in the register 0x55
- *	@brief interrupt2 bit 5 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of single tap interrupt selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_SINGLE_TAP
- *       1         | BMI160_INTR2_MAP_SINGLE_TAP
- *
- *	@param v_intr_single_tap_u8 : The value of single tap  enable
- *	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_single_tap(
-u8 v_channel_u8, u8 v_intr_single_tap_u8)
-{
-/* variable used to 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 for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-	} else {
-	switch (v_channel_u8) {
-	/* write the single tap interrupt */
-	case BMI160_INTR1_MAP_SINGLE_TAP:
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-		dev_addr, BMI160_USER_INTR_MAP_0_INTR1_SINGLE_TAP__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_MAP_0_INTR1_SINGLE_TAP,
-			v_intr_single_tap_u8);
-			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_SINGLE_TAP__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		}
-		break;
-	case BMI160_INTR2_MAP_SINGLE_TAP:
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-		dev_addr, BMI160_USER_INTR_MAP_2_INTR2_SINGLE_TAP__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_MAP_2_INTR2_SINGLE_TAP,
-			v_intr_single_tap_u8);
-			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_SINGLE_TAP__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		}
-		break;
-	default:
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-		break;
-	}
-	/*Accel and Gyro power mode check */
-	if (bmi160_power_mode_status_u8_g != BMI160_NORMAL_MODE)
-		/*interface idle time delay */
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-}
-return com_rslt;
-}
-/*!
- *	@brief This API reads the Orient interrupt which is mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 6 in the register 0x55
- *	@brief interrupt2 bit 6 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of orient interrupt selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_ORIENT
- *       1         | BMI160_INTR2_MAP_ORIENT
- *
- *	@param v_intr_orient_u8 : The value of orient enable
- *	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_orient(
-u8 v_channel_u8, u8 *v_intr_orient_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		switch (v_channel_u8) {
-		/* read the orientation interrupt*/
-		case BMI160_INTR1_MAP_ORIENT:
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_ORIENT__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_orient_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_MAP_0_INTR1_ORIENT);
-			break;
-		case BMI160_INTR2_MAP_ORIENT:
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_ORIENT__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_orient_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_MAP_2_INTR2_ORIENT);
-			break;
-		default:
-			com_rslt = E_BMI160_OUT_OF_RANGE;
-			break;
-		}
-	}
-	return com_rslt;
-}
-/*!
- *	@brief This API configures the Orient interrupt
- *	to be mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 6 in the register 0x55
- *	@brief interrupt2 bit 6 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of orient interrupt selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_ORIENT
- *       1         | BMI160_INTR2_MAP_ORIENT
- *
- *	@param v_intr_orient_u8 : The value of orient enable
- *	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_orient(
-u8 v_channel_u8, u8 v_intr_orient_u8)
-{
-/* variable used to 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 for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-	} else {
-	switch (v_channel_u8) {
-	/* write the orientation interrupt*/
-	case BMI160_INTR1_MAP_ORIENT:
-		com_rslt =
-		p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-		dev_addr, BMI160_USER_INTR_MAP_0_INTR1_ORIENT__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_MAP_0_INTR1_ORIENT, v_intr_orient_u8);
-			com_rslt +=
-			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_ORIENT__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		}
-		break;
-	case BMI160_INTR2_MAP_ORIENT:
-		com_rslt =
-		p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-		dev_addr, BMI160_USER_INTR_MAP_2_INTR2_ORIENT__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_MAP_2_INTR2_ORIENT, v_intr_orient_u8);
-			com_rslt +=
-			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_ORIENT__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		}
-		break;
-	default:
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-		break;
-	}
-	/*Accel and Gyro power mode check */
-	if (bmi160_power_mode_status_u8_g != BMI160_NORMAL_MODE)
-		/*interface idle time delay */
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-}
-return com_rslt;
-}
- /*!
- *	@brief This API reads the Flat interrupt which is
- *	mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 7 in the register 0x55
- *	@brief interrupt2 bit 7 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of flat interrupt selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_FLAT
- *       1         | BMI160_INTR2_MAP_FLAT
- *
- *	@param v_intr_flat_u8 : The value of flat enable
- *	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_flat(
-u8 v_channel_u8, u8 *v_intr_flat_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		switch (v_channel_u8) {
-		/* read the flat interrupt*/
-		case BMI160_INTR1_MAP_FLAT:
-			com_rslt =
-			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_FLAT__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_flat_u8 =
-			BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_MAP_0_INTR1_FLAT);
-			break;
-		case BMI160_INTR2_MAP_FLAT:
-			com_rslt =
-			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_FLAT__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_flat_u8 =
-			BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_MAP_2_INTR2_FLAT);
-			break;
-		default:
-			com_rslt = E_BMI160_OUT_OF_RANGE;
-			break;
-		}
-	}
-	return com_rslt;
-}
- /*!
- *	@brief This API configures the Flat interrupt to be
- *	mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 7 in the register 0x55
- *	@brief interrupt2 bit 7 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of flat interrupt selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_FLAT
- *       1         | BMI160_INTR2_MAP_FLAT
- *
- *	@param v_intr_flat_u8 : The value of flat enable
- *	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_flat(
-u8 v_channel_u8, u8 v_intr_flat_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		switch (v_channel_u8) {
-		/* write the flat interrupt */
-		case BMI160_INTR1_MAP_FLAT:
-			com_rslt =
-			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_0_INTR1_FLAT__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_MAP_0_INTR1_FLAT,
-				v_intr_flat_u8);
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-				dev_addr,
-				BMI160_USER_INTR_MAP_0_INTR1_FLAT__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			}
-			break;
-		case BMI160_INTR2_MAP_FLAT:
-			com_rslt =
-			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_2_INTR2_FLAT__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_MAP_2_INTR2_FLAT,
-				v_intr_flat_u8);
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-				dev_addr,
-				BMI160_USER_INTR_MAP_2_INTR2_FLAT__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			}
-			break;
-		default:
-			com_rslt = E_BMI160_OUT_OF_RANGE;
-			break;
-		}
-		/*Accel and Gyro power mode check*/
-		if (bmi160_power_mode_status_u8_g != BMI160_NORMAL_MODE)
-			/*interface idle time delay */
-			p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	}
-	return com_rslt;
-}
-/*!
- *	@brief This API reads the PMU trigger interrupt which is mapped to
- *	interrupt1 and interrupt2 from the register 0x56 bit 0 and 4
- *	@brief interrupt1 bit 0 in the register 0x56
- *	@brief interrupt2 bit 4 in the register 0x56
- *
- *
- *	@param v_channel_u8: The value of pmu trigger selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_PMUTRIG
- *       1         | BMI160_INTR2_MAP_PMUTRIG
- *
- *	@param v_intr_pmu_trig_u8 : The value of pmu trigger enable
- *	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_pmu_trig(
-u8 v_channel_u8, u8 *v_intr_pmu_trig_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		switch (v_channel_u8) {
-		/* read the pmu trigger interrupt*/
-		case BMI160_INTR1_MAP_PMUTRIG:
-			com_rslt =
-			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_1_INTR1_PMU_TRIG__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_pmu_trig_u8 =
-			BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_MAP_1_INTR1_PMU_TRIG);
-			break;
-		case BMI160_INTR2_MAP_PMUTRIG:
-			com_rslt =
-			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_1_INTR2_PMU_TRIG__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_pmu_trig_u8 =
-			BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_MAP_1_INTR2_PMU_TRIG);
-			break;
-		default:
-			com_rslt = E_BMI160_OUT_OF_RANGE;
-			break;
-		}
-	}
-	return com_rslt;
-}
-/*!
- *	@brief This API configures the PMU trigger interrupt to be mapped to
- *	interrupt1 and interrupt2 from the register 0x56 bit 0 and 4
- *	@brief interrupt1 bit 0 in the register 0x56
- *	@brief interrupt2 bit 4 in the register 0x56
- *
- *
- *	@param v_channel_u8: The value of pmu trigger selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_PMUTRIG
- *       1         | BMI160_INTR2_MAP_PMUTRIG
- *
- *	@param v_intr_pmu_trig_u8 : The value of pmu trigger enable
- *	value    | trigger 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_pmu_trig(
-u8 v_channel_u8, u8 v_intr_pmu_trig_u8)
-{
-/* variable used to 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 for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-	} else {
-	switch (v_channel_u8) {
-	/* write the pmu trigger interrupt */
-	case BMI160_INTR1_MAP_PMUTRIG:
-		com_rslt =
-		p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-		dev_addr, BMI160_USER_INTR_MAP_1_INTR1_PMU_TRIG__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_MAP_1_INTR1_PMU_TRIG,
-			v_intr_pmu_trig_u8);
-			com_rslt +=
-			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_1_INTR1_PMU_TRIG__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		}
-	break;
-	case BMI160_INTR2_MAP_PMUTRIG:
-		com_rslt =
-		p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-		dev_addr, BMI160_USER_INTR_MAP_1_INTR2_PMU_TRIG__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_MAP_1_INTR2_PMU_TRIG,
-			v_intr_pmu_trig_u8);
-			com_rslt +=
-			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_1_INTR2_PMU_TRIG__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		}
-	break;
-	default:
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-	break;
-	}
-	/*Accel and Gyro power mode check */
-	if (bmi160_power_mode_status_u8_g != BMI160_NORMAL_MODE)
-		/*interface idle time delay */
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-}
-return com_rslt;
-}
-#ifdef FIFO_ENABLE
-/*!
- *	@brief This API reads the FIFO Full interrupt which is mapped to
- *	interrupt1 and interrupt2 from the register 0x56 bit 5 and 1
- *	@brief interrupt1 bit 5 in the register 0x56
- *	@brief interrupt2 bit 1 in the register 0x56
- *
- *
- *	@param v_channel_u8: The value of FIFO full interrupt selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_FIFO_FULL
- *       1         | BMI160_INTR2_MAP_FIFO_FULL
- *
- *	@param v_intr_fifo_full_u8 : The value of FIFO full interrupt enable
- *	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_fifo_full(
-u8 v_channel_u8, u8 *v_intr_fifo_full_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		switch (v_channel_u8) {
-		/* read the FIFO full interrupt */
-		case BMI160_INTR1_MAP_FIFO_FULL:
-			com_rslt =
-			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_1_INTR1_FIFO_FULL__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_fifo_full_u8 =
-			BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_MAP_1_INTR1_FIFO_FULL);
-		break;
-		case BMI160_INTR2_MAP_FIFO_FULL:
-			com_rslt =
-			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_1_INTR2_FIFO_FULL__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_fifo_full_u8 =
-			BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_MAP_1_INTR2_FIFO_FULL);
-		break;
-		default:
-			com_rslt = E_BMI160_OUT_OF_RANGE;
-		break;
-		}
-	}
-	return com_rslt;
-}
-/*!
- *	@brief This API configures the  FIFO Full interrupt to be mapped to
- *	interrupt1 and interrupt2 from the register 0x56 bit 5 and 1
- *	@brief interrupt1 bit 5 in the register 0x56
- *	@brief interrupt2 bit 1 in the register 0x56
- *
- *
- *	@param v_channel_u8: The value of FIFO full interrupt selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_FIFO_FULL
- *       1         | BMI160_INTR2_MAP_FIFO_FULL
- *
- *	@param v_intr_fifo_full_u8 : The value of FIFO full interrupt enable
- *	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_fifo_full(
-u8 v_channel_u8, u8 v_intr_fifo_full_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		switch (v_channel_u8) {
-		/* write the FIFO full interrupt */
-		case BMI160_INTR1_MAP_FIFO_FULL:
-			com_rslt =
-			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_1_INTR1_FIFO_FULL__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_MAP_1_INTR1_FIFO_FULL,
-				v_intr_fifo_full_u8);
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-				dev_addr,
-				BMI160_USER_INTR_MAP_1_INTR1_FIFO_FULL__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			}
-		break;
-		case BMI160_INTR2_MAP_FIFO_FULL:
-			com_rslt =
-			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_1_INTR2_FIFO_FULL__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_MAP_1_INTR2_FIFO_FULL,
-				v_intr_fifo_full_u8);
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-				dev_addr,
-				BMI160_USER_INTR_MAP_1_INTR2_FIFO_FULL__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 reads FIFO Watermark interrupt which is mapped to
- *	interrupt1 and interrupt2 from the register 0x56 bit 6 and 2
- *	@brief interrupt1 bit 6 in the register 0x56
- *	@brief interrupt2 bit 2 in the register 0x56
- *
- *
- *	@param v_channel_u8: The value of FIFO Watermark interrupt selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_FIFO_WM
- *       1         | BMI160_INTR2_MAP_FIFO_WM
- *
- *	@param v_intr_fifo_wm_u8 : The value of FIFO Watermark interrupt enable
- *	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_fifo_wm(
-u8 v_channel_u8, u8 *v_intr_fifo_wm_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		switch (v_channel_u8) {
-		/* read the FIFO water mark interrupt */
-		case BMI160_INTR1_MAP_FIFO_WM:
-			com_rslt =
-			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_1_INTR1_FIFO_WM__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_fifo_wm_u8 =
-			BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_MAP_1_INTR1_FIFO_WM);
-			break;
-		case BMI160_INTR2_MAP_FIFO_WM:
-			com_rslt =
-			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_1_INTR2_FIFO_WM__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_fifo_wm_u8 =
-			BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_MAP_1_INTR2_FIFO_WM);
-			break;
-		default:
-			com_rslt = E_BMI160_OUT_OF_RANGE;
-			break;
-		}
-	}
-	return com_rslt;
-}
-/*!
- *	@brief This API configures FIFO Watermark interrupt to be mapped to
- *	interrupt1 and interrupt2 from the register 0x56 bit 6 and 2
- *	@brief interrupt1 bit 6 in the register 0x56
- *	@brief interrupt2 bit 2 in the register 0x56
- *
- *
- *	@param v_channel_u8: The value of FIFO Watermark interrupt selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_FIFO_WM
- *       1         | BMI160_INTR2_MAP_FIFO_WM
- *
- *	@param v_intr_fifo_wm_u8 : The value of FIFO Watermark interrupt enable
- *	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_fifo_wm(
-u8 v_channel_u8, u8 v_intr_fifo_wm_u8)
-{
-/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		switch (v_channel_u8) {
-		/* write the FIFO water mark interrupt */
-		case BMI160_INTR1_MAP_FIFO_WM:
-			com_rslt =
-			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_1_INTR1_FIFO_WM__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_MAP_1_INTR1_FIFO_WM,
-				v_intr_fifo_wm_u8);
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-				dev_addr,
-				BMI160_USER_INTR_MAP_1_INTR1_FIFO_WM__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			}
-			break;
-		case BMI160_INTR2_MAP_FIFO_WM:
-			com_rslt =
-			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_1_INTR2_FIFO_WM__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_MAP_1_INTR2_FIFO_WM,
-				v_intr_fifo_wm_u8);
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-				dev_addr,
-				BMI160_USER_INTR_MAP_1_INTR2_FIFO_WM__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			}
-			break;
-		default:
-			com_rslt = E_BMI160_OUT_OF_RANGE;
-			break;
-		}
-	}
-	return com_rslt;
-}
-#endif
-/*!
- *	@brief This API reads Data Ready interrupt which is mapped to interrupt1
- *	and interrupt2 from the register 0x56
- *	@brief interrupt1 bit 7 in the register 0x56
- *	@brief interrupt2 bit 3 in the register 0x56
- *
- *
- *	@param v_channel_u8: The value of data ready interrupt selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_DATA_RDY
- *       1         | BMI160_INTR2_MAP_DATA_RDY
- *
- *	@param v_intr_data_rdy_u8 : The value of data ready interrupt enable
- *	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_data_rdy(
-u8 v_channel_u8, u8 *v_intr_data_rdy_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		switch (v_channel_u8) {
-		/*Read Data Ready interrupt*/
-		case BMI160_INTR1_MAP_DATA_RDY:
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_1_INTR1_DATA_RDY__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_data_rdy_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_MAP_1_INTR1_DATA_RDY);
-			break;
-		case BMI160_INTR2_MAP_DATA_RDY:
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_1_INTR2_DATA_RDY__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_data_rdy_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_MAP_1_INTR2_DATA_RDY);
-			break;
-		default:
-			com_rslt = E_BMI160_OUT_OF_RANGE;
-			break;
-		}
-	}
-	return com_rslt;
-}
-/*!
- *	@brief This API configures Data Ready interrupt to be mapped to
- *	interrupt1 and interrupt2 from the register 0x56
- *	@brief interrupt1 bit 7 in the register 0x56
- *	@brief interrupt2 bit 3 in the register 0x56
- *
- *
- *	@param v_channel_u8: The value of data ready interrupt selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_DATA_RDY
- *       1         | BMI160_INTR2_MAP_DATA_RDY
- *
- *	@param v_intr_data_rdy_u8 : The value of data ready interrupt enable
- *	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_data_rdy(
-u8 v_channel_u8, u8 v_intr_data_rdy_u8)
-{
-/* variable used to 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 for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-	} else {
-	switch (v_channel_u8) {
-	/*Write Data Ready interrupt*/
-	case BMI160_INTR1_MAP_DATA_RDY:
-		com_rslt =
-		p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-		dev_addr, BMI160_USER_INTR_MAP_1_INTR1_DATA_RDY__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_MAP_1_INTR1_DATA_RDY,
-			v_intr_data_rdy_u8);
-			com_rslt +=
-			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_1_INTR1_DATA_RDY__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		}
-	break;
-	case BMI160_INTR2_MAP_DATA_RDY:
-		com_rslt =
-		p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
-		dev_addr, BMI160_USER_INTR_MAP_1_INTR2_DATA_RDY__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_MAP_1_INTR2_DATA_RDY,
-			v_intr_data_rdy_u8);
-			com_rslt +=
-			p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
-			dev_addr, BMI160_USER_INTR_MAP_1_INTR2_DATA_RDY__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		}
-	break;
-	default:
-	com_rslt = E_BMI160_OUT_OF_RANGE;
-	break;
-	}
-	/*Accel and Gyro power mode check */
-	if (bmi160_power_mode_status_u8_g != BMI160_NORMAL_MODE)
-		/*interface idle time delay */
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-}
-return com_rslt;
-}
- /*!
- *	@brief This API reads data source for the interrupt
- *	engine for the single and double tap interrupts from the register
- *	0x58 bit 3
- *
- *
- *  @param v_tap_source_u8 : The value of the tap source
- *	value    | Description
- * ----------|-------------------
- *  0x01     |  UNFILTER_DATA
- *  0x00     |  FILTER_DATA
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_source(u8 *v_tap_source_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read the tap source interrupt */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_INTR_DATA_0_INTR_TAP_SOURCE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_tap_source_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_DATA_0_INTR_TAP_SOURCE);
-		}
-	return com_rslt;
-}
- /*!
- *	@brief This API writes data source for the interrupt
- *	engine for the single and double tap interrupts from the register
- *	0x58 bit 3
- *
- *
- *  @param v_tap_source_u8 : The value of the tap source
- *	value    | Description
- * ----------|-------------------
- *  0x01     |  UNFILTER_DATA
- *  0x00     |  FILTER_DATA
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_source(
-u8 v_tap_source_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		if (v_tap_source_u8 <= BMI160_MAX_VALUE_SOURCE_INTR) {
-			/* write the tap source interrupt */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_DATA_0_INTR_TAP_SOURCE__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_DATA_0_INTR_TAP_SOURCE,
-				v_tap_source_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
-				(p_bmi160->dev_addr,
-				BMI160_USER_INTR_DATA_0_INTR_TAP_SOURCE__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Check for the power mode of Accel and
-				gyro not in normal mode */
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-		}
-	}
-	return com_rslt;
-}
- /*!
- *	@brief This API Reads Data source for the
- *	interrupt engine for the low and high g interrupts
- *	from the register 0x58 bit 7
- *
- *  @param v_low_high_source_u8 : The value of the low-g/high-g source
- *	value    | Description
- * ----------|-------------------
- *  0x01     |  UNFILTER_DATA
- *  0x00     |  FILTER_DATA
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_high_source(
-u8 *v_low_high_source_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read the high_low_g source interrupt */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_low_high_source_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE);
-		}
-	return com_rslt;
-}
-/*!
- *	@brief This API writes Data source for the
- *	interrupt engine for the low and high g interrupts
- *	from the register 0x58 bit 7
- *
- *  @param v_low_high_source_u8 : The value of the low-g/high-g source
- *	value    | Description
- * ----------|-------------------
- *  0x01     |  UNFILTER_DATA
- *  0x00     |  FILTER_DATA
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_high_source(
-u8 v_low_high_source_u8)
-{
-/* variable used to 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 for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-	} else {
-	if (v_low_high_source_u8 <= BMI160_MAX_VALUE_SOURCE_INTR) {
-		/* write the high_low_g source interrupt */
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-		(p_bmi160->dev_addr,
-		BMI160_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE__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_DATA_0_INTR_LOW_HIGH_SOURCE,
-			v_low_high_source_u8);
-			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-			/*Check for the power mode of Accel and
-			gyro not in normal mode */
-			if (bmi160_power_mode_status_u8_g !=
-			BMI160_NORMAL_MODE)
-				/*interface idle time delay */
-				p_bmi160->delay_msec(
-				BMI160_GEN_READ_WRITE_DELAY);
-
-
-		}
-	} else {
-	com_rslt = E_BMI160_OUT_OF_RANGE;
-	}
-}
-return com_rslt;
-}
- /*!
- *	@brief This API reads Data source for the
- *	interrupt engine for the nomotion and anymotion interrupts
- *	from the register 0x59 bit 7
- *
- *  @param v_motion_source_u8 :
- *	The value of the any/no motion interrupt source
- *	value    | Description
- * ----------|-------------------
- *  0x01     |  UNFILTER_DATA
- *  0x00     |  FILTER_DATA
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_motion_source(
-u8 *v_motion_source_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read the any/no motion interrupt  */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_INTR_DATA_1_INTR_MOTION_SOURCE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_motion_source_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_DATA_1_INTR_MOTION_SOURCE);
-		}
-	return com_rslt;
-}
- /*!
- *	@brief This API writes Data source for the
- *	interrupt engine for the nomotion and anymotion interrupts
- *	from the register 0x59 bit 7
- *
- *  @param v_motion_source_u8 :
- *	The value of the any/no motion interrupt source
- *	value    | Description
- * ----------|-------------------
- *  0x01     |  UNFILTER_DATA
- *  0x00     |  FILTER_DATA
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_motion_source(
-u8 v_motion_source_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		if (v_motion_source_u8 <= BMI160_MAX_VALUE_SOURCE_INTR) {
-			/* write the any/no motion interrupt  */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_INTR_DATA_1_INTR_MOTION_SOURCE__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_DATA_1_INTR_MOTION_SOURCE,
-				v_motion_source_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_INTR_DATA_1_INTR_MOTION_SOURCE__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Check for the power mode of Accel and
-				gyro not in normal mode */
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-
-
-			}
-		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-		}
-	}
-	return com_rslt;
-}
- /*!
- *	@brief This API is used to read the low_g duration from register
- *	0x5A bit 0 to 7
- *
- *
- *
- *
- *  @param v_low_g_durn_u8 : The value of low_g duration
- *
- *	@note Low_g duration trigger trigger delay according to
- *	"(v_low_g_durn_u8 * 2.5)ms" in a range from 2.5ms to 640ms.
- *	the default corresponds delay is 20ms
- *	@note When low_g data source of interrupt is unfiltered
- *	the sensor must not be in low power mode
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_g_durn(
-u8 *v_low_g_durn_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read the low_g interrupt */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_INTR_LOWHIGH_0_INTR_LOW_DURN__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_low_g_durn_u8 =
-			BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_LOWHIGH_0_INTR_LOW_DURN);
-		}
-	return com_rslt;
-}
- /*!
- *	@brief This API is used to write the low_g duration from register
- *	0x5A bit 0 to 7
- *
- *
- *
- *
- *  @param v_low_g_durn_u8 : The value of low_g duration
- *
- *	@note Low_g duration trigger trigger delay according to
- *	"(v_low_g_durn_u8 * 2.5)ms" in a range from 2.5ms to 640ms.
- *	the default corresponds delay is 20ms
- *	@note When low_g data source of interrupt is unfiltered
- *	the sensor must not be in low power mode
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_g_durn(u8 v_low_g_durn_u8)
-{
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* check the p_bmi160 structure for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* write the low_g interrupt */
-			com_rslt = p_bmi160->BMI160_BUS_WRITE_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_INTR_LOWHIGH_0_INTR_LOW_DURN__REG,
-			&v_low_g_durn_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-			/*Check for the power mode of Accel and
-			gyro not in normal mode */
-			if (bmi160_power_mode_status_u8_g !=
-			BMI160_NORMAL_MODE)
-				/*interface idle time delay */
-				p_bmi160->delay_msec(
-				BMI160_GEN_READ_WRITE_DELAY);
-		}
-	return com_rslt;
-}
-/*!
- *	@brief This API is used to read Threshold
- *	definition for the low-g interrupt from the register 0x5B bit 0 to 7
- *
- *
- *
- *
- *  @param v_low_g_thres_u8 : The value of low_g threshold
- *
- *	@note Low_g interrupt trigger threshold according to
- *	(v_low_g_thres_u8 * 7.81)mg for v_low_g_thres_u8 > 0
- *	3.91 mg for v_low_g_thres_u8 = 0
- *	The threshold range is from 3.91mg to 2.000mg
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_g_thres(
-u8 *v_low_g_thres_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read low_g threshold */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_INTR_LOWHIGH_1_INTR_LOW_THRES__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_low_g_thres_u8 =
-			BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_LOWHIGH_1_INTR_LOW_THRES);
-		}
-	return com_rslt;
-}
-/*!
- *	@brief This API is used to write Threshold
- *	definition for the low-g interrupt from the register 0x5B bit 0 to 7
- *
- *
- *
- *
- *  @param v_low_g_thres_u8 : The value of low_g threshold
- *
- *	@note Low_g interrupt trigger threshold according to
- *	(v_low_g_thres_u8 * 7.81)mg for v_low_g_thres_u8 > 0
- *	3.91 mg for v_low_g_thres_u8 = 0
- *	The threshold range is from 3.91mg to 2.000mg
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_g_thres(
-u8 v_low_g_thres_u8)
-{
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* check the p_bmi160 structure for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* write low_g threshold */
-			com_rslt = p_bmi160->BMI160_BUS_WRITE_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_INTR_LOWHIGH_1_INTR_LOW_THRES__REG,
-			&v_low_g_thres_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-			/*Check for the power mode of Accel and
-			gyro not in normal mode */
-			if (bmi160_power_mode_status_u8_g !=
-			BMI160_NORMAL_MODE)
-				/*interface idle time delay */
-				p_bmi160->delay_msec(
-				BMI160_GEN_READ_WRITE_DELAY);
-
-
-		}
-	return com_rslt;
-}
- /*!
- *	@brief This API reads Low-g interrupt hysteresis
- *	from the register 0x5C bit 0 to 1
- *
- *  @param v_low_hyst_u8 :The value of low_g hysteresis
- *
- *	@note Low_g hysteresis calculated by v_low_hyst_u8*125 mg
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_g_hyst(
-u8 *v_low_hyst_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read low_g hysteresis*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_low_hyst_u8 = BMI160_GET_BITSLICE(
-			v_data_u8,
-			BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST);
-		}
-	return com_rslt;
-}
- /*!
- *	@brief This API writes Low-g interrupt hysteresis
- *	from the register 0x5C bit 0 to 1
- *
- *  @param v_low_hyst_u8 :The value of low_g hysteresis
- *
- *	@note Low_g hysteresis calculated by v_low_hyst_u8*125 mg
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_g_hyst(
-u8 v_low_hyst_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* write low_g hysteresis*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST__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_LOWHIGH_2_INTR_LOW_G_HYST,
-				v_low_hyst_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Check for the power mode of Accel and
-				gyro not in normal mode */
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		}
-	return com_rslt;
-}
-/*!
- *	@brief This API reads Low-g interrupt mode
- *	from the register 0x5C bit 2
- *
- *  @param v_low_g_mode_u8 : The value of low_g mode
- *	Value    |  Description
- * ----------|-----------------
- *	   0     | single-axis
- *     1     | axis-summing
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_g_mode(u8 *v_low_g_mode_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/*read Low-g interrupt mode*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_low_g_mode_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE);
-		}
-	return com_rslt;
-}
-/*!
- *	@brief This API writes Low-g interrupt mode
- *	from the register 0x5C bit 2
- *
- *  @param v_low_g_mode_u8 : The value of low_g mode
- *	Value    |  Description
- * ----------|-----------------
- *	   0     | single-axis
- *     1     | axis-summing
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_g_mode(
-u8 v_low_g_mode_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		if (v_low_g_mode_u8 <= BMI160_MAX_VALUE_LOW_G_MODE) {
-			/*write Low-g interrupt mode*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE__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_LOWHIGH_2_INTR_LOW_G_MODE,
-				v_low_g_mode_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Check for the power mode of Accel and
-				gyro not in normal mode */
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-		}
-	}
-	return com_rslt;
-}
-/*!
- *	@brief This API reads High-g interrupt hysteresis
- *	from the register 0x5C bit 6 and 7
- *
- *  @param v_high_g_hyst_u8 : The value of high hysteresis
- *
- *	@note High_g hysteresis changes according to Accel g range
- *	Accel g range can be set by the function "bmi160_set_accel_range"
- *   accel_range    | high_g hysteresis
- *  ----------------|---------------------
- *      2g          |  high_hy*125 mg
- *      4g          |  high_hy*250 mg
- *      8g          |  high_hy*500 mg
- *      16g         |  high_hy*1000 mg
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_high_g_hyst(
-u8 *v_high_g_hyst_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read high_g hysteresis*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_high_g_hyst_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST);
-		}
-	return com_rslt;
-}
-/*!
- *	@brief This API writes High-g interrupt hysteresis
- *	from the register 0x5C bit 6 and 7
- *
- *  @param v_high_g_hyst_u8 : The value of high hysteresis
- *
- *	@note High_g hysteresis changes according to Accel g range
- *	Accel g range can be set by the function "bmi160_set_accel_range"
- *   accel_range    | high_g hysteresis
- *  ----------------|---------------------
- *      2g          |  high_hy*125 mg
- *      4g          |  high_hy*250 mg
- *      8g          |  high_hy*500 mg
- *      16g         |  high_hy*1000 mg
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_high_g_hyst(
-u8 v_high_g_hyst_u8)
-{
-/* variable used to 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 for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-	} else {
-		/* write high_g hysteresis*/
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-		p_bmi160->dev_addr,
-		BMI160_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST__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_LOWHIGH_2_INTR_HIGH_G_HYST,
-			v_high_g_hyst_u8);
-			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-			/*Check for the power mode of Accel and
-			gyro not in normal mode */
-			if (bmi160_power_mode_status_u8_g !=
-			BMI160_NORMAL_MODE)
-				/*interface idle time delay */
-				p_bmi160->delay_msec(
-				BMI160_GEN_READ_WRITE_DELAY);
-
-
-		}
-	}
-return com_rslt;
-}
-/*!
- *	@brief This API is used to read Delay
- *	time definition for the high-g interrupt from the register
- *	0x5D bit 0 to 7
- *
- *
- *
- *  @param  v_high_g_durn_u8 :  The value of high duration
- *
- *	@note High_g interrupt delay triggered according to
- *	v_high_g_durn_u8 * 2.5ms in a range from 2.5ms to 640ms
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_high_g_durn(
-u8 *v_high_g_durn_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read high_g duration*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_INTR_LOWHIGH_3_INTR_HIGH_G_DURN__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_high_g_durn_u8 =
-			BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_LOWHIGH_3_INTR_HIGH_G_DURN);
-		}
-	return com_rslt;
-}
-/*!
- *	@brief This API is used to write Delay
- *	time definition for the high-g interrupt from the register
- *	0x5D bit 0 to 7
- *
- *
- *
- *  @param  v_high_g_durn_u8 :  The value of high duration
- *
- *	@note High_g interrupt delay triggered according to
- *	v_high_g_durn_u8 * 2.5ms in a range from 2.5ms to 640ms
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_high_g_durn(
-u8 v_high_g_durn_u8)
-{
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* check the p_bmi160 structure for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* write high_g duration*/
-			com_rslt = p_bmi160->BMI160_BUS_WRITE_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_LOWHIGH_3_INTR_HIGH_G_DURN__REG,
-			&v_high_g_durn_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-			/*Check for the power mode of Accel and
-			gyro not in normal mode */
-			if (bmi160_power_mode_status_u8_g !=
-			BMI160_NORMAL_MODE)
-				/*interface idle time delay */
-				p_bmi160->delay_msec(
-				BMI160_GEN_READ_WRITE_DELAY);
-		}
-	return com_rslt;
-}
-/*!
- *	@brief This API is used to read Threshold
- *	definition for the high-g interrupt from the register 0x5E 0 to 7
- *
- *
- *
- *
- *  @param  v_high_g_thres_u8 : Pointer holding the value of Threshold
- *	@note High_g threshold changes according to Accel g range
- *	Accel g range can be set by the function "bmi160_set_accel_range"
- *   accel_range    | high_g threshold
- *  ----------------|---------------------
- *      2g          |  v_high_g_thres_u8*7.81 mg
- *      4g          |  v_high_g_thres_u8*15.63 mg
- *      8g          |  v_high_g_thres_u8*31.25 mg
- *      16g         |  v_high_g_thres_u8*62.5 mg
- *	@note when v_high_g_thres_u8 = 0
- *   accel_range    | high_g threshold
- *  ----------------|---------------------
- *      2g          |  3.91 mg
- *      4g          |  7.81 mg
- *      8g          |  15.63 mg
- *      16g         |  31.25 mg
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_high_g_thres(
-u8 *v_high_g_thres_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	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_LOWHIGH_4_INTR_HIGH_THRES__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_high_g_thres_u8 =
-			BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_LOWHIGH_4_INTR_HIGH_THRES);
-	}
-	return com_rslt;
-}
-/*!
- *	@brief This API is used to write Threshold
- *	definition for the high-g interrupt from the register 0x5E 0 to 7
- *
- *
- *
- *
- *  @param  v_high_g_thres_u8 : Pointer holding the value of Threshold
- *	@note High_g threshold changes according to Accel g range
- *	Accel g range can be set by the function "bmi160_set_accel_range"
- *   accel_range    | high_g threshold
- *  ----------------|---------------------
- *      2g          |  v_high_g_thres_u8*7.81 mg
- *      4g          |  v_high_g_thres_u8*15.63 mg
- *      8g          |  v_high_g_thres_u8*31.25 mg
- *      16g         |  v_high_g_thres_u8*62.5 mg
- *	@note when v_high_g_thres_u8 = 0
- *   accel_range    | high_g threshold
- *  ----------------|---------------------
- *      2g          |  3.91 mg
- *      4g          |  7.81 mg
- *      8g          |  15.63 mg
- *      16g         |  31.25 mg
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_high_g_thres(
-u8 v_high_g_thres_u8)
-{
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* check the p_bmi160 structure for NULL pointer assignment*/
-	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_INTR_LOWHIGH_4_INTR_HIGH_THRES__REG,
-		&v_high_g_thres_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-		/*Check for the power mode of Accel and
-		gyro not in normal mode */
-		if (bmi160_power_mode_status_u8_g != BMI160_NORMAL_MODE)
-			/*interface idle time delay */
-			p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-
-	}
-	return com_rslt;
-}
-/*!
- *	@brief This API reads any motion duration
- *	from the register 0x5F bit 0 and 1
- *
- *  @param v_any_motion_durn_u8 : The value of any motion duration
- *
- *	@note Any motion duration can be calculated by "v_any_motion_durn_u8 + 1"
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_any_motion_durn(
-u8 *v_any_motion_durn_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		/* read any motion duration*/
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-		(p_bmi160->dev_addr,
-		BMI160_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN__REG,
-		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		*v_any_motion_durn_u8 = BMI160_GET_BITSLICE
-		(v_data_u8,
-		BMI160_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN);
-	}
-	return com_rslt;
-}
-/*!
- *	@brief This API writes any motion duration
- *	from the register 0x5F bit 0 and 1
- *
- *  @param v_any_motion_durn_u8 : The value of any motion duration
- *
- *	@note Any motion duration can be calculated by "v_any_motion_durn_u8 + 1"
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_any_motion_durn(
-u8 v_any_motion_durn_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		/* write any motion duration*/
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-		(p_bmi160->dev_addr,
-		BMI160_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN__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_MOTION_0_INTR_ANY_MOTION_DURN,
-			v_any_motion_durn_u8);
-			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-			/*Check for the power mode of Accel and
-			gyro not in normal mode */
-			if (bmi160_power_mode_status_u8_g !=
-			BMI160_NORMAL_MODE)
-				/*interface idle time delay */
-				p_bmi160->delay_msec(
-				BMI160_GEN_READ_WRITE_DELAY);
-		}
-	}
-	return com_rslt;
-}
- /*!
- *	@brief This API reads Slow/no-motion
- *	interrupt trigger delay duration from the register 0x5F bit 2 to 7
- *
- *  @param v_slow_no_motion_u8 :The value of slow no motion duration
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *	@note
- *	@note v_slow_no_motion_u8(5:4)=0b00 ->
- *	[v_slow_no_motion_u8(3:0) + 1] * 1.28s (1.28s-20.48s)
- *	@note v_slow_no_motion_u8(5:4)=1 ->
- *	[v_slow_no_motion_u8(3:0)+5] * 5.12s (25.6s-102.4s)
- *	@note v_slow_no_motion_u8(5)='1' ->
- *	[(v_slow_no_motion_u8:0)+11] * 10.24s (112.64s-430.08s);
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_slow_no_motion_durn(
-u8 *v_slow_no_motion_u8)
-{
-/* variable used to 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 for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-	} else {
-		/* read slow no motion duration*/
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-		(p_bmi160->dev_addr,
-		BMI160_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN__REG,
-		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		*v_slow_no_motion_u8 = BMI160_GET_BITSLICE
-		(v_data_u8,
-		BMI160_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN);
-	}
-return com_rslt;
-}
- /*!
- *	@brief This API writes Slow/no-motion
- *	interrupt trigger delay duration from the register 0x5F bit 2 to 7
- *
- *  @param v_slow_no_motion_u8 :The value of slow no motion duration
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *	@note
- *	@note v_slow_no_motion_u8(5:4)=0b00 ->
- *	[v_slow_no_motion_u8(3:0) + 1] * 1.28s (1.28s-20.48s)
- *	@note v_slow_no_motion_u8(5:4)=1 ->
- *	[v_slow_no_motion_u8(3:0)+5] * 5.12s (25.6s-102.4s)
- *	@note v_slow_no_motion_u8(5)='1' ->
- *	[(v_slow_no_motion_u8:0)+11] * 10.24s (112.64s-430.08s);
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_slow_no_motion_durn(
-u8 v_slow_no_motion_u8)
-{
-/* variable used to 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 for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-	} else {
-	/* write slow no motion duration*/
-	com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-	(p_bmi160->dev_addr,
-	BMI160_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN__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_MOTION_0_INTR_SLOW_NO_MOTION_DURN,
-		v_slow_no_motion_u8);
-		com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
-		(p_bmi160->dev_addr,
-		BMI160_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN__REG,
-		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-		/*Check for the power mode of Accel and
-		gyro not in normal mode */
-		if (bmi160_power_mode_status_u8_g != BMI160_NORMAL_MODE)
-			/*interface idle time delay */
-			p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-
-	}
-}
-return com_rslt;
-}
-/*!
- *	@brief This API is used to read threshold
- *	definition for the any-motion interrupt
- *	from the register 0x60 bit 0 to 7
- *
- *
- *  @param  v_any_motion_thres_u8 : The value of any motion threshold
- *
- *	@note any motion threshold changes according to Accel g range
- *	Accel g range can be set by the function "bmi160_set_accel_range"
- *   accel_range    | any motion threshold
- *  ----------------|---------------------
- *      2g          |  v_any_motion_thres_u8*3.91 mg
- *      4g          |  v_any_motion_thres_u8*7.81 mg
- *      8g          |  v_any_motion_thres_u8*15.63 mg
- *      16g         |  v_any_motion_thres_u8*31.25 mg
- *	@note when v_any_motion_thres_u8 = 0
- *   accel_range    | any motion threshold
- *  ----------------|---------------------
- *      2g          |  1.95 mg
- *      4g          |  3.91 mg
- *      8g          |  7.81 mg
- *      16g         |  15.63 mg
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_any_motion_thres(
-u8 *v_any_motion_thres_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read any motion threshold*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_MOTION_1_INTR_ANY_MOTION_THRES__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_any_motion_thres_u8 =
-			BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_MOTION_1_INTR_ANY_MOTION_THRES);
-		}
-	return com_rslt;
-}
-/*!
- *	@brief This API is used to write threshold
- *	definition for  any-motion interrupt
- *	from the register 0x60 bit 0 to 7
- *
- *
- *  @param  v_any_motion_thres_u8 : The value of any motion threshold
- *
- *	@note any motion threshold changes according to Accel g range
- *	Accel g range can be set by the function "bmi160_set_accel_range"
- *   accel_range    | any motion threshold
- *  ----------------|---------------------
- *      2g          |  v_any_motion_thres_u8*3.91 mg
- *      4g          |  v_any_motion_thres_u8*7.81 mg
- *      8g          |  v_any_motion_thres_u8*15.63 mg
- *      16g         |  v_any_motion_thres_u8*31.25 mg
- *	@note when v_any_motion_thres_u8 = 0
- *   accel_range    | any motion threshold
- *  ----------------|---------------------
- *      2g          |  1.95 mg
- *      4g          |  3.91 mg
- *      8g          |  7.81 mg
- *      16g         |  15.63 mg
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_any_motion_thres(
-u8 v_any_motion_thres_u8)
-{
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* check the p_bmi160 structure for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		/* write any motion threshold*/
-		com_rslt = p_bmi160->BMI160_BUS_WRITE_FUNC
-		(p_bmi160->dev_addr,
-		BMI160_USER_INTR_MOTION_1_INTR_ANY_MOTION_THRES__REG,
-		&v_any_motion_thres_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-		/*Check for the power mode of Accel and
-		gyro not in normal mode */
-		if (bmi160_power_mode_status_u8_g != BMI160_NORMAL_MODE)
-			/*interface idle time delay */
-			p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	}
-	return com_rslt;
-}
- /*!
- *	@brief This API is used to read threshold
- *	for the slow/no-motion interrupt
- *	from the register 0x61 bit 0 to 7
- *
- *
- *
- *
- *  @param v_slow_no_motion_thres_u8 : The value of slow no motion threshold
- *	@note slow no motion threshold changes according to Accel g range
- *	Accel g range can be set by the function "bmi160_set_accel_range"
- *   accel_range    | slow no motion threshold
- *  ----------------|---------------------
- *      2g          |  v_slow_no_motion_thres_u8*3.91 mg
- *      4g          |  v_slow_no_motion_thres_u8*7.81 mg
- *      8g          |  v_slow_no_motion_thres_u8*15.63 mg
- *      16g         |  v_slow_no_motion_thres_u8*31.25 mg
- *	@note when v_slow_no_motion_thres_u8 = 0
- *   accel_range    | slow no motion threshold
- *  ----------------|---------------------
- *      2g          |  1.95 mg
- *      4g          |  3.91 mg
- *      8g          |  7.81 mg
- *      16g         |  15.63 mg
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_slow_no_motion_thres(
-u8 *v_slow_no_motion_thres_u8)
-{
-BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-	} else {
-		/* read slow no motion threshold*/
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-		(p_bmi160->dev_addr,
-		BMI160_USER_INTR_MOTION_2_INTR_SLOW_NO_MOTION_THRES__REG,
-		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		*v_slow_no_motion_thres_u8 =
-		BMI160_GET_BITSLICE(v_data_u8,
-		BMI160_USER_INTR_MOTION_2_INTR_SLOW_NO_MOTION_THRES);
-	}
-return com_rslt;
-}
- /*!
- *	@brief This API is used to write threshold
- *	for the slow/no-motion interrupt
- *	in the register 0x61 bit 0 to 7
- *
- *
- *
- *
- *  @param v_slow_no_motion_thres_u8 : The value of slow no motion threshold
- *	@note slow no motion threshold changes according to Accel g range
- *	Accel g range can be set by the function "bmi160_set_accel_range"
- *   accel_range    | slow no motion threshold
- *  ----------------|---------------------
- *      2g          |  v_slow_no_motion_thres_u8*3.91 mg
- *      4g          |  v_slow_no_motion_thres_u8*7.81 mg
- *      8g          |  v_slow_no_motion_thres_u8*15.63 mg
- *      16g         |  v_slow_no_motion_thres_u8*31.25 mg
- *	@note when v_slow_no_motion_thres_u8 = 0
- *   accel_range    | slow no motion threshold
- *  ----------------|---------------------
- *      2g          |  1.95 mg
- *      4g          |  3.91 mg
- *      8g          |  7.81 mg
- *      16g         |  15.63 mg
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_slow_no_motion_thres(
-u8 v_slow_no_motion_thres_u8)
-{
-BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
-/* check the p_bmi160 structure for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-	} else {
-		/* write slow no motion threshold*/
-		com_rslt = p_bmi160->BMI160_BUS_WRITE_FUNC(
-		p_bmi160->dev_addr,
-		BMI160_USER_INTR_MOTION_2_INTR_SLOW_NO_MOTION_THRES__REG,
-		&v_slow_no_motion_thres_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-		/*Check for the power mode of Accel and
-		gyro not in normal mode */
-		if (bmi160_power_mode_status_u8_g != BMI160_NORMAL_MODE)
-			/*interface idle time delay */
-			p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	}
-return com_rslt;
-}
- /*!
- *	@brief This API is used to read
- *	the slow/no-motion selection from the register 0x62 bit 0
- *
- *
- *
- *
- *  @param  v_intr_slow_no_motion_select_u8 :
- *	The value of slow/no-motion select
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     |  SLOW_MOTION
- *  0x01     |  NO_MOTION
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_slow_no_motion_select(
-u8 *v_intr_slow_no_motion_select_u8)
-{
-BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-	} else {
-		/* read slow no motion select*/
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-		p_bmi160->dev_addr,
-		BMI160_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT__REG,
-		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		*v_intr_slow_no_motion_select_u8 =
-		BMI160_GET_BITSLICE(v_data_u8,
-		BMI160_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT);
-	}
-return com_rslt;
-}
- /*!
- *	@brief This API is used to write
- *	the slow/no-motion selection from the register 0x62 bit 0
- *
- *
- *
- *
- *  @param  v_intr_slow_no_motion_select_u8 :
- *	The value of slow/no-motion select
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     |  SLOW_MOTION
- *  0x01     |  NO_MOTION
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_slow_no_motion_select(
-u8 v_intr_slow_no_motion_select_u8)
-{
-/* variable used to 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 for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-} else {
-if (v_intr_slow_no_motion_select_u8 <= BMI160_MAX_VALUE_NO_MOTION) {
-	/* write slow no motion select*/
-	com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-	(p_bmi160->dev_addr,
-	BMI160_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT__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_MOTION_3_INTR_SLOW_NO_MOTION_SELECT,
-		v_intr_slow_no_motion_select_u8);
-		com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
-		(p_bmi160->dev_addr,
-		BMI160_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT__REG,
-		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-		/*Check for the power mode of Accel and
-		gyro not in normal mode */
-		if (bmi160_power_mode_status_u8_g != BMI160_NORMAL_MODE)
-			/*interface idle time delay */
-			p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	}
-} else {
-com_rslt = E_BMI160_OUT_OF_RANGE;
-}
-}
-return com_rslt;
-}
- /*!
- *	@brief This API is used to select
- *	the significant or any motion interrupt from the register 0x62 bit 1
- *
- *
- *
- *
- *  @param  v_intr_significant_motion_select_u8 :
- *	the value of significant or any motion interrupt selection
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     |  ANY_MOTION
- *  0x01     |  SIGNIFICANT_MOTION
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_significant_motion_select(
-u8 *v_intr_significant_motion_select_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read the significant or any motion interrupt*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_INTR_SIGNIFICATION_MOTION_SELECT__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_intr_significant_motion_select_u8 =
-			BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_SIGNIFICATION_MOTION_SELECT);
-		}
-	return com_rslt;
-}
- /*!
- *	@brief This API is used to write, select
- *	the significant or any motion interrupt from the register 0x62 bit 1
- *
- *
- *
- *
- *  @param  v_intr_significant_motion_select_u8 :
- *	the value of significant or any motion interrupt selection
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     |  ANY_MOTION
- *  0x01     |  SIGNIFICANT_MOTION
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_significant_motion_select(
-u8 v_intr_significant_motion_select_u8)
-{
-/* variable used to 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 for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-	} else {
-	if (v_intr_significant_motion_select_u8 <=
-	BMI160_MAX_VALUE_SIGNIFICANT_MOTION) {
-		/* write the significant or any motion interrupt*/
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-		(p_bmi160->dev_addr,
-		BMI160_USER_INTR_SIGNIFICATION_MOTION_SELECT__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_SIGNIFICATION_MOTION_SELECT,
-			v_intr_significant_motion_select_u8);
-			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_SIGNIFICATION_MOTION_SELECT__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-			/*Accel and Gyro power mode check*/
-			if (bmi160_power_mode_status_u8_g !=
-			BMI160_NORMAL_MODE)
-				/*interface idle time delay */
-				p_bmi160->delay_msec(
-				BMI160_GEN_READ_WRITE_DELAY);
-		}
-	} else {
-	com_rslt = E_BMI160_OUT_OF_RANGE;
-	}
-}
-return com_rslt;
-}
-/*!
- *	@brief This API is used to unmap the  signification motion
- *	interrupt
- *
- *
- *  @param v_significant_u8   : The value of interrupt selection
- *
- *      BMI160_MAP_INTR1	0
- *      BMI160_MAP_INTR2	1
- *
- *  \return results of communication routine
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_unmap_significant_motion_intr(
-u8 v_significant_u8)
-{
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-		u8 v_any_motion_intr1_stat_u8 = V_ANY_MOTION_INTR_STAT;
-		u8 v_any_motion_intr2_stat_u8 = V_ANY_MOTION_INTR_STAT;
-		u8 v_any_motion_axis_stat_u8 = V_ANY_MOTION_AXIS_STAT;
-		u8 v_data_u8 = BMI160_INIT_VALUE;
-	switch (v_significant_u8) {
-	case BMI160_MAP_INTR1:
-		/* interrupt */
-		com_rslt = bmi160_read_reg(
-		BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__REG,
-		&v_data_u8, BMI160_ASSIGN_DATA);
-		v_data_u8 &= ~(v_any_motion_intr1_stat_u8);
-		/* map the signification interrupt
-		to any-motion interrupt1*/
-		com_rslt += bmi160_write_reg(
-		BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__REG,
-		&v_data_u8, BMI160_ASSIGN_DATA);
-		p_bmi160->delay_msec(BMI160_ASSIGN_DATA);
-		/* axis*/
-		com_rslt = bmi160_read_reg(
-		BMI160_USER_INTR_ENABLE_0_ADDR,
-		&v_data_u8, BMI160_ASSIGN_DATA);
-		v_data_u8 &= ~(v_any_motion_axis_stat_u8);
-		com_rslt += bmi160_write_reg(
-		BMI160_USER_INTR_ENABLE_0_ADDR,
-		&v_data_u8, BMI160_ASSIGN_DATA);
-		p_bmi160->delay_msec(BMI160_ASSIGN_DATA);
-	break;
-	case BMI160_MAP_INTR2:
-		/* map the signification interrupt
-		to any-motion interrupt2*/
-		com_rslt = bmi160_read_reg(
-		BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__REG,
-		&v_data_u8, BMI160_ASSIGN_DATA);
-		v_data_u8 &= ~(v_any_motion_intr2_stat_u8);
-		com_rslt += bmi160_write_reg(
-		BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__REG,
-		&v_data_u8, BMI160_ASSIGN_DATA);
-		p_bmi160->delay_msec(BMI160_ASSIGN_DATA);
-		/* axis*/
-		com_rslt = bmi160_read_reg(BMI160_USER_INTR_ENABLE_0_ADDR,
-		&v_data_u8, BMI160_ASSIGN_DATA);
-		v_data_u8 &= ~(v_any_motion_axis_stat_u8);
-		com_rslt += bmi160_write_reg(
-		BMI160_USER_INTR_ENABLE_0_ADDR,
-		&v_data_u8, BMI160_ASSIGN_DATA);
-		p_bmi160->delay_msec(BMI160_ASSIGN_DATA);
-	break;
-	default:
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-	break;
-	}
-		return com_rslt;
-}
- /*!
- *	@brief This API is used to read
- *	the significant skip time from the register 0x62 bit  2 and 3
- *
- *
- *
- *
- *  @param  v_int_sig_mot_skip_u8 : the value of significant skip time
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     |  skip time 1.5 seconds
- *  0x01     |  skip time 3 seconds
- *  0x02     |  skip time 6 seconds
- *  0x03     |  skip time 12 seconds
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_significant_motion_skip(
-u8 *v_int_sig_mot_skip_u8)
-{
-	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
-	u8 v_data_u8 = BMI160_INIT_VALUE;
-	/* check the p_bmi160 structure for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read significant skip time*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_INTR_SIGNIFICANT_MOTION_SKIP__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_int_sig_mot_skip_u8 =
-			BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_SIGNIFICANT_MOTION_SKIP);
-		}
-	return com_rslt;
-}
- /*!
- *	@brief This API is used to write
- *	the significant skip time in the register 0x62 bit  2 and 3
- *
- *
- *
- *
- *  @param  v_int_sig_mot_skip_u8 : the value of significant skip time
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     |  skip time 1.5 seconds
- *  0x01     |  skip time 3 seconds
- *  0x02     |  skip time 6 seconds
- *  0x03     |  skip time 12 seconds
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_significant_motion_skip(
-u8 v_int_sig_mot_skip_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		if (v_int_sig_mot_skip_u8 <= BMI160_MAX_UNDER_SIG_MOTION) {
-			/* write significant skip time*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_SIGNIFICANT_MOTION_SKIP__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_SIGNIFICANT_MOTION_SKIP,
-				v_int_sig_mot_skip_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
-				(p_bmi160->dev_addr,
-				BMI160_USER_INTR_SIGNIFICANT_MOTION_SKIP__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-		}
-	}
-	return com_rslt;
-}
- /*!
- *	@brief This API is used to read
- *	the significant proof time from the register 0x62 bit  4 and 5
- *
- *
- *
- *
- *  @param  v_significant_motion_proof_u8 :
- *	the value of significant proof time
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     |  proof time 0.25 seconds
- *  0x01     |  proof time 0.5 seconds
- *  0x02     |  proof time 1 seconds
- *  0x03     |  proof time 2 seconds
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_significant_motion_proof(
-u8 *v_significant_motion_proof_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read significant proof time */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_INTR_SIGNIFICANT_MOTION_PROOF__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_significant_motion_proof_u8 =
-			BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_SIGNIFICANT_MOTION_PROOF);
-		}
-	return com_rslt;
-}
- /*!
- *	@brief This API is used to write
- *	the significant proof time in the register 0x62 bit  4 and 5
- *
- *
- *
- *
- *  @param  v_significant_motion_proof_u8 :
- *	the value of significant proof time
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     |  proof time 0.25 seconds
- *  0x01     |  proof time 0.5 seconds
- *  0x02     |  proof time 1 seconds
- *  0x03     |  proof time 2 seconds
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_significant_motion_proof(
-u8 v_significant_motion_proof_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		if (v_significant_motion_proof_u8
-		<= BMI160_MAX_UNDER_SIG_MOTION) {
-			/* write significant proof time */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_SIGNIFICANT_MOTION_PROOF__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_SIGNIFICANT_MOTION_PROOF,
-				v_significant_motion_proof_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
-				(p_bmi160->dev_addr,
-				BMI160_USER_INTR_SIGNIFICANT_MOTION_PROOF__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-		}
-	}
-	return com_rslt;
-}
-/*!
- *	@brief This API is used to get the tap duration
- *	from the register 0x63 bit 0 to 2
- *
- *
- *
- *  @param v_tap_durn_u8 : The value of tap duration
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | BMI160_TAP_DURN_50MS
- *  0x01     | BMI160_TAP_DURN_100MS
- *  0x02     | BMI160_TAP_DURN_150MS
- *  0x03     | BMI160_TAP_DURN_200MS
- *  0x04     | BMI160_TAP_DURN_250MS
- *  0x05     | BMI160_TAP_DURN_375MS
- *  0x06     | BMI160_TAP_DURN_500MS
- *  0x07     | BMI160_TAP_DURN_700MS
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_durn(
-u8 *v_tap_durn_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read tap duration*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_TAP_0_INTR_TAP_DURN__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_tap_durn_u8 = BMI160_GET_BITSLICE(
-			v_data_u8,
-			BMI160_USER_INTR_TAP_0_INTR_TAP_DURN);
-		}
-	return com_rslt;
-}
-/*!
- *	@brief This API is used to write the tap duration
- *	in the register 0x63 bit 0 to 2
- *
- *
- *
- *  @param v_tap_durn_u8 : The value of tap duration
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | BMI160_TAP_DURN_50MS
- *  0x01     | BMI160_TAP_DURN_100MS
- *  0x02     | BMI160_TAP_DURN_150MS
- *  0x03     | BMI160_TAP_DURN_200MS
- *  0x04     | BMI160_TAP_DURN_250MS
- *  0x05     | BMI160_TAP_DURN_375MS
- *  0x06     | BMI160_TAP_DURN_500MS
- *  0x07     | BMI160_TAP_DURN_700MS
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_durn(
-u8 v_tap_durn_u8)
-{
-	u8 v_data_u8 = BMI160_INIT_VALUE;
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	u8 v_data_tap_durn_u8 = BMI160_INIT_VALUE;
-	/* check the p_bmi160 structure for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		if (v_tap_durn_u8 <= BMI160_MAX_TAP_TURN) {
-			switch (v_tap_durn_u8) {
-			case BMI160_TAP_DURN_50MS:
-				v_data_tap_durn_u8 = BMI160_TAP_DURN_50MS;
-				break;
-			case BMI160_TAP_DURN_100MS:
-				v_data_tap_durn_u8 = BMI160_TAP_DURN_100MS;
-				break;
-			case BMI160_TAP_DURN_150MS:
-				v_data_tap_durn_u8 = BMI160_TAP_DURN_150MS;
-				break;
-			case BMI160_TAP_DURN_200MS:
-				v_data_tap_durn_u8 = BMI160_TAP_DURN_200MS;
-				break;
-			case BMI160_TAP_DURN_250MS:
-				v_data_tap_durn_u8 = BMI160_TAP_DURN_250MS;
-				break;
-			case BMI160_TAP_DURN_375MS:
-				v_data_tap_durn_u8 = BMI160_TAP_DURN_375MS;
-				break;
-			case BMI160_TAP_DURN_500MS:
-				v_data_tap_durn_u8 = BMI160_TAP_DURN_500MS;
-				break;
-			case BMI160_TAP_DURN_700MS:
-				v_data_tap_durn_u8 = BMI160_TAP_DURN_700MS;
-				break;
-			default:
-				break;
-			}
-			/* write tap duration*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_INTR_TAP_0_INTR_TAP_DURN__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_TAP_0_INTR_TAP_DURN,
-				v_data_tap_durn_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
-				(p_bmi160->dev_addr,
-				BMI160_USER_INTR_TAP_0_INTR_TAP_DURN__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-		}
-	}
-	return com_rslt;
-}
- /*!
- *	@brief This API reads the
- *	tap shock duration from the register 0x63 bit 2
- *
- *  @param v_tap_shock_u8 :The value of tap shock
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | BMI160_TAP_SHOCK_50MS
- *  0x01     | BMI160_TAP_SHOCK_75MS
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_shock(
-u8 *v_tap_shock_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read tap shock duration*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_INTR_TAP_0_INTR_TAP_SHOCK__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_tap_shock_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_TAP_0_INTR_TAP_SHOCK);
-		}
-	return com_rslt;
-}
- /*!
- *	@brief This API writes the
- *	tap shock duration from the register 0x63 bit 2
- *
- *  @param v_tap_shock_u8 :The value of tap shock
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | BMI160_TAP_SHOCK_50MS
- *  0x01     | BMI160_TAP_SHOCK_75MS
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_shock(u8 v_tap_shock_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		if (v_tap_shock_u8 <= BMI160_MAX_VALUE_TAP_SHOCK) {
-			/* write tap shock duration*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_TAP_0_INTR_TAP_SHOCK__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_TAP_0_INTR_TAP_SHOCK,
-				v_tap_shock_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
-				(p_bmi160->dev_addr,
-				BMI160_USER_INTR_TAP_0_INTR_TAP_SHOCK__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-		}
-	}
-	return com_rslt;
-}
-/*!
- *	@brief This API reads
- *	tap quiet duration from the register 0x63 bit 7
- *
- *
- *  @param v_tap_quiet_u8 : The value of tap quiet
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | BMI160_TAP_QUIET_30MS
- *  0x01     | BMI160_TAP_QUIET_20MS
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_quiet(
-u8 *v_tap_quiet_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read tap quiet duration*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_INTR_TAP_0_INTR_TAP_QUIET__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_tap_quiet_u8 = BMI160_GET_BITSLICE(
-			v_data_u8,
-			BMI160_USER_INTR_TAP_0_INTR_TAP_QUIET);
-		}
-	return com_rslt;
-}
-/*!
- *	@brief This API writes
- *	tap quiet duration in the register 0x63 bit 7
- *
- *
- *  @param v_tap_quiet_u8 : The value of tap quiet
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | BMI160_TAP_QUIET_30MS
- *  0x01     | BMI160_TAP_QUIET_20MS
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_quiet(u8 v_tap_quiet_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		if (v_tap_quiet_u8 <= BMI160_MAX_VALUE_TAP_QUIET) {
-			/* write tap quiet duration*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_TAP_0_INTR_TAP_QUIET__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_TAP_0_INTR_TAP_QUIET,
-				v_tap_quiet_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
-				(p_bmi160->dev_addr,
-				BMI160_USER_INTR_TAP_0_INTR_TAP_QUIET__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-		}
-	}
-	return com_rslt;
-}
- /*!
- *	@brief This API reads the threshold of the
- *	single/double tap interrupt from the register 0x64 bit 0 to 4
- *
- *
- *	@param v_tap_thres_u8 : The value of single/double tap threshold
- *
- *	@note single/double tap threshold changes according to Accel g range
- *	Accel g range can be set by the function "bmi160_set_accel_range"
- *   accel_range    | single/double tap threshold
- *  ----------------|---------------------
- *      2g          |  ((v_tap_thres_u8 + 1) * 62.5)mg
- *      4g          |  ((v_tap_thres_u8 + 1) * 125)mg
- *      8g          |  ((v_tap_thres_u8 + 1) * 250)mg
- *      16g         |  ((v_tap_thres_u8 + 1) * 500)mg
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_thres(
-u8 *v_tap_thres_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read tap threshold*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_INTR_TAP_1_INTR_TAP_THRES__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_tap_thres_u8 = BMI160_GET_BITSLICE
-			(v_data_u8,
-			BMI160_USER_INTR_TAP_1_INTR_TAP_THRES);
-		}
-	return com_rslt;
-}
- /*!
- *	@brief This API writes the threshold of the
- *	single/double tap interrupt in the register 0x64 bit 0 to 4
- *
- *
- *	@param v_tap_thres_u8 : The value of single/double tap threshold
- *
- *	@note single/double tap threshold changes according to Accel g range
- *	Accel g range can be set by the function "bmi160_set_accel_range"
- *   accel_range    | single/double tap threshold
- *  ----------------|---------------------
- *      2g          |  ((v_tap_thres_u8 + 1) * 62.5)mg
- *      4g          |  ((v_tap_thres_u8 + 1) * 125)mg
- *      8g          |  ((v_tap_thres_u8 + 1) * 250)mg
- *      16g         |  ((v_tap_thres_u8 + 1) * 500)mg
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_thres(
-u8 v_tap_thres_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* write tap threshold*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_TAP_1_INTR_TAP_THRES__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_TAP_1_INTR_TAP_THRES,
-				v_tap_thres_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
-				(p_bmi160->dev_addr,
-				BMI160_USER_INTR_TAP_1_INTR_TAP_THRES__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		}
-	return com_rslt;
-}
- /*!
- *	@brief This API reads the threshold for orientation interrupt
- *	from the register 0x65 bit 0 and 1
- *
- *  @param v_orient_mode_u8 : The value of threshold for orientation
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | symmetrical
- *  0x01     | high-asymmetrical
- *  0x02     | low-asymmetrical
- *  0x03     | symmetrical
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_mode(
-u8 *v_orient_mode_u8)
-{
-	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
-	u8 v_data_u8 = BMI160_INIT_VALUE;
-	/* check the p_bmi160 structure for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read orientation threshold*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_MODE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_orient_mode_u8 = BMI160_GET_BITSLICE
-			(v_data_u8,
-			BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_MODE);
-		}
-	return com_rslt;
-}
- /*!
- *	@brief This API writes the threshold for orientation interrupt
- *	from the register 0x65 bit 0 and 1
- *
- *  @param v_orient_mode_u8 : The value of threshold for orientation
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | symmetrical
- *  0x01     | high-asymmetrical
- *  0x02     | low-asymmetrical
- *  0x03     | symmetrical
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_mode(
-u8 v_orient_mode_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		if (v_orient_mode_u8 <= BMI160_MAX_ORIENT_MODE) {
-			/* write orientation threshold*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_MODE__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_ORIENT_0_INTR_ORIENT_MODE,
-				v_orient_mode_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
-				(p_bmi160->dev_addr,
-				BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_MODE__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-
 
-			}
-		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-		}
-	}
-	return com_rslt;
-}
-/*!
- *	@brief This API reads the orientation blocking mode
- *	that is used for the generation of the orientation interrupt.
- *	from the register 0x65 bit 2 and 3
- *
- *  @param v_orient_blocking_u8 : The value of orient blocking mode
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | No blocking
- *  0x01     | Theta blocking or acceleration in any axis > 1.5g
- *  0x02     | Theta blocking or acceleration slope in any axis >
- *   -       | 0.2g or acceleration in any axis > 1.5g
- *  0x03     | Theta blocking or acceleration slope in any axis >
- *   -       | 0.4g or acceleration in any axis >
- *   -       | 1.5g and value of orient is not stable
- *   -       | for at least 100 ms
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_blocking(
-u8 *v_orient_blocking_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read orient blocking mode*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_orient_blocking_u8 = BMI160_GET_BITSLICE
-			(v_data_u8,
-			BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING);
-		}
-	return com_rslt;
-}
-/*!
- *	@brief This API writes the orientation blocking mode
- *	that is used for the generation of the orientation interrupt.
- *	in the register 0x65 bit 2 and 3
- *
- *  @param v_orient_blocking_u8 : The value of orient blocking mode
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | No blocking
- *  0x01     | Theta blocking or acceleration in any axis > 1.5g
- *  0x02     | Theta blocking or acceleration slope in any axis >
- *   -       | 0.2g or acceleration in any axis > 1.5g
- *  0x03     | Theta blocking or acceleration slope in any axis >
- *   -       | 0.4g or acceleration in any axis >
- *   -       | 1.5g and value of orient is not stable
- *   -       | for at least 100 ms
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_blocking(
-u8 v_orient_blocking_u8)
-{
-/* variable used to 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 for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-	} else {
-	if (v_orient_blocking_u8 <= BMI160_MAX_ORIENT_BLOCKING) {
-		/* write orient blocking mode*/
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-		(p_bmi160->dev_addr,
-		BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING__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_ORIENT_0_INTR_ORIENT_BLOCKING,
-			v_orient_blocking_u8);
-			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-			/*Accel and Gyro power mode check*/
-			if (bmi160_power_mode_status_u8_g !=
-			BMI160_NORMAL_MODE)
-				/*interface idle time delay */
-				p_bmi160->delay_msec(
-				BMI160_GEN_READ_WRITE_DELAY);
-		}
-	} else {
-	com_rslt = E_BMI160_OUT_OF_RANGE;
-	}
-}
-return com_rslt;
-}
 /*!
- *	@brief This API reads the orientation interrupt
- *	hysteresis, from the register 0x64 bit 4 to 7
- *
- *
- *
- *  @param v_orient_hyst_u8 : The value of orient hysteresis
- *
- *	@note 1 LSB corresponds to 62.5 mg,
- *	irrespective of the selected Accel range
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_hyst(
-u8 *v_orient_hyst_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read orient hysteresis*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_HYST__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_orient_hyst_u8 = BMI160_GET_BITSLICE
-			(v_data_u8,
-			BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_HYST);
-		}
-	return com_rslt;
-}
-/*!
- *	@brief This API writes the orientation interrupt
- *	hysteresis, in the register 0x64 bit 4 to 7
- *
- *
- *
- *  @param v_orient_hyst_u8 : The value of orient hysteresis
- *
- *	@note 1 LSB corresponds to 62.5 mg,
- *	irrespective of the selected Accel range
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_hyst(
-u8 v_orient_hyst_u8)
+ *  @brief This API is the entry point for sensor.It performs
+ *  the selection of I2C/SPI read mechanism according to the
+ *  selected interface and reads the chip-id of bmi160 sensor.
+ */
+int8_t bmi160_init(struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* write orient hysteresis*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_HYST__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_ORIENT_0_INTR_ORIENT_HYST,
-				v_orient_hyst_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
-				(p_bmi160->dev_addr,
-				BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_HYST__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-
+	int8_t rslt;
+	uint8_t data;
+	uint8_t chip_id;
 
-			}
-		}
-	return com_rslt;
-}
- /*!
- *	@brief This API reads the orientation
- *	blocking angle (0 to 44.8) from the register 0x66 bit 0 to 5
- *
- *  @param v_orient_theta_u8 : The value of Orient blocking angle
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_theta(
-u8 *v_orient_theta_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read Orient blocking angle*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_THETA__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_orient_theta_u8 = BMI160_GET_BITSLICE
-			(v_data_u8,
-			BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_THETA);
-		}
-	return com_rslt;
-}
- /*!
- *	@brief This API writes orientation
- *	blocking angle (0 to 44.8) in the register 0x66 bit 0 to 5
- *
- *  @param v_orient_theta_u8 : The value of Orient blocking angle
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_theta(
-u8 v_orient_theta_u8)
-{
-/* variable used to 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 for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-	} else {
-	if (v_orient_theta_u8 <= BMI160_MAX_ORIENT_THETA) {
-		/* write Orient blocking angle*/
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-		(p_bmi160->dev_addr,
-		BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_THETA__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_ORIENT_1_INTR_ORIENT_THETA,
-			v_orient_theta_u8);
-			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_THETA__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-			/*Accel and Gyro power mode check*/
-			if (bmi160_power_mode_status_u8_g !=
-			BMI160_NORMAL_MODE)
-				/*interface idle time delay */
-				p_bmi160->delay_msec(
-				BMI160_GEN_READ_WRITE_DELAY);
-		}
-	} else {
-	com_rslt = E_BMI160_OUT_OF_RANGE;
-	}
-}
-return com_rslt;
-}
-/*!
- *	@brief This API reads the orientation change
- *	of up/down bit from the register 0x66 bit 6
- *
- *  @param v_orient_ud_u8 : The value of orient change of up/down
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | Is ignored
- *  0x01     | Generates orientation interrupt
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_ud_enable(
-u8 *v_orient_ud_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
+	/* Null-pointer check */
+	rslt = null_ptr_check(dev);
+
+	/* Dummy read of 0x7F register to enable SPI Interface
+	 if SPI is used */
+	if ((rslt == BMI160_OK) && (dev->interface == BMI160_SPI_INTF))
+		rslt = bmi160_get_regs(BMI160_SPI_COMM_TEST_ADDR, &data, 1, dev);
+
+	if (rslt == BMI160_OK) {
+		/* Read chip_id */
+		rslt = bmi160_get_regs(BMI160_CHIP_ID_ADDR, &chip_id, 1, dev);
+
+		if ((rslt == BMI160_OK) && (chip_id == BMI160_CHIP_ID)) {
+			dev->chip_id = chip_id;
+			dev->any_sig_sel = BMI160_BOTH_ANY_SIG_MOTION_DISABLED;
+			/*Soft reset*/
+			rslt = bmi160_soft_reset(dev);
+			if (rslt == BMI160_OK)
+				default_param_settg(dev);
 		} else {
-			/* read orient up/down enable*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_orient_ud_u8 = BMI160_GET_BITSLICE
-			(v_data_u8,
-			BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE);
+			rslt = BMI160_E_DEV_NOT_FOUND;
 		}
-	return com_rslt;
+	}
+
+	return rslt;
 }
+
 /*!
- *	@brief This API writes orientation change
- *	of up/down bit in the register 0x66 bit 6
- *
- *  @param v_orient_ud_u8 : The value of orient change of up/down
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | Is ignored
- *  0x01     | Generates orientation interrupt
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_ud_enable(
-u8 v_orient_ud_u8)
+ * @brief This API resets and restarts the device.
+ * All register values are overwritten with default parameters.
+ */
+int8_t bmi160_soft_reset(const struct bmi160_dev *dev)
 {
-/* variable used to 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 for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
+	int8_t rslt;
+	uint8_t data = BMI160_SOFT_RESET_CMD;
+
+	/* Null-pointer check */
+	if ((dev == NULL) || (dev->delay_ms == NULL)) {
+		rslt = BMI160_E_NULL_PTR;
 	} else {
-	if (v_orient_ud_u8 <= BMI160_MAX_VALUE_ORIENT_UD) {
-		/* write orient up/down enable */
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-		(p_bmi160->dev_addr,
-		BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_UD_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_ORIENT_1_INTR_ORIENT_UD_ENABLE,
-			v_orient_ud_u8);
-			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-			/*Accel and Gyro power mode check*/
-			if (bmi160_power_mode_status_u8_g !=
-			BMI160_NORMAL_MODE)
-				/*interface idle time delay */
-				p_bmi160->delay_msec(
-				BMI160_GEN_READ_WRITE_DELAY);
+		 /* Reset the device */
+		rslt = bmi160_set_regs(BMI160_COMMAND_REG_ADDR, &data, 1, dev);
+		dev->delay_ms(BMI160_SOFT_RESET_DELAY_MS);
+		if ((rslt == BMI160_OK) && (dev->interface == BMI160_SPI_INTF)) {
+			/* Dummy read of 0x7F register to enable SPI Interface
+			if SPI is used */
+			rslt = bmi160_get_regs(BMI160_SPI_COMM_TEST_ADDR, &data, 1, dev);
 		}
-	} else {
-	com_rslt = E_BMI160_OUT_OF_RANGE;
 	}
+
+	return rslt;
 }
-return com_rslt;
-}
- /*!
- *	@brief This API reads orientation axes changes
- *	from the register 0x66 bit 7
- *
- *  @param v_orient_axes_u8 : The value of orient axes assignment
- *	value    |       Behaviour    | Name
- * ----------|--------------------|------
- *  0x00     | x = x, y = y, z = z|orient_ax_noex
- *  0x01     | x = y, y = z, z = x|orient_ax_ex
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
+
+/*!
+ * @brief This API configures the power mode, range and bandwidth
+ * of sensor.
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_axes_enable(
-u8 *v_orient_axes_u8)
+int8_t bmi160_set_sens_conf(struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read orientation axes changes  */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_orient_axes_u8 = BMI160_GET_BITSLICE
-			(v_data_u8,
-			BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX);
+	int8_t rslt = BMI160_OK;
+
+	/* Null-pointer check */
+	if ((dev == NULL) || (dev->delay_ms == NULL)) {
+		rslt = BMI160_E_NULL_PTR;
+	} else {
+		rslt = set_accel_conf(dev);
+		if (rslt == BMI160_OK) {
+			rslt = set_gyro_conf(dev);
+			if (rslt == BMI160_OK) {
+				/* write power mode for accel and gyro */
+				rslt = bmi160_set_power_mode(dev);
+				if (rslt == BMI160_OK)
+					rslt = check_invalid_settg(dev);
+			}
 		}
-	return com_rslt;
+	}
+
+	return rslt;
 }
- /*!
- *	@brief This API writes orientation axes changes
- *	in the register 0x66 bit 7
- *
- *  @param v_orient_axes_u8 : The value of orient axes assignment
- *	value    |       Behaviour    | Name
- * ----------|--------------------|------
- *  0x00     | x = x, y = y, z = z|orient_ax_noex
- *  0x01     | x = y, y = z, z = x|orient_ax_ex
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
+
+/*!
+ * @brief This API sets the power mode of the sensor.
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_axes_enable(
-u8 v_orient_axes_u8)
+int8_t bmi160_set_power_mode(struct bmi160_dev *dev)
 {
-/* variable used to 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 for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-	} else {
-	if (v_orient_axes_u8 <= BMI160_MAX_VALUE_ORIENT_AXES) {
-		/*write orientation axes changes  */
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-		(p_bmi160->dev_addr,
-		BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX__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_ORIENT_1_INTR_ORIENT_AXES_EX,
-			v_orient_axes_u8);
-			com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-			/*Accel and Gyro power mode check*/
-			if (bmi160_power_mode_status_u8_g !=
-			BMI160_NORMAL_MODE)
-				/*interface idle time delay */
-				p_bmi160->delay_msec(
-				BMI160_GEN_READ_WRITE_DELAY);
+	int8_t rslt = 0;
 
-		}
+	/* Null-pointer check */
+	if ((dev == NULL) || (dev->delay_ms == NULL)) {
+		rslt = BMI160_E_NULL_PTR;
 	} else {
-	com_rslt = E_BMI160_OUT_OF_RANGE;
+		rslt = set_accel_pwr(dev);
+		if (rslt == BMI160_OK)
+			rslt = set_gyro_pwr(dev);
 	}
+
+	return rslt;
+
 }
-return com_rslt;
-}
- /*!
- *	@brief This API reads Flat angle (0 to 44.8) for flat interrupt
- *	from the register 0x67 bit 0 to 5
- *
- *  @param v_flat_theta_u8 : The value of flat angle
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_flat_theta(
-u8 *v_flat_theta_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read Flat angle*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_FLAT_0_INTR_FLAT_THETA__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_flat_theta_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_FLAT_0_INTR_FLAT_THETA);
-		}
-	return com_rslt;
-}
- /*!
- *	@brief This API writes Flat angle (0 to 44.8) for flat interrupt
- *	in the register 0x67 bit 0 to 5
- *
- *  @param v_flat_theta_u8 : The value of flat angle
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_flat_theta(
-u8 v_flat_theta_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		if (v_flat_theta_u8 <= BMI160_MAX_FLAT_THETA) {
-			/* write Flat angle */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_FLAT_0_INTR_FLAT_THETA__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_FLAT_0_INTR_FLAT_THETA,
-				v_flat_theta_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
-				(p_bmi160->dev_addr,
-				BMI160_USER_INTR_FLAT_0_INTR_FLAT_THETA__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
+
+/*!
+ * @brief This API reads sensor data, stores it in
+ * the bmi160_sensor_data structure pointer passed by the user.
+ */
+int8_t bmi160_get_sensor_data(uint8_t select_sensor, struct bmi160_sensor_data *accel, struct bmi160_sensor_data *gyro,
+				const struct bmi160_dev *dev)
+{
+	int8_t rslt = BMI160_OK;
+	uint8_t time_sel;
+	uint8_t sen_sel;
+	uint8_t len = 0;
+
+	/*Extract the sensor  and time select information*/
+	sen_sel = select_sensor & BMI160_SEN_SEL_MASK;
+	time_sel = ((sen_sel & BMI160_TIME_SEL) >> 2);
+	sen_sel = sen_sel & (BMI160_ACCEL_SEL | BMI160_GYRO_SEL);
+	if (time_sel == 1)
+		len = 3;
+
+	/* Null-pointer check */
+	if (dev != NULL) {
+		switch (sen_sel) {
+		case BMI160_ACCEL_ONLY:
+			/* Null-pointer check */
+			if (accel == NULL)
+				rslt = BMI160_E_NULL_PTR;
+			else
+				rslt = get_accel_data(len, accel, dev);
+			break;
+		case BMI160_GYRO_ONLY:
+			/* Null-pointer check */
+			if (gyro == NULL)
+				rslt = BMI160_E_NULL_PTR;
+			else
+				rslt = get_gyro_data(len, gyro, dev);
+			break;
+		case BMI160_BOTH_ACCEL_AND_GYRO:
+			/* Null-pointer check */
+			if ((gyro == NULL) || (accel == NULL))
+				rslt = BMI160_E_NULL_PTR;
+			else
+				rslt = get_accel_gyro_data(len, accel, gyro, dev);
+			break;
+		default:
+			rslt = BMI160_E_INVALID_INPUT;
+			break;
 		}
+	} else {
+		rslt = BMI160_E_NULL_PTR;
 	}
-	return com_rslt;
+
+	return rslt;
+
 }
+
 /*!
- *	@brief This API reads Flat interrupt hold time;
- *	from the register 0x68 bit 4 and 5
- *
- *  @param v_flat_hold_u8 : The value of flat hold time
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | 0ms
- *  0x01     | 512ms
- *  0x01     | 1024ms
- *  0x01     | 2048ms
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_flat_hold(
-u8 *v_flat_hold_u8)
+ * @brief This API configures the necessary interrupt based on
+ *  the user settings in the bmi160_int_settg structure instance.
+ */
+int8_t bmi160_set_int_config(struct bmi160_int_settg *int_config, struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read flat hold time*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_INTR_FLAT_1_INTR_FLAT_HOLD__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_flat_hold_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_INTR_FLAT_1_INTR_FLAT_HOLD);
-		}
-	return com_rslt;
+	int8_t rslt = BMI160_OK;
+
+	switch (int_config->int_type) {
+	case BMI160_ACC_ANY_MOTION_INT:
+		/*Any-motion  interrupt*/
+		rslt = set_accel_any_motion_int(int_config, dev);
+		break;
+	case BMI160_ACC_SIG_MOTION_INT:
+		/* Significant motion interrupt */
+		rslt = set_accel_sig_motion_int(int_config, dev);
+		break;
+	case BMI160_ACC_SLOW_NO_MOTION_INT:
+		/* Slow or no motion interrupt */
+		rslt = set_accel_no_motion_int(int_config, dev);
+		break;
+	case BMI160_ACC_DOUBLE_TAP_INT:
+	case BMI160_ACC_SINGLE_TAP_INT:
+		 /* Double tap and single tap Interrupt */
+		rslt = set_accel_tap_int(int_config, dev);
+		break;
+	case BMI160_STEP_DETECT_INT:
+		/* Step detector interrupt */
+		rslt = set_accel_step_detect_int(int_config, dev);
+		break;
+	case BMI160_ACC_ORIENT_INT:
+		/* Orientation interrupt */
+		rslt = set_accel_orientation_int(int_config, dev);
+		break;
+	case BMI160_ACC_FLAT_INT:
+		/* Flat detection interrupt */
+		rslt = set_accel_flat_detect_int(int_config, dev);
+		break;
+	case BMI160_ACC_LOW_G_INT:
+		 /* Low-g interrupt */
+		rslt = set_accel_low_g_int(int_config, dev);
+		break;
+	case BMI160_ACC_HIGH_G_INT:
+		/* High-g interrupt */
+		rslt = set_accel_high_g_int(int_config, dev);
+		break;
+	case BMI160_ACC_GYRO_DATA_RDY_INT:
+		/* Data ready interrupt */
+		rslt = set_accel_gyro_data_ready_int(int_config, dev);
+		break;
+	case BMI160_ACC_GYRO_FIFO_FULL_INT:
+		 /* Fifo full interrupt */
+		rslt = set_fifo_full_int(int_config, dev);
+		break;
+	case BMI160_ACC_GYRO_FIFO_WATERMARK_INT:
+		 /* Fifo water-mark interrupt */
+		rslt = set_fifo_watermark_int(int_config, dev);
+		break;
+	default:
+		break;
+	}
+	return rslt;
 }
+
 /*!
- *	@brief This API writes flat interrupt hold time in
- *	the register 0x68 bit 4 and 5
- *
- *  @param v_flat_hold_u8 : The value of flat hold time
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | 0ms
- *  0x01     | 512ms
- *  0x01     | 1024ms
- *  0x01     | 2048ms
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_flat_hold(
-u8 v_flat_hold_u8)
+ * @brief This API enables or disable the step counter feature.
+ * 1 - enable step counter (0 - disable)
+ */
+int8_t bmi160_set_step_counter(uint8_t step_cnt_enable, const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		if (v_flat_hold_u8 <= BMI160_MAX_FLAT_HOLD) {
-			/* write flat hold time*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_INTR_FLAT_1_INTR_FLAT_HOLD__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_FLAT_1_INTR_FLAT_HOLD,
-				v_flat_hold_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
-				(p_bmi160->dev_addr,
-				BMI160_USER_INTR_FLAT_1_INTR_FLAT_HOLD__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
+	int8_t rslt;
+	uint8_t data = 0;
+
+	/* Null-pointer check */
+	rslt = null_ptr_check(dev);
+
+	if (rslt != BMI160_OK) {
+		rslt = BMI160_E_NULL_PTR;
+	} else {
+
+		rslt = bmi160_get_regs(BMI160_INT_STEP_CONFIG_1_ADDR, &data, 1, dev);
+		if (rslt == BMI160_OK) {
+			if (step_cnt_enable == BMI160_ENABLE)
+				data |= (uint8_t)(step_cnt_enable << 3);
+			else
+				data &= ~BMI160_STEP_COUNT_EN_BIT_MASK;
+			rslt = bmi160_set_regs(BMI160_INT_STEP_CONFIG_1_ADDR, &data, 1, dev);
 		}
 	}
-	return com_rslt;
+
+	return rslt;
 }
+
 /*!
- *	@brief This API reads flat interrupt hysteresis
- *	from the register 0x68 bit 0 to 3
- *
- *  @param v_flat_hyst_u8 : The value of flat hysteresis
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_flat_hyst(
-u8 *v_flat_hyst_u8)
+ * @brief This API reads the step counter value.
+ */
+int8_t bmi160_read_step_counter(uint16_t *step_val, const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read the flat hysteresis*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_INTR_FLAT_1_INTR_FLAT_HYST__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_flat_hyst_u8 = BMI160_GET_BITSLICE(
-			v_data_u8,
-			BMI160_USER_INTR_FLAT_1_INTR_FLAT_HYST);
+	int8_t rslt;
+	uint8_t data[2] = {0, 0};
+	uint16_t msb = 0;
+	uint8_t lsb = 0;
+
+	/* Null-pointer check */
+	rslt = null_ptr_check(dev);
+
+	if (rslt != BMI160_OK) {
+		rslt = BMI160_E_NULL_PTR;
+	} else {
+		rslt = bmi160_get_regs(BMI160_INT_STEP_CNT_0_ADDR, data, 2, dev);
+		if (rslt == BMI160_OK) {
+			lsb = data[0];
+			msb = data[1] << 8;
+			*step_val = msb | lsb;
 		}
-	return com_rslt;
+	}
+
+	return rslt;
 }
+
 /*!
- *	@brief This API writes flat interrupt hysteresis
- *	in the register 0x68 bit 0 to 3
- *
- *  @param v_flat_hyst_u8 : The value of flat hysteresis
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_flat_hyst(
-u8 v_flat_hyst_u8)
+ * @brief This API reads the mention no of byte of data from the given
+ * register address of auxiliary sensor.
+ */
+int8_t bmi160_aux_read(uint8_t reg_addr, uint8_t *aux_data, uint16_t len, const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		if (v_flat_hyst_u8 <= BMI160_MAX_FLAT_HYST) {
-			/* read the flat hysteresis*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_INTR_FLAT_1_INTR_FLAT_HYST__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_FLAT_1_INTR_FLAT_HYST,
-				v_flat_hyst_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
-				(p_bmi160->dev_addr,
-				BMI160_USER_INTR_FLAT_1_INTR_FLAT_HYST__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
+	int8_t rslt = BMI160_OK;
+	uint16_t map_len = 0;
+
+	/* Null-pointer check */
+	if ((dev == NULL) || (dev->read == NULL)) {
+		rslt = BMI160_E_NULL_PTR;
+	} else {
+		if (dev->aux_cfg.aux_sensor_enable == BMI160_ENABLE) {
+			rslt = map_read_len(&map_len, dev);
+			if (rslt == BMI160_OK)
+				rslt = extract_aux_read(map_len, reg_addr, aux_data, len, dev);
 		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
+			rslt = BMI160_E_INVALID_INPUT;
 		}
 	}
-	return com_rslt;
-}
- /*!
- *	@brief This API reads Accel offset compensation
- *	target value for z-axis from the register 0x69 bit 0 and 1
- *
- *  @param v_foc_accel_z_u8 : the value of Accel offset compensation z axis
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | disable
- *  0x01     | +1g
- *  0x01     | -1g
- *  0x01     | 0g
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_accel_z(u8 *v_foc_accel_z_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read the Accel offset compensation for z axis*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_FOC_ACCEL_Z__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_foc_accel_z_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_FOC_ACCEL_Z);
-		}
-	return com_rslt;
+
+	return rslt;
 }
- /*!
- *	@brief This API writes Accel offset compensation
- *	target value for z-axis in the register 0x69 bit 0 and 1
- *
- *  @param v_foc_accel_z_u8 : the value of Accel offset compensation z axis
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | disable
- *  0x01     | +1g
- *  0x01     | -1g
- *  0x01     | 0g
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_foc_accel_z(
-u8 v_foc_accel_z_u8)
+
+/*!
+ * @brief This API writes the mention no of byte of data to the given
+ * register address of auxiliary sensor.
+ */
+int8_t bmi160_aux_write(uint8_t reg_addr, uint8_t *aux_data, uint16_t len, const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* write the Accel offset compensation for z axis*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_FOC_ACCEL_Z__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_FOC_ACCEL_Z,
-				v_foc_accel_z_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
-				(p_bmi160->dev_addr,
-				BMI160_USER_FOC_ACCEL_Z__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	int8_t rslt = BMI160_OK;
+	uint8_t count = 0;
+
+	/* Null-pointer check */
+	if ((dev == NULL) || (dev->write == NULL)) {
+		rslt = BMI160_E_NULL_PTR;
+	} else {
+		for (; count < len; count++) {
+			/* set data to write */
+			rslt = bmi160_set_regs(BMI160_AUX_IF_4_ADDR, aux_data, 1, dev);
+			dev->delay_ms(BMI160_AUX_COM_DELAY);
+			if (rslt == BMI160_OK) {
+				/* set address to write */
+				rslt = bmi160_set_regs(BMI160_AUX_IF_3_ADDR, &reg_addr, 1, dev);
+				dev->delay_ms(BMI160_AUX_COM_DELAY);
+				if (rslt == BMI160_OK && (count < len - 1)) {
+					aux_data++;
+					reg_addr++;
+				}
 			}
+		}
 	}
-	return com_rslt;
+
+	return rslt;
 }
+
 /*!
- *	@brief This API reads Accel offset compensation
- *	target value for y-axis
- *	from the register 0x69 bit 2 and 3
- *
- *  @param v_foc_accel_y_u8 : the value of Accel offset compensation y axis
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | disable
- *  0x01     | +1g
- *  0x01     | -1g
- *  0x01     | 0g
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_accel_y(u8 *v_foc_accel_y_u8)
+ * @brief This API initialize the auxiliary sensor
+ * in order to access it.
+ */
+int8_t bmi160_aux_init(const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
+	int8_t rslt;
+
+	/* Null-pointer check */
+	rslt = null_ptr_check(dev);
+
+	if (rslt != BMI160_OK) {
+		rslt = BMI160_E_NULL_PTR;
+	} else {
+		if (dev->aux_cfg.aux_sensor_enable == BMI160_ENABLE) {
+			/* Configures the auxiliary sensor interface settings */
+			rslt = config_aux_settg(dev);
 		} else {
-			/* read the Accel offset compensation for y axis*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_FOC_ACCEL_Y__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_foc_accel_y_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_FOC_ACCEL_Y);
+			rslt = BMI160_E_INVALID_INPUT;
 		}
-	return com_rslt;
+	}
+
+	return rslt;
 }
+
 /*!
- *	@brief This API writes Accel offset compensation
- *	target value for y-axis in the register 0x69 bit 2 and 3
- *
- *  @param v_foc_accel_y_u8 : the value of Accel offset compensation y axis
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | disable
- *  0x01     | +1g
- *  0x02     | -1g
- *  0x03     | 0g
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_foc_accel_y(u8 v_foc_accel_y_u8)
+ * @brief This API is used to setup the auxiliary sensor of bmi160 in auto mode
+ * Thus enabling the auto update of 8 bytes of data from auxiliary sensor
+ * to BMI160 register address 0x04 to 0x0B
+ */
+int8_t bmi160_set_aux_auto_mode(uint8_t *data_addr, struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		if (v_foc_accel_y_u8 <= BMI160_MAX_ACCEL_FOC) {
-			/* write the Accel offset compensation for y axis*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_FOC_ACCEL_Y__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_FOC_ACCEL_Y,
-				v_foc_accel_y_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
-				(p_bmi160->dev_addr,
-				BMI160_USER_FOC_ACCEL_Y__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	int8_t rslt;
+
+	/* Null-pointer check */
+	rslt = null_ptr_check(dev);
+
+	if (rslt != BMI160_OK) {
+		rslt = BMI160_E_NULL_PTR;
+	} else {
+		if (dev->aux_cfg.aux_sensor_enable == BMI160_ENABLE) {
+			/* Write the aux. address to read in 0x4D of BMI160*/
+			rslt = bmi160_set_regs(BMI160_AUX_IF_2_ADDR, data_addr, 1, dev);
+			dev->delay_ms(BMI160_AUX_COM_DELAY);
+			if (rslt == BMI160_OK) {
+				/* Disable the aux. manual mode, i.e aux.
+				sensor is in auto-mode (data-mode) */
+				dev->aux_cfg.manual_enable = BMI160_DISABLE;
+				rslt = bmi160_config_aux_mode(dev);
+				/* Auxiliary sensor data is obtained
+				   in auto mode from this point */
+				if (rslt == BMI160_OK) {
+					/* Configure the polling ODR for
+					auxiliary sensor */
+					rslt = config_aux_odr(dev);
+				}
 			}
 		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
+			rslt = BMI160_E_INVALID_INPUT;
 		}
 	}
-	return com_rslt;
+
+	return rslt;
 }
+
 /*!
- *	@brief This API reads Accel offset compensation
- *	target value for x-axis from the register 0x69 bit 4 and 5
- *
- *  @param v_foc_accel_x_u8 : the value of Accel offset compensation x axis
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | disable
- *  0x01     | +1g
- *  0x02     | -1g
- *  0x03     | 0g
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_accel_x(u8 *v_foc_accel_x_u8)
+ * @brief This API configures the 0x4C register and settings like
+ * Auxiliary sensor manual enable/ disable and aux burst read length.
+ */
+int8_t bmi160_config_aux_mode(const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		/* read the Accel offset compensation for x axis*/
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-		p_bmi160->dev_addr,
-		BMI160_USER_FOC_ACCEL_X__REG,
-		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		*v_foc_accel_x_u8 = BMI160_GET_BITSLICE(v_data_u8,
-		BMI160_USER_FOC_ACCEL_X);
+	int8_t rslt;
+	uint8_t aux_if[2] = {(uint8_t)(dev->aux_cfg.aux_i2c_addr * 2), 0};
+
+	rslt = bmi160_get_regs(BMI160_AUX_IF_1_ADDR, &aux_if[1], 1, dev);
+	if (rslt == BMI160_OK) {
+		/* update the Auxiliary interface to manual/auto mode */
+		aux_if[1] = BMI160_SET_BITS(aux_if[1], BMI160_MANUAL_MODE_EN, dev->aux_cfg.manual_enable);
+		/* update the burst read length defined by user */
+		aux_if[1] = BMI160_SET_BITS_POS_0(aux_if[1], BMI160_AUX_READ_BURST, dev->aux_cfg.aux_rd_burst_len);
+		/* Set the secondary interface address and manual mode
+		 * along with burst read length */
+		rslt = bmi160_set_regs(BMI160_AUX_IF_0_ADDR, &aux_if[0], 2, dev);
+		dev->delay_ms(BMI160_AUX_COM_DELAY);
 	}
-	return com_rslt;
+
+	return rslt;
 }
+
 /*!
- *	@brief This API writes Accel offset compensation
- *	target value for x-axis in the register 0x69 bit 4 and 5
- *
- *  @param v_foc_accel_x_u8 : the value of Accel offset compensation x axis
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | disable
- *  0x01     | +1g
- *  0x01     | -1g
- *  0x01     | 0g
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_foc_accel_x(u8 v_foc_accel_x_u8)
+ * @brief This API is used to read the raw uncompensated auxiliary sensor
+ * data of 8 bytes from BMI160 register address 0x04 to 0x0B
+ */
+int8_t bmi160_read_aux_data_auto_mode(uint8_t *aux_data, const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		if (v_foc_accel_x_u8 <= BMI160_MAX_ACCEL_FOC) {
-			/* write the Accel offset compensation for x axis*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_FOC_ACCEL_X__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_FOC_ACCEL_X,
-				v_foc_accel_x_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_FOC_ACCEL_X__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			}
+	int8_t rslt;
+
+	/* Null-pointer check */
+	rslt = null_ptr_check(dev);
+
+	if (rslt != BMI160_OK) {
+		rslt = BMI160_E_NULL_PTR;
+	} else {
+		if ((dev->aux_cfg.aux_sensor_enable == BMI160_ENABLE) &&
+			(dev->aux_cfg.manual_enable == BMI160_DISABLE)) {
+			/* Read the aux. sensor's raw data */
+			rslt = bmi160_get_regs(BMI160_AUX_DATA_ADDR, aux_data, 8, dev);
 		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
+			rslt = BMI160_E_INVALID_INPUT;
 		}
 	}
-	return com_rslt;
+
+	return rslt;
 }
+
 /*!
- *	@brief This API writes Accel fast offset compensation
- *	from the register 0x69 bit 0 to 5
- *	@brief This API writes each axis individually
- *	FOC_X_AXIS - bit 4 and 5
- *	FOC_Y_AXIS - bit 2 and 3
- *	FOC_Z_AXIS - bit 0 and 1
- *
- *  @param  v_foc_accel_u8: The value of Accel offset compensation
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | disable
- *  0x01     | +1g
- *  0x01     | -1g
- *  0x01     | 0g
- *
- *  @param  v_axis_u8: The value of Accel offset axis selection
-  *	value    | axis
- * ----------|-------------------
- *  0        | FOC_X_AXIS
- *  1        | FOC_Y_AXIS
- *  2        | FOC_Z_AXIS
- *
- *	@param v_accel_offset_s8: The Accel offset value
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_foc_trigger(u8 v_axis_u8,
-u8 v_foc_accel_u8, s8 *v_accel_offset_s8)
+ * @brief This is used to perform self test of accel/gyro of the BMI160 sensor
+ */
+int8_t bmi160_perform_self_test(uint8_t select_sensor, struct bmi160_dev *dev)
 {
-/* variable used to return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-s8 v_status_s8 = SUCCESS;
-u8 v_timeout_u8 = BMI160_INIT_VALUE;
-s8 v_foc_accel_offset_x_s8  = BMI160_INIT_VALUE;
-s8 v_foc_accel_offset_y_s8 =  BMI160_INIT_VALUE;
-s8 v_foc_accel_offset_z_s8 =  BMI160_INIT_VALUE;
-u8 focstatus = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-} else {
-	v_status_s8 = bmi160_set_accel_offset_enable(
-	ACCEL_OFFSET_ENABLE);
-	if (v_status_s8 == SUCCESS) {
-		switch (v_axis_u8) {
-		case FOC_X_AXIS:
-			com_rslt =
-			p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_FOC_ACCEL_X__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_FOC_ACCEL_X,
-				v_foc_accel_u8);
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_FOC_ACCEL_X__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			}
-
-			/* trigger the FOC */
-			com_rslt +=
-			bmi160_set_command_register(
-			START_FOC_ACCEL_GYRO);
-
-			com_rslt +=
-			bmi160_get_foc_rdy(&focstatus);
-			if ((com_rslt != SUCCESS) ||
-			(focstatus != BMI160_FOC_STAT_HIGH)) {
-				while ((com_rslt != SUCCESS) ||
-				(focstatus != BMI160_FOC_STAT_HIGH
-				&& v_timeout_u8 <
-				BMI160_MAXIMUM_TIMEOUT)) {
-					p_bmi160->delay_msec(
-					BMI160_DELAY_SETTLING_TIME);
-					com_rslt = bmi160_get_foc_rdy(
-					&focstatus);
-					v_timeout_u8++;
-				}
-			}
-			if ((com_rslt == SUCCESS) &&
-				(focstatus == BMI160_FOC_STAT_HIGH)) {
-				com_rslt +=
-				bmi160_get_accel_offset_compensation_xaxis(
-				&v_foc_accel_offset_x_s8);
-				*v_accel_offset_s8 =
-				v_foc_accel_offset_x_s8;
-			}
-		break;
-		case FOC_Y_AXIS:
-			com_rslt =
-			p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_FOC_ACCEL_Y__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_FOC_ACCEL_Y,
-				v_foc_accel_u8);
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_FOC_ACCEL_Y__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			}
+	int8_t rslt;
+	int8_t self_test_rslt = 0;
 
-			/* trigger the FOC */
-			com_rslt +=
-			bmi160_set_command_register(
-			START_FOC_ACCEL_GYRO);
-
-			com_rslt +=
-			bmi160_get_foc_rdy(&focstatus);
-			if ((com_rslt != SUCCESS) ||
-			(focstatus != BMI160_FOC_STAT_HIGH)) {
-				while ((com_rslt != SUCCESS) ||
-				(focstatus != BMI160_FOC_STAT_HIGH
-				&& v_timeout_u8 <
-				BMI160_MAXIMUM_TIMEOUT)) {
-					p_bmi160->delay_msec(
-					BMI160_DELAY_SETTLING_TIME);
-					com_rslt = bmi160_get_foc_rdy(
-					&focstatus);
-					v_timeout_u8++;
-				}
-			}
-			if ((com_rslt == SUCCESS) &&
-			(focstatus == BMI160_FOC_STAT_HIGH)) {
-				com_rslt +=
-				bmi160_get_accel_offset_compensation_yaxis(
-				&v_foc_accel_offset_y_s8);
-				*v_accel_offset_s8 =
-				v_foc_accel_offset_y_s8;
-			}
-		break;
-		case FOC_Z_AXIS:
-			com_rslt =
-			p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_FOC_ACCEL_Z__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_FOC_ACCEL_Z,
-				v_foc_accel_u8);
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_FOC_ACCEL_Z__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			}
+	/* Null-pointer check */
+	rslt = null_ptr_check(dev);
 
-			/* trigger the FOC */
-			com_rslt +=
-			bmi160_set_command_register(
-			START_FOC_ACCEL_GYRO);
-
-			com_rslt +=
-			bmi160_get_foc_rdy(&focstatus);
-			if ((com_rslt != SUCCESS) ||
-			(focstatus != BMI160_FOC_STAT_HIGH)) {
-				while ((com_rslt != SUCCESS) ||
-				(focstatus != BMI160_FOC_STAT_HIGH
-				&& v_timeout_u8 <
-				BMI160_MAXIMUM_TIMEOUT)) {
-					p_bmi160->delay_msec(
-					BMI160_DELAY_SETTLING_TIME);
-					com_rslt = bmi160_get_foc_rdy(
-					&focstatus);
-					v_timeout_u8++;
-				}
-			}
-			if ((com_rslt == SUCCESS) &&
-			(focstatus == BMI160_FOC_STAT_HIGH)) {
-				com_rslt +=
-				bmi160_get_accel_offset_compensation_zaxis(
-				&v_foc_accel_offset_z_s8);
-				*v_accel_offset_s8 =
-				v_foc_accel_offset_z_s8;
+	if (rslt != BMI160_OK) {
+		rslt = BMI160_E_NULL_PTR;
+	} else {
+		/* Proceed if null check is fine */
+		switch (select_sensor) {
+		case BMI160_ACCEL_ONLY:
+			rslt = perform_accel_self_test(dev);
+			break;
+
+		case BMI160_GYRO_ONLY:
+			/* Set the power mode as normal mode */
+			dev->gyro_cfg.power = BMI160_GYRO_NORMAL_MODE;
+			rslt = bmi160_set_power_mode(dev);
+			/* Perform gyro self test */
+			if (rslt == BMI160_OK) {
+				/* Perform gyro self test */
+				rslt = perform_gyro_self_test(dev);
 			}
-		break;
+			break;
+
 		default:
-		break;
+			rslt = BMI160_E_INVALID_INPUT;
+			break;
 		}
-	} else {
-	com_rslt =  ERROR;
+
+		/* Check to ensure bus error does not occur */
+		if (rslt >= BMI160_OK) {
+			/* Store the status of self test result */
+			self_test_rslt = rslt;
+			/* Perform soft reset */
+			rslt = bmi160_soft_reset(dev);
+		}
+		/* Check to ensure bus operations are success */
+		if (rslt == BMI160_OK) {
+			/* Restore self_test_rslt as return value */
+			rslt = self_test_rslt;
+		}
+
 	}
+
+	return rslt;
 }
-return com_rslt;
-}
+
+
+
 /*!
- *	@brief This API writes fast Accel offset compensation
- *	for all axis in the register 0x69 bit 0 to 5
- *	FOC_X_AXIS - bit 4 and 5
- *	FOC_Y_AXIS - bit 2 and 3
- *	FOC_Z_AXIS - bit 0 and 1
- *
- *  @param  v_foc_accel_x_u8: The value of Accel offset x compensation
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | disable
- *  0x01     | +1g
- *  0x01     | -1g
- *  0x01     | 0g
- *
- *  @param  v_foc_accel_y_u8: The value of Accel offset y compensation
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | disable
- *  0x01     | +1g
- *  0x01     | -1g
- *  0x01     | 0g
- *
- *  @param  v_foc_accel_z_u8: The value of Accel offset z compensation
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | disable
- *  0x01     | +1g
- *  0x01     | -1g
- *  0x01     | 0g
- *
- *  @param  v_accel_off_x_s8: The value of Accel offset x axis
- *  @param  v_accel_off_y_s8: The value of Accel offset y axis
- *  @param  v_accel_off_z_s8: The value of Accel offset z axis
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_accel_foc_trigger_xyz(u8 v_foc_accel_x_u8,
-u8 v_foc_accel_y_u8, u8 v_foc_accel_z_u8, s8 *v_accel_off_x_s8,
-s8 *v_accel_off_y_s8, s8 *v_accel_off_z_s8)
+ * @brief This API reads the data from fifo buffer.
+ */
+int8_t bmi160_get_fifo_data(struct bmi160_dev const *dev)
 {
-/* variable used to return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 focx = BMI160_INIT_VALUE;
-u8 focy = BMI160_INIT_VALUE;
-u8 focz = BMI160_INIT_VALUE;
-s8 v_foc_accel_offset_x_s8 = BMI160_INIT_VALUE;
-s8 v_foc_accel_offset_y_s8 = BMI160_INIT_VALUE;
-s8 v_foc_accel_offset_z_s8 = BMI160_INIT_VALUE;
-u8 v_status_s8 = SUCCESS;
-u8 v_timeout_u8 = BMI160_INIT_VALUE;
-u8 focstatus = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-	} else {
-		v_status_s8 = bmi160_set_accel_offset_enable(
-		ACCEL_OFFSET_ENABLE);
-		if (v_status_s8 == SUCCESS) {
-			/* foc x axis*/
-			com_rslt =
-			p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_FOC_ACCEL_X__REG,
-			&focx, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			if (com_rslt == SUCCESS) {
-				focx = BMI160_SET_BITSLICE(focx,
-				BMI160_USER_FOC_ACCEL_X,
-				v_foc_accel_x_u8);
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_FOC_ACCEL_X__REG,
-				&focx, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			}
+	int8_t rslt = 0;
+	uint16_t bytes_to_read = 0;
+	uint16_t user_fifo_len = 0;
+	uint8_t addr = BMI160_FIFO_DATA_ADDR;
 
-			/* foc y axis*/
-			com_rslt +=
-			p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_FOC_ACCEL_Y__REG,
-			&focy, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			if (com_rslt == SUCCESS) {
-				focy = BMI160_SET_BITSLICE(focy,
-				BMI160_USER_FOC_ACCEL_Y,
-				v_foc_accel_y_u8);
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_FOC_ACCEL_Y__REG,
-				&focy, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+	/* check the bmi160 structure as NULL*/
+	if (dev == NULL || dev->fifo->data == NULL) {
+		rslt = BMI160_E_NULL_PTR;
+	} else {
+		reset_fifo_data_structure(dev);
+		/* get current FIFO fill-level*/
+		rslt = get_fifo_byte_counter(&bytes_to_read, dev);
+		if (rslt == BMI160_OK) {
+			user_fifo_len = dev->fifo->length;
+			if (dev->fifo->length > bytes_to_read) {
+				/* Handling the case where user requests
+				more data than available in FIFO */
+				dev->fifo->length = bytes_to_read;
 			}
 
-			/* foc z axis*/
-			com_rslt +=
-			p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_FOC_ACCEL_Z__REG,
-			&focz, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			if (com_rslt == SUCCESS) {
-				focz = BMI160_SET_BITSLICE(focz,
-				BMI160_USER_FOC_ACCEL_Z,
-				v_foc_accel_z_u8);
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_FOC_ACCEL_Z__REG,
-				&focz, BMI160_GEN_READ_WRITE_DATA_LENGTH);
+			if ((dev->fifo->fifo_time_enable == BMI160_FIFO_TIME_ENABLE) &&  (bytes_to_read + 4 <= user_fifo_len)) {
+				/* Handling case of sensor time availability */
+				dev->fifo->length = dev->fifo->length + 4;
 			}
 
-			/* trigger the FOC */
-			com_rslt += bmi160_set_command_register(
-			START_FOC_ACCEL_GYRO);
-
-			com_rslt += bmi160_get_foc_rdy(
-			&focstatus);
-			if ((com_rslt != SUCCESS) ||
-			(focstatus != BMI160_FOC_STAT_HIGH)) {
-				while ((com_rslt != SUCCESS) ||
-				(focstatus != BMI160_FOC_STAT_HIGH
-				&& v_timeout_u8 <
-				BMI160_MAXIMUM_TIMEOUT)) {
-					p_bmi160->delay_msec(
-					BMI160_DELAY_SETTLING_TIME);
-					com_rslt = bmi160_get_foc_rdy(
-					&focstatus);
-					v_timeout_u8++;
-				}
-			}
-			if ((com_rslt == SUCCESS) &&
-			(focstatus == BMI160_GEN_READ_WRITE_DATA_LENGTH)) {
-				com_rslt +=
-				bmi160_get_accel_offset_compensation_xaxis(
-				&v_foc_accel_offset_x_s8);
-				*v_accel_off_x_s8 =
-				v_foc_accel_offset_x_s8;
-				com_rslt +=
-				bmi160_get_accel_offset_compensation_yaxis(
-				&v_foc_accel_offset_y_s8);
-				*v_accel_off_y_s8 =
-				v_foc_accel_offset_y_s8;
-				com_rslt +=
-				bmi160_get_accel_offset_compensation_zaxis(
-				&v_foc_accel_offset_z_s8);
-				*v_accel_off_z_s8 =
-				v_foc_accel_offset_z_s8;
-			}
-		} else {
-		com_rslt =  ERROR;
+			/* read only the filled bytes in the FIFO Buffer */
+			rslt = dev->read(dev->id, addr, dev->fifo->data, dev->fifo->length);
 		}
 	}
-return com_rslt;
+
+	return rslt;
 }
+
 /*!
- *	@brief This API reads the gyro fast offset enable
- *	from the register 0x69 bit 6
- *
- *  @param v_foc_gyro_u8 : The value of gyro fast offset enable
- *  value    |  Description
- * ----------|-------------
- *    0      | fast offset compensation disabled
- *    1      |  fast offset compensation enabled
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_gyro_enable(
-u8 *v_foc_gyro_u8)
+ *  @brief This API writes fifo_flush command to command register.This
+ *  action clears all data in the Fifo without changing fifo configuration
+ *  settings
+ */
+int8_t bmi160_set_fifo_flush(const struct bmi160_dev *dev)
 {
-	/* used to return the status of bus communication */
-	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
-	u8 v_data_u8 = BMI160_INIT_VALUE;
-	/* check the p_bmi160 structure for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read the gyro fast offset enable*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_FOC_GYRO_ENABLE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_foc_gyro_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_FOC_GYRO_ENABLE);
-		}
-	return com_rslt;
+	int8_t rslt = 0;
+	uint8_t data =  BMI160_FIFO_FLUSH_VALUE;
+	uint8_t reg_addr = BMI160_COMMAND_REG_ADDR;
+
+	/* Check the bmi160_dev structure for NULL address*/
+	if (dev == NULL)
+		rslt = BMI160_E_NULL_PTR;
+	else
+		rslt = bmi160_set_regs(reg_addr, &data, BMI160_ONE, dev);
+
+	return rslt;
 }
-/*!
- *	@brief This API writes the gyro fast offset enable
- *	from the register 0x69 bit 6
- *
- *  @param v_foc_gyro_u8 : The value of gyro fast offset enable
- *  value    |  Description
- * ----------|-------------
- *    0      | fast offset compensation disabled
- *    1      |  fast offset compensation enabled
- *
- *	@param v_gyro_off_x_s16 : The value of gyro fast offset x axis data
- *	@param v_gyro_off_y_s16 : The value of gyro fast offset y axis data
- *	@param v_gyro_off_z_s16 : The value of gyro fast offset z axis data
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
+
+/*! @brief This API sets the FIFO configuration in the sensor.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_foc_gyro_enable(
-u8 v_foc_gyro_u8, s16 *v_gyro_off_x_s16,
-s16 *v_gyro_off_y_s16, s16 *v_gyro_off_z_s16)
+ */
+int8_t bmi160_set_fifo_config(uint8_t config, uint8_t enable, struct bmi160_dev const *dev)
 {
-/* variable used to 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_status_s8 = SUCCESS;
-u8 v_timeout_u8 = BMI160_INIT_VALUE;
-s16 offsetx = BMI160_INIT_VALUE;
-s16 offsety = BMI160_INIT_VALUE;
-s16 offsetz = BMI160_INIT_VALUE;
-u8 focstatus = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
+	int8_t rslt = 0;
+	uint8_t data =  0;
+	uint8_t reg_addr = BMI160_FIFO_CONFIG_1_ADDR;
+	uint8_t fifo_config = config & BMI160_FIFO_CONFIG_1_MASK;
+
+	/* Check the bmi160_dev structure for NULL address*/
+	if (dev == NULL) {
+		rslt = BMI160_E_NULL_PTR;
 	} else {
-		v_status_s8 = bmi160_set_gyro_offset_enable(
-		GYRO_OFFSET_ENABLE);
-		if (v_status_s8 == SUCCESS) {
-			com_rslt =
-			p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_FOC_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_FOC_GYRO_ENABLE,
-				v_foc_gyro_u8);
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC
-				(p_bmi160->dev_addr,
-				BMI160_USER_FOC_GYRO_ENABLE__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			}
+		rslt = bmi160_get_regs(reg_addr, &data, BMI160_ONE, dev);
 
-			/* trigger the FOC */
-			com_rslt += bmi160_set_command_register
-			(START_FOC_ACCEL_GYRO);
-
-			com_rslt += bmi160_get_foc_rdy(&focstatus);
-			if ((com_rslt != SUCCESS) ||
-			(focstatus != BMI160_FOC_STAT_HIGH)) {
-				while ((com_rslt != SUCCESS) ||
-				(focstatus != BMI160_FOC_STAT_HIGH
-				&& v_timeout_u8 <
-				BMI160_MAXIMUM_TIMEOUT)) {
-					p_bmi160->delay_msec(
-					BMI160_DELAY_SETTLING_TIME);
-					com_rslt = bmi160_get_foc_rdy(
-					&focstatus);
-					v_timeout_u8++;
-				}
+		if (rslt == BMI160_OK) {
+
+			if (fifo_config > 0) {
+
+				if (enable == BMI160_ENABLE)
+					data = data | fifo_config;
+				else
+					data = data & (~fifo_config);
 			}
-			if ((com_rslt == SUCCESS) &&
-			(focstatus == BMI160_FOC_STAT_HIGH)) {
-				com_rslt +=
-				bmi160_get_gyro_offset_compensation_xaxis
-				(&offsetx);
-				*v_gyro_off_x_s16 = offsetx;
-
-				com_rslt +=
-				bmi160_get_gyro_offset_compensation_yaxis
-				(&offsety);
-				*v_gyro_off_y_s16 = offsety;
-
-				com_rslt +=
-				bmi160_get_gyro_offset_compensation_zaxis(
-				&offsetz);
-				*v_gyro_off_z_s16 = offsetz;
+			/* write fifo frame content configuration*/
+			rslt = bmi160_set_regs(reg_addr, &data, BMI160_ONE, dev);
+			if (rslt == BMI160_OK) {
+				/* read fifo frame content configuration*/
+				rslt = bmi160_get_regs(reg_addr, &data, BMI160_ONE, dev);
+				if (rslt == BMI160_OK) {
+					/* extract fifo header enabled status */
+					dev->fifo->fifo_header_enable = data & BMI160_FIFO_HEAD_ENABLE;
+					/* extract accel/gyr/aux. data enabled status */
+					dev->fifo->fifo_data_enable = data & BMI160_FIFO_M_G_A_ENABLE;
+					/* extract fifo sensor time enabled status */
+					dev->fifo->fifo_time_enable = data & BMI160_FIFO_TIME_ENABLE;
+				}
 			}
-		} else {
-		com_rslt = ERROR;
 		}
 	}
-return com_rslt;
-}
 
- /*!
- * @brief This API reads  SPI
- * Interface Mode for primary and OIS interface
- * from the register 0x6B bit 0
- *
- *  @param v_spi3_u8 : The value of SPI mode selection
- *  Value  |  Description
- * --------|-------------
- *   0     |  SPI 4-wire mode
- *   1     |  SPI 3-wire mode
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_spi3(
-u8 *v_spi3_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read SPI mode*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_IF_CONFIG_SPI3__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_spi3_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_IF_CONFIG_SPI3);
-		}
-	return com_rslt;
+	return rslt;
 }
-/*!
- * @brief This API configures SPI
- * Interface Mode for primary and OIS interface
- * in the register 0x6B bit 0
- *
- *  @param v_spi3_u8 : The value of SPI mode selection
- *  Value  |  Description
- * --------|-------------
- *   0     |  SPI 4-wire mode
- *   1     |  SPI 3-wire mode
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
+
+/*! @brief This API is used to configure the down sampling ratios of
+ *  the accel and gyro data for FIFO.Also, it configures filtered or
+ *  pre-filtered data for accel and gyro.
  *
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_spi3(
-u8 v_spi3_u8)
+int8_t bmi160_set_fifo_down(uint8_t fifo_down, const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		if (v_spi3_u8 <= BMI160_MAX_VALUE_SPI3) {
-			/* write SPI mode*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_IF_CONFIG_SPI3__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_IF_CONFIG_SPI3,
-				v_spi3_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_IF_CONFIG_SPI3__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-		}
+	int8_t rslt = 0;
+	uint8_t data =  0;
+	uint8_t reg_addr = BMI160_FIFO_DOWN_ADDR;
+
+	/* Check the bmi160_dev structure for NULL address*/
+	if (dev == NULL) {
+		rslt = BMI160_E_NULL_PTR;
+	} else {
+		rslt = bmi160_get_regs(reg_addr, &data, BMI160_ONE, dev);
+
+		 if (rslt == BMI160_OK) {
+			data = data | fifo_down;
+			rslt = bmi160_set_regs(reg_addr, &data, BMI160_ONE, dev);
+		 }
 	}
-	return com_rslt;
+
+	return rslt;
+
 }
+
 /*!
- *	@brief This API reads I2C Watchdog timer
- *	from the register 0x70 bit 1
- *
- *  @param v_i2c_wdt_u8 : The value of I2C watch dog timer
- *  Value  |  Description
- * --------|-------------
- *   0     |  I2C watchdog v_timeout_u8 after 1 ms
- *   1     |  I2C watchdog v_timeout_u8 after 50 ms
- *
+ *  @brief This API sets the FIFO watermark level in the sensor.
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_i2c_wdt_select(
-u8 *v_i2c_wdt_u8)
+ */
+int8_t bmi160_set_fifo_wm(uint8_t fifo_wm, const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read I2C watch dog timer */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_IF_CONFIG_I2C_WDT_SELECT__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_i2c_wdt_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_IF_CONFIG_I2C_WDT_SELECT);
-		}
-	return com_rslt;
+	int8_t rslt = 0;
+	uint8_t data =  fifo_wm;
+	uint8_t reg_addr = BMI160_FIFO_CONFIG_0_ADDR;
+
+	/* Check the bmi160_dev structure for NULL address*/
+	if (dev == NULL)
+		rslt = BMI160_E_NULL_PTR;
+	else
+		rslt = bmi160_set_regs(reg_addr, &data, BMI160_ONE, dev);
+
+	return rslt;
+
 }
+
 /*!
- *	@brief This API writes the I2C Watchdog timer
- *	in the register 0x70 bit 1
- *
- *  @param v_i2c_wdt_u8 : The value of I2C watch dog timer
- *  Value  |  Description
- * --------|-------------
- *   0     |  I2C watchdog v_timeout_u8 after 1 ms
- *   1     |  I2C watchdog v_timeout_u8 after 50 ms
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_i2c_wdt_select(
-u8 v_i2c_wdt_u8)
+ *  @brief This API parses and extracts the accelerometer frames from
+ *  FIFO data read by the "bmi160_get_fifo_data" API and stores it in
+ *  the "accel_data" structure instance.
+ */
+int8_t bmi160_extract_accel(struct bmi160_sensor_data *accel_data, uint8_t *accel_length, struct bmi160_dev const *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		if (v_i2c_wdt_u8 <= BMI160_MAX_VALUE_I2C_WDT) {
-			/* write I2C watch dog timer */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_IF_CONFIG_I2C_WDT_SELECT__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_IF_CONFIG_I2C_WDT_SELECT,
-				v_i2c_wdt_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_IF_CONFIG_I2C_WDT_SELECT__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
+	int8_t rslt = 0;
+	uint16_t data_index = 0;
+	uint16_t data_read_length = 0;
+	uint8_t accel_index = 0;
+	uint8_t fifo_data_enable = 0;
 
+	if (dev == NULL || dev->fifo == NULL || dev->fifo->data == NULL) {
+		rslt = BMI160_E_NULL_PTR;
+	} else {
+		/* Parsing the FIFO data in header-less mode */
+		if (dev->fifo->fifo_header_enable == 0) {
+			/* Number of bytes to be parsed from FIFO */
+			get_accel_len_to_parse(&data_index, &data_read_length, accel_length, dev);
+			for (; data_index < data_read_length; ) {
+				/*Check for the availability of next two bytes of FIFO data */
+				check_frame_validity(&data_index, dev);
+				fifo_data_enable = dev->fifo->fifo_data_enable;
+				unpack_accel_frame(accel_data, &data_index, &accel_index, fifo_data_enable, dev);
 			}
+			/* update number of accel data read*/
+			*accel_length = accel_index;
+			/*update the accel byte index*/
+			dev->fifo->accel_byte_start_idx = data_index;
 		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
+			/* Parsing the FIFO data in header mode */
+			extract_accel_header_mode(accel_data, &accel_index, dev);
+			*accel_length = accel_index;
 		}
 	}
-	return com_rslt;
-}
-/*!
- *	@brief This API reads the status of I2C watchdog enable
- *	from the register 0x70 bit 2
- *
- *  @param v_i2c_wdt_u8 : The value of I2C watchdog enable
- *  Value  |  Description
- * --------|-------------
- *   0     |  DISABLE
- *   1     |  ENABLE
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_i2c_wdt_enable(
-u8 *v_i2c_wdt_u8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read i2c watch dog enable */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_IF_CONFIG_I2C_WDT_ENABLE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_i2c_wdt_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_IF_CONFIG_I2C_WDT_ENABLE);
-		}
-	return com_rslt;
+
+	return rslt;
 }
+
 /*!
- *	@brief This API enables the I2C watchdog
- *	 in the register 0x70 bit 2
- *
- *  @param v_i2c_wdt_u8 : The value of I2C watchdog enable
- *  Value  |  Description
- * --------|-------------
- *   0     |  DISABLE
- *   1     |  ENABLE
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_i2c_wdt_enable(
-u8 v_i2c_wdt_u8)
+ *  @brief This API parses and extracts the gyro frames from
+ *  FIFO data read by the "bmi160_get_fifo_data" API and stores it in
+ *  the "gyro_data" structure instance.
+ */
+int8_t bmi160_extract_gyro(struct bmi160_sensor_data *gyro_data, uint8_t *gyro_length, struct bmi160_dev const *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		if (v_i2c_wdt_u8 <= BMI160_MAX_VALUE_I2C_WDT) {
-			/* write i2c watch dog enable */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_IF_CONFIG_I2C_WDT_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_IF_CONFIG_I2C_WDT_ENABLE,
-				v_i2c_wdt_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_IF_CONFIG_I2C_WDT_ENABLE__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
+	int8_t rslt = 0;
+	uint16_t data_index = 0;
+	uint16_t data_read_length = 0;
+	uint8_t gyro_index = 0;
+	uint8_t fifo_data_enable = 0;
+
+	if (dev == NULL || dev->fifo->data == NULL) {
+		rslt = BMI160_E_NULL_PTR;
+	} else {
+		/* Parsing the FIFO data in header-less mode */
+		if (dev->fifo->fifo_header_enable == 0) {
+			/* Number of bytes to be parsed from FIFO */
+			get_gyro_len_to_parse(&data_index, &data_read_length, gyro_length, dev);
+			for (; data_index < data_read_length ;) {
+				/*Check for the availability of next two bytes of FIFO data */
+				check_frame_validity(&data_index, dev);
+				fifo_data_enable = dev->fifo->fifo_data_enable;
+				unpack_gyro_frame(gyro_data, &data_index, &gyro_index, fifo_data_enable, dev);
 			}
+			/* update number of gyro data read */
+			*gyro_length = gyro_index;
+			/* update the gyro byte index */
+			dev->fifo->gyro_byte_start_idx = data_index;
 		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
+			/* Parsing the FIFO data in header mode */
+			extract_gyro_header_mode(gyro_data, &gyro_index, dev);
+			*gyro_length = gyro_index;
 		}
 	}
-	return com_rslt;
+
+	return rslt;
 }
+
+/*********************** Local function definitions ***************************/
+
 /*!
- * @brief This API reads the I2C interface configuration(if) mode
- * from the register 0x6B bit 4 and 5
- *
- *  @param  v_if_mode_u8 : The value of interface configuration mode
- *  Value  |  Description
- * --------|-------------
- *   0x00  |  Primary interface:autoconfig / secondary interface:off
- *   0x01  |  Primary interface:I2C / secondary interface:OIS
- *   0x02  |  Primary interface:autoconfig/secondary interface:Mag
- *   0x03  |   Reserved
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_if_mode(
-u8 *v_if_mode_u8)
+ * @brief This API sets the any-motion interrupt of the sensor.
+ * This interrupt occurs when accel values exceeds preset threshold
+ * for a certain period of time.
+ */
+static int8_t set_accel_any_motion_int(struct bmi160_int_settg *int_config, struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read if mode*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_IF_CONFIG_IF_MODE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_if_mode_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_IF_CONFIG_IF_MODE);
-		}
-	return com_rslt;
+	int8_t rslt;
+
+	/* Null-pointer check */
+	rslt = null_ptr_check(dev);
+
+	if ((rslt != BMI160_OK) || (int_config == NULL)) {
+		rslt = BMI160_E_NULL_PTR;
+	} else {
+		/* updating the interrupt structure to local structure */
+		struct bmi160_acc_any_mot_int_cfg *any_motion_int_cfg = &(int_config->int_type_cfg.acc_any_motion_int);
+
+		rslt = enable_accel_any_motion_int(any_motion_int_cfg, dev);
+		if (rslt == BMI160_OK)
+			rslt = config_any_motion_int_settg(int_config, any_motion_int_cfg, dev);
+	}
+
+	return rslt;
 }
+
 /*!
- * @brief This API writes the I2C interface configuration(if) mode
- * in the register 0x6B bit 4 and 5
- *
- *  @param  v_if_mode_u8 : The value of interface configuration mode
- *  Value  |  Description
- * --------|-------------
- *   0x00  |  Primary interface:autoconfig / secondary interface:off
- *   0x01  |  Primary interface:I2C / secondary interface:OIS
- *   0x02  |  Primary interface:autoconfig/secondary interface:Mag
- *   0x03  |   Reserved
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_if_mode(
-u8 v_if_mode_u8)
+ * @brief This API sets tap interrupts.Interrupt is fired when
+ * tap movements happen.
+ */
+static int8_t set_accel_tap_int(struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		if (v_if_mode_u8 <= BMI160_MAX_IF_MODE) {
-			/* write if mode*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_IF_CONFIG_IF_MODE__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_IF_CONFIG_IF_MODE,
-				v_if_mode_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_IF_CONFIG_IF_MODE__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
+	int8_t rslt;
 
+	/* Null-pointer check */
+	rslt = null_ptr_check(dev);
 
-			}
-		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
+	if ((rslt != BMI160_OK) || (int_config == NULL)) {
+		rslt = BMI160_E_NULL_PTR;
+	} else {
+
+		/* updating the interrupt structure to local structure */
+		struct bmi160_acc_tap_int_cfg *tap_int_cfg = &(int_config->int_type_cfg.acc_tap_int);
+
+		rslt = enable_tap_int(int_config, tap_int_cfg, dev);
+		if (rslt == BMI160_OK) {
+			/* Configure Interrupt pins */
+			rslt = set_intr_pin_config(int_config, dev);
+			if (rslt == BMI160_OK)
+				rslt = config_tap_int_settg(int_config, tap_int_cfg, dev);
 		}
 	}
-	return com_rslt;
+	return rslt;
 }
+
 /*!
- *	@brief This API reads the gyro sleep trigger
- *	from the register 0x6C bit 0 to 2
- *
- *  @param v_gyro_sleep_trigger_u8 : The value of gyro sleep trigger
- *  Value  |  Description
- * --------|-------------
- *   0x00  | nomotion: no / Not INT1 pin: no / INT2 pin: no
- *   0x01  | nomotion: no / Not INT1 pin: no / INT2 pin: yes
- *   0x02  | nomotion: no / Not INT1 pin: yes / INT2 pin: no
- *   0x03  | nomotion: no / Not INT1 pin: yes / INT2 pin: yes
- *   0x04  | nomotion: yes / Not INT1 pin: no / INT2 pin: no
- *   0x05  | anymotion: yes / Not INT1 pin: no / INT2 pin: yes
- *   0x06  | anymotion: yes / Not INT1 pin: yes / INT2 pin: no
- *   0x07  | anymotion: yes / Not INT1 pin: yes / INT2 pin: yes
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_sleep_trigger(
-u8 *v_gyro_sleep_trigger_u8)
+ * @brief This API sets the data ready interrupt for both accel and gyro.
+ * This interrupt occurs when new accel and gyro data comes.
+ */
+static int8_t set_accel_gyro_data_ready_int(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read gyro sleep trigger */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_GYRO_SLEEP_TRIGGER__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_gyro_sleep_trigger_u8 =
-			BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_GYRO_SLEEP_TRIGGER);
+	int8_t rslt;
+
+	/* Null-pointer check */
+	rslt = null_ptr_check(dev);
+
+	if ((rslt != BMI160_OK) || (int_config == NULL)) {
+		rslt = BMI160_E_NULL_PTR;
+	} else {
+		rslt = enable_data_ready_int(dev);
+
+		if (rslt == BMI160_OK) {
+			/* Configure Interrupt pins */
+			rslt = set_intr_pin_config(int_config, dev);
+
+			if (rslt == BMI160_OK)
+				rslt = map_data_ready_int(int_config, dev);
 		}
-	return com_rslt;
+	}
+
+	return rslt;
 }
+
 /*!
- *	@brief This API writes the gyro sleep trigger
- *	in the register 0x6C bit 0 to 2
- *
- *  @param v_gyro_sleep_trigger_u8 : The value of gyro sleep trigger
- *  Value  |  Description
- * --------|-------------
- *   0x00  | nomotion: no / Not INT1 pin: no / INT2 pin: no
- *   0x01  | nomotion: no / Not INT1 pin: no / INT2 pin: yes
- *   0x02  | nomotion: no / Not INT1 pin: yes / INT2 pin: no
- *   0x03  | nomotion: no / Not INT1 pin: yes / INT2 pin: yes
- *   0x04  | nomotion: yes / Not INT1 pin: no / INT2 pin: no
- *   0x05  | anymotion: yes / Not INT1 pin: no / INT2 pin: yes
- *   0x06  | anymotion: yes / Not INT1 pin: yes / INT2 pin: no
- *   0x07  | anymotion: yes / Not INT1 pin: yes / INT2 pin: yes
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_sleep_trigger(
-u8 v_gyro_sleep_trigger_u8)
+ * @brief This API sets the significant motion interrupt of the sensor.This
+ * interrupt occurs when there is change in user location.
+ */
+static int8_t set_accel_sig_motion_int(struct bmi160_int_settg *int_config, struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		if (v_gyro_sleep_trigger_u8 <= BMI160_MAX_GYRO_SLEEP_TRIGGER) {
-			/* write gyro sleep trigger */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_GYRO_SLEEP_TRIGGER__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_SLEEP_TRIGGER,
-				v_gyro_sleep_trigger_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_GYRO_SLEEP_TRIGGER__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-		}
+	int8_t rslt;
+
+	/* Null-pointer check */
+	rslt = null_ptr_check(dev);
+
+	if ((rslt != BMI160_OK) || (int_config == NULL)) {
+		rslt = BMI160_E_NULL_PTR;
+	} else {
+		/* updating the interrupt structure to local structure */
+		struct bmi160_acc_sig_mot_int_cfg *sig_mot_int_cfg = &(int_config->int_type_cfg.acc_sig_motion_int);
+
+		rslt = enable_sig_motion_int(sig_mot_int_cfg, dev);
+		if (rslt == BMI160_OK)
+			rslt = config_sig_motion_int_settg(int_config, sig_mot_int_cfg, dev);
 	}
-	return com_rslt;
+
+	return rslt;
 }
+
 /*!
- *	@brief This API reads gyro wakeup trigger
- *	from the register 0x6C bit 3 and 4
- *
- *  @param v_gyro_wakeup_trigger_u8 : The value of gyro wakeup trigger
- *  Value  |  Description
- * --------|-------------
- *   0x00  | anymotion: no / INT1 pin: no
- *   0x01  | anymotion: no / INT1 pin: yes
- *   0x02  | anymotion: yes / INT1 pin: no
- *   0x03  | anymotion: yes / INT1 pin: yes
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_wakeup_trigger(
-u8 *v_gyro_wakeup_trigger_u8)
+ * @brief This API sets the no motion/slow motion interrupt of the sensor.
+ * Slow motion is similar to any motion interrupt.No motion interrupt
+ * occurs when slope bet. two accel values falls below preset threshold
+ * for preset duration.
+ */
+static int8_t set_accel_no_motion_int(struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read gyro wakeup trigger */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_GYRO_WAKEUP_TRIGGER__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_gyro_wakeup_trigger_u8 = BMI160_GET_BITSLICE(
-			v_data_u8,
-			BMI160_USER_GYRO_WAKEUP_TRIGGER);
-	  }
-	return com_rslt;
+	int8_t rslt;
+
+	/* Null-pointer check */
+	rslt = null_ptr_check(dev);
+
+	if ((rslt != BMI160_OK) || (int_config == NULL)) {
+		rslt = BMI160_E_NULL_PTR;
+	} else {
+		/* updating the interrupt structure to local structure */
+		struct bmi160_acc_no_motion_int_cfg *no_mot_int_cfg = &(int_config->int_type_cfg.acc_no_motion_int);
+
+		rslt = enable_no_motion_int(no_mot_int_cfg, dev);
+		if (rslt == BMI160_OK)
+			/* Configure the INT PIN settings*/
+			rslt = config_no_motion_int_settg(int_config, no_mot_int_cfg, dev);
+	}
+
+	return rslt;
 }
+
 /*!
- *	@brief This API writes gyro wakeup trigger
- *	in the register 0x6C bit 3 and 4
- *
- *  @param v_gyro_wakeup_trigger_u8 : The value of gyro wakeup trigger
- *  Value  |  Description
- * --------|-------------
- *   0x00  | anymotion: no / INT1 pin: no
- *   0x01  | anymotion: no / INT1 pin: yes
- *   0x02  | anymotion: yes / INT1 pin: no
- *   0x03  | anymotion: yes / INT1 pin: yes
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_wakeup_trigger(
-u8 v_gyro_wakeup_trigger_u8)
+ * @brief This API sets the step detection interrupt.This interrupt
+ * occurs when the single step causes accel values to go above
+ * preset threshold.
+ */
+static int8_t set_accel_step_detect_int(struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		if (v_gyro_wakeup_trigger_u8
-		<= BMI160_MAX_GYRO_WAKEUP_TRIGGER) {
-			/* write gyro wakeup trigger */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_GYRO_WAKEUP_TRIGGER__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_WAKEUP_TRIGGER,
-				v_gyro_wakeup_trigger_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_GYRO_WAKEUP_TRIGGER__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
+	int8_t rslt;
 
+	/* Null-pointer check */
+	rslt = null_ptr_check(dev);
 
+	if ((rslt != BMI160_OK) || (int_config == NULL)) {
+		rslt = BMI160_E_NULL_PTR;
+	} else {
+		/* updating the interrupt structure to local structure */
+		struct bmi160_acc_step_detect_int_cfg *step_detect_int_cfg =
+								&(int_config->int_type_cfg.acc_step_detect_int);
+
+		rslt = enable_step_detect_int(step_detect_int_cfg, dev);
+		if (rslt == BMI160_OK) {
+			/* Configure Interrupt pins */
+			rslt = set_intr_pin_config(int_config, dev);
+			if (rslt == BMI160_OK) {
+				rslt = map_int_pin_to_low_step_detect(int_config, dev);
+				if (rslt == BMI160_OK)
+					rslt = config_step_detect(step_detect_int_cfg, dev);
 			}
-		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
 		}
 	}
-	return com_rslt;
+	return rslt;
 }
+
 /*!
- *	@brief This API reads target state for gyro sleep mode
- *	from the register 0x6C bit 5
- *
- *  @param v_gyro_sleep_state_u8 : The value of gyro sleep mode
- *  Value  |  Description
- * --------|-------------
- *   0x00  | Sleep transition to fast wake up state
- *   0x01  | Sleep transition to suspend state
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_sleep_state(
-u8 *v_gyro_sleep_state_u8)
+ * @brief This API sets the orientation interrupt of the sensor.This
+ * interrupt occurs when there is orientation change in the sensor
+ * with respect to gravitational field vector g.
+ */
+static int8_t set_accel_orientation_int(struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read gyro sleep state*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_GYRO_SLEEP_STATE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_gyro_sleep_state_u8 = BMI160_GET_BITSLICE(
-			v_data_u8,
-			BMI160_USER_GYRO_SLEEP_STATE);
+	int8_t rslt;
+
+	/* Null-pointer check */
+	rslt = null_ptr_check(dev);
+
+	if ((rslt != BMI160_OK) || (int_config == NULL)) {
+		rslt = BMI160_E_NULL_PTR;
+	} else {
+		/* updating the interrupt structure to local structure */
+		struct bmi160_acc_orient_int_cfg *orient_int_cfg = &(int_config->int_type_cfg.acc_orient_int);
+
+		rslt = enable_orient_int(orient_int_cfg, dev);
+		if (rslt == BMI160_OK) {
+			/* Configure Interrupt pins */
+			rslt = set_intr_pin_config(int_config, dev);
+			if (rslt == BMI160_OK) {
+				/* map INT pin to orient interrupt */
+				rslt = map_int_pin_to_orient(int_config, dev);
+				if (rslt == BMI160_OK)
+					/* configure the
+					 * orientation setting*/
+					rslt = config_orient_int_settg(orient_int_cfg, dev);
+			}
 		}
-	return com_rslt;
+	}
+
+	return rslt;
 }
+
 /*!
- *	@brief This API writes target state for gyro sleep mode
- *	in the register 0x6C bit 5
- *
- *  @param v_gyro_sleep_state_u8 : The value of gyro sleep mode
- *  Value  |  Description
- * --------|-------------
- *   0x00  | Sleep transition to fast wake up state
- *   0x01  | Sleep transition to suspend state
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_sleep_state(
-u8 v_gyro_sleep_state_u8)
+ * @brief This API sets the flat interrupt of the sensor.This interrupt
+ * occurs in case of flat orientation
+ */
+static int8_t set_accel_flat_detect_int(struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		if (v_gyro_sleep_state_u8 <= BMI160_MAX_VALUE_SLEEP_STATE) {
-			/* write gyro sleep state*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_GYRO_SLEEP_STATE__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_SLEEP_STATE,
-				v_gyro_sleep_state_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_GYRO_SLEEP_STATE__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
+	int8_t rslt;
+
+	/* Null-pointer check */
+	rslt = null_ptr_check(dev);
+
+	if ((rslt != BMI160_OK) || (int_config == NULL)) {
+		rslt = BMI160_E_NULL_PTR;
+	} else {
+		/* updating the interrupt structure to local structure */
+		struct bmi160_acc_flat_detect_int_cfg *flat_detect_int = &(int_config->int_type_cfg.acc_flat_int);
+
+		/* enable the flat interrupt */
+		rslt = enable_flat_int(flat_detect_int, dev);
+		if (rslt == BMI160_OK) {
+			/* Configure Interrupt pins */
+			rslt = set_intr_pin_config(int_config, dev);
+			if (rslt == BMI160_OK) {
+				/* map INT pin to flat interrupt */
+				rslt = map_int_pin_to_flat(int_config, dev);
+				if (rslt == BMI160_OK)
+					/* configure the flat setting*/
+					rslt = config_flat_int_settg(flat_detect_int, dev);
 			}
-		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
 		}
 	}
-	return com_rslt;
+
+	return rslt;
 }
+
 /*!
- *	@brief This API reads gyro wakeup interrupt
- *	from the register 0x6C bit 6
- *
- *  @param v_gyro_wakeup_intr_u8 : The value of gyro wakeup interrupt
- *  Value  |  Description
- * --------|-------------
- *   0x00  | DISABLE
- *   0x01  | ENABLE
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_wakeup_intr(
-u8 *v_gyro_wakeup_intr_u8)
+ * @brief This API sets the low-g interrupt of the sensor.This interrupt
+ * occurs during free-fall.
+ */
+static int8_t set_accel_low_g_int(struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read gyro wakeup interrupt */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_GYRO_WAKEUP_INTR__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_gyro_wakeup_intr_u8 = BMI160_GET_BITSLICE(
-			v_data_u8,
-			BMI160_USER_GYRO_WAKEUP_INTR);
+	int8_t rslt;
+
+	/* Null-pointer check */
+	rslt = null_ptr_check(dev);
+
+	if ((rslt != BMI160_OK) || (int_config == NULL)) {
+		rslt = BMI160_E_NULL_PTR;
+	} else {
+		/* updating the interrupt structure to local structure */
+		struct bmi160_acc_low_g_int_cfg *low_g_int = &(int_config->int_type_cfg.acc_low_g_int);
+
+		/* Enable the low-g interrupt*/
+		rslt = enable_low_g_int (low_g_int, dev);
+		if (rslt == BMI160_OK) {
+			/* Configure Interrupt pins */
+			rslt = set_intr_pin_config(int_config, dev);
+			if (rslt == BMI160_OK) {
+				/* Map INT pin to low-g interrupt */
+				rslt = map_int_pin_to_low_step_detect(int_config, dev);
+				if (rslt == BMI160_OK) {
+					/* configure the data source
+					 * for low-g interrupt*/
+					rslt = config_low_g_data_src(low_g_int, dev);
+					if (rslt == BMI160_OK)
+						rslt = config_low_g_int_settg(low_g_int, dev);
+				}
+			}
 		}
-	return com_rslt;
+	}
+
+	return rslt;
 }
+
 /*!
- *	@brief This API writes gyro wakeup interrupt
- *	in the register 0x6C bit 6
- *
- *  @param v_gyro_wakeup_intr_u8 : The value of gyro wakeup interrupt
- *  Value  |  Description
- * --------|-------------
- *   0x00  | DISABLE
- *   0x01  | ENABLE
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_wakeup_intr(
-u8 v_gyro_wakeup_intr_u8)
+ * @brief This API sets the high-g interrupt of the sensor.The interrupt
+ * occurs if the absolute value of acceleration data of any enabled axis
+ * exceeds the programmed threshold and the sign of the value does not
+ * change for a preset duration.
+ */
+static int8_t set_accel_high_g_int(struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		if (v_gyro_wakeup_intr_u8 <= BMI160_MAX_VALUE_WAKEUP_INTR) {
-			/* write gyro wakeup interrupt */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_GYRO_WAKEUP_INTR__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_WAKEUP_INTR,
-				v_gyro_wakeup_intr_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_GYRO_WAKEUP_INTR__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
+	int8_t rslt;
 
+	/* Null-pointer check */
+	rslt = null_ptr_check(dev);
 
+	if ((rslt != BMI160_OK) || (int_config == NULL)) {
+		rslt = BMI160_E_NULL_PTR;
+	} else {
+		/* updating the interrupt structure to local structure */
+		struct bmi160_acc_high_g_int_cfg *high_g_int_cfg = &(int_config->int_type_cfg.acc_high_g_int);
+
+		/* Enable the high-g interrupt */
+		rslt = enable_high_g_int(high_g_int_cfg, dev);
+		if (rslt == BMI160_OK) {
+			/* Configure Interrupt pins */
+			rslt = set_intr_pin_config(int_config, dev);
+			if (rslt == BMI160_OK) {
+				/* Map INT pin to high-g interrupt */
+				rslt = map_int_pin_to_high_g(int_config, dev);
+				if (rslt == BMI160_OK) {
+					/* configure the data source
+					* for high-g interrupt*/
+					rslt = config_high_g_data_src(high_g_int_cfg, dev);
+					if (rslt == BMI160_OK)
+						rslt = config_high_g_int_settg(high_g_int_cfg, dev);
+				}
 			}
-		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
 		}
 	}
-	return com_rslt;
+
+	return rslt;
 }
+
 /*!
- * @brief This API reads Accel selftest axis selected for self-test
- * functionality.
- *
- *  @param v_accel_selftest_axis_u8 :
- *	The value of Accel self test axis selection
- *  Value  |  Description
- * --------|-------------
- *   0x00  | disabled
- *   0x01  | x-axis
- *   0x02  | y-axis
- *   0x03  | z-axis
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_selftest_axis(
-u8 *v_accel_selftest_axis_u8)
+ * @brief This API configures the pins to fire the
+ * interrupt signal when it occurs.
+ */
+static int8_t set_intr_pin_config(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read Accel self test axis*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_ACCEL_SELFTEST_AXIS__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_accel_selftest_axis_u8 = BMI160_GET_BITSLICE(
-			v_data_u8,
-			BMI160_USER_ACCEL_SELFTEST_AXIS);
-		}
-	return com_rslt;
+	int8_t rslt;
+
+	/* configure the behavioural settings of interrupt pin */
+	rslt = config_int_out_ctrl(int_config, dev);
+	if (rslt == BMI160_OK)
+		rslt = config_int_latch(int_config, dev);
+
+	return rslt;
 }
+
 /*!
- * @brief This API writes Accel self test axis for self-test
- * functionality.
- *
- *  @param v_accel_selftest_axis_u8 :
- *	The value of Accel self test axis selection
- *  Value  |  Description
- * --------|-------------
- *   0x00  | disabled
- *   0x01  | x-axis
- *   0x02  | y-axis
- *   0x03  | z-axis
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_selftest_axis(
-u8 v_accel_selftest_axis_u8)
+ * @brief This internal API is used to validate the device structure pointer for
+ * null conditions.
+ */
+static int8_t null_ptr_check(const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		if (v_accel_selftest_axis_u8
-		<= BMI160_MAX_ACCEL_SELFTEST_AXIS) {
-			/* write Accel self test axis*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_ACCEL_SELFTEST_AXIS__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_SELFTEST_AXIS,
-				v_accel_selftest_axis_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_ACCEL_SELFTEST_AXIS__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-		}
+	int8_t rslt;
+
+	if ((dev == NULL) || (dev->read == NULL) || (dev->write == NULL) || (dev->delay_ms == NULL)) {
+		rslt = BMI160_E_NULL_PTR;
+	} else {
+		/* Device structure is fine */
+		rslt = BMI160_OK;
 	}
-	return com_rslt;
+
+	return rslt;
 }
+
 /*!
- *	@brief This API reads Accel self test axis sign
- *	from the register 0x6D bit 2
- *
- *  @param v_accel_selftest_sign_u8: The value of Accel self test axis sign
- *  Value  |  Description
- * --------|-------------
- *   0x00  | negative
- *   0x01  | positive
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_selftest_sign(
-u8 *v_accel_selftest_sign_u8)
+ * @brief This API sets the default configuration parameters of accel & gyro.
+ * Also maintain the previous state of configurations.
+ */
+static void default_param_settg(struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read Accel self test axis sign*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_ACCEL_SELFTEST_SIGN__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_accel_selftest_sign_u8 = BMI160_GET_BITSLICE(
-			v_data_u8,
-			BMI160_USER_ACCEL_SELFTEST_SIGN);
-		}
-	return com_rslt;
+	/* Initializing accel and gyro params with
+	* default values */
+	dev->accel_cfg.bw = BMI160_ACCEL_BW_NORMAL_AVG4;
+	dev->accel_cfg.odr = BMI160_ACCEL_ODR_100HZ;
+	dev->accel_cfg.power = BMI160_ACCEL_SUSPEND_MODE;
+	dev->accel_cfg.range = BMI160_ACCEL_RANGE_2G;
+	dev->gyro_cfg.bw = BMI160_GYRO_BW_NORMAL_MODE;
+	dev->gyro_cfg.odr = BMI160_GYRO_ODR_100HZ;
+	dev->gyro_cfg.power = BMI160_GYRO_SUSPEND_MODE;
+	dev->gyro_cfg.range = BMI160_GYRO_RANGE_2000_DPS;
+
+	/* To maintain the previous state of accel configuration */
+	dev->prev_accel_cfg = dev->accel_cfg;
+	/* To maintain the previous state of gyro configuration */
+	dev->prev_gyro_cfg = dev->gyro_cfg;
 }
+
 /*!
- *	@brief This API writes Accel self test axis sign
- *	in the register 0x6D bit 2
- *
- *  @param v_accel_selftest_sign_u8: The value of Accel self test axis sign
- *  Value  |  Description
- * --------|-------------
- *   0x00  | negative
- *   0x01  | positive
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_selftest_sign(
-u8 v_accel_selftest_sign_u8)
+ * @brief This API set the accel configuration.
+ */
+static int8_t set_accel_conf(struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		if (v_accel_selftest_sign_u8 <=
-		BMI160_MAX_VALUE_SELFTEST_SIGN) {
-			/* write Accel self test axis sign*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_ACCEL_SELFTEST_SIGN__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_SELFTEST_SIGN,
-				v_accel_selftest_sign_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_ACCEL_SELFTEST_SIGN__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		} else {
-			com_rslt = E_BMI160_OUT_OF_RANGE;
+	int8_t rslt;
+	uint8_t data[2]  = {0};
+
+	rslt = check_accel_config(data, dev);
+	if (rslt == BMI160_OK) {
+		/* Write output data rate and bandwidth */
+		rslt = bmi160_set_regs(BMI160_ACCEL_CONFIG_ADDR, &data[0], 1, dev);
+		if (rslt == BMI160_OK) {
+			dev->prev_accel_cfg.odr = dev->accel_cfg.odr;
+			dev->prev_accel_cfg.bw = dev->accel_cfg.bw;
+			dev->delay_ms(BMI160_ONE_MS_DELAY);
+			/* write accel range */
+			rslt = bmi160_set_regs(BMI160_ACCEL_RANGE_ADDR, &data[1], 1, dev);
+			if (rslt == BMI160_OK)
+				dev->prev_accel_cfg.range = dev->accel_cfg.range;
 		}
 	}
-	return com_rslt;
+
+	return rslt;
 }
+
 /*!
- *	@brief This API reads Accel self test amplitude
- *	from the register 0x6D bit 3
- *
- *
- *  @param v_accel_selftest_amp_u8 : The value of Accel self test amplitude
- *  Value  |  Description
- * --------|-------------
- *   0x00  | LOW
- *   0x01  | HIGH
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
+* @brief This API check the accel configuration.
 */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_selftest_amp(
-u8 *v_accel_selftest_amp_u8)
+static int8_t check_accel_config(uint8_t *data, const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read  self test amplitude*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_SELFTEST_AMP__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_accel_selftest_amp_u8 = BMI160_GET_BITSLICE(
-			v_data_u8,
-			BMI160_USER_SELFTEST_AMP);
+	int8_t rslt;
+
+	/* read accel Output data rate and bandwidth */
+	rslt = bmi160_get_regs(BMI160_ACCEL_CONFIG_ADDR, data, 2, dev);
+	if (rslt == BMI160_OK) {
+		rslt = process_accel_odr(&data[0], dev);
+		if (rslt == BMI160_OK) {
+			rslt = process_accel_bw(&data[0], dev);
+			if (rslt == BMI160_OK)
+				rslt = process_accel_range(&data[1], dev);
 		}
-	return com_rslt;
+	}
+
+	return rslt;
 }
+
 /*!
- *	@brief This API writes Accel self test amplitude
- *	in the register 0x6D bit 3
- *
- *
- *  @param v_accel_selftest_amp_u8 : The value of Accel self test amplitude
- *  Value  |  Description
- * --------|-------------
- *   0x00  | LOW
- *   0x01  | HIGH
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_selftest_amp(
-u8 v_accel_selftest_amp_u8)
+ * @brief This API process the accel odr.
+ */
+static int8_t process_accel_odr(uint8_t *data, const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		if (v_accel_selftest_amp_u8 <=
-		BMI160_MAX_VALUE_SELFTEST_AMP) {
-			/* write  self test amplitude*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_SELFTEST_AMP__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_SELFTEST_AMP,
-				v_accel_selftest_amp_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_SELFTEST_AMP__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
+	int8_t rslt = 0;
+	uint8_t temp = 0;
+	uint8_t odr = 0;
+
+	if (dev->accel_cfg.odr <= BMI160_ACCEL_ODR_MAX) {
+		if (dev->accel_cfg.odr != dev->prev_accel_cfg.odr) {
+			odr = (uint8_t)dev->accel_cfg.odr;
+			temp = *data & ~BMI160_ACCEL_ODR_MASK;
+			/* Adding output data rate */
+			*data = temp | (odr & BMI160_ACCEL_ODR_MASK);
 		}
+	} else {
+		rslt = BMI160_E_OUT_OF_RANGE;
 	}
-	return com_rslt;
+
+	return rslt;
 }
+
 /*!
- *	@brief This API reads the gyro self test trigger
- *
- *	@param v_gyro_selftest_start_u8: The value of gyro self test start
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_selftest_start(
-u8 *v_gyro_selftest_start_u8)
+ * @brief This API process the accel bandwidth.
+ */
+static int8_t process_accel_bw(uint8_t *data, const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read gyro self test start */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_GYRO_SELFTEST_START__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_gyro_selftest_start_u8 = BMI160_GET_BITSLICE(
-			v_data_u8,
-			BMI160_USER_GYRO_SELFTEST_START);
+	int8_t rslt = 0;
+	uint8_t temp = 0;
+	uint8_t bw = 0;
+
+	if (dev->accel_cfg.bw <= BMI160_ACCEL_BW_MAX) {
+		if (dev->accel_cfg.bw != dev->prev_accel_cfg.bw) {
+			bw = (uint8_t)dev->accel_cfg.bw;
+			temp = *data & ~BMI160_ACCEL_BW_MASK;
+			/* Adding bandwidth */
+			*data = temp | ((bw << 4) & BMI160_ACCEL_ODR_MASK);
 		}
-	return com_rslt;
+	} else {
+		rslt = BMI160_E_OUT_OF_RANGE;
+	}
+
+	return rslt;
 }
+
 /*!
- *	@brief This API writes the gyro self test trigger
- *
- *	@param v_gyro_selftest_start_u8: The value of gyro self test start
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_selftest_start(
-u8 v_gyro_selftest_start_u8)
+ * @brief This API process the accel range.
+ */
+static int8_t process_accel_range(uint8_t *data, const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		if (v_gyro_selftest_start_u8 <=
-		BMI160_MAX_VALUE_SELFTEST_START) {
-			/* write gyro self test start */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_GYRO_SELFTEST_START__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_SELFTEST_START,
-				v_gyro_selftest_start_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_GYRO_SELFTEST_START__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		} else {
-		com_rslt = E_BMI160_OUT_OF_RANGE;
+	int8_t rslt = 0;
+	uint8_t temp = 0;
+	uint8_t range = 0;
+
+	if (dev->accel_cfg.range <= BMI160_ACCEL_RANGE_MAX) {
+		if (dev->accel_cfg.range != dev->prev_accel_cfg.range) {
+			range = (uint8_t)dev->accel_cfg.range;
+			temp = *data & ~BMI160_ACCEL_RANGE_MASK;
+			/* Adding range */
+			*data = temp | (range & BMI160_ACCEL_RANGE_MASK);
 		}
+	} else {
+		rslt = BMI160_E_OUT_OF_RANGE;
 	}
-	return com_rslt;
+
+	return rslt;
 }
- /*!
- * @brief This API reads the primary interface selection I2C or SPI
- *	from the register 0x70 bit 0
- *
- *  @param v_spi_enable_u8: The value of Interface selection
- *  Value  |  Description
- * --------|-------------
- *   0x00  | I2C Enable
- *   0x01  | I2C DISABLE
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_spi_enable(u8 *v_spi_enable_u8)
+
+/*!
+ * @brief This API checks the invalid settings for ODR & Bw for
+ * Accel and Gyro.
+ */
+static int8_t check_invalid_settg(const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read interface section*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_NV_CONFIG_SPI_ENABLE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_spi_enable_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_NV_CONFIG_SPI_ENABLE);
-		}
-	return com_rslt;
+	int8_t rslt;
+	uint8_t data = 0;
+
+	/* read the error reg */
+	rslt = bmi160_get_regs(BMI160_ERROR_REG_ADDR, &data, 1, dev);
+
+	data = data >> 1;
+	data = data & BMI160_ERR_REG_MASK;
+	if (data == 1)
+		rslt = BMI160_E_ACCEL_ODR_BW_INVALID;
+	else if (data == 2)
+		rslt = BMI160_E_GYRO_ODR_BW_INVALID;
+	else if (data == 3)
+		rslt = BMI160_E_LWP_PRE_FLTR_INT_INVALID;
+	else if (data == 7)
+		rslt = BMI160_E_LWP_PRE_FLTR_INVALID;
+
+	return rslt;
 }
- /*!
- * @brief This API writes primary interface selection I2C or SPI
- *	in the register 0x70 bit 0
- *
- *  @param v_spi_enable_u8: The value of Interface selection
- *  Value  |  Description
- * --------|-------------
- *   0x00  | I2C Enable
- *   0x01  | I2C DISABLE
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_spi_enable(u8 v_spi_enable_u8)
+
+static int8_t set_gyro_conf(struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* write interface section*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_NV_CONFIG_SPI_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_NV_CONFIG_SPI_ENABLE,
-				v_spi_enable_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
-				(p_bmi160->dev_addr,
-				BMI160_USER_NV_CONFIG_SPI_ENABLE__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
+	int8_t rslt;
+	uint8_t data[2] = {0};
+
+	rslt = check_gyro_config(data, dev);
+	if (rslt == BMI160_OK) {
+		/* Write output data rate and bandwidth */
+		rslt = bmi160_set_regs(BMI160_GYRO_CONFIG_ADDR, &data[0], 1, dev);
+		if (rslt == BMI160_OK) {
+			dev->prev_gyro_cfg.odr = dev->gyro_cfg.odr;
+			dev->prev_gyro_cfg.bw = dev->gyro_cfg.bw;
+			dev->delay_ms(BMI160_ONE_MS_DELAY);
+			/* Write gyro range */
+			rslt = bmi160_set_regs(BMI160_GYRO_RANGE_ADDR, &data[1], 1, dev);
+			if (rslt == BMI160_OK)
+				dev->prev_gyro_cfg.range = dev->gyro_cfg.range;
 		}
-	return com_rslt;
+	}
+
+	return rslt;
 }
 
 /*!
- *	@brief This API reads the Accel manual offset compensation of x axis
- *	from the register 0x71 bit 0 to 7
- *
- *
- *
- *  @param v_accel_off_x_s8:
- *	The value of Accel manual offset compensation of x axis
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
+* @brief This API check the gyro configuration.
 */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_offset_compensation_xaxis(
-s8 *v_accel_off_x_s8)
+static int8_t check_gyro_config(uint8_t *data, const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read Accel manual offset compensation of x axis*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_OFFSET_0_ACCEL_OFF_X__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_accel_off_x_s8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_OFFSET_0_ACCEL_OFF_X);
+	int8_t rslt;
+
+	/* read gyro Output data rate and bandwidth */
+	rslt = bmi160_get_regs(BMI160_GYRO_CONFIG_ADDR, data, 2, dev);
+	if (rslt == BMI160_OK) {
+		rslt = process_gyro_odr(&data[0], dev);
+		if (rslt == BMI160_OK) {
+			rslt = process_gyro_bw(&data[0], dev);
+			if (rslt == BMI160_OK)
+				rslt = process_gyro_range(&data[1], dev);
 		}
-	return com_rslt;
+	}
+
+	return rslt;
+
 }
+
 /*!
- *	@brief This API writes the Accel manual offset compensation of x axis
- *	in the register 0x71 bit 0 to 7
- *
- *
- *
- *  @param v_accel_off_x_s8:
- *	The value of Accel manual offset compensation of x axis
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_offset_compensation_xaxis(
-s8 v_accel_off_x_s8)
+ * @brief This API process the gyro odr.
+ */
+static int8_t process_gyro_odr(uint8_t *data, const struct bmi160_dev *dev)
 {
-/* variable used to 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_status_s8 = SUCCESS;
-/* check the p_bmi160 structure for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-	} else {
-		/* enable Accel offset */
-		v_status_s8 = bmi160_set_accel_offset_enable(
-		ACCEL_OFFSET_ENABLE);
-		if (v_status_s8 == SUCCESS) {
-			/* write Accel manual offset compensation of x axis*/
-			com_rslt =
-			p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_OFFSET_0_ACCEL_OFF_X__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_OFFSET_0_ACCEL_OFF_X,
-				v_accel_off_x_s8);
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_OFFSET_0_ACCEL_OFF_X__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		} else {
-		com_rslt =  ERROR;
+	int8_t rslt = 0;
+	uint8_t temp = 0;
+	uint8_t odr = 0;
+
+	if (dev->gyro_cfg.odr <= BMI160_GYRO_ODR_MAX) {
+		if (dev->gyro_cfg.odr != dev->prev_gyro_cfg.odr) {
+			odr = (uint8_t)dev->gyro_cfg.odr;
+			temp = (*data & ~BMI160_GYRO_ODR_MASK);
+			/* Adding output data rate */
+			*data = temp | (odr & BMI160_GYRO_ODR_MASK);
 		}
+	} else {
+		rslt = BMI160_E_OUT_OF_RANGE;
 	}
-	return com_rslt;
+
+	return rslt;
 }
+
 /*!
- *	@brief This API reads the  Accel manual offset compensation of y axis
- *	from the register 0x72 bit 0 to 7
- *
- *
- *
- *  @param v_accel_off_y_s8:
- *	The value of Accel manual offset compensation of y axis
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_offset_compensation_yaxis(
-s8 *v_accel_off_y_s8)
+ * @brief This API process the gyro bandwidth.
+ */
+static int8_t process_gyro_bw(uint8_t *data, const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read Accel manual offset compensation of y axis*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_OFFSET_1_ACCEL_OFF_Y__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_accel_off_y_s8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_OFFSET_1_ACCEL_OFF_Y);
-		}
-	return com_rslt;
+	int8_t rslt = 0;
+	uint8_t temp = 0;
+	uint8_t bw = 0;
+
+	if (dev->gyro_cfg.bw <= BMI160_GYRO_BW_MAX) {
+		bw = (uint8_t)dev->gyro_cfg.bw;
+		temp = *data & ~BMI160_GYRO_BW_MASK;
+		/* Adding bandwidth */
+		*data = temp | ((bw << 4) & BMI160_GYRO_BW_MASK);
+	} else {
+		rslt = BMI160_E_OUT_OF_RANGE;
+	}
+
+	return rslt;
 }
+
 /*!
- *	@brief This API writes the Accel manual offset compensation of y axis
- *	in the register 0x72 bit 0 to 7
- *
- *
- *
- *  @param v_accel_off_y_s8:
- *	The value of Accel manual offset compensation of y axis
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_offset_compensation_yaxis(
-s8 v_accel_off_y_s8)
+ * @brief This API process the gyro range.
+ */
+static int8_t process_gyro_range(uint8_t *data, const struct bmi160_dev *dev)
 {
-/* variable used to 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_status_s8 = SUCCESS;
-/* check the p_bmi160 structure for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-	} else {
-		/* enable Accel offset */
-		v_status_s8 = bmi160_set_accel_offset_enable(
-		ACCEL_OFFSET_ENABLE);
-		if (v_status_s8 == SUCCESS) {
-			/* write Accel manual offset compensation of y axis*/
-			com_rslt =
-			p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_OFFSET_1_ACCEL_OFF_Y__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_OFFSET_1_ACCEL_OFF_Y,
-				v_accel_off_y_s8);
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_OFFSET_1_ACCEL_OFF_Y__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		} else {
-		com_rslt = ERROR;
+	int8_t rslt = 0;
+	uint8_t temp = 0;
+	uint8_t range = 0;
+
+	if (dev->gyro_cfg.range <= BMI160_GYRO_RANGE_MAX) {
+		if (dev->gyro_cfg.range != dev->prev_gyro_cfg.range) {
+			range = (uint8_t)dev->gyro_cfg.range;
+			temp = *data & ~BMI160_GYRO_RANGE_MSK;
+			/* Adding range */
+			*data = temp | (range & BMI160_GYRO_RANGE_MSK);
 		}
+	} else {
+		rslt = BMI160_E_OUT_OF_RANGE;
 	}
-	return com_rslt;
+
+	return rslt;
 }
+
 /*!
- *	@brief This API reads the Accel manual offset compensation of z axis
- *	from the register 0x73 bit 0 to 7
- *
- *
- *
- *  @param v_accel_off_z_s8:
- *	The value of Accel manual offset compensation of z axis
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_offset_compensation_zaxis(
-s8 *v_accel_off_z_s8)
-{
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read Accel manual offset compensation of z axis*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_OFFSET_2_ACCEL_OFF_Z__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_accel_off_z_s8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_OFFSET_2_ACCEL_OFF_Z);
+ * @brief This API sets the accel power.
+ */
+static int8_t set_accel_pwr(struct bmi160_dev *dev)
+{
+	int8_t rslt = 0;
+	uint8_t data = 0;
+
+	if ((dev->accel_cfg.power >= BMI160_ACCEL_SUSPEND_MODE) &&
+		(dev->accel_cfg.power <= BMI160_ACCEL_LOWPOWER_MODE)) {
+		if (dev->accel_cfg.power != dev->prev_accel_cfg.power) {
+			rslt = process_under_sampling(&data, dev);
+			if (rslt == BMI160_OK) {
+					/* Write accel power */
+				rslt = bmi160_set_regs(BMI160_COMMAND_REG_ADDR, &dev->accel_cfg.power, 1, dev);
+				/* Add delay of 5 ms */
+				if (dev->prev_accel_cfg.power == BMI160_ACCEL_SUSPEND_MODE)
+					dev->delay_ms(BMI160_ACCEL_DELAY_MS);
+				dev->prev_accel_cfg.power = dev->accel_cfg.power;
+			}
 		}
-	return com_rslt;
+	} else {
+		rslt = BMI160_E_OUT_OF_RANGE;
+	}
+
+	return rslt;
 }
+
 /*!
- *	@brief This API writes the Accel manual offset compensation of z axis
- *	in the register 0x73 bit 0 to 7
- *
- *
- *
- *  @param v_accel_off_z_s8:
- *	The value of Accel manual offset compensation of z axis
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_offset_compensation_zaxis(
-s8 v_accel_off_z_s8)
-{
-	/* variable used to 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_status_s8 = SUCCESS;
-	/* check the p_bmi160 structure for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* enable Accel offset */
-			v_status_s8 = bmi160_set_accel_offset_enable(
-			ACCEL_OFFSET_ENABLE);
-			if (v_status_s8 == SUCCESS) {
-				/* write Accel manual offset
-				compensation of z axis*/
-				com_rslt =
-				p_bmi160->BMI160_BUS_READ_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_OFFSET_2_ACCEL_OFF_Z__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_OFFSET_2_ACCEL_OFF_Z,
-					v_accel_off_z_s8);
-					com_rslt +=
-					p_bmi160->BMI160_BUS_WRITE_FUNC(
-					p_bmi160->dev_addr,
-					BMI160_USER_OFFSET_2_ACCEL_OFF_Z__REG,
-					&v_data_u8,
-					BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-					/*Check for the power mode of Accel
-					and gyro not in normal mode */
-					if (bmi160_power_mode_status_u8_g !=
-					BMI160_NORMAL_MODE)
-						/*interface idle time delay */
-						p_bmi160->delay_msec(
-						BMI160_GEN_READ_WRITE_DELAY);
-				}
+ * @brief This API process the undersampling setting of Accel.
+ */
+static int8_t process_under_sampling(uint8_t *data, const struct bmi160_dev *dev)
+{
+	int8_t rslt;
+	uint8_t temp = 0;
+	uint8_t pre_filter = 0;
+
+	rslt = bmi160_get_regs(BMI160_ACCEL_CONFIG_ADDR, data, 1, dev);
+	if (rslt == BMI160_OK) {
+		if (dev->accel_cfg.power == BMI160_ACCEL_LOWPOWER_MODE) {
+			temp = *data & ~BMI160_ACCEL_UNDERSAMPLING_MASK;
+			/* Set under-sampling parameter */
+			*data = temp | ((1 << 7) & BMI160_ACCEL_UNDERSAMPLING_MASK);
+			/* Write data */
+			rslt = bmi160_set_regs(BMI160_ACCEL_CONFIG_ADDR, data, 1, dev);
+			/* disable the pre-filter data in
+			 * low power mode */
+			if (rslt == BMI160_OK)
+				/* Disable the Pre-filter data*/
+				rslt = bmi160_set_regs(BMI160_INT_DATA_0_ADDR, &pre_filter, 2, dev);
+		} else {
+			if (*data & BMI160_ACCEL_UNDERSAMPLING_MASK) {
+				temp = *data & ~BMI160_ACCEL_UNDERSAMPLING_MASK;
+				/* disable under-sampling parameter
+				if already enabled */
+				*data = temp | 0x7F;
+				/* Write data */
+				rslt = bmi160_set_regs(BMI160_ACCEL_CONFIG_ADDR, data, 1, dev);
+			}
+		}
+	}
+
+	return rslt;
+}
+
+/*!
+ * @brief This API sets the gyro power mode.
+ */
+static int8_t set_gyro_pwr(struct bmi160_dev *dev)
+{
+	int8_t rslt = 0;
+
+	if ((dev->gyro_cfg.power == BMI160_GYRO_SUSPEND_MODE) || (dev->gyro_cfg.power == BMI160_GYRO_NORMAL_MODE)
+		|| (dev->gyro_cfg.power == BMI160_GYRO_FASTSTARTUP_MODE)) {
+
+		if (dev->gyro_cfg.power != dev->prev_gyro_cfg.power) {
+
+			/* Write gyro power */
+			rslt = bmi160_set_regs(BMI160_COMMAND_REG_ADDR, &dev->gyro_cfg.power, 1, dev);
+			if (dev->prev_gyro_cfg.power ==
+				BMI160_GYRO_SUSPEND_MODE) {
+				/* Delay of 81 ms */
+				dev->delay_ms(BMI160_GYRO_DELAY_MS);
+			} else if ((dev->prev_gyro_cfg.power == BMI160_GYRO_FASTSTARTUP_MODE)
+				&& (dev->accel_cfg.power == BMI160_GYRO_NORMAL_MODE)) {
+				/* This delay is required for transition from
+				fast-startup mode to normal mode */
+				dev->delay_ms(10);
 			} else {
-			com_rslt = ERROR;
+				/* do nothing */
 			}
+			dev->prev_gyro_cfg.power = dev->gyro_cfg.power;
 		}
-	return com_rslt;
+	} else {
+		rslt = BMI160_E_OUT_OF_RANGE;
+	}
+
+	return rslt;
 }
+
 /*!
- *	@brief This API reads the gyro manual offset compensation of x axis
- *	from the register 0x74 bit 0 to 7 and 0x77 bit 0 and 1
- *
- *
- *
- *  @param v_gyro_off_x_s16:
- *	The value of gyro manual offset compensation of x axis
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_offset_compensation_xaxis(
-s16 *v_gyro_off_x_s16)
-{
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
-	u8 v_data1_u8r = BMI160_INIT_VALUE;
-	u8 v_data2_u8r = BMI160_INIT_VALUE;
-	s16 v_data3_u8r, v_data4_u8r = BMI160_INIT_VALUE;
-	/* check the p_bmi160 structure for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read gyro offset x*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_OFFSET_3_GYRO_OFF_X__REG,
-			&v_data1_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			v_data1_u8r = BMI160_GET_BITSLICE(v_data1_u8r,
-			BMI160_USER_OFFSET_3_GYRO_OFF_X);
-			com_rslt += p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_OFFSET_6_GYRO_OFF_X__REG,
-			&v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			v_data2_u8r = BMI160_GET_BITSLICE(v_data2_u8r,
-			BMI160_USER_OFFSET_6_GYRO_OFF_X);
-			v_data3_u8r = v_data2_u8r
-			<< BMI160_SHIFT_BIT_POSITION_BY_14_BITS;
-			v_data4_u8r =  v_data1_u8r
-			<< BMI160_SHIFT_BIT_POSITION_BY_06_BITS;
-			v_data3_u8r = v_data3_u8r | v_data4_u8r;
-			*v_gyro_off_x_s16 = v_data3_u8r
-			>> BMI160_SHIFT_BIT_POSITION_BY_06_BITS;
+ * @brief This API reads accel data along with sensor time if time is requested
+ * by user. Kindly refer the user guide(README.md) for more info.
+ */
+static int8_t get_accel_data(uint8_t len, struct bmi160_sensor_data *accel, const struct bmi160_dev *dev)
+{
+	int8_t rslt;
+	uint8_t idx = 0;
+	uint8_t data_array[9] = {0};
+	uint8_t time_0 = 0;
+	uint16_t time_1 = 0;
+	uint32_t time_2 = 0;
+	uint8_t lsb;
+	uint8_t msb;
+	int16_t msblsb;
+
+	/* read accel sensor data along with time if requested */
+	rslt = bmi160_get_regs(BMI160_ACCEL_DATA_ADDR, data_array, 6 + len, dev);
+	if (rslt == BMI160_OK) {
+
+		/* Accel Data */
+		lsb = data_array[idx++];
+		msb = data_array[idx++];
+		msblsb = (int16_t)((msb << 8) | lsb);
+		accel->x = msblsb; /* Data in X axis */
+
+		lsb = data_array[idx++];
+		msb = data_array[idx++];
+		msblsb = (int16_t)((msb << 8) | lsb);
+		accel->y = msblsb; /* Data in Y axis */
+
+		lsb = data_array[idx++];
+		msb = data_array[idx++];
+		msblsb = (int16_t)((msb << 8) | lsb);
+		accel->z = msblsb; /* Data in Z axis */
+
+		if (len == 3) {
+			time_0 = data_array[idx++];
+			time_1 = (uint16_t)(data_array[idx++] << 8);
+			time_2 = (uint32_t)(data_array[idx++] << 16);
+			accel->sensortime = (uint32_t)(time_2 | time_1 | time_0);
+		} else {
+			accel->sensortime = 0;
 		}
-	return com_rslt;
+	} else {
+		rslt = BMI160_E_COM_FAIL;
+	}
+
+	return rslt;
 }
+
 /*!
- *	@brief This API writes the gyro manual offset compensation of x axis
- *	in the register 0x74 bit 0 to 7 and 0x77 bit 0 and 1
- *
- *
- *
- *  @param v_gyro_off_x_s16:
- *	The value of gyro manual offset compensation of x axis
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_offset_compensation_xaxis(
-s16 v_gyro_off_x_s16)
-{
-/* variable used to return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data1_u8r, v_data2_u8r = BMI160_INIT_VALUE;
-u16 v_data3_u8r = BMI160_INIT_VALUE;
-u8 v_status_s8 = SUCCESS;
-/* check the p_bmi160 structure for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
+ * @brief This API reads accel data along with sensor time if time is requested
+ * by user. Kindly refer the user guide(README.md) for more info.
+ */
+static int8_t get_gyro_data(uint8_t len, struct bmi160_sensor_data *gyro, const struct bmi160_dev *dev)
+{
+	int8_t rslt;
+	uint8_t idx = 0;
+	uint8_t data_array[15] = {0};
+	uint8_t time_0 = 0;
+	uint16_t time_1 = 0;
+	uint32_t time_2 = 0;
+	uint8_t lsb;
+	uint8_t msb;
+	int16_t msblsb;
+
+	if (len == 0) {
+		/* read gyro data only */
+		rslt = bmi160_get_regs(BMI160_GYRO_DATA_ADDR, data_array, 6, dev);
+		if (rslt == BMI160_OK) {
+			/* Gyro Data */
+			lsb = data_array[idx++];
+			msb = data_array[idx++];
+			msblsb = (int16_t)((msb << 8) | lsb);
+			gyro->x = msblsb; /* Data in X axis */
+
+			lsb = data_array[idx++];
+			msb = data_array[idx++];
+			msblsb = (int16_t)((msb << 8) | lsb);
+			gyro->y = msblsb; /* Data in Y axis */
+
+			lsb = data_array[idx++];
+			msb = data_array[idx++];
+			msblsb = (int16_t)((msb << 8) | lsb);
+			gyro->z = msblsb; /* Data in Z axis */
+			gyro->sensortime = 0;
+
+		} else {
+			rslt = BMI160_E_COM_FAIL;
+		}
 	} else {
-		/* write gyro offset x*/
-		v_status_s8 = bmi160_set_gyro_offset_enable(
-		GYRO_OFFSET_ENABLE);
-		if (v_status_s8 == SUCCESS) {
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_OFFSET_3_GYRO_OFF_X__REG,
-			&v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			if (com_rslt == SUCCESS) {
-				v_data1_u8r =
-				((s8) (v_gyro_off_x_s16 &
-				BMI160_GYRO_MANUAL_OFFSET_0_7));
-				v_data2_u8r = BMI160_SET_BITSLICE(
-				v_data2_u8r,
-				BMI160_USER_OFFSET_3_GYRO_OFF_X,
-				v_data1_u8r);
-				/* write 0x74 bit 0 to 7*/
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_OFFSET_3_GYRO_OFF_X__REG,
-				&v_data2_u8r,
-				BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
+		/* read gyro sensor data along with time */
+		rslt = bmi160_get_regs(BMI160_GYRO_DATA_ADDR, data_array, 12 + len, dev);
+		if (rslt == BMI160_OK) {
+			/* Gyro Data */
+			lsb = data_array[idx++];
+			msb = data_array[idx++];
+			msblsb = (int16_t)((msb << 8) | lsb);
+			gyro->x = msblsb; /* gyro X axis data */
+
+			lsb = data_array[idx++];
+			msb = data_array[idx++];
+			msblsb = (int16_t)((msb << 8) | lsb);
+			gyro->y = msblsb; /* gyro Y axis data */
+
+			lsb = data_array[idx++];
+			msb = data_array[idx++];
+			msblsb = (int16_t)((msb << 8) | lsb);
+			gyro->z = msblsb; /* gyro Z axis data */
+
+			idx = idx + 6;
+			time_0 = data_array[idx++];
+			time_1 = (uint16_t)(data_array[idx++] << 8);
+			time_2 = (uint32_t)(data_array[idx++] << 16);
+			gyro->sensortime = (uint32_t)(time_2 | time_1 | time_0);
 
-			com_rslt += p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_OFFSET_6_GYRO_OFF_X__REG,
-			&v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			if (com_rslt == SUCCESS) {
-				v_data3_u8r =
-				(u16) (v_gyro_off_x_s16 &
-				BMI160_GYRO_MANUAL_OFFSET_8_9);
-				v_data1_u8r = (u8)(v_data3_u8r
-				>> BMI160_SHIFT_BIT_POSITION_BY_08_BITS);
-				v_data2_u8r = BMI160_SET_BITSLICE(
-				v_data2_u8r,
-				BMI160_USER_OFFSET_6_GYRO_OFF_X,
-				v_data1_u8r);
-				/* write 0x77 bit 0 and 1*/
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_OFFSET_6_GYRO_OFF_X__REG,
-				&v_data2_u8r,
-				BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
 		} else {
-		return ERROR;
+			rslt = BMI160_E_COM_FAIL;
 		}
 	}
-return com_rslt;
+
+	return rslt;
 }
+
 /*!
- *	@brief This API reads the gyro manual offset compensation of y axis
- *	from the register 0x75 bit 0 to 7 and 0x77 bit 2 and 3
- *
- *
- *
- *  @param v_gyro_off_y_s16:
- *	The value of gyro manual offset compensation of y axis
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_offset_compensation_yaxis(
-s16 *v_gyro_off_y_s16)
-{
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
-	u8 v_data1_u8r = BMI160_INIT_VALUE;
-	u8 v_data2_u8r = BMI160_INIT_VALUE;
-	s16 v_data3_u8r, v_data4_u8r = BMI160_INIT_VALUE;
-	/* check the p_bmi160 structure for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read gyro offset y*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_OFFSET_4_GYRO_OFF_Y__REG,
-			&v_data1_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			v_data1_u8r = BMI160_GET_BITSLICE(v_data1_u8r,
-			BMI160_USER_OFFSET_4_GYRO_OFF_Y);
-			com_rslt += p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_OFFSET_6_GYRO_OFF_Y__REG,
-			&v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			v_data2_u8r = BMI160_GET_BITSLICE(v_data2_u8r,
-			BMI160_USER_OFFSET_6_GYRO_OFF_Y);
-			v_data3_u8r = v_data2_u8r
-			<< BMI160_SHIFT_BIT_POSITION_BY_14_BITS;
-			v_data4_u8r =  v_data1_u8r
-			<< BMI160_SHIFT_BIT_POSITION_BY_06_BITS;
-			v_data3_u8r = v_data3_u8r | v_data4_u8r;
-			*v_gyro_off_y_s16 = v_data3_u8r
-			>> BMI160_SHIFT_BIT_POSITION_BY_06_BITS;
+ * @brief This API reads accel and gyro data along with sensor time
+ * if time is requested by user.
+ *  Kindly refer the user guide(README.md) for more info.
+ */
+static int8_t get_accel_gyro_data(uint8_t len, struct bmi160_sensor_data *accel, struct bmi160_sensor_data *gyro,
+					const struct bmi160_dev *dev)
+{
+	int8_t rslt;
+	uint8_t idx = 0;
+	uint8_t data_array[15] = {0};
+	uint8_t time_0 = 0;
+	uint16_t time_1 = 0;
+	uint32_t time_2 = 0;
+	uint8_t lsb;
+	uint8_t msb;
+	int16_t msblsb;
+
+	/* read both accel and gyro sensor data
+	 * along with time if requested */
+	rslt = bmi160_get_regs(BMI160_GYRO_DATA_ADDR, data_array, 12 + len, dev);
+	if (rslt == BMI160_OK) {
+		/* Gyro Data */
+		lsb = data_array[idx++];
+		msb = data_array[idx++];
+		msblsb = (int16_t)((msb << 8) | lsb);
+		gyro->x = msblsb; /* gyro X axis data */
+
+		lsb = data_array[idx++];
+		msb = data_array[idx++];
+		msblsb = (int16_t)((msb << 8) | lsb);
+		gyro->y = msblsb; /* gyro Y axis data */
+
+		lsb = data_array[idx++];
+		msb = data_array[idx++];
+		msblsb = (int16_t)((msb << 8) | lsb);
+		gyro->z = msblsb; /* gyro Z axis data */
+
+		/* Accel Data */
+		lsb = data_array[idx++];
+		msb = data_array[idx++];
+		msblsb = (int16_t)((msb << 8) | lsb);
+		accel->x = (int16_t)msblsb; /* accel X axis data */
+
+		lsb = data_array[idx++];
+		msb = data_array[idx++];
+		msblsb = (int16_t)((msb << 8) | lsb);
+		accel->y = (int16_t)msblsb; /* accel Y axis data */
+
+		lsb = data_array[idx++];
+		msb = data_array[idx++];
+		msblsb = (int16_t)((msb << 8) | lsb);
+		accel->z = (int16_t)msblsb; /* accel Z axis data */
+
+		if (len == 3) {
+			time_0 = data_array[idx++];
+			time_1 = (uint16_t)(data_array[idx++] << 8);
+			time_2 = (uint32_t)(data_array[idx++] << 16);
+			accel->sensortime = (uint32_t)(time_2 | time_1 | time_0);
+			gyro->sensortime = (uint32_t)(time_2 | time_1 | time_0);
+		} else {
+			accel->sensortime = 0;
+			gyro->sensortime = 0;
 		}
-	return com_rslt;
+	} else {
+		rslt = BMI160_E_COM_FAIL;
+	}
+
+	return rslt;
 }
+
 /*!
- *	@brief This API writes gyro manual offset compensation of y axis
- *	in the register 0x75 bit 0 to 7 and 0x77 bit 2 and 3
- *
- *
- *
- *  @param v_gyro_off_y_s16:
- *	The value of gyro manual offset compensation of y axis
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_offset_compensation_yaxis(
-s16 v_gyro_off_y_s16)
+ * @brief This API enables the any-motion interrupt for accel.
+ */
+static int8_t enable_accel_any_motion_int(const struct bmi160_acc_any_mot_int_cfg *any_motion_int_cfg,
+						struct bmi160_dev *dev)
 {
-/* variable used to return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data1_u8r, v_data2_u8r = BMI160_INIT_VALUE;
-u16 v_data3_u8r = BMI160_INIT_VALUE;
-u8 v_status_s8 = SUCCESS;
-/* check the p_bmi160 structure for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-	} else {
-		/* enable gyro offset bit */
-		v_status_s8 = bmi160_set_gyro_offset_enable(
-		GYRO_OFFSET_ENABLE);
-		/* write gyro offset y*/
-		if (v_status_s8 == SUCCESS) {
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_OFFSET_4_GYRO_OFF_Y__REG,
-			&v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			if (com_rslt == SUCCESS) {
-				v_data1_u8r =
-				((s8) (v_gyro_off_y_s16 &
-				BMI160_GYRO_MANUAL_OFFSET_0_7));
-				v_data2_u8r = BMI160_SET_BITSLICE(
-				v_data2_u8r,
-				BMI160_USER_OFFSET_4_GYRO_OFF_Y,
-				v_data1_u8r);
-				/* write 0x75 bit 0 to 7*/
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC
-				(p_bmi160->dev_addr,
-				BMI160_USER_OFFSET_4_GYRO_OFF_Y__REG,
-				&v_data2_u8r,
-				BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
+	int8_t rslt;
+	uint8_t data = 0;
+	uint8_t temp = 0;
 
-			com_rslt += p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_OFFSET_6_GYRO_OFF_Y__REG,
-			&v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			if (com_rslt == SUCCESS) {
-				v_data3_u8r =
-				(u16) (v_gyro_off_y_s16 &
-				BMI160_GYRO_MANUAL_OFFSET_8_9);
-				v_data1_u8r = (u8)(v_data3_u8r
-				>> BMI160_SHIFT_BIT_POSITION_BY_08_BITS);
-				v_data2_u8r = BMI160_SET_BITSLICE(
-				v_data2_u8r,
-				BMI160_USER_OFFSET_6_GYRO_OFF_Y,
-				v_data1_u8r);
-				/* write 0x77 bit 2 and 3*/
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC
-				(p_bmi160->dev_addr,
-				BMI160_USER_OFFSET_6_GYRO_OFF_Y__REG,
-				&v_data2_u8r,
-				BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
+	/* Enable any motion x, any motion y, any motion z
+	in Int Enable 0 register */
+	rslt = bmi160_get_regs(BMI160_INT_ENABLE_0_ADDR, &data, 1, dev);
+	if (rslt == BMI160_OK) {
+
+		if (any_motion_int_cfg->anymotion_en == BMI160_ENABLE) {
+			temp = data & ~BMI160_ANY_MOTION_X_INT_EN_MASK;
+			/* Adding Any_motion x axis */
+			data = temp | (any_motion_int_cfg->anymotion_x & BMI160_ANY_MOTION_X_INT_EN_MASK);
+
+
+			temp = data & ~BMI160_ANY_MOTION_Y_INT_EN_MASK;
+			/* Adding Any_motion y axis */
+			data = temp | ((any_motion_int_cfg->anymotion_y << 1) & BMI160_ANY_MOTION_Y_INT_EN_MASK);
+
+
+			temp = data & ~BMI160_ANY_MOTION_Z_INT_EN_MASK;
+			/* Adding Any_motion z axis */
+			data = temp | ((any_motion_int_cfg->anymotion_z << 2) & BMI160_ANY_MOTION_Z_INT_EN_MASK);
+
+			/* any-motion feature selected*/
+			dev->any_sig_sel = BMI160_ANY_MOTION_ENABLED;
 		} else {
-		return ERROR;
+			data = data & ~BMI160_ANY_MOTION_ALL_INT_EN_MASK;
+			/* neither any-motion feature nor sig-motion selected */
+			dev->any_sig_sel = BMI160_BOTH_ANY_SIG_MOTION_DISABLED;
 		}
+
+		/* write data to Int Enable 0 register */
+		rslt = bmi160_set_regs(BMI160_INT_ENABLE_0_ADDR, &data, 1, dev);
 	}
-return com_rslt;
+
+	return rslt;
 }
+
 /*!
- *	@brief This API reads the gyro manual offset compensation of z axis
- *	from the register 0x76 bit 0 to 7 and 0x77 bit 4 and 5
- *
- *
- *
- *  @param v_gyro_off_z_s16:
- *	The value of gyro manual offset compensation of z axis
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_offset_compensation_zaxis(
-s16 *v_gyro_off_z_s16)
+ * @brief This API disable the sig-motion interrupt.
+ */
+static int8_t disable_sig_motion_int(const struct bmi160_dev *dev)
 {
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
-	u8 v_data1_u8r = BMI160_INIT_VALUE;
-	u8 v_data2_u8r = BMI160_INIT_VALUE;
-	s16 v_data3_u8r, v_data4_u8r = BMI160_INIT_VALUE;
-	/* check the p_bmi160 structure for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read gyro manual offset z axis*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_OFFSET_5_GYRO_OFF_Z__REG,
-			&v_data1_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			v_data1_u8r = BMI160_GET_BITSLICE
-			(v_data1_u8r,
-			BMI160_USER_OFFSET_5_GYRO_OFF_Z);
-			com_rslt +=
-			p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_OFFSET_6_GYRO_OFF_Z__REG,
-			&v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			v_data2_u8r = BMI160_GET_BITSLICE(
-			v_data2_u8r,
-			BMI160_USER_OFFSET_6_GYRO_OFF_Z);
-			v_data3_u8r = v_data2_u8r
-			<< BMI160_SHIFT_BIT_POSITION_BY_14_BITS;
-			v_data4_u8r =  v_data1_u8r
-			<< BMI160_SHIFT_BIT_POSITION_BY_06_BITS;
-			v_data3_u8r = v_data3_u8r | v_data4_u8r;
-			*v_gyro_off_z_s16 = v_data3_u8r
-			>> BMI160_SHIFT_BIT_POSITION_BY_06_BITS;
+	int8_t rslt;
+	uint8_t data = 0;
+	uint8_t temp = 0;
+
+	/* Disabling Significant motion interrupt if enabled */
+	rslt = bmi160_get_regs(BMI160_INT_MOTION_3_ADDR, &data, 1, dev);
+	if (rslt == BMI160_OK) {
+		temp = (data & BMI160_SIG_MOTION_SEL_MASK);
+		if (temp) {
+			temp = data & ~BMI160_SIG_MOTION_SEL_MASK;
+			data = temp;
+			/* Write data to register */
+			rslt = bmi160_set_regs(BMI160_INT_MOTION_3_ADDR, &data, 1, dev);
 		}
-	return com_rslt;
+	}
+	return rslt;
 }
+
 /*!
- *	@brief This API writes gyro manual offset compensation of z axis
- *	in the register 0x76 bit 0 to 7 and 0x77 bit 4 and 5
- *
- *
- *
- *  @param v_gyro_off_z_s16:
- *	The value of gyro manual offset compensation of z axis
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_offset_compensation_zaxis(
-s16 v_gyro_off_z_s16)
+ * @brief This API maps the INT pin to any-motion or
+ * sig-motion interrupt.
+ */
+static int8_t map_int_pin_to_sig_any_motion(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
 {
-/* variable used to return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data1_u8r, v_data2_u8r = BMI160_INIT_VALUE;
-u16 v_data3_u8r = BMI160_INIT_VALUE;
-u8 v_status_s8 = SUCCESS;
-/* check the p_bmi160 structure for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-	} else {
-		/* enable gyro offset*/
-		v_status_s8 = bmi160_set_gyro_offset_enable(
-		GYRO_OFFSET_ENABLE);
-		/* write gyro manual offset z axis*/
-		if (v_status_s8 == SUCCESS) {
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_OFFSET_5_GYRO_OFF_Z__REG,
-			&v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			if (com_rslt == SUCCESS) {
-				v_data1_u8r =
-				((u8) (v_gyro_off_z_s16 &
-				BMI160_GYRO_MANUAL_OFFSET_0_7));
-				v_data2_u8r = BMI160_SET_BITSLICE(
-				v_data2_u8r,
-				BMI160_USER_OFFSET_5_GYRO_OFF_Z,
-				v_data1_u8r);
-				/* write 0x76 bit 0 to 7*/
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC
-				(p_bmi160->dev_addr,
-				BMI160_USER_OFFSET_5_GYRO_OFF_Z__REG,
-				&v_data2_u8r,
-				BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
+	int8_t rslt;
+	uint8_t data = 0;
+	uint8_t temp = 0;
 
-			com_rslt += p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_OFFSET_6_GYRO_OFF_Z__REG,
-			&v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			if (com_rslt == SUCCESS) {
-				v_data3_u8r =
-				(u16) (v_gyro_off_z_s16 &
-				BMI160_GYRO_MANUAL_OFFSET_8_9);
-				v_data1_u8r = (u8)(v_data3_u8r
-				>> BMI160_SHIFT_BIT_POSITION_BY_08_BITS);
-				v_data2_u8r = BMI160_SET_BITSLICE(
-				v_data2_u8r,
-				BMI160_USER_OFFSET_6_GYRO_OFF_Z,
-				v_data1_u8r);
-				/* write 0x77 bit 4 and 5*/
-				com_rslt +=
-				p_bmi160->BMI160_BUS_WRITE_FUNC
-				(p_bmi160->dev_addr,
-				BMI160_USER_OFFSET_6_GYRO_OFF_Z__REG,
-				&v_data2_u8r,
-				BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
-		} else {
-		return ERROR;
+	/* Configure Int Map register to map interrupt pin to
+	Slope/Any motion interrupt */
+	if (int_config->int_channel == BMI160_INT_CHANNEL_1) {
+		rslt = bmi160_get_regs(BMI160_INT_MAP_0_ADDR, &data, 1, dev);
+		if (rslt == BMI160_OK) {
+			temp = data & ~BMI160_INT1_SLOPE_MASK;
+			data = temp | ((1 << 2) & BMI160_INT1_SLOPE_MASK);
+			rslt = bmi160_set_regs(BMI160_INT_MAP_0_ADDR, &data, 1, dev);
+		}
+	} else {
+		rslt = bmi160_get_regs(BMI160_INT_MAP_2_ADDR, &data, 1, dev);
+		if (rslt == BMI160_OK) {
+			temp = data & ~BMI160_INT2_SLOPE_MASK;
+			data = temp | ((1 << 2) & BMI160_INT2_SLOPE_MASK);
+			rslt = bmi160_set_regs(BMI160_INT_MAP_2_ADDR, &data, 1, dev);
 		}
 	}
-return com_rslt;
+
+	return rslt;
 }
+
 /*!
- *	@brief This API reads the Accel offset enable bit
- *	from the register 0x77 bit 6
- *
- *
- *
- *  @param v_accel_off_enable_u8: The value of Accel offset enable
- *  value    |  Description
- * ----------|--------------
- *   0x01    | ENABLE
- *   0x00    | DISABLE
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_offset_enable(
-u8 *v_accel_off_enable_u8)
+ * @brief This API configure the source of data(filter & pre-filter)
+ * for any-motion interrupt.
+ */
+static int8_t config_any_motion_src(const struct bmi160_acc_any_mot_int_cfg *any_motion_int_cfg,
+					const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read Accel offset enable */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_OFFSET_6_ACCEL_OFF_ENABLE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_accel_off_enable_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_OFFSET_6_ACCEL_OFF_ENABLE);
-		}
-	return com_rslt;
+	int8_t rslt;
+	uint8_t data = 0;
+	uint8_t temp = 0;
+
+	/* Configure Int data 1 register to add source of interrupt */
+	rslt = bmi160_get_regs(BMI160_INT_DATA_1_ADDR, &data, 1, dev);
+	if (rslt == BMI160_OK) {
+		temp = data & ~BMI160_MOTION_SRC_INT_MASK;
+		data = temp | ((any_motion_int_cfg->anymotion_data_src << 7) & BMI160_MOTION_SRC_INT_MASK);
+		/* Write data to DATA 1 address */
+		rslt = bmi160_set_regs(BMI160_INT_DATA_1_ADDR, &data, 1, dev);
+	}
+
+	return rslt;
 }
+
 /*!
- *	@brief This API writes the Accel offset enable bit
- *	in the register 0x77 bit 6
- *
- *
- *
- *  @param v_accel_off_enable_u8: The value of Accel offset enable
- *  value    |  Description
- * ----------|--------------
- *   0x01    | ENABLE
- *   0x00    | DISABLE
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_offset_enable(
-u8 v_accel_off_enable_u8)
+ * @brief This API configure the duration and threshold of
+ * any-motion interrupt.
+ */
+static int8_t config_any_dur_threshold(const struct bmi160_acc_any_mot_int_cfg *any_motion_int_cfg,
+					const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-			} else {
-			/* write Accel offset enable */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_OFFSET_6_ACCEL_OFF_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_OFFSET_6_ACCEL_OFF_ENABLE,
-				v_accel_off_enable_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_OFFSET_6_ACCEL_OFF_ENABLE__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
+	int8_t rslt;
+	uint8_t data = 0;
+	uint8_t temp = 0;
+	uint8_t data_array[2] = {0};
+	uint8_t dur;
+
+	/* Configure Int Motion 0 register */
+	rslt = bmi160_get_regs(BMI160_INT_MOTION_0_ADDR, &data, 1, dev);
+	if (rslt == BMI160_OK) {
+		/* slope duration */
+		dur = (uint8_t)any_motion_int_cfg->anymotion_dur;
+		temp = data & ~BMI160_SLOPE_INT_DUR_MASK;
+		data = temp | (dur & BMI160_MOTION_SRC_INT_MASK);
+		data_array[0] = data;
+		/* add slope threshold */
+		data_array[1] = any_motion_int_cfg->anymotion_thr;
+
+		/* INT MOTION 0 and INT MOTION 1 address lie consecutively,
+		hence writing data to respective registers at one go */
+		/* Writing to Int_motion 0 and
+		Int_motion 1 Address simultaneously */
+		rslt = bmi160_set_regs(BMI160_INT_MOTION_0_ADDR, data_array, 2, dev);
+	}
+
+	return rslt;
+}
+
+/*!
+ * @brief This API configure necessary setting of any-motion interrupt.
+ */
+static int8_t config_any_motion_int_settg(const struct bmi160_int_settg *int_config,
+					const struct bmi160_acc_any_mot_int_cfg *any_motion_int_cfg,
+					const struct bmi160_dev *dev)
+{
+	int8_t rslt;
+	/* Configure Interrupt pins */
+	rslt = set_intr_pin_config(int_config, dev);
+	if (rslt == BMI160_OK) {
+		rslt = disable_sig_motion_int(dev);
+		if (rslt == BMI160_OK) {
+			rslt = map_int_pin_to_sig_any_motion(int_config, dev);
+			if (rslt == BMI160_OK) {
+				rslt = config_any_motion_src(any_motion_int_cfg, dev);
+				if (rslt == BMI160_OK)
+					rslt = config_any_dur_threshold(any_motion_int_cfg, dev);
 			}
 		}
-	return com_rslt;
+	}
+
+	return rslt;
 }
+
 /*!
- *	@brief This API reads the Accel offset enable bit
- *	from the register 0x77 bit 7
- *
- *
- *
- *  @param v_gyro_off_enable_u8: The value of gyro offset enable
- *  value    |  Description
- * ----------|--------------
- *   0x01    | ENABLE
- *   0x00    | DISABLE
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_offset_enable(
-u8 *v_gyro_off_enable_u8)
+ * @brief This API enable the data ready interrupt.
+ */
+static int8_t enable_data_ready_int(const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read gyro offset*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_OFFSET_6_GYRO_OFF_EN__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_gyro_off_enable_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_OFFSET_6_GYRO_OFF_EN);
-		}
-	return com_rslt;
+	int8_t rslt;
+	uint8_t data = 0;
+	uint8_t temp = 0;
+
+	/* Enable data ready interrupt in Int Enable 1 register */
+	rslt = bmi160_get_regs(BMI160_INT_ENABLE_1_ADDR, &data, 1, dev);
+	if (rslt == BMI160_OK) {
+		temp = data & ~BMI160_DATA_RDY_INT_EN_MASK;
+		data = temp | ((1 << 4) & BMI160_DATA_RDY_INT_EN_MASK);
+		/* Writing data to INT ENABLE 1 Address */
+		rslt = bmi160_set_regs(BMI160_INT_ENABLE_1_ADDR, &data, 1, dev);
+	}
+
+	return rslt;
 }
+
 /*!
- *	@brief This API writes the gyro offset enable bit
- *	in the register 0x77 bit 7
- *
- *
- *
- *  @param v_gyro_off_enable_u8: The value of gyro offset enable
- *  value    |  Description
- * ----------|--------------
- *   0x01    | ENABLE
- *   0x00    | DISABLE
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_offset_enable(
-u8 v_gyro_off_enable_u8)
+ * @brief This API maps the data ready interrupt to INT pin as per selection.
+ */
+static int8_t map_data_ready_int(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
+	int8_t rslt;
+	uint8_t data = 0;
+	uint8_t temp = 0;
+
+	/* Configure Map register to map interrupt pin to data ready interrupt*/
+	rslt = bmi160_get_regs(BMI160_INT_MAP_1_ADDR, &data, 1, dev);
+
+	if (rslt == BMI160_OK) {
+		if (int_config->int_channel == BMI160_INT_CHANNEL_1) {
+			temp = data & ~BMI160_INT1_DATA_READY_MASK;
+			data = temp | ((1 << 7) & BMI160_INT1_DATA_READY_MASK);
 		} else {
-			/* write gyro offset*/
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_OFFSET_6_GYRO_OFF_EN__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_OFFSET_6_GYRO_OFF_EN,
-				v_gyro_off_enable_u8);
-				com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
-				p_bmi160->dev_addr,
-				BMI160_USER_OFFSET_6_GYRO_OFF_EN__REG,
-				&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-				/*Accel and Gyro power mode check*/
-				if (bmi160_power_mode_status_u8_g !=
-				BMI160_NORMAL_MODE)
-					/*interface idle time delay */
-					p_bmi160->delay_msec(
-					BMI160_GEN_READ_WRITE_DELAY);
-			}
+			temp = data & ~BMI160_INT2_DATA_READY_MASK;
+			data = temp | ((1 << 3) & BMI160_INT2_DATA_READY_MASK);
 		}
-	return com_rslt;
+		/* Writing data to Map 1 address */
+		rslt = bmi160_set_regs(BMI160_INT_MAP_1_ADDR, &data, 1, dev);
+	}
+
+	return rslt;
 }
+
 /*!
- *	@brief This API reads step counter output value
- *	from the register 0x78 and 0x79
- *
- *
- *
- *
- *  @param v_step_cnt_s16 : The value of step counter output
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_step_count(s16 *v_step_cnt_s16)
+ * @brief This API enables the no motion/slow motion interrupt.
+ */
+static int8_t enable_no_motion_int(const struct bmi160_acc_no_motion_int_cfg *no_mot_int_cfg,
+					const struct bmi160_dev *dev)
 {
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* array having the step counter LSB and MSB data
-	v_data_u8[0] - LSB
-	v_data_u8[1] - MSB*/
-	u8 a_data_u8r[BMI160_STEP_COUNT_DATA_SIZE] = {BMI160_INIT_VALUE,
-	BMI160_INIT_VALUE};
-	/* check the p_bmi160 structure for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* read step counter */
-			com_rslt =
-			p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
-			BMI160_USER_STEP_COUNT_LSB__REG,
-			a_data_u8r, BMI160_STEP_COUNTER_LENGTH);
-
-			*v_step_cnt_s16 = (s16)
-			((((s32)((s8)a_data_u8r[BMI160_STEP_COUNT_MSB_BYTE]))
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-			| (a_data_u8r[BMI160_STEP_COUNT_LSB_BYTE]));
+	int8_t rslt;
+	uint8_t data = 0;
+	uint8_t temp = 0;
+	/* Enable no motion x, no motion y, no motion z
+	in Int Enable 2 register */
+	rslt = bmi160_get_regs(BMI160_INT_ENABLE_2_ADDR, &data, 1, dev);
+	if (rslt == BMI160_OK) {
+		if (no_mot_int_cfg->no_motion_x == 1) {
+			temp = data & ~BMI160_NO_MOTION_X_INT_EN_MASK;
+			/* Adding No_motion x axis */
+			data = temp | (1 & BMI160_NO_MOTION_X_INT_EN_MASK);
 		}
-	return com_rslt;
+		if (no_mot_int_cfg->no_motion_y == 1) {
+			temp = data & ~BMI160_NO_MOTION_Y_INT_EN_MASK;
+			/* Adding No_motion x axis */
+			data = temp | ((1 << 1) & BMI160_NO_MOTION_Y_INT_EN_MASK);
+		}
+		if (no_mot_int_cfg->no_motion_z == 1) {
+			temp = data & ~BMI160_NO_MOTION_Z_INT_EN_MASK;
+			/* Adding No_motion x axis */
+			data = temp | ((1 << 2) & BMI160_NO_MOTION_Z_INT_EN_MASK);
+		}
+		/* write data to Int Enable 2 register */
+		rslt = bmi160_set_regs(BMI160_INT_ENABLE_2_ADDR, &data, 1, dev);
+	}
+
+	return rslt;
 }
- /*!
- *	@brief This API reads
- *	step counter configuration
- *	from the register 0x7A bit 0 to 7
- *	and also from the register 0x7B bit 0 to 2 and 4 to 7
- *
- *
- *  @param v_step_config_u16 : The value of step counter configuration
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_step_config(
-u16 *v_step_config_u16)
+
+/*!
+ * @brief This API configure the interrupt PIN setting for
+ * no motion/slow motion interrupt.
+ */
+static int8_t config_no_motion_int_settg(const struct bmi160_int_settg *int_config,
+					const struct bmi160_acc_no_motion_int_cfg *no_mot_int_cfg,
+					const struct bmi160_dev *dev)
 {
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	u8 v_data1_u8r = BMI160_INIT_VALUE;
-	u8 v_data2_u8r = BMI160_INIT_VALUE;
-	u16 v_data3_u8r = BMI160_INIT_VALUE;
-	/* Read the 0 to 7 bit*/
-	com_rslt =
-	p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
-	BMI160_USER_STEP_CONFIG_ZERO__REG,
-	&v_data1_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	/* Read the 8 to 10 bit*/
-	com_rslt +=
-	p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
-	BMI160_USER_STEP_CONFIG_ONE_CNF1__REG,
-	&v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	v_data2_u8r = BMI160_GET_BITSLICE(v_data2_u8r,
-	BMI160_USER_STEP_CONFIG_ONE_CNF1);
-	v_data3_u8r = ((u16)((((u32)
-	((u8)v_data2_u8r))
-	<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS) | (v_data1_u8r)));
-	/* Read the 11 to 14 bit*/
-	com_rslt +=
-	p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
-	BMI160_USER_STEP_CONFIG_ONE_CNF2__REG,
-	&v_data1_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	v_data1_u8r = BMI160_GET_BITSLICE(v_data1_u8r,
-	BMI160_USER_STEP_CONFIG_ONE_CNF2);
-	*v_step_config_u16 = ((u16)((((u32)
-	((u8)v_data1_u8r))
-	<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS) | (v_data3_u8r)));
-
-	return com_rslt;
+	int8_t rslt;
+
+	/* Configure Interrupt pins */
+	rslt = set_intr_pin_config(int_config, dev);
+	if (rslt == BMI160_OK) {
+		rslt = map_int_pin_to_no_motion(int_config, dev);
+		if (rslt == BMI160_OK) {
+			rslt = config_no_motion_data_src(no_mot_int_cfg, dev);
+			if (rslt == BMI160_OK)
+				rslt = config_no_motion_dur_thr(no_mot_int_cfg, dev);
+		}
+	}
+
+	return rslt;
 }
- /*!
- *	@brief This API writes the
- *	step counter configuration
- *	in the register 0x7A bit 0 to 7
- *	and also in the register 0x7B bit 0 to 2 and 4 to 7
- *
- *
- *  @param v_step_config_u16   :
- *	the value of step configuration
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_step_config(
-u16 v_step_config_u16)
+
+/*!
+ * @brief This API maps the INT pin to no motion/slow interrupt.
+ */
+static int8_t map_int_pin_to_no_motion(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
+{
+	int8_t rslt;
+	uint8_t temp = 0;
+	uint8_t data = 0;
+
+	/* Configure Int Map register to map interrupt pin
+	 * to No motion interrupt */
+	if (int_config->int_channel == BMI160_INT_CHANNEL_1) {
+		rslt = bmi160_get_regs(BMI160_INT_MAP_0_ADDR, &data, 1, dev);
+		if (rslt == BMI160_OK) {
+			temp = data & ~BMI160_INT1_NO_MOTION_MASK;
+			data = temp | ((1 << 3) & BMI160_INT1_NO_MOTION_MASK);
+			/* Write data to appropriate MAP address */
+			rslt = bmi160_set_regs(BMI160_INT_MAP_0_ADDR, &data, 1, dev);
+		}
+	} else {
+		rslt = bmi160_get_regs(BMI160_INT_MAP_2_ADDR, &data, 1, dev);
+		if (rslt == BMI160_OK) {
+			temp = data & ~BMI160_INT2_NO_MOTION_MASK;
+			data = temp | ((1 << 3) & BMI160_INT2_NO_MOTION_MASK);
+			/* Write data to appropriate MAP address */
+			rslt = bmi160_set_regs(BMI160_INT_MAP_2_ADDR, &data, 1, dev);
+		}
+	}
+
+	return rslt;
+}
+
+/*!
+ * @brief This API configure the source of interrupt for no motion.
+ */
+static int8_t config_no_motion_data_src(const struct bmi160_acc_no_motion_int_cfg *no_mot_int_cfg,
+					const struct bmi160_dev *dev)
 {
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	u8 v_data1_u8r = BMI160_INIT_VALUE;
-	u8 v_data2_u8r = BMI160_INIT_VALUE;
-	u16 v_data3_u16 = BMI160_INIT_VALUE;
-
-	/* write the 0 to 7 bit*/
-	v_data1_u8r = (u8)(v_step_config_u16 &
-	BMI160_STEP_CONFIG_0_7);
-	p_bmi160->BMI160_BUS_WRITE_FUNC
-	(p_bmi160->dev_addr,
-	BMI160_USER_STEP_CONFIG_ZERO__REG,
-	&v_data1_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-	/*Accel and Gyro power mode check*/
-	if (bmi160_power_mode_status_u8_g != BMI160_NORMAL_MODE)
-		/*interface idle time delay */
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-
-	/* write the 8 to 10 bit*/
-	com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-	(p_bmi160->dev_addr,
-	BMI160_USER_STEP_CONFIG_ONE_CNF1__REG,
-	&v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	if (com_rslt == SUCCESS) {
-		v_data3_u16 = (u16) (v_step_config_u16 &
-		BMI160_STEP_CONFIG_8_10);
-		v_data1_u8r = (u8)(v_data3_u16
-		>> BMI160_SHIFT_BIT_POSITION_BY_08_BITS);
-		v_data2_u8r = BMI160_SET_BITSLICE(v_data2_u8r,
-		BMI160_USER_STEP_CONFIG_ONE_CNF1, v_data1_u8r);
-		p_bmi160->BMI160_BUS_WRITE_FUNC
-		(p_bmi160->dev_addr,
-		BMI160_USER_STEP_CONFIG_ONE_CNF1__REG,
-		&v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-		/*Accel and Gyro power mode check*/
-		if (bmi160_power_mode_status_u8_g != BMI160_NORMAL_MODE)
-			/*interface idle time delay */
-			p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	int8_t rslt;
+	uint8_t data = 0;
+	uint8_t temp = 0;
 
+	/* Configure Int data 1 register to add source of interrupt */
+	rslt = bmi160_get_regs(BMI160_INT_DATA_1_ADDR, &data, 1, dev);
+	if (rslt == BMI160_OK) {
+		temp = data & ~BMI160_MOTION_SRC_INT_MASK;
+		data = temp | ((no_mot_int_cfg->no_motion_src << 7) & BMI160_MOTION_SRC_INT_MASK);
+		/* Write data to DATA 1 address */
+		rslt = bmi160_set_regs(BMI160_INT_DATA_1_ADDR, &data, 1, dev);
 	}
-	/* write the 11 to 14 bit*/
-	com_rslt += p_bmi160->BMI160_BUS_READ_FUNC
-	(p_bmi160->dev_addr,
-	BMI160_USER_STEP_CONFIG_ONE_CNF2__REG,
-	&v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	if (com_rslt == SUCCESS) {
-		v_data3_u16 = (u16) (v_step_config_u16 &
-		BMI160_STEP_CONFIG_11_14);
-		v_data1_u8r = (u8)(v_data3_u16
-		>> BMI160_SHIFT_BIT_POSITION_BY_12_BITS);
-		v_data2_u8r = BMI160_SET_BITSLICE(v_data2_u8r,
-		BMI160_USER_STEP_CONFIG_ONE_CNF2, v_data1_u8r);
-		p_bmi160->BMI160_BUS_WRITE_FUNC
-		(p_bmi160->dev_addr,
-		BMI160_USER_STEP_CONFIG_ONE_CNF2__REG,
-		&v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-		/*Accel and Gyro power mode check*/
-		if (bmi160_power_mode_status_u8_g != BMI160_NORMAL_MODE)
-			/*interface idle time delay */
-			p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+
+	return rslt;
+}
+
+/*!
+ * @brief This API configure the duration and threshold of
+ * no motion/slow motion interrupt along with selection of no/slow motion.
+ */
+static int8_t config_no_motion_dur_thr(const struct bmi160_acc_no_motion_int_cfg *no_mot_int_cfg,
+					const struct bmi160_dev *dev)
+{
+	int8_t rslt;
+	uint8_t data = 0;
+	uint8_t temp = 0;
+	uint8_t temp_1 = 0;
+	uint8_t reg_addr;
+	uint8_t data_array[2] = {0};
+
+	/* Configuring INT_MOTION register */
+	reg_addr = BMI160_INT_MOTION_0_ADDR;
+	rslt = bmi160_get_regs(reg_addr, &data, 1, dev);
+	if (rslt == BMI160_OK) {
+		temp = data & ~BMI160_NO_MOTION_INT_DUR_MASK;
+		/* Adding no_motion duration */
+		data = temp | ((no_mot_int_cfg->no_motion_dur << 2) & BMI160_NO_MOTION_INT_DUR_MASK);
+		/* Write data to NO_MOTION 0 address */
+		rslt = bmi160_set_regs(reg_addr, &data, 1, dev);
+		if (rslt == BMI160_OK) {
+			reg_addr = BMI160_INT_MOTION_3_ADDR;
+			rslt = bmi160_get_regs(reg_addr, &data, 1, dev);
+			if (rslt == BMI160_OK) {
+				temp = data & ~BMI160_NO_MOTION_SEL_BIT_MASK;
+				/* Adding no_motion_sel bit */
+				temp_1 = (no_mot_int_cfg->no_motion_sel & BMI160_NO_MOTION_SEL_BIT_MASK);
+				data = (temp | temp_1);
+				data_array[1] = data;
+				/* Adding no motion threshold */
+				data_array[0] = no_mot_int_cfg->no_motion_thres;
+				reg_addr = BMI160_INT_MOTION_2_ADDR;
+				/* writing data to INT_MOTION 2 and INT_MOTION 3
+				 * address simultaneously */
+				rslt = bmi160_set_regs(reg_addr, data_array, 2, dev);
+			}
+		}
 	}
 
-	return com_rslt;
+	return rslt;
 }
- /*!
- *	@brief This API is used to get the step counter enable/disable status
- *	from the register 0x7B bit 3
- *
- *
- *  @param v_step_counter_u8 : The value of step counter enable
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_step_counter_enable(
-u8 *v_step_counter_u8)
+
+/*!
+ * @brief This API enables the sig-motion motion interrupt.
+ */
+static int8_t enable_sig_motion_int(const struct bmi160_acc_sig_mot_int_cfg *sig_mot_int_cfg, struct bmi160_dev *dev)
 {
-	/* variable used to 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 for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
+	int8_t rslt;
+	uint8_t data = 0;
+	uint8_t temp = 0;
+
+	/* For significant motion,enable any motion x,any motion y,
+	 * any motion z in Int Enable 0 register */
+	rslt = bmi160_get_regs(BMI160_INT_ENABLE_0_ADDR, &data, 1, dev);
+	if (rslt == BMI160_OK) {
+		if (sig_mot_int_cfg->sig_en == BMI160_ENABLE) {
+			temp = data & ~BMI160_SIG_MOTION_INT_EN_MASK;
+			data = temp | (7 & BMI160_SIG_MOTION_INT_EN_MASK);
+			/* sig-motion feature selected*/
+			dev->any_sig_sel = BMI160_SIG_MOTION_ENABLED;
 		} else {
-			/* read the step counter */
-			com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			*v_step_counter_u8 = BMI160_GET_BITSLICE(v_data_u8,
-			BMI160_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE);
+			data = data & ~BMI160_SIG_MOTION_INT_EN_MASK;
+			/* neither any-motion feature nor sig-motion selected */
+			dev->any_sig_sel = BMI160_BOTH_ANY_SIG_MOTION_DISABLED;
 		}
-	return com_rslt;
+		/* write data to Int Enable 0 register */
+		rslt = bmi160_set_regs(BMI160_INT_ENABLE_0_ADDR, &data, 1, dev);
+	}
+	return rslt;
 }
- /*!
- *	@brief This API is used to enable step counter
- *	by setting the register 0x7B bit 3
- *
- *
- *  @param v_step_counter_u8 : The value of step counter enable
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_step_counter_enable(u8 v_step_counter_u8)
+
+/*!
+ * @brief This API configure the interrupt PIN setting for
+ * significant motion interrupt.
+ */
+static int8_t config_sig_motion_int_settg(const struct bmi160_int_settg *int_config,
+					const struct bmi160_acc_sig_mot_int_cfg *sig_mot_int_cfg,
+					const struct bmi160_dev *dev)
 {
-/* variable used to 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 for NULL pointer assignment*/
-if (p_bmi160 == BMI160_NULL) {
-	return E_BMI160_NULL_PTR;
-} else {
-	if (v_step_counter_u8 <= BMI160_MAX_GYRO_STEP_COUNTER) {
-		/* write the step counter */
-		com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
-		(p_bmi160->dev_addr,
-		BMI160_USER_STEP_CONFIG_1_STEP_COUNT_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_STEP_CONFIG_1_STEP_COUNT_ENABLE,
-			v_step_counter_u8);
-			com_rslt +=
-			p_bmi160->BMI160_BUS_WRITE_FUNC
-			(p_bmi160->dev_addr,
-			BMI160_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE__REG,
-			&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
-			/*Accel and Gyro power mode check*/
-			if (bmi160_power_mode_status_u8_g !=
-			BMI160_NORMAL_MODE)
-				/*interface idle time delay */
-				p_bmi160->delay_msec(
-				BMI160_GEN_READ_WRITE_DELAY);
+	int8_t rslt;
+
+	/* Configure Interrupt pins */
+	rslt = set_intr_pin_config(int_config, dev);
+	if (rslt == BMI160_OK) {
+		rslt = map_int_pin_to_sig_any_motion(int_config, dev);
+		if (rslt == BMI160_OK) {
+			rslt = config_sig_motion_data_src(sig_mot_int_cfg, dev);
+			if (rslt == BMI160_OK)
+				rslt = config_sig_dur_threshold(sig_mot_int_cfg, dev);
 		}
-	} else {
-	com_rslt = E_BMI160_OUT_OF_RANGE;
 	}
+
+	return rslt;
 }
-	return com_rslt;
-}
- /*!
- *	@brief This API is used to set step counter modes
- *
- *
- *  @param  v_step_mode_u8 : The value of step counter mode
- *  value    |   mode
- * ----------|-----------
- *   0       | BMI160_STEP_NORMAL_MODE
- *   1       | BMI160_STEP_SENSITIVE_MODE
- *   2       | BMI160_STEP_ROBUST_MODE
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
+
+/*!
+ * @brief This API configure the source of data(filter & pre-filter)
+ * for sig motion interrupt.
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_step_mode(u8 v_step_mode_u8)
+static int8_t config_sig_motion_data_src(const struct bmi160_acc_sig_mot_int_cfg *sig_mot_int_cfg,
+					const struct bmi160_dev *dev)
 {
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-
-	switch (v_step_mode_u8) {
-	case BMI160_STEP_NORMAL_MODE:
-		com_rslt = bmi160_set_step_config(
-		STEP_CONFIG_NORMAL);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	break;
-	case BMI160_STEP_SENSITIVE_MODE:
-		com_rslt = bmi160_set_step_config(
-		STEP_CONFIG_SENSITIVE);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	break;
-	case BMI160_STEP_ROBUST_MODE:
-		com_rslt = bmi160_set_step_config(
-		STEP_CONFIG_ROBUST);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	break;
-	default:
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-	break;
+	int8_t rslt;
+	uint8_t data = 0;
+	uint8_t temp = 0;
+
+	/* Configure Int data 1 register to add source of interrupt */
+	rslt = bmi160_get_regs(BMI160_INT_DATA_1_ADDR, &data, 1, dev);
+	if (rslt == BMI160_OK) {
+		temp = data & ~BMI160_MOTION_SRC_INT_MASK;
+		data = temp | ((sig_mot_int_cfg->sig_data_src << 7) & BMI160_MOTION_SRC_INT_MASK);
+		/* Write data to DATA 1 address */
+		rslt = bmi160_set_regs(BMI160_INT_DATA_1_ADDR, &data, 1, dev);
 	}
 
-	return com_rslt;
+	return rslt;
 }
+
 /*!
- *	@brief This API is used to trigger the  signification motion
- *	interrupt
- *
- *
- *  @param  v_significant_u8 : The value of interrupt selection
- *  value    |  interrupt
- * ----------|-----------
- *   0       |  BMI160_MAP_INTR1
- *   1       |  BMI160_MAP_INTR2
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_map_significant_motion_intr(
-u8 v_significant_u8)
+ * @brief This API configure the threshold, skip and proof time of
+ * sig motion interrupt.
+ */
+static int8_t config_sig_dur_threshold(const struct bmi160_acc_sig_mot_int_cfg *sig_mot_int_cfg,
+					const struct bmi160_dev *dev)
 {
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	u8 v_sig_motion_u8 = BMI160_INIT_VALUE;
-	u8 v_data_u8 = BMI160_INIT_VALUE;
-	u8 v_any_motion_intr1_stat_u8 = BMI160_ENABLE_ANY_MOTION_INTR1;
-	u8 v_any_motion_intr2_stat_u8 = BMI160_ENABLE_ANY_MOTION_INTR2;
-	u8 v_any_motion_axis_stat_u8 = BMI160_ENABLE_ANY_MOTION_AXIS;
-	/* enable the significant motion interrupt */
-	com_rslt = bmi160_get_intr_significant_motion_select(&v_sig_motion_u8);
-	if (v_sig_motion_u8 != BMI160_SIG_MOTION_STAT_HIGH)
-		com_rslt += bmi160_set_intr_significant_motion_select(
-		BMI160_SIG_MOTION_INTR_ENABLE);
-	switch (v_significant_u8) {
-	case BMI160_MAP_INTR1:
-		/* interrupt */
-		com_rslt += bmi160_read_reg(
-		BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__REG,
-		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		v_data_u8 |= v_any_motion_intr1_stat_u8;
-		/* map the signification interrupt to any-motion interrupt1*/
-		com_rslt += bmi160_write_reg(
-		BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__REG,
-		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		/* axis*/
-		com_rslt = bmi160_read_reg(BMI160_USER_INTR_ENABLE_0_ADDR,
-		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		v_data_u8 |= v_any_motion_axis_stat_u8;
-		com_rslt += bmi160_write_reg(
-		BMI160_USER_INTR_ENABLE_0_ADDR,
-		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	break;
-
-	case BMI160_MAP_INTR2:
-		/* map the signification interrupt to any-motion interrupt2*/
-		com_rslt += bmi160_read_reg(
-		BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__REG,
-		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		v_data_u8 |= v_any_motion_intr2_stat_u8;
-		com_rslt += bmi160_write_reg(
-		BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__REG,
-		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		/* axis*/
-		com_rslt = bmi160_read_reg(BMI160_USER_INTR_ENABLE_0_ADDR,
-		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		v_data_u8 |= v_any_motion_axis_stat_u8;
-		com_rslt += bmi160_write_reg(
-		BMI160_USER_INTR_ENABLE_0_ADDR,
-		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	break;
+	int8_t rslt;
+	uint8_t data;
+	uint8_t temp = 0;
 
-	default:
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-	break;
+	/* Configuring INT_MOTION registers */
+	/* Write significant motion threshold.
+	 * This threshold is same as any motion threshold */
+	data = sig_mot_int_cfg->sig_mot_thres;
+	/* Write data to INT_MOTION 1 address */
+	rslt = bmi160_set_regs(BMI160_INT_MOTION_1_ADDR, &data, 1, dev);
+	if (rslt == BMI160_OK) {
+		rslt = bmi160_get_regs(BMI160_INT_MOTION_3_ADDR, &data, 1, dev);
+		if (rslt == BMI160_OK) {
+			temp = data & ~BMI160_SIG_MOTION_SKIP_MASK;
+			/* adding skip time of sig_motion interrupt*/
+			data = temp | ((sig_mot_int_cfg->sig_mot_skip << 2) & BMI160_SIG_MOTION_SKIP_MASK);
+			temp = data & ~BMI160_SIG_MOTION_PROOF_MASK;
+			 /* adding proof time of sig_motion interrupt */
+			data = temp | ((sig_mot_int_cfg->sig_mot_proof << 4) & BMI160_SIG_MOTION_PROOF_MASK);
+			/* configure the int_sig_mot_sel bit to select
+			 * significant motion interrupt */
+			temp = data & ~BMI160_SIG_MOTION_SEL_MASK;
+			data = temp | ((sig_mot_int_cfg->sig_en << 1) & BMI160_SIG_MOTION_SEL_MASK);
 
+			rslt = bmi160_set_regs(BMI160_INT_MOTION_3_ADDR, &data, 1, dev);
+		}
 	}
-	return com_rslt;
+	return rslt;
 }
+
 /*!
- *	@brief This API is used to trigger the step detector
- *	interrupt
- *
- *
- *  @param  v_step_detector_u8 : The value of interrupt selection
- *  value    |  interrupt
- * ----------|-----------
- *   0       |  BMI160_MAP_INTR1
- *   1       |  BMI160_MAP_INTR2
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_map_step_detector_intr(
-u8 v_step_detector_u8)
+ * @brief This API enables the step detector interrupt.
+ */
+static int8_t enable_step_detect_int(const struct bmi160_acc_step_detect_int_cfg *step_detect_int_cfg,
+					const struct bmi160_dev *dev)
 {
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	u8 v_step_det_u8 = BMI160_INIT_VALUE;
-	u8 v_data_u8 = BMI160_INIT_VALUE;
-	u8 v_low_g_intr_u81_stat_u8 = BMI160_LOW_G_INTR_STAT;
-	u8 v_low_g_intr_u82_stat_u8 = BMI160_LOW_G_INTR_STAT;
-	/* read the v_status_s8 of step detector interrupt*/
-	com_rslt = bmi160_get_step_detector_enable(&v_step_det_u8);
-	if (v_step_det_u8 != BMI160_STEP_DET_STAT_HIGH)
-		com_rslt += bmi160_set_step_detector_enable(
-		BMI160_STEP_DETECT_INTR_ENABLE);
-	switch (v_step_detector_u8) {
-	case BMI160_MAP_INTR1:
-		com_rslt += bmi160_read_reg(
-		BMI160_USER_INTR_MAP_0_INTR1_LOW_G__REG,
-		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		v_data_u8 |= v_low_g_intr_u81_stat_u8;
-		/* map the step detector interrupt
-		to Low-g interrupt 1*/
-		com_rslt += bmi160_write_reg(
-		BMI160_USER_INTR_MAP_0_INTR1_LOW_G__REG,
-		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	break;
-	case BMI160_MAP_INTR2:
-		/* map the step detector interrupt
-		to Low-g interrupt 2*/
-		com_rslt += bmi160_read_reg(
-		BMI160_USER_INTR_MAP_2_INTR2_LOW_G__REG,
-		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		v_data_u8 |= v_low_g_intr_u82_stat_u8;
-
-		com_rslt += bmi160_write_reg(
-		BMI160_USER_INTR_MAP_2_INTR2_LOW_G__REG,
-		&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-
-	break;
-	default:
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-	break;
+	int8_t rslt;
+	uint8_t data = 0;
+	uint8_t temp = 0;
+
+	/* Enable data ready interrupt in Int Enable 2 register */
+	rslt = bmi160_get_regs(BMI160_INT_ENABLE_2_ADDR, &data, 1, dev);
+	if (rslt == BMI160_OK) {
+		temp = data & ~BMI160_STEP_DETECT_INT_EN_MASK;
+		data = temp | ((step_detect_int_cfg->step_detector_en << 3) & BMI160_STEP_DETECT_INT_EN_MASK);
+		/* Writing data to INT ENABLE 2 Address */
+		rslt = bmi160_set_regs(BMI160_INT_ENABLE_2_ADDR, &data, 1, dev);
 	}
-	return com_rslt;
+	return rslt;
 }
- /*!
- *	@brief This API is used to clear the step counter interrupt
- *
- *
- *  @param  : None
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_clear_step_counter(void)
+
+/*!
+ * @brief This API maps the INT pin to low-g or step detector interrupt.
+ */
+static int8_t map_int_pin_to_low_step_detect(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
 {
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* clear the step counter*/
-	com_rslt = bmi160_set_command_register(RESET_STEP_COUNTER);
-	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
+	int8_t rslt;
+	uint8_t data = 0;
+	uint8_t temp = 0;
+
 
-	return com_rslt;
+	/* Configure Int Map register to map interrupt pin to step detector */
+	if (int_config->int_channel == BMI160_INT_CHANNEL_1) {
 
+		rslt = bmi160_get_regs(BMI160_INT_MAP_0_ADDR, &data, 1, dev);
+		if (rslt == BMI160_OK) {
+			temp = data & ~BMI160_INT1_LOW_STEP_DETECT_MASK;
+			data = temp | (1 & BMI160_INT1_LOW_STEP_DETECT_MASK);
+			/* Write data to MAP address */
+			rslt = bmi160_set_regs(BMI160_INT_MAP_0_ADDR, &data, 1, dev);
+		}
+	} else {
+
+		rslt = bmi160_get_regs(BMI160_INT_MAP_2_ADDR, &data, 1, dev);
+		if (rslt == BMI160_OK) {
+			temp = data & ~BMI160_INT2_LOW_STEP_DETECT_MASK;
+			data = temp | (1 & BMI160_INT2_LOW_STEP_DETECT_MASK);
+			/* Write data to MAP address */
+			rslt = bmi160_set_regs(BMI160_INT_MAP_2_ADDR, &data, 1, dev);
+		}
+	}
+
+	return rslt;
 }
+
 /*!
- *	@brief This API writes the value to the register 0x7E bit 0 to 7
- *
- *
- *  @param  v_command_reg_u8 : The value to write command register
- *  value   |  Description
- * ---------|--------------------------------------------------------
- *	0x00	|	Reserved
- *  0x03	|	Starts fast offset calibration for the Accel and gyro
- *	0x10	|	Sets the PMU mode for the Accel to suspend
- *	0x11	|	Sets the PMU mode for the Accel to normal
- *	0x12	|	Sets the PMU mode for the Accel Lowpower
- *  0x14	|	Sets the PMU mode for the Gyro to suspend
- *	0x15	|	Sets the PMU mode for the Gyro to normal
- *	0x16	|	Reserved
- *	0x17	|	Sets the PMU mode for the Gyro to fast start-up
- *  0x18	|	Sets the PMU mode for the Mag to suspend
- *	0x19	|	Sets the PMU mode for the Mag to normal
- *	0x1A	|	Sets the PMU mode for the Mag to Lowpower
- *	0xB0	|	Clears all data in the FIFO
- *  0xB1	|	Resets the interrupt engine
- *	0xB2	|	step_cnt_clr Clears the step counter
- *	0xB6	|	Triggers a reset
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_command_register(u8 v_command_reg_u8)
+ * @brief This API configure the step detector parameter.
+ */
+static int8_t config_step_detect(const struct bmi160_acc_step_detect_int_cfg *step_detect_int_cfg,
+				const struct bmi160_dev *dev)
 {
-	BMI160_RETURN_FUNCTION_TYPE com_rslt  = E_BMI160_COMM_RES;
-	/* check the p_bmi160 structure for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-			/* write command register */
-			com_rslt = p_bmi160->BMI160_BUS_WRITE_FUNC(
-			p_bmi160->dev_addr,
-			BMI160_CMD_COMMANDS__REG,
-			&v_command_reg_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-				/*interface idle time delay */
-			p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-			/*power mode status of Accel and gyro is stored in the
-			global variable bmi160_power_mode_status_u8_g */
-			com_rslt += bmi160_read_reg(BMI160_USER_PMU_STAT_ADDR,
-			&bmi160_power_mode_status_u8_g,
-			BMI160_GEN_READ_WRITE_DATA_LENGTH);
-			bmi160_power_mode_status_u8_g &=
-			BMI160_ACCEL_GYRO_PMU_MASK;
+	int8_t rslt;
+	uint8_t temp = 0;
+	uint8_t data_array[2] = {0};
+
+
+	if (step_detect_int_cfg->step_detector_mode == BMI160_STEP_DETECT_NORMAL) {
+		/* Normal mode setting */
+		data_array[0] = 0x15;
+		data_array[1] = 0x03;
+	} else if (step_detect_int_cfg->step_detector_mode == BMI160_STEP_DETECT_SENSITIVE) {
+		/* Sensitive mode setting */
+		data_array[0] = 0x2D;
+		data_array[1] = 0x00;
+	} else if (step_detect_int_cfg->step_detector_mode == BMI160_STEP_DETECT_ROBUST) {
+		/* Robust mode setting */
+		data_array[0] = 0x1D;
+		data_array[1] = 0x07;
+	} else if (step_detect_int_cfg->step_detector_mode == BMI160_STEP_DETECT_USER_DEFINE) {
+		/* Non recommended User defined setting */
+		/* Configuring STEP_CONFIG register */
+		rslt = bmi160_get_regs(BMI160_INT_STEP_CONFIG_0_ADDR, &data_array[0], 2, dev);
+
+		if (rslt == BMI160_OK) {
+			temp = data_array[0] & ~BMI160_STEP_DETECT_MIN_THRES_MASK;
+			/* Adding min_threshold */
+			data_array[0] = temp | ((step_detect_int_cfg->min_threshold << 3)
+					& BMI160_STEP_DETECT_MIN_THRES_MASK);
+
+			temp = data_array[0] & ~BMI160_STEP_DETECT_STEPTIME_MIN_MASK;
+			/* Adding steptime_min */
+			data_array[0] = temp | ((step_detect_int_cfg->steptime_min)
+					& BMI160_STEP_DETECT_STEPTIME_MIN_MASK);
+
+			temp = data_array[1] & ~BMI160_STEP_MIN_BUF_MASK;
+			/* Adding steptime_min */
+			data_array[1] = temp | ((step_detect_int_cfg->step_min_buf) & BMI160_STEP_MIN_BUF_MASK);
+
 		}
-	return com_rslt;
+	}
+
+	/* Write data to STEP_CONFIG register */
+	rslt = bmi160_set_regs(BMI160_INT_STEP_CONFIG_0_ADDR, data_array, 2, dev);
+
+	return rslt;
 }
 
 /*!
- *	@brief This function is used to read the compensated xyz axis data of
- *	mag secondary interface
- *	@note v_mag_x_s16: The value of Mag x data
- *	@note v_mag_y_s16: The value of Mag y data
- *	@note v_mag_z_s16: The value of Mag z data
- *	@note v_mag_r_s16: The value of Mag r data
- *	@param v_mag_second_if_u8: The value of Mag selection
- *
- *  value   |   v_mag_second_if_u8
- * ---------|----------------------
- *    0     |    BMM150
- *    1     |    AKM09911
- *    2     |    AKM09912
- *    3     |    YAS532
- *    4     |    YAS537
- *	@param mag_fifo_data: The value of compensated Mag xyz data
- *
- *
- *  @return
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_second_if_mag_compensate_xyz(
-struct bmi160_mag_fifo_data_t mag_fifo_data,
-u8 v_mag_second_if_u8)
+ * @brief This API enables the single/double tap interrupt.
+ */
+static int8_t enable_tap_int(const struct bmi160_int_settg *int_config,
+				const struct bmi160_acc_tap_int_cfg *tap_int_cfg,
+				const struct bmi160_dev *dev)
 {
-s8 com_rslt = BMI160_INIT_VALUE;
-s16 v_mag_x_s16 = BMI160_INIT_VALUE;
-s16 v_mag_y_s16 = BMI160_INIT_VALUE;
-s16 v_mag_z_s16 = BMI160_INIT_VALUE;
-u16 v_mag_r_u16 = BMI160_INIT_VALUE;
-#ifdef YAS537
-	u8 v_outflow_u8 = BMI160_INIT_VALUE;
-	u8 v_busy_u8 = BMI160_INIT_VALUE;
-	u8 v_coil_stat_u8 = BMI160_INIT_VALUE;
-	u16 v_temperature_u16 = BMI160_INIT_VALUE;
-	s32 a_h_s32[BMI160_YAS_H_DATA_SIZE] = {
-	BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
-	s32 a_s_s32[BMI160_YAS_S_DATA_SIZE] = {
-	BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
-	u16 xy1y2[3] = {
-	BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
-#endif
-#ifdef YAS532
-	u16 v_xy1y2_u16[3] = {
-	BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
-	u8 v_busy_yas532_u8 = BMI160_INIT_VALUE;
-	u16 v_temp_yas532_u16 = BMI160_INIT_VALUE;
-	u8 v_overflow_yas532_u8 = BMI160_INIT_VALUE;
-#endif
-switch (v_mag_second_if_u8) {
-case BMI160_SEC_IF_BMM150:
-	/* x data*/
-	v_mag_x_s16 = (s16)((mag_fifo_data.mag_x_msb
-	<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-	| (mag_fifo_data.mag_x_lsb));
-	v_mag_x_s16 = (s16)
-	(v_mag_x_s16 >> BMI160_SHIFT_BIT_POSITION_BY_03_BITS);
-	/* y data*/
-	v_mag_y_s16 = (s16)((mag_fifo_data.mag_y_msb
-	<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-	| (mag_fifo_data.mag_y_lsb));
-	v_mag_y_s16 = (s16)
-	(v_mag_y_s16 >> BMI160_SHIFT_BIT_POSITION_BY_03_BITS);
-	/* z data*/
-	v_mag_z_s16 = (s16)((mag_fifo_data.mag_z_msb
-	<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-	| (mag_fifo_data.mag_z_lsb));
-	v_mag_z_s16 = (s16)
-	(v_mag_z_s16 >> BMI160_SHIFT_BIT_POSITION_BY_01_BIT);
-	/* r data*/
-	v_mag_r_u16 = (u16)((mag_fifo_data.mag_r_y2_msb
-	<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-	| (mag_fifo_data.mag_r_y2_lsb));
-	v_mag_r_u16 = (u16)
-	(v_mag_r_u16 >> BMI160_SHIFT_BIT_POSITION_BY_02_BITS);
-	/* Compensated Mag x data */
-	processed_data.x =
-	bmi160_bmm150_mag_compensate_X(v_mag_x_s16,
-	v_mag_r_u16);
-	/* Compensated Mag y data */
-	processed_data.y =
-	bmi160_bmm150_mag_compensate_Y(v_mag_y_s16,
-	v_mag_r_u16);
-	/* Compensated Mag z data */
-	processed_data.z =
-	bmi160_bmm150_mag_compensate_Z(v_mag_z_s16,
-	v_mag_r_u16);
-break;
-#ifdef AKM09911
-case BMI160_SEC_IF_AKM09911:
-	/* x data*/
-	v_mag_x_s16 = (s16)((mag_fifo_data.mag_x_msb
-	<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-	| (mag_fifo_data.mag_x_lsb));
-	/* y data*/
-	v_mag_y_s16 = (s16)((mag_fifo_data.mag_y_msb
-	<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-	| (mag_fifo_data.mag_y_lsb));
-	/* z data*/
-	v_mag_z_s16 = (s16)((mag_fifo_data.mag_z_msb
-	<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-	| (mag_fifo_data.mag_z_lsb));
-	/* Compensated for X data */
-	processed_data.x =
-	bmi160_bst_akm09911_compensate_X(v_mag_x_s16);
-	/* Compensated for Y data */
-	processed_data.y =
-	bmi160_bst_akm09911_compensate_Y(v_mag_y_s16);
-	/* Compensated for Z data */
-	processed_data.z =
-	bmi160_bst_akm09911_compensate_Z(v_mag_z_s16);
-break;
-#endif
-#ifdef AKM09912
-case BMI160_SEC_IF_AKM09912:
-	/* x data*/
-	v_mag_x_s16 = (s16)((mag_fifo_data.mag_x_msb
-	<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-	| (mag_fifo_data.mag_x_lsb));
-	/* y data*/
-	v_mag_y_s16 = (s16)((mag_fifo_data.mag_y_msb
-	<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-	| (mag_fifo_data.mag_y_lsb));
-	/* z data*/
-	v_mag_z_s16 = (s16)((mag_fifo_data.mag_z_msb
-	<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-	| (mag_fifo_data.mag_z_lsb));
-	/* Compensated for X data */
-	processed_data.x =
-	bmi160_bst_akm09912_compensate_X(v_mag_x_s16);
-	/* Compensated for Y data */
-	processed_data.y =
-	bmi160_bst_akm09912_compensate_Y(v_mag_y_s16);
-	/* Compensated for Z data */
-	processed_data.z =
-	bmi160_bst_akm09912_compensate_Z(v_mag_z_s16);
-break;
-#endif
-#ifdef YAS532
-case BMI160_SEC_IF_YAS532:{
-	u8 i = BMI160_INIT_VALUE;
-	/* read the xyy1 data*/
-	v_busy_yas532_u8 =
-	((mag_fifo_data.mag_x_lsb
-	>> BMI160_SHIFT_BIT_POSITION_BY_07_BITS) & 0x01);
-	v_temp_yas532_u16 =
-	(u16)((((s32)mag_fifo_data.mag_x_lsb
-	<< BMI160_SHIFT_BIT_POSITION_BY_03_BITS)
-	& 0x3F8) | ((mag_fifo_data.mag_x_msb
-	>> BMI160_SHIFT_BIT_POSITION_BY_05_BITS) & 0x07));
-
-	v_xy1y2_u16[0] =
-	(u16)((((s32)mag_fifo_data.mag_y_lsb
-	<< BMI160_SHIFT_BIT_POSITION_BY_06_BITS) & 0x1FC0)
-	| ((mag_fifo_data.mag_y_msb >>
-	BMI160_SHIFT_BIT_POSITION_BY_02_BITS) & 0x3F));
-	v_xy1y2_u16[1] =
-	(u16)((((s32)mag_fifo_data.mag_z_lsb
-	<< BMI160_SHIFT_BIT_POSITION_BY_06_BITS)
-	& 0x1FC0)
-	| ((mag_fifo_data.mag_z_msb
-	>> BMI160_SHIFT_BIT_POSITION_BY_02_BITS) & 0x3F));
-	v_xy1y2_u16[2] =
-	(u16)((((s32)mag_fifo_data.mag_r_y2_lsb
-	<< BMI160_SHIFT_BIT_POSITION_BY_06_BITS)
-	& 0x1FC0)
-	| ((mag_fifo_data.mag_r_y2_msb
-	>> BMI160_SHIFT_BIT_POSITION_BY_02_BITS) & 0x3F));
-	v_overflow_yas532_u8 = 0;
-	for (i = 0; i < 3; i++) {
-		if (v_xy1y2_u16[i] == YAS532_DATA_OVERFLOW)
-			v_overflow_yas532_u8 |= (1 << (i * 2));
-		if (v_xy1y2_u16[i] == YAS532_DATA_UNDERFLOW)
-			v_overflow_yas532_u8 |= (1 << (i * 2 + 1));
-	}
-	/* assign the data*/
-	com_rslt = bmi160_bst_yas532_fifo_xyz_data(
-	v_xy1y2_u16, 1, v_overflow_yas532_u8,
-	v_temp_yas532_u16, v_busy_yas532_u8);
-	processed_data.x =
-	fifo_xyz_data.yas532_vector_xyz[0];
-	processed_data.y =
-	fifo_xyz_data.yas532_vector_xyz[1];
-	processed_data.z =
-	fifo_xyz_data.yas532_vector_xyz[2];
-	}
-break;
-#endif
-#ifdef YAS537
-case BMI160_SEC_IF_YAS537:{
-	u8 i = BMI160_INIT_VALUE;
-	/* read the busy flag*/
-	v_busy_u8 = mag_fifo_data.mag_y_lsb
-	>> BMI160_SHIFT_BIT_POSITION_BY_07_BITS;
-	/* read the coil status*/
-	v_coil_stat_u8 =
-	((mag_fifo_data.mag_y_lsb >>
-	BMI160_SHIFT_BIT_POSITION_BY_06_BITS) & 0X01);
-	/* read temperature data*/
-	v_temperature_u16 = (u16)((mag_fifo_data.mag_x_lsb
-	<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-	| mag_fifo_data.mag_x_msb);
-	/* read x data*/
-	xy1y2[0] = (u16)(((mag_fifo_data.mag_y_lsb &
-	0x3F)
-	<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-	| (mag_fifo_data.mag_y_msb));
-	/* read y1 data*/
-	xy1y2[1] = (u16)((mag_fifo_data.mag_z_lsb
-	<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-	| mag_fifo_data.mag_z_msb);
-	/* read y2 data*/
-	xy1y2[2] = (u16)((mag_fifo_data.mag_r_y2_lsb
-	<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-	| mag_fifo_data.mag_r_y2_msb);
-	for (i = 0; i < 3; i++)
-		yas537_data.last_raw[i] = xy1y2[i];
-		yas537_data.last_raw[i] = v_temperature_u16;
-		if (yas537_data.calib_yas537.ver == 1) {
-			for (i = 0; i < 3; i++)
-				a_s_s32[i] = xy1y2[i] - 8192;
-		/* read hx*/
-		a_h_s32[0] = ((yas537_data.calib_yas537.k * (
-		(128 * a_s_s32[0]) +
-		(yas537_data.calib_yas537.a2 * a_s_s32[1]) +
-		(yas537_data.calib_yas537.a3 * a_s_s32[2])))
-		/ (8192));
-		/* read hy1*/
-		a_h_s32[1] = ((yas537_data.calib_yas537.k * (
-		(yas537_data.calib_yas537.a4 * a_s_s32[0]) +
-		(yas537_data.calib_yas537.a5 * a_s_s32[1]) +
-		(yas537_data.calib_yas537.a6 * a_s_s32[2])))
-		/ (8192));
-		/* read hy2*/
-		a_h_s32[2] = ((yas537_data.calib_yas537.k * (
-		(yas537_data.calib_yas537.a7 * a_s_s32[0]) +
-		(yas537_data.calib_yas537.a8 * a_s_s32[1]) +
-		(yas537_data.calib_yas537.a9 * a_s_s32[2])))
-		/ (8192));
-
-	for (i = 0; i < 3; i++) {
-		if (a_h_s32[i] < -8192)
-			a_h_s32[i] = -8192;
-
-		if (8192 < a_h_s32[i])
-			a_h_s32[i] = 8192;
-
-		xy1y2[i] = a_h_s32[i] + 8192;
+	int8_t rslt;
+	uint8_t data = 0;
+	uint8_t temp = 0;
 
+	/* Enable single tap or double tap interrupt in Int Enable 0 register */
+	rslt = bmi160_get_regs(BMI160_INT_ENABLE_0_ADDR, &data, 1, dev);
+	if (rslt == BMI160_OK) {
+		if (int_config->int_type == BMI160_ACC_SINGLE_TAP_INT) {
+			temp = data & ~BMI160_SINGLE_TAP_INT_EN_MASK;
+			data = temp | ((tap_int_cfg->tap_en << 5) & BMI160_SINGLE_TAP_INT_EN_MASK);
+		} else {
+			temp = data & ~BMI160_DOUBLE_TAP_INT_EN_MASK;
+			data = temp | ((tap_int_cfg->tap_en << 4) & BMI160_DOUBLE_TAP_INT_EN_MASK);
+		}
+		/* Write to Enable 0 Address */
+		rslt = bmi160_set_regs(BMI160_INT_ENABLE_0_ADDR, &data, 1, dev);
 	}
-	}
-	v_outflow_u8 = 0;
-	for (i = 0; i < 3; i++) {
-		if (YAS537_DATA_OVERFLOW
-		<= xy1y2[i])
-			v_outflow_u8 |=
-			(1 << (i * 2));
-		if (xy1y2[i] ==
-		YAS537_DATA_UNDERFLOW)
-			v_outflow_u8
-			|= (1 << (i * 2 + 1));
-	}
-	com_rslt = bmi160_bst_yamaha_yas537_fifo_xyz_data(
-	xy1y2, v_outflow_u8, v_coil_stat_u8, v_busy_u8);
-	processed_data.x =
-	fifo_vector_xyz.yas537_vector_xyz[0];
-	processed_data.y =
-	fifo_vector_xyz.yas537_vector_xyz[1];
-	processed_data.z =
-	fifo_vector_xyz.yas537_vector_xyz[2];
-	}
-break;
-#endif
-default:
-	com_rslt = E_BMI160_OUT_OF_RANGE;
-break;
+	return rslt;
 }
-	return com_rslt;
-}
-#ifdef FIFO_ENABLE
+
 /*!
- *	@brief This function is used to read the
- *	fifo data of  header mode
- *
- *
- *	@note Configure the below functions for FIFO header mode
- *	@note 1. bmi160_set_fifo_down_gyro()
- *	@note 2. bmi160_set_gyro_fifo_filter_data()
- *	@note 3. bmi160_set_fifo_down_accel()
- *	@note 4. bmi160_set_accel_fifo_filter_dat()
- *	@note 5. bmi160_set_fifo_mag_enable()
- *	@note 6. bmi160_set_fifo_accel_enable()
- *	@note 7. bmi160_set_fifo_gyro_enable()
- *	@note 8. bmi160_set_fifo_header_enable()
- *	@note For interrupt configuration
- *	@note 1. bmi160_set_intr_fifo_full()
- *	@note 2. bmi160_set_intr_fifo_wm()
- *	@note 3. bmi160_set_fifo_tag_intr2_enable()
- *	@note 4. bmi160_set_fifo_tag_intr1_enable()
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
+ * @brief This API configure the interrupt PIN setting for
+ * tap interrupt.
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_fifo_header_data(u8 v_mag_if_u8,
-struct bmi160_fifo_data_header_t *header_data)
+static int8_t config_tap_int_settg(const struct bmi160_int_settg *int_config,
+					const struct bmi160_acc_tap_int_cfg *tap_int_cfg,
+					const struct bmi160_dev *dev)
 {
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* read the whole FIFO data*/
-	com_rslt =
-	bmi160_read_fifo_header_data_user_defined_length(
-	FIFO_FRAME, v_mag_if_u8, header_data);
-	return com_rslt;
+	int8_t rslt;
+
+	/* Configure Interrupt pins */
+	rslt = set_intr_pin_config(int_config, dev);
+	if (rslt == BMI160_OK) {
+		rslt = map_int_pin_to_tap(int_config, dev);
+		if (rslt == BMI160_OK) {
+			rslt = config_tap_data_src(tap_int_cfg, dev);
+			if (rslt == BMI160_OK)
+				rslt = config_tap_param(int_config, tap_int_cfg, dev);
+		}
+	}
+
+	return rslt;
 }
+
 /*!
- *	@brief This function is used to read the
- *	fifo data of  header mode for user defined length
- *
- *
- *	@note Configure the below functions for FIFO header mode
- *	@note 1. bmi160_set_fifo_down_gyro()
- *	@note 2. bmi160_set_gyro_fifo_filter_data()
- *	@note 3. bmi160_set_fifo_down_accel()
- *	@note 4. bmi160_set_accel_fifo_filter_dat()
- *	@note 5. bmi160_set_fifo_mag_enable()
- *	@note 6. bmi160_set_fifo_accel_enable()
- *	@note 7. bmi160_set_fifo_gyro_enable()
- *	@note 8. bmi160_set_fifo_header_enable()
- *	@note For interrupt configuration
- *	@note 1. bmi160_set_intr_fifo_full()
- *	@note 2. bmi160_set_intr_fifo_wm()
- *	@note 3. bmi160_set_fifo_tag_intr2_enable()
- *	@note 4. bmi160_set_fifo_tag_intr1_enable()
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
+ * @brief This API maps the INT pin to single or double tap interrupt.
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_fifo_header_data_user_defined_length(
-u16 v_fifo_user_length_u16, u8 v_mag_if_mag_u8,
-struct bmi160_fifo_data_header_t *fifo_header_data)
+static int8_t map_int_pin_to_tap(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
 {
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	u8 v_accel_index_u8 = BMI160_INIT_VALUE;
-	u8 v_gyro_index_u8 = BMI160_INIT_VALUE;
-	u8 v_mag_index_u8 = BMI160_INIT_VALUE;
-	s8 v_last_return_stat_s8 = BMI160_INIT_VALUE;
-	u16 v_fifo_index_u16 = BMI160_INIT_VALUE;
-	u8 v_frame_head_u8 = BMI160_INIT_VALUE;
-	u8 v_frame_index_u8 = BMI160_INIT_VALUE;
-
-	u16 v_fifo_length_u16 = BMI160_INIT_VALUE;
-
-	fifo_header_data->accel_frame_count = BMI160_INIT_VALUE;
-	fifo_header_data->mag_frame_count = BMI160_INIT_VALUE;
-	fifo_header_data->gyro_frame_count = BMI160_INIT_VALUE;
-	/* read FIFO data*/
-	com_rslt = bmi160_fifo_data(&v_fifo_data_u8[BMI160_INIT_VALUE],
-	v_fifo_user_length_u16);
-	v_fifo_length_u16 = v_fifo_user_length_u16;
-	for (v_fifo_index_u16 = BMI160_INIT_VALUE;
-	v_fifo_index_u16 < v_fifo_length_u16;) {
-		fifo_header_data->fifo_header[v_frame_index_u8]
-		= v_fifo_data_u8[v_fifo_index_u16];
-		v_frame_head_u8 =
-		fifo_header_data->fifo_header[v_frame_index_u8]
-		 & BMI160_FIFO_TAG_INTR_MASK;
-		v_frame_index_u8++;
-		switch (v_frame_head_u8) {
-		/* Header frame of Accel */
-		case FIFO_HEAD_A:
-		{	/*fifo data frame index + 1*/
-			v_fifo_index_u16 = v_fifo_index_u16 +
-			BMI160_FIFO_INDEX_LENGTH;
-
-			if ((v_fifo_index_u16 + BMI160_FIFO_A_LENGTH)
-			> v_fifo_length_u16) {
-				v_last_return_stat_s8 = FIFO_A_OVER_LEN;
-			break;
-			}
-			/* Accel raw x data */
-			fifo_header_data->accel_fifo[v_accel_index_u8].x =
-			(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_X_MSB_DATA])
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-			| (v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_X_LSB_DATA]));
-			/* Accel raw y data */
-			fifo_header_data->accel_fifo[v_accel_index_u8].y =
-			(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_Y_MSB_DATA])
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-			| (v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_Y_LSB_DATA]));
-			/* Accel raw z data */
-			fifo_header_data->accel_fifo[v_accel_index_u8].z =
-			(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_Z_MSB_DATA])
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-			| (v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_Z_LSB_DATA]));
-			/* check for Accel frame count*/
-			fifo_header_data->accel_frame_count =
-			fifo_header_data->accel_frame_count
-			+ BMI160_FRAME_COUNT;
-			v_fifo_index_u16 = v_fifo_index_u16 +
-			BMI160_FIFO_A_LENGTH;
-			v_accel_index_u8++;
+	int8_t rslt;
+	uint8_t data = 0;
+	uint8_t temp = 0;
 
-		break;
-		}
-		/* Header frame of gyro */
-		case FIFO_HEAD_G:
-		{	/*fifo data frame index + 1*/
-			v_fifo_index_u16 = v_fifo_index_u16
-			+ BMI160_FIFO_INDEX_LENGTH;
-
-			if ((v_fifo_index_u16 + BMI160_FIFO_G_LENGTH) >
-			v_fifo_length_u16) {
-				v_last_return_stat_s8 = FIFO_G_OVER_LEN;
-			break;
-			}
-			/* Gyro raw x data */
-			fifo_header_data->gyro_fifo[v_gyro_index_u8].x  =
-			(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_X_MSB_DATA])
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-			| (v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_X_LSB_DATA]));
-			/* Gyro raw y data */
-			fifo_header_data->gyro_fifo[v_gyro_index_u8].y =
-			(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_Y_MSB_DATA])
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-			| (v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_Y_LSB_DATA]));
-			/* Gyro raw z data */
-			fifo_header_data->gyro_fifo[v_gyro_index_u8].z  =
-			(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_Z_MSB_DATA])
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-			| (v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_Z_LSB_DATA]));
-			/* check for gyro frame count*/
-			fifo_header_data->gyro_frame_count =
-			fifo_header_data->gyro_frame_count + BMI160_FRAME_COUNT;
-			/*fifo G data frame index + 6*/
-			v_fifo_index_u16 = v_fifo_index_u16 +
-			BMI160_FIFO_G_LENGTH;
-			v_gyro_index_u8++;
 
-		break;
-		}
-		/* Header frame of Mag */
-		case FIFO_HEAD_M:
-		{	/*fifo data frame index + 1*/
-			v_fifo_index_u16 = v_fifo_index_u16
-			+ BMI160_FIFO_INDEX_LENGTH;
-
-			if ((v_fifo_index_u16 + BMI160_FIFO_M_LENGTH) >
-			(v_fifo_length_u16)) {
-				v_last_return_stat_s8 = FIFO_M_OVER_LEN;
-			break;
+	/* Configure Map register to map interrupt pin to
+	single or double tap interrupt*/
+	if (int_config->int_channel == BMI160_INT_CHANNEL_1) {
+		rslt = bmi160_get_regs(BMI160_INT_MAP_0_ADDR, &data, 1, dev);
+		if (rslt == BMI160_OK) {
+			if (int_config->int_type == BMI160_ACC_SINGLE_TAP_INT) {
+				temp = data & ~BMI160_INT1_SINGLE_TAP_MASK;
+				data = temp | ((1 << 5) & BMI160_INT1_SINGLE_TAP_MASK);
+			} else {
+				temp = data & ~BMI160_INT1_DOUBLE_TAP_MASK;
+				data = temp | ((1 << 4) & BMI160_INT1_DOUBLE_TAP_MASK);
 			}
-			/* Mag x data*/
-			mag_data.mag_x_lsb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_X_LSB_DATA]);
-			mag_data.mag_x_msb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_X_MSB_DATA]);
-			/* Mag y data*/
-			mag_data.mag_y_lsb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_Y_LSB_DATA]);
-			mag_data.mag_y_msb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_Y_MSB_DATA]);
-			mag_data.mag_z_lsb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_Z_LSB_DATA]);
-			mag_data.mag_z_msb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_Z_MSB_DATA]);
-			/* Mag r data*/
-			mag_data.mag_r_y2_lsb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_R_LSB_DATA]);
-			mag_data.mag_r_y2_msb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_R_MSB_DATA]);
-
-			com_rslt = bmi160_second_if_mag_compensate_xyz(mag_data,
-			v_mag_if_mag_u8);
-			 /* compensated Mag x */
-			fifo_header_data->mag_fifo[v_gyro_index_u8].x
-			= processed_data.x;
-			/* compensated Mag y */
-			fifo_header_data->mag_fifo[v_gyro_index_u8].y
-			= processed_data.y;
-			/* compensated Mag z */
-			fifo_header_data->mag_fifo[v_gyro_index_u8].z
-			= processed_data.z;
-
-			/* check for Mag frame count*/
-			fifo_header_data->mag_frame_count =
-			fifo_header_data->mag_frame_count
-			+ BMI160_FRAME_COUNT;
-
-			v_mag_index_u8++;
-			/*fifo M data frame index + 8*/
-			v_fifo_index_u16 = v_fifo_index_u16 +
-			BMI160_FIFO_M_LENGTH;
-		break;
+
 		}
-		/* Header frame of gyro and Accel */
-		case FIFO_HEAD_G_A:
-			v_fifo_index_u16 = v_fifo_index_u16 +
-			BMI160_FIFO_INDEX_LENGTH;
-			if ((v_fifo_index_u16 + BMI160_FIFO_AG_LENGTH)
-			> v_fifo_length_u16) {
-				v_last_return_stat_s8 = FIFO_G_A_OVER_LEN;
-			break;
-			}
-			/* Raw gyro x */
-			fifo_header_data->gyro_fifo[v_gyro_index_u8].x   =
-			(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_GA_FIFO_G_X_MSB])
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-			|(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_GA_FIFO_G_X_LSB]));
-			/* Raw gyro y */
-			fifo_header_data->gyro_fifo[v_gyro_index_u8].y  =
-			(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_GA_FIFO_G_Y_MSB])
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-			|(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_GA_FIFO_G_Y_LSB]));
-			/* Raw gyro z */
-			fifo_header_data->gyro_fifo[v_gyro_index_u8].z  =
-			(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_GA_FIFO_G_Z_MSB])
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-			|(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_GA_FIFO_G_Z_LSB]));
-			/* check for gyro frame count*/
-			fifo_header_data->gyro_frame_count =
-			fifo_header_data->gyro_frame_count + BMI160_FRAME_COUNT;
-			/* Raw Accel x */
-			fifo_header_data->accel_fifo[v_accel_index_u8].x =
-			(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_GA_FIFO_A_X_MSB])
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-			|(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_GA_FIFO_A_X_LSB]));
-			/* Raw Accel y */
-			fifo_header_data->accel_fifo[v_accel_index_u8].y =
-			(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_GA_FIFO_A_Y_MSB])
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-			|(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_GA_FIFO_A_Y_LSB]));
-			/* Raw Accel z */
-			fifo_header_data->accel_fifo[v_accel_index_u8].z =
-			(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_GA_FIFO_A_Z_MSB])
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-			|(v_fifo_data_u8[v_fifo_index_u16
-			+ BMI160_GA_FIFO_A_Z_LSB]));
-			/* check for Accel frame count*/
-			fifo_header_data->accel_frame_count =
-			fifo_header_data->accel_frame_count
-			+ BMI160_FRAME_COUNT;
-			/* Index added to 12 for gyro and Accel*/
-			v_fifo_index_u16 = v_fifo_index_u16 +
-			BMI160_FIFO_AG_LENGTH;
-			v_gyro_index_u8++;
-			v_accel_index_u8++;
-		break;
-		/* Header frame of mag, gyro and Accel */
-		case FIFO_HEAD_M_G_A:
-			{	/*fifo data frame index + 1*/
-			v_fifo_index_u16 = v_fifo_index_u16
-			+ BMI160_FIFO_INDEX_LENGTH;
-
-			if ((v_fifo_index_u16 + BMI160_FIFO_AMG_LENGTH)
-			> (v_fifo_length_u16)) {
-				v_last_return_stat_s8 = FIFO_M_G_A_OVER_LEN;
-				break;
-			}
-			/* Mag x data*/
-			mag_data.mag_x_lsb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_X_LSB_DATA]);
-			mag_data.mag_x_msb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_X_MSB_DATA]);
-			/* Mag y data*/
-			mag_data.mag_y_lsb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_Y_LSB_DATA]);
-			mag_data.mag_y_msb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_Y_MSB_DATA]);
-			mag_data.mag_z_lsb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_Z_LSB_DATA]);
-			mag_data.mag_z_msb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_Z_MSB_DATA]);
-			/* Mag r data*/
-			mag_data.mag_r_y2_lsb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_R_LSB_DATA]);
-			mag_data.mag_r_y2_msb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_R_MSB_DATA]);
-			/* Processing the compensation data*/
-			com_rslt = bmi160_second_if_mag_compensate_xyz(mag_data,
-			v_mag_if_mag_u8);
-			 /* compensated Mag x */
-			fifo_header_data->mag_fifo[v_mag_index_u8].x =
-			processed_data.x;
-			/* compensated Mag y */
-			fifo_header_data->mag_fifo[v_mag_index_u8].y =
-			processed_data.y;
-			/* compensated Mag z */
-			fifo_header_data->mag_fifo[v_mag_index_u8].z =
-			processed_data.z;
-			/* check for Mag frame count*/
-			fifo_header_data->mag_frame_count =
-			fifo_header_data->mag_frame_count + BMI160_FRAME_COUNT;
-			/* Gyro raw x data */
-			fifo_header_data->gyro_fifo[v_gyro_index_u8].x =
-				(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-				BMI160_MGA_FIFO_G_X_MSB])
-				<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-				|(v_fifo_data_u8[v_fifo_index_u16 +
-				BMI160_MGA_FIFO_G_X_LSB]));
-			/* Gyro raw y data */
-			fifo_header_data->gyro_fifo[v_gyro_index_u8].y =
-				(s16)(((v_fifo_data_u8[
-				v_fifo_index_u16 + BMI160_MGA_FIFO_G_Y_MSB])
-				<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-				|(v_fifo_data_u8[v_fifo_index_u16 +
-				BMI160_MGA_FIFO_G_Y_LSB]));
-			/* Gyro raw z data */
-			fifo_header_data->gyro_fifo[v_gyro_index_u8].z =
-				(s16)(((v_fifo_data_u8[
-				v_fifo_index_u16 + BMI160_MGA_FIFO_G_Z_MSB])
-				<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-				|(v_fifo_data_u8[
-				v_fifo_index_u16 + BMI160_MGA_FIFO_G_Z_LSB]));
-			/* check for gyro frame count*/
-			fifo_header_data->gyro_frame_count =
-			fifo_header_data->gyro_frame_count + BMI160_FRAME_COUNT;
-			/* Accel raw x data */
-			fifo_header_data->accel_fifo[v_accel_index_u8].x =
-				(s16)(((v_fifo_data_u8[
-				v_fifo_index_u16 + BMI160_MGA_FIFO_A_X_MSB])
-				<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-				|(v_fifo_data_u8[v_fifo_index_u16 +
-				BMI160_MGA_FIFO_A_X_LSB]));
-			/* Accel raw y data */
-			fifo_header_data->accel_fifo[v_accel_index_u8].y =
-				(s16)(((v_fifo_data_u8[
-				v_fifo_index_u16 + BMI160_MGA_FIFO_A_Y_MSB])
-				<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-				|(v_fifo_data_u8[v_fifo_index_u16 +
-				BMI160_MGA_FIFO_A_Y_LSB]));
-			/* Accel raw z data */
-			fifo_header_data->accel_fifo[v_accel_index_u8].z =
-				(s16)(((v_fifo_data_u8[
-				v_fifo_index_u16 + BMI160_MGA_FIFO_A_Z_MSB])
-				<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-				|(v_fifo_data_u8[v_fifo_index_u16 +
-				BMI160_MGA_FIFO_A_Z_LSB]));
-			/* check for Accel frame count*/
-			fifo_header_data->accel_frame_count =
-			fifo_header_data->accel_frame_count
-			+ BMI160_FRAME_COUNT;
-			/* Index added to 20 for mag, gyro and Accel*/
-			v_fifo_index_u16 = v_fifo_index_u16 +
-			BMI160_FIFO_AMG_LENGTH;
-			v_accel_index_u8++;
-			v_mag_index_u8++;
-			v_gyro_index_u8++;
-		break;
-			}
-		/* Header frame of Mag and Accel */
-		case FIFO_HEAD_M_A:
-			{	/*fifo data frame index + 1*/
-			v_fifo_index_u16 = v_fifo_index_u16
-			+ BMI160_GEN_READ_WRITE_DATA_LENGTH;
-
-			if ((v_fifo_index_u16 + BMI160_FIFO_MA_OR_MG_LENGTH)
-			> (v_fifo_length_u16)) {
-				v_last_return_stat_s8 = FIFO_M_A_OVER_LEN;
-				break;
-			}
-			/* Mag x data*/
-			mag_data.mag_x_lsb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_X_LSB_DATA]);
-			mag_data.mag_x_msb = (v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_X_MSB_DATA]);
-			/* Mag y data*/
-			mag_data.mag_y_lsb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_Y_LSB_DATA]);
-			mag_data.mag_y_msb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_Y_MSB_DATA]);
-			mag_data.mag_z_lsb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_Z_LSB_DATA]);
-			mag_data.mag_z_msb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_Z_MSB_DATA]);
-			/* Mag r data*/
-			mag_data.mag_r_y2_lsb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_R_LSB_DATA]);
-			mag_data.mag_r_y2_msb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_R_MSB_DATA]);
-			com_rslt =
-			bmi160_second_if_mag_compensate_xyz(mag_data,
-			 v_mag_if_mag_u8);
-			 /* compensated Mag x */
-			fifo_header_data->mag_fifo[v_mag_index_u8].x =
-			processed_data.x;
-			/* compensated Mag y */
-			fifo_header_data->mag_fifo[v_mag_index_u8].y =
-			processed_data.y;
-			/* compensated Mag z */
-			fifo_header_data->mag_fifo[v_mag_index_u8].z =
-			processed_data.z;
-			/* check for Mag frame count*/
-			fifo_header_data->mag_frame_count =
-			fifo_header_data->mag_frame_count
-			+ BMI160_FRAME_COUNT;
-			/* Accel raw x data */
-			fifo_header_data->accel_fifo[v_accel_index_u8].x =
-			(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_MA_FIFO_A_X_MSB])
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-			|(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_MA_FIFO_A_X_LSB]));
-			/* Accel raw y data */
-			fifo_header_data->accel_fifo[v_accel_index_u8].y =
-			(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_MA_FIFO_A_Y_MSB])
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-			|(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_MA_FIFO_A_Y_LSB]));
-			/* Accel raw z data */
-			fifo_header_data->accel_fifo[v_accel_index_u8].z =
-			(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_MA_FIFO_A_Z_MSB])
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-			|(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_MA_FIFO_A_Z_LSB]));
-			/* check for Accel frame count*/
-			fifo_header_data->accel_frame_count =
-			fifo_header_data->accel_frame_count
-			+ BMI160_FRAME_COUNT;
-			/*fifo AM data frame index + 14(8+6)*/
-			v_fifo_index_u16 = v_fifo_index_u16 +
-			BMI160_FIFO_MA_OR_MG_LENGTH;
-			v_accel_index_u8++;
-			v_mag_index_u8++;
-		break;
-			}
-			/* Header frame of Mag and gyro */
-		case FIFO_HEAD_M_G:
-			{
-			/*fifo data frame index + 1*/
-			v_fifo_index_u16 = v_fifo_index_u16
-			+ BMI160_GEN_READ_WRITE_DATA_LENGTH;
-
-			if ((v_fifo_index_u16 + BMI160_FIFO_MA_OR_MG_LENGTH)
-			> v_fifo_length_u16) {
-				v_last_return_stat_s8 = FIFO_M_G_OVER_LEN;
-				break;
-			}
-			/* Mag x data*/
-			mag_data.mag_x_lsb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_X_LSB_DATA]);
-			mag_data.mag_x_msb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_X_MSB_DATA]);
-			/* Mag y data*/
-			mag_data.mag_y_lsb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_Y_LSB_DATA]);
-			mag_data.mag_y_msb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_Y_MSB_DATA]);
-			mag_data.mag_z_lsb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_Z_LSB_DATA]);
-			mag_data.mag_z_msb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_Z_MSB_DATA]);
-			/* Mag r data*/
-			mag_data.mag_r_y2_lsb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_R_LSB_DATA]);
-			mag_data.mag_r_y2_msb =
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_R_MSB_DATA]);
-			com_rslt =
-			bmi160_second_if_mag_compensate_xyz(mag_data,
-			v_mag_if_mag_u8);
-			 /* compensated Mag x */
-			fifo_header_data->mag_fifo[v_mag_index_u8].x =
-			processed_data.x;
-			/* compensated Mag y */
-			fifo_header_data->mag_fifo[v_mag_index_u8].y =
-			processed_data.y;
-			/* compensated Mag z */
-			fifo_header_data->mag_fifo[v_mag_index_u8].z =
-			processed_data.z;
-			/* check for Mag frame count*/
-			fifo_header_data->mag_frame_count =
-			fifo_header_data->mag_frame_count + BMI160_FRAME_COUNT;
-			/* Gyro raw x data */
-			fifo_header_data->gyro_fifo[v_gyro_index_u8].x =
-			(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_MG_FIFO_G_X_MSB])
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-			|(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_MG_FIFO_G_X_LSB]));
-			/* Gyro raw y data */
-			fifo_header_data->gyro_fifo[v_gyro_index_u8].y =
-			(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_MG_FIFO_G_Y_MSB])
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-			|(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_MG_FIFO_G_Y_LSB]));
-			/* Gyro raw z data */
-			fifo_header_data->gyro_fifo[v_gyro_index_u8].z =
-			(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_MG_FIFO_G_Z_MSB])
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-			|(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_MG_FIFO_G_Z_LSB]));
-			/* check for gyro frame count*/
-			fifo_header_data->gyro_frame_count =
-			fifo_header_data->gyro_frame_count
-			+ BMI160_FRAME_COUNT;
-			/*fifo GM data frame index + 14(8+6)*/
-			v_fifo_index_u16 = v_fifo_index_u16 +
-			BMI160_FIFO_MA_OR_MG_LENGTH;
-			v_mag_index_u8++;
-			v_gyro_index_u8++;
-		break;
-			}
-		/* Header frame of sensor time */
-		case FIFO_HEAD_SENSOR_TIME:
-			{
-			v_fifo_index_u16 = v_fifo_index_u16 +
-			BMI160_GEN_READ_WRITE_DATA_LENGTH;
-
-			if ((v_fifo_index_u16
-			+ BMI160_FIFO_SENSOR_TIME_LENGTH) >
-			(v_fifo_length_u16)) {
-				v_last_return_stat_s8
-				= FIFO_SENSORTIME_RETURN;
-			break;
-			}
-			/* Sensor time */
-			fifo_header_data->fifo_time = (u32)
-			((v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_SENSOR_TIME_MSB]
-			<< BMI160_SHIFT_BIT_POSITION_BY_16_BITS) |
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_SENSOR_TIME_XLSB]
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
-			(v_fifo_data_u8[v_fifo_index_u16 +
-			BMI160_FIFO_SENSOR_TIME_LSB]));
-
-			v_fifo_index_u16 = v_fifo_index_u16 +
-			BMI160_FIFO_SENSOR_TIME_LENGTH;
-		break;
-			}
-		/* Header frame of skip frame */
-		case FIFO_HEAD_SKIP_FRAME:
-			{
-			/*fifo data frame index + 1*/
-				v_fifo_index_u16 = v_fifo_index_u16 +
-				BMI160_FIFO_INDEX_LENGTH;
-				if (v_fifo_index_u16
-				+ BMI160_FIFO_INDEX_LENGTH
-				> v_fifo_length_u16) {
-					v_last_return_stat_s8 =
-					FIFO_SKIP_OVER_LEN;
-				break;
-				}
-				fifo_header_data->skip_frame =
-				v_fifo_data_u8[v_fifo_index_u16];
-				v_fifo_index_u16 = v_fifo_index_u16 +
-				BMI160_FIFO_INDEX_LENGTH;
-		break;
-			}
-		case FIFO_HEAD_INPUT_CONFIG:
-			{
-			/*fifo data frame index + 1*/
-				v_fifo_index_u16 = v_fifo_index_u16 +
-				BMI160_FIFO_INDEX_LENGTH;
-				if (v_fifo_index_u16
-				+ BMI160_FIFO_INDEX_LENGTH
-				> v_fifo_length_u16) {
-					v_last_return_stat_s8 =
-					FIFO_INPUT_CONFIG_OVER_LEN;
-				break;
-				}
-				fifo_header_data->fifo_input_config_info
-				= v_fifo_data_u8[v_fifo_index_u16];
-				v_fifo_index_u16 = v_fifo_index_u16 +
-				BMI160_FIFO_INDEX_LENGTH;
-		break;
-			}
-		/* Header frame of over read FIFO data */
-		case FIFO_HEAD_OVER_READ_LSB:
-			{
-		/*fifo data frame index + 1*/
-			v_fifo_index_u16 = v_fifo_index_u16 +
-			BMI160_FIFO_INDEX_LENGTH;
-
-			if ((v_fifo_index_u16 + BMI160_FIFO_INDEX_LENGTH)
-			> (v_fifo_length_u16)) {
-				v_last_return_stat_s8 = FIFO_OVER_READ_RETURN;
-			break;
-			}
-			if (v_fifo_data_u8[v_fifo_index_u16] ==
-			FIFO_HEAD_OVER_READ_MSB) {
-				/*fifo over read frame index + 1*/
-				v_fifo_index_u16 = v_fifo_index_u16 +
-				BMI160_FIFO_INDEX_LENGTH;
-			break;
+		/* Write data to MAP address */
+		rslt = bmi160_set_regs(BMI160_INT_MAP_0_ADDR, &data, 1, dev);
+	} else {
+		rslt = bmi160_get_regs(BMI160_INT_MAP_2_ADDR, &data, 1, dev);
+		if (rslt == BMI160_OK) {
+			if (int_config->int_type == BMI160_ACC_SINGLE_TAP_INT) {
+				temp = data & ~BMI160_INT2_SINGLE_TAP_MASK;
+				data = temp | ((1 << 5) & BMI160_INT2_SINGLE_TAP_MASK);
 			} else {
-				v_last_return_stat_s8 = FIFO_OVER_READ_RETURN;
-			break;
-			}
+				temp = data & ~BMI160_INT2_DOUBLE_TAP_MASK;
+				data = temp | ((1 << 4) & BMI160_INT2_DOUBLE_TAP_MASK);
 			}
-
-		default:
-			v_last_return_stat_s8 = BMI160_FIFO_INDEX_LENGTH;
-		break;
 		}
-	if (v_last_return_stat_s8 != 0)
-		break;
+		/* Write data to MAP address */
+		rslt = bmi160_set_regs(BMI160_INT_MAP_2_ADDR, &data, 1, dev);
 	}
-return com_rslt;
+
+	return rslt;
 }
+
 /*!
- *	@brief This function is used to read the
- *	fifo data for  header less mode
- *
- *
- *
- *	@note Configure the below functions for FIFO header less mode
- *	@note 1. bmi160_set_fifo_down_gyro
- *	@note 2. bmi160_set_gyro_fifo_filter_data
- *	@note 3. bmi160_set_fifo_down_accel
- *	@note 4. bmi160_set_accel_fifo_filter_dat
- *	@note 5. bmi160_set_fifo_mag_enable
- *	@note 6. bmi160_set_fifo_accel_enable
- *	@note 7. bmi160_set_fifo_gyro_enable
- *	@note For interrupt configuration
- *	@note 1. bmi160_set_intr_fifo_full
- *	@note 2. bmi160_set_intr_fifo_wm
- *	@note 3. bmi160_set_fifo_tag_intr2_enable
- *	@note 4. bmi160_set_fifo_tag_intr1_enable
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
+ * @brief This API configure the source of data(filter & pre-filter)
+ * for tap interrupt.
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_fifo_headerless_mode(
-u8 v_mag_if_u8, struct bmi160_fifo_data_header_less_t *headerless_data) {
-
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* read the whole FIFO data*/
-	com_rslt =
-	bmi160_read_fifo_headerless_mode_user_defined_length(
-	FIFO_FRAME, headerless_data, v_mag_if_u8);
-	return com_rslt;
+static int8_t config_tap_data_src(const struct bmi160_acc_tap_int_cfg *tap_int_cfg, const struct bmi160_dev *dev)
+{
+	int8_t rslt;
+	uint8_t data = 0;
+	uint8_t temp = 0;
+
+	/* Configure Int data 0 register to add source of interrupt */
+	rslt = bmi160_get_regs(BMI160_INT_DATA_0_ADDR, &data, 1, dev);
+	if (rslt == BMI160_OK) {
+		temp = data & ~BMI160_TAP_SRC_INT_MASK;
+		data = temp | ((tap_int_cfg->tap_data_src << 3) & BMI160_TAP_SRC_INT_MASK);
+		/* Write data to Data 0 address */
+		rslt = bmi160_set_regs(BMI160_INT_DATA_0_ADDR, &data, 1, dev);
+	}
+
+	return rslt;
 }
+
 /*!
- *	@brief This function is used to read the
- *	fifo data for header less mode according to user defined length
- *
- *
- *	@param v_fifo_user_length_u16: length of FIFO data to be read
- *	@param v_mag_if_mag_u8 : the Mag interface data
- *	@param fifo_data : the pointer to fifo_data_header_less_t structure
- *
- *	@note Configure the below functions for FIFO header less mode
- *	@note 1. bmi160_set_fifo_down_gyro
- *	@note 2. bmi160_set_gyro_fifo_filter_data
- *	@note 3. bmi160_set_fifo_down_accel
- *	@note 4. bmi160_set_accel_fifo_filter_dat
- *	@note 5. bmi160_set_fifo_mag_enable
- *	@note 6. bmi160_set_fifo_accel_enable
- *	@note 7. bmi160_set_fifo_gyro_enable
- *	@note For interrupt configuration
- *	@note 1. bmi160_set_intr_fifo_full
- *	@note 2. bmi160_set_intr_fifo_wm
- *	@note 3. bmi160_set_fifo_tag_intr2_enable
- *	@note 4. bmi160_set_fifo_tag_intr1_enable
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
+ * @brief This API configure the  parameters of tap interrupt.
+ * Threshold, quite, shock, and duration.
  */
-BMI160_RETURN_FUNCTION_TYPE
-bmi160_read_fifo_headerless_mode_user_defined_length(
-u16 v_fifo_user_length_u16,
-struct bmi160_fifo_data_header_less_t *fifo_data,
-u8 v_mag_if_mag_u8)
+static int8_t config_tap_param(const struct bmi160_int_settg *int_config,
+				const struct bmi160_acc_tap_int_cfg *tap_int_cfg,
+				const struct bmi160_dev *dev)
 {
-u8 v_data_u8 = BMI160_INIT_VALUE;
-u32 v_fifo_index_u16 = BMI160_INIT_VALUE;
-u32 v_fifo_length_u16 = BMI160_INIT_VALUE;
-u8 v_accel_index_u8 = BMI160_INIT_VALUE;
-u8 v_gyro_index_u8 = BMI160_INIT_VALUE;
-u8 v_mag_index_u8 = BMI160_INIT_VALUE;
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-fifo_data->accel_frame_count = BMI160_INIT_VALUE;
-fifo_data->mag_frame_count = BMI160_INIT_VALUE;
-fifo_data->gyro_frame_count = BMI160_INIT_VALUE;
-/* disable the header data */
-com_rslt = bmi160_set_fifo_header_enable(BMI160_INIT_VALUE);
-/* read mag, Accel and gyro enable status*/
-com_rslt += bmi160_read_reg(BMI160_USER_FIFO_CONFIG_1_ADDR,
-&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-v_data_u8 = v_data_u8 & BMI160_FIFO_M_G_A_ENABLE;
-/* read the FIFO data of 1024 bytes*/
-com_rslt += bmi160_fifo_data(&v_fifo_data_u8[BMI160_INIT_VALUE],
-v_fifo_user_length_u16);
-v_fifo_length_u16 = v_fifo_user_length_u16;
-/* loop for executing the different conditions */
-for (v_fifo_index_u16 = BMI160_INIT_VALUE;
-v_fifo_index_u16 < v_fifo_length_u16;) {
-	/* condition for mag, gyro and Accel enable*/
-	if (v_data_u8 == BMI160_FIFO_M_G_A_ENABLE) {
-		/* Raw Mag x*/
-		mag_data.mag_x_lsb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_X_LSB_DATA]);
-		mag_data.mag_x_msb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_X_MSB_DATA]);
-		/* Mag y data*/
-		mag_data.mag_y_lsb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_Y_LSB_DATA]);
-		mag_data.mag_y_msb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_Y_MSB_DATA]);
-		/* Mag z data*/
-		mag_data.mag_z_lsb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_Z_LSB_DATA]);
-		mag_data.mag_z_msb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_Z_MSB_DATA]);
-		/* Mag r data*/
-		mag_data.mag_r_y2_lsb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_R_LSB_DATA]);
-		mag_data.mag_r_y2_msb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_R_MSB_DATA]);
-		com_rslt =
-		bmi160_second_if_mag_compensate_xyz(mag_data,
-		v_mag_if_mag_u8);
-		/* compensated Mag x */
-		fifo_data->mag_fifo[v_mag_index_u8].x =
-		processed_data.x;
-		/* compensated Mag y */
-		fifo_data->mag_fifo[v_mag_index_u8].y =
-		processed_data.y;
-		/* compensated Mag z */
-		fifo_data->mag_fifo[v_mag_index_u8].z =
-		processed_data.z;
-		/* check for Mag frame count*/
-		fifo_data->mag_frame_count =
-		fifo_data->mag_frame_count + BMI160_FRAME_COUNT;
-		/* Gyro raw x v_data_u8 */
-		fifo_data->gyro_fifo[v_gyro_index_u8].x  =
-		(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_MGA_FIFO_G_X_MSB])
-		<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-		|(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_MGA_FIFO_G_X_LSB]));
-		/* Gyro raw y v_data_u8 */
-		fifo_data->gyro_fifo[v_gyro_index_u8].y =
-		(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_MGA_FIFO_G_Y_MSB])
-		<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-		|(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_MGA_FIFO_G_Y_LSB]));
-		/* Gyro raw z v_data_u8 */
-		fifo_data->gyro_fifo[v_gyro_index_u8].z  =
-		(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_MGA_FIFO_G_Z_MSB])
-		<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-		|(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_MGA_FIFO_G_Z_LSB]));
-		/* check for gyro frame count*/
-		fifo_data->gyro_frame_count =
-		fifo_data->gyro_frame_count + BMI160_FRAME_COUNT;
-		/* Accel raw x v_data_u8 */
-		fifo_data->accel_fifo[v_accel_index_u8].x =
-		(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_MGA_FIFO_A_X_MSB])
-		<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-		|(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_MGA_FIFO_A_X_LSB]));
-		/* Accel raw y v_data_u8 */
-		fifo_data->accel_fifo[v_accel_index_u8].y =
-		(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_MGA_FIFO_A_Y_MSB])
-		<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-		|(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_MGA_FIFO_A_Y_LSB]));
-		/* Accel raw z v_data_u8 */
-		fifo_data->accel_fifo[v_accel_index_u8].z =
-		(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_MGA_FIFO_A_Z_MSB])
-		<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-		|(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_MGA_FIFO_A_Z_LSB]));
-		/* check for Accel frame count*/
-		fifo_data->accel_frame_count =
-		fifo_data->accel_frame_count + BMI160_FRAME_COUNT;
-		v_accel_index_u8++;
-		v_mag_index_u8++;
-		v_gyro_index_u8++;
-	   v_fifo_index_u16 = v_fifo_index_u16 +
-	   BMI160_FIFO_AMG_LENGTH;
-	}
-	/* condition for Mag and gyro enable*/
-	else if (v_data_u8 == BMI160_FIFO_M_G_ENABLE) {
-		/* Raw Mag x*/
-		mag_data.mag_x_lsb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_X_LSB_DATA]);
-		mag_data.mag_x_msb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_X_MSB_DATA]);
-		/* Mag y data*/
-		mag_data.mag_y_lsb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_Y_LSB_DATA]);
-		mag_data.mag_y_msb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_Y_MSB_DATA]);
-		/* Mag z data*/
-		mag_data.mag_z_lsb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_Z_LSB_DATA]);
-		mag_data.mag_z_msb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_Z_MSB_DATA]);
-		/* Mag r data*/
-		mag_data.mag_r_y2_lsb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_R_LSB_DATA]);
-		mag_data.mag_r_y2_msb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_R_MSB_DATA]);
-		 com_rslt = bmi160_second_if_mag_compensate_xyz(mag_data,
-		 v_mag_if_mag_u8);
-		 /* compensated Mag x */
-		fifo_data->mag_fifo[v_mag_index_u8].x =
-		processed_data.x;
-		/* compensated Mag y */
-		fifo_data->mag_fifo[v_mag_index_u8].y =
-		processed_data.y;
-		/* compensated Mag z */
-		fifo_data->mag_fifo[v_mag_index_u8].z =
-		processed_data.z;
-		/* check for Mag frame count*/
-		fifo_data->mag_frame_count =
-		fifo_data->mag_frame_count + BMI160_FRAME_COUNT;
-		/* Gyro raw x v_data_u8 */
-		fifo_data->gyro_fifo[v_gyro_index_u8].x  =
-		(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_MG_FIFO_G_X_MSB])
-		<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-		|(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_MG_FIFO_G_X_LSB]));
-		/* Gyro raw y v_data_u8 */
-		fifo_data->gyro_fifo[v_gyro_index_u8].y =
-		(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_MG_FIFO_G_Y_MSB])
-		<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-		|(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_MG_FIFO_G_Y_LSB]));
-		/* Gyro raw z v_data_u8 */
-		fifo_data->gyro_fifo[v_gyro_index_u8].z  =
-		(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_MG_FIFO_G_Z_MSB])
-		<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-		|(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_MG_FIFO_G_Z_LSB]));
-		/* check for gyro frame count*/
-		fifo_data->gyro_frame_count =
-		fifo_data->gyro_frame_count + BMI160_FRAME_COUNT;
-		v_gyro_index_u8++;
-		v_mag_index_u8++;
-		v_fifo_index_u16 = v_fifo_index_u16 +
-		BMI160_FIFO_MA_OR_MG_LENGTH;
-	}
-	/* condition for Mag and Accel enable*/
-	else if (v_data_u8 == BMI160_FIFO_M_A_ENABLE) {
-		/* Raw Mag x*/
-		mag_data.mag_x_lsb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_X_LSB_DATA]);
-		mag_data.mag_x_msb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_X_MSB_DATA]);
-		/* Mag y data*/
-		mag_data.mag_y_lsb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_Y_LSB_DATA]);
-		mag_data.mag_y_msb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_Y_MSB_DATA]);
-		/* Mag z data*/
-		mag_data.mag_z_lsb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_Z_LSB_DATA]);
-		mag_data.mag_z_msb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_Z_MSB_DATA]);
-			/* Mag r data*/
-		mag_data.mag_r_y2_lsb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_R_LSB_DATA]);
-		mag_data.mag_r_y2_msb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_R_MSB_DATA]);
-		 com_rslt = bmi160_second_if_mag_compensate_xyz(mag_data,
-		 v_mag_if_mag_u8);
-		 /* compensated Mag x */
-		fifo_data->mag_fifo[v_mag_index_u8].x =
-		processed_data.x;
-		/* compensated Mag y */
-		fifo_data->mag_fifo[v_mag_index_u8].y =
-		processed_data.y;
-		/* compensated Mag z */
-		fifo_data->mag_fifo[v_mag_index_u8].z =
-		processed_data.z;
-		/* check for Mag frame count*/
-		fifo_data->mag_frame_count =
-		fifo_data->mag_frame_count + BMI160_FRAME_COUNT;
-		/* Accel raw x v_data_u8 */
-		fifo_data->accel_fifo[v_accel_index_u8].x =
-		(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_MA_FIFO_A_X_MSB])
-		<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-		|(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_MA_FIFO_A_X_LSB]));
-		/* Accel raw y v_data_u8 */
-		fifo_data->accel_fifo[v_accel_index_u8].y =
-		(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_MA_FIFO_A_Y_MSB])
-		<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-		|(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_MA_FIFO_A_Y_LSB]));
-		/* Accel raw z v_data_u8 */
-		fifo_data->accel_fifo[v_accel_index_u8].z =
-		(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_MA_FIFO_A_Z_MSB])
-		<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-		|(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_MA_FIFO_A_Z_LSB]));
-		/* check for Accel frame count*/
-		fifo_data->accel_frame_count =
-		fifo_data->accel_frame_count + BMI160_FRAME_COUNT;
-		v_accel_index_u8++;
-		v_mag_index_u8++;
-		v_fifo_index_u16 = v_fifo_index_u16 +
-		BMI160_FIFO_MA_OR_MG_LENGTH;
-	}
-	/* condition for gyro and Accel enable*/
-	else if (v_data_u8 == BMI160_FIFO_G_A_ENABLE) {
-		/* Gyro raw x v_data_u8 */
-		fifo_data->gyro_fifo[v_gyro_index_u8].x  =
-		(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_GA_FIFO_G_X_MSB])
-		<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-		|(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_GA_FIFO_G_X_LSB]));
-		/* Gyro raw y v_data_u8 */
-		fifo_data->gyro_fifo[v_gyro_index_u8].y =
-		(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_GA_FIFO_G_Y_MSB])
-		<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-		|(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_GA_FIFO_G_Y_LSB]));
-		/* Gyro raw z v_data_u8 */
-		fifo_data->gyro_fifo[v_gyro_index_u8].z  =
-		(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_GA_FIFO_G_Z_MSB])
-		<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-		|(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_GA_FIFO_G_Z_LSB]));
-		/* check for gyro frame count*/
-		fifo_data->gyro_frame_count =
-		fifo_data->gyro_frame_count + BMI160_FRAME_COUNT;
-		/* Accel raw x v_data_u8 */
-		fifo_data->accel_fifo[v_accel_index_u8].x =
-		(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_GA_FIFO_A_X_MSB])
-		<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-		|(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_GA_FIFO_A_X_LSB]));
-		/* Accel raw y v_data_u8 */
-		fifo_data->accel_fifo[v_accel_index_u8].y =
-		(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_GA_FIFO_A_Y_MSB])
-		<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-		|(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_GA_FIFO_A_Y_LSB]));
-		/* Accel raw z v_data_u8 */
-		fifo_data->accel_fifo[v_accel_index_u8].z =
-		(s16)(((v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_GA_FIFO_A_Z_MSB])
-		<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-		|(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_GA_FIFO_A_Z_LSB]));
-		/* check for Accel frame count*/
-		fifo_data->accel_frame_count =
-		fifo_data->accel_frame_count + BMI160_FRAME_COUNT;
-		v_accel_index_u8++;
-		v_gyro_index_u8++;
-		v_fifo_index_u16 = v_fifo_index_u16 +
-		BMI160_FIFO_AG_LENGTH;
-	}
-	/* condition  for gyro enable*/
-	else if (v_data_u8 == BMI160_FIFO_GYRO_ENABLE) {
-		/* Gyro raw x v_data_u8 */
-		fifo_data->gyro_fifo[v_gyro_index_u8].x  =
-		(s16)(((v_fifo_data_u8[v_fifo_index_u16
-		+ BMI160_FIFO_X_MSB_DATA])
-		<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-		|(v_fifo_data_u8[v_fifo_index_u16
-		+ BMI160_FIFO_X_LSB_DATA]));
-		/* Gyro raw y v_data_u8 */
-		fifo_data->gyro_fifo[v_gyro_index_u8].y =
-		(s16)(((v_fifo_data_u8[v_fifo_index_u16
-		+ BMI160_FIFO_Y_MSB_DATA])
-		<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-		|(v_fifo_data_u8[v_fifo_index_u16
-		+ BMI160_FIFO_Y_LSB_DATA]));
-		/* Gyro raw z v_data_u8 */
-		fifo_data->gyro_fifo[v_gyro_index_u8].z  =
-		(s16)(((v_fifo_data_u8[v_fifo_index_u16
-		+ BMI160_FIFO_Z_MSB_DATA])
-		<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-		|(v_fifo_data_u8[v_fifo_index_u16
-		+ BMI160_FIFO_Z_LSB_DATA]));
-		/* check for gyro frame count*/
-		fifo_data->gyro_frame_count =
-		fifo_data->gyro_frame_count + BMI160_FRAME_COUNT;
-		v_fifo_index_u16 = v_fifo_index_u16 + BMI160_FIFO_G_LENGTH;
-		v_gyro_index_u8++;
-	}
-	/* condition  for Accel enable*/
-	else if (v_data_u8 == BMI160_FIFO_A_ENABLE) {
-		/* Accel raw x v_data_u8 */
-		fifo_data->accel_fifo[v_accel_index_u8].x =
-		(s16)(((v_fifo_data_u8[v_fifo_index_u16
-		+ BMI160_FIFO_X_MSB_DATA])
-		<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-		|(v_fifo_data_u8[v_fifo_index_u16 + BMI160_FIFO_X_LSB_DATA]));
-		/* Accel raw y v_data_u8 */
-		fifo_data->accel_fifo[v_accel_index_u8].y =
-		(s16)(((v_fifo_data_u8[v_fifo_index_u16
-		+ BMI160_FIFO_Y_MSB_DATA])
-		<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-		|(v_fifo_data_u8[v_fifo_index_u16 + BMI160_FIFO_Y_LSB_DATA]));
-		/* Accel raw z v_data_u8 */
-		fifo_data->accel_fifo[v_accel_index_u8].z =
-		(s16)(((v_fifo_data_u8[v_fifo_index_u16
-		+ BMI160_FIFO_Z_MSB_DATA])
-		<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-		|(v_fifo_data_u8[v_fifo_index_u16 + BMI160_FIFO_Z_LSB_DATA]));
-		/* check for Accel frame count*/
-		fifo_data->accel_frame_count =
-		fifo_data->accel_frame_count + BMI160_FRAME_COUNT;
-		v_fifo_index_u16 = v_fifo_index_u16 + BMI160_FIFO_A_LENGTH;
-		v_accel_index_u8++;
-	}
-	/* condition  for Mag enable*/
-	else if (v_data_u8 == BMI160_FIFO_M_ENABLE) {
-		/* Raw Mag x*/
-		mag_data.mag_x_lsb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_X_LSB_DATA]);
-		mag_data.mag_x_msb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_X_MSB_DATA]);
-		/* Mag y data*/
-		mag_data.mag_y_lsb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_Y_LSB_DATA]);
-		mag_data.mag_y_msb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_Y_MSB_DATA]);
-		/* Mag z data*/
-		mag_data.mag_z_lsb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_Z_LSB_DATA]);
-		mag_data.mag_z_msb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_Z_MSB_DATA]);
-		/* Mag r data*/
-		mag_data.mag_r_y2_lsb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_R_LSB_DATA]);
-		mag_data.mag_r_y2_msb =
-		(v_fifo_data_u8[v_fifo_index_u16 +
-		BMI160_FIFO_R_MSB_DATA]);
-		com_rslt = bmi160_second_if_mag_compensate_xyz(mag_data,
-		v_mag_if_mag_u8);
-		 /* compensated Mag x */
-		fifo_data->mag_fifo[v_mag_index_u8].x =
-		processed_data.x;
-		/* compensated Mag y */
-		fifo_data->mag_fifo[v_mag_index_u8].y =
-		processed_data.y;
-		/* compensated Mag z */
-		fifo_data->mag_fifo[v_mag_index_u8].z =
-		processed_data.z;
-		/* check for Mag frame count*/
-		fifo_data->mag_frame_count =
-		fifo_data->mag_frame_count + BMI160_FRAME_COUNT;
-		v_fifo_index_u16 = v_fifo_index_u16
-		+ BMI160_FIFO_M_LENGTH;
-		v_mag_index_u8++;
-	}
-	/* condition  for FIFO over read enable*/
-	if (v_fifo_data_u8[v_fifo_index_u16] == FIFO_CONFIG_CHECK1 &&
-	v_fifo_data_u8[v_fifo_index_u16 + BMI160_FIFO_INDEX_LENGTH] ==
-	FIFO_CONFIG_CHECK2) {
-		break;
+	int8_t rslt;
+	uint8_t temp = 0;
+	uint8_t data = 0;
+	uint8_t data_array[2] = {0};
+	uint8_t count = 0;
+	uint8_t dur, shock, quiet, thres;
+
+	/* Configure tap 0 register for tap shock,tap quiet duration
+	 * in case of single tap interrupt */
+	rslt = bmi160_get_regs(BMI160_INT_TAP_0_ADDR, data_array, 2, dev);
+	if (rslt == BMI160_OK) {
+		data = data_array[count];
+
+		if (int_config->int_type == BMI160_ACC_DOUBLE_TAP_INT) {
+			dur  = (uint8_t)tap_int_cfg->tap_dur;
+			temp = (data & ~BMI160_TAP_DUR_MASK);
+			/* Add tap duration data in case of
+			 * double tap interrupt */
+			data = temp | (dur & BMI160_TAP_DUR_MASK);
 		}
+
+		shock = (uint8_t)tap_int_cfg->tap_shock;
+		temp = data & ~BMI160_TAP_SHOCK_DUR_MASK;
+		data = temp | ((shock << 6) & BMI160_TAP_SHOCK_DUR_MASK);
+
+		quiet = (uint8_t)tap_int_cfg->tap_quiet;
+		temp = data & ~BMI160_TAP_QUIET_DUR_MASK;
+		data = temp | ((quiet << 7) & BMI160_TAP_QUIET_DUR_MASK);
+
+		data_array[count++] = data;
+
+		data = data_array[count];
+		thres = (uint8_t)tap_int_cfg->tap_thr;
+		temp = data & ~BMI160_TAP_THRES_MASK;
+		data = temp | (thres & BMI160_TAP_THRES_MASK);
+
+		data_array[count++] = data;
+		/* TAP 0 and TAP 1 address lie consecutively,
+		hence writing data to respective registers at one go */
+		/* Writing to Tap 0 and Tap 1 Address simultaneously */
+		rslt = bmi160_set_regs(BMI160_INT_TAP_0_ADDR, data_array, count, dev);
 	}
-	return com_rslt;
-}
-#endif
- /*!
- *	@brief This function is used to read the compensated value of mag
- *	Before start reading the mag compensated data
- *	make sure the following two points are addressed
- *	@note
- *	1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note
- *	2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode.
- *		by using the function bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bmm150_mag_compensate_xyz(
-struct bmi160_mag_xyz_s32_t *mag_comp_xyz)
-{
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	struct bmi160_mag_xyzr_t mag_xyzr;
-
-	com_rslt = bmi160_read_mag_xyzr(&mag_xyzr);
-	if (com_rslt != 0)
-		return com_rslt;
-	/* Compensation for X axis */
-	mag_comp_xyz->x = bmi160_bmm150_mag_compensate_X(
-	mag_xyzr.x, mag_xyzr.r);
-
-	/* Compensation for Y axis */
-	mag_comp_xyz->y = bmi160_bmm150_mag_compensate_Y(
-	mag_xyzr.y, mag_xyzr.r);
-
-	/* Compensation for Z axis */
-	mag_comp_xyz->z = bmi160_bmm150_mag_compensate_Z(
-	mag_xyzr.z, mag_xyzr.r);
-
-	return com_rslt;
+
+	return rslt;
 }
+
 /*!
- *	@brief This API is used to get the compensated BMM150-X axis data
- *
- *	Before start reading the Mag compensated X data
- *	make sure the following two points are addressed
- *	@note
- *	1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note
- *	2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode.
- *		by using the function bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
- *
- *
- *  @param  v_mag_data_x_s16 : The value of Mag raw X data
- *  @param  v_data_r_u16 : The value of Mag R data
- *
- *	@return compensated X axis data
- *
+ * @brief This API configure the secondary interface.
  */
-s32 bmi160_bmm150_mag_compensate_X(s16 v_mag_data_x_s16, u16 v_data_r_u16)
+static int8_t config_sec_if(const struct bmi160_dev *dev)
 {
-s32 inter_retval = BMI160_INIT_VALUE;
-/* no overflow */
-if (v_mag_data_x_s16 != BMI160_MAG_FLIP_OVERFLOW_ADCVAL) {
-	if ((v_data_r_u16 != 0)
-	|| (mag_trim.dig_xyz1 != 0)) {
-		inter_retval = ((s32)(((u16)
-		((((s32)mag_trim.dig_xyz1)
-		<< BMI160_SHIFT_BIT_POSITION_BY_14_BITS)/
-		 (v_data_r_u16 != 0 ?
-		 v_data_r_u16 : mag_trim.dig_xyz1))) -
-		((u16)0x4000)));
-	} else {
-		inter_retval = BMI160_MAG_OVERFLOW_OUTPUT;
-		return inter_retval;
+	int8_t rslt;
+	uint8_t if_conf = 0;
+	uint8_t cmd = BMI160_AUX_NORMAL_MODE;
+
+	/* set the aux power mode to normal*/
+	rslt = bmi160_set_regs(BMI160_COMMAND_REG_ADDR, &cmd, 1, dev);
+	if (rslt == BMI160_OK) {
+		rslt = bmi160_get_regs(BMI160_IF_CONF_ADDR, &if_conf, 1, dev);
+		if_conf |= (uint8_t)(1 << 5);
+		if (rslt == BMI160_OK)
+			/*enable the secondary interface also*/
+			rslt = bmi160_set_regs(BMI160_IF_CONF_ADDR, &if_conf, 1, dev);
 	}
-	inter_retval = ((s32)((((s32)v_mag_data_x_s16) *
-			((((((((s32)mag_trim.dig_xy2) *
-			((((s32)inter_retval) *
-			((s32)inter_retval))
-			>> BMI160_SHIFT_BIT_POSITION_BY_07_BITS)) +
-			 (((s32)inter_retval) *
-			  ((s32)(((s16)mag_trim.dig_xy1)
-			  << BMI160_SHIFT_BIT_POSITION_BY_07_BITS))))
-			  >> BMI160_SHIFT_BIT_POSITION_BY_09_BITS) +
-		   ((s32)0x100000)) *
-		  ((s32)(((s16)mag_trim.dig_x2) +
-		  ((s16)0xA0))))
-		  >> BMI160_SHIFT_BIT_POSITION_BY_12_BITS))
-		  >> BMI160_SHIFT_BIT_POSITION_BY_13_BITS)) +
-		(((s16)mag_trim.dig_x1)
-		<< BMI160_SHIFT_BIT_POSITION_BY_03_BITS);
-	/* check the overflow output */
-	if (inter_retval == (s32)BMI160_MAG_OVERFLOW_OUTPUT)
-		inter_retval = BMI160_MAG_OVERFLOW_OUTPUT_S32;
-} else {
-	/* overflow */
-	inter_retval = BMI160_MAG_OVERFLOW_OUTPUT;
-}
-return inter_retval;
+
+	return rslt;
 }
+
 /*!
- *	@brief This API is used to get the compensated BMM150-Y axis data
- *
- *	Before reading the Mag compensated Y axis data
- *	make sure the following two points are addressed
- *	@note
- *	1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled then set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note
- *	2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode.
- *		by using the function bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
- *
- *
- *  @param  v_mag_data_y_s16 : The value of Mag raw Y axis data
- *  @param  v_data_r_u16 : The value of Mag R data
- *
- *	@return results of compensated Y axis data
+ * @brief This API configure the ODR of the auxiliary sensor.
  */
-s32 bmi160_bmm150_mag_compensate_Y(s16 v_mag_data_y_s16, u16 v_data_r_u16)
+static int8_t config_aux_odr(const struct bmi160_dev *dev)
 {
-s32 inter_retval = BMI160_INIT_VALUE;
-/* no overflow */
-if (v_mag_data_y_s16 != BMI160_MAG_FLIP_OVERFLOW_ADCVAL) {
-	if ((v_data_r_u16 != 0)
-	|| (mag_trim.dig_xyz1 != 0)) {
-		inter_retval = ((s32)(((u16)(((
-		(s32)mag_trim.dig_xyz1)
-		<< BMI160_SHIFT_BIT_POSITION_BY_14_BITS) /
-		(v_data_r_u16 != 0 ?
-		 v_data_r_u16 : mag_trim.dig_xyz1))) -
-		((u16)0x4000)));
-		} else {
-			inter_retval = BMI160_MAG_OVERFLOW_OUTPUT;
-			return inter_retval;
-		}
-	inter_retval = ((s32)((((s32)v_mag_data_y_s16) * ((((((((s32)
-		mag_trim.dig_xy2) * ((((s32) inter_retval) *
-		((s32)inter_retval)) >> BMI160_SHIFT_BIT_POSITION_BY_07_BITS))
-		+ (((s32)inter_retval) *
-		((s32)(((s16)mag_trim.dig_xy1)
-		<< BMI160_SHIFT_BIT_POSITION_BY_07_BITS))))
-		>> BMI160_SHIFT_BIT_POSITION_BY_09_BITS) +
-		((s32)0x100000))
-		* ((s32)(((s16)mag_trim.dig_y2)
-		+ ((s16)0xA0))))
-		>> BMI160_SHIFT_BIT_POSITION_BY_12_BITS))
-		>> BMI160_SHIFT_BIT_POSITION_BY_13_BITS)) +
-		(((s16)mag_trim.dig_y1)
-		<< BMI160_SHIFT_BIT_POSITION_BY_03_BITS);
-	/* check the overflow output */
-	if (inter_retval == (s32)BMI160_MAG_OVERFLOW_OUTPUT)
-		inter_retval = BMI160_MAG_OVERFLOW_OUTPUT_S32;
-} else {
-	/* overflow */
-	inter_retval = BMI160_MAG_OVERFLOW_OUTPUT;
-}
-return inter_retval;
+	int8_t rslt;
+	uint8_t aux_odr;
+
+	rslt = bmi160_get_regs(BMI160_AUX_ODR_ADDR, &aux_odr, 1, dev);
+	if (rslt == BMI160_OK) {
+		aux_odr = (uint8_t)(dev->aux_cfg.aux_odr);
+		/* Set the secondary interface ODR
+		   i.e polling rate of secondary sensor */
+		rslt = bmi160_set_regs(BMI160_AUX_ODR_ADDR, &aux_odr, 1, dev);
+		dev->delay_ms(BMI160_AUX_COM_DELAY);
+	}
+
+	return rslt;
 }
+
 /*!
- *	@brief This API is used to get the compensated BMM150-Z axis data
- *
- *	Before reading the Mag compensated Z data
- *	make sure the following two points are addressed
- *	@note
- *	1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled then set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note
- *	2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode.
- *		by using the function bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
- *
- *
- *  @param  v_mag_data_z_s16 : The value of Mag raw Z data
- *  @param  v_data_r_u16 : The value of Mag R data
- *
- *	@return results of compensated Z axis data
+ * @brief This API maps the actual burst read length set by user.
  */
-s32 bmi160_bmm150_mag_compensate_Z(s16 v_mag_data_z_s16, u16 v_data_r_u16)
+static int8_t map_read_len(uint16_t *len, const struct bmi160_dev *dev)
 {
-	s32 retval = BMI160_INIT_VALUE;
-
-	if (v_mag_data_z_s16 != BMI160_MAG_HALL_OVERFLOW_ADCVAL) {
-		if ((v_data_r_u16 != 0)
-		   && (mag_trim.dig_z2 != 0)
-		   && (mag_trim.dig_z1 != 0)) {
-			retval = (((((s32)(v_mag_data_z_s16 - mag_trim.dig_z4))
-			<< BMI160_SHIFT_BIT_POSITION_BY_15_BITS) -
-			((((s32)mag_trim.dig_z3) *
-			((s32)(((s16)v_data_r_u16) -
-			((s16)mag_trim.dig_xyz1))))
-			>> BMI160_SHIFT_BIT_POSITION_BY_02_BITS))/
-			(mag_trim.dig_z2 +
-			((s16)(((((s32)mag_trim.dig_z1) *
-			((((s16)v_data_r_u16)
-			<< BMI160_SHIFT_BIT_POSITION_BY_01_BIT))) +
-			(1 << BMI160_SHIFT_BIT_POSITION_BY_15_BITS))
-			>> BMI160_SHIFT_BIT_POSITION_BY_16_BITS))));
-		}
-	} else {
-		retval = BMI160_MAG_OVERFLOW_OUTPUT;
+	int8_t rslt = BMI160_OK;
+
+	switch (dev->aux_cfg.aux_rd_burst_len) {
+
+	case BMI160_AUX_READ_LEN_0:
+		*len = 1;
+		break;
+	case BMI160_AUX_READ_LEN_1:
+		*len = 2;
+		break;
+	case BMI160_AUX_READ_LEN_2:
+		*len = 6;
+		break;
+	case BMI160_AUX_READ_LEN_3:
+		*len = 8;
+		break;
+	default:
+		rslt = BMI160_E_INVALID_INPUT;
+		break;
 	}
-		return retval;
+
+	return rslt;
 }
- /*!
- *	@brief This function is used to initialize the bmm150 sensor
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bmm150_mag_interface_init(u8 *v_chip_id_u8)
+
+/*!
+ * @brief This API configure the settings of auxiliary sensor.
+ */
+static int8_t config_aux_settg(const struct bmi160_dev *dev)
 {
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = BMI160_INIT_VALUE;
-	u8 v_data_u8 = BMI160_INIT_VALUE;
-	u8 v_accel_power_mode_status = BMI160_INIT_VALUE;
-
-	com_rslt = bmi160_get_accel_power_mode_stat(
-		&v_accel_power_mode_status);
-	/* Accel operation mode to normal*/
-	if (v_accel_power_mode_status != BMI160_ACCEL_NORMAL_MODE) {
-		com_rslt += bmi160_set_command_register(ACCEL_MODE_NORMAL);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	int8_t rslt;
+
+	rslt = config_sec_if(dev);
+	if (rslt == BMI160_OK) {
+		/* Configures the auxiliary interface settings */
+		rslt = bmi160_config_aux_mode(dev);
 	}
-	/* write the Mag power mode as NORMAL*/
-	com_rslt += bmi160_set_mag_interface_normal();
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* Write the BMM150 i2c address*/
-	com_rslt += bmi160_set_i2c_device_addr(BMI160_AUX_BMM150_I2C_ADDRESS);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* enable the Mag interface to manual mode*/
-	com_rslt += bmi160_set_mag_manual_enable(BMI160_MANUAL_ENABLE);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	bmi160_get_mag_manual_enable(&v_data_u8);
-	/*Enable the MAG interface */
-	com_rslt += bmi160_set_if_mode(BMI160_ENABLE_MAG_IF_MODE);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	bmi160_get_if_mode(&v_data_u8);
-	/* Mag normal mode*/
-	com_rslt += bmi160_bmm150_mag_wakeup();
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* Read the BMM150 device id is 0x32*/
-	com_rslt += bmi160_set_mag_read_addr(BMI160_BMM150_CHIP_ID);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	*v_chip_id_u8 = v_data_u8;
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* write the power mode register*/
-	com_rslt += bmi160_set_mag_write_data(BMI160_BMM_POWER_MODE_REG);
-	/*write 0x4C register to write set power mode to normal*/
-	com_rslt += bmi160_set_mag_write_addr(
-	BMI160_BMM150_POWER_MODE_REG);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* read the Mag trim values*/
-	com_rslt += bmi160_read_bmm150_mag_trim();
-	/* To avoid the auto mode enable when manual mode operation running*/
-	bmm150_manual_auto_condition_u8_g = BMI160_MANUAL_ENABLE;
-	/* write the XY and Z repetitions*/
-	com_rslt += bmi160_set_bmm150_mag_presetmode(
-	BMI160_MAG_PRESETMODE_REGULAR);
-	/* To avoid the auto mode enable when manual mode operation running*/
-	bmm150_manual_auto_condition_u8_g = BMI160_MANUAL_DISABLE;
-	/* Set the power mode of Mag as force mode*/
-	com_rslt += bmi160_set_mag_write_data(BMI160_BMM150_FORCE_MODE);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* write into power mode register*/
-	com_rslt += bmi160_set_mag_write_addr(
-	BMI160_BMM150_POWER_MODE_REG);
-	/* write the Mag v_data_bw_u8 as 25Hz*/
-	com_rslt += bmi160_set_mag_output_data_rate(
-	BMI160_MAG_OUTPUT_DATA_RATE_25HZ);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-
-	/* When Mag interface is in auto mode - The Mag read address
-	starts at the register 0x42*/
-	com_rslt += bmi160_set_mag_read_addr(
-	BMI160_BMM150_DATA_REG);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* enable Mag interface to auto mode*/
-	com_rslt += bmi160_set_mag_manual_enable(BMI160_MANUAL_DISABLE);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	bmi160_get_mag_manual_enable(&v_data_u8);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-
-		switch (v_accel_power_mode_status) {
-
-		case BMI160_ACCEL_SUSPEND:
-			com_rslt += bmi160_set_command_register(ACCEL_SUSPEND);
-			p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-			break;
 
-		case BMI160_ACCEL_LOW_POWER:
-			com_rslt += bmi160_set_command_register(ACCEL_LOWPOWER);
-			p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-			break;
+	return rslt;
+}
+
+/*!
+ * @brief This API extract the read data from auxiliary sensor.
+ */
+static int8_t extract_aux_read(uint16_t map_len, uint8_t reg_addr, uint8_t *aux_data, uint16_t len,
+											const struct bmi160_dev *dev)
+{
+	int8_t rslt = BMI160_OK;
+	uint8_t data[8] = {0,};
+	uint8_t read_addr = BMI160_AUX_DATA_ADDR;
+	uint8_t count = 0;
+	uint8_t read_count;
+	uint8_t read_len = (uint8_t)map_len;
+
+	for (; count < len;) {
+		/* set address to read */
+		rslt = bmi160_set_regs(BMI160_AUX_IF_2_ADDR, &reg_addr, 1, dev);
+		dev->delay_ms(BMI160_AUX_COM_DELAY);
+		if (rslt == BMI160_OK) {
+			rslt = bmi160_get_regs(read_addr, data, map_len, dev);
+			if (rslt == BMI160_OK) {
+				read_count = 0;
+				/* if read len is less the burst read len
+				 * mention by user*/
+				if (len < map_len) {
+					read_len = (uint8_t)len;
+				} else {
+					if ((len - count) < map_len)
+						read_len = (uint8_t)(len - count);
+				}
+
+				for (; read_count < read_len; read_count++)
+					aux_data[count + read_count] = data[read_count];
 
-		default:
-			break;
+				reg_addr += (uint8_t)map_len;
+				count += (uint8_t)map_len;
+			} else {
+				rslt = BMI160_E_COM_FAIL;
+				break;
+			}
+		}
 	}
-	return com_rslt;
+
+	return rslt;
 }
- /*!
- *	@brief This function is used to set the Mag power control
- *	bit enable
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bmm150_mag_wakeup(void)
+
+/*!
+ * @brief This API enables the orient interrupt.
+ */
+static int8_t enable_orient_int(const struct bmi160_acc_orient_int_cfg *orient_int_cfg, const struct bmi160_dev *dev)
 {
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = BMI160_INIT_VALUE;
-	u8 v_try_times_u8 = BMI160_BMM150_MAX_RETRY_WAKEUP;
-	u8 v_power_control_bit_u8 = BMI160_INIT_VALUE;
-	u8 i = BMI160_INIT_VALUE;
-
-	for (i = BMI160_INIT_VALUE; i < v_try_times_u8; i++) {
-		com_rslt = bmi160_set_mag_write_data(BMI160_BMM150_POWER_ON);
-		p_bmi160->delay_msec(BMI160_BMM150_WAKEUP_DELAY1);
-		/*write 0x4B register to enable power control bit*/
-		com_rslt += bmi160_set_mag_write_addr(
-		BMI160_BMM150_POWER_CONTROL_REG);
-		p_bmi160->delay_msec(BMI160_BMM150_WAKEUP_DELAY2);
-		com_rslt += bmi160_set_mag_read_addr(
-		BMI160_BMM150_POWER_CONTROL_REG);
-		/* 0x04 is secondary read Mag x LSB register */
-		p_bmi160->delay_msec(BMI160_BMM150_WAKEUP_DELAY3);
-		com_rslt += bmi160_read_reg(BMI160_USER_DATA_0_ADDR,
-		&v_power_control_bit_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-		v_power_control_bit_u8 = BMI160_BMM150_SET_POWER_CONTROL
-		& v_power_control_bit_u8;
-		if (v_power_control_bit_u8 == BMI160_BMM150_POWER_ON)
-			break;
+	int8_t rslt;
+	uint8_t data = 0;
+	uint8_t temp = 0;
+
+	/* Enable data ready interrupt in Int Enable 0 register */
+	rslt = bmi160_get_regs(BMI160_INT_ENABLE_0_ADDR, &data, 1, dev);
+	if (rslt == BMI160_OK) {
+		temp = data & ~BMI160_ORIENT_INT_EN_MASK;
+		data = temp | ((orient_int_cfg->orient_en << 6) & BMI160_ORIENT_INT_EN_MASK);
+		/* write data to Int Enable 0 register */
+		rslt = bmi160_set_regs(BMI160_INT_ENABLE_0_ADDR, &data, 1, dev);
 	}
-	com_rslt = (i >= v_try_times_u8) ?
-	BMI160_BMM150_POWER_ON_FAIL : BMI160_BMM150_POWER_ON_SUCCESS;
-	return com_rslt;
+
+	return rslt;
 }
- /*!
- *	@brief This function is used to set the Mag
- *	power mode.
- *	@note Before setting the Mag power mode
- *	make sure the following points are addressed
- *		Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *
- *	@param v_mag_sec_if_pow_mode_u8 : The value of Mag power mode
- *  value    |  mode
- * ----------|------------
- *   0       | BMI160_MAG_FORCE_MODE
- *   1       | BMI160_MAG_SUSPEND_MODE
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_bmm150_mag_and_secondary_if_power_mode(
-u8 v_mag_sec_if_pow_mode_u8)
+
+/*!
+ * @brief This API maps the INT pin to orientation interrupt.
+ */
+static int8_t map_int_pin_to_orient(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
 {
-	  u8 v_accel_power_mode_status = BMI160_INIT_VALUE;
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = BMI160_INIT_VALUE;
-
-	com_rslt = bmi160_get_accel_power_mode_stat(
-		&v_accel_power_mode_status);
-	/* set the Accel power mode to NORMAL*/
-	if (v_accel_power_mode_status != BMI160_ACCEL_NORMAL_MODE) {
-		com_rslt += bmi160_set_command_register(ACCEL_MODE_NORMAL);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	}
+	int8_t rslt;
+	uint8_t data = 0;
+	uint8_t temp = 0;
 
-	switch (v_mag_sec_if_pow_mode_u8) {
-	case BMI160_MAG_FORCE_MODE:
-		/* set the secondary Mag power mode as NORMAL*/
-		com_rslt += bmi160_set_mag_interface_normal();
-		/* set the Mag power mode as FORCE mode*/
-		com_rslt += bmi160_bmm150_mag_set_power_mode(FORCE_MODE);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	break;
-	case BMI160_MAG_SUSPEND_MODE:
-		/* set the Mag power mode as SUSPEND mode*/
-		com_rslt += bmi160_bmm150_mag_set_power_mode(SUSPEND_MODE);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		/* set the secondary Mag power mode as SUSPEND*/
-		com_rslt += bmi160_set_command_register(MAG_MODE_SUSPEND);
-		p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-	break;
-	default:
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-	break;
-	}
-	if (p_bmi160->mag_manual_enable == BMI160_MANUAL_ENABLE) {
-		/* set Mag interface auto mode*/
-		com_rslt += bmi160_set_mag_manual_enable(
-		BMI160_MANUAL_DISABLE);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	/* Configure Int Map register to map interrupt pin
+	 * to orientation interrupt */
+	if (int_config->int_channel == BMI160_INT_CHANNEL_1) {
+		rslt = bmi160_get_regs(BMI160_INT_MAP_0_ADDR, &data, 1, dev);
+		if (rslt == BMI160_OK) {
+			temp = data & ~BMI160_INT1_ORIENT_MASK;
+			data = temp | ((1 << 6) & BMI160_INT1_ORIENT_MASK);
+			rslt = bmi160_set_regs(BMI160_INT_MAP_0_ADDR, &data, 1, dev);
+		}
+	} else {
+		rslt = bmi160_get_regs(BMI160_INT_MAP_2_ADDR, &data, 1, dev);
+		if (rslt == BMI160_OK) {
+			temp = data & ~BMI160_INT2_ORIENT_MASK;
+			data = temp | ((1 << 6) & BMI160_INT2_ORIENT_MASK);
+			rslt = bmi160_set_regs(BMI160_INT_MAP_2_ADDR, &data, 1, dev);
+		}
 	}
-		switch (v_accel_power_mode_status) {
 
-		case BMI160_ACCEL_SUSPEND:
-			com_rslt += bmi160_set_command_register(ACCEL_SUSPEND);
-			p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-			break;
+	return rslt;
+}
 
-		case BMI160_ACCEL_LOW_POWER:
-			com_rslt += bmi160_set_command_register(ACCEL_LOWPOWER);
-			p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-			break;
+/*!
+ * @brief This API configure the necessary setting of orientation interrupt.
+ */
+static int8_t config_orient_int_settg(const struct bmi160_acc_orient_int_cfg *orient_int_cfg,
+					const struct bmi160_dev *dev)
+{
+	int8_t rslt;
+	uint8_t data = 0;
+	uint8_t temp = 0;
+	uint8_t data_array[2] = {0, 0};
+
+	/* Configuring INT_ORIENT registers */
+	rslt = bmi160_get_regs(BMI160_INT_ORIENT_0_ADDR, data_array, 2, dev);
+	if (rslt == BMI160_OK) {
+		data = data_array[0];
+		temp = data & ~BMI160_ORIENT_MODE_MASK;
+		/* Adding Orientation mode */
+		data = temp | ((orient_int_cfg->orient_mode) & BMI160_ORIENT_MODE_MASK);
+		temp = data & ~BMI160_ORIENT_BLOCK_MASK;
+		/* Adding Orientation blocking */
+		data = temp | ((orient_int_cfg->orient_blocking << 2) & BMI160_ORIENT_BLOCK_MASK);
+		temp = data & ~BMI160_ORIENT_HYST_MASK;
+		 /* Adding Orientation hysteresis */
+		data = temp | ((orient_int_cfg->orient_hyst << 4) & BMI160_ORIENT_HYST_MASK);
+		data_array[0] = data;
+
+		data = data_array[1];
+		temp = data & ~BMI160_ORIENT_THETA_MASK;
+		/* Adding Orientation threshold */
+		data = temp | ((orient_int_cfg->orient_theta) & BMI160_ORIENT_THETA_MASK);
+		temp = data & ~BMI160_ORIENT_UD_ENABLE;
+		/* Adding Orient_ud_en */
+		data = temp | ((orient_int_cfg->orient_ud_en << 6) & BMI160_ORIENT_UD_ENABLE);
+		temp = data & ~BMI160_AXES_EN_MASK;
+		/* Adding axes_en */
+		data = temp | ((orient_int_cfg->axes_ex << 7) & BMI160_AXES_EN_MASK);
+		data_array[1] = data;
+		/* Writing data to INT_ORIENT 0 and INT_ORIENT 1
+		 * registers simultaneously */
+		rslt = bmi160_set_regs(BMI160_INT_ORIENT_0_ADDR, data_array, 2, dev);
+	}
+
+	return rslt;
+}
+
+/*!
+ * @brief This API enables the flat interrupt.
+ */
+static int8_t enable_flat_int(const struct bmi160_acc_flat_detect_int_cfg *flat_int, const struct bmi160_dev *dev)
+{
+	int8_t rslt;
+	uint8_t data = 0;
+	uint8_t temp = 0;
 
-		default:
-			break;
+	/* Enable flat interrupt in Int Enable 0 register */
+	rslt = bmi160_get_regs(BMI160_INT_ENABLE_0_ADDR, &data, 1, dev);
+	if (rslt == BMI160_OK) {
+		temp = data & ~BMI160_FLAT_INT_EN_MASK;
+		data = temp | ((flat_int->flat_en << 7) & BMI160_FLAT_INT_EN_MASK);
+		/* write data to Int Enable 0 register */
+		rslt = bmi160_set_regs(BMI160_INT_ENABLE_0_ADDR, &data, 1, dev);
 	}
-	return com_rslt;
+
+	return rslt;
 }
+
 /*!
- *	@brief This function is used to set the Mag
- *	power mode.
- *	@note
- *	Before setting the Mag power mode make sure the following
- *	two points are addressed
- *	@note
- *	1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled then set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note
- *	2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode by using the
- *		function bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
- *	@param v_mag_pow_mode_u8 : The value of Mag power mode
- *  value    |  mode
- * ----------|------------
- *   0       | FORCE_MODE
- *   1       | SUSPEND_MODE
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bmm150_mag_set_power_mode(
-u8 v_mag_pow_mode_u8)
+ * @brief This API maps the INT pin to flat interrupt.
+ */
+static int8_t map_int_pin_to_flat(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
 {
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* set Mag interface manual mode*/
-	if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE) {
-		com_rslt = bmi160_set_mag_manual_enable(
-		BMI160_MANUAL_ENABLE);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		if (com_rslt != SUCCESS)
-			return com_rslt;
+	int8_t rslt;
+	uint8_t data = 0;
+	uint8_t temp = 0;
+
+	/* Configure Map register to map interrupt pin to flat interrupt*/
+	if (int_config->int_channel == BMI160_INT_CHANNEL_1) {
+		rslt = bmi160_get_regs(BMI160_INT_MAP_0_ADDR, &data, 1, dev);
+		if (rslt == BMI160_OK) {
+			temp = data & ~BMI160_INT1_FLAT_MASK;
+			data = temp | ((1 << 7) & BMI160_INT1_FLAT_MASK);
+			rslt = bmi160_set_regs(BMI160_INT_MAP_0_ADDR, &data, 1, dev);
+		}
 	} else {
-		com_rslt = SUCCESS;
-	}
-	switch (v_mag_pow_mode_u8) {
-	case FORCE_MODE:
-		/* Set the power control bit enabled */
-		com_rslt = bmi160_bmm150_mag_wakeup();
-		/* write the Mag power mode as FORCE mode*/
-		com_rslt += bmi160_set_mag_write_data(
-		BMI160_BMM150_FORCE_MODE);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		com_rslt += bmi160_set_mag_write_addr(
-		BMI160_BMM150_POWER_MODE_REG);
-		p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-		/* To avoid the auto mode enable when manual
-		mode operation running*/
-		bmm150_manual_auto_condition_u8_g = BMI160_MANUAL_ENABLE;
-		/* set the preset mode */
-		com_rslt += bmi160_set_bmm150_mag_presetmode(
-		BMI160_MAG_PRESETMODE_REGULAR);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		/* To avoid the auto mode enable when manual
-		mode operation running*/
-		bmm150_manual_auto_condition_u8_g = BMI160_MANUAL_DISABLE;
-		/* set the Mag read address to data registers*/
-		com_rslt += bmi160_set_mag_read_addr(
-		BMI160_BMM150_DATA_REG);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	break;
-	case SUSPEND_MODE:
-		/* Set the power mode of Mag as suspend mode*/
-		com_rslt = bmi160_set_mag_write_data(
-		BMI160_BMM150_POWER_OFF);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		com_rslt += bmi160_set_mag_write_addr(
-		BMI160_BMM150_POWER_CONTROL_REG);
-		p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-	break;
-	default:
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-	break;
-	}
-	/* set Mag interface auto mode*/
-	if (p_bmi160->mag_manual_enable == BMI160_MANUAL_ENABLE) {
-		com_rslt += bmi160_set_mag_manual_enable(
-		BMI160_MANUAL_DISABLE);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+		rslt = bmi160_get_regs(BMI160_INT_MAP_2_ADDR, &data, 1, dev);
+		if (rslt == BMI160_OK) {
+			temp = data & ~BMI160_INT2_FLAT_MASK;
+			data = temp | ((1 << 7) & BMI160_INT2_FLAT_MASK);
+			rslt = bmi160_set_regs(BMI160_INT_MAP_2_ADDR, &data, 1, dev);
+		}
 	}
-	return com_rslt;
+
+	return rslt;
 }
+
 /*!
- *	@brief This API is used to set the pre-set modes of bmm150
- *	The pre-set mode setting depends on the data rate and xy and z
- *	repetitions
- *
- *	@note
- *	Before setting the Mag preset mode
- *	make sure the following two points are addressed
- *	@note
- *	1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note
- *	2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode by using the function
- *		bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
- *
- *  @param  v_mode_u8: The value of pre-set mode selection value
- *  value    |  pre_set mode
- * ----------|------------
- *   1       | BMI160_MAG_PRESETMODE_LOWPOWER
- *   2       | BMI160_MAG_PRESETMODE_REGULAR
- *   3       | BMI160_MAG_PRESETMODE_HIGHACCURACY
- *   4       | BMI160_MAG_PRESETMODE_ENHANCED
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
+ * @brief This API configure the necessary setting of flat interrupt.
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_bmm150_mag_presetmode(u8 v_mode_u8)
+static int8_t config_flat_int_settg(const struct bmi160_acc_flat_detect_int_cfg *flat_int, const struct bmi160_dev *dev)
 {
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* set Mag interface manual mode*/
-	if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE)
-			com_rslt = bmi160_set_mag_manual_enable(
-			BMI160_MANUAL_ENABLE);
-	switch (v_mode_u8) {
-	case BMI160_MAG_PRESETMODE_LOWPOWER:
-		/* write the XY and Z repetitions*/
-
-		com_rslt = bmi160_set_mag_write_data(
-		BMI160_MAG_LOWPOWER_REPXY);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		com_rslt += bmi160_set_mag_write_addr(
-		BMI160_BMM150_XY_REP);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		/* write the Z repetitions*/
-
-		com_rslt += bmi160_set_mag_write_data(
-		BMI160_MAG_LOWPOWER_REPZ);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		com_rslt += bmi160_set_mag_write_addr(
-		BMI160_BMM150_Z_REP);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		/* set the Mag v_data_u8 rate as 10 to the register 0x4C*/
-		com_rslt += bmi160_set_mag_write_data(
-		BMI160_MAG_LOWPOWER_DR);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		com_rslt += bmi160_set_mag_write_addr(
-		BMI160_BMM150_POWER_MODE_REG);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	break;
-	case BMI160_MAG_PRESETMODE_REGULAR:
-		/* write the XY and Z repetitions*/
-
-		com_rslt = bmi160_set_mag_write_data(
-		BMI160_MAG_REGULAR_REPXY);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		com_rslt += bmi160_set_mag_write_addr(
-		BMI160_BMM150_XY_REP);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		/* write the Z repetitions*/
-
-		com_rslt += bmi160_set_mag_write_data(
-		BMI160_MAG_REGULAR_REPZ);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		com_rslt += bmi160_set_mag_write_addr(
-		BMI160_BMM150_Z_REP);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		/* set the Mag v_data_u8 rate as 10 to the register 0x4C*/
-		com_rslt += bmi160_set_mag_write_data(
-		BMI160_MAG_REGULAR_DR);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		com_rslt += bmi160_set_mag_write_addr(
-		BMI160_BMM150_POWER_MODE_REG);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	break;
-	case BMI160_MAG_PRESETMODE_HIGHACCURACY:
-		/* write the XY and Z repetitions*/
-
-		com_rslt = bmi160_set_mag_write_data(
-		BMI160_MAG_HIGHACCURACY_REPXY);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		com_rslt += bmi160_set_mag_write_addr(
-		BMI160_BMM150_XY_REP);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		/* write the Z repetitions*/
-
-		com_rslt += bmi160_set_mag_write_data(
-		BMI160_MAG_HIGHACCURACY_REPZ);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		com_rslt += bmi160_set_mag_write_addr(
-		BMI160_BMM150_Z_REP);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		/* set the Mag v_data_u8 rate as 20 to the register 0x4C*/
-		com_rslt += bmi160_set_mag_write_data(
-		BMI160_MAG_HIGHACCURACY_DR);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		com_rslt += bmi160_set_mag_write_addr(
-		BMI160_BMM150_POWER_MODE_REG);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	break;
-	case BMI160_MAG_PRESETMODE_ENHANCED:
-		/* write the XY and Z repetitions*/
-
-		com_rslt = bmi160_set_mag_write_data(
-		BMI160_MAG_ENHANCED_REPXY);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		com_rslt += bmi160_set_mag_write_addr(
-		BMI160_BMM150_XY_REP);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		/* write the Z repetitions*/
-
-		com_rslt += bmi160_set_mag_write_data(
-		BMI160_MAG_ENHANCED_REPZ);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		com_rslt += bmi160_set_mag_write_addr(
-		BMI160_BMM150_Z_REP);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		/* set the Mag v_data_u8 rate as 10 to the register 0x4C*/
-		com_rslt += bmi160_set_mag_write_data(
-		BMI160_MAG_ENHANCED_DR);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		com_rslt += bmi160_set_mag_write_addr(
-		BMI160_BMM150_POWER_MODE_REG);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	break;
-	default:
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-	break;
+	int8_t rslt;
+	uint8_t data = 0;
+	uint8_t temp = 0;
+	uint8_t data_array[2] = {0, 0};
+
+	/* Configuring INT_FLAT register */
+	rslt = bmi160_get_regs(BMI160_INT_FLAT_0_ADDR, data_array, 2, dev);
+	if (rslt == BMI160_OK) {
+		data = data_array[0];
+		temp = data & ~BMI160_FLAT_THRES_MASK;
+		/* Adding flat theta */
+		data = temp | ((flat_int->flat_theta) & BMI160_FLAT_THRES_MASK);
+		data_array[0] = data;
+
+		data = data_array[1];
+		temp = data & ~BMI160_FLAT_HOLD_TIME_MASK;
+		/* Adding flat hold time */
+		data = temp | ((flat_int->flat_hold_time << 4) & BMI160_FLAT_HOLD_TIME_MASK);
+		temp = data & ~BMI160_FLAT_HYST_MASK;
+		/* Adding flat hysteresis */
+		data = temp | ((flat_int->flat_hy) & BMI160_FLAT_HYST_MASK);
+		data_array[1] = data;
+		/* Writing data to INT_FLAT 0 and INT_FLAT 1
+		 * registers simultaneously */
+		rslt = bmi160_set_regs(BMI160_INT_FLAT_0_ADDR, data_array, 2, dev);
 	}
-	if (bmm150_manual_auto_condition_u8_g == BMI160_MANUAL_DISABLE) {
-			com_rslt += bmi160_set_mag_write_data(
-			BMI160_BMM150_FORCE_MODE);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		com_rslt += bmi160_set_mag_write_addr(
-		BMI160_BMM150_POWER_MODE_REG);
-		p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-		com_rslt += bmi160_set_mag_read_addr(BMI160_BMM150_DATA_REG);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		/* set Mag interface auto mode*/
-		if (p_bmi160->mag_manual_enable == BMI160_MANUAL_ENABLE)
-			com_rslt = bmi160_set_mag_manual_enable(
-			BMI160_MANUAL_DISABLE);
-		}
-	return com_rslt;
-}
- /*!
- *	@brief This function is used to read the trim values of Mag
- *
- *	@note Before reading the Mag trimming values
- *	make sure the following two points are addressed
- *	@note
- *	1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note
- *	2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode.
- *		by using the function bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_bmm150_mag_trim(void)
-{
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* Array holding the bmm150 trim data
-	*/
-	u8 v_data_u8[BMI160_MAG_TRIM_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, BMI160_INIT_VALUE,
-	BMI160_INIT_VALUE,
-	BMI160_INIT_VALUE, BMI160_INIT_VALUE,
-	BMI160_INIT_VALUE,
-	BMI160_INIT_VALUE, BMI160_INIT_VALUE,
-	BMI160_INIT_VALUE};
-	/* read dig_x1 value */
-	com_rslt = bmi160_set_mag_read_addr(
-	BMI160_MAG_DIG_X1);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* 0x04 is secondary read Mag x LSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[BMI160_BMM150_DIG_X1],
-	BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	mag_trim.dig_x1 = v_data_u8[BMI160_BMM150_DIG_X1];
-	/* read dig_y1 value */
-	com_rslt += bmi160_set_mag_read_addr(
-	BMI160_MAG_DIG_Y1);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* 0x04 is secondary read Mag x LSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[BMI160_BMM150_DIG_Y1],
-	BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	mag_trim.dig_y1 = v_data_u8[BMI160_BMM150_DIG_Y1];
-
-	/* read dig_x2 value */
-	com_rslt += bmi160_set_mag_read_addr(
-	BMI160_MAG_DIG_X2);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* 0x04 is secondary read Mag x LSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[BMI160_BMM150_DIG_X2],
-	BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	mag_trim.dig_x2 = v_data_u8[BMI160_BMM150_DIG_X2];
-	/* read dig_y2 value */
-	com_rslt += bmi160_set_mag_read_addr(
-	BMI160_MAG_DIG_Y2);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* 0x04 is secondary read Mag x LSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[BMI160_BMM150_DIG_Y3],
-	BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	mag_trim.dig_y2 = v_data_u8[BMI160_BMM150_DIG_Y3];
-
-	/* read dig_xy1 value */
-	com_rslt += bmi160_set_mag_read_addr(
-	BMI160_MAG_DIG_XY1);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* 0x04 is secondary read Mag x LSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[BMI160_BMM150_DIG_XY1],
-	BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	mag_trim.dig_xy1 = v_data_u8[BMI160_BMM150_DIG_XY1];
-	/* read dig_xy2 value */
-	com_rslt += bmi160_set_mag_read_addr(
-	BMI160_MAG_DIG_XY2);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* 0x04 is v_mag_x_s16 ls register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[BMI160_BMM150_DIG_XY2],
-	BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	mag_trim.dig_xy2 = v_data_u8[BMI160_BMM150_DIG_XY2];
-
-	/* read dig_z1 LSB value */
-	com_rslt += bmi160_set_mag_read_addr(
-	BMI160_MAG_DIG_Z1_LSB);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* 0x04 is secondary read Mag x LSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[BMI160_BMM150_DIG_Z1_LSB],
-	BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* read dig_z1 MSB value */
-	com_rslt += bmi160_set_mag_read_addr(BMI160_MAG_DIG_Z1_MSB);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* 0x04 is v_mag_x_s16 MSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[BMI160_BMM150_DIG_Z1_MSB],
-	BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	mag_trim.dig_z1 =
-	(u16)((((u32)((u8)v_data_u8[BMI160_BMM150_DIG_Z1_MSB]))
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
-			(v_data_u8[BMI160_BMM150_DIG_Z1_LSB]));
-
-	/* read dig_z2 LSB value */
-	com_rslt += bmi160_set_mag_read_addr(BMI160_MAG_DIG_Z2_LSB);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* 0x04 is secondary read Mag x LSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[BMI160_BMM150_DIG_Z2_LSB],
-	BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* read dig_z2 MSB value */
-	com_rslt += bmi160_set_mag_read_addr(BMI160_MAG_DIG_Z2_MSB);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* 0x04 is v_mag_x_s16 MSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[BMI160_BMM150_DIG_Z2_MSB],
-	BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	mag_trim.dig_z2 =
-	(s16)((((s32)((s8)v_data_u8[BMI160_BMM150_DIG_Z2_MSB]))
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
-			(v_data_u8[BMI160_BMM150_DIG_Z2_LSB]));
-
-	/* read dig_z3 LSB value */
-	com_rslt += bmi160_set_mag_read_addr(BMI160_MAG_DIG_Z3_LSB);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* 0x04 is secondary read Mag x LSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[BMI160_BMM150_DIG_DIG_Z3_LSB],
-	BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* read dig_z3 MSB value */
-	com_rslt += bmi160_set_mag_read_addr(BMI160_MAG_DIG_Z3_MSB);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* 0x04 is v_mag_x_s16 MSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[BMI160_BMM150_DIG_DIG_Z3_MSB],
-	BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	mag_trim.dig_z3 =
-	(s16)((((s32)((s8)v_data_u8[BMI160_BMM150_DIG_DIG_Z3_MSB]))
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
-			(v_data_u8[BMI160_BMM150_DIG_DIG_Z3_LSB]));
-	/* read dig_z4 LSB value */
-	com_rslt += bmi160_set_mag_read_addr(BMI160_MAG_DIG_Z4_LSB);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* 0x04 is secondary read Mag x LSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[BMI160_BMM150_DIG_DIG_Z4_LSB],
-	BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* read dig_z4 MSB value */
-	com_rslt += bmi160_set_mag_read_addr(BMI160_MAG_DIG_Z4_MSB);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* 0x04 is v_mag_x_s16 MSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[BMI160_BMM150_DIG_DIG_Z4_MSB],
-	BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	mag_trim.dig_z4 =
-	(s16)((((s32)((s8)v_data_u8[BMI160_BMM150_DIG_DIG_Z4_MSB]))
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
-			(v_data_u8[BMI160_BMM150_DIG_DIG_Z4_LSB]));
-
-	/* read dig_xyz1 LSB value */
-	com_rslt += bmi160_set_mag_read_addr(BMI160_MAG_DIG_XYZ1_LSB);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* 0x04 is secondary read Mag x LSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[BMI160_BMM150_DIG_DIG_XYZ1_LSB],
-	BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* read dig_xyz1 MSB value */
-	com_rslt += bmi160_set_mag_read_addr(BMI160_MAG_DIG_XYZ1_MSB);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* 0x04 is v_mag_x_s16 MSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[BMI160_BMM150_DIG_DIG_XYZ1_MSB],
-	BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	mag_trim.dig_xyz1 =
-	(u16)((((u32)((u8)v_data_u8[BMI160_BMM150_DIG_DIG_XYZ1_MSB]))
-			<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
-			(v_data_u8[BMI160_BMM150_DIG_DIG_XYZ1_LSB]));
-
-	return com_rslt;
+
+	return rslt;
 }
- #ifdef AKM09912
- /***************************************************/
-/**\name	FUNCTIONS FOR AKM09912*/
-/***************************************************/
 
 /*!
- *	@brief This API is used to get the compensated X data
- *	of AKM09912 sensor
- *	Output of X is s32
- *	@note	Before start reading the Mag compensated X data
- *			make sure the following two points are addressed
- *	@note 1. Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note 2. And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode.
- *		by using the function bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
- *
- *	@param v_bst_akm_x_s16 : The value of X data
- *
- *	@return compensated X data value
- *
+ * @brief This API enables the Low-g interrupt.
  */
-s32 bmi160_bst_akm09912_compensate_X(s16 v_bst_akm_x_s16)
+static int8_t enable_low_g_int(const struct bmi160_acc_low_g_int_cfg *low_g_int, const struct bmi160_dev *dev)
 {
-	/*Return value of AKM x compensated data*/
-	s32 retval = BMI160_INIT_VALUE;
-	/* Convert raw data into compensated data*/
-	retval = v_bst_akm_x_s16 *
-	(akm_asa_data.asax + AKM09912_SENSITIVITY)
-	/ AKM09912_SENSITIVITY_DIV;
-	return retval;
+	int8_t rslt;
+	uint8_t data = 0;
+	uint8_t temp = 0;
+
+	/* Enable low-g interrupt in Int Enable 1 register */
+	rslt = bmi160_get_regs(BMI160_INT_ENABLE_1_ADDR, &data, 1, dev);
+	if (rslt == BMI160_OK) {
+		temp = data & ~BMI160_LOW_G_INT_EN_MASK;
+		data = temp | ((low_g_int->low_en << 3) & BMI160_LOW_G_INT_EN_MASK);
+		/* write data to Int Enable 0 register */
+		rslt = bmi160_set_regs(BMI160_INT_ENABLE_1_ADDR, &data, 1, dev);
+	}
+
+	return rslt;
 }
+
 /*!
- *	@brief This API is used to get the compensated Y data
- *	of AKM09912 sensor
- *	@note	Before reading the Mag compensated Y data
- *		make sure the following two points are addressed
- *	@note 1. Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note 2. And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode by using the function
- *		bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
- *
- *  @param v_bst_akm_y_s16 : The value of Y data
- *
- *	@return compensated Y data value
- *
+ * @brief This API configure the source of data(filter & pre-filter)
+ * for low-g interrupt.
  */
-s32 bmi160_bst_akm09912_compensate_Y(s16 v_bst_akm_y_s16)
+static int8_t config_low_g_data_src(const struct bmi160_acc_low_g_int_cfg *low_g_int, const struct bmi160_dev *dev)
 {
-	/*Return value of AKM y compensated data*/
-	s32 retval = BMI160_INIT_VALUE;
-	/* Convert raw data into compensated data*/
-	retval = v_bst_akm_y_s16 *
-	(akm_asa_data.asax + AKM09912_SENSITIVITY)
-	/ AKM09912_SENSITIVITY_DIV;
-	return retval;
+	int8_t rslt;
+	uint8_t data = 0;
+	uint8_t temp = 0;
+
+	/* Configure Int data 0 register to add source of interrupt */
+	rslt = bmi160_get_regs(BMI160_INT_DATA_0_ADDR, &data, 1, dev);
+	if (rslt == BMI160_OK) {
+		temp = data & ~BMI160_LOW_HIGH_SRC_INT_MASK;
+		data = temp | ((low_g_int->low_data_src << 7) & BMI160_LOW_HIGH_SRC_INT_MASK);
+		/* Write data to Data 0 address */
+		rslt = bmi160_set_regs(BMI160_INT_DATA_0_ADDR, &data, 1, dev);
+	}
+
+	return rslt;
 }
+
 /*!
- *	@brief This API is used to get the compensated Z data
- *	of AKM09912
- *	Output of X is s32
- *	@note	Before start reading the Mag compensated Z data
- *			make sure the following two points are addressed
- *	@note 1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note 2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode.
- *		by using the function bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
- *
- *  @param v_bst_akm_z_s16 : The value of Z data
- *
- *	@return compensated Z data value
- *
+ * @brief This API configure the necessary setting of low-g interrupt.
  */
-s32 bmi160_bst_akm09912_compensate_Z(s16 v_bst_akm_z_s16)
+static int8_t config_low_g_int_settg(const struct bmi160_acc_low_g_int_cfg *low_g_int,  const struct bmi160_dev *dev)
 {
-	/*Return value of AKM z compensated data*/
-	s32 retval = BMI160_INIT_VALUE;
-	/* Convert raw data into compensated data*/
-	retval = v_bst_akm_z_s16 *
-	(akm_asa_data.asax + AKM09912_SENSITIVITY)
-	/ AKM09912_SENSITIVITY_DIV;
-	return retval;
+	int8_t rslt;
+	uint8_t temp = 0;
+	uint8_t data_array[3] = {0, 0, 0};
+
+	/* Configuring INT_LOWHIGH register for low-g interrupt */
+	rslt = bmi160_get_regs(BMI160_INT_LOWHIGH_2_ADDR, &data_array[2], 1, dev);
+
+	if (rslt == BMI160_OK) {
+		temp = data_array[2] & ~BMI160_LOW_G_HYST_MASK;
+		/* Adding low-g hysteresis */
+		data_array[2] = temp | (low_g_int->low_hyst & BMI160_LOW_G_HYST_MASK);
+		temp = data_array[2] & ~BMI160_LOW_G_LOW_MODE_MASK;
+		/* Adding low-mode */
+		data_array[2] = temp | ((low_g_int->low_mode << 2) & BMI160_LOW_G_LOW_MODE_MASK);
+
+		/* Adding low-g threshold */
+		data_array[1] = low_g_int->low_thres;
+		/* Adding low-g interrupt delay */
+		data_array[0] = low_g_int->low_dur;
+		/* Writing data to INT_LOWHIGH 0,1,2 registers simultaneously*/
+		rslt = bmi160_set_regs(BMI160_INT_LOWHIGH_0_ADDR, data_array, 3, dev);
+	}
+
+	return rslt;
 }
 
- /*!
- *	@brief This function is used to read the compensated value of
- *	AKM09912 sensor
- *	@note Before start reading the Mag compensated data's
- *	make sure the following two points are addressed
- *	@note	1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note	2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode by using the function
- *		bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_akm09912_compensate_xyz(
-struct bmi160_bst_akm_xyz_t *bst_akm_xyz)
+/*!
+ * @brief This API enables the high-g interrupt.
+ */
+static int8_t enable_high_g_int(const struct bmi160_acc_high_g_int_cfg *high_g_int_cfg, const struct bmi160_dev *dev)
 {
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	struct bmi160_mag_t mag_xyz;
+	int8_t rslt;
+	uint8_t data = 0;
+	uint8_t temp = 0;
 
-	com_rslt = bmi160_read_mag_xyz(&mag_xyz, BST_AKM);
-	/* Compensation for X axis */
-	bst_akm_xyz->x = bmi160_bst_akm09912_compensate_X(mag_xyz.x);
+	/* Enable low-g interrupt in Int Enable 1 register */
+	rslt = bmi160_get_regs(BMI160_INT_ENABLE_1_ADDR, &data, 1, dev);
 
-	/* Compensation for Y axis */
-	bst_akm_xyz->y = bmi160_bst_akm09912_compensate_Y(mag_xyz.y);
+	if (rslt == BMI160_OK) {
 
-	/* Compensation for Z axis */
-	bst_akm_xyz->z = bmi160_bst_akm09912_compensate_Z(mag_xyz.z);
+		/* Adding high-g X-axis */
+		temp = data & ~BMI160_HIGH_G_X_INT_EN_MASK;
+		data = temp | (high_g_int_cfg->high_g_x & BMI160_HIGH_G_X_INT_EN_MASK);
 
-	return com_rslt;
+		/* Adding high-g Y-axis */
+		temp = data & ~BMI160_HIGH_G_Y_INT_EN_MASK;
+		data = temp | ((high_g_int_cfg->high_g_y << 1) & BMI160_HIGH_G_Y_INT_EN_MASK);
+
+		/* Adding high-g Z-axis */
+		temp = data & ~BMI160_HIGH_G_Z_INT_EN_MASK;
+		data = temp | ((high_g_int_cfg->high_g_z << 2) & BMI160_HIGH_G_Z_INT_EN_MASK);
+
+		/* write data to Int Enable 0 register */
+		rslt = bmi160_set_regs(BMI160_INT_ENABLE_1_ADDR, &data, 1, dev);
+	}
+
+	return rslt;
 }
-#endif
-#ifdef AKM09911
-/***************************************************/
-/**\name	FUNCTIONS FOR AKM09911 */
-/***************************************************/
+
 /*!
- *	@brief This API is used to get the compensated X data
- *	of AKM09911 sensor
- *	Output of X is s32
- *	@note	Before start reading the Mag compensated X data
- *			make sure the following two points are addressed
- *	@note 1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note 2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode.
- *		by using the function bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
- *
- *  @param v_bst_akm_x_s16 : The value of X data
- *
- *	@return compensated X data value
- *
+ * @brief This API maps the INT pin to High-g interrupt.
  */
-s32 bmi160_bst_akm09911_compensate_X(s16 v_bst_akm_x_s16)
+static int8_t map_int_pin_to_high_g(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
 {
-	/*Return value of AKM x compensated v_data_u8*/
-	s32 retval = BMI160_INIT_VALUE;
-	/* Convert raw v_data_u8 into compensated v_data_u8*/
-	retval = (v_bst_akm_x_s16 *
-	((akm_asa_data.asax/AKM09911_SENSITIVITY_DIV) +
-	BMI160_GEN_READ_WRITE_DATA_LENGTH));
-	return retval;
+	int8_t rslt;
+	uint8_t data = 0;
+	uint8_t temp = 0;
+
+	/* Configure Map register to map interrupt pin to high-g interrupt*/
+	if (int_config->int_channel == BMI160_INT_CHANNEL_1) {
+		rslt = bmi160_get_regs(BMI160_INT_MAP_0_ADDR, &data, 1, dev);
+		if (rslt == BMI160_OK) {
+			temp = data & ~BMI160_INT1_HIGH_G_MASK;
+			data = temp | ((1 << 1) & BMI160_INT1_HIGH_G_MASK);
+			rslt = bmi160_set_regs(BMI160_INT_MAP_0_ADDR, &data, 1, dev);
+		}
+	} else {
+		rslt = bmi160_get_regs(BMI160_INT_MAP_2_ADDR, &data, 1, dev);
+		if (rslt == BMI160_OK) {
+			temp = data & ~BMI160_INT2_HIGH_G_MASK;
+			data = temp | ((1 << 1) & BMI160_INT2_HIGH_G_MASK);
+			rslt = bmi160_set_regs(BMI160_INT_MAP_2_ADDR, &data, 1, dev);
+		}
+	}
+
+	return rslt;
 }
+
 /*!
- *	@brief This API is used to get the compensated Y data
- *	of AKM09911 sensor
- *  Output of Y is s32
- *	@note	Before start reading the Mag compensated Y data
- *			make sure the following two points are addressed
- *	@note 1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note 2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode.
- *		by using the function bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
- *
- *  @param v_bst_akm_y_s16 : The value of Y data
- *
- *	@return compensated Y data value
- *
+ * @brief This API configure the source of data(filter & pre-filter)
+ * for high-g interrupt.
  */
-s32 bmi160_bst_akm09911_compensate_Y(s16 v_bst_akm_y_s16)
+static int8_t config_high_g_data_src(const struct bmi160_acc_high_g_int_cfg *high_g_int_cfg,
+					const struct bmi160_dev *dev)
 {
-	/*Return value of AKM y compensated v_data_u8*/
-	s32 retval = BMI160_INIT_VALUE;
-	/* Convert raw v_data_u8 into compensated v_data_u8*/
-	retval = (v_bst_akm_y_s16 *
-	((akm_asa_data.asay/AKM09911_SENSITIVITY_DIV) +
-	BMI160_GEN_READ_WRITE_DATA_LENGTH));
-	return retval;
+	int8_t rslt;
+	uint8_t data = 0;
+	uint8_t temp = 0;
+
+	/* Configure Int data 0 register to add source of interrupt */
+	rslt = bmi160_get_regs(BMI160_INT_DATA_0_ADDR, &data, 1, dev);
+	if (rslt == BMI160_OK) {
+		temp = data & ~BMI160_LOW_HIGH_SRC_INT_MASK;
+		data = temp | ((high_g_int_cfg->high_data_src << 7) & BMI160_LOW_HIGH_SRC_INT_MASK);
+		/* Write data to Data 0 address */
+		rslt = bmi160_set_regs(BMI160_INT_DATA_0_ADDR, &data, 1, dev);
+	}
+
+	return rslt;
 }
+
 /*!
- *	@brief This API is used to get the compensated Z data
- *	of AKM09911 sensor
- *  Out put of Z is s32
- *	@note	Before start reading the Mag compensated Z data
- *			make sure the following two points are addressed
- *	@note 1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note 2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode.
- *		by using the function bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
- *
- *  @param v_bst_akm_z_s16 : The value of Z data
- *
- *	@return compensated Z data value
- *
+ * @brief This API configure the necessary setting of high-g interrupt.
  */
-s32 bmi160_bst_akm09911_compensate_Z(s16 v_bst_akm_z_s16)
+static int8_t config_high_g_int_settg(const struct bmi160_acc_high_g_int_cfg *high_g_int_cfg,
+					const struct bmi160_dev *dev)
 {
-	/*Return value of AKM z compensated v_data_u8*/
-	s32 retval = BMI160_INIT_VALUE;
-	/* Convert raw v_data_u8 into compensated v_data_u8*/
-	retval = (v_bst_akm_z_s16 *
-	((akm_asa_data.asaz/AKM09911_SENSITIVITY_DIV) +
-	BMI160_GEN_READ_WRITE_DATA_LENGTH));
-	return retval;
+	int8_t rslt;
+	uint8_t temp = 0;
+	uint8_t data_array[3] = {0, 0, 0};
+
+	rslt = bmi160_get_regs(BMI160_INT_LOWHIGH_2_ADDR, &data_array[0], 1, dev);
+	if (rslt == BMI160_OK) {
+		temp = data_array[0] & ~BMI160_HIGH_G_HYST_MASK;
+		/* Adding high-g hysteresis */
+		data_array[0] = temp | ((high_g_int_cfg->high_hy << 6) & BMI160_HIGH_G_HYST_MASK);
+		/* Adding high-g duration */
+		data_array[1] = high_g_int_cfg->high_dur;
+		/* Adding high-g threshold */
+		data_array[2] = high_g_int_cfg->high_thres;
+		rslt = bmi160_set_regs(BMI160_INT_LOWHIGH_2_ADDR, data_array, 3, dev);
+	}
+
+	return rslt;
 }
- /*!
- *	@brief This function is used to read the compensated value of
- *	AKM09911
- *	@note Before start reading the Mag compensated data's
- *	make sure the following two points are addressed
- *	@note	1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note	2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode by using the function
- *		bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_akm09911_compensate_xyz(
-struct bmi160_bst_akm_xyz_t *bst_akm_xyz)
+
+/*!
+ * @brief This API configure the behavioural setting of interrupt pin.
+ */
+static int8_t config_int_out_ctrl(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
 {
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	struct bmi160_mag_t mag_xyz;
+	int8_t rslt;
+	uint8_t temp = 0;
+	uint8_t data = 0;
 
-	com_rslt = bmi160_read_mag_xyz(&mag_xyz, BST_AKM);
-	/* Compensation for X axis */
-	bst_akm_xyz->x = bmi160_bst_akm09911_compensate_X(mag_xyz.x);
+	/* Configuration of output interrupt signals on pins INT1 and INT2 are
+	 * done in BMI160_INT_OUT_CTRL_ADDR register*/
+	rslt = bmi160_get_regs(BMI160_INT_OUT_CTRL_ADDR, &data, 1, dev);
 
-	/* Compensation for Y axis */
-	bst_akm_xyz->y = bmi160_bst_akm09911_compensate_Y(mag_xyz.y);
+	if (rslt == BMI160_OK) {
+		/* updating the interrupt pin structure to local structure */
+		const struct bmi160_int_pin_settg *intr_pin_sett = &(int_config->int_pin_settg);
 
-	/* Compensation for Z axis */
-	bst_akm_xyz->z = bmi160_bst_akm09911_compensate_Z(mag_xyz.z);
+		/* Configuring channel 1 */
+		if (int_config->int_channel == BMI160_INT_CHANNEL_1) {
 
-	return com_rslt;
-}
+			/* Output enable */
+			temp = data & ~BMI160_INT1_OUTPUT_EN_MASK;
+			data = temp | ((intr_pin_sett->output_en << 3) & BMI160_INT1_OUTPUT_EN_MASK);
 
-#endif
+			/* Output mode */
+			temp = data & ~BMI160_INT1_OUTPUT_MODE_MASK;
+			data = temp | ((intr_pin_sett->output_mode << 2) & BMI160_INT1_OUTPUT_MODE_MASK);
 
-#if defined AKM09911 || defined AKM09912
-/***************************************************/
-/**\name	FUNCTIONS FOR AKM09911 and AKM09912 */
-/***************************************************/
-/*!
- *	@brief This function is used to initialize
- *	the AKM09911 and AKM09912 sensor
- *
- *
- *	@param v_akm_i2c_address_u8: The value of device address
- *	AKM sensor   |  Slave address
- * --------------|---------------------
- *  AKM09911     |  AKM09911_I2C_ADDR_1
- *     -         |  and AKM09911_I2C_ADDR_2
- *  AKM09912     |  AKM09912_I2C_ADDR_1
- *     -         |  AKM09912_I2C_ADDR_2
- *     -         |  AKM09912_I2C_ADDR_3
- *     -         |  AKM09912_I2C_ADDR_4
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_akm_mag_interface_init(
-u8 v_akm_i2c_address_u8)
-{
-	/* variable used to 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_akm_chip_id_u8 = BMI160_INIT_VALUE;
-	u8 v_accel_power_mode_status = BMI160_INIT_VALUE;
-
-	com_rslt = bmi160_get_accel_power_mode_stat(
-		&v_accel_power_mode_status);
-	/* set Accel operation mode to normal*/
-	if (v_accel_power_mode_status != BMI160_ACCEL_NORMAL_MODE) {
-		com_rslt += bmi160_set_command_register(ACCEL_MODE_NORMAL);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	}
-	com_rslt += bmi160_set_command_register(MAG_MODE_NORMAL);
-	p_bmi160->delay_msec(BMI160_AKM_INIT_DELAY);
-	bmi160_get_mag_power_mode_stat(&v_data_u8);
-	/* Write the AKM09911 0r AKM09912 i2c address*/
-	com_rslt += bmi160_set_i2c_device_addr(v_akm_i2c_address_u8);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* enable the Mag interface to manual mode*/
-	com_rslt += bmi160_set_mag_manual_enable(BMI160_MANUAL_ENABLE);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	bmi160_get_mag_manual_enable(&v_data_u8);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/*Enable the MAG interface */
-	com_rslt += bmi160_set_if_mode(BMI160_ENABLE_MAG_IF_MODE);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	bmi160_get_if_mode(&v_data_u8);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-
-	/* Set the AKM Fuse ROM mode */
-	com_rslt += bmi160_set_mag_write_data(AKM_FUSE_ROM_MODE);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* AKM mode address is 0x31*/
-	com_rslt += bmi160_set_mag_write_addr(AKM_POWER_MODE_REG);
-	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-	/* Read the Fuse ROM v_data_u8 from registers
-	0x60,0x61 and 0x62*/
-	/* ASAX v_data_u8 */
-	com_rslt += bmi160_read_bst_akm_sensitivity_data();
-	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-	/* read the device id of the AKM sensor
-	if device id is 0x05 - AKM09911
-	if device id is 0x04 - AKM09912*/
-	com_rslt += bmi160_set_mag_read_addr(AKM_CHIP_ID_REG);
-	/* 0x04 is mag_x LSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_akm_chip_id_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	/* Set power down mode*/
-	com_rslt += bmi160_set_mag_write_data(AKM_POWER_DOWN_MODE_DATA);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* AKM mode address is 0x31*/
-	com_rslt += bmi160_set_mag_write_addr(AKM_POWER_MODE_REG);
-	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-	/* Set AKM Force mode*/
-	com_rslt += bmi160_set_mag_write_data(
-	AKM_SINGLE_MEASUREMENT_MODE);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* AKM mode address is 0x31*/
-	com_rslt += bmi160_set_mag_write_addr(AKM_POWER_MODE_REG);
-	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-	/* Set the AKM read xyz v_data_u8 address*/
-	com_rslt += bmi160_set_mag_read_addr(AKM_DATA_REGISTER);
-	/* write the Mag v_data_bw_u8 as 25Hz*/
-	com_rslt += bmi160_set_mag_output_data_rate(
-	BMI160_MAG_OUTPUT_DATA_RATE_25HZ);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* Enable Mag interface to auto mode*/
-	com_rslt += bmi160_set_mag_manual_enable(BMI160_MANUAL_DISABLE);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	bmi160_get_mag_manual_enable(&v_data_u8);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		switch (v_accel_power_mode_status) {
-
-		case BMI160_ACCEL_SUSPEND:
-			com_rslt += bmi160_set_command_register(ACCEL_SUSPEND);
-			p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-			break;
+			/* Output type */
+			temp = data & ~BMI160_INT1_OUTPUT_TYPE_MASK;
+			data = temp | ((intr_pin_sett->output_type << 1) & BMI160_INT1_OUTPUT_TYPE_MASK);
 
-		case BMI160_ACCEL_LOW_POWER:
-			com_rslt += bmi160_set_command_register(ACCEL_LOWPOWER);
-			p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-			break;
+			/* edge control */
+			temp = data & ~BMI160_INT1_EDGE_CTRL_MASK;
+			data = temp | ((intr_pin_sett->edge_ctrl) & BMI160_INT1_EDGE_CTRL_MASK);
 
-		default:
-			break;
+		} else {
+			/* Configuring channel 2 */
+			/* Output enable */
+			temp = data & ~BMI160_INT2_OUTPUT_EN_MASK;
+			data = temp | ((intr_pin_sett->output_en << 7) & BMI160_INT2_OUTPUT_EN_MASK);
+
+			/* Output mode */
+			temp = data & ~BMI160_INT2_OUTPUT_MODE_MASK;
+			data = temp | ((intr_pin_sett->output_mode << 6) & BMI160_INT2_OUTPUT_MODE_MASK);
+
+			/* Output type */
+			temp = data & ~BMI160_INT2_OUTPUT_TYPE_MASK;
+			data = temp | ((intr_pin_sett->output_type << 5) & BMI160_INT2_OUTPUT_TYPE_MASK);
+
+			/* edge control */
+			temp = data & ~BMI160_INT2_EDGE_CTRL_MASK;
+			data = temp | ((intr_pin_sett->edge_ctrl << 4) & BMI160_INT2_EDGE_CTRL_MASK);
+		}
+
+		rslt = bmi160_set_regs(BMI160_INT_OUT_CTRL_ADDR, &data, 1, dev);
 	}
-	return com_rslt;
+
+	return rslt;
 }
+
 /*!
- *	@brief This function is used to read the sensitivity data of
- *	AKM09911 and AKM09912
- *
- *	@note Before reading the Mag sensitivity values
- *	make sure the following two points are addressed
- *	@note	1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note	2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode by using the function
- *		bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_bst_akm_sensitivity_data(void)
+ * @brief This API configure the mode(input enable, latch or non-latch) of interrupt pin.
+ */
+static int8_t config_int_latch(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
 {
-	/* This variable is used to provide the communication
-	results*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* Array holding the sensitivity ax,ay and az data*/
-	u8 v_data_u8[BMI160_AKM_SENSITIVITY_DATA_SIZE] = {
-	BMI160_INIT_VALUE,
-	BMI160_INIT_VALUE, BMI160_INIT_VALUE};
-	/* read asax value */
-	com_rslt = bmi160_set_mag_read_addr(BMI160_BST_AKM_ASAX);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* 0x04 is secondary read Mag x LSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[AKM_ASAX],
-	BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	akm_asa_data.asax = v_data_u8[AKM_ASAX];
-	/* read asay value */
-	com_rslt += bmi160_set_mag_read_addr(BMI160_BST_AKM_ASAY);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* 0x04 is secondary read Mag x LSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[AKM_ASAY],
-	BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	akm_asa_data.asay = v_data_u8[AKM_ASAY];
-	/* read asaz value */
-	com_rslt += bmi160_set_mag_read_addr(BMI160_BST_AKM_ASAZ);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* 0x04 is secondary read Mag x LSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[AKM_ASAZ],
-	BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	akm_asa_data.asaz = v_data_u8[AKM_ASAZ];
-
-	return com_rslt;
+	int8_t rslt;
+	uint8_t temp = 0;
+	uint8_t data = 0;
+
+	/* Configuration of latch on pins INT1 and INT2 are done in
+	 * BMI160_INT_LATCH_ADDR register*/
+	rslt = bmi160_get_regs(BMI160_INT_LATCH_ADDR, &data, 1, dev);
+
+	if (rslt == BMI160_OK) {
+		/* updating the interrupt pin structure to local structure */
+		const struct bmi160_int_pin_settg *intr_pin_sett = &(int_config->int_pin_settg);
+
+		if (int_config->int_channel == BMI160_INT_CHANNEL_1) {
+			/* Configuring channel 1 */
+			/* Input enable */
+			temp = data & ~BMI160_INT1_INPUT_EN_MASK;
+			data = temp | ((intr_pin_sett->input_en << 4) & BMI160_INT1_INPUT_EN_MASK);
+		} else {
+			/* Configuring channel 2 */
+			/* Input enable */
+			temp = data & ~BMI160_INT2_INPUT_EN_MASK;
+			data = temp | ((intr_pin_sett->input_en << 5) & BMI160_INT2_INPUT_EN_MASK);
+		}
+
+		/* In case of latch interrupt,update the latch duration */
+		/* Latching holds the interrupt for the amount of latch
+		 * duration time */
+		temp = data & ~BMI160_INT_LATCH_MASK;
+		data = temp | (intr_pin_sett->latch_dur & BMI160_INT_LATCH_MASK);
+
+		/* OUT_CTRL_INT and LATCH_INT address lie consecutively,
+		 * hence writing data to respective registers at one go */
+		rslt = bmi160_set_regs(BMI160_INT_LATCH_ADDR, &data, 1, dev);
+	}
+	return rslt;
 }
+
 /*!
- *	@brief This function is used to set the AKM09911 and AKM09912
- *	power mode.
- *	@note Before setting the AKM power mode
- *	make sure the following two points are addressed
- *	@note	1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled then set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note	2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode.
- *		by using the function bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
- *	@param v_akm_pow_mode_u8 : The value of akm power mode
- *  value   |    Description
- * ---------|--------------------
- *    0     |  AKM_POWER_DOWN_MODE
- *    1     |  AKM_SINGLE_MEAS_MODE
- *    2     |  FUSE_ROM_MODE
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_akm_set_powermode(
-u8 v_akm_pow_mode_u8)
-{
-	/* variable is used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* set Mag interface manual mode*/
-	if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE) {
-		com_rslt = bmi160_set_mag_manual_enable(
-		BMI160_MANUAL_ENABLE);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	}
-	switch (v_akm_pow_mode_u8) {
-	case AKM_POWER_DOWN_MODE:
-		/* Set the power mode of AKM as power down mode*/
-		com_rslt += bmi160_set_mag_write_data(
-		AKM_POWER_DOWN_MODE_DATA);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		com_rslt += bmi160_set_mag_write_addr(
-		AKM_POWER_MODE_REG);
-		p_bmi160->delay_msec(
-		BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-	break;
-	case AKM_SINGLE_MEAS_MODE:
-		/* Set the power mode of AKM as
-		single measurement mode*/
-		com_rslt += bmi160_set_mag_write_data
-		(AKM_SINGLE_MEASUREMENT_MODE);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		com_rslt += bmi160_set_mag_write_addr(
-		AKM_POWER_MODE_REG);
-		p_bmi160->delay_msec(
-		BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-		com_rslt += bmi160_set_mag_read_addr(AKM_DATA_REGISTER);
-	break;
-	case FUSE_ROM_MODE:
-		/* Set the power mode of AKM as
-		Fuse ROM mode*/
-		com_rslt += bmi160_set_mag_write_data(
-		AKM_FUSE_ROM_MODE);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		com_rslt += bmi160_set_mag_write_addr(
-		AKM_POWER_MODE_REG);
-		p_bmi160->delay_msec(
-		BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-		/* Sensitivity v_data_u8 */
-		com_rslt += bmi160_read_bst_akm_sensitivity_data();
-		p_bmi160->delay_msec(
-		BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-		/* power down mode*/
-		com_rslt += bmi160_set_mag_write_data(
-		AKM_POWER_DOWN_MODE);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		com_rslt += bmi160_set_mag_write_addr(
-		AKM_POWER_MODE_REG);
-		p_bmi160->delay_msec(
-		BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-	break;
-	default:
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-	break;
-	}
-	/* set Mag interface auto mode*/
-	if (p_bmi160->mag_manual_enable == BMI160_MANUAL_ENABLE) {
-		com_rslt += bmi160_set_mag_manual_enable(
-		BMI160_MANUAL_DISABLE);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+ * @brief This API performs the self test for accelerometer of BMI160
+ */
+static int8_t perform_accel_self_test(struct bmi160_dev *dev)
+{
+	int8_t rslt;
+	struct bmi160_sensor_data accel_pos, accel_neg;
+
+	/* Enable Gyro self test bit */
+	rslt = enable_accel_self_test(dev);
+	if (rslt == BMI160_OK) {
+		/* Perform accel self test with positive excitation */
+		rslt = accel_self_test_positive_excitation(&accel_pos, dev);
+		if (rslt == BMI160_OK) {
+			/* Perform accel self test with negative excitation */
+			rslt = accel_self_test_negative_excitation(&accel_neg, dev);
+			if (rslt == BMI160_OK) {
+				/* Validate the self test result */
+				rslt = validate_accel_self_test(&accel_pos, &accel_neg);
+			}
+		}
 	}
-	return com_rslt;
+
+	return rslt;
 }
- /*!
- *	@brief This function is used to set the Mag
- *	power mode of AKM09911 and AKM09912
- *	@note Before setting the Mag power mode
- *	make sure the following two points are addressed
- *		Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled then set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *
- *	@param v_mag_sec_if_pow_mode_u8 : The value of secondary if power mode
- *  value   |    Description
- * ---------|--------------------
- *    0     |  BMI160_MAG_FORCE_MODE
- *    1     |  BMI160_MAG_SUSPEND_MODE
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE
-bmi160_set_bst_akm_and_secondary_if_powermode(
-u8 v_mag_sec_if_pow_mode_u8)
-{
-	u8 v_accel_power_mode_status = BMI160_INIT_VALUE;
-	/* variable used to return the status of communication result*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
 
-	com_rslt = bmi160_get_accel_power_mode_stat(
-		&v_accel_power_mode_status);
+/*!
+ * @brief This API enables to perform the accel self test by setting proper
+ * configurations to facilitate accel self test
+ */
+static int8_t enable_accel_self_test(struct bmi160_dev *dev)
+{
+	int8_t rslt;
+	uint8_t reg_data;
 
-	/* Accel operation mode to normal*/
-	if (v_accel_power_mode_status != BMI160_ACCEL_NORMAL_MODE) {
-		com_rslt += bmi160_set_command_register(ACCEL_MODE_NORMAL);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	}
-	/* set Mag interface manual mode*/
-	if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE) {
-		com_rslt += bmi160_set_mag_manual_enable(
-		BMI160_MANUAL_ENABLE);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	}
-	switch (v_mag_sec_if_pow_mode_u8) {
-	case BMI160_MAG_FORCE_MODE:
-		/* set the secondary Mag power mode as NORMAL*/
-		com_rslt += bmi160_set_mag_interface_normal();
-		/* set the akm power mode as single measurement mode*/
-		com_rslt += bmi160_bst_akm_set_powermode(
-		AKM_SINGLE_MEAS_MODE);
-		p_bmi160->delay_msec(
-		BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-		com_rslt += bmi160_set_mag_read_addr(AKM_DATA_REGISTER);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	break;
-	case BMI160_MAG_SUSPEND_MODE:
-		/* set the akm power mode as power down mode*/
-		com_rslt += bmi160_bst_akm_set_powermode(
-		AKM_POWER_DOWN_MODE);
-		p_bmi160->delay_msec(
-		BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-		/* set the secondary Mag power mode as SUSPEND*/
-		com_rslt += bmi160_set_command_register(
-		MAG_MODE_SUSPEND);
-		p_bmi160->delay_msec(
-		BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-	break;
-	default:
-		com_rslt = E_BMI160_OUT_OF_RANGE;
-	break;
+	/* Set the Accel power mode as normal mode */
+	dev->accel_cfg.power = BMI160_ACCEL_NORMAL_MODE;
+	/* Set the sensor range configuration as 8G */
+	dev->accel_cfg.range = BMI160_ACCEL_RANGE_8G;
+	rslt = bmi160_set_sens_conf(dev);
+	if (rslt == BMI160_OK) {
+		/* Accel configurations are set to facilitate self test
+		 * acc_odr - 1600Hz ; acc_bwp = 2 ; acc_us = 0 */
+		reg_data = BMI160_ACCEL_SELF_TEST_CONFIG;
+		rslt = bmi160_set_regs(BMI160_ACCEL_CONFIG_ADDR, &reg_data, 1, dev);
 	}
-	/* set Mag interface auto mode*/
-	if (p_bmi160->mag_manual_enable == BMI160_MANUAL_ENABLE)
-		com_rslt += bmi160_set_mag_manual_enable(
-		BMI160_MANUAL_DISABLE);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	switch (v_accel_power_mode_status) {
-
-	case BMI160_ACCEL_SUSPEND:
-		com_rslt += bmi160_set_command_register(ACCEL_SUSPEND);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		break;
 
-	case BMI160_ACCEL_LOW_POWER:
-		com_rslt += bmi160_set_command_register(ACCEL_LOWPOWER);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		break;
+	return rslt;
+}
 
-	default:
-		break;
+/*!
+ * @brief This API performs accel self test with positive excitation
+ */
+static int8_t accel_self_test_positive_excitation(struct bmi160_sensor_data *accel_pos, const struct bmi160_dev *dev)
+{
+	int8_t rslt;
+	uint8_t reg_data;
+
+	/* Enable accel self test with positive self-test excitation
+	   and with amplitude of deflection set as high */
+	reg_data = BMI160_ACCEL_SELF_TEST_POSITIVE_EN;
+	rslt = bmi160_set_regs(BMI160_SELF_TEST_ADDR, &reg_data, 1, dev);
+	if (rslt == BMI160_OK) {
+		/* Read the data after a delay of 50ms */
+		dev->delay_ms(BMI160_ACCEL_SELF_TEST_DELAY);
+		rslt = bmi160_get_sensor_data(BMI160_ACCEL_ONLY, accel_pos, NULL, dev);
 	}
-	return com_rslt;
+
+	return rslt;
 }
-#endif
-#ifdef YAS532
-/***************************************************/
-/**\name	FUNCTIONS FOR YAMAHA-YAS532 */
-/***************************************************/
+
 /*!
- *	@brief This function is used to initialize the YAMAHA-YAS532 sensor
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas532_mag_interface_init(
-void)
+ * @brief This API performs accel self test with negative excitation
+ */
+static int8_t accel_self_test_negative_excitation(struct bmi160_sensor_data *accel_neg, const struct bmi160_dev *dev)
 {
-	/* This variable used to provide the communication
-	results*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	u8 v_data_u8 = BMI160_INIT_VALUE;
-	u8 i = BMI160_INIT_VALUE;
-	u8 v_accel_power_mode_status = BMI160_INIT_VALUE;
-
-	com_rslt = bmi160_get_accel_power_mode_stat(
-		&v_accel_power_mode_status);
-	/* Accel operation mode to normal*/
-	if (v_accel_power_mode_status != BMI160_ACCEL_NORMAL_MODE) {
-		com_rslt += bmi160_set_command_register(ACCEL_MODE_NORMAL);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	}
-	/* write Mag power mode as NORMAL*/
-	com_rslt += bmi160_set_mag_interface_normal();
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* Write the YAS532 i2c address*/
-	com_rslt += bmi160_set_i2c_device_addr(BMI160_AUX_YAS532_I2C_ADDRESS);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* enable the Mag interface to manual mode*/
-	com_rslt += bmi160_set_mag_manual_enable(BMI160_MANUAL_ENABLE);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	bmi160_get_mag_manual_enable(&v_data_u8);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/*Enable the MAG interface */
-	com_rslt += bmi160_set_if_mode(BMI160_ENABLE_MAG_IF_MODE);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	bmi160_get_if_mode(&v_data_u8);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	v_data_u8 = BMI160_MANUAL_DISABLE;
-	/* Read the YAS532 device id is 0x02*/
-	com_rslt += bmi160_set_mag_read_addr(BMI160_YAS_DEVICE_ID_REG);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* Read the YAS532 calibration data*/
-	com_rslt += bmi160_bst_yamaha_yas532_calib_values();
-	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-	/* Assign the data acquisition mode*/
-	yas532_data.measure_state = YAS532_MAG_STATE_INIT_COIL;
-	/* Set the default offset as invalid offset*/
-	set_vector(yas532_data.v_hard_offset_s8, INVALID_OFFSET);
-	/* set the transform to zero */
-
-	yas532_data.transform = BMI160_NULL;
-	/* Assign overflow as zero*/
-	yas532_data.overflow = 0;
-	#if 1 < YAS532_MAG_TEMPERATURE_LOG
-		yas532_data.temp_data.num =
-		yas532_data.temp_data.idx = 0;
-	#endif
-	/* Assign the coefficient value*/
-	for (i = 0; i < 3; i++) {
-		yas532_data.coef[i] = yas532_version_ac_coef[i];
-		yas532_data.last_raw[i] = 0;
-	}
-	yas532_data.last_raw[3] = 0;
-	/* Set the initial values of yas532*/
-	com_rslt += bmi160_bst_yas532_set_initial_values();
-	/* write the Mag v_data_bw_u8 as 25Hz*/
-	com_rslt += bmi160_set_mag_output_data_rate(
-	BMI160_MAG_OUTPUT_DATA_RATE_25HZ);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* Enable Mag interface to auto mode*/
-	com_rslt += bmi160_set_mag_manual_enable(
-	BMI160_MANUAL_DISABLE);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	bmi160_get_mag_manual_enable(&v_data_u8);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		switch (v_accel_power_mode_status) {
-
-		case BMI160_ACCEL_SUSPEND:
-			com_rslt += bmi160_set_command_register(ACCEL_SUSPEND);
-			p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-			break;
+	int8_t rslt;
+	uint8_t reg_data;
 
-		case BMI160_ACCEL_LOW_POWER:
-			com_rslt += bmi160_set_command_register(ACCEL_LOWPOWER);
-			p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-			break;
-		default:
-			break;
+	/* Enable accel self test with negative self-test excitation
+	   and with amplitude of deflection set as high */
+	reg_data = BMI160_ACCEL_SELF_TEST_NEGATIVE_EN;
+	rslt = bmi160_set_regs(BMI160_SELF_TEST_ADDR, &reg_data, 1, dev);
+	if (rslt == BMI160_OK) {
+		/* Read the data after a delay of 50ms */
+		dev->delay_ms(BMI160_ACCEL_SELF_TEST_DELAY);
+		rslt = bmi160_get_sensor_data(BMI160_ACCEL_ONLY, accel_neg, NULL, dev);
 	}
 
-	return com_rslt;
+	return rslt;
 }
+
 /*!
- *	@brief This function used to set the YAS532 initial values
- *
- *
-  *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
+ * @brief This API validates the accel self test results
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_set_initial_values(void)
+static int8_t validate_accel_self_test(const struct bmi160_sensor_data *accel_pos,
+					const struct bmi160_sensor_data *accel_neg)
 {
-/* This variable is used to provide the communication
-	results*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* write testr1 as 0x00*/
-	com_rslt = bmi160_set_mag_write_data(
-	BMI160_YAS532_WRITE_TESTR1);
-	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-	com_rslt += bmi160_set_mag_write_addr(BMI160_YAS532_TESTR1);
-	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-	/* write testr2 as 0x00*/
-	com_rslt += bmi160_set_mag_write_data(
-	BMI160_YAS532_WRITE_TESTR2);
-	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-	com_rslt += bmi160_set_mag_write_addr(BMI160_YAS532_TESTR2);
-	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-	/* write Rcoil as 0x00*/
-	com_rslt += bmi160_set_mag_write_data(
-	BMI160_YAS532_WRITE_RCOIL);
-	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-	com_rslt += bmi160_set_mag_write_addr(BMI160_YAS532_RCOIL);
-	p_bmi160->delay_msec(BMI160_YAS532_SET_INITIAL_VALUE_DELAY);
-	/* check the valid offset*/
-	if (is_valid_offset(yas532_data.v_hard_offset_s8)) {
-		com_rslt += bmi160_bst_yas532_set_offset(
-		yas532_data.v_hard_offset_s8);
-		yas532_data.measure_state = YAS532_MAG_STATE_NORMAL;
+	int8_t rslt;
+
+	/* Validate the results of self test */
+	if (((accel_neg->x - accel_pos->x) > BMI160_ACCEL_SELF_TEST_LIMIT)
+		&& ((accel_neg->y - accel_pos->y) > BMI160_ACCEL_SELF_TEST_LIMIT)
+		&& ((accel_neg->z - accel_pos->z) > BMI160_ACCEL_SELF_TEST_LIMIT)) {
+		/* Self test pass condition */
+		rslt = BMI160_OK;
 	} else {
-		/* set the default offset as invalid offset*/
-		set_vector(yas532_data.v_hard_offset_s8, INVALID_OFFSET);
-		/*Set the default measure state for offset correction*/
-		yas532_data.measure_state = YAS532_MAG_STATE_MEASURE_OFFSET;
+		rslt = BMI160_W_ACCEl_SELF_TEST_FAIL;
 	}
-	return com_rslt;
+
+	return rslt;
 }
+
 /*!
- *	@brief This function is used to perform YAS532 offset correction
- *
- *
-  *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_magnetic_measure_set_offset(
-void)
+ * @brief This API performs the self test for gyroscope of BMI160
+ */
+static int8_t perform_gyro_self_test(const struct bmi160_dev *dev)
 {
-	/* This variable used to provide the communication
-	results*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* to set  the offset register*/
-	s8 v_hard_offset_s8[BMI160_HARD_OFFSET_DATA_SIZE] = {
-	BMI160_INIT_VALUE,
-	BMI160_INIT_VALUE, BMI160_INIT_VALUE};
-	/* offset correction factors*/
-	static const u8 v_correct_u8[BMI160_YAS_CORRECT_DATA_SIZE] = {
-	16, 8, 4, 2, 1};
-	/* used to store the temperature */
-	u16 v_temp_u16 = BMI160_INIT_VALUE;
-	/* used to read for the xy1y2 value */
-	u16 v_xy1y2_u16[BMI160_YAS_XY1Y2_DATA_SIZE] = {BMI160_INIT_VALUE,
-	BMI160_INIT_VALUE, BMI160_INIT_VALUE};
-	/* local flag for assigning the values*/
-	s32 v_flag_s32[BMI160_YAS_FLAG_DATA_SIZE] = {BMI160_INIT_VALUE,
-	BMI160_INIT_VALUE, BMI160_INIT_VALUE};
-	u8 i, j, v_busy_u8, v_overflow_u8 = BMI160_INIT_VALUE;
-
-	for (i = 0; i < 5; i++) {
-		/* set the offset values*/
-		com_rslt = bmi160_bst_yas532_set_offset(v_hard_offset_s8);
-		/* read the sensor data*/
-		com_rslt += bmi160_bst_yas532_normal_measurement_data(
-		BMI160_YAS532_ACQ_START, &v_busy_u8, &v_temp_u16,
-		v_xy1y2_u16, &v_overflow_u8);
-		/* check the sensor busy status*/
-		if (v_busy_u8)
-			return E_BMI160_BUSY;
-		/* calculate the magnetic correction with
-		offset and assign the values
-		to the offset register */
-		for (j = 0; j < 3; j++) {
-			if (YAS532_DATA_CENTER == v_xy1y2_u16[j])
-				v_flag_s32[j] = 0;
-			if (YAS532_DATA_CENTER < v_xy1y2_u16[j])
-				v_flag_s32[j] = 1;
-			if (v_xy1y2_u16[j] < YAS532_DATA_CENTER)
-				v_flag_s32[j] = -1;
-		}
-		for (j = 0; j < 3; j++) {
-			if (v_flag_s32[j])
-				v_hard_offset_s8[j] = (s8)(v_hard_offset_s8[j]
-				+ v_flag_s32[j] * v_correct_u8[i]);
-		}
+	int8_t rslt;
+
+	/* Enable Gyro self test bit */
+	rslt = enable_gyro_self_test(dev);
+	if (rslt == BMI160_OK) {
+		/* Validate the gyro self test results */
+		rslt = validate_gyro_self_test(dev);
 	}
-	/* set the offset */
-	com_rslt += bmi160_bst_yas532_set_offset(v_hard_offset_s8);
-	return com_rslt;
+
+	return rslt;
 }
+
 /*!
- *	@brief This function used to read the
- *	YAMAHA YAS532 calibration data
- *
- *
-  *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
+ * @brief This API enables the self test bit to trigger self test for Gyro
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas532_calib_values(void)
+static int8_t enable_gyro_self_test(const struct bmi160_dev *dev)
 {
-	/* This variable is used to provide the communication
-	results*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* Array holding the YAS532 calibration values */
-	u8 v_data_u8[BMI160_YAS532_CALIB_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,
-	BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE,
-	BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
-	/* Read the DX value */
-	com_rslt = bmi160_set_mag_read_addr(BMI160_YAS532_CALIB_CX);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	/* 0x04 is secondary read Mag x LSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[0], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	yas532_data.calib_yas532.cx = (s32)((v_data_u8[0]
-	* 10) - 1280);
-	/* Read the DY1 value */
-	com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB_CY1);
-	/* 0x04 is secondary read Mag x LSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[1], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	yas532_data.calib_yas532.cy1 =
-	(s32)((v_data_u8[1] * 10) - 1280);
-	/* Read the DY2 value */
-	com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB_CY2);
-	/* 0x04 is secondary read Mag x LSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[2], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	yas532_data.calib_yas532.cy2 =
-	(s32)((v_data_u8[2] * 10) - 1280);
-	/* Read the D2 and D3 value */
-	com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB1);
-	/* 0x04 is secondary read Mag x LSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[3], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	yas532_data.calib_yas532.a2 =
-	(s32)(((v_data_u8[3] >>
-	BMI160_SHIFT_BIT_POSITION_BY_02_BITS)
-	& 0x03F) - 32);
-	/* Read the D3 and D4 value */
-	com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB2);
-	/* 0x04 is secondary read Mag x LSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[4], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	/* calculate a3*/
-	yas532_data.calib_yas532.a3 = (s32)((((v_data_u8[3] <<
-	BMI160_SHIFT_BIT_POSITION_BY_02_BITS) & 0x0C) |
-	((v_data_u8[4]
-	>> BMI160_SHIFT_BIT_POSITION_BY_06_BITS)
-	& 0x03)) - 8);
-	/* calculate a4*/
-	yas532_data.calib_yas532.a4 = (s32)((v_data_u8[4]
-	& 0x3F) - 32);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-    /* Read the D5 and D6 value */
-	com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB3);
-	/* 0x04 is secondary read Mag x LSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[5], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	/* calculate a5*/
-	yas532_data.calib_yas532.a5 =
-	(s32)(((v_data_u8[5]
-	>> BMI160_SHIFT_BIT_POSITION_BY_02_BITS)
-	& 0x3F) + 38);
-	/* Read the D6 and D7 value */
-	com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB4);
-	/* 0x04 is secondary read Mag x LSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[6], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	/* calculate a6*/
-	yas532_data.calib_yas532.a6 =
-	(s32)((((v_data_u8[5]
-	<< BMI160_SHIFT_BIT_POSITION_BY_04_BITS)
-	& 0x30) | ((v_data_u8[6] >>
-	 BMI160_SHIFT_BIT_POSITION_BY_04_BITS)
-	 & 0x0F)) - 32);
-	 /* Read the D7 and D8 value */
-	com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB5);
-	/* 0x04 is secondary read Mag x LSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[7], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	/* calculate a7*/
-	yas532_data.calib_yas532.a7 = (s32)((((v_data_u8[6]
-	<< BMI160_SHIFT_BIT_POSITION_BY_03_BITS)
-	& 0x78) |
-	((v_data_u8[7]
-	>> BMI160_SHIFT_BIT_POSITION_BY_05_BITS) &
-	0x07)) - 64);
-	/* Read the D8 and D9 value */
-	com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB6);
-	/* 0x04 is secondary read Mag x LSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[8], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	/* calculate a8*/
-	yas532_data.calib_yas532.a8 = (s32)((((v_data_u8[7] <<
-	BMI160_GEN_READ_WRITE_DATA_LENGTH) & 0x3E) |
-	((v_data_u8[8] >>
-	BMI160_SHIFT_BIT_POSITION_BY_07_BITS) & 0x01)) -
-	32);
-
-	/* Read the D8 and D9 value */
-	com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB7);
-	/* 0x04 is secondary read Mag x LSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[9], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	/* calculate a9*/
-	yas532_data.calib_yas532.a9 = (s32)(((v_data_u8[8] <<
-	BMI160_GEN_READ_WRITE_DATA_LENGTH) & 0xFE) |
-	 ((v_data_u8[9] >>
-	 BMI160_SHIFT_BIT_POSITION_BY_07_BITS) & 0x01));
-	/* calculate k*/
-	yas532_data.calib_yas532.k = (s32)((v_data_u8[9] >>
-	BMI160_SHIFT_BIT_POSITION_BY_02_BITS) & 0x1F);
-	/* Read the  value from register 0x9A*/
-	com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB8);
-	/* 0x04 is secondary read Mag x LSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[10],
-	BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	/* Read the  value from register 0x9B*/
-	com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB9);
-	/* 0x04 is secondary read Mag x LSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[11],
-	BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	/* Read the  value from register 0x9C*/
-	com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB10);
-	/* 0x04 is secondary read Mag x LSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[12],
-	BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	/* Read the  value from register 0x9D*/
-	com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB11);
-	/* 0x04 is secondary read Mag x LSB register */
-	com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-	&v_data_u8[13],
-	BMI160_GEN_READ_WRITE_DATA_LENGTH);
-	/* Calculate the fxy1y2 and rxy1y1*/
-	yas532_data.calib_yas532.fxy1y2[0] =
-	(u8)(((v_data_u8[10]
-	& 0x01)
-	<< BMI160_SHIFT_BIT_POSITION_BY_01_BIT)
-	| ((v_data_u8[11] >>
-	BMI160_SHIFT_BIT_POSITION_BY_07_BITS) & 0x01));
-	yas532_data.calib_yas532.rxy1y2[0] =
-	((s8)(((v_data_u8[10]
-	>> BMI160_SHIFT_BIT_POSITION_BY_01_BIT) & 0x3F)
-	<< BMI160_SHIFT_BIT_POSITION_BY_02_BITS))
-	>> BMI160_SHIFT_BIT_POSITION_BY_02_BITS;
-	yas532_data.calib_yas532.fxy1y2[1] =
-	(u8)(((v_data_u8[11] & 0x01)
-	<< BMI160_SHIFT_BIT_POSITION_BY_01_BIT)
-	 | ((v_data_u8[12] >>
-	 BMI160_SHIFT_BIT_POSITION_BY_07_BITS) & 0x01));
-	yas532_data.calib_yas532.rxy1y2[1] =
-	((s8)(((v_data_u8[11]
-	>> BMI160_SHIFT_BIT_POSITION_BY_01_BIT) & 0x3F)
-	<< BMI160_SHIFT_BIT_POSITION_BY_02_BITS))
-	>> BMI160_SHIFT_BIT_POSITION_BY_02_BITS;
-	yas532_data.calib_yas532.fxy1y2[2] =
-	(u8)(((v_data_u8[12] & 0x01)
-	<< BMI160_SHIFT_BIT_POSITION_BY_01_BIT)
-	| ((v_data_u8[13]
-	>> BMI160_SHIFT_BIT_POSITION_BY_07_BITS) & 0x01));
-	yas532_data.calib_yas532.rxy1y2[2] =
-	((s8)(((v_data_u8[12]
-	>> BMI160_SHIFT_BIT_POSITION_BY_01_BIT) & 0x3F)
-	 << BMI160_SHIFT_BIT_POSITION_BY_02_BITS))
-	 >> BMI160_SHIFT_BIT_POSITION_BY_02_BITS;
-
-	return com_rslt;
+	int8_t rslt;
+	uint8_t reg_data;
+
+	/* Enable the Gyro self test bit to trigger the self test */
+	rslt = bmi160_get_regs(BMI160_SELF_TEST_ADDR, &reg_data, 1, dev);
+	if (rslt == BMI160_OK) {
+		reg_data = BMI160_SET_BITS(reg_data, BMI160_GYRO_SELF_TEST, 1);
+		rslt = bmi160_set_regs(BMI160_SELF_TEST_ADDR, &reg_data, 1, dev);
+		if (rslt == BMI160_OK) {
+			/* Delay to enable gyro self test */
+			dev->delay_ms(BMI160_GYRO_SELF_TEST_DELAY);
+		}
+	}
+
+	return rslt;
 }
+
 /*!
- *	@brief This function is used to calculate the
- *	linear data in YAS532 sensor.
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
+ * @brief This API validates the self test results of Gyro
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_xy1y2_to_linear(
-u16 *v_xy1y2_u16, s32 *xy1y2_linear)
+static int8_t validate_gyro_self_test(const struct bmi160_dev *dev)
 {
-	/* This variable used to provide the communication
-	results*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = SUCCESS;
-	static const u16 v_calib_data[] = {
-	3721, 3971, 4221, 4471};
-	u8 i = BMI160_INIT_VALUE;
-
-	for (i = 0; i < 3; i++)
-		xy1y2_linear[i] = v_xy1y2_u16[i] -
-		 v_calib_data[yas532_data.calib_yas532.fxy1y2[i]]
-			+ (yas532_data.v_hard_offset_s8[i] -
-			yas532_data.calib_yas532.rxy1y2[i])
-			* yas532_data.coef[i];
-	return com_rslt;
+	int8_t rslt;
+	uint8_t reg_data;
+
+	/* Validate the Gyro self test result */
+	rslt = bmi160_get_regs(BMI160_STATUS_ADDR, &reg_data, 1, dev);
+	if (rslt == BMI160_OK) {
+		reg_data = BMI160_GET_BITS(reg_data, BMI160_GYRO_SELF_TEST_STATUS);
+		if (reg_data == BMI160_ENABLE) {
+			/* Gyro self test success case */
+			rslt = BMI160_OK;
+		} else {
+			rslt = BMI160_W_GYRO_SELF_TEST_FAIL;
+		}
+	}
+
+	return rslt;
 }
+
 /*!
- *	@brief This function is used to read the YAS532 sensor data
- *	@param	v_acquisition_command_u8: used to set the data acquisition
- *	acquisition_command  |   operation
- *  ---------------------|-------------------------
- *         0x17          | turn on the acquisition coil
- *         -             | set direction of the coil
- *         _             | (x and y as minus(-))
- *         _             | Deferred acquisition mode
- *        0x07           | turn on the acquisition coil
- *         _             | set direction of the coil
- *         _             | (x and y as minus(-))
- *         _             | Normal acquisition mode
- *        0x11           | turn OFF the acquisition coil
- *         _             | set direction of the coil
- *         _             | (x and y as plus(+))
- *         _             | Deferred acquisition mode
- *       0x01            | turn OFF the acquisition coil
- *        _              | set direction of the coil
- *        _              | (x and y as plus(+))
- *        _              | Normal acquisition mode
- *
- *	@param	v_busy_u8 : used to get the busy flag for sensor data read
- *	@param	v_temp_u16 : used to get the temperature data
- *	@param	v_xy1y2_u16 : used to get the sensor xy1y2 data
- *	@param	v_overflow_u8 : used to get the overflow data
- *
- *
- *
-  *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_normal_measurement_data(
-u8 v_acquisition_command_u8, u8 *v_busy_u8,
-u16 *v_temp_u16, u16 *v_xy1y2_u16, u8 *v_overflow_u8)
+*  @brief This API sets FIFO full interrupt of the sensor.This interrupt
+*  occurs when the FIFO is full and the next full data sample would cause
+*  a FIFO overflow, which may delete the old samples.
+*/
+static int8_t set_fifo_full_int(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
 {
-	/* This variable is used to provide the communication
-	results*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* Array holding the YAS532 xyy1 data*/
-	u8 v_data_u8[BMI160_YAS_XY1Y2T_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};
-	u8 i = BMI160_INIT_VALUE;
-	/* check the p_bmi160 structure for NULL pointer assignment*/
-	if (p_bmi160 == BMI160_NULL) {
-		return E_BMI160_NULL_PTR;
-		} else {
-		/* read the sensor data */
-		com_rslt = bmi160_bst_yas532_acquisition_command_register(
-		v_acquisition_command_u8);
-		com_rslt +=
-		p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
-		BMI160_USER_DATA_MAG_X_LSB__REG,
-		v_data_u8, BMI160_MAG_YAS_DATA_LENGTH);
-		/* read the xyy1 data*/
-		*v_busy_u8 =
-		((v_data_u8[0]
-		>> BMI160_SHIFT_BIT_POSITION_BY_07_BITS) & 0x01);
-		*v_temp_u16 =
-		(u16)((((s32)v_data_u8[0]
-		<< BMI160_SHIFT_BIT_POSITION_BY_03_BITS)
-		& 0x3F8) | ((v_data_u8[1]
-		>> BMI160_SHIFT_BIT_POSITION_BY_05_BITS) & 0x07));
-		v_xy1y2_u16[0] =
-		(u16)((((s32)v_data_u8[2]
-		<< BMI160_SHIFT_BIT_POSITION_BY_06_BITS) & 0x1FC0)
-		| ((v_data_u8[3] >>
-		BMI160_SHIFT_BIT_POSITION_BY_02_BITS) & 0x3F));
-		v_xy1y2_u16[1] =
-		(u16)((((s32)v_data_u8[4]
-		<< BMI160_SHIFT_BIT_POSITION_BY_06_BITS)
-		& 0x1FC0)
-		| ((v_data_u8[5]
-		>> BMI160_SHIFT_BIT_POSITION_BY_02_BITS) & 0x3F));
-		v_xy1y2_u16[2] =
-		(u16)((((s32)v_data_u8[6]
-		<< BMI160_SHIFT_BIT_POSITION_BY_06_BITS)
-		& 0x1FC0)
-		| ((v_data_u8[7]
-		>> BMI160_SHIFT_BIT_POSITION_BY_02_BITS) & 0x3F));
-		*v_overflow_u8 = 0;
-		for (i = 0; i < 3; i++) {
-			if (v_xy1y2_u16[i] == YAS532_DATA_OVERFLOW)
-				*v_overflow_u8 |= (1 << (i * 2));
-			if (v_xy1y2_u16[i] == YAS532_DATA_UNDERFLOW)
-				*v_overflow_u8 |= (1 << (i * 2 + 1));
+	int8_t rslt = BMI160_OK;
+
+	/* Null-pointer check */
+	if ((dev == NULL) || (dev->delay_ms == NULL)) {
+		rslt = BMI160_E_NULL_PTR;
+	} else {
+		/*enable the fifo full interrupt */
+		rslt = enable_fifo_full_int(int_config, dev);
+		if (rslt == BMI160_OK) {
+			/* Configure Interrupt pins */
+			rslt = set_intr_pin_config(int_config, dev);
+			if (rslt == BMI160_OK)
+				rslt = map_int_pin_to_fifo_full(int_config, dev);
 		}
 	}
-	return com_rslt;
+	return rslt;
 }
+
 /*!
- *	@brief This function is used to read the YAS532 sensor data
- *	@param	v_acquisition_command_u8	:	the value of CMDR
- *	acquisition_command  |   operation
- *  ---------------------|-------------------------
- *         0x17          | turn on the acquisition coil
- *         -             | set direction of the coil
- *         _             | (x and y as minus(-))
- *         _             | Deferred acquisition mode
- *        0x07           | turn on the acquisition coil
- *         _             | set direction of the coil
- *         _             | (x and y as minus(-))
- *         _             | Normal acquisition mode
- *        0x11           | turn OFF the acquisition coil
- *         _             | set direction of the coil
- *         _             | (x and y as plus(+))
- *         _             | Deferred acquisition mode
- *       0x01            | turn OFF the acquisition coil
- *        _              | set direction of the coil
- *        _              | (x and y as plus(+))
- *        _              | Normal acquisition mode
- *
- * @param xyz_data : the vector xyz output
- * @param v_overflow_s8 : the value of overflow
- * @param v_temp_correction_u8 : the value of temperate correction enable
- *
- *
-  *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
+ * @brief This enable the FIFO full interrupt engine.
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_measurement_xyz_data(
-struct yas532_vector *xyz_data, u8 *v_overflow_s8, u8 v_temp_correction_u8,
-u8 v_acquisition_command_u8)
+static int8_t enable_fifo_full_int(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
 {
-	/* This variable is used to provide the communication
-	results*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* Array holding the linear calculation output*/
-	s32 v_xy1y2_linear_s32[BMI160_YAS_XY1Y2_DATA_SIZE] = {
-	BMI160_INIT_VALUE,
-	BMI160_INIT_VALUE, BMI160_INIT_VALUE};
-	/* Array holding the temperature data */
-	s32 v_xyz_tmp_s32[BMI160_YAS_TEMP_DATA_SIZE] = {BMI160_INIT_VALUE,
-	BMI160_INIT_VALUE, BMI160_INIT_VALUE};
-	s32 tmp = BMI160_INIT_VALUE;
-	s32 sx, sy1, sy2, sy, sz = BMI160_INIT_VALUE;
-	u8 i, v_busy_u8 = BMI160_INIT_VALUE;
-	u16 v_temp_u16 = BMI160_INIT_VALUE;
-	/* Array holding the xyy1 sensor raw data*/
-	u16 v_xy1y2_u16[BMI160_YAS_XY1Y2_DATA_SIZE] = {BMI160_INIT_VALUE,
-	BMI160_INIT_VALUE, BMI160_INIT_VALUE};
-	#if 1 < YAS532_MAG_TEMPERATURE_LOG
-	s32 sum = BMI160_INIT_VALUE;
-	#endif
-	*v_overflow_s8 = BMI160_INIT_VALUE;
-	switch (yas532_data.measure_state) {
-	case YAS532_MAG_STATE_INIT_COIL:
-		if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE)
-			com_rslt = bmi160_set_mag_manual_enable(
-			BMI160_MANUAL_ENABLE);
-		/* write Rcoil*/
-		com_rslt += bmi160_set_mag_write_data(
-		BMI160_YAS_DISABLE_RCOIL);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		com_rslt += bmi160_set_mag_write_addr(BMI160_YAS532_RCOIL);
-		p_bmi160->delay_msec(BMI160_YAS532_MEASUREMENT_DELAY);
-		if (!yas532_data.overflow && is_valid_offset(
-		yas532_data.v_hard_offset_s8))
-			yas532_data.measure_state = 0;
-	break;
-	case YAS532_MAG_STATE_MEASURE_OFFSET:
-		com_rslt = bmi160_bst_yas532_magnetic_measure_set_offset();
-		yas532_data.measure_state = 0;
-	break;
-	default:
-	break;
-	}
-	/* Read sensor data*/
-	com_rslt += bmi160_bst_yas532_normal_measurement_data(
-	v_acquisition_command_u8, &v_busy_u8, &v_temp_u16,
-	v_xy1y2_u16, v_overflow_s8);
-	/* Calculate the linear data*/
-	com_rslt += bmi160_bst_yas532_xy1y2_to_linear(v_xy1y2_u16,
-	v_xy1y2_linear_s32);
-	/* Calculate temperature correction */
-	#if 1 < YAS532_MAG_TEMPERATURE_LOG
-		yas532_data.temp_data.log[yas532_data.temp_data.idx++] =
-		v_temp_u16;
-	if (YAS532_MAG_TEMPERATURE_LOG <= yas532_data.temp_data.idx)
-		yas532_data.temp_data.idx = 0;
-		yas532_data.temp_data.num++;
-	if (YAS532_MAG_TEMPERATURE_LOG <= yas532_data.temp_data.num)
-		yas532_data.temp_data.num = YAS532_MAG_TEMPERATURE_LOG;
-	for (i = 0; i < yas532_data.temp_data.num; i++)
-		sum += yas532_data.temp_data.log[i];
-		tmp = sum * 10 / yas532_data.temp_data.num
-		- YAS532_TEMP20DEGREE_TYPICAL * 10;
-	#else
-		tmp = (v_temp_u16 - YAS532_TEMP20DEGREE_TYPICAL)
-		* 10;
-	#endif
-	sx  = v_xy1y2_linear_s32[0];
-	sy1 = v_xy1y2_linear_s32[1];
-	sy2 = v_xy1y2_linear_s32[2];
-	/* Temperature correction */
-	if (v_temp_correction_u8) {
-		sx  -= (yas532_data.calib_yas532.cx  * tmp)
-		/ 1000;
-		sy1 -= (yas532_data.calib_yas532.cy1 * tmp)
-		/ 1000;
-		sy2 -= (yas532_data.calib_yas532.cy2 * tmp)
-		/ 1000;
-	}
-	sy = sy1 - sy2;
-	sz = -sy1 - sy2;
-	#if 1
-	xyz_data->yas532_vector_xyz[0] = yas532_data.calib_yas532.k *
-	((100 * sx + yas532_data.calib_yas532.a2 * sy +
-	yas532_data.calib_yas532.a3 * sz) / 10);
-	xyz_data->yas532_vector_xyz[1] = yas532_data.calib_yas532.k *
-	((yas532_data.calib_yas532.a4 * sx + yas532_data.calib_yas532.a5 * sy +
-	yas532_data.calib_yas532.a6 * sz) / 10);
-	xyz_data->yas532_vector_xyz[2] = yas532_data.calib_yas532.k *
-	((yas532_data.calib_yas532.a7 * sx + yas532_data.calib_yas532.a8 * sy +
-	yas532_data.calib_yas532.a9 * sz) / 10);
-	if (yas532_data.transform != BMI160_NULL) {
-		for (i = 0; i < 3; i++) {
-				v_xyz_tmp_s32[i] = yas532_data.transform[i
-				* 3] *
-				xyz_data->yas532_vector_xyz[0]
-				+ yas532_data.transform[i * 3 + 1] *
-				xyz_data->yas532_vector_xyz[1]
-				+ yas532_data.transform[i * 3 + 2] *
-				xyz_data->yas532_vector_xyz[2];
-		}
-		set_vector(xyz_data->yas532_vector_xyz, v_xyz_tmp_s32);
+	int8_t rslt;
+	uint8_t data = 0;
+
+	rslt = bmi160_get_regs(BMI160_INT_ENABLE_1_ADDR, &data, 1, dev);
+
+	if (rslt == BMI160_OK) {
+		data = BMI160_SET_BITS(data, BMI160_FIFO_FULL_INT, int_config->fifo_full_int_en);
+		/* Writing data to INT ENABLE 1 Address */
+		rslt = bmi160_set_regs(BMI160_INT_ENABLE_1_ADDR, &data, 1, dev);
 	}
-	for (i = 0; i < 3; i++) {
-		xyz_data->yas532_vector_xyz[i] -=
-		xyz_data->yas532_vector_xyz[i] % 10;
-		if (*v_overflow_s8 & (1
-		<< (i * 2)))
-			xyz_data->yas532_vector_xyz[i] +=
-			1; /* set overflow */
-		if (*v_overflow_s8 & (1 <<
-		(i * 2 + 1)))
-			xyz_data->yas532_vector_xyz[i] += 2; /* set underflow */
+
+	return rslt;
+}
+
+/*!
+ * @brief This API maps the INT pin to FIFO FULL interrupt.
+ */
+static int8_t map_int_pin_to_fifo_full(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
+{
+	int8_t rslt;
+	uint8_t data = 0;
+	/* Configure Map register to map interrupt pin
+	 * to fifo-full interrupt*/
+	rslt = bmi160_get_regs(BMI160_INT_MAP_1_ADDR, &data, 1, dev);
+	if (rslt == BMI160_OK) {
+		if (int_config->int_channel == BMI160_INT_CHANNEL_1)
+			data = BMI160_SET_BITS(data, BMI160_FIFO_FULL_INT_PIN1, 1);
+		else
+			data = BMI160_SET_BITS(data, BMI160_FIFO_FULL_INT_PIN2, 1);
+
+		/* Writing data to Map 1 address */
+		rslt = bmi160_set_regs(BMI160_INT_MAP_1_ADDR, &data, 1, dev);
 	}
-#else
-	xyz_data->yas532_vector_xyz[0] = sx;
-	xyz_data->yas532_vector_xyz[1] = sy;
-	xyz_data->yas532_vector_xyz[2] = sz;
-#endif
-if (v_busy_u8)
-		return com_rslt;
-	if (0 < *v_overflow_s8) {
-		if (!yas532_data.overflow)
-			yas532_data.overflow = 1;
-		yas532_data.measure_state = YAS532_MAG_STATE_INIT_COIL;
-	} else
-		yas532_data.overflow = 0;
-	for (i = 0; i < 3; i++)
-		yas532_data.last_raw[i] = v_xy1y2_u16[i];
-	  yas532_data.last_raw[i] = v_temp_u16;
-	return com_rslt;
+
+	return rslt;
 }
+
 /*!
- *	@brief This function is used to read YAS532 sensor data
- *
- *
- * @param v_xy1y2_u16 : the vector xyz output
- * @param v_overflow_s8 : the value of overflow
- * @param v_temp_correction_u8 : the value of temperate correction enable
- * @param v_temp_u16 : the value of temperature
- * @param v_busy_u8 : the value denoting the sensor is busy
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
+ *  @brief This API sets FIFO watermark interrupt of the sensor.The FIFO
+ *  watermark interrupt is fired, when the FIFO fill level is above a fifo
+ *  watermark.
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_fifo_xyz_data(
-u16 *v_xy1y2_u16, u8 v_temp_correction_u8,
-s8 v_overflow_s8, u16 v_temp_u16, u8 v_busy_u8)
+static int8_t set_fifo_watermark_int(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
 {
-	/* This variable is used to provide the communication
-	results*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* Array holding the linear calculation output*/
-	s32 v_xy1y2_linear_s32[BMI160_YAS_XY1Y2_DATA_SIZE] = {
-	BMI160_INIT_VALUE,
-	BMI160_INIT_VALUE, BMI160_INIT_VALUE};
-	/* Array holding the temperature data */
-	s32 v_xyz_tmp_s32[BMI160_YAS_TEMP_DATA_SIZE] = {BMI160_INIT_VALUE,
-	BMI160_INIT_VALUE, BMI160_INIT_VALUE};
-	s32 tmp = BMI160_INIT_VALUE;
-	s32 sx, sy1, sy2, sy, sz = BMI160_INIT_VALUE;
-	u8 i = BMI160_INIT_VALUE;
-	#if 1 < YAS532_MAG_TEMPERATURE_LOG
-	s32 sum = BMI160_INIT_VALUE;
-	#endif
-	v_overflow_s8 = BMI160_INIT_VALUE;
-	/* Calculate the linear data*/
-	com_rslt = bmi160_bst_yas532_xy1y2_to_linear(v_xy1y2_u16,
-	v_xy1y2_linear_s32);
-	/* Calculate temperature correction */
-	#if 1 < YAS532_MAG_TEMPERATURE_LOG
-		yas532_data.temp_data.log[yas532_data.temp_data.idx++] =
-		v_temp_u16;
-	if (YAS532_MAG_TEMPERATURE_LOG <= yas532_data.temp_data.idx)
-		yas532_data.temp_data.idx = 0;
-		yas532_data.temp_data.num++;
-	if (YAS532_MAG_TEMPERATURE_LOG <= yas532_data.temp_data.num)
-		yas532_data.temp_data.num = YAS532_MAG_TEMPERATURE_LOG;
-	for (i = 0; i < yas532_data.temp_data.num; i++)
-		sum += yas532_data.temp_data.log[i];
-		tmp = sum * 10 / yas532_data.temp_data.num
-		- YAS532_TEMP20DEGREE_TYPICAL * 10;
-	#else
-		tmp = (v_temp_u16 - YAS532_TEMP20DEGREE_TYPICAL)
-		* 10;
-	#endif
-	sx  = v_xy1y2_linear_s32[0];
-	sy1 = v_xy1y2_linear_s32[1];
-	sy2 = v_xy1y2_linear_s32[2];
-	/* Temperature correction */
-	if (v_temp_correction_u8) {
-		sx  -= (yas532_data.calib_yas532.cx  * tmp)
-		/ 1000;
-		sy1 -= (yas532_data.calib_yas532.cy1 * tmp)
-		/ 1000;
-		sy2 -= (yas532_data.calib_yas532.cy2 * tmp)
-		/ 1000;
-	}
-	sy = sy1 - sy2;
-	sz = -sy1 - sy2;
-	#if 1
-	fifo_xyz_data.yas532_vector_xyz[0] = yas532_data.calib_yas532.k *
-	((100 * sx + yas532_data.calib_yas532.a2 * sy +
-	yas532_data.calib_yas532.a3 * sz) / 10);
-	fifo_xyz_data.yas532_vector_xyz[1] = yas532_data.calib_yas532.k *
-	((yas532_data.calib_yas532.a4 * sx + yas532_data.calib_yas532.a5 * sy +
-	yas532_data.calib_yas532.a6 * sz) / 10);
-	fifo_xyz_data.yas532_vector_xyz[2] = yas532_data.calib_yas532.k *
-	((yas532_data.calib_yas532.a7 * sx + yas532_data.calib_yas532.a8 * sy +
-	yas532_data.calib_yas532.a9 * sz) / 10);
-	if (yas532_data.transform != BMI160_NULL) {
-		for (i = 0; i < 3; i++) {
-				v_xyz_tmp_s32[i] = yas532_data.transform[i
-				* 3] *
-				fifo_xyz_data.yas532_vector_xyz[0]
-				+ yas532_data.transform[i * 3 + 1] *
-				fifo_xyz_data.yas532_vector_xyz[1]
-				+ yas532_data.transform[i * 3 + 2] *
-				fifo_xyz_data.yas532_vector_xyz[2];
+	int8_t rslt = BMI160_OK;
+
+	if ((dev == NULL) || (dev->delay_ms == NULL)) {
+		rslt = BMI160_E_NULL_PTR;
+	} else {
+		/* Enable fifo-watermark interrupt in Int Enable 1 register */
+		rslt = enable_fifo_wtm_int(int_config, dev);
+		if (rslt == BMI160_OK) {
+			/* Configure Interrupt pins */
+			rslt = set_intr_pin_config(int_config, dev);
+			if (rslt == BMI160_OK)
+				rslt = map_int_pin_to_fifo_wtm(int_config, dev);
 		}
-		set_vector(fifo_xyz_data.yas532_vector_xyz, v_xyz_tmp_s32);
 	}
-	for (i = 0; i < 3; i++) {
-		fifo_xyz_data.yas532_vector_xyz[i] -=
-		fifo_xyz_data.yas532_vector_xyz[i] % 10;
-		if (v_overflow_s8 & (1
-		<< (i * 2)))
-			fifo_xyz_data.yas532_vector_xyz[i] +=
-			1; /* set overflow */
-		if (v_overflow_s8 & (1 <<
-		(i * 2 + 1)))
-			fifo_xyz_data.yas532_vector_xyz[i] += 2;
-	}
-#else
-	fifo_xyz_data.yas532_vector_xyz[0] = sx;
-	fifo_xyz_data.yas532_vector_xyz[1] = sy;
-	fifo_xyz_data.yas532_vector_xyz[2] = sz;
-#endif
-if (v_busy_u8)
-		return com_rslt;
-	if (0 < v_overflow_s8) {
-		if (!yas532_data.overflow)
-			yas532_data.overflow = 1;
-		yas532_data.measure_state = YAS532_MAG_STATE_INIT_COIL;
-	} else
-		yas532_data.overflow = 0;
-	for (i = 0; i < 3; i++)
-		yas532_data.last_raw[i] = v_xy1y2_u16[i];
-	  yas532_data.last_raw[i] = v_temp_u16;
-	return com_rslt;
+
+	return rslt;
 }
 
 /*!
- *	@brief This function is used to write the data acquisition
- *	command register in YAS532 sensor.
- *	@param v_command_reg_data_u8	:	the value of data acquisition
- *
- *	acquisition_command  |   operation
- *  ---------------------|-------------------------
- *         0x17          | turn on the acquisition coil
- *         -             | set direction of the coil
- *         _             | (x and y as minus(-))
- *         _             | Deferred acquisition mode
- *        0x07           | turn on the acquisition coil
- *         _             | set direction of the coil
- *         _             | (x and y as minus(-))
- *         _             | Normal acquisition mode
- *        0x11           | turn OFF the acquisition coil
- *         _             | set direction of the coil
- *         _             | (x and y as plus(+))
- *         _             | Deferred acquisition mode
- *       0x01            | turn OFF the acquisition coil
- *        _              | set direction of the coil
- *        _              | (x and y as plus(+))
- *        _              | Normal acquisition mode
- *
- *
- *
-  *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
+ * @brief This enable the FIFO watermark interrupt engine.
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_acquisition_command_register(
-u8 v_command_reg_data_u8)
+static int8_t enable_fifo_wtm_int(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
 {
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
+	int8_t rslt;
+	uint8_t data = 0;
 
-	if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE)
-			com_rslt = bmi160_set_mag_manual_enable(
-			BMI160_MANUAL_ENABLE);
+	rslt = bmi160_get_regs(BMI160_INT_ENABLE_1_ADDR, &data, 1, dev);
+
+	if (rslt == BMI160_OK) {
+		data = BMI160_SET_BITS(data, BMI160_FIFO_WTM_INT, int_config->fifo_WTM_int_en);
+		/* Writing data to INT ENABLE 1 Address */
+		rslt = bmi160_set_regs(BMI160_INT_ENABLE_1_ADDR, &data, 1, dev);
+	}
 
-		com_rslt = bmi160_set_mag_write_data(v_command_reg_data_u8);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		/* YAMAHA YAS532-0x82*/
-		com_rslt += bmi160_set_mag_write_addr(
-		BMI160_YAS532_COMMAND_REGISTER);
-		p_bmi160->delay_msec(BMI160_YAS_ACQ_COMMAND_DELAY);
-		com_rslt += bmi160_set_mag_read_addr(
-		BMI160_YAS532_DATA_REGISTER);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	return rslt;
+}
 
-	if (p_bmi160->mag_manual_enable == BMI160_MANUAL_ENABLE)
-		com_rslt += bmi160_set_mag_manual_enable(BMI160_MANUAL_DISABLE);
+/*!
+ * @brief This API maps the INT pin to FIFO watermark interrupt.
+ */
+static int8_t map_int_pin_to_fifo_wtm(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
+{
+	int8_t rslt;
+	uint8_t data = 0;
+	/* Configure Map register to map interrupt pin
+	 * to fifo-full interrupt*/
+	rslt = bmi160_get_regs(BMI160_INT_MAP_1_ADDR, &data, 1, dev);
+	if (rslt == BMI160_OK) {
+		if (int_config->int_channel == BMI160_INT_CHANNEL_1)
+			data = BMI160_SET_BITS(data, BMI160_FIFO_WTM_INT_PIN1, 1);
+		else
+			data = BMI160_SET_BITS(data, BMI160_FIFO_WTM_INT_PIN2, 1);
 
-	return com_rslt;
+		/* Writing data to Map 1 address */
+		rslt = bmi160_set_regs(BMI160_INT_MAP_1_ADDR, &data, 1, dev);
+	}
 
+	return rslt;
 }
 /*!
- *	@brief This function is used write the offset for YAS532 sensor
- *
- *	@param	p_offset_s8	: The value of offset to write
- *
- *
-  *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
+ *  @brief This API is used to reset the FIFO related configurations
+ *  in the fifo_frame structure.
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_set_offset(
-const s8 *p_offset_s8)
+static void reset_fifo_data_structure(const struct bmi160_dev *dev)
 {
-	/* This variable is used to provide the communication
-	results*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-
-	if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE)
-		com_rslt = bmi160_set_mag_manual_enable(BMI160_MANUAL_ENABLE);
-		p_bmi160->delay_msec(BMI160_YAS532_OFFSET_DELAY);
-
-	    /* Write offset X data*/
-		com_rslt = bmi160_set_mag_write_data(p_offset_s8[0]);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		/* YAS532 offset x write*/
-		com_rslt += bmi160_set_mag_write_addr(BMI160_YAS532_OFFSET_X);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-
-		/* Write offset Y data*/
-		com_rslt = bmi160_set_mag_write_data(p_offset_s8[1]);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		/* YAS532 offset y write*/
-		com_rslt += bmi160_set_mag_write_addr(BMI160_YAS532_OFFSET_Y);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-
-		/* Write offset Z data*/
-		com_rslt = bmi160_set_mag_write_data(p_offset_s8[2]);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		/* YAS532 offset z write*/
-		com_rslt += bmi160_set_mag_write_addr(BMI160_YAS532_OFFSET_Z);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		set_vector(yas532_data.v_hard_offset_s8, p_offset_s8);
-
-	if (p_bmi160->mag_manual_enable == BMI160_MANUAL_ENABLE)
-		com_rslt = bmi160_set_mag_manual_enable(BMI160_MANUAL_DISABLE);
-	return com_rslt;
+	/*Prepare for next FIFO read by resetting FIFO's
+	internal data structures*/
+	dev->fifo->accel_byte_start_idx = 0;
+	dev->fifo->gyro_byte_start_idx = 0;
+	dev->fifo->sensor_time = 0;
+	dev->fifo->skipped_frame_count = 0;
 }
-#endif
-#ifdef YAS537
-/***************************************************/
-/**\name	FUNCTIONS FOR YAMAHA-YAS537 */
-/***************************************************/
+
 /*!
- *	@brief This function used to init the YAMAHA-YAS537
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas537_mag_interface_init(
-void)
+ *  @brief This API is used to read fifo_byte_counter value (i.e)
+ *  current fill-level in Fifo buffer.
+ */
+static int8_t get_fifo_byte_counter(uint16_t *bytes_to_read, struct bmi160_dev const *dev)
 {
-/* This variable is used to provide the communication
-results*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-u8 i = BMI160_INIT_VALUE;
-u8 v_accel_power_mode_status = BMI160_INIT_VALUE;
-
-com_rslt = bmi160_get_accel_power_mode_stat(
-	&v_accel_power_mode_status);
-/* Accel operation mode to normal*/
-if (v_accel_power_mode_status != BMI160_ACCEL_NORMAL_MODE) {
-	com_rslt += bmi160_set_command_register(ACCEL_MODE_NORMAL);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+	int8_t rslt = 0;
+	uint8_t data[2];
+	uint8_t addr = BMI160_FIFO_LENGTH_ADDR;
+
+	rslt |= bmi160_get_regs(addr, data, 2, dev);
+	data[1] = data[1] & BMI160_FIFO_BYTE_COUNTER_MASK;
+
+	/* Available data in FIFO is stored in bytes_to_read*/
+	*bytes_to_read = (((uint16_t)data[1] << 8) | ((uint16_t)data[0]));
+
+	return rslt;
 }
-/* write Mag power mode as NORMAL*/
-com_rslt += bmi160_set_mag_interface_normal();
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* Write the YAS532 i2c address*/
-com_rslt += bmi160_set_i2c_device_addr(BMI160_YAS537_I2C_ADDRESS);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* enable the Mag interface to manual mode*/
-com_rslt += bmi160_set_mag_manual_enable(BMI160_MANUAL_ENABLE);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-bmi160_get_mag_manual_enable(&v_data_u8);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/*Enable the MAG interface */
-com_rslt += bmi160_set_if_mode(BMI160_ENABLE_MAG_IF_MODE);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-bmi160_get_if_mode(&v_data_u8);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-v_data_u8 = BMI160_MANUAL_DISABLE;
-/* Read the YAS537 device id 0x07*/
-com_rslt += bmi160_set_mag_read_addr(BMI160_YAS_DEVICE_ID_REG);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-yas537_data.dev_id = v_data_u8;
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* Read the YAS537 calibration data*/
-
-com_rslt +=
-bmi160_bst_yamaha_yas537_calib_values(
-BMI160_GEN_READ_WRITE_DATA_LENGTH);
-p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-/* set the mode to NORMAL*/
-yas537_data.measure_state = YAS537_MAG_STATE_NORMAL;
-/* set the transform to zero */
-yas537_data.transform = BMI160_NULL;
-yas537_data.average = 32;
-for (i = 0; i < 3; i++) {
-	yas537_data.hard_offset[i] = -128;
-	yas537_data.last_after_rcoil[i] = 0;
+
+/*!
+ *  @brief This API is used to compute the number of bytes of accel FIFO data
+ *  which is to be parsed in header-less mode
+ */
+static void get_accel_len_to_parse(uint16_t *data_index, uint16_t *data_read_length, const uint8_t *acc_frame_count,
+				const struct bmi160_dev *dev)
+{
+	/* Data start index */
+	*data_index = dev->fifo->accel_byte_start_idx;
+
+	if (dev->fifo->fifo_data_enable == BMI160_FIFO_A_ENABLE) {
+		*data_read_length = (*acc_frame_count) * BMI160_FIFO_A_LENGTH;
+	} else if (dev->fifo->fifo_data_enable == BMI160_FIFO_G_A_ENABLE) {
+		*data_read_length = (*acc_frame_count) * BMI160_FIFO_GA_LENGTH;
+	} else if (dev->fifo->fifo_data_enable == BMI160_FIFO_M_A_ENABLE) {
+		*data_read_length = (*acc_frame_count) * BMI160_FIFO_MA_LENGTH;
+	} else if (dev->fifo->fifo_data_enable == BMI160_FIFO_M_G_A_ENABLE) {
+		*data_read_length = (*acc_frame_count) * BMI160_FIFO_MGA_LENGTH;
+	} else {
+		/* When accel is not enabled ,there will be no accel data.
+		so we update the data index as complete */
+		*data_index = dev->fifo->length;
+	}
+
+	if (*data_read_length > dev->fifo->length) {
+		/* Handling the case where more data is requested
+		than that is available*/
+		*data_read_length = dev->fifo->length;
+	}
+
 }
-for (i = 0; i < 4; i++)
-	yas537_data.last_raw[i] = 0;
-/* write the Mag bandwidth as 25Hz*/
-com_rslt += bmi160_set_mag_output_data_rate(
-BMI160_MAG_OUTPUT_DATA_RATE_25HZ);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* Enable Mag interface to auto mode*/
-com_rslt += bmi160_set_mag_manual_enable(
-BMI160_MANUAL_DISABLE);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-bmi160_get_mag_manual_enable(&v_data_u8);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-
-	switch (v_accel_power_mode_status) {
-
-	case BMI160_ACCEL_SUSPEND:
-		com_rslt += bmi160_set_command_register(ACCEL_SUSPEND);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		break;
 
-	case BMI160_ACCEL_LOW_POWER:
-		com_rslt += bmi160_set_command_register(ACCEL_LOWPOWER);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
+/*!
+ *  @brief This API is used to parse the accelerometer data from the
+ *  FIFO data in both header mode and header-less mode.
+ *  It updates the idx value which is used to store the index of
+ *  the current data byte which is parsed.
+ */
+static void unpack_accel_frame(struct bmi160_sensor_data *acc, uint16_t *idx, uint8_t *acc_idx, uint8_t frame_info,
+				const struct bmi160_dev *dev)
+{
+	switch (frame_info) {
+	case BMI160_FIFO_HEAD_A:
+	case BMI160_FIFO_A_ENABLE:
+		/*Partial read, then skip the data*/
+		if ((*idx + BMI160_FIFO_A_LENGTH) > dev->fifo->length) {
+			/*Update the data index as complete*/
+			*idx = dev->fifo->length;
+			break;
+		}
+		/*Unpack the data array into the structure instance "acc" */
+		unpack_accel_data(&acc[*acc_idx], *idx, dev);
+		/*Move the data index*/
+		*idx = *idx + BMI160_FIFO_A_LENGTH;
+		(*acc_idx)++;
+		break;
+	case BMI160_FIFO_HEAD_G_A:
+	case BMI160_FIFO_G_A_ENABLE:
+		/*Partial read, then skip the data*/
+		if ((*idx + BMI160_FIFO_GA_LENGTH) > dev->fifo->length) {
+			/*Update the data index as complete*/
+			*idx = dev->fifo->length;
+			break;
+		}
+		/*Unpack the data array into structure instance "acc"*/
+		unpack_accel_data(&acc[*acc_idx], *idx + BMI160_FIFO_G_LENGTH, dev);
+		/*Move the data index*/
+		*idx = *idx + BMI160_FIFO_GA_LENGTH;
+		(*acc_idx)++;
+		break;
+	case BMI160_FIFO_HEAD_M_A:
+	case BMI160_FIFO_M_A_ENABLE:
+		/*Partial read, then skip the data*/
+		if ((*idx + BMI160_FIFO_MA_LENGTH) > dev->fifo->length) {
+			/*Update the data index as complete*/
+			*idx = dev->fifo->length;
+			break;
+		}
+		/*Unpack the data array into structure instance "acc"*/
+		unpack_accel_data(&acc[*acc_idx], *idx + BMI160_FIFO_M_LENGTH, dev);
+		/*Move the data index*/
+		*idx = *idx + BMI160_FIFO_MA_LENGTH;
+		(*acc_idx)++;
+		break;
+	case BMI160_FIFO_HEAD_M_G_A:
+	case BMI160_FIFO_M_G_A_ENABLE:
+		/*Partial read, then skip the data*/
+		if ((*idx + BMI160_FIFO_MGA_LENGTH) > dev->fifo->length) {
+			/*Update the data index as complete*/
+			*idx = dev->fifo->length;
+			break;
+		}
+		/*Unpack the data array into structure instance "acc"*/
+		unpack_accel_data(&acc[*acc_idx], *idx + BMI160_FIFO_MG_LENGTH, dev);
+		/*Move the data index*/
+		*idx = *idx + BMI160_FIFO_MGA_LENGTH;
+		(*acc_idx)++;
+		break;
+	case BMI160_FIFO_HEAD_M:
+	case BMI160_FIFO_M_ENABLE:
+		(*idx) = (*idx) + BMI160_FIFO_M_LENGTH;
+		break;
+	case BMI160_FIFO_HEAD_G:
+	case BMI160_FIFO_G_ENABLE:
+		(*idx) = (*idx) + BMI160_FIFO_G_LENGTH;
+		break;
+	case BMI160_FIFO_HEAD_M_G:
+	case BMI160_FIFO_M_G_ENABLE:
+		(*idx) = (*idx) + BMI160_FIFO_MG_LENGTH;
 		break;
-
 	default:
 		break;
+	}
+
 }
-return com_rslt;
-}
+
 /*!
-*	@brief This function is used to read the
-*	YAMAHA YAS537 calibration data
-*
-*
-*	@param v_rcoil_u8 : The value of r coil
-*
-*
-*	@return results of bus communication function
-*	@retval 0 -> Success
-*	@retval -1 -> Error
-*
-*
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas537_calib_values(
-u8 v_rcoil_u8)
+ *  @brief This API is used to parse the accelerometer data from the
+ *  FIFO data and store it in the instance of the structure bmi160_sensor_data.
+ */
+static void unpack_accel_data(struct bmi160_sensor_data *accel_data, uint16_t data_start_index,
+				const struct bmi160_dev *dev)
 {
-/* This variable is used to provide the communication
-results*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-/* Array holding the YAS532 calibration values */
-u8 a_data_u8[BMI160_YAS537_CALIB_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,
-BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE,
-BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE,
-BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE,
-};
-static const u8 v_avrr_u8[] = {0x50, 0x60, 0x70};
-u8 v_cal_valid_u8 = BMI160_INIT_VALUE, i;
-/* write soft reset as 0x02*/
-com_rslt = bmi160_set_mag_write_data(
-YAS537_SRSTR_DATA);
-p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-com_rslt += bmi160_set_mag_write_addr(YAS537_REG_SRSTR);
-p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-/* Read the DX value */
-com_rslt = bmi160_set_mag_read_addr(YAS537_REG_CALR_C0);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read Mag x LSB register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[0], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the DY1 value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_C1);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read Mag x LSB register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[1], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the DY2 value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_C2);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read Mag x LSB register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[2], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the D2 value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_C3);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read Mag x LSB register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[3], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the D3 value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_C4);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read Mag x LSB register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[4], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the D4 value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_C5);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read Mag x LSB register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[5], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the D5 value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_C6);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read Mag x LSB register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[6], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the D6 value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_C7);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read Mag x LSB register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[7], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the D7 value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_C8);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read Mag x LSB register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[8], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the D8 value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_C9);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read Mag x LSB register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[9], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the D9 value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_CA);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read Mag x LSB register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[10], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the RX value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_CB);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read Mag x LSB register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[11], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the RY1 value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_CC);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read Mag x LSB register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[12], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the RY2 value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_CD);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read Mag x LSB register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[13], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the RY2 value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_CE);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read Mag x LSB register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[14], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the CHF value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_CF);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read Mag x LSB register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[15], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the VER value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_DO);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read Mag x LSB register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[16], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* get the calib ver*/
-yas537_data.calib_yas537.ver =
-(a_data_u8[16] >> BMI160_SHIFT_BIT_POSITION_BY_06_BITS);
-for (i = 0; i < 17; i++) {
-	if (((i < 16 && a_data_u8[i]) != 0))
-		v_cal_valid_u8 = 1;
-	if ((i < 16 &&
-	(a_data_u8[i] & 0x3F)) != 0)
-		v_cal_valid_u8 = 1;
-}
-if (!v_cal_valid_u8)
-	return ERROR;
-if (yas537_data.calib_yas537.ver == 0) {
-	for (i = 0; i < 17; i++) {
-		if (i < 12) {
-			/* write offset*/
-			com_rslt += bmi160_set_mag_write_data(
-			a_data_u8[i]);
-			p_bmi160->delay_msec(
-			BMI160_GEN_READ_WRITE_DELAY);
-			com_rslt += bmi160_set_mag_write_addr(
-			YAS537_REG_MTCR + i);
-			p_bmi160->delay_msec(
-			BMI160_GEN_READ_WRITE_DELAY);
-		} else if (i < 15) {
-			/* write offset correction*/
-			com_rslt += bmi160_set_mag_write_data(
-			a_data_u8[i]);
-			p_bmi160->delay_msec(
-			BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-			com_rslt += bmi160_set_mag_write_addr((
-			(YAS537_REG_OXR + i) - 12));
-			p_bmi160->delay_msec(
-			BMI160_GEN_READ_WRITE_DELAY);
-			yas537_data.hard_offset[i - 12]
-			= a_data_u8[i];
-		} else {
-			/* write offset correction*/
-			com_rslt += bmi160_set_mag_write_data(
-			a_data_u8[i]);
-			p_bmi160->delay_msec(
-			BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-			com_rslt += bmi160_set_mag_write_addr((
-			(YAS537_REG_OXR + i) - 11));
-			p_bmi160->delay_msec(
-			BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-		}
+	uint16_t data_lsb;
+	uint16_t data_msb;
+
+	/* Accel raw x data */
+	data_lsb = dev->fifo->data[data_start_index++];
+	data_msb = dev->fifo->data[data_start_index++];
+	accel_data->x = (int16_t)((data_msb << 8) | data_lsb);
+
+	/* Accel raw y data */
+	data_lsb = dev->fifo->data[data_start_index++];
+	data_msb = dev->fifo->data[data_start_index++];
+	accel_data->y = (int16_t)((data_msb << 8) | data_lsb);
+
+	/* Accel raw z data */
+	data_lsb = dev->fifo->data[data_start_index++];
+	data_msb = dev->fifo->data[data_start_index++];
+	accel_data->z = (int16_t)((data_msb << 8) | data_lsb);
 
 }
-} else if (yas537_data.calib_yas537.ver == 1) {
-	for (i = 0; i < 3; i++) {
-		/* write offset*/
-		com_rslt += bmi160_set_mag_write_data(
-		a_data_u8[i]);
-		p_bmi160->delay_msec(
-		BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-		com_rslt += bmi160_set_mag_write_addr(
-		YAS537_REG_MTCR + i);
-		p_bmi160->delay_msec(
-		BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-		if (com_rslt == SUCCESS) {
-			/* write offset*/
-			com_rslt += bmi160_set_mag_write_data(
-			a_data_u8[i + 12]);
-			p_bmi160->delay_msec(
-			BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-			com_rslt += bmi160_set_mag_write_addr(
-			YAS537_REG_OXR + i);
-			p_bmi160->delay_msec(
-			BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-			yas537_data.hard_offset[i] =
-			a_data_u8[i + 12];
-		} else {
-			com_rslt = ERROR;
+
+/*!
+ *  @brief This API is used to parse the accelerometer data from the
+ *  FIFO data in header mode.
+ */
+static void extract_accel_header_mode(struct bmi160_sensor_data *accel_data, uint8_t *accel_length,
+					const struct bmi160_dev *dev)
+{
+	uint8_t frame_header = 0;
+	uint16_t data_index;
+	uint8_t accel_index = 0;
+
+	for (data_index = dev->fifo->accel_byte_start_idx; data_index < dev->fifo->length;) {
+		/* extracting Frame header */
+		frame_header = (dev->fifo->data[data_index] & BMI160_FIFO_TAG_INTR_MASK);
+		/*Index is moved to next byte where the data is starting*/
+		data_index++;
+
+		switch (frame_header) {
+		/* Accel frame */
+		case BMI160_FIFO_HEAD_A:
+		case BMI160_FIFO_HEAD_M_A:
+		case BMI160_FIFO_HEAD_G_A:
+		case BMI160_FIFO_HEAD_M_G_A:
+			unpack_accel_frame(accel_data, &data_index, &accel_index, frame_header, dev);
+			break;
+		case BMI160_FIFO_HEAD_M:
+			move_next_frame(&data_index, BMI160_FIFO_M_LENGTH, dev);
+			break;
+
+		case BMI160_FIFO_HEAD_G:
+			move_next_frame(&data_index, BMI160_FIFO_G_LENGTH, dev);
+			break;
+		case BMI160_FIFO_HEAD_M_G:
+			move_next_frame(&data_index, BMI160_FIFO_MG_LENGTH, dev);
+			break;
+			/* Sensor time frame */
+		case BMI160_FIFO_HEAD_SENSOR_TIME:
+			unpack_sensortime_frame(&data_index, dev);
+			break;
+			/* Skip frame */
+		case BMI160_FIFO_HEAD_SKIP_FRAME:
+			unpack_skipped_frame(&data_index, dev);
+			break;
+			/* Input config frame */
+		case BMI160_FIFO_HEAD_INPUT_CONFIG:
+			move_next_frame(&data_index, 1, dev);
+			break;
+		case BMI160_FIFO_HEAD_OVER_READ:
+			/* Update the data index as complete in case of Over read */
+			data_index = dev->fifo->length;
+			break;
+		default:
+			break;
 		}
 	}
-	/* write offset*/
-	com_rslt += bmi160_set_mag_write_data(
-	((a_data_u8[i] & 0xE0) | 0x10));
-	p_bmi160->delay_msec(
-	BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-	com_rslt += bmi160_set_mag_write_addr(
-	YAS537_REG_MTCR + i);
-	p_bmi160->delay_msec(
-	BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-	/* write offset*/
-	com_rslt += bmi160_set_mag_write_data(
-	((a_data_u8[15]
-	>> BMI160_SHIFT_BIT_POSITION_BY_03_BITS)
-	& 0x1E));
-	p_bmi160->delay_msec(
-	BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-	com_rslt += bmi160_set_mag_write_addr(YAS537_REG_HCKR);
-	p_bmi160->delay_msec(
-	BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-	/* write offset*/
-	com_rslt += bmi160_set_mag_write_data(
-	((a_data_u8[15] << 1) & 0x1E));
-	p_bmi160->delay_msec(
-	BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-	com_rslt += bmi160_set_mag_write_addr(YAS537_REG_LCKR);
-	p_bmi160->delay_msec(
-	BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-	/* write offset*/
-	com_rslt += bmi160_set_mag_write_data(
-	(a_data_u8[16] & 0x3F));
-	p_bmi160->delay_msec(
-	BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-	com_rslt += bmi160_set_mag_write_addr(YAS537_REG_OCR);
-	p_bmi160->delay_msec(
-	BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-
-	/* Assign the calibration values*/
-	/* a2 */
-	yas537_data.calib_yas537.a2 =
-	((((a_data_u8[3]
-	<< BMI160_SHIFT_BIT_POSITION_BY_02_BITS)
-	& 0x7C)
-	| (a_data_u8[4]
-	>> BMI160_SHIFT_BIT_POSITION_BY_06_BITS)) - 64);
-	/* a3 */
-	yas537_data.calib_yas537.a3 =
-	((((a_data_u8[4] << BMI160_SHIFT_BIT_POSITION_BY_01_BIT)
-	& 0x7E)
-	| (a_data_u8[5]
-	>> BMI160_SHIFT_BIT_POSITION_BY_07_BITS)) - 64);
-	/* a4 */
-	yas537_data.calib_yas537.a4 =
-	((((a_data_u8[5]
-	<< BMI160_SHIFT_BIT_POSITION_BY_01_BIT)
-	& 0xFE)
-	| (a_data_u8[6]
-	>> BMI160_SHIFT_BIT_POSITION_BY_07_BITS))
-	- 128);
-	/* a5 */
-	yas537_data.calib_yas537.a5 =
-	((((a_data_u8[6]
-	<< BMI160_SHIFT_BIT_POSITION_BY_02_BITS)
-	& 0x1FC)
-	| (a_data_u8[7]
-	>> BMI160_SHIFT_BIT_POSITION_BY_06_BITS))
-	- 112);
-	/* a6 */
-	yas537_data.calib_yas537.a6 =
-	((((a_data_u8[7]
-	<< BMI160_SHIFT_BIT_POSITION_BY_01_BIT)
-	& 0x7E)
-	| (a_data_u8[8]
-	>> BMI160_SHIFT_BIT_POSITION_BY_07_BITS)) - 64);
-	/* a7 */
-	yas537_data.calib_yas537.a7 =
-	((((a_data_u8[8]
-	<< BMI160_SHIFT_BIT_POSITION_BY_01_BIT)
-	& 0xFE)
-	| (a_data_u8[9]
-	>> BMI160_SHIFT_BIT_POSITION_BY_07_BITS))
-	- 128);
-	/* a8 */
-	yas537_data.calib_yas537.a8 = ((a_data_u8[9] &
-	0x7F) - 64);
-	/* a9 */
-	yas537_data.calib_yas537.a9 = ((((a_data_u8[10]
-	<< BMI160_SHIFT_BIT_POSITION_BY_01_BIT) & 0x1FE)
-	| (a_data_u8[11]
-	>> BMI160_SHIFT_BIT_POSITION_BY_07_BITS))
-	- 112);
-	/* k */
-	yas537_data.calib_yas537.k = (
-	a_data_u8[11] & 0x7F);
+
+	/*Update number of accel data read*/
+	*accel_length = accel_index;
+	/*Update the accel frame index*/
+	dev->fifo->accel_byte_start_idx = data_index;
+}
+
+/*!
+ *  @brief This API computes the number of bytes of gyro FIFO data
+ *  which is to be parsed in header-less mode
+ */
+static void get_gyro_len_to_parse(uint16_t *data_index, uint16_t *data_read_length, const uint8_t *gyro_frame_count,
+					const struct bmi160_dev *dev)
+{
+	/* Data start index */
+	*data_index = dev->fifo->gyro_byte_start_idx;
+
+	if (dev->fifo->fifo_data_enable == BMI160_FIFO_G_ENABLE) {
+		*data_read_length = (*gyro_frame_count) * BMI160_FIFO_G_LENGTH;
+	} else if (dev->fifo->fifo_data_enable == BMI160_FIFO_G_A_ENABLE) {
+		*data_read_length = (*gyro_frame_count) * BMI160_FIFO_GA_LENGTH;
+	} else if (dev->fifo->fifo_data_enable == BMI160_FIFO_M_G_ENABLE) {
+		*data_read_length = (*gyro_frame_count) * BMI160_FIFO_MG_LENGTH;
+	} else if (dev->fifo->fifo_data_enable == BMI160_FIFO_M_G_A_ENABLE) {
+		*data_read_length = (*gyro_frame_count) * BMI160_FIFO_MGA_LENGTH;
 	} else {
-		return ERROR;
+		/* When gyro is not enabled ,there will be no gyro data.
+		so we update the data index as complete */
+		*data_index = dev->fifo->length;
 	}
-/* write A/D converter*/
-com_rslt += bmi160_set_mag_write_data(
-YAS537_WRITE_A_D_CONVERTER);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-com_rslt += bmi160_set_mag_write_addr(YAS537_REG_ADCCALR);
-p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-/* write A/D converter second register*/
-com_rslt += bmi160_set_mag_write_data(
-YAS537_WRITE_A_D_CONVERTER2);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-com_rslt += bmi160_set_mag_write_addr(YAS537_REG_ADCCALR_ONE);
-p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-/* write temperature calibration register*/
-com_rslt += bmi160_set_mag_write_data(YAS537_WRITE_TEMP_CALIB);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-com_rslt += bmi160_set_mag_write_addr(YAS537_REG_TRMR);
-p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-/* write average filter register*/
-com_rslt += bmi160_set_mag_write_data(
-v_avrr_u8[yas537_data.average]);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-com_rslt += bmi160_set_mag_write_addr(YAS537_REG_AVRR);
-p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-if (v_rcoil_u8) {
-	/* write average; filter register*/
-	com_rslt += bmi160_set_mag_write_data(
-	YAS537_WRITE_FILTER);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	com_rslt += bmi160_set_mag_write_addr(YAS537_REG_CONFR);
-	p_bmi160->delay_msec(
-	BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-}
 
-return com_rslt;
+	if (*data_read_length > dev->fifo->length) {
+		/* Handling the case where more data is requested
+		than that is available*/
+		*data_read_length = dev->fifo->length;
+	}
 
 }
+
+
 /*!
- *	@brief This function is used for writing the data acquisition
- *	command register write in YAS537
- *	@param	v_command_reg_data_u8	:	the value of data acquisition
- *	acquisition_command  |   operation
- *  ---------------------|-------------------------
- *         0x17          | turn on the acquisition coil
- *         -             | set direction of the coil
- *         _             | (x and y as minus(-))
- *         _             | Deferred acquisition mode
- *        0x07           | turn on the acquisition coil
- *         _             | set direction of the coil
- *         _             | (x and y as minus(-))
- *         _             | Normal acquisition mode
- *        0x11           | turn OFF the acquisition coil
- *         _             | set direction of the coil
- *         _             | (x and y as plus(+))
- *         _             | Deferred acquisition mode
- *       0x01            | turn OFF the acquisition coil
- *        _              | set direction of the coil
- *        _              | (x and y as plus(+))
- *        _              | Normal acquisition mode
- *
- *
- *
-  *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
+ *  @brief This API is used to parse the gyroscope's data from the
+ *  FIFO data in both header mode and header-less mode.
+ *  It updates the idx value which is used to store the index of
+ *  the current data byte which is parsed.
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas537_acquisition_command_register(
-u8 v_command_reg_data_u8)
+static void unpack_gyro_frame(struct bmi160_sensor_data *gyro, uint16_t *idx, uint8_t *gyro_idx, uint8_t frame_info,
+				const struct bmi160_dev *dev)
 {
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-
-	if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE)
-			com_rslt = bmi160_set_mag_manual_enable(
-			BMI160_MANUAL_ENABLE);
-			p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-
-		com_rslt = bmi160_set_mag_write_data(v_command_reg_data_u8);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		/* YAMAHA YAS532-0x82*/
-		com_rslt += bmi160_set_mag_write_addr(
-		BMI160_REG_YAS537_CMDR);
-		/* set the mode to RECORD*/
-		yas537_data.measure_state = YAS537_MAG_STATE_RECORD_DATA;
-		p_bmi160->delay_msec(BMI160_YAS_ACQ_COMMAND_DELAY);
-		com_rslt += bmi160_set_mag_read_addr(
-		YAS537_REG_TEMPERATURE_0);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-
-	if (p_bmi160->mag_manual_enable == BMI160_MANUAL_ENABLE)
-		com_rslt += bmi160_set_mag_manual_enable(
-		BMI160_MANUAL_DISABLE);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-
-	return com_rslt;
+	switch (frame_info) {
+
+	case BMI160_FIFO_HEAD_G:
+	case BMI160_FIFO_G_ENABLE:
+		/*Partial read, then skip the data*/
+		if ((*idx + BMI160_FIFO_G_LENGTH) > dev->fifo->length) {
+			/*Update the data index as complete*/
+			*idx = dev->fifo->length;
+			break;
+		}
+		/*Unpack the data array into structure instance "gyro"*/
+		unpack_gyro_data(&gyro[*gyro_idx], *idx, dev);
+		/*Move the data index*/
+		(*idx) = (*idx) + BMI160_FIFO_G_LENGTH;
+		(*gyro_idx)++;
+		break;
+
+	case BMI160_FIFO_HEAD_G_A:
+	case BMI160_FIFO_G_A_ENABLE:
+		/*Partial read, then skip the data*/
+		if ((*idx + BMI160_FIFO_GA_LENGTH) > dev->fifo->length) {
+			/*Update the data index as complete*/
+			*idx = dev->fifo->length;
+			break;
+		}
+		/* Unpack the data array into structure instance "gyro" */
+		unpack_gyro_data(&gyro[*gyro_idx], *idx, dev);
+		/* Move the data index */
+		*idx = *idx + BMI160_FIFO_GA_LENGTH;
+		(*gyro_idx)++;
+		break;
+
+	case BMI160_FIFO_HEAD_M_G_A:
+	case BMI160_FIFO_M_G_A_ENABLE:
+		/*Partial read, then skip the data*/
+		if ((*idx + BMI160_FIFO_MGA_LENGTH) > dev->fifo->length) {
+			/*Update the data index as complete*/
+			*idx = dev->fifo->length;
+			break;
+		}
+		/*Unpack the data array into structure instance "gyro"*/
+		unpack_gyro_data(&gyro[*gyro_idx], *idx + BMI160_FIFO_M_LENGTH, dev);
+		/*Move the data index*/
+		*idx = *idx + BMI160_FIFO_MGA_LENGTH;
+		(*gyro_idx)++;
+		break;
+
+
+	case BMI160_FIFO_HEAD_M_A:
+	case BMI160_FIFO_M_A_ENABLE:
+		/* Move the data index */
+		*idx = *idx + BMI160_FIFO_MA_LENGTH;
+		break;
+
+	case BMI160_FIFO_HEAD_M:
+	case BMI160_FIFO_M_ENABLE:
+		(*idx) = (*idx) + BMI160_FIFO_M_LENGTH;
+		break;
+
+	case BMI160_FIFO_HEAD_M_G:
+	case BMI160_FIFO_M_G_ENABLE:
+		/*Partial read, then skip the data*/
+		if ((*idx + BMI160_FIFO_MG_LENGTH) > dev->fifo->length) {
+			/*Update the data index as complete*/
+			*idx = dev->fifo->length;
+			break;
+		}
+		/*Unpack the data array into structure instance "gyro"*/
+		unpack_gyro_data(&gyro[*gyro_idx], *idx + BMI160_FIFO_M_LENGTH, dev);
+		/*Move the data index*/
+		(*idx) = (*idx) + BMI160_FIFO_MG_LENGTH;
+		(*gyro_idx)++;
+		break;
+
+	case BMI160_FIFO_HEAD_A:
+	case BMI160_FIFO_A_ENABLE:
+		/*Move the data index*/
+		*idx = *idx + BMI160_FIFO_A_LENGTH;
+		break;
+
+	default:
+		break;
+	}
 
 }
+
 /*!
- *	@brief This function is used for processing the
- *	YAMAHA YAS537 xy1y2 raw data
- *
- *	@param xy1y2: The value of raw xy1y2 data
- *	@param xyz: The value of  xyz data
- *
- *
- *	@return None
- *
- *
+ *  @brief This API is used to parse the gyro data from the
+ *  FIFO data and store it in the instance of the structure bmi160_sensor_data.
  */
-static void xy1y2_to_xyz(u16 *xy1y2, s32 *xyz)
+static void unpack_gyro_data(struct bmi160_sensor_data *gyro_data, uint16_t data_start_index,
+				const struct bmi160_dev *dev)
 {
-	xyz[0] = ((xy1y2[0] - 8192)
-	* 300);
-	xyz[1] = (((xy1y2[1] - xy1y2[2])
-	* 1732) / 10);
-	xyz[2] = (((-xy1y2[2] - xy1y2[2])
-	+ 16384) * 300);
+	uint16_t data_lsb;
+	uint16_t data_msb;
+
+	/* Gyro raw x data */
+	data_lsb = dev->fifo->data[data_start_index++];
+	data_msb = dev->fifo->data[data_start_index++];
+	gyro_data->x = (int16_t)((data_msb << 8) | data_lsb);
+
+	/* Gyro raw y data */
+	data_lsb = dev->fifo->data[data_start_index++];
+	data_msb = dev->fifo->data[data_start_index++];
+	gyro_data->y = (int16_t)((data_msb << 8) | data_lsb);
+
+	/* Gyro raw z data */
+	data_lsb = dev->fifo->data[data_start_index++];
+	data_msb = dev->fifo->data[data_start_index++];
+	gyro_data->z = (int16_t)((data_msb << 8) | data_lsb);
+
 }
+
 /*!
- *	@brief This function is used to read the
- *	YAMAHA YAS537 xy1y2 data
- *
- *	@param v_coil_stat_u8: The value of R coil status
- *	@param v_busy_u8: The value of busy status
- *	@param v_temperature_u16: The value of temperature
- *	@param xy1y2: The value of raw xy1y2 data
- *	@param v_outflow_u8: The value of overflow
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
+ *  @brief This API is used to parse the gyro data from the
+ *  FIFO data in header mode.
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas537_read_xy1y2_data(
-u8 *v_coil_stat_u8, u8 *v_busy_u8,
-u16 *v_temperature_u16, u16 *xy1y2, u8 *v_outflow_u8)
-{
-	/* This variable is used to provide the communication
-	results*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-	/* Array holding the YAS532 calibration values */
-	u8 a_data_u8[BMI160_YAS_XY1Y2T_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,
-	};
-	u8 i = BMI160_INIT_VALUE;
-	s32 a_h_s32[BMI160_YAS_H_DATA_SIZE] = {
-	BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
-	s32 a_s_s32[BMI160_YAS_S_DATA_SIZE] = {
-	BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
-	/* set command register*/
-	com_rslt = bmi160_bst_yas537_acquisition_command_register(
-	YAS537_SET_COMMAND_REGISTER);
-	/* read the yas537 sensor data of xy1y2*/
-	com_rslt +=
-	p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
-	BMI160_USER_DATA_MAG_X_LSB__REG,
-	a_data_u8, BMI160_MAG_YAS_DATA_LENGTH);
-	/* read the busy flag*/
-	*v_busy_u8 = a_data_u8[2]
-	>> BMI160_SHIFT_BIT_POSITION_BY_07_BITS;
-	/* read the coil status*/
-	*v_coil_stat_u8 =
-	((a_data_u8[2] >>
-	BMI160_SHIFT_BIT_POSITION_BY_06_BITS) & 0X01);
-	/* read temperature data*/
-	*v_temperature_u16 = (u16)((a_data_u8[0]
-	<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS) | a_data_u8[1]);
-	/* read x data*/
-	xy1y2[0] = (u16)(((a_data_u8[2] &
-	0x3F)
-	<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-	| (a_data_u8[3]));
-	/* read y1 data*/
-	xy1y2[1] = (u16)((a_data_u8[4]
-	<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-	| a_data_u8[5]);
-	/* read y2 data*/
-	xy1y2[2] = (u16)((a_data_u8[6]
-	<< BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
-	| a_data_u8[7]);
-	for (i = 0; i < 3; i++)
-		yas537_data.last_raw[i] = xy1y2[i];
-	yas537_data.last_raw[i] = *v_temperature_u16;
-	if (yas537_data.calib_yas537.ver == 1) {
-		for (i = 0; i < 3; i++)
-			a_s_s32[i] = xy1y2[i] - 8192;
-		/* read hx*/
-		a_h_s32[0] = ((yas537_data.calib_yas537.k * (
-		(128 * a_s_s32[0]) +
-		(yas537_data.calib_yas537.a2 * a_s_s32[1]) +
-		(yas537_data.calib_yas537.a3 * a_s_s32[2])))
-		/ (8192));
-		/* read hy1*/
-		a_h_s32[1] = ((yas537_data.calib_yas537.k * (
-		(yas537_data.calib_yas537.a4 * a_s_s32[0]) +
-		(yas537_data.calib_yas537.a5 * a_s_s32[1]) +
-		(yas537_data.calib_yas537.a6 * a_s_s32[2])))
-		/ (8192));
-		/* read hy2*/
-		a_h_s32[2] = ((yas537_data.calib_yas537.k * (
-		(yas537_data.calib_yas537.a7 * a_s_s32[0]) +
-		(yas537_data.calib_yas537.a8 * a_s_s32[1]) +
-		(yas537_data.calib_yas537.a9 * a_s_s32[2])))
-		/ (8192));
-
-		for (i = 0; i < 3; i++) {
-			if (a_h_s32[i] < -8192)
-				a_h_s32[i] = -8192;
-
-			if (8192 < a_h_s32[i])
-				a_h_s32[i] = 8192;
-
-			xy1y2[i] = a_h_s32[i] + 8192;
-
+static void extract_gyro_header_mode(struct bmi160_sensor_data *gyro_data, uint8_t *gyro_length,
+					const struct bmi160_dev *dev)
+{
+	uint8_t frame_header = 0;
+	uint16_t data_index;
+	uint8_t gyro_index = 0;
+
+	for (data_index = dev->fifo->gyro_byte_start_idx; data_index < dev->fifo->length;) {
+		/* extracting Frame header */
+		frame_header = (dev->fifo->data[data_index] & BMI160_FIFO_TAG_INTR_MASK);
+		/*Index is moved to next byte where the data is starting*/
+		data_index++;
+
+		switch (frame_header) {
+			/* GYRO frame */
+		case BMI160_FIFO_HEAD_G:
+		case BMI160_FIFO_HEAD_G_A:
+		case BMI160_FIFO_HEAD_M_G:
+		case BMI160_FIFO_HEAD_M_G_A:
+			unpack_gyro_frame(gyro_data, &data_index, &gyro_index, frame_header, dev);
+			break;
+		case BMI160_FIFO_HEAD_A:
+			move_next_frame(&data_index, BMI160_FIFO_A_LENGTH, dev);
+			break;
+		case BMI160_FIFO_HEAD_M:
+			move_next_frame(&data_index, BMI160_FIFO_M_LENGTH, dev);
+			break;
+		case BMI160_FIFO_HEAD_M_A:
+			move_next_frame(&data_index, BMI160_FIFO_M_LENGTH, dev);
+			break;
+			/* Sensor time frame */
+		case BMI160_FIFO_HEAD_SENSOR_TIME:
+			unpack_sensortime_frame(&data_index, dev);
+			break;
+			/* Skip frame */
+		case BMI160_FIFO_HEAD_SKIP_FRAME:
+			unpack_skipped_frame(&data_index, dev);
+			break;
+			/* Input config frame */
+		case BMI160_FIFO_HEAD_INPUT_CONFIG:
+			move_next_frame(&data_index, 1, dev);
+			break;
+		case BMI160_FIFO_HEAD_OVER_READ:
+			/* Update the data index as complete in case of over read */
+			data_index = dev->fifo->length;
+			break;
+		default:
+			break;
 		}
 	}
-	*v_outflow_u8 = 0;
-	for (i = 0; i < 3; i++) {
-		if (YAS537_DATA_OVERFLOW <= xy1y2[i])
-			*v_outflow_u8 |= (1 << (i * 2));
-		if (xy1y2[i] == YAS537_DATA_UNDERFLOW)
-			*v_outflow_u8 |= (1 << (i * 2 + 1));
-	}
-
-	return com_rslt;
 
+	/*Update number of gyro data read*/
+	*gyro_length = gyro_index;
+	/*Update the gyro frame index*/
+	dev->fifo->gyro_byte_start_idx = data_index;
 }
+
 /*!
- *	@brief This function is used for detecting whether the mag
- *  data obtained is valid or not
- *
- *
- *	@param v_cur_u16: The value of current Mag data
- *  @param v_last_u16: The value of last Mag data
- *
- *
- *	@return results of magnetic field data's validity
- *	@retval 0 -> VALID DATA
- *	@retval 1 -> INVALID DATA
- *
- *
+ *  @brief This API checks the presence of non-valid frames in the read fifo data.
  */
-static BMI160_RETURN_FUNCTION_TYPE invalid_magnetic_field(
-u16 *v_cur_u16, u16 *v_last_u16)
+static void check_frame_validity(uint16_t *data_index, const struct bmi160_dev *dev)
 {
-	s16 invalid_thresh[] = {1500, 1500, 1500};
-	u8 i = BMI160_INIT_VALUE;
-
-	for (i = 0; i < 3; i++)
-		if (invalid_thresh[i] < ABS(v_cur_u16[i] - v_last_u16[i]))
-			return 1;
-	return 0;
+	if ((*data_index + 2) < dev->fifo->length) {
+		/* Check if FIFO is empty */
+		if ((dev->fifo->data[*data_index] == FIFO_CONFIG_MSB_CHECK)
+			&& (dev->fifo->data[*data_index + 1] == FIFO_CONFIG_LSB_CHECK)) {
+			/*Update the data index as complete*/
+			*data_index = dev->fifo->length;
+		}
+	}
 }
+
 /*!
- *	@brief This function is used to read the
- *	YAMAHA YAS537 xy1y2 data
- *
- *	@param v_outflow_u8: The value of overflow
- *	@param *vector_xyz : yas vector structure pointer
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
+ *  @brief This API is used to move the data index ahead of the
+ *  current_frame_length parameter when unnecessary FIFO data appears while
+ *  extracting the user specified data.
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas537_measure_xyz_data(
-u8 *v_outflow_u8, struct yas_vector *vector_xyz)
+static void move_next_frame(uint16_t *data_index, uint8_t current_frame_length, const struct bmi160_dev *dev)
 {
-	s32 a_xyz_tmp_s32[BMI160_YAS_TEMP_DATA_SIZE] = {
-	BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
-	u8 i = BMI160_INIT_VALUE;
-	s8 com_rslt = BMI160_INIT_VALUE;
-	u8 v_busy_u8 = BMI160_INIT_VALUE;
-	u8 v_rcoil_u8 = BMI160_INIT_VALUE;
-	u16 v_temperature_u16 = BMI160_INIT_VALUE;
-	u16 a_xy1y2_u16[BMI160_YAS_XY1Y2_DATA_SIZE] = {
-	BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
-	*v_outflow_u8 = 0;
-	/* read the yas537 xy1y2 data*/
-	com_rslt = bmi160_bst_yamaha_yas537_read_xy1y2_data(
-	&v_rcoil_u8, &v_busy_u8,
-	&v_temperature_u16, a_xy1y2_u16, v_outflow_u8);
-	/* linear calculation*/
-	xy1y2_to_xyz(a_xy1y2_u16, vector_xyz->yas537_vector_xyz);
-	if (yas537_data.transform != BMI160_NULL) {
-		for (i = 0; i < 3; i++) {
-			a_xyz_tmp_s32[i] = ((
-			yas537_data.transform[i + 3]
-			* vector_xyz->yas537_vector_xyz[0])
-			+ (yas537_data.transform[
-			i * 3 + 1]
-			* vector_xyz->yas537_vector_xyz[1])
-			+ (yas537_data.transform[
-			i * 3 + 2]
-			* vector_xyz->yas537_vector_xyz[2]));
-		}
-		yas537_set_vector(
-		vector_xyz->yas537_vector_xyz, a_xyz_tmp_s32);
-	}
-	for (i = 0; i < 3; i++) {
-		vector_xyz->yas537_vector_xyz[i] -=
-		vector_xyz->yas537_vector_xyz[i] % 10;
-		if (*v_outflow_u8 & (1 <<
-		(i * 2)))
-			vector_xyz->yas537_vector_xyz[i] +=
-			1; /* set overflow */
-		if (*v_outflow_u8 & (1 << (i * 2 + 1)))
-			/* set underflow */
-			vector_xyz->yas537_vector_xyz[i] += 2;
-	}
-	if (v_busy_u8)
-		return ERROR;
-	switch (yas537_data.measure_state) {
-	case YAS537_MAG_STATE_INIT_COIL:
-		if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE)
-			com_rslt = bmi160_set_mag_manual_enable(
-			BMI160_MANUAL_ENABLE);
-		com_rslt += bmi160_set_mag_write_data(YAS537_WRITE_CONFR);
-		p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-		com_rslt += bmi160_set_mag_write_addr(YAS537_REG_CONFR);
-		p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-		yas537_data.measure_state = YAS537_MAG_STATE_RECORD_DATA;
-		if (p_bmi160->mag_manual_enable == BMI160_MANUAL_ENABLE)
-			com_rslt = bmi160_set_mag_manual_enable(
-			BMI160_MANUAL_DISABLE);
-	break;
-	case YAS537_MAG_STATE_RECORD_DATA:
-		if (v_rcoil_u8)
-			break;
-		yas537_set_vector(yas537_data.last_after_rcoil, a_xy1y2_u16);
-		yas537_data.measure_state = YAS537_MAG_STATE_NORMAL;
-	break;
-	case YAS537_MAG_STATE_NORMAL:
-		if (BMI160_INIT_VALUE < v_outflow_u8
-		|| invalid_magnetic_field(a_xy1y2_u16,
-		yas537_data.last_after_rcoil)) {
-			yas537_data.measure_state = YAS537_MAG_STATE_INIT_COIL;
-			for (i = 0; i < 3; i++) {
-				if (!*v_outflow_u8)
-					vector_xyz->yas537_vector_xyz[i] += 3;
-			}
-		}
-	break;
+	/*Partial read, then move the data index to last data*/
+	if ((*data_index + current_frame_length) > dev->fifo->length) {
+		/*Update the data index as complete*/
+		*data_index = dev->fifo->length;
+	} else {
+		/*Move the data index to next frame*/
+		*data_index = *data_index + current_frame_length;
 	}
-
-	return com_rslt;
 }
+
 /*!
- *	@brief This function is used to read the
- *	YAMAHA YAS537 xy1y2 data of fifo
- *
- *	@param a_xy1y2_u16: The value of xyy1 data
- *	@param v_over_flow_u8: The value of overflow
- *	@param v_rcoil_u8: The value of rcoil
- *	@param v_busy_u8: The value of busy flag
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
+ *  @brief This API is used to parse and store the sensor time from the
+ *  FIFO data in the structure instance dev.
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas537_fifo_xyz_data(
-u16 *a_xy1y2_u16, u8 v_over_flow_u8, u8 v_rcoil_u8, u8 v_busy_u8)
+static void unpack_sensortime_frame(uint16_t *data_index, const struct bmi160_dev *dev)
 {
+	uint32_t sensor_time_byte3 = 0;
+	uint16_t sensor_time_byte2 = 0;
+	uint8_t sensor_time_byte1 = 0;
 
-s32 a_xyz_tmp_s32[BMI160_YAS_TEMP_DATA_SIZE] = {
-BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
-u8 i = BMI160_INIT_VALUE;
-s8 com_rslt = BMI160_INIT_VALUE;
-/* linear calculation*/
-xy1y2_to_xyz(a_xy1y2_u16, fifo_vector_xyz.yas537_vector_xyz);
-if (yas537_data.transform != BMI160_NULL) {
-	for (i = 0; i < 3; i++) {
-		a_xyz_tmp_s32[i] = ((
-		yas537_data.transform[i + 3]
-		* fifo_vector_xyz.yas537_vector_xyz[0])
-		+ (yas537_data.transform[
-		i * 3 + 1]
-		* fifo_vector_xyz.yas537_vector_xyz[1])
-		+ (yas537_data.transform[
-		i * 3 + 2]
-		* fifo_vector_xyz.yas537_vector_xyz[2]));
+	/*Partial read, then move the data index to last data*/
+	if ((*data_index + BMI160_SENSOR_TIME_LENGTH) > dev->fifo->length) {
+		/*Update the data index as complete*/
+		*data_index = dev->fifo->length;
+	} else {
+		sensor_time_byte3 = dev->fifo->data[(*data_index) + BMI160_SENSOR_TIME_MSB_BYTE] << 16;
+		sensor_time_byte2 = dev->fifo->data[(*data_index) + BMI160_SENSOR_TIME_XLSB_BYTE] << 8;
+		sensor_time_byte1 = dev->fifo->data[(*data_index)];
+		/* Sensor time */
+		dev->fifo->sensor_time = (uint32_t)(sensor_time_byte3 | sensor_time_byte2 | sensor_time_byte1);
+		*data_index = (*data_index) + BMI160_SENSOR_TIME_LENGTH;
 	}
-	yas537_set_vector(
-	fifo_vector_xyz.yas537_vector_xyz, a_xyz_tmp_s32);
 }
-for (i = 0; i < 3; i++) {
-	fifo_vector_xyz.yas537_vector_xyz[i] -=
-	fifo_vector_xyz.yas537_vector_xyz[i] % 10;
-	if (v_over_flow_u8 & (1 <<
-	(i * 2)))
-		fifo_vector_xyz.yas537_vector_xyz[i] +=
-		1; /* set overflow */
-	if (v_over_flow_u8 & (1 << (i * 2 + 1)))
-		/* set underflow */
-		fifo_vector_xyz.yas537_vector_xyz[i] += 2;
-}
-if (v_busy_u8)
-	return ERROR;
-switch (yas537_data.measure_state) {
-case YAS537_MAG_STATE_INIT_COIL:
-	if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE)
-		com_rslt = bmi160_set_mag_manual_enable(
-		BMI160_MANUAL_ENABLE);
-	com_rslt += bmi160_set_mag_write_data(YAS537_WRITE_CONFR);
-	p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	com_rslt += bmi160_set_mag_write_addr(YAS537_REG_CONFR);
-	p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-	yas537_data.measure_state = YAS537_MAG_STATE_RECORD_DATA;
-	if (p_bmi160->mag_manual_enable == BMI160_MANUAL_ENABLE)
-		com_rslt = bmi160_set_mag_manual_enable(
-		BMI160_MANUAL_DISABLE);
-break;
-case YAS537_MAG_STATE_RECORD_DATA:
-	if (v_rcoil_u8)
-		break;
-	yas537_set_vector(yas537_data.last_after_rcoil, a_xy1y2_u16);
-	yas537_data.measure_state = YAS537_MAG_STATE_NORMAL;
-break;
-case YAS537_MAG_STATE_NORMAL:
-	if (BMI160_INIT_VALUE < v_over_flow_u8
-	|| invalid_magnetic_field(a_xy1y2_u16,
-	yas537_data.last_after_rcoil)) {
-		yas537_data.measure_state = YAS537_MAG_STATE_INIT_COIL;
-		for (i = 0; i < 3; i++) {
-			if (!v_over_flow_u8)
-				fifo_vector_xyz.yas537_vector_xyz[i]
-				+= 3;
-		}
+
+/*!
+ *  @brief This API is used to parse and store the skipped_frame_count from
+ *  the FIFO data in the structure instance dev.
+ */
+static void unpack_skipped_frame(uint16_t *data_index, const struct bmi160_dev *dev)
+{
+	/*Partial read, then move the data index to last data*/
+	if (*data_index >= dev->fifo->length) {
+		/*Update the data index as complete*/
+		*data_index = dev->fifo->length;
+	} else {
+		dev->fifo->skipped_frame_count = dev->fifo->data[*data_index];
+		/*Move the data index*/
+		*data_index = (*data_index) + 1;
 	}
-break;
 }
 
-return com_rslt;
-
-}
-#endif
+/** @}*/

+ 389 - 11666
bmi160.h

@@ -1,11802 +1,525 @@
-/** \mainpage
-*
-****************************************************************************
-* Copyright (C) 2016 Bosch Sensortec GmbH
-*
-* File : bmi160.h
-*
-* Date : 2016/06/27
-*
-* Revision : 2.2.1 $
-*
-* Usage: Sensor Driver for BMI160 sensor
-*
-****************************************************************************
-*
-* \section License
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-*
-*   Redistributions of source code must retain the above copyright
-*   notice, this list of conditions and the following disclaimer.
-*
-*   Redistributions in binary form must reproduce the above copyright
-*   notice, this list of conditions and the following disclaimer in the
-*   documentation and/or other materials provided with the distribution.
-*
-*   Neither the name of the copyright holder nor the names of the
-*   contributors may be used to endorse or promote products derived from
-*   this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
-* OR CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-* OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO,
-* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-* ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
-*
-* The information provided is believed to be accurate and reliable.
-* The copyright holder 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 the copyright holder.
-**************************************************************************/
-
-/*! \file bmi160.h
-    \brief BMI160 Sensor Driver Support Header File */
-/* user defined code to be added here ... */
-#ifndef __BMI160_H__
-#define __BMI160_H__
-
-/*!
-* @brief The following definition is used to define the data types
-*
-* @note While porting the API please consider the following
-* @note Please check the version of C standard
-* @note Are you using Linux platform
-*/
-
-/*!
-* @brief For the Linux platform support
-* Please use the types.h for your data types definitions
-*/
-#ifdef	__KERNEL__
-
-#include <linux/types.h>
-/* singed integer type*/
-typedef	int8_t s8;/**< used for signed 8bit */
-typedef	int16_t s16;/**< used for signed 16bit */
-typedef	int32_t s32;/**< used for signed 32bit */
-typedef	int64_t s64;/**< used for signed 64bit */
-
-typedef	u_int8_t u8;/**< used for unsigned 8bit */
-typedef	u_int16_t u16;/**< used for unsigned 16bit */
-typedef	u_int32_t u32;/**< used for unsigned 32bit */
-typedef	u_int64_t u64;/**< used for unsigned 64bit */
-
-
-
-#else /* ! __KERNEL__ */
-/**********************************************************
-* below definitions are used to define the C
-* standard version data types
-***********************************************************/
-# if !defined(__STDC_VERSION__)
-
-/************************************************
- * compiler is C11 C standard
-************************************************/
-#if (__STDC_VERSION__ == 201112L)
-
-/************************************************/
-#include <stdint.h>
-/************************************************/
-
-/*unsigned integer types*/
-typedef	uint8_t u8;/**< used for unsigned 8bit */
-typedef	uint16_t u16;/**< used for unsigned 16bit */
-typedef	uint32_t u32;/**< used for unsigned 32bit */
-typedef	uint64_t u64;/**< used for unsigned 64bit */
-
-/*signed integer types*/
-typedef	int8_t s8;/**< used for signed 8bit */
-typedef	int16_t s16;/**< used for signed 16bit */
-typedef	int32_t s32;/**< used for signed 32bit */
-typedef	int64_t s64;/**< used for signed 64bit */
-/************************************************
- * compiler is C99 C standard
-************************************************/
-
-#elif (__STDC_VERSION__ == 199901L)
-
-/* stdint.h is a C99 supported c library.
-which is used to fix the integer size*/
-/************************************************/
-#include <stdint.h>
-/************************************************/
-
-/*unsigned integer types*/
-typedef	uint8_t u8;/**< used for unsigned 8bit */
-typedef	uint16_t u16;/**< used for unsigned 16bit */
-typedef	uint32_t u32;/**< used for unsigned 32bit */
-typedef	uint64_t u64;/**< used for unsigned 64bit */
-
-/*signed integer types*/
-typedef int8_t s8;/**< used for signed 8bit */
-typedef	int16_t s16;/**< used for signed 16bit */
-typedef	int32_t s32;/**< used for signed 32bit */
-typedef	int64_t s64;/**< used for signed 64bit */
-/************************************************
- * compiler is C89 or other C standard
-************************************************/
-
-#else /*  !defined(__STDC_VERSION__) */
-/*!
-* @brief By default it is defined as 32 bit machine configuration
-*	define your data types based on your
-*	machine/compiler/controller configuration
-*/
-#define  MACHINE_32_BIT
-
-/*! @brief
- *	If your machine support 16 bit
- *	define the MACHINE_16_BIT
- */
-#ifdef MACHINE_16_BIT
-#include <limits.h>
-/*signed integer types*/
-typedef	signed char  s8;/**< used for signed 8bit */
-typedef	signed short int s16;/**< used for signed 16bit */
-typedef	signed long int s32;/**< used for signed 32bit */
-
-#if defined(LONG_MAX) && LONG_MAX == 0x7fffffffffffffffL
-typedef long int s64;/**< used for signed 64bit */
-typedef unsigned long int u64;/**< used for unsigned 64bit */
-#elif defined(LLONG_MAX) && (LLONG_MAX == 0x7fffffffffffffffLL)
-typedef long long int s64;/**< used for signed 64bit */
-typedef unsigned long long int u64;/**< used for unsigned 64bit */
-#else
-#warning Either the correct data type for signed 64 bit integer \
-could not be found, or 64 bit integers are not supported in your environment.
-#warning If 64 bit integers are supported on your platform, \
-please set s64 manually.
-#endif
-
-/*unsigned integer types*/
-typedef	unsigned char u8;/**< used for unsigned 8bit */
-typedef	unsigned short int u16;/**< used for unsigned 16bit */
-typedef	unsigned long int u32;/**< used for unsigned 32bit */
-
-/* If your machine support 32 bit
-define the MACHINE_32_BIT*/
-#elif defined MACHINE_32_BIT
-/*signed integer types*/
-typedef	signed char  s8;/**< used for signed 8bit */
-typedef	signed short int s16;/**< used for signed 16bit */
-typedef	signed int s32;/**< used for signed 32bit */
-typedef	signed long long int s64;/**< used for signed 64bit */
-
-/*unsigned integer types*/
-typedef	unsigned char u8;/**< used for unsigned 8bit */
-typedef	unsigned short int u16;/**< used for unsigned 16bit */
-typedef	unsigned int u32;/**< used for unsigned 32bit */
-typedef	unsigned long long int u64;/**< used for unsigned 64bit */
-
-/* If your machine support 64 bit
-define the MACHINE_64_BIT*/
-#elif defined MACHINE_64_BIT
-/*signed integer types*/
-typedef	signed char  s8;/**< used for signed 8bit */
-typedef	signed short int s16;/**< used for signed 16bit */
-typedef	signed int s32;/**< used for signed 32bit */
-typedef	signed long int s64;/**< used for signed 64bit */
-
-/*unsigned integer types*/
-typedef	unsigned char u8;/**< used for unsigned 8bit */
-typedef	unsigned short int u16;/**< used for unsigned 16bit */
-typedef	unsigned int u32;/**< used for unsigned 32bit */
-typedef	unsigned long int u64;/**< used for unsigned 64bit */
-
-#else
-#warning The data types defined above which not supported \
-define the data types manually
-#endif
-#endif
-
-/* This else part will be executed for the compilers
-which does not support the C89/C99/C11 standards ***/
-#else
-/*!
-* @brief By default it is defined as 32 bit machine configuration
-*	define your data types based on your
-*	machine/compiler/controller configuration
-*/
-#define  MACHINE_32_BIT
-
-/* If your machine support 16 bit
-define the MACHINE_16_BIT*/
-#ifdef MACHINE_16_BIT
-#include <limits.h>
-/*signed integer types*/
-typedef	signed char  s8;/**< used for signed 8bit */
-typedef	signed short int s16;/**< used for signed 16bit */
-typedef	signed long int s32;/**< used for signed 32bit */
-
-#if defined(LONG_MAX) && LONG_MAX == 0x7fffffffffffffffL
-typedef long int s64;/**< used for signed 64bit */
-typedef unsigned long int u64;/**< used for unsigned 64bit */
-#elif defined(LLONG_MAX) && (LLONG_MAX == 0x7fffffffffffffffLL)
-typedef long long int s64;/**< used for signed 64bit */
-typedef unsigned long long int u64;/**< used for unsigned 64bit */
-#else
-#warning Either the correct data type for signed 64 bit integer \
-could not be found, or 64 bit integers are not supported in your environment.
-#warning If 64 bit integers are supported on your platform, \
-please set s64 manually.
-#endif
-
-/*unsigned integer types*/
-typedef	unsigned char u8;/**< used for unsigned 8bit */
-typedef	unsigned short int u16;/**< used for unsigned 16bit */
-typedef	unsigned long int u32;/**< used for unsigned 32bit */
-
-/*! @brief If your machine support 32 bit
-define the MACHINE_32_BIT*/
-#elif defined MACHINE_32_BIT
-/*signed integer types*/
-typedef	signed char  s8;/**< used for signed 8bit */
-typedef	signed short int s16;/**< used for signed 16bit */
-typedef	signed int s32;/**< used for signed 32bit */
-typedef	signed long long int s64;/**< used for signed 64bit */
-
-/*unsigned integer types*/
-typedef	unsigned char u8;/**< used for unsigned 8bit */
-typedef	unsigned short int u16;/**< used for unsigned 16bit */
-typedef	unsigned int u32;/**< used for unsigned 32bit */
-typedef	unsigned long long int u64;/**< used for unsigned 64bit */
-
-/* If your machine support 64 bit
-define the MACHINE_64_BIT*/
-#elif defined MACHINE_64_BIT
-/*signed integer types*/
-typedef	signed char  s8;/**< used for signed 8bit */
-typedef	signed short int s16;/**< used for signed 16bit */
-typedef	signed int s32;/**< used for signed 32bit */
-typedef	signed long int s64;/**< used for signed 64bit */
-
-/*unsigned integer types*/
-typedef	unsigned char u8;/**< used for unsigned 8bit */
-typedef	unsigned short int u16;/**< used for unsigned 16bit */
-typedef	unsigned int u32;/**< used for unsigned 32bit */
-typedef	unsigned long int u64;/**< used for unsigned 64bit */
-
-#else
-#warning If the data types defined above are not supported \
-then define the data types manually
-#endif
-#endif
-#endif
-/***************************************************************/
-/**\name	BUS READ AND WRITE FUNCTION POINTERS        */
-/***************************************************************/
-/*!
-	@brief Define the calling convention of your bus communication routine.
-	@note This includes types of parameters. This example shows the
-	configuration for an SPI bus link.
-
-    If your communication function looks like this:
-
-    write_my_bus_xy(u8 device_addr, u8 register_addr,
-    u8 * data, u8 length);
-
-    The BMI160_WR_FUNC_PTR would equal:
-
-    BMI160_WR_FUNC_PTR s8 (* bus_write)(u8,
-    u8, u8 *, u8)
-
-    Parameters can be mixed as needed refer to the
-    @ref BMI160_BUS_WRITE_FUNC  macro.
-
-
-*/
-#define BMI160_WR_FUNC_PTR s8 (*bus_write)(u8, u8,\
-u8 *, u8)
-/**< link macro between API function calls and bus write function
-	@note The bus write function can change since this is a
-	system dependant issue.
-
-    If the bus_write parameter calling order is like: reg_addr,
-    reg_data, wr_len it would be as it is here.
-
-    If the parameters are differently ordered or your communication
-    function like I2C need to know the device address,
-    you can change this macro accordingly.
-
-
-    BMI160_BUS_WRITE_FUNC(dev_addr, reg_addr, reg_data, wr_len)\
-    bus_write(dev_addr, reg_addr, reg_data, wr_len)
-
-    This macro lets all API functions call your communication routine in a
-    way that equals your definition in the
-    @ref BMI160_WR_FUNC_PTR definition.
-
-*/
-#define BMI160_BUS_WRITE_FUNC(dev_addr, reg_addr, reg_data, wr_len)\
-				bus_write(dev_addr, reg_addr, reg_data, wr_len)
-
-/**< Define the calling convention of your bus communication routine.
-	@note This includes types of parameters. This example shows the
-	configuration for an SPI bus link.
-
-    If your communication function looks like this:
-
-    read_my_bus_xy(u8 device_addr, u8 register_addr,
-    u8 * data, u8 length);
-
-    The BMI160_RD_FUNC_PTR would equal:
-
-    BMI160_RD_FUNC_PTR s8 (* bus_read)(u8,
-    u8, u8 *, u8)
-
-    Parameters can be mixed as needed refer to the
-    refer BMI160_BUS_READ_FUNC  macro.
-
-*/
-#define BMI160_SPI_RD_MASK (0x80)   /* for spi read transactions on SPI the
-			MSB has to be set */
-#define BMI160_RD_FUNC_PTR s8 (*bus_read)(u8,\
-			u8, u8 *, u8)
-
-#define BMI160_BRD_FUNC_PTR s8 \
-(*burst_read)(u8, u8, u8 *, u32)
-
-/**< link macro between API function calls and bus read function
-	@note The bus write function can change since this is a
-	system dependant issue.
-
-    If the bus_read parameter calling order is like: reg_addr,
-    reg_data, wr_len it would be as it is here.
-
-    If the parameters are differently ordered or your communication
-    function like I2C need to know the device address,
-    you can change this macro accordingly.
-
-
-    BMI160_BUS_READ_FUNC(dev_addr, reg_addr, reg_data, wr_len)\
-    bus_read(dev_addr, reg_addr, reg_data, wr_len)
-
-    This macro lets all API functions call your communication routine in a
-    way that equals your definition in the
-    refer BMI160_WR_FUNC_PTR definition.
-
-    @note: this macro also includes the "MSB='1'
-    for reading BMI160 addresses.
-
-*/
-#define BMI160_BUS_READ_FUNC(dev_addr, reg_addr, reg_data, r_len)\
-				bus_read(dev_addr, reg_addr, reg_data, r_len)
-
-#define BMI160_BURST_READ_FUNC(device_addr, \
-register_addr, register_data, rd_len)\
-burst_read(device_addr, register_addr, register_data, rd_len)
-
-/* enable the macro for FIFO functionalities when FIFO is used*/
-#define FIFO_ENABLE
-/* enable the macro of the secondary interface which is used */
-
-#define YAS537 /* used to select the secondary interface as YAS537 */
-#define YAS532  /* used to select the secondary interface as YAS532 */
-#define AKM09911 /* used to select the secondary interface as AKM09911 */
-#define AKM09912 /* used to select the secondary interface as AKM09912 */
-
-#define BMI160_MDELAY_DATA_TYPE                 u32
-
-/***************************************************************/
-/**\name	BUS READ AND WRITE FUNCTION POINTERS        */
-/***************************************************************/
-#define BMI160_I2C_ADDR1                   (0x68)
-/**< I2C Address needs to be changed */
-#define BMI160_I2C_ADDR2                    (0x69)
- /**< I2C Address needs to be changed */
-#define BMI160_AUX_BMM150_I2C_ADDRESS       (0x10)
-/**< I2C address of BMM150*/
-#define BMI160_AUX_YAS532_I2C_ADDRESS       (0x2E)
-/**< I2C address of YAS532*/
-#define	BMI160_AUX_AKM09911_I2C_ADDR_1		(0x0C)
-/**< I2C address of AKM09911*/
-#define	BMI160_AUX_AKM09911_I2C_ADDR_2		(0x0D)
-/**< I2C address of AKM09911*/
-#define	BMI160_AUX_AKM09912_I2C_ADDR_1		(0x0C)
-/**< I2C address of AKM09912*/
-#define	BMI160_AUX_AKM09912_I2C_ADDR_2		(0x0D)
-/**< I2C address of AKM09912*/
-#define	BMI160_AUX_AKM09912_I2C_ADDR_3		(0x0E)
-/**< I2C address of AKM09912*/
-#define	BMI160_AUX_AKM09912_I2C_ADDR_4		(0x0F)
-/**< I2C address of AKM09912*/
-/*******************************************/
-/**\name	CONSTANTS        */
-/******************************************/
-#define  BMI160_INIT_VALUE					(0)
-#define  BMI160_ASSIGN_DATA                 (1)
-#define  BMI160_GEN_READ_WRITE_DATA_LENGTH	(1)
-#define  BMI160_MAXIMUM_TIMEOUT             (10)
-
-/* output data rate condition check*/
-#define  BMI160_OUTPUT_DATA_RATE0	(0)
-#define  BMI160_OUTPUT_DATA_RATE1	(1)
-#define  BMI160_OUTPUT_DATA_RATE2	(2)
-#define  BMI160_OUTPUT_DATA_RATE3	(3)
-#define  BMI160_OUTPUT_DATA_RATE4	(4)
-#define  BMI160_OUTPUT_DATA_RATE5	(5)
-#define  BMI160_OUTPUT_DATA_RATE6	(14)
-#define  BMI160_OUTPUT_DATA_RATE7	(15)
-
-/*unmap significant motion*/
-#define V_ANY_MOTION_INTR_STAT   (4)
-#define V_ANY_MOTION_AXIS_STAT   (7)
-
-/* Accel range check*/
-#define BMI160_ACCEL_RANGE0  (3)
-#define BMI160_ACCEL_RANGE1  (5)
-#define BMI160_ACCEL_RANGE3  (8)
-#define BMI160_ACCEL_RANGE4  (12)
-
-/* check the status of registers*/
-#define  BMI160_FOC_STAT_HIGH			(1)
-#define  BMI160_SIG_MOTION_STAT_HIGH	(1)
-#define  BMI160_STEP_DET_STAT_HIGH		(1)
-
-/*condition check for reading and writing data*/
-#define	BMI160_MAX_VALUE_SIGNIFICANT_MOTION      (1)
-#define	BMI160_MAX_VALUE_FIFO_FILTER    (1)
-#define	BMI160_MAX_VALUE_FIFO_TIME      (1)
-#define	BMI160_MAX_VALUE_FIFO_INTR      (1)
-#define	BMI160_MAX_VALUE_FIFO_HEADER    (1)
-#define	BMI160_MAX_VALUE_FIFO_MAG       (1)
-#define	BMI160_MAX_VALUE_FIFO_ACCEL     (1)
-#define	BMI160_MAX_VALUE_FIFO_GYRO      (1)
-#define	BMI160_MAX_VALUE_SOURCE_INTR    (1)
-#define	BMI160_MAX_VALUE_LOW_G_MODE     (1)
-#define	BMI160_MAX_VALUE_NO_MOTION      (1)
-#define	BMI160_MAX_VALUE_TAP_SHOCK      (1)
-#define	BMI160_MAX_VALUE_TAP_QUIET      (1)
-#define	BMI160_MAX_VALUE_ORIENT_UD      (1)
-#define	BMI160_MAX_VALUE_ORIENT_AXES    (1)
-
-#define	BMI160_MAX_VALUE_SPI3           (1)
-#define	BMI160_MAX_VALUE_I2C_WDT        (1)
-#define	BMI160_MAX_VALUE_SLEEP_STATE    (1)
-#define	BMI160_MAX_VALUE_WAKEUP_INTR    (1)
-#define	BMI160_MAX_VALUE_SELFTEST_SIGN  (1)
-#define	BMI160_MAX_VALUE_SELFTEST_AMP   (1)
-#define	BMI160_MAX_VALUE_SELFTEST_START (1)
-
-#define BMI160_MAX_GYRO_WAKEUP_TRIGGER		(3)
-#define BMI160_MAX_ACCEL_SELFTEST_AXIS	    (3)
-#define BMI160_MAX_GYRO_STEP_COUNTER        (1)
-#define BMI160_MAX_GYRO_BW                  (3)
-#define BMI160_MAX_ACCEL_BW                 (7)
-#define BMI160_MAX_ORIENT_MODE              (3)
-#define BMI160_MAX_ORIENT_BLOCKING          (3)
-#define BMI160_MAX_FLAT_HOLD                (3)
-#define BMI160_MAX_ACCEL_FOC                (3)
-#define BMI160_MAX_IF_MODE                  (3)
-
-#define BMI160_MAX_GYRO_RANGE               (4)
-#define BMI160_MAX_GYRO_SLEEP_TRIGGER        (7)
-#define BMI160_MAX_TAP_TURN                 (7)
-#define BMI160_MAX_UNDER_SAMPLING           (1)
-#define BMI160_MAX_UNDER_SIG_MOTION         (3)
-#define BMI160_MAX_ACCEL_OUTPUT_DATA_RATE   (12)
-#define BMI160_MAX_LATCH_INTR               (15)
-#define BMI160_MAX_FLAT_HYST                (15)
-#define BMI160_MAX_ORIENT_THETA             (63)
-#define BMI160_MAX_FLAT_THETA               (63)
-
-#ifdef FIFO_ENABLE
-/* FIFO index definitions*/
-#define BMI160_FIFO_X_LSB_DATA			(0)
-#define BMI160_FIFO_X_MSB_DATA			(1)
-#define BMI160_FIFO_Y_LSB_DATA			(2)
-#define BMI160_FIFO_Y_MSB_DATA			(3)
-#define BMI160_FIFO_Z_LSB_DATA			(4)
-#define BMI160_FIFO_Z_MSB_DATA			(5)
-#define BMI160_FIFO_R_LSB_DATA			(6)
-#define BMI160_FIFO_R_MSB_DATA			(7)
-/* FIFO Gyro  definition*/
-#define BMI160_GA_FIFO_G_X_LSB		(0)
-#define BMI160_GA_FIFO_G_X_MSB		(1)
-#define BMI160_GA_FIFO_G_Y_LSB		(2)
-#define BMI160_GA_FIFO_G_Y_MSB		(3)
-#define BMI160_GA_FIFO_G_Z_LSB		(4)
-#define BMI160_GA_FIFO_G_Z_MSB		(5)
-#define BMI160_GA_FIFO_A_X_LSB		(6)
-#define BMI160_GA_FIFO_A_X_MSB		(7)
-#define BMI160_GA_FIFO_A_Y_LSB		(8)
-#define BMI160_GA_FIFO_A_Y_MSB		(9)
-#define BMI160_GA_FIFO_A_Z_LSB		(10)
-#define BMI160_GA_FIFO_A_Z_MSB		(11)
-/* FIFO mag/gyro/accel definition*/
-#define BMI160_MGA_FIFO_M_X_LSB		(0)
-#define BMI160_MGA_FIFO_M_X_MSB		(1)
-#define BMI160_MGA_FIFO_M_Y_LSB		(2)
-#define BMI160_MGA_FIFO_M_Y_MSB		(3)
-#define BMI160_MGA_FIFO_M_Z_LSB		(4)
-#define BMI160_MGA_FIFO_M_Z_MSB		(5)
-#define BMI160_MGA_FIFO_M_R_LSB		(6)
-#define BMI160_MGA_FIFO_M_R_MSB		(7)
-#define BMI160_MGA_FIFO_G_X_LSB		(8)
-#define BMI160_MGA_FIFO_G_X_MSB		(9)
-#define BMI160_MGA_FIFO_G_Y_LSB		(10)
-#define BMI160_MGA_FIFO_G_Y_MSB		(11)
-#define BMI160_MGA_FIFO_G_Z_LSB		(12)
-#define BMI160_MGA_FIFO_G_Z_MSB		(13)
-#define BMI160_MGA_FIFO_A_X_LSB		(14)
-#define BMI160_MGA_FIFO_A_X_MSB		(15)
-#define BMI160_MGA_FIFO_A_Y_LSB		(16)
-#define BMI160_MGA_FIFO_A_Y_MSB		(17)
-#define BMI160_MGA_FIFO_A_Z_LSB		(18)
-#define BMI160_MGA_FIFO_A_Z_MSB		(19)
-/* FIFO Mag definition*/
-#define BMI160_MA_FIFO_M_X_LSB		(0)
-#define BMI160_MA_FIFO_M_X_MSB		(1)
-#define BMI160_MA_FIFO_M_Y_LSB		(2)
-#define BMI160_MA_FIFO_M_Y_MSB		(3)
-#define BMI160_MA_FIFO_M_Z_LSB		(4)
-#define BMI160_MA_FIFO_M_Z_MSB		(5)
-#define BMI160_MA_FIFO_M_R_LSB		(6)
-#define BMI160_MA_FIFO_M_R_MSB		(7)
-#define BMI160_MA_FIFO_A_X_LSB		(8)
-#define BMI160_MA_FIFO_A_X_MSB		(9)
-#define BMI160_MA_FIFO_A_Y_LSB		(10)
-#define BMI160_MA_FIFO_A_Y_MSB		(11)
-#define BMI160_MA_FIFO_A_Z_LSB		(12)
-#define BMI160_MA_FIFO_A_Z_MSB		(13)
-/* FIFO mag/gyro definition*/
-#define BMI160_MG_FIFO_M_X_LSB		(0)
-#define BMI160_MG_FIFO_M_X_MSB		(1)
-#define BMI160_MG_FIFO_M_Y_LSB		(2)
-#define BMI160_MG_FIFO_M_Y_MSB		(3)
-#define BMI160_MG_FIFO_M_Z_LSB		(4)
-#define BMI160_MG_FIFO_M_Z_MSB		(5)
-#define BMI160_MG_FIFO_M_R_LSB		(6)
-#define BMI160_MG_FIFO_M_R_MSB		(7)
-#define BMI160_MG_FIFO_G_X_LSB		(8)
-#define BMI160_MG_FIFO_G_X_MSB		(9)
-#define BMI160_MG_FIFO_G_Y_LSB		(10)
-#define BMI160_MG_FIFO_G_Y_MSB		(11)
-#define BMI160_MG_FIFO_G_Z_LSB		(12)
-#define BMI160_MG_FIFO_G_Z_MSB		(13)
-/* FIFO length definitions*/
-#define BMI160_FIFO_SENSOR_TIME_LSB     (0)
-#define BMI160_FIFO_SENSOR_TIME_XLSB    (1)
-#define BMI160_FIFO_SENSOR_TIME_MSB     (2)
-#define BMI160_FIFO_SENSOR_TIME_LENGTH  (3)
-#define BMI160_FIFO_A_LENGTH            (6)
-#define BMI160_FIFO_G_LENGTH            (6)
-#define BMI160_FIFO_M_LENGTH            (8)
-#define BMI160_FIFO_AG_LENGTH           (12)
-#define BMI160_FIFO_AMG_LENGTH          (20)
-#define BMI160_FIFO_MA_OR_MG_LENGTH     (14)
-#define	BMI160_FIFO_LENGTH_LSB_BYTE    (0)
-#define	BMI160_FIFO_LENGTH_MSB_BYTE    (1)
-
-#endif
-
-/* bus read and write length for mag, Accel and gyro*/
-#define BMI160_MAG_X_DATA_LENGTH     (2)
-#define BMI160_MAG_Y_DATA_LENGTH     (2)
-#define BMI160_MAG_Z_DATA_LENGTH     (2)
-#define BMI160_MAG_R_DATA_LENGTH     (2)
-#define BMI160_MAG_XYZ_DATA_LENGTH	 (6)
-#define BMI160_MAG_XYZR_DATA_LENGTH	 (8)
-#define BMI160_MAG_YAS_DATA_LENGTH	 (8)
-#define BMI160_GYRO_DATA_LENGTH		 (2)
-#define BMI160_GYRO_XYZ_DATA_LENGTH	 (6)
-#define BMI160_ACCEL_DATA_LENGTH	 (2)
-#define BMI160_ACCEL_XYZ_DATA_LENGTH (6)
-#define BMI160_TEMP_DATA_LENGTH		 (2)
-#define BMI160_FIFO_DATA_LENGTH		 (2)
-#define BMI160_STEP_COUNTER_LENGTH	 (2)
-#define BMI160_SENSOR_TIME_LENGTH	 (3)
-
-/* Delay definitions*/
-#define BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY    (5)
-#define BMI160_BMM150_WAKEUP_DELAY1                  (2)
-#define BMI160_BMM150_WAKEUP_DELAY2                  (3)
-#define BMI160_BMM150_WAKEUP_DELAY3                  (1)
-#define BMI160_YAS532_OFFSET_DELAY                   (2)
-#define BMI160_GEN_READ_WRITE_DELAY                  (1)
-#define BMI160_YAS532_MEASUREMENT_DELAY              (25)
-#define BMI160_YAS_ACQ_COMMAND_DELAY                 (50)
-#define BMI160_YAS532_SET_INITIAL_VALUE_DELAY        (200)
-#define BMI160_AKM_INIT_DELAY                        (60)
-/****************************************************/
-/**\name	ARRAY SIZE DEFINITIONS      */
-/***************************************************/
-#define	BMI160_ACCEL_X_DATA_SIZE   (2)
-#define	BMI160_ACCEL_Y_DATA_SIZE   (2)
-#define	BMI160_ACCEL_Z_DATA_SIZE   (2)
-#define	BMI160_ACCEL_XYZ_DATA_SIZE (6)
-
-#define	BMI160_GYRO_X_DATA_SIZE    (2)
-#define	BMI160_GYRO_Y_DATA_SIZE    (2)
-#define	BMI160_GYRO_Z_DATA_SIZE    (2)
-#define	BMI160_GYRO_XYZ_DATA_SIZE  (6)
-
-#define	BMI160_MAG_X_DATA_SIZE      (2)
-#define	BMI160_MAG_Y_DATA_SIZE      (2)
-#define	BMI160_MAG_Z_DATA_SIZE      (2)
-#define	BMI160_MAG_R_DATA_SIZE      (2)
-#define	BMI160_MAG_XYZ_DATA_SIZE    (6)
-#define	BMI160_MAG_XYZR_DATA_SIZE   (8)
-#define	BMI160_MAG_TRIM_DATA_SIZE   (16)
-
-
-#define	BMI160_TEMP_DATA_SIZE       (2)
-#define	BMI160_FIFO_DATA_SIZE       (2)
-#define	BMI160_STEP_COUNT_DATA_SIZE (2)
-
-#define	BMI160_SENSOR_TIME_DATA_SIZE      (3)
-#define	BMI160_AKM_SENSITIVITY_DATA_SIZE  (3)
-#define	BMI160_HARD_OFFSET_DATA_SIZE      (3)
-#define	BMI160_YAS_XY1Y2_DATA_SIZE        (3)
-#define	BMI160_YAS_FLAG_DATA_SIZE         (3)
-#define	BMI160_YAS_TEMP_DATA_SIZE         (3)
-#define	BMI160_YAS_H_DATA_SIZE            (3)
-#define	BMI160_YAS_S_DATA_SIZE            (3)
-#define BMI160_YAS_CORRECT_DATA_SIZE      (5)
-#define BMI160_YAS_XY1Y2T_DATA_SIZE       (8)
-#define BMI160_YAS537_CALIB_DATA_SIZE     (17)
-#define BMI160_YAS532_CALIB_DATA_SIZE     (14)
-#define BMI160_GYRO_ACCEL_SENSORTIME_DATA_SIZE		(15)
-#define BMI160_ACCEL_SENSORTIME_DATA_SIZE			(9)
-
-
-#define BMI160_GYRO_ACCEL_SENSORTIME_DATA (1)
-#define BMI160_ACCEL_SENSORTIME_DATA (0)
-
-
-
-/****************************************************/
-/**\name	ARRAY PARAMETER DEFINITIONS      */
-/***************************************************/
-#define BMI160_SENSOR_TIME_MSB_BYTE   (2)
-#define BMI160_SENSOR_TIME_XLSB_BYTE  (1)
-#define BMI160_SENSOR_TIME_LSB_BYTE   (0)
-
-#define BMI160_MAG_X_LSB_BYTE	          (0)
-#define BMI160_MAG_X_MSB_BYTE              (1)
-#define BMI160_MAG_Y_LSB_BYTE	           (0)
-#define BMI160_MAG_Y_MSB_BYTE              (1)
-#define BMI160_MAG_Z_LSB_BYTE	           (0)
-#define BMI160_MAG_Z_MSB_BYTE              (1)
-#define BMI160_MAG_R_LSB_BYTE	           (0)
-#define BMI160_MAG_R_MSB_BYTE              (1)
-#define BMI160_DATA_FRAME_MAG_X_LSB_BYTE   (0)
-#define BMI160_DATA_FRAME_MAG_X_MSB_BYTE   (1)
-#define BMI160_DATA_FRAME_MAG_Y_LSB_BYTE   (2)
-#define BMI160_DATA_FRAME_MAG_Y_MSB_BYTE   (3)
-#define BMI160_DATA_FRAME_MAG_Z_LSB_BYTE   (4)
-#define BMI160_DATA_FRAME_MAG_Z_MSB_BYTE   (5)
-#define BMI160_DATA_FRAME_MAG_R_LSB_BYTE   (6)
-#define BMI160_DATA_FRAME_MAG_R_MSB_BYTE   (7)
-
-#define BMI160_GYRO_X_LSB_BYTE              (0)
-#define BMI160_GYRO_X_MSB_BYTE              (1)
-#define BMI160_GYRO_Y_LSB_BYTE              (0)
-#define BMI160_GYRO_Y_MSB_BYTE              (1)
-#define BMI160_GYRO_Z_LSB_BYTE              (0)
-#define BMI160_GYRO_Z_MSB_BYTE              (1)
-#define BMI160_DATA_FRAME_GYRO_X_LSB_BYTE   (0)
-#define BMI160_DATA_FRAME_GYRO_X_MSB_BYTE   (1)
-#define BMI160_DATA_FRAME_GYRO_Y_LSB_BYTE   (2)
-#define BMI160_DATA_FRAME_GYRO_Y_MSB_BYTE   (3)
-#define BMI160_DATA_FRAME_GYRO_Z_LSB_BYTE   (4)
-#define BMI160_DATA_FRAME_GYRO_Z_MSB_BYTE   (5)
-
-#define BMI160_ACCEL_X_LSB_BYTE              (0)
-#define BMI160_ACCEL_X_MSB_BYTE              (1)
-#define BMI160_ACCEL_Y_LSB_BYTE              (0)
-#define BMI160_ACCEL_Y_MSB_BYTE              (1)
-#define BMI160_ACCEL_Z_LSB_BYTE              (0)
-#define BMI160_ACCEL_Z_MSB_BYTE              (1)
-#define BMI160_DATA_FRAME_ACCEL_X_LSB_BYTE   (0)
-#define BMI160_DATA_FRAME_ACCEL_X_MSB_BYTE   (1)
-#define BMI160_DATA_FRAME_ACCEL_Y_LSB_BYTE   (2)
-#define BMI160_DATA_FRAME_ACCEL_Y_MSB_BYTE   (3)
-#define BMI160_DATA_FRAME_ACCEL_Z_LSB_BYTE   (4)
-#define BMI160_DATA_FRAME_ACCEL_Z_MSB_BYTE   (5)
-
-#define	BMI160_TEMP_LSB_BYTE    (0)
-#define	BMI160_TEMP_MSB_BYTE    (1)
-#define	BMI160_STEP_COUNT_LSB_BYTE    (0)
-#define	BMI160_STEP_COUNT_MSB_BYTE    (1)
-/****************************************************/
-/**\name	ERROR CODES       */
-/***************************************************/
-
-#define E_BMI160_NULL_PTR			((s8)-127)
-#define E_BMI160_COMM_RES			((s8)-1)
-#define E_BMI160_OUT_OF_RANGE		((s8)-2)
-#define E_BMI160_BUSY				((s8)-3)
-#define	SUCCESS						((u8)0)
-#define	ERROR						((s8)-1)
-
-/* Constants */
-#define BMI160_NULL						(0)
-#define BMI160_DELAY_SETTLING_TIME		(5)
-/*This refers BMI160 return type as s8 */
-#define BMI160_RETURN_FUNCTION_TYPE		s8
-/****************************************************/
-/**\name	REGISTER DEFINITIONS       */
-/***************************************************/
-/*******************/
-/**\name CHIP ID */
-/*******************/
-#define BMI160_USER_CHIP_ID_ADDR				(0x00)
-/*******************/
-/**\name ERROR STATUS */
-/*******************/
-#define BMI160_USER_ERROR_ADDR					(0X02)
-/*******************/
-/**\name POWER MODE STATUS */
-/*******************/
-#define BMI160_USER_PMU_STAT_ADDR				(0X03)
-#define BMI160_ACCEL_GYRO_PMU_MASK				(0X3C)
-#define BMI160_NORMAL_MODE					(0X14)
-/*******************/
-/**\name MAG DATA REGISTERS */
-/*******************/
-#define BMI160_USER_DATA_0_ADDR					(0X04)
-#define BMI160_USER_DATA_1_ADDR					(0X05)
-#define BMI160_USER_DATA_2_ADDR					(0X06)
-#define BMI160_USER_DATA_3_ADDR					(0X07)
-#define BMI160_USER_DATA_4_ADDR					(0X08)
-#define BMI160_USER_DATA_5_ADDR					(0X09)
-#define BMI160_USER_DATA_6_ADDR					(0X0A)
-#define BMI160_USER_DATA_7_ADDR					(0X0B)
-/*******************/
-/**\name GYRO DATA REGISTERS */
-/*******************/
-#define BMI160_USER_DATA_8_ADDR					(0X0C)
-#define BMI160_USER_DATA_9_ADDR					(0X0D)
-#define BMI160_USER_DATA_10_ADDR				(0X0E)
-#define BMI160_USER_DATA_11_ADDR				(0X0F)
-#define BMI160_USER_DATA_12_ADDR				(0X10)
-#define BMI160_USER_DATA_13_ADDR				(0X11)
-/*******************/
-/**\name ACCEL DATA REGISTERS */
-/*******************/
-#define BMI160_USER_DATA_14_ADDR				(0X12)
-#define BMI160_USER_DATA_15_ADDR				(0X13)
-#define BMI160_USER_DATA_16_ADDR				(0X14)
-#define BMI160_USER_DATA_17_ADDR				(0X15)
-#define BMI160_USER_DATA_18_ADDR				(0X16)
-#define BMI160_USER_DATA_19_ADDR				(0X17)
-/*******************/
-/**\name SENSOR TIME REGISTERS */
-/*******************/
-#define BMI160_USER_SENSORTIME_0_ADDR			(0X18)
-#define BMI160_USER_SENSORTIME_1_ADDR			(0X19)
-#define BMI160_USER_SENSORTIME_2_ADDR			(0X1A)
-/*******************/
-/**\name STATUS REGISTER FOR SENSOR STATUS FLAG */
-/*******************/
-#define BMI160_USER_STAT_ADDR					(0X1B)
-/*******************/
-/**\name INTERRUPT STATUS REGISTERS */
-/*******************/
-#define BMI160_USER_INTR_STAT_0_ADDR			(0X1C)
-#define BMI160_USER_INTR_STAT_1_ADDR			(0X1D)
-#define BMI160_USER_INTR_STAT_2_ADDR			(0X1E)
-#define BMI160_USER_INTR_STAT_3_ADDR			(0X1F)
-/*******************/
-/**\name TEMPERATURE REGISTERS */
-/*******************/
-#define BMI160_USER_TEMPERATURE_0_ADDR			(0X20)
-#define BMI160_USER_TEMPERATURE_1_ADDR			(0X21)
-/*******************/
-/**\name FIFO REGISTERS */
-/*******************/
-#define BMI160_USER_FIFO_LENGTH_0_ADDR			(0X22)
-#define BMI160_USER_FIFO_LENGTH_1_ADDR			(0X23)
-#define BMI160_USER_FIFO_DATA_ADDR				(0X24)
-/***************************************************/
-/**\name ACCEL CONFIG REGISTERS  FOR ODR, BANDWIDTH AND UNDERSAMPLING*/
-/******************************************************/
-#define BMI160_USER_ACCEL_CONFIG_ADDR			(0X40)
-/*******************/
-/**\name ACCEL RANGE */
-/*******************/
-#define BMI160_USER_ACCEL_RANGE_ADDR            (0X41)
-/***************************************************/
-/**\name GYRO CONFIG REGISTERS  FOR ODR AND BANDWIDTH */
-/******************************************************/
-#define BMI160_USER_GYRO_CONFIG_ADDR            (0X42)
-/*******************/
-/**\name GYRO RANGE */
-/*******************/
-#define BMI160_USER_GYRO_RANGE_ADDR             (0X43)
-/***************************************************/
-/**\name MAG CONFIG REGISTERS  FOR ODR*/
-/******************************************************/
-#define BMI160_USER_MAG_CONFIG_ADDR				(0X44)
-#ifdef FIFO_ENABLE
-/***************************************************/
-/**\name REGISTER FOR GYRO AND ACCEL DOWNSAMPLING RATES FOR FIFO*/
-/******************************************************/
-#define BMI160_USER_FIFO_DOWN_ADDR              (0X45)
-/***************************************************/
-/**\name FIFO CONFIG REGISTERS*/
-/******************************************************/
-#define BMI160_USER_FIFO_CONFIG_0_ADDR          (0X46)
-#define BMI160_USER_FIFO_CONFIG_1_ADDR          (0X47)
-#endif
-
-/***************************************************/
-/**\name MAG INTERFACE REGISTERS*/
-/******************************************************/
-#define BMI160_USER_MAG_IF_0_ADDR				(0X4B)
-#define BMI160_USER_MAG_IF_1_ADDR				(0X4C)
-#define BMI160_USER_MAG_IF_2_ADDR				(0X4D)
-#define BMI160_USER_MAG_IF_3_ADDR				(0X4E)
-#define BMI160_USER_MAG_IF_4_ADDR				(0X4F)
-/***************************************************/
-/**\name INTERRUPT ENABLE REGISTERS*/
-/******************************************************/
-#define BMI160_USER_INTR_ENABLE_0_ADDR			(0X50)
-#define BMI160_USER_INTR_ENABLE_1_ADDR			(0X51)
-#define BMI160_USER_INTR_ENABLE_2_ADDR			(0X52)
-#define BMI160_USER_INTR_OUT_CTRL_ADDR			(0X53)
-/***************************************************/
-/**\name LATCH DURATION REGISTERS*/
-/******************************************************/
-#define BMI160_USER_INTR_LATCH_ADDR				(0X54)
-/***************************************************/
-/**\name MAP INTERRUPT 1 and 2 REGISTERS*/
-/******************************************************/
-#define BMI160_USER_INTR_MAP_0_ADDR				(0X55)
-#define BMI160_USER_INTR_MAP_1_ADDR				(0X56)
-#define BMI160_USER_INTR_MAP_2_ADDR				(0X57)
-/***************************************************/
-/**\name DATA SOURCE REGISTERS*/
-/******************************************************/
-#define BMI160_USER_INTR_DATA_0_ADDR			(0X58)
-#define BMI160_USER_INTR_DATA_1_ADDR			(0X59)
-/***************************************************/
-/**\name
-INTERRUPT THRESHOLD, HYSTERESIS, DURATION, MODE CONFIGURATION REGISTERS*/
-/******************************************************/
-#define BMI160_USER_INTR_LOWHIGH_0_ADDR			(0X5A)
-#define BMI160_USER_INTR_LOWHIGH_1_ADDR			(0X5B)
-#define BMI160_USER_INTR_LOWHIGH_2_ADDR			(0X5C)
-#define BMI160_USER_INTR_LOWHIGH_3_ADDR			(0X5D)
-#define BMI160_USER_INTR_LOWHIGH_4_ADDR			(0X5E)
-#define BMI160_USER_INTR_MOTION_0_ADDR			(0X5F)
-#define BMI160_USER_INTR_MOTION_1_ADDR			(0X60)
-#define BMI160_USER_INTR_MOTION_2_ADDR			(0X61)
-#define BMI160_USER_INTR_MOTION_3_ADDR			(0X62)
-#define BMI160_USER_INTR_TAP_0_ADDR				(0X63)
-#define BMI160_USER_INTR_TAP_1_ADDR				(0X64)
-#define BMI160_USER_INTR_ORIENT_0_ADDR			(0X65)
-#define BMI160_USER_INTR_ORIENT_1_ADDR			(0X66)
-#define BMI160_USER_INTR_FLAT_0_ADDR			(0X67)
-#define BMI160_USER_INTR_FLAT_1_ADDR			(0X68)
-/***************************************************/
-/**\name FAST OFFSET CONFIGURATION REGISTER*/
-/******************************************************/
-#define BMI160_USER_FOC_CONFIG_ADDR				(0X69)
-/***************************************************/
-/**\name MISCELLANEOUS CONFIGURATION REGISTER*/
-/******************************************************/
-#define BMI160_USER_CONFIG_ADDR					(0X6A)
-/***************************************************/
-/**\name SERIAL INTERFACE SETTINGS REGISTER*/
-/******************************************************/
-#define BMI160_USER_IF_CONFIG_ADDR				(0X6B)
-/***************************************************/
-/**\name GYRO POWER MODE TRIGGER REGISTER */
-/******************************************************/
-#define BMI160_USER_PMU_TRIGGER_ADDR			(0X6C)
-/***************************************************/
-/**\name SELF_TEST REGISTER*/
-/******************************************************/
-#define BMI160_USER_SELF_TEST_ADDR				(0X6D)
-/***************************************************/
-/**\name SPI,I2C SELECTION REGISTER*/
-/******************************************************/
-#define BMI160_USER_NV_CONFIG_ADDR				(0x70)
-/***************************************************/
-/**\name ACCEL AND GYRO OFFSET REGISTERS*/
-/******************************************************/
-#define BMI160_USER_OFFSET_0_ADDR				(0X71)
-#define BMI160_USER_OFFSET_1_ADDR				(0X72)
-#define BMI160_USER_OFFSET_2_ADDR				(0X73)
-#define BMI160_USER_OFFSET_3_ADDR				(0X74)
-#define BMI160_USER_OFFSET_4_ADDR				(0X75)
-#define BMI160_USER_OFFSET_5_ADDR				(0X76)
-#define BMI160_USER_OFFSET_6_ADDR				(0X77)
-/***************************************************/
-/**\name STEP COUNTER INTERRUPT REGISTERS*/
-/******************************************************/
-#define BMI160_USER_STEP_COUNT_0_ADDR			(0X78)
-#define BMI160_USER_STEP_COUNT_1_ADDR			(0X79)
-/***************************************************/
-/**\name STEP COUNTER CONFIGURATION REGISTERS*/
-/******************************************************/
-#define BMI160_USER_STEP_CONFIG_0_ADDR			(0X7A)
-#define BMI160_USER_STEP_CONFIG_1_ADDR			(0X7B)
-/***************************************************/
-/**\name COMMAND REGISTER*/
-/******************************************************/
-#define BMI160_CMD_COMMANDS_ADDR				(0X7E)
-
-/****************************************************/
-/**\name	SHIFT VALUE DEFINITION       */
-/***************************************************/
-#define BMI160_SHIFT_BIT_POSITION_BY_01_BIT      (1)
-#define BMI160_SHIFT_BIT_POSITION_BY_02_BITS     (2)
-#define BMI160_SHIFT_BIT_POSITION_BY_03_BITS     (3)
-#define BMI160_SHIFT_BIT_POSITION_BY_04_BITS     (4)
-#define BMI160_SHIFT_BIT_POSITION_BY_05_BITS     (5)
-#define BMI160_SHIFT_BIT_POSITION_BY_06_BITS     (6)
-#define BMI160_SHIFT_BIT_POSITION_BY_07_BITS     (7)
-#define BMI160_SHIFT_BIT_POSITION_BY_08_BITS     (8)
-#define BMI160_SHIFT_BIT_POSITION_BY_09_BITS     (9)
-#define BMI160_SHIFT_BIT_POSITION_BY_12_BITS     (12)
-#define BMI160_SHIFT_BIT_POSITION_BY_13_BITS     (13)
-#define BMI160_SHIFT_BIT_POSITION_BY_14_BITS     (14)
-#define BMI160_SHIFT_BIT_POSITION_BY_15_BITS     (15)
-#define BMI160_SHIFT_BIT_POSITION_BY_16_BITS     (16)
-
-/****************************************************/
-/**\name	 DEFINITIONS USED FOR YAMAHA-YAS532 */
-/***************************************************/
-#define YAS532_MAG_STATE_NORMAL				(0)
-#define YAS532_MAG_STATE_INIT_COIL			(1)
-#define YAS532_MAG_STATE_MEASURE_OFFSET		(2)
-#define YAS532_MAG_INITCOIL_TIMEOUT			(1000)
-#define YAS532_MAG_NOTRANS_POSITION			(3)
-#define YAS532_DEFAULT_SENSOR_DELAY			(50)
-#define YAS532_DATA_OVERFLOW				(8190)
-#define YAS532_DATA_UNDERFLOW				(0)
-#define YAS532_MAG_TEMPERATURE_LOG			(10)
-#define YAS532_TEMP20DEGREE_TYPICAL			(390)
-#define YAS532_VERSION_AC_COEF_X			(850)
-#define YAS532_VERSION_AC_COEF_Y1			(750)
-#define YAS532_VERSION_AC_COEF_Y2			(750)
-#define YAS532_DATA_CENTER					(4096)
-/****************************************************/
-/**\name	YAMAHA-YAS532 OFFSET DEFINITION */
-/***************************************************/
-static const s8 INVALID_OFFSET[] = {0x7f, 0x7f, 0x7f};
-#define set_vector(to, from) \
-	{int _l; for (_l = 0; _l < 3; _l++) (to)[_l] = (from)[_l]; }
-#define is_valid_offset(a) \
-	(((a)[0] <= 31) && ((a)[1] <= 31) && ((a)[2] <= 31) \
-		&& (-31 <= (a)[0]) && (-31 <= (a)[1]) && (-31 <= (a)[2]))
-
-/**************************************************/
-/**\name	YAS532 CALIB DATA DEFINITIONS  */
-/*************************************************/
-
-
-/* register address of YAS532*/
-#define BMI160_YAS532_TESTR1			(0x88)
-#define BMI160_YAS532_TESTR2			(0x89)
-#define BMI160_YAS532_RCOIL				(0x81)
-#define BMI160_YAS532_COMMAND_REGISTER	(0x82)
-#define BMI160_YAS532_DATA_REGISTER		(0xB0)
-/* calib data register definition*/
-#define BMI160_YAS532_CALIB_CX	        (0x90)
-#define BMI160_YAS532_CALIB_CY1	        (0x91)
-#define BMI160_YAS532_CALIB_CY2	        (0x92)
-#define BMI160_YAS532_CALIB1	        (0x93)
-#define BMI160_YAS532_CALIB2	        (0x94)
-#define BMI160_YAS532_CALIB3	        (0x95)
-#define BMI160_YAS532_CALIB4	        (0x96)
-#define BMI160_YAS532_CALIB5	        (0x97)
-#define BMI160_YAS532_CALIB6	        (0x98)
-#define BMI160_YAS532_CALIB7	        (0x99)
-#define BMI160_YAS532_CALIB8	        (0x9A)
-#define BMI160_YAS532_CALIB9	        (0x9B)
-#define BMI160_YAS532_CALIB10	        (0x9C)
-#define BMI160_YAS532_CALIB11	        (0x9D)
-/* offset definition */
-#define BMI160_YAS532_OFFSET_X	        (0x85)
-#define BMI160_YAS532_OFFSET_Y	        (0x86)
-#define BMI160_YAS532_OFFSET_Z	        (0x87)
-/* data to write register for yas532*/
-#define BMI160_YAS532_WRITE_TESTR1	    (0x00)
-#define BMI160_YAS532_WRITE_TESTR2	    (0x00)
-#define BMI160_YAS532_WRITE_RCOIL       (0x00)
-/**************************************************/
-/**\name	YAS537 DEFINITION  */
-/*************************************************/
-
-#define	YAS537_SRSTR_DATA		        (0x02)
-#define	YAS537_WRITE_A_D_CONVERTER		(0x03)
-#define	YAS537_WRITE_A_D_CONVERTER2		(0xF8)
-#define	YAS537_WRITE_FILTER             (0x08)
-#define	YAS537_WRITE_CONFR              (0x08)
-#define	YAS537_WRITE_TEMP_CALIB         (0xFF)
-#define	YAS537_SET_COMMAND_REGISTER     (0x01)
-
-/**************************************************/
-/**\name	YAS537 REGISTER DEFINITION  */
-/*************************************************/
-#define	YAS537_REG_SRSTR				(0x90)
-#define	YAS537_REG_CALR_C0				(0xC0)
-#define	YAS537_REG_CALR_C1				(0xC1)
-#define	YAS537_REG_CALR_C2				(0xC2)
-#define	YAS537_REG_CALR_C3				(0xC3)
-#define	YAS537_REG_CALR_C4				(0xC4)
-#define	YAS537_REG_CALR_C5				(0xC5)
-#define	YAS537_REG_CALR_C6				(0xC6)
-#define	YAS537_REG_CALR_C7				(0xC7)
-#define	YAS537_REG_CALR_C8				(0xC8)
-#define	YAS537_REG_CALR_C9				(0xC9)
-#define	YAS537_REG_CALR_CA				(0xCA)
-#define	YAS537_REG_CALR_CB				(0xCB)
-#define	YAS537_REG_CALR_CC				(0xCC)
-#define	YAS537_REG_CALR_CD				(0xCD)
-#define	YAS537_REG_CALR_CE				(0xCE)
-#define	YAS537_REG_CALR_CF				(0xCF)
-#define	YAS537_REG_CALR_DO				(0xD0)
-#define	YAS537_REG_MTCR					(0x93)
-#define	YAS537_REG_CONFR				(0x82)
-#define	BMI160_REG_YAS537_CMDR			(0x81)
-#define	YAS537_REG_OXR					(0x84)
-#define	YAS537_REG_AVRR					(0x87)
-#define	YAS537_REG_HCKR					(0x88)
-#define	YAS537_REG_LCKR					(0x89)
-#define	YAS537_REG_ADCCALR				(0x91)
-#define	YAS537_REG_ADCCALR_ONE			(0x92)
-#define	YAS537_REG_OCR					(0x9E)
-#define	YAS537_REG_TRMR			        (0x9F)
-#define	YAS537_REG_TEMPERATURE_0		(0xB0)
-#define	YAS537_REG_TEMPERATURE_1		(0xB1)
-#define	YAS537_REG_DATA_X_0				(0xB2)
-#define	YAS537_REG_DATA_X_1				(0xB3)
-#define	YAS537_REG_DATA_Y1_0			(0xB4)
-#define	YAS537_REG_DATA_Y1_1			(0xB5)
-#define	YAS537_REG_DATA_Y2_0			(0xB6)
-#define	YAS537_REG_DATA_Y2_1			(0xB7)
-#define YAS537_MAG_STATE_NORMAL			(0)
-#define YAS537_MAG_STATE_INIT_COIL		(1)
-#define YAS537_MAG_STATE_RECORD_DATA	(2)
-#define YAS537_DATA_UNDERFLOW			(0)
-#define YAS537_DATA_OVERFLOW			(16383)
-/****************************************************/
-/**\name	YAS537_set vector */
-/***************************************************/
-#define yas537_set_vector(to, from) \
-	{int _l; for (_l = 0; _l < 3; _l++) (to)[_l] = (from)[_l]; }
-
-#ifndef ABS
-#define ABS(a)		((a) > 0 ? (a) : -(a)) /*!< Absolute value */
-#endif
-/****************************************************/
-/**\name	AKM09911 AND AKM09912 DEFINITION */
-/***************************************************/
-#define AKM09912_SENSITIVITY_DIV	(256)
-#define AKM09912_SENSITIVITY		(128)
-#define AKM09911_SENSITIVITY_DIV	(128)
-#define AKM_ASAX			(0)
-#define AKM_ASAY			(1)
-#define AKM_ASAZ			(2)
-#define AKM_POWER_DOWN_MODE_DATA	(0x00)
-#define AKM_FUSE_ROM_MODE		(0x1F)
-#define AKM_POWER_MODE_REG		(0x31)
-#define	AKM_SINGLE_MEASUREMENT_MODE	(0x01)
-#define AKM_DATA_REGISTER		(0x11)
-/*! AKM09912 Register definition */
-#define AKM_CHIP_ID_REG			(0x01)
-/****************************************************/
-/**\name	BMM150 DEFINITION */
-/***************************************************/
-#define BMI160_BMM150_SET_POWER_CONTROL		(0x01)
-#define BMI160_BMM150_MAX_RETRY_WAKEUP		(5)
-#define BMI160_BMM150_POWER_ON			(0x01)
-#define BMI160_BMM150_POWER_OFF			(0x00)
-#define BMI160_BMM150_FORCE_MODE		(0x02)
-#define BMI160_BMM150_POWER_ON_SUCCESS		(0)
-#define BMI160_BMM150_POWER_ON_FAIL		((s8)-1)
-
-#define	BMI160_BMM150_DIG_X1			(0)
-#define	BMI160_BMM150_DIG_Y1			(1)
-#define	BMI160_BMM150_DIG_X2			(2)
-#define	BMI160_BMM150_DIG_Y3			(3)
-#define	BMI160_BMM150_DIG_XY1			(4)
-#define	BMI160_BMM150_DIG_XY2			(5)
-#define	BMI160_BMM150_DIG_Z1_LSB		(6)
-#define	BMI160_BMM150_DIG_Z1_MSB		(7)
-#define	BMI160_BMM150_DIG_Z2_LSB		(8)
-#define	BMI160_BMM150_DIG_Z2_MSB		(9)
-#define	BMI160_BMM150_DIG_DIG_Z3_LSB	(10)
-#define	BMI160_BMM150_DIG_DIG_Z3_MSB	(11)
-#define	BMI160_BMM150_DIG_DIG_Z4_LSB	(12)
-#define	BMI160_BMM150_DIG_DIG_Z4_MSB	(13)
-#define	BMI160_BMM150_DIG_DIG_XYZ1_LSB	(14)
-#define	BMI160_BMM150_DIG_DIG_XYZ1_MSB	(15)
-#define BMI160_FIFO_FRAME_CNT		(146)
-#define	BMI160_FRAME_COUNT		(1)
-
-/**************************************************************/
-/**\name	STRUCTURE DEFINITIONS                         */
-/**************************************************************/
-/*!
-*	@brief bmi160 structure
-*	This structure holds all relevant information about bmi160
-*/
-struct bmi160_t {
-u8 chip_id;/**< chip id of BMI160 */
-u8 dev_addr;/**< device address of BMI160 */
-s8 mag_manual_enable;/**< used to check the Mag manual/auto mode status */
-BMI160_WR_FUNC_PTR;/**< bus write function pointer */
-BMI160_RD_FUNC_PTR;/**< bus read function pointer */
-BMI160_BRD_FUNC_PTR;/**< burst write function pointer */
-void (*delay_msec)(BMI160_MDELAY_DATA_TYPE);/**< delay function pointer */
-};
-/*!
- * @brief Structure containing bmm150 and akm09911
- *	magnetometer values for x,y and
- *	z-axis in s16
- */
-struct bmi160_mag_t {
-s32 x;/**< BMM150 and AKM09911 and AKM09912 X raw data*/
-s32 y;/**< BMM150 and AKM09911 and AKM09912 Y raw data*/
-s32 z;/**< BMM150 and AKM09911 and AKM09912 Z raw data*/
-};
-/*!
- * @brief Structure containing bmm150 xyz data and temperature
- */
-struct bmi160_mag_xyzr_t {
-s16 x;/**< BMM150 X raw data*/
-s16 y;/**< BMM150 Y raw data*/
-s16 z;/**<BMM150 Z raw data*/
-u16 r;/**<BMM150 R raw data*/
-};
-/*!
- * @brief Structure containing Gyro  xyz data
- */
-struct bmi160_gyro_t {
-s16 x;/**<gyro X  data*/
-s16 y;/**<gyro Y  data*/
-s16 z;/**<gyro Z  data*/
-};
-/*!
- * @brief Structure containing Accel xyz data
- */
-struct bmi160_accel_t {
-s16 x;/**<accel X  data*/
-s16 y;/**<accel Y  data*/
-s16 z;/**<accel Z  data*/
-};
-/*!
- * @brief Structure containing Accel Gyro  data and sensor time
- */
-struct bmi160_sensortime_accel_gyro_data {
-struct bmi160_gyro_t gyro; /**<gyro data structure*/
-struct bmi160_accel_t accel;/**<accel data structure*/
-u32 v_sensor_time_u32;/**<Sensor time value*/
-};
-/*!
- * @brief Structure bmm150 Mag compensated data with s32 output
- */
-struct bmi160_mag_xyz_s32_t {
-s32 x;/**<BMM150 X compensated data*/
-s32 y;/**<BMM150 Y compensated data*/
-s32 z;/**<BMM150 Z compensated data*/
-};
-/*!
- * @brief Structure bmm150 Mag trim data
- */
-struct trim_data_t {
-s8 dig_x1;/**<BMM150 trim x1 data*/
-s8 dig_y1;/**<BMM150 trim y1 data*/
-
-s8 dig_x2;/**<BMM150 trim x2 data*/
-s8 dig_y2;/**<BMM150 trim y2 data*/
-
-u16 dig_z1;/**<BMM150 trim z1 data*/
-s16 dig_z2;/**<BMM150 trim z2 data*/
-s16 dig_z3;/**<BMM150 trim z3 data*/
-s16 dig_z4;/**<BMM150 trim z4 data*/
-
-u8 dig_xy1;/**<BMM150 trim xy1 data*/
-s8 dig_xy2;/**<BMM150 trim xy2 data*/
-
-u16 dig_xyz1;/**<BMM150 trim xyz1 data*/
-};
-#ifdef FIFO_ENABLE
-/*!
-* @brief FIFO used to store the FIFO header less data
-*/
-struct bmi160_fifo_data_header_less_t {
-
-struct bmi160_accel_t accel_fifo[BMI160_FIFO_FRAME_CNT];/**<
-Accel data of XYZ */
-struct bmi160_mag_t mag_fifo[BMI160_FIFO_FRAME_CNT];/**<
-Mag data of XYZ */
-struct bmi160_gyro_t gyro_fifo[BMI160_FIFO_FRAME_CNT];/**<
-Gyro data of XYZ */
-u8 accel_frame_count;/**< The total number of Accel frame stored
-in the FIFO*/
-u8 gyro_frame_count;/**< The total number of Gyro  frame stored
-in the FIFO*/
-u8 mag_frame_count;/**< The total number of Mag frame stored
-in the FIFO*/
-};
-/*!
-* @brief Struct used to store the FIFO header data
-*/
-struct bmi160_fifo_data_header_t {
-struct bmi160_accel_t accel_fifo[BMI160_FIFO_FRAME_CNT];/**<
-Accel data of XYZ */
-struct bmi160_mag_t mag_fifo[BMI160_FIFO_FRAME_CNT];/**<
-Mag data of XYZ */
-struct bmi160_gyro_t gyro_fifo[BMI160_FIFO_FRAME_CNT];/**<
-Gyro data of XYZ */
-u32 fifo_time;/**< Value of FIFO time*/
-u8 skip_frame;/**< The value of skip frame information */
-u8 fifo_input_config_info; /**< FIFO input config info*/
-u8 accel_frame_count; /**< The total number of Accel frame stored
-in the FIFO*/
-u8 gyro_frame_count; /**< The total number of Gyro  frame stored
-in the FIFO*/
-u8 mag_frame_count; /**< The total number of Mag frame stored
-in the FIFO*/
-u8 fifo_header[BMI160_FIFO_FRAME_CNT]; /**< FIFO header info*/
-};
-/*!
-* @brief Struct used to store the FIFO Mag data
-*/
-struct bmi160_mag_fifo_data_t {
-u8 mag_x_lsb;/**< The value of Mag x LSB data*/
-u8 mag_x_msb;/**< The value of Mag x MSB data*/
-u8 mag_y_lsb;/**< The value of Mag y LSB data*/
-u8 mag_y_msb;/**< The value of Mag y MSB data*/
-u8 mag_z_lsb;/**< The value of Mag z LSB data*/
-u8 mag_z_msb;/**< The value of Mag z MSB data*/
-u8 mag_r_y2_lsb;
-/**< The value of Mag r for BMM150 Y2 for YAMAHA LSB data*/
-u8 mag_r_y2_msb;
-/**< The value of Mag r for BMM150 Y2 for YAMAHA MSB data*/
-};
-#endif
-/**************************************************************/
-/**\name	USER DATA REGISTERS DEFINITION START    */
-/**************************************************************/
-
-/**************************************************************/
-/**\name	CHIP ID LENGTH, POSITION AND MASK    */
-/**************************************************************/
-/* Chip ID Description - Reg Addr --> (0x00), Bit --> 0...7 */
-#define BMI160_USER_CHIP_ID__POS             (0)
-#define BMI160_USER_CHIP_ID__MSK            (0xFF)
-#define BMI160_USER_CHIP_ID__LEN             (8)
-#define BMI160_USER_CHIP_ID__REG             (BMI160_USER_CHIP_ID_ADDR)
-/**************************************************************/
-/**\name	ERROR STATUS LENGTH, POSITION AND MASK    */
-/**************************************************************/
-/* Error Description - Reg Addr --> (0x02), Bit --> 0 */
-#define BMI160_USER_ERR_STAT__POS               (0)
-#define BMI160_USER_ERR_STAT__LEN               (8)
-#define BMI160_USER_ERR_STAT__MSK               (0xFF)
-#define BMI160_USER_ERR_STAT__REG               (BMI160_USER_ERROR_ADDR)
-
-#define BMI160_USER_FATAL_ERR__POS               (0)
-#define BMI160_USER_FATAL_ERR__LEN               (1)
-#define BMI160_USER_FATAL_ERR__MSK               (0x01)
-#define BMI160_USER_FATAL_ERR__REG               (BMI160_USER_ERROR_ADDR)
-
-/* Error Description - Reg Addr --> (0x02), Bit --> 1...4 */
-#define BMI160_USER_ERR_CODE__POS               (1)
-#define BMI160_USER_ERR_CODE__LEN               (4)
-#define BMI160_USER_ERR_CODE__MSK               (0x1E)
-#define BMI160_USER_ERR_CODE__REG               (BMI160_USER_ERROR_ADDR)
-
-/* Error Description - Reg Addr --> (0x02), Bit --> 5 */
-#define BMI160_USER_I2C_FAIL_ERR__POS               (5)
-#define BMI160_USER_I2C_FAIL_ERR__LEN               (1)
-#define BMI160_USER_I2C_FAIL_ERR__MSK               (0x20)
-#define BMI160_USER_I2C_FAIL_ERR__REG               (BMI160_USER_ERROR_ADDR)
-
-/* Error Description - Reg Addr --> (0x02), Bit --> 6 */
-#define BMI160_USER_DROP_CMD_ERR__POS              (6)
-#define BMI160_USER_DROP_CMD_ERR__LEN              (1)
-#define BMI160_USER_DROP_CMD_ERR__MSK              (0x40)
-#define BMI160_USER_DROP_CMD_ERR__REG              (BMI160_USER_ERROR_ADDR)
-/**************************************************************/
-/**\name	MAG DATA READY LENGTH, POSITION AND MASK    */
-/**************************************************************/
-/* Error Description - Reg Addr --> (0x02), Bit --> 7 */
-#define BMI160_USER_MAG_DATA_RDY_ERR__POS               (7)
-#define BMI160_USER_MAG_DATA_RDY_ERR__LEN               (1)
-#define BMI160_USER_MAG_DATA_RDY_ERR__MSK               (0x80)
-#define BMI160_USER_MAG_DATA_RDY_ERR__REG               (BMI160_USER_ERROR_ADDR)
-/**************************************************************/
-/**\name	MAG POWER MODE LENGTH, POSITION AND MASK    */
-/**************************************************************/
-/* PMU_Status Description of MAG - Reg Addr --> (0x03), Bit --> 1..0 */
-#define BMI160_USER_MAG_POWER_MODE_STAT__POS		(0)
-#define BMI160_USER_MAG_POWER_MODE_STAT__LEN		(2)
-#define BMI160_USER_MAG_POWER_MODE_STAT__MSK		(0x03)
-#define BMI160_USER_MAG_POWER_MODE_STAT__REG		\
-(BMI160_USER_PMU_STAT_ADDR)
-/**************************************************************/
-/**\name	GYRO POWER MODE LENGTH, POSITION AND MASK    */
-/**************************************************************/
-/* PMU_Status Description of GYRO - Reg Addr --> (0x03), Bit --> 3...2 */
-#define BMI160_USER_GYRO_POWER_MODE_STAT__POS               (2)
-#define BMI160_USER_GYRO_POWER_MODE_STAT__LEN               (2)
-#define BMI160_USER_GYRO_POWER_MODE_STAT__MSK               (0x0C)
-#define BMI160_USER_GYRO_POWER_MODE_STAT__REG		      \
-(BMI160_USER_PMU_STAT_ADDR)
-/**************************************************************/
-/**\name	ACCEL POWER MODE LENGTH, POSITION AND MASK    */
-/**************************************************************/
-/* PMU_Status Description of ACCEL - Reg Addr --> (0x03), Bit --> 5...4 */
-#define BMI160_USER_ACCEL_POWER_MODE_STAT__POS               (4)
-#define BMI160_USER_ACCEL_POWER_MODE_STAT__LEN               (2)
-#define BMI160_USER_ACCEL_POWER_MODE_STAT__MSK               (0x30)
-#define BMI160_USER_ACCEL_POWER_MODE_STAT__REG		    \
-(BMI160_USER_PMU_STAT_ADDR)
-/**************************************************************/
-/**\name	MAG DATA XYZ LENGTH, POSITION AND MASK    */
-/**************************************************************/
-/* Mag_X(LSB) Description - Reg Addr --> (0x04), Bit --> 0...7 */
-#define BMI160_USER_DATA_0_MAG_X_LSB__POS           (0)
-#define BMI160_USER_DATA_0_MAG_X_LSB__LEN           (8)
-#define BMI160_USER_DATA_0_MAG_X_LSB__MSK          (0xFF)
-#define BMI160_USER_DATA_0_MAG_X_LSB__REG          (BMI160_USER_DATA_0_ADDR)
-
-/* Mag_X(LSB) Description - Reg Addr --> (0x04), Bit --> 3...7 */
-#define BMI160_USER_DATA_MAG_X_LSB__POS           (3)
-#define BMI160_USER_DATA_MAG_X_LSB__LEN           (5)
-#define BMI160_USER_DATA_MAG_X_LSB__MSK          (0xF8)
-#define BMI160_USER_DATA_MAG_X_LSB__REG          (BMI160_USER_DATA_0_ADDR)
-
-/* Mag_X(MSB) Description - Reg Addr --> (0x05), Bit --> 0...7 */
-#define BMI160_USER_DATA_1_MAG_X_MSB__POS           (0)
-#define BMI160_USER_DATA_1_MAG_X_MSB__LEN           (8)
-#define BMI160_USER_DATA_1_MAG_X_MSB__MSK          (0xFF)
-#define BMI160_USER_DATA_1_MAG_X_MSB__REG          (BMI160_USER_DATA_1_ADDR)
-
-/* Mag_Y(LSB) Description - Reg Addr --> (0x06), Bit --> 0...7 */
-#define BMI160_USER_DATA_2_MAG_Y_LSB__POS           (0)
-#define BMI160_USER_DATA_2_MAG_Y_LSB__LEN           (8)
-#define BMI160_USER_DATA_2_MAG_Y_LSB__MSK          (0xFF)
-#define BMI160_USER_DATA_2_MAG_Y_LSB__REG          (BMI160_USER_DATA_2_ADDR)
-
-/* Mag_Y(LSB) Description - Reg Addr --> (0x06), Bit --> 3...7 */
-#define BMI160_USER_DATA_MAG_Y_LSB__POS           (3)
-#define BMI160_USER_DATA_MAG_Y_LSB__LEN           (5)
-#define BMI160_USER_DATA_MAG_Y_LSB__MSK          (0xF8)
-#define BMI160_USER_DATA_MAG_Y_LSB__REG          (BMI160_USER_DATA_2_ADDR)
-
-/* Mag_Y(MSB) Description - Reg Addr --> (0x07), Bit --> 0...7 */
-#define BMI160_USER_DATA_3_MAG_Y_MSB__POS           (0)
-#define BMI160_USER_DATA_3_MAG_Y_MSB__LEN           (8)
-#define BMI160_USER_DATA_3_MAG_Y_MSB__MSK          (0xFF)
-#define BMI160_USER_DATA_3_MAG_Y_MSB__REG          (BMI160_USER_DATA_3_ADDR)
-
-/* Mag_Z(LSB) Description - Reg Addr --> (0x08), Bit --> 0...7 */
-#define BMI160_USER_DATA_4_MAG_Z_LSB__POS           (0)
-#define BMI160_USER_DATA_4_MAG_Z_LSB__LEN           (8)
-#define BMI160_USER_DATA_4_MAG_Z_LSB__MSK          (0xFF)
-#define BMI160_USER_DATA_4_MAG_Z_LSB__REG          (BMI160_USER_DATA_4_ADDR)
-
-/* Mag_X(LSB) Description - Reg Addr --> (0x08), Bit --> 3...7 */
-#define BMI160_USER_DATA_MAG_Z_LSB__POS           (1)
-#define BMI160_USER_DATA_MAG_Z_LSB__LEN           (7)
-#define BMI160_USER_DATA_MAG_Z_LSB__MSK          (0xFE)
-#define BMI160_USER_DATA_MAG_Z_LSB__REG          (BMI160_USER_DATA_4_ADDR)
-
-/* Mag_Z(MSB) Description - Reg Addr --> (0x09), Bit --> 0...7 */
-#define BMI160_USER_DATA_5_MAG_Z_MSB__POS           (0)
-#define BMI160_USER_DATA_5_MAG_Z_MSB__LEN           (8)
-#define BMI160_USER_DATA_5_MAG_Z_MSB__MSK          (0xFF)
-#define BMI160_USER_DATA_5_MAG_Z_MSB__REG          (BMI160_USER_DATA_5_ADDR)
-
-/* RHALL(LSB) Description - Reg Addr --> (0x0A), Bit --> 0...7 */
-#define BMI160_USER_DATA_6_RHALL_LSB__POS           (0)
-#define BMI160_USER_DATA_6_RHALL_LSB__LEN           (8)
-#define BMI160_USER_DATA_6_RHALL_LSB__MSK          (0xFF)
-#define BMI160_USER_DATA_6_RHALL_LSB__REG          (BMI160_USER_DATA_6_ADDR)
-
-/* Mag_R(LSB) Description - Reg Addr --> (0x0A), Bit --> 3...7 */
-#define BMI160_USER_DATA_MAG_R_LSB__POS           (2)
-#define BMI160_USER_DATA_MAG_R_LSB__LEN           (6)
-#define BMI160_USER_DATA_MAG_R_LSB__MSK          (0xFC)
-#define BMI160_USER_DATA_MAG_R_LSB__REG          (BMI160_USER_DATA_6_ADDR)
-
-/* RHALL(MSB) Description - Reg Addr --> (0x0B), Bit --> 0...7 */
-#define BMI160_USER_DATA_7_RHALL_MSB__POS           (0)
-#define BMI160_USER_DATA_7_RHALL_MSB__LEN           (8)
-#define BMI160_USER_DATA_7_RHALL_MSB__MSK          (0xFF)
-#define BMI160_USER_DATA_7_RHALL_MSB__REG          (BMI160_USER_DATA_7_ADDR)
-/**************************************************************/
-/**\name	GYRO DATA XYZ LENGTH, POSITION AND MASK    */
-/**************************************************************/
-/* GYR_X (LSB) Description - Reg Addr --> (0x0C), Bit --> 0...7 */
-#define BMI160_USER_DATA_8_GYRO_X_LSB__POS           (0)
-#define BMI160_USER_DATA_8_GYRO_X_LSB__LEN           (8)
-#define BMI160_USER_DATA_8_GYRO_X_LSB__MSK          (0xFF)
-#define BMI160_USER_DATA_8_GYRO_X_LSB__REG          (BMI160_USER_DATA_8_ADDR)
-
-/* GYR_X (MSB) Description - Reg Addr --> (0x0D), Bit --> 0...7 */
-#define BMI160_USER_DATA_9_GYRO_X_MSB__POS           (0)
-#define BMI160_USER_DATA_9_GYRO_X_MSB__LEN           (8)
-#define BMI160_USER_DATA_9_GYRO_X_MSB__MSK          (0xFF)
-#define BMI160_USER_DATA_9_GYRO_X_MSB__REG          (BMI160_USER_DATA_9_ADDR)
-
-/* GYR_Y (LSB) Description - Reg Addr --> 0x0E, Bit --> 0...7 */
-#define BMI160_USER_DATA_10_GYRO_Y_LSB__POS           (0)
-#define BMI160_USER_DATA_10_GYRO_Y_LSB__LEN           (8)
-#define BMI160_USER_DATA_10_GYRO_Y_LSB__MSK          (0xFF)
-#define BMI160_USER_DATA_10_GYRO_Y_LSB__REG          (BMI160_USER_DATA_10_ADDR)
-
-/* GYR_Y (MSB) Description - Reg Addr --> (0x0F), Bit --> 0...7 */
-#define BMI160_USER_DATA_11_GYRO_Y_MSB__POS           (0)
-#define BMI160_USER_DATA_11_GYRO_Y_MSB__LEN           (8)
-#define BMI160_USER_DATA_11_GYRO_Y_MSB__MSK          (0xFF)
-#define BMI160_USER_DATA_11_GYRO_Y_MSB__REG          (BMI160_USER_DATA_11_ADDR)
-
-/* GYR_Z (LSB) Description - Reg Addr --> (0x10), Bit --> 0...7 */
-#define BMI160_USER_DATA_12_GYRO_Z_LSB__POS           (0)
-#define BMI160_USER_DATA_12_GYRO_Z_LSB__LEN           (8)
-#define BMI160_USER_DATA_12_GYRO_Z_LSB__MSK          (0xFF)
-#define BMI160_USER_DATA_12_GYRO_Z_LSB__REG          (BMI160_USER_DATA_12_ADDR)
-
-/* GYR_Z (MSB) Description - Reg Addr --> (0x11), Bit --> 0...7 */
-#define BMI160_USER_DATA_13_GYRO_Z_MSB__POS           (0)
-#define BMI160_USER_DATA_13_GYRO_Z_MSB__LEN           (8)
-#define BMI160_USER_DATA_13_GYRO_Z_MSB__MSK          (0xFF)
-#define BMI160_USER_DATA_13_GYRO_Z_MSB__REG          (BMI160_USER_DATA_13_ADDR)
-/**************************************************************/
-/**\name	ACCEL DATA XYZ LENGTH, POSITION AND MASK    */
-/**************************************************************/
-/* ACC_X (LSB) Description - Reg Addr --> (0x12), Bit --> 0...7 */
-#define BMI160_USER_DATA_14_ACCEL_X_LSB__POS           (0)
-#define BMI160_USER_DATA_14_ACCEL_X_LSB__LEN           (8)
-#define BMI160_USER_DATA_14_ACCEL_X_LSB__MSK          (0xFF)
-#define BMI160_USER_DATA_14_ACCEL_X_LSB__REG          (BMI160_USER_DATA_14_ADDR)
-
-/* ACC_X (MSB) Description - Reg Addr --> 0x13, Bit --> 0...7 */
-#define BMI160_USER_DATA_15_ACCEL_X_MSB__POS           (0)
-#define BMI160_USER_DATA_15_ACCEL_X_MSB__LEN           (8)
-#define BMI160_USER_DATA_15_ACCEL_X_MSB__MSK          (0xFF)
-#define BMI160_USER_DATA_15_ACCEL_X_MSB__REG          (BMI160_USER_DATA_15_ADDR)
-
-/* ACC_Y (LSB) Description - Reg Addr --> (0x14), Bit --> 0...7 */
-#define BMI160_USER_DATA_16_ACCEL_Y_LSB__POS           (0)
-#define BMI160_USER_DATA_16_ACCEL_Y_LSB__LEN           (8)
-#define BMI160_USER_DATA_16_ACCEL_Y_LSB__MSK          (0xFF)
-#define BMI160_USER_DATA_16_ACCEL_Y_LSB__REG          (BMI160_USER_DATA_16_ADDR)
-
-/* ACC_Y (MSB) Description - Reg Addr --> (0x15), Bit --> 0...7 */
-#define BMI160_USER_DATA_17_ACCEL_Y_MSB__POS           (0)
-#define BMI160_USER_DATA_17_ACCEL_Y_MSB__LEN           (8)
-#define BMI160_USER_DATA_17_ACCEL_Y_MSB__MSK          (0xFF)
-#define BMI160_USER_DATA_17_ACCEL_Y_MSB__REG          (BMI160_USER_DATA_17_ADDR)
-
-/* ACC_Z (LSB) Description - Reg Addr --> 0x16, Bit --> 0...7 */
-#define BMI160_USER_DATA_18_ACCEL_Z_LSB__POS           (0)
-#define BMI160_USER_DATA_18_ACCEL_Z_LSB__LEN           (8)
-#define BMI160_USER_DATA_18_ACCEL_Z_LSB__MSK          (0xFF)
-#define BMI160_USER_DATA_18_ACCEL_Z_LSB__REG          (BMI160_USER_DATA_18_ADDR)
-
-/* ACC_Z (MSB) Description - Reg Addr --> (0x17), Bit --> 0...7 */
-#define BMI160_USER_DATA_19_ACCEL_Z_MSB__POS           (0)
-#define BMI160_USER_DATA_19_ACCEL_Z_MSB__LEN           (8)
-#define BMI160_USER_DATA_19_ACCEL_Z_MSB__MSK          (0xFF)
-#define BMI160_USER_DATA_19_ACCEL_Z_MSB__REG          (BMI160_USER_DATA_19_ADDR)
-/**************************************************************/
-/**\name	SENSOR TIME LENGTH, POSITION AND MASK    */
-/**************************************************************/
-/* SENSORTIME_0 (LSB) Description - Reg Addr --> (0x18), Bit --> 0...7 */
-#define BMI160_USER_SENSORTIME_0_SENSOR_TIME_LSB__POS           (0)
-#define BMI160_USER_SENSORTIME_0_SENSOR_TIME_LSB__LEN           (8)
-#define BMI160_USER_SENSORTIME_0_SENSOR_TIME_LSB__MSK          (0xFF)
-#define BMI160_USER_SENSORTIME_0_SENSOR_TIME_LSB__REG          \
-		(BMI160_USER_SENSORTIME_0_ADDR)
-
-/* SENSORTIME_1 (MSB) Description - Reg Addr --> (0x19), Bit --> 0...7 */
-#define BMI160_USER_SENSORTIME_1_SENSOR_TIME_MSB__POS           (0)
-#define BMI160_USER_SENSORTIME_1_SENSOR_TIME_MSB__LEN           (8)
-#define BMI160_USER_SENSORTIME_1_SENSOR_TIME_MSB__MSK          (0xFF)
-#define BMI160_USER_SENSORTIME_1_SENSOR_TIME_MSB__REG          \
-		(BMI160_USER_SENSORTIME_1_ADDR)
-
-/* SENSORTIME_2 (MSB) Description - Reg Addr --> (0x1A), Bit --> 0...7 */
-#define BMI160_USER_SENSORTIME_2_SENSOR_TIME_MSB__POS           (0)
-#define BMI160_USER_SENSORTIME_2_SENSOR_TIME_MSB__LEN           (8)
-#define BMI160_USER_SENSORTIME_2_SENSOR_TIME_MSB__MSK          (0xFF)
-#define BMI160_USER_SENSORTIME_2_SENSOR_TIME_MSB__REG          \
-		(BMI160_USER_SENSORTIME_2_ADDR)
-/**************************************************************/
-/**\name	GYRO SELF TEST LENGTH, POSITION AND MASK    */
-/**************************************************************/
-/* Status Description - Reg Addr --> 0x1B, Bit --> 1 */
-#define BMI160_USER_STAT_GYRO_SELFTEST_OK__POS          (1)
-#define BMI160_USER_STAT_GYRO_SELFTEST_OK__LEN          (1)
-#define BMI160_USER_STAT_GYRO_SELFTEST_OK__MSK          (0x02)
-#define BMI160_USER_STAT_GYRO_SELFTEST_OK__REG         \
-		(BMI160_USER_STAT_ADDR)
-/**************************************************************/
-/**\name	MAG MANUAL OPERATION LENGTH, POSITION AND MASK    */
-/**************************************************************/
-/* Status Description - Reg Addr --> 0x1B, Bit --> 2 */
-#define BMI160_USER_STAT_MAG_MANUAL_OPERATION__POS          (2)
-#define BMI160_USER_STAT_MAG_MANUAL_OPERATION__LEN          (1)
-#define BMI160_USER_STAT_MAG_MANUAL_OPERATION__MSK          (0x04)
-#define BMI160_USER_STAT_MAG_MANUAL_OPERATION__REG          \
-		(BMI160_USER_STAT_ADDR)
-/**************************************************************/
-/**\name	FOC STATUS LENGTH, POSITION AND MASK    */
-/**************************************************************/
-/* Status Description - Reg Addr --> 0x1B, Bit --> 3 */
-#define BMI160_USER_STAT_FOC_RDY__POS          (3)
-#define BMI160_USER_STAT_FOC_RDY__LEN          (1)
-#define BMI160_USER_STAT_FOC_RDY__MSK          (0x08)
-#define BMI160_USER_STAT_FOC_RDY__REG          (BMI160_USER_STAT_ADDR)
-
-/**************************************************************/
-/**\name	DATA READY LENGTH, POSITION AND MASK FOR ACCEL, MAG AND GYRO*/
-/**************************************************************/
-/* Status Description - Reg Addr --> 0x1B, Bit --> 5 */
-#define BMI160_USER_STAT_DATA_RDY_MAG__POS           (5)
-#define BMI160_USER_STAT_DATA_RDY_MAG__LEN           (1)
-#define BMI160_USER_STAT_DATA_RDY_MAG__MSK           (0x20)
-#define BMI160_USER_STAT_DATA_RDY_MAG__REG           (BMI160_USER_STAT_ADDR)
-
-/* Status Description - Reg Addr --> 0x1B, Bit --> 6 */
-#define BMI160_USER_STAT_DATA_RDY_GYRO__POS           (6)
-#define BMI160_USER_STAT_DATA_RDY_GYRO__LEN           (1)
-#define BMI160_USER_STAT_DATA_RDY_GYRO__MSK           (0x40)
-#define BMI160_USER_STAT_DATA_RDY_GYRO__REG           (BMI160_USER_STAT_ADDR)
-
-/* Status Description - Reg Addr --> 0x1B, Bit --> 7 */
-#define BMI160_USER_STAT_DATA_RDY_ACCEL__POS           (7)
-#define BMI160_USER_STAT_DATA_RDY_ACCEL__LEN           (1)
-#define BMI160_USER_STAT_DATA_RDY_ACCEL__MSK           (0x80)
-#define BMI160_USER_STAT_DATA_RDY_ACCEL__REG           (BMI160_USER_STAT_ADDR)
-/**************************************************************/
-/**\name	INTERRUPT STATUS LENGTH, POSITION AND MASK    */
-/**************************************************************/
-/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 0 */
-#define BMI160_USER_INTR_STAT_0_STEP_INTR__POS           (0)
-#define BMI160_USER_INTR_STAT_0_STEP_INTR__LEN           (1)
-#define BMI160_USER_INTR_STAT_0_STEP_INTR__MSK          (0x01)
-#define BMI160_USER_INTR_STAT_0_STEP_INTR__REG          \
-		(BMI160_USER_INTR_STAT_0_ADDR)
-/**************************************************************/
-/**\name	SIGNIFICANT INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 1 */
-#define BMI160_USER_INTR_STAT_0_SIGNIFICANT_INTR__POS		(1)
-#define BMI160_USER_INTR_STAT_0_SIGNIFICANT_INTR__LEN		(1)
-#define BMI160_USER_INTR_STAT_0_SIGNIFICANT_INTR__MSK		(0x02)
-#define BMI160_USER_INTR_STAT_0_SIGNIFICANT_INTR__REG       \
-		(BMI160_USER_INTR_STAT_0_ADDR)
-/**************************************************************/
-/**\name	ANY_MOTION INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 2 */
-#define BMI160_USER_INTR_STAT_0_ANY_MOTION__POS           (2)
-#define BMI160_USER_INTR_STAT_0_ANY_MOTION__LEN           (1)
-#define BMI160_USER_INTR_STAT_0_ANY_MOTION__MSK          (0x04)
-#define BMI160_USER_INTR_STAT_0_ANY_MOTION__REG          \
-		(BMI160_USER_INTR_STAT_0_ADDR)
-/**************************************************************/
-/**\name	PMU TRIGGER INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 3 */
-#define BMI160_USER_INTR_STAT_0_PMU_TRIGGER__POS           3
-#define BMI160_USER_INTR_STAT_0_PMU_TRIGGER__LEN           (1)
-#define BMI160_USER_INTR_STAT_0_PMU_TRIGGER__MSK          (0x08)
-#define BMI160_USER_INTR_STAT_0_PMU_TRIGGER__REG          \
-		(BMI160_USER_INTR_STAT_0_ADDR)
-/**************************************************************/
-/**\name	DOUBLE TAP INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 4 */
-#define BMI160_USER_INTR_STAT_0_DOUBLE_TAP_INTR__POS           4
-#define BMI160_USER_INTR_STAT_0_DOUBLE_TAP_INTR__LEN           (1)
-#define BMI160_USER_INTR_STAT_0_DOUBLE_TAP_INTR__MSK          (0x10)
-#define BMI160_USER_INTR_STAT_0_DOUBLE_TAP_INTR__REG          \
-		(BMI160_USER_INTR_STAT_0_ADDR)
-/**************************************************************/
-/**\name	SINGLE TAP INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 5 */
-#define BMI160_USER_INTR_STAT_0_SINGLE_TAP_INTR__POS           5
-#define BMI160_USER_INTR_STAT_0_SINGLE_TAP_INTR__LEN           (1)
-#define BMI160_USER_INTR_STAT_0_SINGLE_TAP_INTR__MSK          (0x20)
-#define BMI160_USER_INTR_STAT_0_SINGLE_TAP_INTR__REG          \
-		(BMI160_USER_INTR_STAT_0_ADDR)
-/**************************************************************/
-/**\name	ORIENT INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 6 */
-#define BMI160_USER_INTR_STAT_0_ORIENT__POS           (6)
-#define BMI160_USER_INTR_STAT_0_ORIENT__LEN           (1)
-#define BMI160_USER_INTR_STAT_0_ORIENT__MSK          (0x40)
-#define BMI160_USER_INTR_STAT_0_ORIENT__REG          \
-		(BMI160_USER_INTR_STAT_0_ADDR)
-/**************************************************************/
-/**\name	FLAT INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 7 */
-#define BMI160_USER_INTR_STAT_0_FLAT__POS           (7)
-#define BMI160_USER_INTR_STAT_0_FLAT__LEN           (1)
-#define BMI160_USER_INTR_STAT_0_FLAT__MSK          (0x80)
-#define BMI160_USER_INTR_STAT_0_FLAT__REG          \
-		(BMI160_USER_INTR_STAT_0_ADDR)
-/**************************************************************/
-/**\name	HIGH_G INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_1 Description - Reg Addr --> 0x1D, Bit --> 2 */
-#define BMI160_USER_INTR_STAT_1_HIGH_G_INTR__POS               (2)
-#define BMI160_USER_INTR_STAT_1_HIGH_G_INTR__LEN               (1)
-#define BMI160_USER_INTR_STAT_1_HIGH_G_INTR__MSK              (0x04)
-#define BMI160_USER_INTR_STAT_1_HIGH_G_INTR__REG              \
-		(BMI160_USER_INTR_STAT_1_ADDR)
-/**************************************************************/
-/**\name	LOW_G INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_1 Description - Reg Addr --> 0x1D, Bit --> 3 */
-#define BMI160_USER_INTR_STAT_1_LOW_G_INTR__POS               (3)
-#define BMI160_USER_INTR_STAT_1_LOW_G_INTR__LEN               (1)
-#define BMI160_USER_INTR_STAT_1_LOW_G_INTR__MSK              (0x08)
-#define BMI160_USER_INTR_STAT_1_LOW_G_INTR__REG              \
-		(BMI160_USER_INTR_STAT_1_ADDR)
-/**************************************************************/
-/**\name	DATA READY INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_1 Description - Reg Addr --> 0x1D, Bit --> 4 */
-#define BMI160_USER_INTR_STAT_1_DATA_RDY_INTR__POS               (4)
-#define BMI160_USER_INTR_STAT_1_DATA_RDY_INTR__LEN               (1)
-#define BMI160_USER_INTR_STAT_1_DATA_RDY_INTR__MSK               (0x10)
-#define BMI160_USER_INTR_STAT_1_DATA_RDY_INTR__REG               \
-		(BMI160_USER_INTR_STAT_1_ADDR)
-/**************************************************************/
-/**\name	FIFO FULL INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_1 Description - Reg Addr --> 0x1D, Bit --> 5 */
-#define BMI160_USER_INTR_STAT_1_FIFO_FULL_INTR__POS               (5)
-#define BMI160_USER_INTR_STAT_1_FIFO_FULL_INTR__LEN               (1)
-#define BMI160_USER_INTR_STAT_1_FIFO_FULL_INTR__MSK               (0x20)
-#define BMI160_USER_INTR_STAT_1_FIFO_FULL_INTR__REG               \
-		(BMI160_USER_INTR_STAT_1_ADDR)
-/**************************************************************/
-/**\name FIFO WATERMARK INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_1 Description - Reg Addr --> 0x1D, Bit --> 6 */
-#define BMI160_USER_INTR_STAT_1_FIFO_WM_INTR__POS               (6)
-#define BMI160_USER_INTR_STAT_1_FIFO_WM_INTR__LEN               (1)
-#define BMI160_USER_INTR_STAT_1_FIFO_WM_INTR__MSK               (0x40)
-#define BMI160_USER_INTR_STAT_1_FIFO_WM_INTR__REG               \
-		(BMI160_USER_INTR_STAT_1_ADDR)
-/**************************************************************/
-/**\name	NO MOTION INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_1 Description - Reg Addr --> 0x1D, Bit --> 7 */
-#define BMI160_USER_INTR_STAT_1_NOMOTION_INTR__POS               (7)
-#define BMI160_USER_INTR_STAT_1_NOMOTION_INTR__LEN               (1)
-#define BMI160_USER_INTR_STAT_1_NOMOTION_INTR__MSK               (0x80)
-#define BMI160_USER_INTR_STAT_1_NOMOTION_INTR__REG               \
-		(BMI160_USER_INTR_STAT_1_ADDR)
-/**************************************************************/
-/**\name	ANY MOTION-XYZ AXIS INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 0 */
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_X__POS               (0)
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_X__LEN               (1)
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_X__MSK               (0x01)
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_X__REG               \
-		(BMI160_USER_INTR_STAT_2_ADDR)
-
-/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 1 */
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Y__POS               (1)
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Y__LEN               (1)
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Y__MSK               (0x02)
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Y__REG               \
-		(BMI160_USER_INTR_STAT_2_ADDR)
-
-/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 2 */
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Z__POS               (2)
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Z__LEN               (1)
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Z__MSK               (0x04)
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Z__REG               \
-		(BMI160_USER_INTR_STAT_2_ADDR)
-/**************************************************************/
-/**\name	ANY MOTION SIGN LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 3 */
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_SIGN__POS               (3)
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_SIGN__LEN               (1)
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_SIGN__MSK               (0x08)
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_SIGN__REG               \
-		(BMI160_USER_INTR_STAT_2_ADDR)
-/**************************************************************/
-/**\name	TAP_XYZ AND SIGN LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 4 */
-#define BMI160_USER_INTR_STAT_2_TAP_FIRST_X__POS               (4)
-#define BMI160_USER_INTR_STAT_2_TAP_FIRST_X__LEN               (1)
-#define BMI160_USER_INTR_STAT_2_TAP_FIRST_X__MSK               (0x10)
-#define BMI160_USER_INTR_STAT_2_TAP_FIRST_X__REG               \
-		(BMI160_USER_INTR_STAT_2_ADDR)
-
-/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 5 */
-#define BMI160_USER_INTR_STAT_2_TAP_FIRST_Y__POS               (5)
-#define BMI160_USER_INTR_STAT_2_TAP_FIRST_Y__LEN               (1)
-#define BMI160_USER_INTR_STAT_2_TAP_FIRST_Y__MSK               (0x20)
-#define BMI160_USER_INTR_STAT_2_TAP_FIRST_Y__REG               \
-		(BMI160_USER_INTR_STAT_2_ADDR)
-
-/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 6 */
-#define BMI160_USER_INTR_STAT_2_TAP_FIRST_Z__POS               (6)
-#define BMI160_USER_INTR_STAT_2_TAP_FIRST_Z__LEN               (1)
-#define BMI160_USER_INTR_STAT_2_TAP_FIRST_Z__MSK               (0x40)
-#define BMI160_USER_INTR_STAT_2_TAP_FIRST_Z__REG               \
-		(BMI160_USER_INTR_STAT_2_ADDR)
-
-/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 7 */
-#define BMI160_USER_INTR_STAT_2_TAP_SIGN__POS               (7)
-#define BMI160_USER_INTR_STAT_2_TAP_SIGN__LEN               (1)
-#define BMI160_USER_INTR_STAT_2_TAP_SIGN__MSK               (0x80)
-#define BMI160_USER_INTR_STAT_2_TAP_SIGN__REG               \
-		(BMI160_USER_INTR_STAT_2_ADDR)
-/**************************************************************/
-/**\name	INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 0...7 */
-#define BMI160_USER_INTR_STAT_2__POS               (0)
-#define BMI160_USER_INTR_STAT_2__LEN               (8)
-#define BMI160_USER_INTR_STAT_2__MSK               (0xFF)
-#define BMI160_USER_INTR_STAT_2__REG               \
-		(BMI160_USER_INTR_STAT_2_ADDR)
-/**************************************************************/
-/**\name	HIGH_G-XYZ AND SIGN LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_3 Description - Reg Addr --> (0x1F), Bit --> 0 */
-#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_X__POS               (0)
-#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_X__LEN               (1)
-#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_X__MSK               (0x01)
-#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_X__REG               \
-		(BMI160_USER_INTR_STAT_3_ADDR)
-
-/* Int_Status_3 Description - Reg Addr --> 0x1E, Bit --> 1 */
-#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Y__POS               (1)
-#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Y__LEN               (1)
-#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Y__MSK               (0x02)
-#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Y__REG               \
-		(BMI160_USER_INTR_STAT_3_ADDR)
-
-/* Int_Status_3 Description - Reg Addr --> (0x1F), Bit --> 2 */
-#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Z__POS               (2)
-#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Z__LEN               (1)
-#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Z__MSK               (0x04)
-#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Z__REG               \
-		(BMI160_USER_INTR_STAT_3_ADDR)
-
-/* Int_Status_3 Description - Reg Addr --> (0x1F), Bit --> 3 */
-#define BMI160_USER_INTR_STAT_3_HIGH_G_SIGN__POS               (3)
-#define BMI160_USER_INTR_STAT_3_HIGH_G_SIGN__LEN               (1)
-#define BMI160_USER_INTR_STAT_3_HIGH_G_SIGN__MSK               (0x08)
-#define BMI160_USER_INTR_STAT_3_HIGH_G_SIGN__REG               \
-		(BMI160_USER_INTR_STAT_3_ADDR)
-/**************************************************************/
-/**\name	ORIENT XY and Z AXIS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_3 Description - Reg Addr --> (0x1F), Bit --> 4...5 */
-#define BMI160_USER_INTR_STAT_3_ORIENT_XY__POS               (4)
-#define BMI160_USER_INTR_STAT_3_ORIENT_XY__LEN               (2)
-#define BMI160_USER_INTR_STAT_3_ORIENT_XY__MSK               (0x30)
-#define BMI160_USER_INTR_STAT_3_ORIENT_XY__REG               \
-		(BMI160_USER_INTR_STAT_3_ADDR)
-
-/* Int_Status_3 Description - Reg Addr --> (0x1F), Bit --> 6 */
-#define BMI160_USER_INTR_STAT_3_ORIENT_Z__POS               (6)
-#define BMI160_USER_INTR_STAT_3_ORIENT_Z__LEN               (1)
-#define BMI160_USER_INTR_STAT_3_ORIENT_Z__MSK               (0x40)
-#define BMI160_USER_INTR_STAT_3_ORIENT_Z__REG               \
-		(BMI160_USER_INTR_STAT_3_ADDR)
-/**************************************************************/
-/**\name	FLAT LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_3 Description - Reg Addr --> (0x1F), Bit --> 7 */
-#define BMI160_USER_INTR_STAT_3_FLAT__POS               (7)
-#define BMI160_USER_INTR_STAT_3_FLAT__LEN               (1)
-#define BMI160_USER_INTR_STAT_3_FLAT__MSK               (0x80)
-#define BMI160_USER_INTR_STAT_3_FLAT__REG               \
-		(BMI160_USER_INTR_STAT_3_ADDR)
-/**************************************************************/
-/**\name	(0x1F) LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_3 Description - Reg Addr --> (0x1F), Bit --> 0...7 */
-#define BMI160_USER_INTR_STAT_3__POS               (0)
-#define BMI160_USER_INTR_STAT_3__LEN               (8)
-#define BMI160_USER_INTR_STAT_3__MSK               (0xFF)
-#define BMI160_USER_INTR_STAT_3__REG               \
-		(BMI160_USER_INTR_STAT_3_ADDR)
-/**************************************************************/
-/**\name	TEMPERATURE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Temperature Description - LSB Reg Addr --> (0x20), Bit --> 0...7 */
-#define BMI160_USER_TEMP_LSB_VALUE__POS               (0)
-#define BMI160_USER_TEMP_LSB_VALUE__LEN               (8)
-#define BMI160_USER_TEMP_LSB_VALUE__MSK               (0xFF)
-#define BMI160_USER_TEMP_LSB_VALUE__REG               \
-		(BMI160_USER_TEMPERATURE_0_ADDR)
-
-/* Temperature Description - LSB Reg Addr --> 0x21, Bit --> 0...7 */
-#define BMI160_USER_TEMP_MSB_VALUE__POS               (0)
-#define BMI160_USER_TEMP_MSB_VALUE__LEN               (8)
-#define BMI160_USER_TEMP_MSB_VALUE__MSK               (0xFF)
-#define BMI160_USER_TEMP_MSB_VALUE__REG               \
-		(BMI160_USER_TEMPERATURE_1_ADDR)
-
-#ifdef FIFO_ENABLE
-/**************************************************************/
-/**\name	FIFO BYTE COUNTER LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Fifo_Length0 Description - Reg Addr --> 0x22, Bit --> 0...7 */
-#define BMI160_USER_FIFO_BYTE_COUNTER_LSB__POS           (0)
-#define BMI160_USER_FIFO_BYTE_COUNTER_LSB__LEN           (8)
-#define BMI160_USER_FIFO_BYTE_COUNTER_LSB__MSK          (0xFF)
-#define BMI160_USER_FIFO_BYTE_COUNTER_LSB__REG          \
-		(BMI160_USER_FIFO_LENGTH_0_ADDR)
-
-/*Fifo_Length1 Description - Reg Addr --> 0x23, Bit --> 0...2 */
-#define BMI160_USER_FIFO_BYTE_COUNTER_MSB__POS           (0)
-#define BMI160_USER_FIFO_BYTE_COUNTER_MSB__LEN           3
-#define BMI160_USER_FIFO_BYTE_COUNTER_MSB__MSK          (0x07)
-#define BMI160_USER_FIFO_BYTE_COUNTER_MSB__REG          \
-		(BMI160_USER_FIFO_LENGTH_1_ADDR)
-
-/**************************************************************/
-/**\name	FIFO DATA LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Fifo_Data Description - Reg Addr --> 0x24, Bit --> 0...7 */
-#define BMI160_USER_FIFO_DATA__POS           (0)
-#define BMI160_USER_FIFO_DATA__LEN           (8)
-#define BMI160_USER_FIFO_DATA__MSK          (0xFF)
-#define BMI160_USER_FIFO_DATA__REG          (BMI160_USER_FIFO_DATA_ADDR)
-#endif
-/**************************************************************/
-/**\name	ACCEL CONFIGURATION LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Acc_Conf Description - Reg Addr --> (0x40), Bit --> 0...3 */
-#define BMI160_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE__POS               (0)
-#define BMI160_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE__LEN               (4)
-#define BMI160_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE__MSK               (0x0F)
-#define BMI160_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE__REG		       \
-(BMI160_USER_ACCEL_CONFIG_ADDR)
-
-/* Acc_Conf Description - Reg Addr --> (0x40), Bit --> 4...6 */
-#define BMI160_USER_ACCEL_CONFIG_ACCEL_BW__POS               (4)
-#define BMI160_USER_ACCEL_CONFIG_ACCEL_BW__LEN               (3)
-#define BMI160_USER_ACCEL_CONFIG_ACCEL_BW__MSK               (0x70)
-#define BMI160_USER_ACCEL_CONFIG_ACCEL_BW__REG	(BMI160_USER_ACCEL_CONFIG_ADDR)
-
-/* Acc_Conf Description - Reg Addr --> (0x40), Bit --> 7 */
-#define BMI160_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING__POS           (7)
-#define BMI160_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING__LEN           (1)
-#define BMI160_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING__MSK           (0x80)
-#define BMI160_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING__REG	\
-(BMI160_USER_ACCEL_CONFIG_ADDR)
-
-/* Acc_Range Description - Reg Addr --> 0x41, Bit --> 0...3 */
-#define BMI160_USER_ACCEL_RANGE__POS               (0)
-#define BMI160_USER_ACCEL_RANGE__LEN               (4)
-#define BMI160_USER_ACCEL_RANGE__MSK               (0x0F)
-#define BMI160_USER_ACCEL_RANGE__REG              \
-(BMI160_USER_ACCEL_RANGE_ADDR)
-/**************************************************************/
-/**\name	GYRO CONFIGURATION LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Gyro_Conf Description - Reg Addr --> (0x42), Bit --> 0...3 */
-#define BMI160_USER_GYRO_CONFIG_OUTPUT_DATA_RATE__POS               (0)
-#define BMI160_USER_GYRO_CONFIG_OUTPUT_DATA_RATE__LEN               (4)
-#define BMI160_USER_GYRO_CONFIG_OUTPUT_DATA_RATE__MSK               (0x0F)
-#define BMI160_USER_GYRO_CONFIG_OUTPUT_DATA_RATE__REG               \
-(BMI160_USER_GYRO_CONFIG_ADDR)
-
-/* Gyro_Conf Description - Reg Addr --> (0x42), Bit --> 4...5 */
-#define BMI160_USER_GYRO_CONFIG_BW__POS               (4)
-#define BMI160_USER_GYRO_CONFIG_BW__LEN               (2)
-#define BMI160_USER_GYRO_CONFIG_BW__MSK               (0x30)
-#define BMI160_USER_GYRO_CONFIG_BW__REG               \
-(BMI160_USER_GYRO_CONFIG_ADDR)
-
-/* Gyr_Range Description - Reg Addr --> 0x43, Bit --> 0...2 */
-#define BMI160_USER_GYRO_RANGE__POS               (0)
-#define BMI160_USER_GYRO_RANGE__LEN               (3)
-#define BMI160_USER_GYRO_RANGE__MSK               (0x07)
-#define BMI160_USER_GYRO_RANGE__REG               (BMI160_USER_GYRO_RANGE_ADDR)
-/**************************************************************/
-/**\name	MAG CONFIGURATION LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Mag_Conf Description - Reg Addr --> (0x44), Bit --> 0...3 */
-#define BMI160_USER_MAG_CONFIG_OUTPUT_DATA_RATE__POS               (0)
-#define BMI160_USER_MAG_CONFIG_OUTPUT_DATA_RATE__LEN               (4)
-#define BMI160_USER_MAG_CONFIG_OUTPUT_DATA_RATE__MSK               (0x0F)
-#define BMI160_USER_MAG_CONFIG_OUTPUT_DATA_RATE__REG               \
-(BMI160_USER_MAG_CONFIG_ADDR)
-
-#ifdef FIFO_ENABLE
-/**************************************************************/
-/**\name	FIFO DOWNS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Fifo_Downs Description - Reg Addr --> 0x45, Bit --> 0...2 */
-#define BMI160_USER_FIFO_DOWN_GYRO__POS               (0)
-#define BMI160_USER_FIFO_DOWN_GYRO__LEN               (3)
-#define BMI160_USER_FIFO_DOWN_GYRO__MSK               (0x07)
-#define BMI160_USER_FIFO_DOWN_GYRO__REG	(BMI160_USER_FIFO_DOWN_ADDR)
-/**************************************************************/
-/**\name	FIFO FILTER FOR ACCEL AND GYRO LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Fifo_filter Description - Reg Addr --> 0x45, Bit --> 3 */
-#define BMI160_USER_FIFO_FILTER_GYRO__POS               (3)
-#define BMI160_USER_FIFO_FILTER_GYRO__LEN               (1)
-#define BMI160_USER_FIFO_FILTER_GYRO__MSK               (0x08)
-#define BMI160_USER_FIFO_FILTER_GYRO__REG	  (BMI160_USER_FIFO_DOWN_ADDR)
-
-/* Fifo_Downs Description - Reg Addr --> 0x45, Bit --> 4...6 */
-#define BMI160_USER_FIFO_DOWN_ACCEL__POS               (4)
-#define BMI160_USER_FIFO_DOWN_ACCEL__LEN               (3)
-#define BMI160_USER_FIFO_DOWN_ACCEL__MSK               (0x70)
-#define BMI160_USER_FIFO_DOWN_ACCEL__REG	(BMI160_USER_FIFO_DOWN_ADDR)
-
-/* Fifo_FILT Description - Reg Addr --> 0x45, Bit --> 7 */
-#define BMI160_USER_FIFO_FILTER_ACCEL__POS               (7)
-#define BMI160_USER_FIFO_FILTER_ACCEL__LEN               (1)
-#define BMI160_USER_FIFO_FILTER_ACCEL__MSK               (0x80)
-#define BMI160_USER_FIFO_FILTER_ACCEL__REG	(BMI160_USER_FIFO_DOWN_ADDR)
-/**************************************************************/
-/**\name	FIFO WATER MARK LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Fifo_Config_0 Description - Reg Addr --> 0x46, Bit --> 0...7 */
-#define BMI160_USER_FIFO_WM__POS               (0)
-#define BMI160_USER_FIFO_WM__LEN               (8)
-#define BMI160_USER_FIFO_WM__MSK               (0xFF)
-#define BMI160_USER_FIFO_WM__REG	(BMI160_USER_FIFO_CONFIG_0_ADDR)
-/**************************************************************/
-/**\name	FIFO TIME LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Fifo_Config_1 Description - Reg Addr --> 0x47, Bit --> 1 */
-#define BMI160_USER_FIFO_TIME_ENABLE__POS               (1)
-#define BMI160_USER_FIFO_TIME_ENABLE__LEN               (1)
-#define BMI160_USER_FIFO_TIME_ENABLE__MSK               (0x02)
-#define BMI160_USER_FIFO_TIME_ENABLE__REG	(BMI160_USER_FIFO_CONFIG_1_ADDR)
-/**************************************************************/
-/**\name	FIFO TAG INTERRUPT LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Fifo_Config_1 Description - Reg Addr --> 0x47, Bit --> 2 */
-#define BMI160_USER_FIFO_TAG_INTR2_ENABLE__POS               (2)
-#define BMI160_USER_FIFO_TAG_INTR2_ENABLE__LEN               (1)
-#define BMI160_USER_FIFO_TAG_INTR2_ENABLE__MSK               (0x04)
-#define BMI160_USER_FIFO_TAG_INTR2_ENABLE__REG	(BMI160_USER_FIFO_CONFIG_1_ADDR)
-
-/* Fifo_Config_1 Description - Reg Addr --> 0x47, Bit --> 3 */
-#define BMI160_USER_FIFO_TAG_INTR1_ENABLE__POS               (3)
-#define BMI160_USER_FIFO_TAG_INTR1_ENABLE__LEN               (1)
-#define BMI160_USER_FIFO_TAG_INTR1_ENABLE__MSK               (0x08)
-#define BMI160_USER_FIFO_TAG_INTR1_ENABLE__REG	(BMI160_USER_FIFO_CONFIG_1_ADDR)
-/**************************************************************/
-/**\name	FIFO HEADER LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Fifo_Config_1 Description - Reg Addr --> 0x47, Bit --> 4 */
-#define BMI160_USER_FIFO_HEADER_ENABLE__POS               (4)
-#define BMI160_USER_FIFO_HEADER_ENABLE__LEN               (1)
-#define BMI160_USER_FIFO_HEADER_ENABLE__MSK               (0x10)
-#define BMI160_USER_FIFO_HEADER_ENABLE__REG		         \
-(BMI160_USER_FIFO_CONFIG_1_ADDR)
-/**************************************************************/
-/**\name	FIFO MAG ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Fifo_Config_1 Description - Reg Addr --> 0x47, Bit --> 5 */
-#define BMI160_USER_FIFO_MAG_ENABLE__POS               (5)
-#define BMI160_USER_FIFO_MAG_ENABLE__LEN               (1)
-#define BMI160_USER_FIFO_MAG_ENABLE__MSK               (0x20)
-#define BMI160_USER_FIFO_MAG_ENABLE__REG		     \
-(BMI160_USER_FIFO_CONFIG_1_ADDR)
-/**************************************************************/
-/**\name	FIFO ACCEL ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Fifo_Config_1 Description - Reg Addr --> 0x47, Bit --> 6 */
-#define BMI160_USER_FIFO_ACCEL_ENABLE__POS               (6)
-#define BMI160_USER_FIFO_ACCEL_ENABLE__LEN               (1)
-#define BMI160_USER_FIFO_ACCEL_ENABLE__MSK               (0x40)
-#define BMI160_USER_FIFO_ACCEL_ENABLE__REG		        \
-(BMI160_USER_FIFO_CONFIG_1_ADDR)
-/**************************************************************/
-/**\name	FIFO GYRO ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Fifo_Config_1 Description - Reg Addr --> 0x47, Bit --> 7 */
-#define BMI160_USER_FIFO_GYRO_ENABLE__POS               (7)
-#define BMI160_USER_FIFO_GYRO_ENABLE__LEN               (1)
-#define BMI160_USER_FIFO_GYRO_ENABLE__MSK               (0x80)
-#define BMI160_USER_FIFO_GYRO_ENABLE__REG		       \
-(BMI160_USER_FIFO_CONFIG_1_ADDR)
-#endif
-/**************************************************************/
-/**\name	MAG I2C ADDRESS SELECTION LENGTH, POSITION AND MASK*/
-/**************************************************************/
-
-/* Mag_IF_0 Description - Reg Addr --> 0x4b, Bit --> 1...7 */
-#define BMI160_USER_I2C_DEVICE_ADDR__POS               (1)
-#define BMI160_USER_I2C_DEVICE_ADDR__LEN               (7)
-#define BMI160_USER_I2C_DEVICE_ADDR__MSK               (0xFE)
-#define BMI160_USER_I2C_DEVICE_ADDR__REG	(BMI160_USER_MAG_IF_0_ADDR)
-/**************************************************************/
-/**\name MAG CONFIGURATION FOR SECONDARY
-	INTERFACE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Mag_IF_1 Description - Reg Addr --> 0x4c, Bit --> 0...1 */
-#define BMI160_USER_MAG_BURST__POS               (0)
-#define BMI160_USER_MAG_BURST__LEN               (2)
-#define BMI160_USER_MAG_BURST__MSK               (0x03)
-#define BMI160_USER_MAG_BURST__REG               (BMI160_USER_MAG_IF_1_ADDR)
-
-/* Mag_IF_1 Description - Reg Addr --> 0x4c, Bit --> 2...5 */
-#define BMI160_USER_MAG_OFFSET__POS               (2)
-#define BMI160_USER_MAG_OFFSET__LEN               (4)
-#define BMI160_USER_MAG_OFFSET__MSK               (0x3C)
-#define BMI160_USER_MAG_OFFSET__REG               (BMI160_USER_MAG_IF_1_ADDR)
-
-/* Mag_IF_1 Description - Reg Addr --> 0x4c, Bit --> 7 */
-#define BMI160_USER_MAG_MANUAL_ENABLE__POS               (7)
-#define BMI160_USER_MAG_MANUAL_ENABLE__LEN               (1)
-#define BMI160_USER_MAG_MANUAL_ENABLE__MSK               (0x80)
-#define BMI160_USER_MAG_MANUAL_ENABLE__REG               \
-(BMI160_USER_MAG_IF_1_ADDR)
-
-/* Mag_IF_2 Description - Reg Addr --> 0x4d, Bit -->0... 7 */
-#define BMI160_USER_READ_ADDR__POS               (0)
-#define BMI160_USER_READ_ADDR__LEN               (8)
-#define BMI160_USER_READ_ADDR__MSK               (0xFF)
-#define BMI160_USER_READ_ADDR__REG               (BMI160_USER_MAG_IF_2_ADDR)
-
-/* Mag_IF_3 Description - Reg Addr --> 0x4e, Bit -->0... 7 */
-#define BMI160_USER_WRITE_ADDR__POS               (0)
-#define BMI160_USER_WRITE_ADDR__LEN               (8)
-#define BMI160_USER_WRITE_ADDR__MSK               (0xFF)
-#define BMI160_USER_WRITE_ADDR__REG               (BMI160_USER_MAG_IF_3_ADDR)
-
-/* Mag_IF_4 Description - Reg Addr --> 0x4f, Bit -->0... 7 */
-#define BMI160_USER_WRITE_DATA__POS               (0)
-#define BMI160_USER_WRITE_DATA__LEN               (8)
-#define BMI160_USER_WRITE_DATA__MSK               (0xFF)
-#define BMI160_USER_WRITE_DATA__REG               (BMI160_USER_MAG_IF_4_ADDR)
-/**************************************************************/
-/**\name	ANY MOTION XYZ AXIS ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_En_0 Description - Reg Addr --> 0x50, Bit -->0 */
-#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE__POS               (0)
-#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE__LEN               (1)
-#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE__MSK               (0x01)
-#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE__REG	              \
-(BMI160_USER_INTR_ENABLE_0_ADDR)
-
-/* Int_En_0 Description - Reg Addr --> 0x50, Bit -->1 */
-#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE__POS               (1)
-#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE__LEN               (1)
-#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE__MSK               (0x02)
-#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE__REG	          \
-(BMI160_USER_INTR_ENABLE_0_ADDR)
-
-/* Int_En_0 Description - Reg Addr --> 0x50, Bit -->2 */
-#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE__POS               (2)
-#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE__LEN               (1)
-#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE__MSK               (0x04)
-#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE__REG	            \
-(BMI160_USER_INTR_ENABLE_0_ADDR)
-/**************************************************************/
-/**\name	DOUBLE TAP ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_En_0 Description - Reg Addr --> 0x50, Bit -->4 */
-#define BMI160_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE__POS               (4)
-#define BMI160_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE__LEN               (1)
-#define BMI160_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE__MSK               (0x10)
-#define BMI160_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE__REG	        \
-(BMI160_USER_INTR_ENABLE_0_ADDR)
-/**************************************************************/
-/**\name	SINGLE TAP ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_En_0 Description - Reg Addr --> 0x50, Bit -->5 */
-#define BMI160_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE__POS               (5)
-#define BMI160_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE__LEN               (1)
-#define BMI160_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE__MSK               (0x20)
-#define BMI160_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE__REG	       \
-(BMI160_USER_INTR_ENABLE_0_ADDR)
-/**************************************************************/
-/**\name	ORIENT ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_En_0 Description - Reg Addr --> 0x50, Bit -->6 */
-#define BMI160_USER_INTR_ENABLE_0_ORIENT_ENABLE__POS               (6)
-#define BMI160_USER_INTR_ENABLE_0_ORIENT_ENABLE__LEN               (1)
-#define BMI160_USER_INTR_ENABLE_0_ORIENT_ENABLE__MSK               (0x40)
-#define BMI160_USER_INTR_ENABLE_0_ORIENT_ENABLE__REG	           \
-(BMI160_USER_INTR_ENABLE_0_ADDR)
-/**************************************************************/
-/**\name	FLAT ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_En_0 Description - Reg Addr --> 0x50, Bit -->7 */
-#define BMI160_USER_INTR_ENABLE_0_FLAT_ENABLE__POS               (7)
-#define BMI160_USER_INTR_ENABLE_0_FLAT_ENABLE__LEN               (1)
-#define BMI160_USER_INTR_ENABLE_0_FLAT_ENABLE__MSK               (0x80)
-#define BMI160_USER_INTR_ENABLE_0_FLAT_ENABLE__REG	           \
-(BMI160_USER_INTR_ENABLE_0_ADDR)
-/**************************************************************/
-/**\name	HIGH_G XYZ ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_En_1 Description - Reg Addr --> (0x51), Bit -->0 */
-#define BMI160_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE__POS               (0)
-#define BMI160_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE__LEN               (1)
-#define BMI160_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE__MSK               (0x01)
-#define BMI160_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE__REG	           \
-(BMI160_USER_INTR_ENABLE_1_ADDR)
-
-/* Int_En_1 Description - Reg Addr --> (0x51), Bit -->1 */
-#define BMI160_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE__POS               (1)
-#define BMI160_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE__LEN               (1)
-#define BMI160_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE__MSK               (0x02)
-#define BMI160_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE__REG	           \
-(BMI160_USER_INTR_ENABLE_1_ADDR)
-
-/* Int_En_1 Description - Reg Addr --> (0x51), Bit -->2 */
-#define BMI160_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE__POS               (2)
-#define BMI160_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE__LEN               (1)
-#define BMI160_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE__MSK               (0x04)
-#define BMI160_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE__REG	           \
-(BMI160_USER_INTR_ENABLE_1_ADDR)
-/**************************************************************/
-/**\name	LOW_G ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_En_1 Description - Reg Addr --> (0x51), Bit -->3 */
-#define BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__POS               (3)
-#define BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__LEN               (1)
-#define BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__MSK               (0x08)
-#define BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__REG	          \
-(BMI160_USER_INTR_ENABLE_1_ADDR)
-/**************************************************************/
-/**\name	DATA READY ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_En_1 Description - Reg Addr --> (0x51), Bit -->4 */
-#define BMI160_USER_INTR_ENABLE_1_DATA_RDY_ENABLE__POS               (4)
-#define BMI160_USER_INTR_ENABLE_1_DATA_RDY_ENABLE__LEN               (1)
-#define BMI160_USER_INTR_ENABLE_1_DATA_RDY_ENABLE__MSK               (0x10)
-#define BMI160_USER_INTR_ENABLE_1_DATA_RDY_ENABLE__REG	            \
-(BMI160_USER_INTR_ENABLE_1_ADDR)
-
-#ifdef FIFO_ENABLE
-/**************************************************************/
-/**\name	FIFO FULL AND WATER MARK ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_En_1 Description - Reg Addr --> (0x51), Bit -->5 */
-#define BMI160_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE__POS               (5)
-#define BMI160_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE__LEN               (1)
-#define BMI160_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE__MSK               (0x20)
-#define BMI160_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE__REG	              \
-(BMI160_USER_INTR_ENABLE_1_ADDR)
-
-/* Int_En_1 Description - Reg Addr --> (0x51), Bit -->6 */
-#define BMI160_USER_INTR_ENABLE_1_FIFO_WM_ENABLE__POS               (6)
-#define BMI160_USER_INTR_ENABLE_1_FIFO_WM_ENABLE__LEN               (1)
-#define BMI160_USER_INTR_ENABLE_1_FIFO_WM_ENABLE__MSK               (0x40)
-#define BMI160_USER_INTR_ENABLE_1_FIFO_WM_ENABLE__REG	           \
-(BMI160_USER_INTR_ENABLE_1_ADDR)
-#endif
-/**************************************************************/
-/**\name	NO MOTION XYZ ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_En_2 Description - Reg Addr --> (0x52), Bit -->0 */
-#define BMI160_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE__POS               (0)
-#define BMI160_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE__LEN               (1)
-#define BMI160_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE__MSK               (0x01)
-#define BMI160_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE__REG	  \
-(BMI160_USER_INTR_ENABLE_2_ADDR)
-
-/* Int_En_2 Description - Reg Addr --> (0x52), Bit -->1 */
-#define BMI160_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE__POS               (1)
-#define BMI160_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE__LEN               (1)
-#define BMI160_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE__MSK               (0x02)
-#define BMI160_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE__REG	  \
-(BMI160_USER_INTR_ENABLE_2_ADDR)
-
-/* Int_En_2 Description - Reg Addr --> (0x52), Bit -->2 */
-#define BMI160_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE__POS               (2)
-#define BMI160_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE__LEN               (1)
-#define BMI160_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE__MSK               (0x04)
-#define BMI160_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE__REG	  \
-(BMI160_USER_INTR_ENABLE_2_ADDR)
-/**************************************************************/
-/**\name	STEP DETECTOR ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_En_2 Description - Reg Addr --> (0x52), Bit -->3 */
-#define BMI160_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE__POS               (3)
-#define BMI160_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE__LEN               (1)
-#define BMI160_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE__MSK               (0x08)
-#define BMI160_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE__REG	  \
-(BMI160_USER_INTR_ENABLE_2_ADDR)
-/**************************************************************/
-/**\name	EDGE CONTROL ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->0 */
-#define BMI160_USER_INTR1_EDGE_CTRL__POS               (0)
-#define BMI160_USER_INTR1_EDGE_CTRL__LEN               (1)
-#define BMI160_USER_INTR1_EDGE_CTRL__MSK               (0x01)
-#define BMI160_USER_INTR1_EDGE_CTRL__REG		\
-(BMI160_USER_INTR_OUT_CTRL_ADDR)
-/**************************************************************/
-/**\name	LEVEL CONTROL ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->1 */
-#define BMI160_USER_INTR1_LEVEL__POS               (1)
-#define BMI160_USER_INTR1_LEVEL__LEN               (1)
-#define BMI160_USER_INTR1_LEVEL__MSK               (0x02)
-#define BMI160_USER_INTR1_LEVEL__REG               \
-(BMI160_USER_INTR_OUT_CTRL_ADDR)
-/**************************************************************/
-/**\name	OUTPUT TYPE ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->2 */
-#define BMI160_USER_INTR1_OUTPUT_TYPE__POS               (2)
-#define BMI160_USER_INTR1_OUTPUT_TYPE__LEN               (1)
-#define BMI160_USER_INTR1_OUTPUT_TYPE__MSK               (0x04)
-#define BMI160_USER_INTR1_OUTPUT_TYPE__REG               \
-(BMI160_USER_INTR_OUT_CTRL_ADDR)
-/**************************************************************/
-/**\name	OUTPUT TYPE ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->3 */
-#define BMI160_USER_INTR1_OUTPUT_ENABLE__POS               (3)
-#define BMI160_USER_INTR1_OUTPUT_ENABLE__LEN               (1)
-#define BMI160_USER_INTR1_OUTPUT_ENABLE__MSK               (0x08)
-#define BMI160_USER_INTR1_OUTPUT_ENABLE__REG		\
-(BMI160_USER_INTR_OUT_CTRL_ADDR)
-/**************************************************************/
-/**\name	EDGE CONTROL ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->4 */
-#define BMI160_USER_INTR2_EDGE_CTRL__POS               (4)
-#define BMI160_USER_INTR2_EDGE_CTRL__LEN               (1)
-#define BMI160_USER_INTR2_EDGE_CTRL__MSK               (0x10)
-#define BMI160_USER_INTR2_EDGE_CTRL__REG		\
-(BMI160_USER_INTR_OUT_CTRL_ADDR)
-/**************************************************************/
-/**\name	LEVEL CONTROL ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->5 */
-#define BMI160_USER_INTR2_LEVEL__POS               (5)
-#define BMI160_USER_INTR2_LEVEL__LEN               (1)
-#define BMI160_USER_INTR2_LEVEL__MSK               (0x20)
-#define BMI160_USER_INTR2_LEVEL__REG               \
-(BMI160_USER_INTR_OUT_CTRL_ADDR)
-/**************************************************************/
-/**\name	OUTPUT TYPE ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->6 */
-#define BMI160_USER_INTR2_OUTPUT_TYPE__POS               (6)
-#define BMI160_USER_INTR2_OUTPUT_TYPE__LEN               (1)
-#define BMI160_USER_INTR2_OUTPUT_TYPE__MSK               (0x40)
-#define BMI160_USER_INTR2_OUTPUT_TYPE__REG               \
-(BMI160_USER_INTR_OUT_CTRL_ADDR)
-
-/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->7 */
-#define BMI160_USER_INTR2_OUTPUT_EN__POS               (7)
-#define BMI160_USER_INTR2_OUTPUT_EN__LEN               (1)
-#define BMI160_USER_INTR2_OUTPUT_EN__MSK               (0x80)
-#define BMI160_USER_INTR2_OUTPUT_EN__REG		\
-(BMI160_USER_INTR_OUT_CTRL_ADDR)
-/**************************************************************/
-/**\name	LATCH INTERRUPT LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Latch Description - Reg Addr --> 0x54, Bit -->0...3 */
-#define BMI160_USER_INTR_LATCH__POS               (0)
-#define BMI160_USER_INTR_LATCH__LEN               (4)
-#define BMI160_USER_INTR_LATCH__MSK               (0x0F)
-#define BMI160_USER_INTR_LATCH__REG               (BMI160_USER_INTR_LATCH_ADDR)
-/**************************************************************/
-/**\name	INPUT ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Latch Description - Reg Addr --> 0x54, Bit -->4 */
-#define BMI160_USER_INTR1_INPUT_ENABLE__POS               (4)
-#define BMI160_USER_INTR1_INPUT_ENABLE__LEN               (1)
-#define BMI160_USER_INTR1_INPUT_ENABLE__MSK               (0x10)
-#define BMI160_USER_INTR1_INPUT_ENABLE__REG               \
-(BMI160_USER_INTR_LATCH_ADDR)
-
-/* Int_Latch Description - Reg Addr --> 0x54, Bit -->5*/
-#define BMI160_USER_INTR2_INPUT_ENABLE__POS               (5)
-#define BMI160_USER_INTR2_INPUT_ENABLE__LEN               (1)
-#define BMI160_USER_INTR2_INPUT_ENABLE__MSK               (0x20)
-#define BMI160_USER_INTR2_INPUT_ENABLE__REG              \
-(BMI160_USER_INTR_LATCH_ADDR)
-/**************************************************************/
-/**\name	INTERRUPT1 MAPPING OF LOW_G LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_0 Description - Reg Addr --> 0x55, Bit -->0 */
-#define BMI160_USER_INTR_MAP_0_INTR1_LOW_G__POS               (0)
-#define BMI160_USER_INTR_MAP_0_INTR1_LOW_G__LEN               (1)
-#define BMI160_USER_INTR_MAP_0_INTR1_LOW_G__MSK               (0x01)
-#define BMI160_USER_INTR_MAP_0_INTR1_LOW_G__REG	(BMI160_USER_INTR_MAP_0_ADDR)
-/**************************************************************/
-/**\name	INTERRUPT1 MAPPING OF HIGH_G LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_0 Description - Reg Addr --> 0x55, Bit -->1 */
-#define BMI160_USER_INTR_MAP_0_INTR1_HIGH_G__POS               (1)
-#define BMI160_USER_INTR_MAP_0_INTR1_HIGH_G__LEN               (1)
-#define BMI160_USER_INTR_MAP_0_INTR1_HIGH_G__MSK               (0x02)
-#define BMI160_USER_INTR_MAP_0_INTR1_HIGH_G__REG	\
-(BMI160_USER_INTR_MAP_0_ADDR)
-/**************************************************************/
-/**\name	INTERRUPT MAPPING OF ANY MOTION_G LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_0 Description - Reg Addr --> 0x55, Bit -->2 */
-#define BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__POS               (2)
-#define BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__LEN               (1)
-#define BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__MSK               (0x04)
-#define BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__REG            \
-(BMI160_USER_INTR_MAP_0_ADDR)
-/**************************************************************/
-/**\name	INTERRUPT1 MAPPING OF NO MOTION LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_0 Description - Reg Addr --> 0x55, Bit -->3 */
-#define BMI160_USER_INTR_MAP_0_INTR1_NOMOTION__POS               (3)
-#define BMI160_USER_INTR_MAP_0_INTR1_NOMOTION__LEN               (1)
-#define BMI160_USER_INTR_MAP_0_INTR1_NOMOTION__MSK               (0x08)
-#define BMI160_USER_INTR_MAP_0_INTR1_NOMOTION__REG (BMI160_USER_INTR_MAP_0_ADDR)
-/**************************************************************/
-/**\name	INTERRUPT1 MAPPING OF DOUBLE TAP LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_0 Description - Reg Addr --> 0x55, Bit -->4 */
-#define BMI160_USER_INTR_MAP_0_INTR1_DOUBLE_TAP__POS               (4)
-#define BMI160_USER_INTR_MAP_0_INTR1_DOUBLE_TAP__LEN               (1)
-#define BMI160_USER_INTR_MAP_0_INTR1_DOUBLE_TAP__MSK               (0x10)
-#define BMI160_USER_INTR_MAP_0_INTR1_DOUBLE_TAP__REG	\
-(BMI160_USER_INTR_MAP_0_ADDR)
-/**************************************************************/
-/**\name	INTERRUPT1 MAPPING OF SINGLE TAP LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_0 Description - Reg Addr --> 0x55, Bit -->5 */
-#define BMI160_USER_INTR_MAP_0_INTR1_SINGLE_TAP__POS               (5)
-#define BMI160_USER_INTR_MAP_0_INTR1_SINGLE_TAP__LEN               (1)
-#define BMI160_USER_INTR_MAP_0_INTR1_SINGLE_TAP__MSK               (0x20)
-#define BMI160_USER_INTR_MAP_0_INTR1_SINGLE_TAP__REG	      \
-(BMI160_USER_INTR_MAP_0_ADDR)
-/**************************************************************/
-/**\name	INTERRUPT1 MAPPING OF ORIENT LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_0 Description - Reg Addr --> 0x55, Bit -->6 */
-#define BMI160_USER_INTR_MAP_0_INTR1_ORIENT__POS               (6)
-#define BMI160_USER_INTR_MAP_0_INTR1_ORIENT__LEN               (1)
-#define BMI160_USER_INTR_MAP_0_INTR1_ORIENT__MSK               (0x40)
-#define BMI160_USER_INTR_MAP_0_INTR1_ORIENT__REG	          \
-(BMI160_USER_INTR_MAP_0_ADDR)
-/**************************************************************/
-/**\name	INTERRUPT MAPPING OF FLAT LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_0 Description - Reg Addr --> 0x56, Bit -->7 */
-#define BMI160_USER_INTR_MAP_0_INTR1_FLAT__POS               (7)
-#define BMI160_USER_INTR_MAP_0_INTR1_FLAT__LEN               (1)
-#define BMI160_USER_INTR_MAP_0_INTR1_FLAT__MSK               (0x80)
-#define BMI160_USER_INTR_MAP_0_INTR1_FLAT__REG	(BMI160_USER_INTR_MAP_0_ADDR)
-/**************************************************************/
-/**\name	INTERRUPT1 MAPPING OF PMU TRIGGER LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->0 */
-#define BMI160_USER_INTR_MAP_1_INTR2_PMU_TRIG__POS               (0)
-#define BMI160_USER_INTR_MAP_1_INTR2_PMU_TRIG__LEN               (1)
-#define BMI160_USER_INTR_MAP_1_INTR2_PMU_TRIG__MSK               (0x01)
-#define BMI160_USER_INTR_MAP_1_INTR2_PMU_TRIG__REG (BMI160_USER_INTR_MAP_1_ADDR)
-
-#ifdef FIFO_ENABLE
-/**************************************************************/
-/**\name	INTERRUPT1 MAPPING OF FIFO FULL AND
-	WATER MARK LENGTH, POSITION AND MASK*/
-/**************************************************************/
-
-/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->1 */
-#define BMI160_USER_INTR_MAP_1_INTR2_FIFO_FULL__POS               (1)
-#define BMI160_USER_INTR_MAP_1_INTR2_FIFO_FULL__LEN               (1)
-#define BMI160_USER_INTR_MAP_1_INTR2_FIFO_FULL__MSK               (0x02)
-#define BMI160_USER_INTR_MAP_1_INTR2_FIFO_FULL__REG	         \
-(BMI160_USER_INTR_MAP_1_ADDR)
-
-/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->2 */
-#define BMI160_USER_INTR_MAP_1_INTR2_FIFO_WM__POS               (2)
-#define BMI160_USER_INTR_MAP_1_INTR2_FIFO_WM__LEN               (1)
-#define BMI160_USER_INTR_MAP_1_INTR2_FIFO_WM__MSK               (0x04)
-#define BMI160_USER_INTR_MAP_1_INTR2_FIFO_WM__REG	         \
-(BMI160_USER_INTR_MAP_1_ADDR)
-#endif
-/**************************************************************/
-/**\name	INTERRUPT1 MAPPING OF DATA READY LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->3 */
-#define BMI160_USER_INTR_MAP_1_INTR2_DATA_RDY__POS               (3)
-#define BMI160_USER_INTR_MAP_1_INTR2_DATA_RDY__LEN               (1)
-#define BMI160_USER_INTR_MAP_1_INTR2_DATA_RDY__MSK               (0x08)
-#define BMI160_USER_INTR_MAP_1_INTR2_DATA_RDY__REG	      \
-(BMI160_USER_INTR_MAP_1_ADDR)
-/**************************************************************/
-/**\name	INTERRUPT1 MAPPING OF PMU TRIGGER LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->4 */
-#define BMI160_USER_INTR_MAP_1_INTR1_PMU_TRIG__POS               (4)
-#define BMI160_USER_INTR_MAP_1_INTR1_PMU_TRIG__LEN               (1)
-#define BMI160_USER_INTR_MAP_1_INTR1_PMU_TRIG__MSK               (0x10)
-#define BMI160_USER_INTR_MAP_1_INTR1_PMU_TRIG__REG (BMI160_USER_INTR_MAP_1_ADDR)
-/**************************************************************/
-/**\name	INTERRUPT1 MAPPING OF FIFO FULL AND
-	WATER MARK LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->5 */
-#define BMI160_USER_INTR_MAP_1_INTR1_FIFO_FULL__POS               (5)
-#define BMI160_USER_INTR_MAP_1_INTR1_FIFO_FULL__LEN               (1)
-#define BMI160_USER_INTR_MAP_1_INTR1_FIFO_FULL__MSK               (0x20)
-#define BMI160_USER_INTR_MAP_1_INTR1_FIFO_FULL__REG	       \
-(BMI160_USER_INTR_MAP_1_ADDR)
-
-/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->6 */
-#define BMI160_USER_INTR_MAP_1_INTR1_FIFO_WM__POS               (6)
-#define BMI160_USER_INTR_MAP_1_INTR1_FIFO_WM__LEN               (1)
-#define BMI160_USER_INTR_MAP_1_INTR1_FIFO_WM__MSK               (0x40)
-#define BMI160_USER_INTR_MAP_1_INTR1_FIFO_WM__REG	\
-(BMI160_USER_INTR_MAP_1_ADDR)
-/**************************************************************/
-/**\name	INTERRUPT1 MAPPING OF DATA READY LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->7 */
-#define BMI160_USER_INTR_MAP_1_INTR1_DATA_RDY__POS               (7)
-#define BMI160_USER_INTR_MAP_1_INTR1_DATA_RDY__LEN               (1)
-#define BMI160_USER_INTR_MAP_1_INTR1_DATA_RDY__MSK               (0x80)
-#define BMI160_USER_INTR_MAP_1_INTR1_DATA_RDY__REG	\
-(BMI160_USER_INTR_MAP_1_ADDR)
-/**************************************************************/
-/**\name	INTERRUPT2 MAPPING OF LOW_G LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->0 */
-#define BMI160_USER_INTR_MAP_2_INTR2_LOW_G__POS               (0)
-#define BMI160_USER_INTR_MAP_2_INTR2_LOW_G__LEN               (1)
-#define BMI160_USER_INTR_MAP_2_INTR2_LOW_G__MSK               (0x01)
-#define BMI160_USER_INTR_MAP_2_INTR2_LOW_G__REG	(BMI160_USER_INTR_MAP_2_ADDR)
-/**************************************************************/
-/**\name	INTERRUPT2 MAPPING OF HIGH_G LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->1 */
-#define BMI160_USER_INTR_MAP_2_INTR2_HIGH_G__POS               (1)
-#define BMI160_USER_INTR_MAP_2_INTR2_HIGH_G__LEN               (1)
-#define BMI160_USER_INTR_MAP_2_INTR2_HIGH_G__MSK               (0x02)
-#define BMI160_USER_INTR_MAP_2_INTR2_HIGH_G__REG	\
-(BMI160_USER_INTR_MAP_2_ADDR)
-/**************************************************************/
-/**\name	INTERRUPT2 MAPPING OF ANY MOTION LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->2 */
-#define BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__POS      (2)
-#define BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__LEN      (1)
-#define BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__MSK     (0x04)
-#define BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__REG     \
-(BMI160_USER_INTR_MAP_2_ADDR)
-/**************************************************************/
-/**\name	INTERRUPT2 MAPPING OF NO MOTION LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->3 */
-#define BMI160_USER_INTR_MAP_2_INTR2_NOMOTION__POS               (3)
-#define BMI160_USER_INTR_MAP_2_INTR2_NOMOTION__LEN               (1)
-#define BMI160_USER_INTR_MAP_2_INTR2_NOMOTION__MSK               (0x08)
-#define BMI160_USER_INTR_MAP_2_INTR2_NOMOTION__REG (BMI160_USER_INTR_MAP_2_ADDR)
-/**************************************************************/
-/**\name	INTERRUPT2 MAPPING OF DOUBLE TAP LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->4 */
-#define BMI160_USER_INTR_MAP_2_INTR2_DOUBLE_TAP__POS               (4)
-#define BMI160_USER_INTR_MAP_2_INTR2_DOUBLE_TAP__LEN               (1)
-#define BMI160_USER_INTR_MAP_2_INTR2_DOUBLE_TAP__MSK               (0x10)
-#define BMI160_USER_INTR_MAP_2_INTR2_DOUBLE_TAP__REG	\
-(BMI160_USER_INTR_MAP_2_ADDR)
-/**************************************************************/
-/**\name	INTERRUPT2 MAPPING OF SINGLE TAP LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->5 */
-#define BMI160_USER_INTR_MAP_2_INTR2_SINGLE_TAP__POS               (5)
-#define BMI160_USER_INTR_MAP_2_INTR2_SINGLE_TAP__LEN               (1)
-#define BMI160_USER_INTR_MAP_2_INTR2_SINGLE_TAP__MSK               (0x20)
-#define BMI160_USER_INTR_MAP_2_INTR2_SINGLE_TAP__REG	\
-(BMI160_USER_INTR_MAP_2_ADDR)
-/**************************************************************/
-/**\name	INTERRUPT2 MAPPING OF ORIENT LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->6 */
-#define BMI160_USER_INTR_MAP_2_INTR2_ORIENT__POS               (6)
-#define BMI160_USER_INTR_MAP_2_INTR2_ORIENT__LEN               (1)
-#define BMI160_USER_INTR_MAP_2_INTR2_ORIENT__MSK               (0x40)
-#define BMI160_USER_INTR_MAP_2_INTR2_ORIENT__REG	\
-(BMI160_USER_INTR_MAP_2_ADDR)
-/**************************************************************/
-/**\name	INTERRUPT2 MAPPING OF FLAT LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->7 */
-#define BMI160_USER_INTR_MAP_2_INTR2_FLAT__POS               (7)
-#define BMI160_USER_INTR_MAP_2_INTR2_FLAT__LEN               (1)
-#define BMI160_USER_INTR_MAP_2_INTR2_FLAT__MSK               (0x80)
-#define BMI160_USER_INTR_MAP_2_INTR2_FLAT__REG	(BMI160_USER_INTR_MAP_2_ADDR)
-
-/**************************************************************/
-/**\name	TAP SOURCE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Data_0 Description - Reg Addr --> 0x58, Bit --> 3 */
-#define BMI160_USER_INTR_DATA_0_INTR_TAP_SOURCE__POS               (3)
-#define BMI160_USER_INTR_DATA_0_INTR_TAP_SOURCE__LEN               (1)
-#define BMI160_USER_INTR_DATA_0_INTR_TAP_SOURCE__MSK               (0x08)
-#define BMI160_USER_INTR_DATA_0_INTR_TAP_SOURCE__REG	           \
-(BMI160_USER_INTR_DATA_0_ADDR)
-
-/**************************************************************/
-/**\name	HIGH SOURCE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Data_0 Description - Reg Addr --> 0x58, Bit --> 7 */
-#define BMI160_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE__POS           (7)
-#define BMI160_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE__LEN           (1)
-#define BMI160_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE__MSK           (0x80)
-#define BMI160_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE__REG            \
-(BMI160_USER_INTR_DATA_0_ADDR)
-
-/**************************************************************/
-/**\name	MOTION SOURCE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Data_1 Description - Reg Addr --> 0x59, Bit --> 7 */
-#define BMI160_USER_INTR_DATA_1_INTR_MOTION_SOURCE__POS               (7)
-#define BMI160_USER_INTR_DATA_1_INTR_MOTION_SOURCE__LEN               (1)
-#define BMI160_USER_INTR_DATA_1_INTR_MOTION_SOURCE__MSK               (0x80)
-#define BMI160_USER_INTR_DATA_1_INTR_MOTION_SOURCE__REG               \
-		(BMI160_USER_INTR_DATA_1_ADDR)
-/**************************************************************/
-/**\name	LOW HIGH DURATION LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_LowHigh_0 Description - Reg Addr --> 0x5a, Bit --> 0...7 */
-#define BMI160_USER_INTR_LOWHIGH_0_INTR_LOW_DURN__POS               (0)
-#define BMI160_USER_INTR_LOWHIGH_0_INTR_LOW_DURN__LEN               (8)
-#define BMI160_USER_INTR_LOWHIGH_0_INTR_LOW_DURN__MSK               (0xFF)
-#define BMI160_USER_INTR_LOWHIGH_0_INTR_LOW_DURN__REG               \
-		(BMI160_USER_INTR_LOWHIGH_0_ADDR)
-/**************************************************************/
-/**\name	LOW THRESHOLD LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_LowHigh_1 Description - Reg Addr --> 0x5b, Bit --> 0...7 */
-#define BMI160_USER_INTR_LOWHIGH_1_INTR_LOW_THRES__POS               (0)
-#define BMI160_USER_INTR_LOWHIGH_1_INTR_LOW_THRES__LEN               (8)
-#define BMI160_USER_INTR_LOWHIGH_1_INTR_LOW_THRES__MSK               (0xFF)
-#define BMI160_USER_INTR_LOWHIGH_1_INTR_LOW_THRES__REG               \
-		(BMI160_USER_INTR_LOWHIGH_1_ADDR)
-/**************************************************************/
-/**\name	LOW HYSTERESIS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_LowHigh_2 Description - Reg Addr --> 0x5c, Bit --> 0...1 */
-#define BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST__POS               (0)
-#define BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST__LEN               (2)
-#define BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST__MSK               (0x03)
-#define BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST__REG               \
-		(BMI160_USER_INTR_LOWHIGH_2_ADDR)
-/**************************************************************/
-/**\name	LOW MODE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_LowHigh_2 Description - Reg Addr --> 0x5c, Bit --> 2 */
-#define BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE__POS               (2)
-#define BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE__LEN               (1)
-#define BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE__MSK               (0x04)
-#define BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE__REG               \
-		(BMI160_USER_INTR_LOWHIGH_2_ADDR)
-/**************************************************************/
-/**\name	HIGH_G HYSTERESIS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_LowHigh_2 Description - Reg Addr --> 0x5c, Bit --> 6...7 */
-#define BMI160_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST__POS               (6)
-#define BMI160_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST__LEN               (2)
-#define BMI160_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST__MSK               (0xC0)
-#define BMI160_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST__REG               \
-		(BMI160_USER_INTR_LOWHIGH_2_ADDR)
-/**************************************************************/
-/**\name	HIGH_G DURATION LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_LowHigh_3 Description - Reg Addr --> 0x5d, Bit --> 0...7 */
-#define BMI160_USER_INTR_LOWHIGH_3_INTR_HIGH_G_DURN__POS               (0)
-#define BMI160_USER_INTR_LOWHIGH_3_INTR_HIGH_G_DURN__LEN               (8)
-#define BMI160_USER_INTR_LOWHIGH_3_INTR_HIGH_G_DURN__MSK               (0xFF)
-#define BMI160_USER_INTR_LOWHIGH_3_INTR_HIGH_G_DURN__REG               \
-		(BMI160_USER_INTR_LOWHIGH_3_ADDR)
-/**************************************************************/
-/**\name	HIGH_G THRESHOLD LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_LowHigh_4 Description - Reg Addr --> 0x5e, Bit --> 0...7 */
-#define BMI160_USER_INTR_LOWHIGH_4_INTR_HIGH_THRES__POS               (0)
-#define BMI160_USER_INTR_LOWHIGH_4_INTR_HIGH_THRES__LEN               (8)
-#define BMI160_USER_INTR_LOWHIGH_4_INTR_HIGH_THRES__MSK               (0xFF)
-#define BMI160_USER_INTR_LOWHIGH_4_INTR_HIGH_THRES__REG               \
-		(BMI160_USER_INTR_LOWHIGH_4_ADDR)
-/**************************************************************/
-/**\name	ANY MOTION DURATION LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Motion_0 Description - Reg Addr --> 0x5f, Bit --> 0...1 */
-#define BMI160_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN__POS               (0)
-#define BMI160_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN__LEN               (2)
-#define BMI160_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN__MSK               (0x03)
-#define BMI160_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN__REG               \
-		(BMI160_USER_INTR_MOTION_0_ADDR)
-/**************************************************************/
-/**\name	SLOW/NO MOTION DURATION LENGTH, POSITION AND MASK*/
-/**************************************************************/
-	/* Int_Motion_0 Description - Reg Addr --> 0x5f, Bit --> 2...7 */
-#define BMI160_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN__POS      (2)
-#define BMI160_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN__LEN      (6)
-#define BMI160_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN__MSK      (0xFC)
-#define BMI160_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN__REG       \
-		(BMI160_USER_INTR_MOTION_0_ADDR)
-/**************************************************************/
-/**\name	ANY MOTION THRESHOLD LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Motion_1 Description - Reg Addr --> (0x60), Bit --> 0...7 */
-#define BMI160_USER_INTR_MOTION_1_INTR_ANY_MOTION_THRES__POS      (0)
-#define BMI160_USER_INTR_MOTION_1_INTR_ANY_MOTION_THRES__LEN      (8)
-#define BMI160_USER_INTR_MOTION_1_INTR_ANY_MOTION_THRES__MSK      (0xFF)
-#define BMI160_USER_INTR_MOTION_1_INTR_ANY_MOTION_THRES__REG               \
-		(BMI160_USER_INTR_MOTION_1_ADDR)
-/**************************************************************/
-/**\name	SLOW/NO MOTION THRESHOLD LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Motion_2 Description - Reg Addr --> 0x61, Bit --> 0...7 */
-#define BMI160_USER_INTR_MOTION_2_INTR_SLOW_NO_MOTION_THRES__POS       (0)
-#define BMI160_USER_INTR_MOTION_2_INTR_SLOW_NO_MOTION_THRES__LEN       (8)
-#define BMI160_USER_INTR_MOTION_2_INTR_SLOW_NO_MOTION_THRES__MSK       (0xFF)
-#define BMI160_USER_INTR_MOTION_2_INTR_SLOW_NO_MOTION_THRES__REG       \
-		(BMI160_USER_INTR_MOTION_2_ADDR)
-/**************************************************************/
-/**\name	SLOW/NO MOTION SELECT LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Motion_3 Description - Reg Addr --> (0x62), Bit --> 0 */
-#define BMI160_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT__POS	(0)
-#define BMI160_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT__LEN	(1)
-#define BMI160_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT__MSK	(0x01)
-#define BMI160_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT__REG   \
-(BMI160_USER_INTR_MOTION_3_ADDR)
-/**************************************************************/
-/**\name	SIGNIFICANT MOTION SELECT LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Motion_3 Description - Reg Addr --> (0x62), Bit --> 1 */
-#define BMI160_USER_INTR_SIGNIFICATION_MOTION_SELECT__POS		(1)
-#define BMI160_USER_INTR_SIGNIFICATION_MOTION_SELECT__LEN		(1)
-#define BMI160_USER_INTR_SIGNIFICATION_MOTION_SELECT__MSK		(0x02)
-#define BMI160_USER_INTR_SIGNIFICATION_MOTION_SELECT__REG		\
-		(BMI160_USER_INTR_MOTION_3_ADDR)
-
-/* Int_Motion_3 Description - Reg Addr --> (0x62), Bit --> 3..2 */
-#define BMI160_USER_INTR_SIGNIFICANT_MOTION_SKIP__POS		(2)
-#define BMI160_USER_INTR_SIGNIFICANT_MOTION_SKIP__LEN		(2)
-#define BMI160_USER_INTR_SIGNIFICANT_MOTION_SKIP__MSK		(0x0C)
-#define BMI160_USER_INTR_SIGNIFICANT_MOTION_SKIP__REG		\
-		(BMI160_USER_INTR_MOTION_3_ADDR)
-
-/* Int_Motion_3 Description - Reg Addr --> (0x62), Bit --> 5..4 */
-#define BMI160_USER_INTR_SIGNIFICANT_MOTION_PROOF__POS		(4)
-#define BMI160_USER_INTR_SIGNIFICANT_MOTION_PROOF__LEN		(2)
-#define BMI160_USER_INTR_SIGNIFICANT_MOTION_PROOF__MSK		(0x30)
-#define BMI160_USER_INTR_SIGNIFICANT_MOTION_PROOF__REG		\
-		(BMI160_USER_INTR_MOTION_3_ADDR)
-/**************************************************************/
-/**\name	TAP DURATION LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* INT_TAP_0 Description - Reg Addr --> (0x63), Bit --> 0..2*/
-#define BMI160_USER_INTR_TAP_0_INTR_TAP_DURN__POS               (0)
-#define BMI160_USER_INTR_TAP_0_INTR_TAP_DURN__LEN               (3)
-#define BMI160_USER_INTR_TAP_0_INTR_TAP_DURN__MSK               (0x07)
-#define BMI160_USER_INTR_TAP_0_INTR_TAP_DURN__REG	\
-(BMI160_USER_INTR_TAP_0_ADDR)
-/**************************************************************/
-/**\name	TAP SHOCK LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Tap_0 Description - Reg Addr --> (0x63), Bit --> 6 */
-#define BMI160_USER_INTR_TAP_0_INTR_TAP_SHOCK__POS               (6)
-#define BMI160_USER_INTR_TAP_0_INTR_TAP_SHOCK__LEN               (1)
-#define BMI160_USER_INTR_TAP_0_INTR_TAP_SHOCK__MSK               (0x40)
-#define BMI160_USER_INTR_TAP_0_INTR_TAP_SHOCK__REG (BMI160_USER_INTR_TAP_0_ADDR)
-/**************************************************************/
-/**\name	TAP QUIET LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Tap_0 Description - Reg Addr --> (0x63), Bit --> 7 */
-#define BMI160_USER_INTR_TAP_0_INTR_TAP_QUIET__POS               (7)
-#define BMI160_USER_INTR_TAP_0_INTR_TAP_QUIET__LEN               (1)
-#define BMI160_USER_INTR_TAP_0_INTR_TAP_QUIET__MSK               (0x80)
-#define BMI160_USER_INTR_TAP_0_INTR_TAP_QUIET__REG (BMI160_USER_INTR_TAP_0_ADDR)
-/**************************************************************/
-/**\name	TAP THRESHOLD LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Tap_1 Description - Reg Addr --> (0x64), Bit --> 0...4 */
-#define BMI160_USER_INTR_TAP_1_INTR_TAP_THRES__POS               (0)
-#define BMI160_USER_INTR_TAP_1_INTR_TAP_THRES__LEN               (5)
-#define BMI160_USER_INTR_TAP_1_INTR_TAP_THRES__MSK               (0x1F)
-#define BMI160_USER_INTR_TAP_1_INTR_TAP_THRES__REG (BMI160_USER_INTR_TAP_1_ADDR)
-/**************************************************************/
-/**\name	ORIENT MODE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Orient_0 Description - Reg Addr --> (0x65), Bit --> 0...1 */
-#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_MODE__POS               (0)
-#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_MODE__LEN               (2)
-#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_MODE__MSK               (0x03)
-#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_MODE__REG               \
-		(BMI160_USER_INTR_ORIENT_0_ADDR)
-/**************************************************************/
-/**\name	ORIENT BLOCKING LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Orient_0 Description - Reg Addr --> (0x65), Bit --> 2...3 */
-#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING__POS               (2)
-#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING__LEN               (2)
-#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING__MSK               (0x0C)
-#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING__REG               \
-		(BMI160_USER_INTR_ORIENT_0_ADDR)
-/**************************************************************/
-/**\name	ORIENT HYSTERESIS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Orient_0 Description - Reg Addr --> (0x65), Bit --> 4...7 */
-#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_HYST__POS               (4)
-#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_HYST__LEN               (4)
-#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_HYST__MSK               (0xF0)
-#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_HYST__REG               \
-		(BMI160_USER_INTR_ORIENT_0_ADDR)
-/**************************************************************/
-/**\name	ORIENT THETA LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Orient_1 Description - Reg Addr --> 0x66, Bit --> 0...5 */
-#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_THETA__POS               (0)
-#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_THETA__LEN               (6)
-#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_THETA__MSK               (0x3F)
-#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_THETA__REG               \
-		(BMI160_USER_INTR_ORIENT_1_ADDR)
-/**************************************************************/
-/**\name	ORIENT UD LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Orient_1 Description - Reg Addr --> 0x66, Bit --> 6 */
-#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE__POS         (6)
-#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE__LEN         (1)
-#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE__MSK         (0x40)
-#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE__REG          \
-		(BMI160_USER_INTR_ORIENT_1_ADDR)
-/**************************************************************/
-/**\name	ORIENT AXIS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Orient_1 Description - Reg Addr --> 0x66, Bit --> 7 */
-#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX__POS               (7)
-#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX__LEN               (1)
-#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX__MSK               (0x80)
-#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX__REG               \
-		(BMI160_USER_INTR_ORIENT_1_ADDR)
-/**************************************************************/
-/**\name	FLAT THETA LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Flat_0 Description - Reg Addr --> 0x67, Bit --> 0...5 */
-#define BMI160_USER_INTR_FLAT_0_INTR_FLAT_THETA__POS               (0)
-#define BMI160_USER_INTR_FLAT_0_INTR_FLAT_THETA__LEN               (6)
-#define BMI160_USER_INTR_FLAT_0_INTR_FLAT_THETA__MSK               (0x3F)
-#define BMI160_USER_INTR_FLAT_0_INTR_FLAT_THETA__REG  \
-		(BMI160_USER_INTR_FLAT_0_ADDR)
-/**************************************************************/
-/**\name	FLAT HYSTERESIS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Flat_1 Description - Reg Addr --> (0x68), Bit --> 0...3 */
-#define BMI160_USER_INTR_FLAT_1_INTR_FLAT_HYST__POS		(0)
-#define BMI160_USER_INTR_FLAT_1_INTR_FLAT_HYST__LEN		(4)
-#define BMI160_USER_INTR_FLAT_1_INTR_FLAT_HYST__MSK		(0x0F)
-#define BMI160_USER_INTR_FLAT_1_INTR_FLAT_HYST__REG	 \
-(BMI160_USER_INTR_FLAT_1_ADDR)
-/**************************************************************/
-/**\name	FLAT HOLD LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Flat_1 Description - Reg Addr --> (0x68), Bit --> 4...5 */
-#define BMI160_USER_INTR_FLAT_1_INTR_FLAT_HOLD__POS                (4)
-#define BMI160_USER_INTR_FLAT_1_INTR_FLAT_HOLD__LEN                (2)
-#define BMI160_USER_INTR_FLAT_1_INTR_FLAT_HOLD__MSK                (0x30)
-#define BMI160_USER_INTR_FLAT_1_INTR_FLAT_HOLD__REG  \
-(BMI160_USER_INTR_FLAT_1_ADDR)
-/**************************************************************/
-/**\name	FOC ACCEL XYZ LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Foc_Conf Description - Reg Addr --> (0x69), Bit --> 0...1 */
-#define BMI160_USER_FOC_ACCEL_Z__POS               (0)
-#define BMI160_USER_FOC_ACCEL_Z__LEN               (2)
-#define BMI160_USER_FOC_ACCEL_Z__MSK               (0x03)
-#define BMI160_USER_FOC_ACCEL_Z__REG               (BMI160_USER_FOC_CONFIG_ADDR)
-
-/* Foc_Conf Description - Reg Addr --> (0x69), Bit --> 2...3 */
-#define BMI160_USER_FOC_ACCEL_Y__POS               (2)
-#define BMI160_USER_FOC_ACCEL_Y__LEN               (2)
-#define BMI160_USER_FOC_ACCEL_Y__MSK               (0x0C)
-#define BMI160_USER_FOC_ACCEL_Y__REG               (BMI160_USER_FOC_CONFIG_ADDR)
-
-/* Foc_Conf Description - Reg Addr --> (0x69), Bit --> 4...5 */
-#define BMI160_USER_FOC_ACCEL_X__POS               (4)
-#define BMI160_USER_FOC_ACCEL_X__LEN               (2)
-#define BMI160_USER_FOC_ACCEL_X__MSK               (0x30)
-#define BMI160_USER_FOC_ACCEL_X__REG               (BMI160_USER_FOC_CONFIG_ADDR)
-/**************************************************************/
-/**\name	FOC GYRO LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Foc_Conf Description - Reg Addr --> (0x69), Bit --> 6 */
-#define BMI160_USER_FOC_GYRO_ENABLE__POS               (6)
-#define BMI160_USER_FOC_GYRO_ENABLE__LEN               (1)
-#define BMI160_USER_FOC_GYRO_ENABLE__MSK               (0x40)
-#define BMI160_USER_FOC_GYRO_ENABLE__REG               \
-(BMI160_USER_FOC_CONFIG_ADDR)
-
-/*IF_CONF Description - Reg Addr --> (0x6B), Bit --> 0 */
-
-#define BMI160_USER_IF_CONFIG_SPI3__POS               (0)
-#define BMI160_USER_IF_CONFIG_SPI3__LEN               (1)
-#define BMI160_USER_IF_CONFIG_SPI3__MSK               (0x01)
-#define BMI160_USER_IF_CONFIG_SPI3__REG               \
-(BMI160_USER_IF_CONFIG_ADDR)
-
-/*IF_CONF Description - Reg Addr --> (0x6B), Bit --> 5..4 */
-#define BMI160_USER_IF_CONFIG_IF_MODE__POS               (4)
-#define BMI160_USER_IF_CONFIG_IF_MODE__LEN               (2)
-#define BMI160_USER_IF_CONFIG_IF_MODE__MSK               (0x30)
-#define BMI160_USER_IF_CONFIG_IF_MODE__REG		\
-(BMI160_USER_IF_CONFIG_ADDR)
-/**************************************************************/
-/**\name	GYRO SLEEP CONFIGURATION LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Pmu_Trigger Description - Reg Addr --> 0x6c, Bit --> 0...2 */
-#define BMI160_USER_GYRO_SLEEP_TRIGGER__POS               (0)
-#define BMI160_USER_GYRO_SLEEP_TRIGGER__LEN               (3)
-#define BMI160_USER_GYRO_SLEEP_TRIGGER__MSK               (0x07)
-#define BMI160_USER_GYRO_SLEEP_TRIGGER__REG	(BMI160_USER_PMU_TRIGGER_ADDR)
-
-/* Pmu_Trigger Description - Reg Addr --> 0x6c, Bit --> 3...4 */
-#define BMI160_USER_GYRO_WAKEUP_TRIGGER__POS               (3)
-#define BMI160_USER_GYRO_WAKEUP_TRIGGER__LEN               (2)
-#define BMI160_USER_GYRO_WAKEUP_TRIGGER__MSK               (0x18)
-#define BMI160_USER_GYRO_WAKEUP_TRIGGER__REG	(BMI160_USER_PMU_TRIGGER_ADDR)
-
-/* Pmu_Trigger Description - Reg Addr --> 0x6c, Bit --> 5 */
-#define BMI160_USER_GYRO_SLEEP_STATE__POS               (5)
-#define BMI160_USER_GYRO_SLEEP_STATE__LEN               (1)
-#define BMI160_USER_GYRO_SLEEP_STATE__MSK               (0x20)
-#define BMI160_USER_GYRO_SLEEP_STATE__REG	(BMI160_USER_PMU_TRIGGER_ADDR)
-
-/* Pmu_Trigger Description - Reg Addr --> 0x6c, Bit --> 6 */
-#define BMI160_USER_GYRO_WAKEUP_INTR__POS               (6)
-#define BMI160_USER_GYRO_WAKEUP_INTR__LEN               (1)
-#define BMI160_USER_GYRO_WAKEUP_INTR__MSK               (0x40)
-#define BMI160_USER_GYRO_WAKEUP_INTR__REG	(BMI160_USER_PMU_TRIGGER_ADDR)
-/**************************************************************/
-/**\name	ACCEL SELF TEST LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Self_Test Description - Reg Addr --> 0x6d, Bit --> 0...1 */
-#define BMI160_USER_ACCEL_SELFTEST_AXIS__POS               (0)
-#define BMI160_USER_ACCEL_SELFTEST_AXIS__LEN               (2)
-#define BMI160_USER_ACCEL_SELFTEST_AXIS__MSK               (0x03)
-#define BMI160_USER_ACCEL_SELFTEST_AXIS__REG	(BMI160_USER_SELF_TEST_ADDR)
-
-/* Self_Test Description - Reg Addr --> 0x6d, Bit --> 2 */
-#define BMI160_USER_ACCEL_SELFTEST_SIGN__POS               (2)
-#define BMI160_USER_ACCEL_SELFTEST_SIGN__LEN               (1)
-#define BMI160_USER_ACCEL_SELFTEST_SIGN__MSK               (0x04)
-#define BMI160_USER_ACCEL_SELFTEST_SIGN__REG	(BMI160_USER_SELF_TEST_ADDR)
-
-/* Self_Test Description - Reg Addr --> 0x6d, Bit --> 3 */
-#define BMI160_USER_SELFTEST_AMP__POS               (3)
-#define BMI160_USER_SELFTEST_AMP__LEN               (1)
-#define BMI160_USER_SELFTEST_AMP__MSK               (0x08)
-#define BMI160_USER_SELFTEST_AMP__REG		(BMI160_USER_SELF_TEST_ADDR)
-/**************************************************************/
-/**\name	GYRO SELF TEST LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Self_Test Description - Reg Addr --> 0x6d, Bit --> 4 */
-#define BMI160_USER_GYRO_SELFTEST_START__POS               (4)
-#define BMI160_USER_GYRO_SELFTEST_START__LEN               (1)
-#define BMI160_USER_GYRO_SELFTEST_START__MSK               (0x10)
-#define BMI160_USER_GYRO_SELFTEST_START__REG		    \
-(BMI160_USER_SELF_TEST_ADDR)
-/**************************************************************/
-/**\name	NV_CONFIG LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* NV_CONF Description - Reg Addr --> (0x70), Bit --> 0 */
-#define BMI160_USER_NV_CONFIG_SPI_ENABLE__POS               (0)
-#define BMI160_USER_NV_CONFIG_SPI_ENABLE__LEN               (1)
-#define BMI160_USER_NV_CONFIG_SPI_ENABLE__MSK               (0x01)
-#define BMI160_USER_NV_CONFIG_SPI_ENABLE__REG	 (BMI160_USER_NV_CONFIG_ADDR)
-
-/*IF_CONF Description - Reg Addr --> (0x70), Bit --> 1 */
-#define BMI160_USER_IF_CONFIG_I2C_WDT_SELECT__POS               (1)
-#define BMI160_USER_IF_CONFIG_I2C_WDT_SELECT__LEN               (1)
-#define BMI160_USER_IF_CONFIG_I2C_WDT_SELECT__MSK               (0x02)
-#define BMI160_USER_IF_CONFIG_I2C_WDT_SELECT__REG		\
-(BMI160_USER_NV_CONFIG_ADDR)
-
-/*IF_CONF Description - Reg Addr --> (0x70), Bit --> 2 */
-#define BMI160_USER_IF_CONFIG_I2C_WDT_ENABLE__POS               (2)
-#define BMI160_USER_IF_CONFIG_I2C_WDT_ENABLE__LEN               (1)
-#define BMI160_USER_IF_CONFIG_I2C_WDT_ENABLE__MSK               (0x04)
-#define BMI160_USER_IF_CONFIG_I2C_WDT_ENABLE__REG		\
-(BMI160_USER_NV_CONFIG_ADDR)
-
-/**************************************************************/
-/**\name	ACCEL MANUAL OFFSET LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Offset_0 Description - Reg Addr --> (0x71), Bit --> 0...7 */
-#define BMI160_USER_OFFSET_0_ACCEL_OFF_X__POS               (0)
-#define BMI160_USER_OFFSET_0_ACCEL_OFF_X__LEN               (8)
-#define BMI160_USER_OFFSET_0_ACCEL_OFF_X__MSK               (0xFF)
-#define BMI160_USER_OFFSET_0_ACCEL_OFF_X__REG	(BMI160_USER_OFFSET_0_ADDR)
-
-/* Offset_1 Description - Reg Addr --> 0x72, Bit --> 0...7 */
-#define BMI160_USER_OFFSET_1_ACCEL_OFF_Y__POS               (0)
-#define BMI160_USER_OFFSET_1_ACCEL_OFF_Y__LEN               (8)
-#define BMI160_USER_OFFSET_1_ACCEL_OFF_Y__MSK               (0xFF)
-#define BMI160_USER_OFFSET_1_ACCEL_OFF_Y__REG	(BMI160_USER_OFFSET_1_ADDR)
-
-/* Offset_2 Description - Reg Addr --> 0x73, Bit --> 0...7 */
-#define BMI160_USER_OFFSET_2_ACCEL_OFF_Z__POS               (0)
-#define BMI160_USER_OFFSET_2_ACCEL_OFF_Z__LEN               (8)
-#define BMI160_USER_OFFSET_2_ACCEL_OFF_Z__MSK               (0xFF)
-#define BMI160_USER_OFFSET_2_ACCEL_OFF_Z__REG	(BMI160_USER_OFFSET_2_ADDR)
-/**************************************************************/
-/**\name	GYRO MANUAL OFFSET LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Offset_3 Description - Reg Addr --> 0x74, Bit --> 0...7 */
-#define BMI160_USER_OFFSET_3_GYRO_OFF_X__POS               (0)
-#define BMI160_USER_OFFSET_3_GYRO_OFF_X__LEN               (8)
-#define BMI160_USER_OFFSET_3_GYRO_OFF_X__MSK               (0xFF)
-#define BMI160_USER_OFFSET_3_GYRO_OFF_X__REG	(BMI160_USER_OFFSET_3_ADDR)
-
-/* Offset_4 Description - Reg Addr --> 0x75, Bit --> 0...7 */
-#define BMI160_USER_OFFSET_4_GYRO_OFF_Y__POS               (0)
-#define BMI160_USER_OFFSET_4_GYRO_OFF_Y__LEN               (8)
-#define BMI160_USER_OFFSET_4_GYRO_OFF_Y__MSK               (0xFF)
-#define BMI160_USER_OFFSET_4_GYRO_OFF_Y__REG	(BMI160_USER_OFFSET_4_ADDR)
-
-/* Offset_5 Description - Reg Addr --> 0x76, Bit --> 0...7 */
-#define BMI160_USER_OFFSET_5_GYRO_OFF_Z__POS               (0)
-#define BMI160_USER_OFFSET_5_GYRO_OFF_Z__LEN               (8)
-#define BMI160_USER_OFFSET_5_GYRO_OFF_Z__MSK               (0xFF)
-#define BMI160_USER_OFFSET_5_GYRO_OFF_Z__REG	(BMI160_USER_OFFSET_5_ADDR)
-
-
-/* Offset_6 Description - Reg Addr --> 0x77, Bit --> 0..1 */
-#define BMI160_USER_OFFSET_6_GYRO_OFF_X__POS               (0)
-#define BMI160_USER_OFFSET_6_GYRO_OFF_X__LEN               (2)
-#define BMI160_USER_OFFSET_6_GYRO_OFF_X__MSK               (0x03)
-#define BMI160_USER_OFFSET_6_GYRO_OFF_X__REG	(BMI160_USER_OFFSET_6_ADDR)
-
-/* Offset_6 Description - Reg Addr --> 0x77, Bit --> 2...3 */
-#define BMI160_USER_OFFSET_6_GYRO_OFF_Y__POS               (2)
-#define BMI160_USER_OFFSET_6_GYRO_OFF_Y__LEN               (2)
-#define BMI160_USER_OFFSET_6_GYRO_OFF_Y__MSK               (0x0C)
-#define BMI160_USER_OFFSET_6_GYRO_OFF_Y__REG	(BMI160_USER_OFFSET_6_ADDR)
-
-/* Offset_6 Description - Reg Addr --> 0x77, Bit --> 4...5 */
-#define BMI160_USER_OFFSET_6_GYRO_OFF_Z__POS               (4)
-#define BMI160_USER_OFFSET_6_GYRO_OFF_Z__LEN               (2)
-#define BMI160_USER_OFFSET_6_GYRO_OFF_Z__MSK               (0x30)
-#define BMI160_USER_OFFSET_6_GYRO_OFF_Z__REG	 (BMI160_USER_OFFSET_6_ADDR)
-/**************************************************************/
-/**\name	ACCEL OFFSET  ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Offset_6 Description - Reg Addr --> 0x77, Bit --> 6 */
-#define BMI160_USER_OFFSET_6_ACCEL_OFF_ENABLE__POS               (6)
-#define BMI160_USER_OFFSET_6_ACCEL_OFF_ENABLE__LEN               (1)
-#define BMI160_USER_OFFSET_6_ACCEL_OFF_ENABLE__MSK               (0x40)
-#define BMI160_USER_OFFSET_6_ACCEL_OFF_ENABLE__REG	 \
-(BMI160_USER_OFFSET_6_ADDR)
-/**************************************************************/
-/**\name	GYRO OFFSET  ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Offset_6 Description - Reg Addr --> 0x77, Bit -->  7 */
-#define BMI160_USER_OFFSET_6_GYRO_OFF_EN__POS               (7)
-#define BMI160_USER_OFFSET_6_GYRO_OFF_EN__LEN               (1)
-#define BMI160_USER_OFFSET_6_GYRO_OFF_EN__MSK               (0x80)
-#define BMI160_USER_OFFSET_6_GYRO_OFF_EN__REG	 (BMI160_USER_OFFSET_6_ADDR)
-/**************************************************************/
-/**\name	STEP COUNTER LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* STEP_CNT_0  Description - Reg Addr --> 0x78, Bit -->  0 to 7 */
-#define BMI160_USER_STEP_COUNT_LSB__POS               (0)
-#define BMI160_USER_STEP_COUNT_LSB__LEN               (7)
-#define BMI160_USER_STEP_COUNT_LSB__MSK               (0xFF)
-#define BMI160_USER_STEP_COUNT_LSB__REG	 (BMI160_USER_STEP_COUNT_0_ADDR)
-
-/* STEP_CNT_1  Description - Reg Addr --> 0x79, Bit -->  0 to 7 */
-#define BMI160_USER_STEP_COUNT_MSB__POS               (0)
-#define BMI160_USER_STEP_COUNT_MSB__LEN               (7)
-#define BMI160_USER_STEP_COUNT_MSB__MSK               (0xFF)
-#define BMI160_USER_STEP_COUNT_MSB__REG	 (BMI160_USER_STEP_COUNT_1_ADDR)
-/**************************************************************/
-/**\name	STEP COUNTER CONFIGURATION LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* STEP_CONFIG_0  Description - Reg Addr --> 0x7A, Bit -->  0 to 7 */
-#define BMI160_USER_STEP_CONFIG_ZERO__POS               (0)
-#define BMI160_USER_STEP_CONFIG_ZERO__LEN               (7)
-#define BMI160_USER_STEP_CONFIG_ZERO__MSK               (0xFF)
-#define BMI160_USER_STEP_CONFIG_ZERO__REG	 \
-(BMI160_USER_STEP_CONFIG_0_ADDR)
-
-
-/* STEP_CONFIG_1  Description - Reg Addr --> 0x7B, Bit -->  0 to 2 and
-4 to 7 */
-#define BMI160_USER_STEP_CONFIG_ONE_CNF1__POS               (0)
-#define BMI160_USER_STEP_CONFIG_ONE_CNF1__LEN               (3)
-#define BMI160_USER_STEP_CONFIG_ONE_CNF1__MSK               (0x07)
-#define BMI160_USER_STEP_CONFIG_ONE_CNF1__REG	 \
-(BMI160_USER_STEP_CONFIG_1_ADDR)
-
-#define BMI160_USER_STEP_CONFIG_ONE_CNF2__POS               (4)
-#define BMI160_USER_STEP_CONFIG_ONE_CNF2__LEN               (4)
-#define BMI160_USER_STEP_CONFIG_ONE_CNF2__MSK               (0xF0)
-#define BMI160_USER_STEP_CONFIG_ONE_CNF2__REG	 \
-(BMI160_USER_STEP_CONFIG_1_ADDR)
-/**************************************************************/
-/**\name	STEP COUNTER ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* STEP_CONFIG_1  Description - Reg Addr --> 0x7B, Bit -->  0 to 2 */
-#define BMI160_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE__POS		(3)
-#define BMI160_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE__LEN		(1)
-#define BMI160_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE__MSK		(0x08)
-#define BMI160_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE__REG	\
-(BMI160_USER_STEP_CONFIG_1_ADDR)
-
-/* USER REGISTERS DEFINITION END */
-/**************************************************************************/
-/* CMD REGISTERS DEFINITION START */
-/**************************************************************/
-/**\name	COMMAND REGISTER LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Command description address - Reg Addr --> 0x7E, Bit -->  0....7 */
-#define BMI160_CMD_COMMANDS__POS              (0)
-#define BMI160_CMD_COMMANDS__LEN              (8)
-#define BMI160_CMD_COMMANDS__MSK              (0xFF)
-#define BMI160_CMD_COMMANDS__REG	 (BMI160_CMD_COMMANDS_ADDR)
-
-
-/**************************************************************************/
-/* CMD REGISTERS DEFINITION END */
-#ifdef FIFO_ENABLE
-/**************************************************/
-/**\name	FIFO FRAME COUNT DEFINITION           */
-/*************************************************/
-#define FIFO_FRAME				(1024)
-#define FIFO_CONFIG_CHECK1		(0x00)
-#define FIFO_CONFIG_CHECK2		(0x80)
-#endif
-/**************************************************/
-/**\name	MAG SENSOR SELECT          */
-/*************************************************/
-#define BST_BMM		(0)
-#define BST_AKM		(1)
-#define BMI160_YAS537_I2C_ADDRESS	(0x2E)
-/**************************************************/
-/**\name	ACCEL RANGE          */
-/*************************************************/
-#define BMI160_ACCEL_RANGE_2G           (0X03)
-#define BMI160_ACCEL_RANGE_4G           (0X05)
-#define BMI160_ACCEL_RANGE_8G           (0X08)
-#define BMI160_ACCEL_RANGE_16G          (0X0C)
-/**************************************************/
-/**\name	ACCEL ODR          */
-/*************************************************/
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_RESERVED       (0x00)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_0_78HZ         (0x01)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_1_56HZ         (0x02)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_3_12HZ         (0x03)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_6_25HZ         (0x04)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_12_5HZ         (0x05)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_25HZ           (0x06)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_50HZ           (0x07)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_100HZ          (0x08)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_200HZ          (0x09)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_400HZ          (0x0A)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_800HZ          (0x0B)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_1600HZ         (0x0C)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_RESERVED0      (0x0D)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_RESERVED1      (0x0E)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_RESERVED2      (0x0F)
-/**************************************************/
-/**\name	ACCEL BANDWIDTH PARAMETER         */
-/*************************************************/
-#define BMI160_ACCEL_OSR4_AVG1			(0)
-#define BMI160_ACCEL_OSR2_AVG2			(1)
-#define BMI160_ACCEL_NORMAL_AVG4		(2)
-#define BMI160_ACCEL_CIC_AVG8			(3)
-#define BMI160_ACCEL_RES_AVG2			(4)
-#define BMI160_ACCEL_RES_AVG4			(5)
-#define BMI160_ACCEL_RES_AVG8			(6)
-#define BMI160_ACCEL_RES_AVG16			(7)
-#define BMI160_ACCEL_RES_AVG32			(8)
-#define BMI160_ACCEL_RES_AVG64			(9)
-#define BMI160_ACCEL_RES_AVG128			(10)
-
-#define BMI160_US_DISABLE				(0)
-#define BMI160_US_ENABLE				(1)
-/**************************************************/
-/**\name	GYRO ODR         */
-/*************************************************/
-#define BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED		(0x00)
-#define BMI160_GYRO_OUTPUT_DATA_RATE_25HZ			(0x06)
-#define BMI160_GYRO_OUTPUT_DATA_RATE_50HZ			(0x07)
-#define BMI160_GYRO_OUTPUT_DATA_RATE_100HZ			(0x08)
-#define BMI160_GYRO_OUTPUT_DATA_RATE_200HZ			(0x09)
-#define BMI160_GYRO_OUTPUT_DATA_RATE_400HZ			(0x0A)
-#define BMI160_GYRO_OUTPUT_DATA_RATE_800HZ			(0x0B)
-#define BMI160_GYRO_OUTPUT_DATA_RATE_1600HZ			(0x0C)
-#define BMI160_GYRO_OUTPUT_DATA_RATE_3200HZ			(0x0D)
-/**************************************************/
-/**\name	GYRO BANDWIDTH PARAMETER         */
-/*************************************************/
-#define BMI160_GYRO_OSR4_MODE		(0x00)
-#define BMI160_GYRO_OSR2_MODE		(0x01)
-#define BMI160_GYRO_NORMAL_MODE		(0x02)
-#define BMI160_GYRO_CIC_MODE		(0x03)
-/**************************************************/
-/**\name	GYROSCOPE RANGE PARAMETER         */
-/*************************************************/
-#define BMI160_GYRO_RANGE_2000_DEG_SEC	(0x00)
-#define BMI160_GYRO_RANGE_1000_DEG_SEC	(0x01)
-#define BMI160_GYRO_RANGE_500_DEG_SEC	(0x02)
-#define BMI160_GYRO_RANGE_250_DEG_SEC	(0x03)
-#define BMI160_GYRO_RANGE_125_DEG_SEC	(0x04)
-/**************************************************/
-/**\name	MAG ODR         */
-/*************************************************/
-#define BMI160_MAG_OUTPUT_DATA_RATE_RESERVED       (0x00)
-#define BMI160_MAG_OUTPUT_DATA_RATE_0_78HZ         (0x01)
-#define BMI160_MAG_OUTPUT_DATA_RATE_1_56HZ         (0x02)
-#define BMI160_MAG_OUTPUT_DATA_RATE_3_12HZ         (0x03)
-#define BMI160_MAG_OUTPUT_DATA_RATE_6_25HZ         (0x04)
-#define BMI160_MAG_OUTPUT_DATA_RATE_12_5HZ         (0x05)
-#define BMI160_MAG_OUTPUT_DATA_RATE_25HZ           (0x06)
-#define BMI160_MAG_OUTPUT_DATA_RATE_50HZ           (0x07)
-#define BMI160_MAG_OUTPUT_DATA_RATE_100HZ          (0x08)
-#define BMI160_MAG_OUTPUT_DATA_RATE_200HZ          (0x09)
-#define BMI160_MAG_OUTPUT_DATA_RATE_400HZ          (0x0A)
-#define BMI160_MAG_OUTPUT_DATA_RATE_800HZ          (0x0B)
-#define BMI160_MAG_OUTPUT_DATA_RATE_1600HZ         (0x0C)
-#define BMI160_MAG_OUTPUT_DATA_RATE_RESERVED0      (0x0D)
-#define BMI160_MAG_OUTPUT_DATA_RATE_RESERVED1      (0x0E)
-#define BMI160_MAG_OUTPUT_DATA_RATE_RESERVED2      (0x0F)
-
-/**************************************************/
-/**\name	ENABLE/DISABLE SELECTIONS        */
-/*************************************************/
-
-/* Enable Accel and Gyro  offset */
-#define ACCEL_OFFSET_ENABLE		(0x01)
-#define GYRO_OFFSET_ENABLE		(0x01)
-
-/* command register definition */
-#define START_FOC_ACCEL_GYRO	(0X03)
-
- /* INT ENABLE 1 */
-#define BMI160_ANY_MOTION_X_ENABLE       (0)
-#define BMI160_ANY_MOTION_Y_ENABLE       (1)
-#define BMI160_ANY_MOTION_Z_ENABLE       (2)
-#define BMI160_DOUBLE_TAP_ENABLE         (4)
-#define BMI160_SINGLE_TAP_ENABLE         (5)
-#define BMI160_ORIENT_ENABLE             (6)
-#define BMI160_FLAT_ENABLE               (7)
-
-/* INT ENABLE 1 */
-#define BMI160_HIGH_G_X_ENABLE       (0)
-#define BMI160_HIGH_G_Y_ENABLE       (1)
-#define BMI160_HIGH_G_Z_ENABLE       (2)
-#define BMI160_LOW_G_ENABLE          (3)
-#define BMI160_DATA_RDY_ENABLE       (4)
-#define BMI160_FIFO_FULL_ENABLE      (5)
-#define BMI160_FIFO_WM_ENABLE        (6)
-
-/* INT ENABLE 2 */
-#define  BMI160_NOMOTION_X_ENABLE	(0)
-#define  BMI160_NOMOTION_Y_ENABLE	(1)
-#define  BMI160_NOMOTION_Z_ENABLE	(2)
-
-/* FOC axis selection for accel*/
-#define	FOC_X_AXIS		(0)
-#define	FOC_Y_AXIS		(1)
-#define	FOC_Z_AXIS		(2)
-
-/* IN OUT CONTROL */
-#define BMI160_INTR1_EDGE_CTRL			(0)
-#define BMI160_INTR2_EDGE_CTRL			(1)
-#define BMI160_INTR1_LEVEL				(0)
-#define BMI160_INTR2_LEVEL				(1)
-#define BMI160_INTR1_OUTPUT_TYPE		(0)
-#define BMI160_INTR2_OUTPUT_TYPE		(1)
-#define BMI160_INTR1_OUTPUT_ENABLE		(0)
-#define BMI160_INTR2_OUTPUT_ENABLE		(1)
-
-#define BMI160_INTR1_INPUT_ENABLE	(0)
-#define BMI160_INTR2_INPUT_ENABLE	(1)
-
-/*  INTERRUPT MAPS    */
-#define BMI160_INTR1_MAP_LOW_G			(0)
-#define BMI160_INTR2_MAP_LOW_G			(1)
-#define BMI160_INTR1_MAP_HIGH_G			(0)
-#define BMI160_INTR2_MAP_HIGH_G			(1)
-#define BMI160_INTR1_MAP_ANY_MOTION		(0)
-#define BMI160_INTR2_MAP_ANY_MOTION		(1)
-#define BMI160_INTR1_MAP_NOMO			(0)
-#define BMI160_INTR2_MAP_NOMO			(1)
-#define BMI160_INTR1_MAP_DOUBLE_TAP		(0)
-#define BMI160_INTR2_MAP_DOUBLE_TAP		(1)
-#define BMI160_INTR1_MAP_SINGLE_TAP		(0)
-#define BMI160_INTR2_MAP_SINGLE_TAP		(1)
-#define BMI160_INTR1_MAP_ORIENT			(0)
-#define BMI160_INTR2_MAP_ORIENT			(1)
-#define BMI160_INTR1_MAP_FLAT			(0)
-#define BMI160_INTR2_MAP_FLAT			(1)
-#define BMI160_INTR1_MAP_DATA_RDY		(0)
-#define BMI160_INTR2_MAP_DATA_RDY		(1)
-#define BMI160_INTR1_MAP_FIFO_WM		(0)
-#define BMI160_INTR2_MAP_FIFO_WM		(1)
-#define BMI160_INTR1_MAP_FIFO_FULL      (0)
-#define BMI160_INTR2_MAP_FIFO_FULL      (1)
-#define BMI160_INTR1_MAP_PMUTRIG        (0)
-#define BMI160_INTR2_MAP_PMUTRIG		(1)
-
-/* Interrupt mapping*/
-#define	BMI160_MAP_INTR1		(0)
-#define	BMI160_MAP_INTR2		(1)
-/**************************************************/
-/**\name	 TAP DURATION         */
-/*************************************************/
-#define BMI160_TAP_DURN_50MS     (0x00)
-#define BMI160_TAP_DURN_100MS    (0x01)
-#define BMI160_TAP_DURN_150MS    (0x02)
-#define BMI160_TAP_DURN_200MS    (0x03)
-#define BMI160_TAP_DURN_250MS    (0x04)
-#define BMI160_TAP_DURN_375MS    (0x05)
-#define BMI160_TAP_DURN_500MS    (0x06)
-#define BMI160_TAP_DURN_700MS    (0x07)
-/**************************************************/
-/**\name	TAP SHOCK         */
-/*************************************************/
-#define BMI160_TAP_SHOCK_50MS	(0x00)
-#define BMI160_TAP_SHOCK_75MS	(0x01)
-/**************************************************/
-/**\name	TAP QUIET        */
-/*************************************************/
-#define BMI160_TAP_QUIET_30MS	(0x00)
-#define BMI160_TAP_QUIET_20MS	(0x01)
-/**************************************************/
-/**\name	STEP DETECTION SELECTION MODES      */
-/*************************************************/
-#define	BMI160_STEP_NORMAL_MODE			(0)
-#define	BMI160_STEP_SENSITIVE_MODE		(1)
-#define	BMI160_STEP_ROBUST_MODE			(2)
-/**************************************************/
-/**\name	STEP CONFIGURATION SELECT MODE    */
-/*************************************************/
-#define	STEP_CONFIG_NORMAL		(0X315)
-#define	STEP_CONFIG_SENSITIVE	(0X2D)
-#define	STEP_CONFIG_ROBUST		(0X71D)
-/**************************************************/
-/**\name	BMM150 TRIM DATA DEFINITIONS      */
-/*************************************************/
-#define BMI160_MAG_DIG_X1                      (0x5D)
-#define BMI160_MAG_DIG_Y1                      (0x5E)
-#define BMI160_MAG_DIG_Z4_LSB                  (0x62)
-#define BMI160_MAG_DIG_Z4_MSB                  (0x63)
-#define BMI160_MAG_DIG_X2                      (0x64)
-#define BMI160_MAG_DIG_Y2                      (0x65)
-#define BMI160_MAG_DIG_Z2_LSB                  (0x68)
-#define BMI160_MAG_DIG_Z2_MSB                  (0x69)
-#define BMI160_MAG_DIG_Z1_LSB                  (0x6A)
-#define BMI160_MAG_DIG_Z1_MSB                  (0x6B)
-#define BMI160_MAG_DIG_XYZ1_LSB                (0x6C)
-#define BMI160_MAG_DIG_XYZ1_MSB                (0x6D)
-#define BMI160_MAG_DIG_Z3_LSB                  (0x6E)
-#define BMI160_MAG_DIG_Z3_MSB                  (0x6F)
-#define BMI160_MAG_DIG_XY2                     (0x70)
-#define BMI160_MAG_DIG_XY1                     (0x71)
-/**************************************************/
-/**\name	BMM150 PRE-SET MODE DEFINITIONS     */
-/*************************************************/
-#define BMI160_MAG_PRESETMODE_LOWPOWER                 (1)
-#define BMI160_MAG_PRESETMODE_REGULAR                  (2)
-#define BMI160_MAG_PRESETMODE_HIGHACCURACY             (3)
-#define BMI160_MAG_PRESETMODE_ENHANCED                 (4)
-/**************************************************/
-/**\name	BMM150 PRESET MODES - DATA RATES    */
-/*************************************************/
-#define BMI160_MAG_LOWPOWER_DR                       (0x02)
-#define BMI160_MAG_REGULAR_DR                        (0x02)
-#define BMI160_MAG_HIGHACCURACY_DR                   (0x2A)
-#define BMI160_MAG_ENHANCED_DR                       (0x02)
-/**************************************************/
-/**\name	BMM150 PRESET MODES - REPETITIONS-XY RATES */
-/*************************************************/
-#define BMI160_MAG_LOWPOWER_REPXY                    (1)
-#define BMI160_MAG_REGULAR_REPXY                     (4)
-#define BMI160_MAG_HIGHACCURACY_REPXY                (23)
-#define BMI160_MAG_ENHANCED_REPXY                    (7)
-/**************************************************/
-/**\name	BMM150 PRESET MODES - REPETITIONS-Z RATES */
-/*************************************************/
-#define BMI160_MAG_LOWPOWER_REPZ                     (2)
-#define BMI160_MAG_REGULAR_REPZ                      (14)
-#define BMI160_MAG_HIGHACCURACY_REPZ                 (82)
-#define BMI160_MAG_ENHANCED_REPZ                     (26)
-#define BMI160_MAG_NORMAL_SWITCH_TIMES               (5)
-#define MAG_INTERFACE_PMU_ENABLE                     (1)
-#define MAG_INTERFACE_PMU_DISABLE                    (0)
-/**************************************************/
-/**\name	USED FOR MAG OVERFLOW CHECK FOR BMM150  */
-/*************************************************/
-#define BMI160_MAG_OVERFLOW_OUTPUT			((s16)-32768)
-#define BMI160_MAG_OVERFLOW_OUTPUT_S32		((s32)(-2147483647-1))
-#define BMI160_MAG_NEGATIVE_SATURATION_Z   ((s16)-32767)
-#define BMI160_MAG_POSITIVE_SATURATION_Z   ((u16)32767)
-#define BMI160_MAG_FLIP_OVERFLOW_ADCVAL		((s16)-4096)
-#define BMI160_MAG_HALL_OVERFLOW_ADCVAL		((s16)-16384)
-/**************************************************/
-/**\name	BMM150 REGISTER DEFINITION */
-/*************************************************/
-#define BMI160_BMM150_CHIP_ID           (0x40)
-#define BMI160_BMM150_POWER_CONTROL_REG	(0x4B)
-#define BMI160_BMM150_POWER_MODE_REG		(0x4C)
-#define BMI160_BMM150_DATA_REG			(0x42)
-#define BMI160_BMM150_XY_REP			(0x51)
-#define BMI160_BMM150_Z_REP				(0x52)
-/**************************************************/
-/**\name	AKM COMPENSATING DATA REGISTERS     */
-/*************************************************/
-#define BMI160_BST_AKM_ASAX		(0x60)
-#define BMI160_BST_AKM_ASAY		(0x61)
-#define BMI160_BST_AKM_ASAZ		(0x62)
-/**************************************************/
-/**\name	AKM POWER MODE SELECTION     */
-/*************************************************/
-#define AKM_POWER_DOWN_MODE			(0)
-#define AKM_SINGLE_MEAS_MODE		(1)
-#define FUSE_ROM_MODE				(2)
-/**************************************************/
-/**\name	SECONDARY_MAG POWER MODE SELECTION    */
-/*************************************************/
-#define BMI160_MAG_FORCE_MODE		(0)
-#define BMI160_MAG_SUSPEND_MODE		(1)
-/**************************************************/
-/**\name	MAG POWER MODE SELECTION    */
-/*************************************************/
-#define	FORCE_MODE		(0)
-#define	SUSPEND_MODE	(1)
-#define	NORMAL_MODE		(2)
-#define MAG_SUSPEND_MODE (1)
-
-#ifdef FIFO_ENABLE
-/**************************************************/
-/**\name	FIFO CONFIGURATIONS    */
-/*************************************************/
-#define FIFO_HEADER_ENABLE			(0x01)
-#define FIFO_MAG_ENABLE				(0x01)
-#define FIFO_ACCEL_ENABLE			(0x01)
-#define FIFO_GYRO_ENABLE			(0x01)
-#define FIFO_TIME_ENABLE			(0x01)
-#define FIFO_STOPONFULL_ENABLE		(0x01)
-#define FIFO_WM_INTERRUPT_ENABLE	(0x01)
-#define	BMI160_FIFO_INDEX_LENGTH	(1)
-#define	BMI160_FIFO_TAG_INTR_MASK	(0xFC)
-
-/* FIFO definitions*/
-#define FIFO_HEAD_A        (0x84)
-#define FIFO_HEAD_G        (0x88)
-#define FIFO_HEAD_M        (0x90)
-
-#define FIFO_HEAD_G_A	(0x8C)
-#define FIFO_HEAD_M_A   (0x94)
-#define FIFO_HEAD_M_G   (0x98)
-
-#define FIFO_HEAD_M_G_A		(0x9C)
-
-#define FIFO_HEAD_SENSOR_TIME			(0x44)
-#define FIFO_HEAD_INPUT_CONFIG			(0x48)
-#define FIFO_HEAD_SKIP_FRAME			(0x40)
-#define FIFO_HEAD_OVER_READ_LSB			(0x80)
-#define FIFO_HEAD_OVER_READ_MSB			(0x00)
-
-
-#define	FIFO_INPUT_CONFIG_OVER_LEN  ((s8)-11)
-#define	FIFO_OVER_READ_RETURN		((s8)-10)
-#define	FIFO_SENSORTIME_RETURN		((s8)-9)
-#define	FIFO_SKIP_OVER_LEN			((s8)-8)
-#define	FIFO_M_G_A_OVER_LEN			((s8)-7)
-#define	FIFO_M_G_OVER_LEN			((s8)-6)
-#define	FIFO_M_A_OVER_LEN			((s8)-5)
-#define	FIFO_G_A_OVER_LEN			((s8)-4)
-#define	FIFO_M_OVER_LEN				((s8)-3)
-#define	FIFO_G_OVER_LEN				((s8)-2)
-#define	FIFO_A_OVER_LEN				((s8)-1)
-#endif
-/**************************************************/
-/**\name	ACCEL POWER MODE    */
-/*************************************************/
-#define ACCEL_MODE_NORMAL	(0x11)
-#define	ACCEL_LOWPOWER		(0X12)
-#define	ACCEL_SUSPEND		(0X10)
-/* BMI160 Accel power modes*/
-#define BMI160_ACCEL_SUSPEND        0
-#define BMI160_ACCEL_NORMAL_MODE    1
-#define BMI160_ACCEL_LOW_POWER      2
-/**************************************************/
-/**\name	GYRO POWER MODE    */
-/*************************************************/
-#define GYRO_MODE_SUSPEND		(0x14)
-#define GYRO_MODE_NORMAL		(0x15)
-#define GYRO_MODE_FASTSTARTUP	(0x17)
-/**************************************************/
-/**\name	MAG POWER MODE    */
-/*************************************************/
-#define MAG_MODE_SUSPEND	(0x18)
-#define MAG_MODE_NORMAL		(0x19)
-#define MAG_MODE_LOWPOWER	(0x1A)
-/**************************************************/
-/**\name	ENABLE/DISABLE BIT VALUES    */
-/*************************************************/
-#define BMI160_ENABLE	(0x01)
-#define BMI160_DISABLE	(0x00)
-/**************************************************/
-/**\name	INTERRUPT EDGE TRIGGER ENABLE    */
-/*************************************************/
-#define BMI160_EDGE		(0x01)
-#define BMI160_LEVEL	(0x00)
-/**************************************************/
-/**\name	INTERRUPT LEVEL ENABLE    */
-/*************************************************/
-#define BMI160_LEVEL_LOW		(0x00)
-#define BMI160_LEVEL_HIGH		(0x01)
-/**************************************************/
-/**\name	INTERRUPT OUTPUT ENABLE    */
-/*************************************************/
-#define BMI160_OPEN_DRAIN	(0x01)
-#define BMI160_PUSH_PULL	(0x00)
-
-/* interrupt output enable*/
-#define BMI160_INPUT	(0x01)
-#define BMI160_OUTPUT	(0x00)
-
-/**************************************************/
-/**\name	INTERRUPT TAP SOURCE ENABLE    */
-/*************************************************/
-#define FILTER_DATA		(0x00)
-#define UNFILTER_DATA	(0x01)
-/**************************************************/
-/**\name	SLOW MOTION/ NO MOTION SELECT   */
-/*************************************************/
-#define SLOW_MOTION		(0x00)
-#define NO_MOTION		(0x01)
-/**************************************************/
-/**\name	SIGNIFICANT MOTION SELECTION   */
-/*************************************************/
-#define ANY_MOTION			(0x00)
-#define SIGNIFICANT_MOTION	(0x01)
-/**************************************************/
-/**\name	LATCH DURATION   */
-/*************************************************/
-#define BMI160_LATCH_DUR_NONE				(0x00)
-#define BMI160_LATCH_DUR_312_5_MICRO_SEC	(0x01)
-#define BMI160_LATCH_DUR_625_MICRO_SEC		(0x02)
-#define BMI160_LATCH_DUR_1_25_MILLI_SEC		(0x03)
-#define BMI160_LATCH_DUR_2_5_MILLI_SEC		(0x04)
-#define BMI160_LATCH_DUR_5_MILLI_SEC		(0x05)
-#define BMI160_LATCH_DUR_10_MILLI_SEC		(0x06)
-#define BMI160_LATCH_DUR_20_MILLI_SEC		(0x07)
-#define BMI160_LATCH_DUR_40_MILLI_SEC		(0x08)
-#define BMI160_LATCH_DUR_80_MILLI_SEC		(0x09)
-#define BMI160_LATCH_DUR_160_MILLI_SEC		(0x0A)
-#define BMI160_LATCH_DUR_320_MILLI_SEC		(0x0B)
-#define BMI160_LATCH_DUR_640_MILLI_SEC		(0x0C)
-#define BMI160_LATCH_DUR_1_28_SEC			(0x0D)
-#define BMI160_LATCH_DUR_2_56_SEC			(0x0E)
-#define BMI160_LATCHED						(0x0F)
-/**************************************************/
-/**\name	GYRO OFFSET MASK DEFINITION   */
-/*************************************************/
-#define BMI160_GYRO_MANUAL_OFFSET_0_7	(0x00FF)
-#define BMI160_GYRO_MANUAL_OFFSET_8_9	(0x0300)
-/**************************************************/
-/**\name	STEP CONFIGURATION MASK DEFINITION   */
-/*************************************************/
-#define BMI160_STEP_CONFIG_0_7		(0x00FF)
-#define BMI160_STEP_CONFIG_8_10		(0x0700)
-#define BMI160_STEP_CONFIG_11_14	(0xF000)
-/**************************************************/
-/**\name	DEFINITION USED FOR DIFFERENT WRITE   */
-/*************************************************/
-
-#define	BMI160_MANUAL_DISABLE	    (0x00)
-#define	BMI160_MANUAL_ENABLE	    (0x01)
-#define	BMI160_YAS_DISABLE_RCOIL	(0x00)
-#define	BMI160_ENABLE_MAG_IF_MODE	(0x02)
-#define	BMI160_ENABLE_ANY_MOTION_INTR1	(0x04)
-#define	BMI160_ENABLE_ANY_MOTION_INTR2	(0x04)
-#define	BMI160_MAG_DATA_READ_REG        (0x04)
-#define BMI160_BMM_POWER_MODE_REG		(0x06)
-#define	BMI160_ENABLE_ANY_MOTION_AXIS	(0x07)
-#define	BMI160_ENABLE_LOW_G             (0x08)
-#define	BMI160_YAS532_ACQ_START         (0x11)
-#define	BMI160_YAS_DEVICE_ID_REG        (0x80)
-#define	BMI160_FIFO_GYRO_ENABLE         (0x80)
-#define	BMI160_SIG_MOTION_INTR_ENABLE   (0x01)
-#define	BMI160_STEP_DETECT_INTR_ENABLE  (0x01)
-#define	BMI160_LOW_G_INTR_STAT          (0x01)
-#define BMI160_PULL_UP_DATA             (0x30)
-#define BMI160_FIFO_M_G_A_ENABLE        (0xE0)
-#define BMI160_FIFO_M_G_ENABLE          (0xA0)
-#define BMI160_FIFO_M_A_ENABLE          (0x60)
-#define BMI160_FIFO_G_A_ENABLE          (0xC0)
-#define BMI160_FIFO_A_ENABLE            (0x40)
-#define BMI160_FIFO_M_ENABLE            (0x20)
-
-#define BMI160_SEC_IF_BMM150	(0)
-#define BMI160_SEC_IF_AKM09911	(1)
-#define BMI160_SEC_IF_AKM09912	(2)
-#define BMI160_SEC_IF_YAS532	(3)
-#define BMI160_SEC_IF_YAS537	(4)
-/**************************************************/
-/**\name	MAG INIT DEFINITION  */
-/*************************************************/
-#define BMI160_COMMAND_REG_ONE		(0x37)
-#define BMI160_COMMAND_REG_TWO		(0x9A)
-#define BMI160_COMMAND_REG_THREE	(0xC0)
-#define	RESET_STEP_COUNTER			(0xB2)
-/**************************************************/
-/**\name	BIT SLICE GET AND SET FUNCTIONS  */
-/*************************************************/
-#define BMI160_GET_BITSLICE(regvar, bitname)\
-		((regvar & bitname##__MSK) >> bitname##__POS)
-
-
-#define BMI160_SET_BITSLICE(regvar, bitname, val)\
-		((regvar & ~bitname##__MSK) | \
-		((val<<bitname##__POS)&bitname##__MSK))
-
-/**************************************************/
-/**\name	 FUNCTION DECLARATIONS  */
-/*************************************************/
-/**************************************************/
-/**\name	 FUNCTION FOR BMI160 INITIALIZE  */
-/*************************************************/
-/*!
- *	@brief
- *	This API is used to 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 of bmi160 instance
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *	@note
- *	While changing the parameter of the bmi160_t
- *	consider the following points:
- *	Changing the reference value of the parameter
- *	will change the local copy or local reference
- *	make sure your changes will not
- *	affect the reference value of the parameter
- *	(Better don't change the reference value of the parameter)
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_init(struct bmi160_t *bmi160);
-/**************************************************/
-/**\name	 FUNCTION FOR READ AND WRITE REGISTERS  */
-/*************************************************/
-/*!
- * @brief
- *	This API writes the data to
- *	the given register
- *
- *
- *	@param v_addr_u8 -> Address of the register
- *	@param v_data_u8 -> The data to write to the register
- *	@param v_len_u8 -> no of bytes to write
- *
- *
- *	@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);
-/*!
- * @brief
- *	This API reads the data from
- *	the given register
- *
- *
- *	@param v_addr_u8 -> Address of the register
- *	@param v_data_u8 -> The data read 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);
-/**************************************************/
-/**\name	 FUNCTION FOR ERROR CODES  */
-/*************************************************/
-/*!
- *	@brief This API is used to read 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);
-/*!
- *	@brief This API is 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 is 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_error_code_u8);
-/*!
- *	@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_error_code_u8);
- /*!
- *	@brief This API reads the dropped command error
- *	from the register 0x02 bit 6
- *
- *
- *  @param v_drop_cmd_err_u8 : The status of dropped 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);
-/*!
- *	@brief This API reads the Mag data ready
- *	error interrupt
- *	It reads from the error register 0x02 bit 7
- *
- *
- *
- *
- *  @param v_mag_data_rdy_err_u8 : The status of Mag data ready error interrupt
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_data_rdy_err(u8
-*v_mag_data_rdy_err_u8);
-/*!
- *	@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_err_u8 : 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_err_u8,
-u8 *v_err_code_u8, u8 *v_i2c_fail_err_u8,
-u8 *v_drop_cmd_err_u8, u8 *v_mag_data_rdy_err_u8);
-/******************************************************************/
-/**\name	 FUNCTIONS FOR MAG,ACCEL AND GYRO POWER MODE STATUS  */
-/*****************************************************************/
-/*!
- *	@brief This API reads the Mag 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 is set by the 0x7E command register
- * 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);
-/*!
- *	@brief This API reads the Gyro 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  is set by the 0x7E command register
- * 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);
-/*!
- *	@brief This API reads the Accel 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 is set by the 0x7E command register
- * 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);
-/*!
- *	@brief This API switches the Mag interface to normal mode
- *	and confirm whether the mode switching is done successfully or not
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_interface_normal(void);
-/**************************************************/
-/**\name	 FUNCTION FOR Mag XYZ data read */
-/*************************************************/
-/*!
- *	@brief This API reads Mag data X values
- *	from the register 0x04 and 0x05
- *	@brief The Mag sensor data read from 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 output data rate configuration use the following function
- *	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);
-/*!
- *	@brief This API reads Mag data Y values
- *	from the register 0x06 and 0x07
- *	@brief The Mag sensor data read from 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 output data rate configuration use the following function
- *	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);
-/*!
- *	@brief This API reads Mag data Z values
- *	from the register 0x08 and 0x09
- *	@brief The Mag sensor data read from 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 output data rate configuration use the following function
- *	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);
-/*!
- *	@brief This API reads Mag 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);
-/*!
- *	@brief This API reads Mag data X,Y,Z values
- *	from the register 0x04 to 0x09
- *
- *	@brief The Mag sensor data read from 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 output data 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);
- /*!*
- *	@brief This API reads Mag data X,Y,Z,r
- *	values from the register 0x04 to 0x0B.
- *
- *	@brief The Mag sensor data read from 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);
-/**************************************************/
-/**\name	 FUNCTION FOR GYRO XYZ DATA READ  */
-/*************************************************/
-/*!
- *	@brief This API reads Gyro data X values
- *	from the register 0x0C and 0x0D.
- *
- *	@param v_gyro_x_s16 : The value of Gyro x data.
- *
- *	@note Gyro configuration use the following functions.
- *	@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);
-/*!
- *	@brief This API reads Gyro data Y values
- *	from 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);
-/*!
- *	@brief This API reads Gyro data Z values
- *	from the register 0x10 and 0x11.
- *
- *	@param v_gyro_z_s16 : The value of Gyro z data.
- *
- *	@note Gyro configuration use the following functions.
- *	@note bmi160_set_gyro_output_data_rate()
- *	@note bmi160_set_gyro_bw()
- *	@note bmi160_set_gyro_range()
- *
- *	@return results of the bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_gyro_z(
-s16 *v_gyro_z_s16);
-/*!
- *	@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 functions.
- *	@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);
-/**************************************************/
-/**\name	 FUNCTION FOR ACCEL XYZ DATA READ  */
-/*************************************************/
-/*!
- *	@brief This API reads the Accel data for X axis
- *	from the register 0x12 and 0x13.
- *
- *	@param v_accel_x_s16 : The value of Accel x axis.
- *
- *	@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);
-/*!
- *	@brief This API reads Accel data for Y axis
- *	from the register 0x14 and 0x15.
- *
- *	@param v_accel_y_s16 : The value of Accel y axis.
- *
- *	@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);
-/*!
- *	@brief This API reads Accel data Z values
- *	from the register 0x16 and 0x17.
- *
- *	@param v_accel_z_s16 : The value of Accel z axis.
- *
- *	@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);
-/*!
- *	@brief This API reads Accel data X,Y,Z values
- *	from the register 0x12 to 0x17.
- *
- *	@param Accel :The value of Accel xyz axis.
- *
- *	@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);
-/**************************************************/
-/**\name	 FUNCTION FOR SENSOR TIME */
-/*************************************************/
-/*!
- *	@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);
-/*!
- *	@brief This API reads sensor_time, Accel data, Gyro data from the
- *	register 0x0C to 0x1A.
- *
- *	@param accel_gyro_sensortime_select : to select the configuration
- *  value    |   output
- *  ---------|----------------
- *   0       | Accel data and Sensor time
- *   1       | Accel data ,Gyro data and Sensor time
- *
- *	@param accel_gyro_sensor_time : the value of Accel data, Gyro data and
- *	sensor time data
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_accel_gyro_sensor_time
-(u8 accel_gyro_sensortime_select,
-struct bmi160_sensortime_accel_gyro_data *accel_gyro_sensor_time);
-/**************************************************/
-/**\name	 FUNCTION FOR GYRO SELF TEST  */
-/*************************************************/
-/*!
- *	@brief This API reads the Gyro self test
- *	status from the register 0x1B bit 1
- *
- *  @param v_gyro_selftest_u8 : The value of Gyro self test status
- *  value    |   status
- *  ---------|----------------
- *   0       | Gyro self test is running or failed
- *   1       | Gyro 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);
-/**************************************************/
-/**\name	 FUNCTION FOR MANUAL INTERFACE  */
-/*************************************************/
-/*!
- *	@brief This API reads the status of
- *	mag manual interface operation from 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);
-/**************************************************/
-/**\name	 FUNCTION FOR FAST OFFSET READY  */
-/*************************************************/
-/*!
- *	@brief This API reads the fast offset compensation
- *	status from 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);
-
-/**************************************************/
-/**\name	 FUNCTION FOR DATA READY FOR MAG, GYRO, AND ACCEL */
-/*************************************************/
-/*!
- *	@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);
-/*!
- *	@brief This API reads the status of Gyro data ready from 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);
-/*!
- *	@brief This API reads the status of Accel data ready from the
- *	register 0x1B bit 7
- *	The status get reset when Accel data register is read
- *
- *
- *	@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
-*drdy_acc);
-/**************************************************/
-/**\name	 FUNCTION FOR STEP INTERRUPT STATUS  */
-/*************************************************/
-/*!
- *	@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 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);
-/**************************************************/
-/**\name	 FUNCTION FOR SIGNIFICANT INTERRUPT STATUS  */
-/*************************************************/
-/*!
- *	@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 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
-*sigmot_intr);
-/**************************************************/
-/**\name	 FUNCTION FOR ANY MOTION INTERRUPT STATUS  */
-/*************************************************/
- /*!
- *	@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 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);
-/**************************************************/
-/**\name	 FUNCTION FOR PMU TRIGGER INTERRUPT STATUS  */
-/*************************************************/
-/*!
- *	@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 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);
-/**************************************************/
-/**\name	 FUNCTION FOR DOUBLE TAB STATUS  */
-/*************************************************/
-/*!
- *	@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 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);
-/**************************************************/
-/**\name	 FUNCTION FOR SINGLE TAB STATUS  */
-/*************************************************/
-/*!
- *	@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 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);
-/**************************************************/
-/**\name	 FUNCTION FOR ORIENT INTERRUPT STATUS  */
-/*************************************************/
-/*!
- *	@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 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);
-/**************************************************/
-/**\name	 FUNCTION FOR FLAT INTERRUPT STATUS  */
-/*************************************************/
-/*!
- *	@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 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);
-/**************************************************/
-/**\name	 FUNCTION FOR HIGH_G INTERRUPT STATUS  */
-/*************************************************/
-/*!
- *	@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 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);
-/**************************************************/
-/**\name	 FUNCTION FOR LOW_G INTERRUPT STATUS  */
-/*************************************************/
-/*!
- *	@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 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);
-/**************************************************/
-/**\name	 FUNCTION FOR DATA READY INTERRUPT STATUS  */
-/*************************************************/
-/*!
- *	@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 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);
-
-#ifdef FIFO_ENABLE
-/**************************************************/
-/**\name	 FUNCTIONS FOR FIFO FULL AND WATER MARK INTERRUPT STATUS*/
-/*************************************************/
-/*!
- *	@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 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);
-/*!
- *	@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 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);
-#endif
-/**************************************************/
-/**\name	 FUNCTIONS FOR NO MOTION INTERRUPT STATUS*/
-/*************************************************/
-/*!
- *	@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 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
-*nomo_intr);
-/**************************************************/
-/**\name	 FUNCTIONS FOR ANY MOTION FIRST XYZ AND SIGN INTERRUPT STATUS*/
-/*************************************************/
-/*!
- *@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);
-/*!
- *	@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);
-/*!
- *	@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);
-/*!
- *	@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);
-/**************************************************/
-/**\name	 FUNCTIONS FOR TAP FIRST XYZ AND SIGN INTERRUPT STATUS*/
-/*************************************************/
-/*!
- *	@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);
-/*!
- *	@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);
-/*!
- *	@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);
-/*!
- *	@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
-*tap_sign);
-/**************************************************/
-/**\name	 FUNCTIONS FOR HIGH_G FIRST XYZ AND SIGN INTERRUPT STATUS*/
-/*************************************************/
-/*!
- *	@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);
-/*!
- *	@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);
-/*!
- *	@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);
-/*!
- *	@brief This API reads the high g sign status from the
- *	register 0x1F bit 3
- *
- *
- *
- *
- *  @param v_high_g_sign_u8 :The status of high g 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);
-/**************************************************/
-/**\name	 FUNCTIONS FOR ORIENT XY AND Z INTERRUPT STATUS*/
-/*************************************************/
-/*!
- *	@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);
-/*!
- *	@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);
-/**************************************************/
-/**\name	 FUNCTIONS FOR FLAT INTERRUPT STATUS*/
-/*************************************************/
-/*!
- *	@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
-*flat);
-/**************************************************/
-/**\name	 FUNCTION FOR TEMPERATURE READ */
-/*************************************************/
-/*!
- *	@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);
-#ifdef FIFO_ENABLE
-/**************************************************/
-/**\name	 FUNCTION FOR FIFO LENGTH AND FIFO DATA READ */
-/*************************************************/
-/*!
- *	@brief This API reads the FIFO length of the sensor
- *	from the register 0x23 and 0x24 bit 0 to 7 and 0 to 2
- *	@brief this byte counter is updated each time a complete frame
- *	is read or written
- *
- *
- *  @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);
-/*!
- *	@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 v_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);
-#endif
-/**************************************************/
-/**\name	 FUNCTION FOR ACCEL CONFIGURATIONS */
-/*************************************************/
-/*!
- *	@brief This API is used to get the
- *	accel output date rate from 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);
-/*!
- *	@brief This API is used to set the
- *	accel output date rate from 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
- *
- *  @param  v_accel_bw_u8 :The value of Accel selected Accel bandwidth
- *  value |  output data rate
- * -------|--------------------------
- *    0   |  BMI160_ACCEL_OSR4_AVG1
- *    1   |  BMI160_ACCEL_OSR2_AVG2
- *    2   |  BMI160_ACCEL_NORMAL_AVG4
- *    3   |  BMI160_ACCEL_CIC_AVG8
- *    4   |  BMI160_ACCEL_RES_AVG2
- *    5   |  BMI160_ACCEL_RES_AVG4
- *    6   |  BMI160_ACCEL_RES_AVG8
- *    7   |  BMI160_ACCEL_RES_AVG16
- *    8   |  BMI160_ACCEL_RES_AVG32
- *    9   |  BMI160_ACCEL_RES_AVG64
- *    10  |  BMI160_ACCEL_RES_AVG128
- *
- *
- *
- *
- *
- *	@note Verify the Accel bandwidth before setting the
- *  output data rate
- *  bandwidth  | output data rate |  under sampling
- *-------------|------------------|----------------
- *   OSR4      |  12.5 TO 1600    |   0
- *   OSR2      |  12.5 TO 1600    |   0
- *  NORMAL     |  12.5 TO 1600    |   0
- *   CIC       |  12.5 TO 1600    |   0
- *   AVG2      |  0.78 TO 400     |   1
- *   AVG4      |  0.78 TO 200     |   1
- *   AVG8      |  0.78 TO 100     |   1
- *   AVG16     |  0.78 TO 50      |   1
- *   AVG32     |  0.78 TO 25      |   1
- *   AVG64     |  0.78 TO 12.5    |   1
- *   AVG128    |  0.78 TO 6.25    |   1
- *
- *	@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, u8 v_accel_bw_u8);
-/*!
- *	@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);
-/*!
- *	@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);
-/*!
- *	@brief This API is used to get the accel
- *	under sampling parameter from 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);
-/*!
- *	@brief This API is used to set the accel
- *	under sampling parameter from 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);
-/*!
- *	@brief This API is used to get the range
- *	(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);
-/*!
- *	@brief This API is used to set the range
- *	(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);
-/**************************************************/
-/**\name	 FUNCTION FOR GYRO CONFIGURATIONS */
-/*************************************************/
-/*!
- *	@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 *gyro_output_typer);
-/*!
- *	@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 gyro_output_typer);
-/*!
- *	@brief This API is used to get the
- *	bandwidth 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);
-/*!
- *	@brief This API is used to set the
- *	bandwidth 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);
-/*!
- *	@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);
-/*!
- *	@brief This API sets 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);
-/**************************************************/
-/**\name	 FUNCTION FOR MAG CONFIGURATIONS */
-/*************************************************/
-/*!
- *	@brief This API is used to get the
- *	output data rate of Mag from the register 0x44 bit 0 to 3
- *
- *
- *
- *
- *  @param  v_output_data_rate_u8 : 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 *odr);
-/*!
- *	@brief This API is used to set the
- *	output data rate of Mag from the register 0x44 bit 0 to 3
- *
- *
- *
- *
- *  @param  v_output_data_rate_u8 : 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 odr);
-#ifdef FIFO_ENABLE
-/**************************************************/
-/**\name	 FUNCTION FOR FIFO CONFIGURATIONS */
-/*************************************************/
- /*!
- *	@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);
- /*!
- *	@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);
-/*!
- *	@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);
-/*!
- *	@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);
-/*!
- *	@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);
- /*!
- *	@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);
-/*!
- *	@brief This API is used to read Accel FIFO filter data
- *	from the register 0x45 bit 7
- *
- *
- *
- *  @param accel_fifo_filter_u8 :The value of Accel filter data
- *  value      |  accel_fifo_filter_u8
- * ------------|-------------------------
- *    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 *accel_fifo_filter_u8);
-/*!
- *	@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);
-/**************************************************/
-/**\name	 FUNCTION FOR FIFO WATER MARK ENABLE */
-/*************************************************/
-/*!
- *	@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);
-/*!
- *	@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);
-/**************************************************/
-/**\name	 FUNCTION FOR FIFO CONFIGURATIONS */
-/*************************************************/
-/*!
- *	@brief This API reads FIFO sensor time
- *	frame after the last valid data frame from 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);
-/*!
- *	@brief This API sets FIFO sensor time
- *	frame after the last valid data frame from 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);
-/*!
- *	@brief This API reads FIFO tag interrupt2 enable status
- *	from the register 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);
-/*!
- *	@brief This API sets FIFO tag interrupt2 enable status
- *	from the register 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);
-/*!
- *	@brief This API reads FIFO tag interrupt1 enable status
- *	from the register 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);
-/*!
- *	@brief This API sets FIFO tag interrupt1 enable status
- *	from the register 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);
-/*!
- *	@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);
-/*!
- *	@brief This API sets 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);
-/*!
- *	@brief This API is used to check whether
- *	magnetometer data in FIFO (all 3 axes) or not from the
- *	register 0x47 bit 5
- *
- *  @param v_fifo_mag_u8 : The value of FIFO Mag enable
- *	value    | FIFO mag
- * ----------|-------------------
- *  0x00     |  no Mag data is stored
- *  0x01     |  Mag 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);
-/*!
- *	@brief This API is used to enable
- *	magnetometer data in FIFO (all 3 axes) from the register 0x47 bit 5
- *
- *  @param v_fifo_mag_u8 : The value of FIFO Mag enable
- *	value    | FIFO mag
- * ----------|-------------------
- *  0x00     |  no Mag data is stored
- *  0x01     |  Mag 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);
-/*!
- *	@brief This API is used to check whether
- *	accel data is stored in FIFO (all 3 axes) or not from the
- *	register 0x47 bit 6
- *
- *  @param v_fifo_accel_u8 : The value of FIFO Accel enable
- *	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);
-/*!
- *	@brief This API is used to enable
- *	accel data in FIFO (all 3 axes) from the register 0x47 bit 6
- *
- *  @param v_fifo_accel_u8 : The value of FIFO Accel enable
- *	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);
-/*!
- *	@brief This API is used to check whether
- *	gyro data is stored in FIFO (all 3 axes) or not from the
- *	register 0x47 bit 7
- *
- *
- *  @param v_fifo_gyro_u8 : The value of FIFO Gyro enable
- *	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);
-/*!
- *	@brief This API is used to enable
- *	gyro data in FIFO (all 3 axes) from the register 0x47 bit 7
- *
- *
- *  @param v_fifo_gyro_u8 : The value of FIFO Gyro enable
- *	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);
-#endif
-/***************************************************************/
-/**\name	FUNCTION FOR MAG I2C ADDRESS SELECTION          */
-/***************************************************************/
-/*!
- *	@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);
-/*!
- *	@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);
-/*!
- *	@brief This API is used to read the
- *	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 length
- *
- *
- *
- *	@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);
-/*!
- *	@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 length
- *
- *
- *
- *	@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);
-/***************************************************************/
-/**\name	FUNCTION FOR MAG OFFSET         */
-/***************************************************************/
-/*!
- *	@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);
-/*!
- *	@brief This API is used to set the
- *	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);
-/***************************************************************/
-/**\name	FUNCTION FOR MAG MANUAL/AUTO MODE SELECTION          */
-/***************************************************************/
-/*!
- *	@brief This API is used to read the
- *	Enable register access on MAG_IF[2] or MAG_IF[3].
- *	This implies that the DATA registers are not updated with
- *	magnetometer values. Accessing Mag requires
- *	the Mag 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);
-/*!
- *	@brief This API is used to set the
- *	Enable register access of MAG_IF[2] or MAG_IF[3].
- *	This implies that the DATA registers are not updated with
- *	magnetometer values. Accessing Mag requires
- *	the Mag 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);
-/***************************************************************/
-/**\name	FUNCTIONS FOR MAG READ, WRITE AND WRITE DATA ADDRESS  */
-/***************************************************************/
-/*!
- *	@brief This API is used to get the
- *	magnetometer read address from the register 0x4D bit 0 to 7
- *	@brief 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);
-/*!
- *	@brief This API is used to set
- *	magnetometer read address from the register 0x4D bit 0 to 7
- *	@brief address where data will be read from auxiliary mag
- *
- *
- *
- *  @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);
-/*!
- *	@brief This API is used to read
- *	magnetometer write address from the register 0x4E bit 0 to 7
- *	@brief write address where data will be written in magnetometer
- *
- *
- *
- *  @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);
-/*!
- *	@brief This API is used to set
- *	magnetometer write address from the register 0x4E bit 0 to 7
- *	@brief this is the address in Mag where the data will be written
- *
- *
- *
- *  @param  v_mag_write_addr_u8:
- *	The address which the data will be written to
- *
- *
- *	@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);
-/*!
- *	@brief This API is used to read Mag write data
- *	from the register 0x4F bit 0 to 7
- *	@brief The data will be written 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);
-/*!
- *	@brief This API is used to set Mag write data
- *	from the register 0x4F bit 0 to 7
- *	@brief The data will be written 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);
-/***************************************************************/
-/**\name	FUNCTION FOR INTERRUPT ENABLE OF
-ANY-MOTION XYZ, DOUBLE AND SINGLE TAP, ORIENT AND FLAT         */
-/***************************************************************/
-/*!
- *	@brief  This API is used to read
- *	interrupt enable from the register 0x50 bit 0 to 7
- *
- *
- *
- *
- *	@param v_enable_u8 : Value which selects the 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 enable, u8 *v_intr_enable_zero_u8);
-/*!
- *	@brief  This API is used to set
- *	interrupt enable from the register 0x50 bit 0 to 7
- *
- *
- *
- *
- *	@param v_enable_u8 : Value which selects the 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 enable, u8 v_intr_enable_zero_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR INTERRUPT ENABLE OF
-HIGH_G XYZ, LOW_G, DATA READY, FIFO FULL AND FIFO WATER MARK  */
-/***************************************************************/
-/*!
- *	@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 which selects 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 enable, u8 *v_intr_enable_1_u8);
-/*!
- *	@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 select the 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 enable, u8 v_intr_enable_1_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR INTERRUPT ENABLE OF
-NO MOTION XYZ  */
-/***************************************************************/
-/*!
- *	@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(
-u8 enable, u8 *v_intr_enable_2_u8);
-/*!
- *	@brief  This API is used to set
- *	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_set_intr_enable_2(
-u8 enable, u8 v_intr_enable_2_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR INTERRUPT ENABLE OF
-  STEP DETECTOR */
-/***************************************************************/
- /*!
- *	@brief This API is used to read
- *	interrupt enable step detector interrupt from
- *	the register bit 0x52 bit 3
- *
- *
- *
- *
- *	@param v_step_intr_u8 : The value of step detector interrupt enable
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_step_detector_enable(
-u8 *v_step_intr_u8);
- /*!
- *	@brief This API is used to set
- *	interrupt enable step detector interrupt from
- *	the register bit 0x52 bit 3
- *
- *
- *
- *
- *	@param v_step_intr_u8 : The value of step detector interrupt enable
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_step_detector_enable(
-u8 v_step_intr_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR INTERRUPT CONTROL */
-/***************************************************************/
-/*!
- *	@brief  This API reads trigger condition of interrupt1
- *	and interrupt2 pin from the register 0x53
- *	@brief interrupt1 - bit 0
- *	@brief interrupt2 - bit 4
- *
- *  @param v_channel_u8: The value of edge trigger selection
- *   v_channel_u8  |   Edge trigger
- *  ---------------|---------------
- *       0         | BMI160_INTR1_EDGE_CTRL
- *       1         | BMI160_INTR2_EDGE_CTRL
- *
- *	@param v_intr_edge_ctrl_u8 : The value of edge trigger enable
- *	value    | interrupt enable
- * ----------|-------------------
- *  0x01     |  BMI160_EDGE
- *  0x00     |  BMI160_LEVEL
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_edge_ctrl(
-u8 v_channel_u8, u8 *v_intr_edge_ctrl_u8);
-/*!
- *	@brief  This API configures trigger condition of interrupt1
- *	and interrupt2 pin from the register 0x53
- *	@brief interrupt1 - bit 0
- *	@brief interrupt2 - bit 4
- *
- *  @param v_channel_u8: The value of edge trigger selection
- *   v_channel_u8  |   Edge trigger
- *  ---------------|---------------
- *       0         | BMI160_INTR1_EDGE_CTRL
- *       1         | BMI160_INTR2_EDGE_CTRL
- *
- *	@param v_intr_edge_ctrl_u8 : The value of edge trigger enable
- *	value    | interrupt enable
- * ----------|-------------------
- *  0x01     |  BMI160_EDGE
- *  0x00     |  BMI160_LEVEL
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_edge_ctrl(
-u8 v_channel_u8, u8 v_intr_edge_ctrl_u8);
-/*!
- *	@brief  This API is used to get the Configure level condition of
- *	interrupt1 and interrupt2 pin from the register 0x53
- *	@brief interrupt1 - bit 1
- *	@brief interrupt2 - bit 5
- *
- *  @param v_channel_u8: The value of level condition selection
- *   v_channel_u8  |   level selection
- *  ---------------|---------------
- *       0         | BMI160_INTR1_LEVEL
- *       1         | BMI160_INTR2_LEVEL
- *
- *	@param v_intr_level_u8 : The value of level of interrupt enable
- *	value    | Behaviour
- * ----------|-------------------
- *  0x01     |  BMI160_LEVEL_HIGH
- *  0x00     |  BMI160_LEVEL_LOW
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_level(
-u8 v_channel_u8, u8 *v_intr_level_u8);
-/*!
- *	@brief  This API is used to set the configure level condition of
- *	interrupt1 and interrupt2 pin from the register 0x53
- *	@brief interrupt1 - bit 1
- *	@brief interrupt2 - bit 5
- *
- *  @param v_channel_u8: The value of level condition selection
- *   v_channel_u8  |   level selection
- *  ---------------|---------------
- *       0         | BMI160_INTR1_LEVEL
- *       1         | BMI160_INTR2_LEVEL
- *
- *	@param v_intr_level_u8 : The value of level of interrupt enable
- *	value    | Behaviour
- * ----------|-------------------
- *  0x01     |  BMI160_LEVEL_HIGH
- *  0x00     |  BMI160_LEVEL_LOW
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_level(
-u8 v_channel_u8, u8 v_intr_level_u8);
-/*!
- *	@brief  This API is used to get configured output enable of interrupt1
- *	and interrupt2 from the register 0x53
- *	@brief interrupt1 - bit 2
- *	@brief interrupt2 - bit 6
- *
- *
- *  @param v_channel_u8: The value of output type enable selection
- *   v_channel_u8  |   level selection
- *  ---------------|---------------
- *       0         | BMI160_INTR1_OUTPUT_TYPE
- *       1         | BMI160_INTR2_OUTPUT_TYPE
- *
- *	@param v_intr_output_type_u8 :
- *	The value of output type of interrupt enable
- *	value    | Behaviour
- * ----------|-------------------
- *  0x01     |  BMI160_OPEN_DRAIN
- *  0x00     |  BMI160_PUSH_PULL
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_output_type(
-u8 v_channel_u8, u8 *v_intr_output_type_u8);
-/*!
- *	@brief  This API is used to set output enable of interrupt1
- *	and interrupt2 from the register 0x53
- *	@brief interrupt1 - bit 2
- *	@brief interrupt2 - bit 6
- *
- *
- *  @param v_channel_u8: The value of output type enable selection
- *   v_channel_u8  |   level selection
- *  ---------------|---------------
- *       0         | BMI160_INTR1_OUTPUT_TYPE
- *       1         | BMI160_INTR2_OUTPUT_TYPE
- *
- *	@param v_intr_output_type_u8 :
- *	The value of output type of interrupt enable
- *	value    | Behaviour
- * ----------|-------------------
- *  0x01     |  BMI160_OPEN_DRAIN
- *  0x00     |  BMI160_PUSH_PULL
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_output_type(
-u8 v_channel_u8, u8 v_intr_output_type_u8);
- /*!
- *	@brief This API is used to get the output enable for interrupt1
- *	and interrupt2 pin from the register 0x53
- *	@brief interrupt1 - bit 3
- *	@brief interrupt2 - bit 7
- *
- *  @param v_channel_u8: The value of output enable selection
- *   v_channel_u8  |   level selection
- *  ---------------|---------------
- *       0         | BMI160_INTR1_OUTPUT_ENABLE
- *       1         | BMI160_INTR2_OUTPUT_ENABLE
- *
- *	@param v_output_enable_u8 :
- *	The value of output enable of interrupt enable
- *	value    | Behaviour
- * ----------|-------------------
- *  0x01     |  INTERRUPT OUTPUT ENABLED
- *  0x00     |  INTERRUPT OUTPUT DISABLED
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_output_enable(
-u8 v_channel_u8, u8 *v_output_enable_u8);
- /*!
- *	@brief This API is used to set the Output enable for interrupt1
- *	and interrupt2 pin from the register 0x53
- *	@brief interrupt1 - bit 3
- *	@brief interrupt2 - bit 7
- *
- *  @param v_channel_u8: The value of output enable selection
- *   v_channel_u8  |   level selection
- *  ---------------|---------------
- *       0         | BMI160_INTR1_OUTPUT_ENABLE
- *       1         | BMI160_INTR2_OUTPUT_ENABLE
- *
- *	@param v_output_enable_u8 :
- *	The value of output enable of interrupt enable
- *	value    | Behaviour
- * ----------|-------------------
- *  0x01     |  INTERRUPT OUTPUT ENABLED
- *  0x00     |  INTERRUPT OUTPUT DISABLED
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_output_enable(
-u8 v_channel_u8, u8 v_output_enable_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR INTERRUPT LATCH INTERRUPT  */
-/***************************************************************/
-/*!
-*	@brief This API is used to get the latch duration
-*	from the register 0x54 bit 0 to 3
-*	@brief This latch selection is not applicable for data ready,
-*	orientation and flat interrupts.
-*
-*
-*
-*  @param v_latch_intr_u8 : The value of latch duration
-*	Latch Duration                      |     value
-* --------------------------------------|------------------
-*    BMI160_LATCH_DUR_NONE              |      0x00
-*    BMI160_LATCH_DUR_312_5_MICRO_SEC   |      0x01
-*    BMI160_LATCH_DUR_625_MICRO_SEC     |      0x02
-*    BMI160_LATCH_DUR_1_25_MILLI_SEC    |      0x03
-*    BMI160_LATCH_DUR_2_5_MILLI_SEC     |      0x04
-*    BMI160_LATCH_DUR_5_MILLI_SEC       |      0x05
-*    BMI160_LATCH_DUR_10_MILLI_SEC      |      0x06
-*    BMI160_LATCH_DUR_20_MILLI_SEC      |      0x07
-*    BMI160_LATCH_DUR_40_MILLI_SEC      |      0x08
-*    BMI160_LATCH_DUR_80_MILLI_SEC      |      0x09
-*    BMI160_LATCH_DUR_160_MILLI_SEC     |      0x0A
-*    BMI160_LATCH_DUR_320_MILLI_SEC     |      0x0B
-*    BMI160_LATCH_DUR_640_MILLI_SEC     |      0x0C
-*    BMI160_LATCH_DUR_1_28_SEC          |      0x0D
-*    BMI160_LATCH_DUR_2_56_SEC          |      0x0E
-*    BMI160_LATCHED                     |      0x0F
-*
-*
-*
-*	@return results of bus communication function
-*	@retval 0 -> Success
-*	@retval -1 -> Error
-*
-*
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_latch_intr(
-u8 *v_latch_intr_u8);
-/*!
-*	@brief This API is used to set the latch duration
-*	from the register 0x54 bit 0 to 3
-*	@brief This latch selection is not applicable for data ready,
-*	orientation and flat interrupts.
-*
-*
-*
-*  @param v_latch_intr_u8 : The value of latch duration
-*	Latch Duration                      |     value
-* --------------------------------------|------------------
-*    BMI160_LATCH_DUR_NONE              |      0x00
-*    BMI160_LATCH_DUR_312_5_MICRO_SEC   |      0x01
-*    BMI160_LATCH_DUR_625_MICRO_SEC     |      0x02
-*    BMI160_LATCH_DUR_1_25_MILLI_SEC    |      0x03
-*    BMI160_LATCH_DUR_2_5_MILLI_SEC     |      0x04
-*    BMI160_LATCH_DUR_5_MILLI_SEC       |      0x05
-*    BMI160_LATCH_DUR_10_MILLI_SEC      |      0x06
-*    BMI160_LATCH_DUR_20_MILLI_SEC      |      0x07
-*    BMI160_LATCH_DUR_40_MILLI_SEC      |      0x08
-*    BMI160_LATCH_DUR_80_MILLI_SEC      |      0x09
-*    BMI160_LATCH_DUR_160_MILLI_SEC     |      0x0A
-*    BMI160_LATCH_DUR_320_MILLI_SEC     |      0x0B
-*    BMI160_LATCH_DUR_640_MILLI_SEC     |      0x0C
-*    BMI160_LATCH_DUR_1_28_SEC          |      0x0D
-*    BMI160_LATCH_DUR_2_56_SEC          |      0x0E
-*    BMI160_LATCHED                     |      0x0F
-*
-*
-*
-*	@return results of bus communication function
-*	@retval 0 -> Success
-*	@retval -1 -> Error
-*
-*
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_latch_intr(
-u8 v_latch_intr_u8);
-/*!
- *	@brief API is used to get input enable for interrupt1
- *	and interrupt2 pin from the register 0x54
- *	@brief interrupt1 - bit 4
- *	@brief interrupt2 - bit 5
- *
- *  @param v_channel_u8: The value of input enable selection
- *   v_channel_u8  |   input selection
- *  ---------------|---------------
- *       0         | BMI160_INTR1_INPUT_ENABLE
- *       1         | BMI160_INTR2_INPUT_ENABLE
- *
- *	@param v_input_en_u8 :
- *	The value of input enable of interrupt enable
- *	value    | Behaviour
- * ----------|-------------------
- *  0x01     |  BMI160_INPUT_ENABLED
- *  0x00     |  BMI160_INPUT_DISABLED
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_input_enable(
-u8 v_channel_u8, u8 *v_input_en_u8);
-/*!
- *	@brief API is used to set input enable for interrupt1
- *	and interrupt2 pin from the register 0x54
- *	@brief interrupt1 - bit 4
- *	@brief interrupt2 - bit 5
- *
- *  @param v_channel_u8: The value of input enable selection
- *   v_channel_u8  |   input selection
- *  ---------------|---------------
- *       0         | BMI160_INTR1_INPUT_ENABLE
- *       1         | BMI160_INTR2_INPUT_ENABLE
- *
- *	@param v_input_en_u8 :
- *	The value of input enable of interrupt enable
- *	value    | Behaviour
- * ----------|-------------------
- *  0x01     |  BMI160_INPUT_ENABLED
- *  0x00     |  BMI160_INPUT_DISABLED
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_input_enable(
-u8 v_channel_u8, u8 v_input_en_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR INTERRUPT1 AND INTERRUPT2 MAPPING */
-/***************************************************************/
- /*!
- *	@brief This API reads the Low g interrupt which is mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 0 in the register 0x55
- *	@brief interrupt2 bit 0 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of low_g selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_LOW_G
- *       1         | BMI160_INTR2_MAP_LOW_G
- *
- *	@param v_intr_low_g_u8 : The value of low_g enable
- *	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_low_g(
-u8 v_channel_u8, u8 *v_intr_low_g_u8);
- /*!
- *	@brief This API sets the Low g interrupt to be mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 0 in the register 0x55
- *	@brief interrupt2 bit 0 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of low_g selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_LOW_G
- *       1         | BMI160_INTR2_MAP_LOW_G
- *
- *	@param v_intr_low_g_u8 : The value of low_g enable
- *	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_low_g(
-u8 v_channel_u8, u8 v_intr_low_g_u8);
-/*!
- *	@brief This API reads the HIGH g interrupt which is mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 1 in the register 0x55
- *	@brief interrupt2 bit 1 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of high_g selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_HIGH_G
- *       1         | BMI160_INTR2_MAP_HIGH_G
- *
- *	@param v_intr_high_g_u8 : The value of high_g enable
- *	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_high_g(
-u8 v_channel_u8, u8 *v_intr_high_g_u8);
-/*!
- *	@brief This API writes the HIGH g interrupt to be mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 1 in the register 0x55
- *	@brief interrupt2 bit 1 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of high_g selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_HIGH_G
- *       1         | BMI160_INTR2_MAP_HIGH_G
- *
- *	@param v_intr_high_g_u8 : The value of high_g enable
- *	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_high_g(
-u8 v_channel_u8, u8 v_intr_high_g_u8);
-/*!
- *	@brief This API reads the Any motion interrupt which is mapped to
- *	interrupt1 and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 2 in the register 0x55
- *	@brief interrupt2 bit 2 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of any motion selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_ANY_MOTION
- *       1         | BMI160_INTR2_MAP_ANY_MOTION
- *
- *	@param v_intr_any_motion_u8 : The value of any motion enable
- *	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_any_motion(
-u8 v_channel_u8, u8 *v_intr_any_motion_u8);
-/*!
- *	@brief This API writes the Any motion interrupt
- *	to be mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 2 in the register 0x55
- *	@brief interrupt2 bit 2 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of any motion selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_ANY_MOTION
- *       1         | BMI160_INTR2_MAP_ANY_MOTION
- *
- *	@param v_intr_any_motion_u8 : The value of any motion enable
- *	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_any_motion(
-u8 v_channel_u8, u8 v_intr_any_motion_u8);
-/*!
- *	@brief This API reads the No motion interrupt
- *	which is  mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 3 in the register 0x55
- *	@brief interrupt2 bit 3 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of no motion selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_NOMO
- *       1         | BMI160_INTR2_MAP_NOMO
- *
- *	@param v_intr_nomotion_u8 : The value of no motion enable
- *	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_nomotion(
-u8 v_channel_u8, u8 *v_intr_nomotion_u8);
-/*!
- *	@brief This API configures the No motion interrupt
- *	to be mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 3 in the register 0x55
- *	@brief interrupt2 bit 3 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of no motion selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_NOMO
- *       1         | BMI160_INTR2_MAP_NOMO
- *
- *	@param v_intr_nomotion_u8 : The value of no motion enable
- *	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_nomotion(
-u8 v_channel_u8, u8 v_intr_nomotion_u8);
-/*!
- *	@brief This API reads the Double Tap interrupt
- *	which is mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 4 in the register 0x55
- *	@brief interrupt2 bit 4 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of double tap interrupt selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_DOUBLE_TAP
- *       1         | BMI160_INTR2_MAP_DOUBLE_TAP
- *
- *	@param v_intr_double_tap_u8 : The value of double tap enable
- *	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_double_tap(
-u8 v_channel_u8, u8 *v_intr_double_tap_u8);
-/*!
- *	@brief This API configures the Double Tap interrupt
- *	to be mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 4 in the register 0x55
- *	@brief interrupt2 bit 4 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of double tap interrupt selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_DOUBLE_TAP
- *       1         | BMI160_INTR2_MAP_DOUBLE_TAP
- *
- *	@param v_intr_double_tap_u8 : The value of double tap enable
- *	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_double_tap(
-u8 v_channel_u8, u8 v_intr_double_tap_u8);
-/*!
- *	@brief This API reads the Single Tap interrupt
- *	which is mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 5 in the register 0x55
- *	@brief interrupt2 bit 5 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of single tap interrupt selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_SINGLE_TAP
- *       1         | BMI160_INTR2_MAP_SINGLE_TAP
- *
- *	@param v_intr_single_tap_u8 : The value of single tap  enable
- *	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_single_tap(
-u8 v_channel_u8, u8 *v_intr_single_tap_u8);
-/*!
- *	@brief This API configures the Single Tap interrupt
- *	to be mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 5 in the register 0x55
- *	@brief interrupt2 bit 5 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of single tap interrupt selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_SINGLE_TAP
- *       1         | BMI160_INTR2_MAP_SINGLE_TAP
- *
- *	@param v_intr_single_tap_u8 : The value of single tap  enable
- *	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_single_tap(
-u8 v_channel_u8, u8 v_intr_single_tap_u8);
-/*!
- *	@brief This API reads the Orient interrupt which is mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 6 in the register 0x55
- *	@brief interrupt2 bit 6 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of orient interrupt selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_ORIENT
- *       1         | BMI160_INTR2_MAP_ORIENT
- *
- *	@param v_intr_orient_u8 : The value of orient enable
- *	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_orient(
-u8 v_channel_u8, u8 *v_intr_orient_u8);
-/*!
- *	@brief This API configures the Orient interrupt
- *	to be mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 6 in the register 0x55
- *	@brief interrupt2 bit 6 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of orient interrupt selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_ORIENT
- *       1         | BMI160_INTR2_MAP_ORIENT
- *
- *	@param v_intr_orient_u8 : The value of orient enable
- *	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_orient(
-u8 v_channel_u8, u8 v_intr_orient_u8);
- /*!
- *	@brief This API reads the Flat interrupt which is
- *	mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 7 in the register 0x55
- *	@brief interrupt2 bit 7 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of flat interrupt selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_FLAT
- *       1         | BMI160_INTR2_MAP_FLAT
- *
- *	@param v_intr_flat_u8 : The value of flat enable
- *	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_flat(
-u8 v_channel_u8, u8 *v_intr_flat_u8);
- /*!
- *	@brief This API configures the Flat interrupt to be
- *	mapped to interrupt1
- *	and interrupt2 from the register 0x55 and 0x57
- *	@brief interrupt1 bit 7 in the register 0x55
- *	@brief interrupt2 bit 7 in the register 0x57
- *
- *
- *	@param v_channel_u8: The value of flat interrupt selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_FLAT
- *       1         | BMI160_INTR2_MAP_FLAT
- *
- *	@param v_intr_flat_u8 : The value of flat enable
- *	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_flat(
-u8 v_channel_u8, u8 v_intr_flat_u8);
-/*!
- *	@brief This API reads the PMU trigger interrupt which is mapped to
- *	interrupt1 and interrupt2 from the register 0x56 bit 0 and 4
- *	@brief interrupt1 bit 0 in the register 0x56
- *	@brief interrupt2 bit 4 in the register 0x56
- *
- *
- *	@param v_channel_u8: The value of pmu trigger selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_PMUTRIG
- *       1         | BMI160_INTR2_MAP_PMUTRIG
- *
- *	@param v_intr_pmu_trig_u8 : The value of pmu trigger enable
- *	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_pmu_trig(
-u8 v_channel_u8, u8 *v_intr_pmu_trig_u8);
-/*!
- *	@brief This API configures the PMU trigger interrupt to be mapped to
- *	interrupt1 and interrupt2 from the register 0x56 bit 0 and 4
- *	@brief interrupt1 bit 0 in the register 0x56
- *	@brief interrupt2 bit 4 in the register 0x56
- *
- *
- *	@param v_channel_u8: The value of pmu trigger selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_PMUTRIG
- *       1         | BMI160_INTR2_MAP_PMUTRIG
- *
- *	@param v_intr_pmu_trig_u8 : The value of pmu trigger enable
- *	value    | trigger 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_pmu_trig(
-u8 v_channel_u8, u8 v_intr_pmu_trig_u8);
-
-/*!
- *	@brief This API reads the FIFO Full interrupt which is mapped to
- *	interrupt1 and interrupt2 from the register 0x56 bit 5 and 1
- *	@brief interrupt1 bit 5 in the register 0x56
- *	@brief interrupt2 bit 1 in the register 0x56
- *
- *
- *	@param v_channel_u8: The value of FIFO full interrupt selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_FIFO_FULL
- *       1         | BMI160_INTR2_MAP_FIFO_FULL
- *
- *	@param v_intr_fifo_full_u8 : The value of FIFO full interrupt enable
- *	value    | interrupt enable
- * ----------|-------------------
- *  0x01     |  BMI160_ENABLE
- *  0x00     |  BMI160_DISABLE
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-#ifdef FIFO_ENABLE
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_fifo_full(
-u8 v_channel_u8, u8 *v_intr_fifo_full_u8);
-/*!
- *	@brief This API configures the  FIFO Full interrupt to be mapped to
- *	interrupt1 and interrupt2 from the register 0x56 bit 5 and 1
- *	@brief interrupt1 bit 5 in the register 0x56
- *	@brief interrupt2 bit 1 in the register 0x56
- *
- *
- *	@param v_channel_u8: The value of FIFO full interrupt selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_FIFO_FULL
- *       1         | BMI160_INTR2_MAP_FIFO_FULL
- *
- *	@param v_intr_fifo_full_u8 : The value of FIFO full interrupt enable
- *	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_fifo_full(
-u8 v_channel_u8, u8 v_intr_fifo_full_u8);
-/*!
- *	@brief This API reads FIFO Watermark interrupt which is mapped to
- *	interrupt1 and interrupt2 from the register 0x56 bit 6 and 2
- *	@brief interrupt1 bit 6 in the register 0x56
- *	@brief interrupt2 bit 2 in the register 0x56
- *
- *
- *	@param v_channel_u8: The value of FIFO Watermark interrupt selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_FIFO_WM
- *       1         | BMI160_INTR2_MAP_FIFO_WM
- *
- *	@param v_intr_fifo_wm_u8 : The value of FIFO Watermark interrupt enable
- *	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_fifo_wm(
-u8 v_channel_u8, u8 *v_intr_fifo_wm_u8);
-/*!
- *	@brief This API configures FIFO Watermark interrupt to be mapped to
- *	interrupt1 and interrupt2 from the register 0x56 bit 6 and 2
- *	@brief interrupt1 bit 6 in the register 0x56
- *	@brief interrupt2 bit 2 in the register 0x56
- *
- *
- *	@param v_channel_u8: The value of FIFO Watermark interrupt selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_FIFO_WM
- *       1         | BMI160_INTR2_MAP_FIFO_WM
- *
- *	@param v_intr_fifo_wm_u8 : The value of FIFO Watermark interrupt enable
- *	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_fifo_wm(
-u8 v_channel_u8, u8 v_intr_fifo_wm_u8);
-#endif
-/*!
- *	@brief This API reads Data Ready interrupt which is mapped to interrupt1
- *	and interrupt2 from the register 0x56
- *	@brief interrupt1 bit 7 in the register 0x56
- *	@brief interrupt2 bit 3 in the register 0x56
- *
- *
- *	@param v_channel_u8: The value of data ready interrupt selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_DATA_RDY
- *       1         | BMI160_INTR2_MAP_DATA_RDY
- *
- *	@param v_intr_data_rdy_u8 : The value of data ready interrupt enable
- *	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_data_rdy(
-u8 v_channel_u8, u8 *v_intr_data_rdy_u8);
-/*!
- *	@brief This API configures Data Ready interrupt to be mapped to
- *	interrupt1 and interrupt2 from the register 0x56
- *	@brief interrupt1 bit 7 in the register 0x56
- *	@brief interrupt2 bit 3 in the register 0x56
- *
- *
- *	@param v_channel_u8: The value of data ready interrupt selection
- *   v_channel_u8  |   interrupt
- *  ---------------|---------------
- *       0         | BMI160_INTR1_MAP_DATA_RDY
- *       1         | BMI160_INTR2_MAP_DATA_RDY
- *
- *	@param v_intr_data_rdy_u8 : The value of data ready interrupt enable
- *	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_data_rdy(
-u8 v_channel_u8, u8 v_intr_data_rdy_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR TAP SOURCE CONFIGURATION          */
-/***************************************************************/
- /*!
- *	@brief This API reads data source for the interrupt
- *	engine for the single and double tap interrupts from the register
- *	0x58 bit 3
- *
- *
- *  @param v_tap_source_u8 : The value of the tap source
- *	value    | Description
- * ----------|-------------------
- *  0x01     |  UNFILTER_DATA
- *  0x00     |  FILTER_DATA
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_source(
-u8 *v_tap_source_u8);
- /*!
- *	@brief This API writes data source for the interrupt
- *	engine for the single and double tap interrupts from the register
- *	0x58 bit 3
- *
- *
- *  @param v_tap_source_u8 : The value of the tap source
- *	value    | Description
- * ----------|-------------------
- *  0x01     |  UNFILTER_DATA
- *  0x00     |  FILTER_DATA
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_source(
-u8 v_tap_source_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR LOW_G AND HIGH_G SOURCE CONFIGURATION */
-/***************************************************************/
- /*!
- *	@brief This API reads Data source for the
- *	interrupt engine for the low and high g interrupts
- *	from the register 0x58 bit 7
- *
- *  @param v_low_high_source_u8 : The value of the low-g/high-g source
- *	value    | Description
- * ----------|-------------------
- *  0x01     |  UNFILTER_DATA
- *  0x00     |  FILTER_DATA
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_high_source(
-u8 *v_low_high_source_u8);
-/*!
- *	@brief This API writes Data source for the
- *	interrupt engine for the low and high g interrupts
- *	from the register 0x58 bit 7
- *
- *  @param v_low_high_source_u8 : The value of the low-g/high-g source
- *	value    | Description
- * ----------|-------------------
- *  0x01     |  UNFILTER_DATA
- *  0x00     |  FILTER_DATA
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_high_source(
-u8 v_low_high_source_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR MOTION SOURCE CONFIGURATION          */
-/***************************************************************/
- /*!
- *	@brief This API reads Data source for the
- *	interrupt engine for the nomotion and anymotion interrupts
- *	from the register 0x59 bit 7
- *
- *  @param v_motion_source_u8 :
- *	The value of the any/no motion interrupt source
- *	value    | Description
- * ----------|-------------------
- *  0x01     |  UNFILTER_DATA
- *  0x00     |  FILTER_DATA
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_motion_source(
-u8 *v_motion_source_u8);
- /*!
- *	@brief This API writes Data source for the
- *	interrupt engine for the nomotion and anymotion interrupts
- *	from the register 0x59 bit 7
- *
- *  @param v_motion_source_u8 :
- *	The value of the any/no motion interrupt source
- *	value    | Description
- * ----------|-------------------
- *  0x01     |  UNFILTER_DATA
- *  0x00     |  FILTER_DATA
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_motion_source(
-u8 v_motion_source_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR LOW_G DURATION CONFIGURATION          */
-/***************************************************************/
- /*!
- *	@brief This API is used to read the low_g duration from register
- *	0x5A bit 0 to 7
- *
- *
- *
- *
- *  @param v_low_g_durn_u8 : The value of low_g duration
- *
- *	@note Low_g duration trigger trigger delay according to
- *	"(v_low_g_durn_u8 * 2.5)ms" in a range from 2.5ms to 640ms.
- *	the default corresponds delay is 20ms
- *	@note When low_g data source of interrupt is unfiltered
- *	the sensor must not be in low power mode
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_g_durn(
-u8 *v_low_durn_u8);
- /*!
- *	@brief This API is used to write the low_g duration from register
- *	0x5A bit 0 to 7
- *
- *
- *
- *
- *  @param v_low_g_durn_u8 : The value of low_g duration
- *
- *	@note Low_g duration trigger trigger delay according to
- *	"(v_low_g_durn_u8 * 2.5)ms" in a range from 2.5ms to 640ms.
- *	the default corresponds delay is 20ms
- *	@note When low_g data source of interrupt is unfiltered
- *	the sensor must not be in low power mode
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_g_durn(
-u8 v_low_durn_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR LOW_G THRESH CONFIGURATION          */
-/***************************************************************/
-/*!
- *	@brief This API is used to read Threshold
- *	definition for the low-g interrupt from the register 0x5B bit 0 to 7
- *
- *
- *
- *
- *  @param v_low_g_thres_u8 : The value of low_g threshold
- *
- *	@note Low_g interrupt trigger threshold according to
- *	(v_low_g_thres_u8 * 7.81)mg for v_low_g_thres_u8 > 0
- *	3.91 mg for v_low_g_thres_u8 = 0
- *	The threshold range is from 3.91mg to 2.000mg
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_g_thres(
-u8 *v_low_g_thres_u8);
-/*!
- *	@brief This API is used to write Threshold
- *	definition for the low-g interrupt from the register 0x5B bit 0 to 7
- *
- *
- *
- *
- *  @param v_low_g_thres_u8 : The value of low_g threshold
- *
- *	@note Low_g interrupt trigger threshold according to
- *	(v_low_g_thres_u8 * 7.81)mg for v_low_g_thres_u8 > 0
- *	3.91 mg for v_low_g_thres_u8 = 0
- *	The threshold range is from 3.91mg to 2.000mg
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_g_thres(
-u8 v_low_g_thres_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR LOW_G HYSTERESIS CONFIGURATION     */
-/***************************************************************/
- /*!
- *	@brief This API reads Low-g interrupt hysteresis
- *	from the register 0x5C bit 0 to 1
- *
- *  @param v_low_hyst_u8 :The value of low_g hysteresis
- *
- *	@note Low_g hysteresis calculated by v_low_hyst_u8*125 mg
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_g_hyst(
-u8 *v_low_hyst_u8);
- /*!
- *	@brief This API writes Low-g interrupt hysteresis
- *	from the register 0x5C bit 0 to 1
- *
- *  @param v_low_hyst_u8 :The value of low_g hysteresis
- *
- *	@note Low_g hysteresis calculated by v_low_hyst_u8*125 mg
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_g_hyst(
-u8 v_low_hyst_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR LOW_G MODE CONFIGURATION     */
-/***************************************************************/
-/*!
- *	@brief This API reads Low-g interrupt mode
- *	from the register 0x5C bit 2
- *
- *  @param v_low_g_mode_u8 : The value of low_g mode
- *	Value    |  Description
- * ----------|-----------------
- *	   0     | single-axis
- *     1     | axis-summing
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_g_mode(
-u8 *v_low_g_mode_u8);
-/*!
- *	@brief This API writes Low-g interrupt mode
- *	from the register 0x5C bit 2
- *
- *  @param v_low_g_mode_u8 : The value of low_g mode
- *	Value    |  Description
- * ----------|-----------------
- *	   0     | single-axis
- *     1     | axis-summing
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_g_mode(
-u8 v_low_g_mode_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR HIGH_G HYST CONFIGURATION     */
-/***************************************************************/
-/*!
- *	@brief This API reads High-g interrupt hysteresis
- *	from the register 0x5C bit 6 and 7
- *
- *  @param v_high_g_hyst_u8 : The value of high hysteresis
- *
- *	@note High_g hysteresis changes according to Accel g range
- *	accel g range can be set by the function "bmi160_set_accel_range"
- *   accel_range    | high_g hysteresis
- *  ----------------|---------------------
- *      2g          |  high_hy*125 mg
- *      4g          |  high_hy*250 mg
- *      8g          |  high_hy*500 mg
- *      16g         |  high_hy*1000 mg
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_high_g_hyst(
-u8 *v_high_g_hyst_u8);
-/*!
- *	@brief This API writes High-g interrupt hysteresis
- *	from the register 0x5C bit 6 and 7
- *
- *  @param v_high_g_hyst_u8 : The value of high hysteresis
- *
- *	@note High_g hysteresis changes according to Accel g range
- *	accel g range can be set by the function "bmi160_set_accel_range"
- *   accel_range    | high_g hysteresis
- *  ----------------|---------------------
- *      2g          |  high_hy*125 mg
- *      4g          |  high_hy*250 mg
- *      8g          |  high_hy*500 mg
- *      16g         |  high_hy*1000 mg
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_high_g_hyst(
-u8 v_high_g_hyst_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR HIGH_G DURATION CONFIGURATION     */
-/***************************************************************/
-/*!
- *	@brief This API is used to read Delay
- *	time definition for the high-g interrupt from the register
- *	0x5D bit 0 to 7
- *
- *
- *
- *  @param  v_high_g_durn_u8 :  The value of high duration
- *
- *	@note High_g interrupt delay triggered according to
- *	v_high_g_durn_u8 * 2.5ms in a range from 2.5ms to 640ms
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_high_g_durn(
-u8 *v_high_g_durn_u8);
-/*!
- *	@brief This API is used to write Delay
- *	time definition for the high-g interrupt from the register
- *	0x5D bit 0 to 7
- *
- *
- *
- *  @param  v_high_g_durn_u8 :  The value of high duration
- *
- *	@note High_g interrupt delay triggered according to
- *	v_high_g_durn_u8 * 2.5ms in a range from 2.5ms to 640ms
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_high_g_durn(
-u8 v_high_g_durn_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR HIGH_G THRESHOLD CONFIGURATION     */
-/***************************************************************/
-/*!
- *	@brief This API is used to read Threshold
- *	definition for the high-g interrupt from the register 0x5E 0 to 7
- *
- *
- *
- *
- *  @param  v_high_g_thres_u8 : Pointer holding the value of Threshold
- *	@note High_g threshold changes according to Accel g range
- *	accel g range can be set by the function "bmi160_set_accel_range"
- *   accel_range    | high_g threshold
- *  ----------------|---------------------
- *      2g          |  v_high_g_thres_u8*7.81 mg
- *      4g          |  v_high_g_thres_u8*15.63 mg
- *      8g          |  v_high_g_thres_u8*31.25 mg
- *      16g         |  v_high_g_thres_u8*62.5 mg
- *	@note when v_high_g_thres_u8 = 0
- *   accel_range    | high_g threshold
- *  ----------------|---------------------
- *      2g          |  3.91 mg
- *      4g          |  7.81 mg
- *      8g          |  15.63 mg
- *      16g         |  31.25 mg
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_high_g_thres(
-u8 *v_high_g_thres_u8);
-/*!
- *	@brief This API is used to write Threshold
- *	definition for the high-g interrupt from the register 0x5E 0 to 7
- *
- *
- *
- *
- *  @param  v_high_g_thres_u8 : Pointer holding the value of Threshold
- *	@note High_g threshold changes according to Accel g range
- *	accel g range can be set by the function "bmi160_set_accel_range"
- *   accel_range    | high_g threshold
- *  ----------------|---------------------
- *      2g          |  v_high_g_thres_u8*7.81 mg
- *      4g          |  v_high_g_thres_u8*15.63 mg
- *      8g          |  v_high_g_thres_u8*31.25 mg
- *      16g         |  v_high_g_thres_u8*62.5 mg
- *	@note when v_high_g_thres_u8 = 0
- *   accel_range    | high_g threshold
- *  ----------------|---------------------
- *      2g          |  3.91 mg
- *      4g          |  7.81 mg
- *      8g          |  15.63 mg
- *      16g         |  31.25 mg
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_high_g_thres(
-u8 v_high_g_thres_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR ANY MOTION DURATION CONFIGURATION     */
-/***************************************************************/
-/*!
- *	@brief This API reads any motion duration
- *	from the register 0x5F bit 0 and 1
- *
- *  @param v_any_motion_durn_u8 : The value of any motion duration
- *
- *	@note Any motion duration can be calculated by "v_any_motion_durn_u8 + 1"
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_any_motion_durn(
-u8 *v_any_motion_durn_u8);
-/*!
- *	@brief This API writes any motion duration
- *	from the register 0x5F bit 0 and 1
- *
- *  @param v_any_motion_durn_u8 : The value of any motion duration
- *
- *	@note Any motion duration can be calculated by "v_any_motion_durn_u8 + 1"
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_any_motion_durn(
-u8 nomotion);
-/***************************************************************/
-/**\name	FUNCTION FOR SLOW NO MOTION DURATION CONFIGURATION  */
-/***************************************************************/
- /*!
- *	@brief This API reads Slow/no-motion
- *	interrupt trigger delay duration from the register 0x5F bit 2 to 7
- *
- *  @param v_slow_no_motion_u8 :The value of slow no motion duration
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *	@note
- *	@note v_slow_no_motion_u8(5:4)=0b00 ->
- *	[v_slow_no_motion_u8(3:0) + 1] * 1.28s (1.28s-20.48s)
- *	@note v_slow_no_motion_u8(5:4)=1 ->
- *	[v_slow_no_motion_u8(3:0)+5] * 5.12s (25.6s-102.4s)
- *	@note v_slow_no_motion_u8(5)='1' ->
- *	[(v_slow_no_motion_u8:0)+11] * 10.24s (112.64s-430.08s);
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_slow_no_motion_durn(
-u8 *v_slow_no_motion_u8);
- /*!
- *	@brief This API writes Slow/no-motion
- *	interrupt trigger delay duration from the register 0x5F bit 2 to 7
- *
- *  @param v_slow_no_motion_u8 :The value of slow no motion duration
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *	@note
- *	@note v_slow_no_motion_u8(5:4)=0b00 ->
- *	[v_slow_no_motion_u8(3:0) + 1] * 1.28s (1.28s-20.48s)
- *	@note v_slow_no_motion_u8(5:4)=1 ->
- *	[v_slow_no_motion_u8(3:0)+5] * 5.12s (25.6s-102.4s)
- *	@note v_slow_no_motion_u8(5)='1' ->
- *	[(v_slow_no_motion_u8:0)+11] * 10.24s (112.64s-430.08s);
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_slow_no_motion_durn(
-u8 v_slow_no_motion_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR ANY MOTION THRESHOLD CONFIGURATION  */
-/***************************************************************/
-/*!
- *	@brief This API is used to read threshold
- *	definition for the any-motion interrupt
- *	from the register 0x60 bit 0 to 7
- *
- *
- *  @param  v_any_motion_thres_u8 : The value of any motion threshold
- *
- *	@note any motion threshold changes according to Accel g range
- *	accel g range can be set by the function "bmi160_set_accel_range"
- *   accel_range    | any motion threshold
- *  ----------------|---------------------
- *      2g          |  v_any_motion_thres_u8*3.91 mg
- *      4g          |  v_any_motion_thres_u8*7.81 mg
- *      8g          |  v_any_motion_thres_u8*15.63 mg
- *      16g         |  v_any_motion_thres_u8*31.25 mg
- *	@note when v_any_motion_thres_u8 = 0
- *   accel_range    | any motion threshold
- *  ----------------|---------------------
- *      2g          |  1.95 mg
- *      4g          |  3.91 mg
- *      8g          |  7.81 mg
- *      16g         |  15.63 mg
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_any_motion_thres(
-u8 *v_any_motion_thres_u8);
-/*!
- *	@brief This API is used to write threshold
- *	definition for  any-motion interrupt
- *	from the register 0x60 bit 0 to 7
- *
- *
- *  @param  v_any_motion_thres_u8 : The value of any motion threshold
- *
- *	@note any motion threshold changes according to Accel g range
- *	accel g range can be set by the function "bmi160_set_accel_range"
- *   accel_range    | any motion threshold
- *  ----------------|---------------------
- *      2g          |  v_any_motion_thres_u8*3.91 mg
- *      4g          |  v_any_motion_thres_u8*7.81 mg
- *      8g          |  v_any_motion_thres_u8*15.63 mg
- *      16g         |  v_any_motion_thres_u8*31.25 mg
- *	@note when v_any_motion_thres_u8 = 0
- *   accel_range    | any motion threshold
- *  ----------------|---------------------
- *      2g          |  1.95 mg
- *      4g          |  3.91 mg
- *      8g          |  7.81 mg
- *      16g         |  15.63 mg
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_any_motion_thres(
-u8 v_any_motion_thres_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR SLOW/NO MOTION THRESHOLD CONFIGURATION  */
-/***************************************************************/
- /*!
- *	@brief This API is used to read threshold
- *	for the slow/no-motion interrupt
- *	from the register 0x61 bit 0 to 7
- *
- *
- *
- *
- *  @param v_slow_no_motion_thres_u8 : The value of slow no motion threshold
- *	@note slow no motion threshold changes according to Accel g range
- *	accel g range can be set by the function "bmi160_set_accel_range"
- *   accel_range    | slow no motion threshold
- *  ----------------|---------------------
- *      2g          |  v_slow_no_motion_thres_u8*3.91 mg
- *      4g          |  v_slow_no_motion_thres_u8*7.81 mg
- *      8g          |  v_slow_no_motion_thres_u8*15.63 mg
- *      16g         |  v_slow_no_motion_thres_u8*31.25 mg
- *	@note when v_slow_no_motion_thres_u8 = 0
- *   accel_range    | slow no motion threshold
- *  ----------------|---------------------
- *      2g          |  1.95 mg
- *      4g          |  3.91 mg
- *      8g          |  7.81 mg
- *      16g         |  15.63 mg
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_slow_no_motion_thres(
-u8 *v_slow_no_motion_thres_u8);
- /*!
- *	@brief This API is used to write threshold
- *	for the slow/no-motion interrupt
- *	in the register 0x61 bit 0 to 7
- *
- *
- *
- *
- *  @param v_slow_no_motion_thres_u8 : The value of slow no motion threshold
- *	@note slow no motion threshold changes according to Accel g range
- *	accel g range can be set by the function "bmi160_set_accel_range"
- *   accel_range    | slow no motion threshold
- *  ----------------|---------------------
- *      2g          |  v_slow_no_motion_thres_u8*3.91 mg
- *      4g          |  v_slow_no_motion_thres_u8*7.81 mg
- *      8g          |  v_slow_no_motion_thres_u8*15.63 mg
- *      16g         |  v_slow_no_motion_thres_u8*31.25 mg
- *	@note when v_slow_no_motion_thres_u8 = 0
- *   accel_range    | slow no motion threshold
- *  ----------------|---------------------
- *      2g          |  1.95 mg
- *      4g          |  3.91 mg
- *      8g          |  7.81 mg
- *      16g         |  15.63 mg
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_slow_no_motion_thres(
-u8 v_slow_no_motion_thres_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR SLOW/NO MOTION SELECT CONFIGURATION  */
-/***************************************************************/
- /*!
- *	@brief This API is used to read
- *	the slow/no-motion selection from the register 0x62 bit 0
- *
- *
- *
- *
- *  @param  v_intr_slow_no_motion_select_u8 :
- *	The value of slow/no-motion select
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     |  SLOW_MOTION
- *  0x01     |  NO_MOTION
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_slow_no_motion_select(
-u8 *v_intr_slow_no_motion_select_u8);
- /*!
- *	@brief This API is used to write
- *	the slow/no-motion selection from the register 0x62 bit 0
- *
- *
- *
- *
- *  @param  v_intr_slow_no_motion_select_u8 :
- *	The value of slow/no-motion select
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     |  SLOW_MOTION
- *  0x01     |  NO_MOTION
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_slow_no_motion_select(
-u8 v_intr_slow_no_motion_select_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR SIGNIFICANT MOTION SELECT CONFIGURATION*/
-/***************************************************************/
- /*!
- *	@brief This API is used to select
- *	the significant or any motion interrupt from the register 0x62 bit 1
- *
- *
- *
- *
- *  @param  v_intr_significant_motion_select_u8 :
- *	the value of significant or any motion interrupt selection
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     |  ANY_MOTION
- *  0x01     |  SIGNIFICANT_MOTION
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_significant_motion_select(
-u8 *int_sig_mot_sel);
- /*!
- *	@brief This API is used to write, select
- *	the significant or any motion interrupt from the register 0x62 bit 1
- *
- *
- *
- *
- *  @param  v_intr_significant_motion_select_u8 :
- *	the value of significant or any motion interrupt selection
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     |  ANY_MOTION
- *  0x01     |  SIGNIFICANT_MOTION
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_significant_motion_select(
-u8 int_sig_mot_sel);
-/*!
- *	@brief This API is used to unmap the  signification motion
- *	interrupt
- *
- *
- *  @param v_significant_u8   : The value of interrupt selection
- *
- *      BMI160_MAP_INTR1	0
- *      BMI160_MAP_INTR2	1
- *
- *  \return results of communication routine
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_unmap_significant_motion_intr(
-u8 v_significant_u8);
-
- /*!
- *	@brief This API is used to read
- *	the significant skip time from the register 0x62 bit  2 and 3
- *
- *
- *
- *
- *  @param  v_int_sig_mot_skip_u8 : the value of significant skip time
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     |  skip time 1.5 seconds
- *  0x01     |  skip time 3 seconds
- *  0x02     |  skip time 6 seconds
- *  0x03     |  skip time 12 seconds
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_significant_motion_skip(
-u8 *v_int_sig_mot_skip_u8);
- /*!
- *	@brief This API is used to write
- *	the significant skip time in the register 0x62 bit  2 and 3
- *
- *
- *
- *
- *  @param  v_int_sig_mot_skip_u8 : the value of significant skip time
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     |  skip time 1.5 seconds
- *  0x01     |  skip time 3 seconds
- *  0x02     |  skip time 6 seconds
- *  0x03     |  skip time 12 seconds
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_significant_motion_skip(
-u8 v_int_sig_mot_skip_u8);
- /*!
- *	@brief This API is used to read
- *	the significant proof time from the register 0x62 bit  4 and 5
- *
- *
- *
- *
- *  @param  v_significant_motion_proof_u8 :
- *	the value of significant proof time
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     |  proof time 0.25 seconds
- *  0x01     |  proof time 0.5 seconds
- *  0x02     |  proof time 1 seconds
- *  0x03     |  proof time 2 seconds
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_significant_motion_proof(
-u8 *int_sig_mot_proof);
- /*!
- *	@brief This API is used to write
- *	the significant proof time in the register 0x62 bit  4 and 5
- *
- *
- *
- *
- *  @param  v_significant_motion_proof_u8 :
- *	the value of significant proof time
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     |  proof time 0.25 seconds
- *  0x01     |  proof time 0.5 seconds
- *  0x02     |  proof time 1 seconds
- *  0x03     |  proof time 2 seconds
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_significant_motion_proof(
-u8 int_sig_mot_proof);
-/***************************************************************/
-/**\name	FUNCTION FOR TAP DURATION CONFIGURATION*/
-/***************************************************************/
-/*!
- *	@brief This API is used to get the tap duration
- *	from the register 0x63 bit 0 to 2
- *
- *
- *
- *  @param v_tap_durn_u8 : The value of tap duration
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | BMI160_TAP_DURN_50MS
- *  0x01     | BMI160_TAP_DURN_100MS
- *  0x02     | BMI160_TAP_DURN_150MS
- *  0x03     | BMI160_TAP_DURN_200MS
- *  0x04     | BMI160_TAP_DURN_250MS
- *  0x05     | BMI160_TAP_DURN_375MS
- *  0x06     | BMI160_TAP_DURN_500MS
- *  0x07     | BMI160_TAP_DURN_700MS
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_durn(
-u8 *v_tap_durn_u8);
-/*!
- *	@brief This API is used to write the tap duration
- *	in the register 0x63 bit 0 to 2
- *
- *
- *
- *  @param v_tap_durn_u8 : The value of tap duration
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | BMI160_TAP_DURN_50MS
- *  0x01     | BMI160_TAP_DURN_100MS
- *  0x02     | BMI160_TAP_DURN_150MS
- *  0x03     | BMI160_TAP_DURN_200MS
- *  0x04     | BMI160_TAP_DURN_250MS
- *  0x05     | BMI160_TAP_DURN_375MS
- *  0x06     | BMI160_TAP_DURN_500MS
- *  0x07     | BMI160_TAP_DURN_700MS
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_durn(
-u8 v_tap_durn_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR TAP SHOCK CONFIGURATION*/
-/***************************************************************/
- /*!
- *	@brief This API reads the
- *	tap shock duration from the register 0x63 bit 2
- *
- *  @param v_tap_shock_u8 :The value of tap shock
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | BMI160_TAP_SHOCK_50MS
- *  0x01     | BMI160_TAP_SHOCK_75MS
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_shock(
-u8 *v_tap_shock_u8);
- /*!
- *	@brief This API writes the
- *	tap shock duration from the register 0x63 bit 2
- *
- *  @param v_tap_shock_u8 :The value of tap shock
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | BMI160_TAP_SHOCK_50MS
- *  0x01     | BMI160_TAP_SHOCK_75MS
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_shock(
-u8 v_tap_shock_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR TAP QUIET CONFIGURATION*/
-/***************************************************************/
-/*!
- *	@brief This API reads
- *	tap quiet duration from the register 0x63 bit 7
- *
- *
- *  @param v_tap_quiet_u8 : The value of tap quiet
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | BMI160_TAP_QUIET_30MS
- *  0x01     | BMI160_TAP_QUIET_20MS
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_quiet(
-u8 *v_tap_quiet_u8);
-/*!
- *	@brief This API writes
- *	tap quiet duration in the register 0x63 bit 7
- *
- *
- *  @param v_tap_quiet_u8 : The value of tap quiet
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | BMI160_TAP_QUIET_30MS
- *  0x01     | BMI160_TAP_QUIET_20MS
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_quiet(
-u8 v_tap_quiet_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR TAP THRESHOLD CONFIGURATION*/
-/***************************************************************/
- /*!
- *	@brief This API reads the threshold of the
- *	single/double tap interrupt from the register 0x64 bit 0 to 4
- *
- *
- *	@param v_tap_thres_u8 : The value of single/double tap threshold
- *
- *	@note single/double tap threshold changes according to Accel g range
- *	accel g range can be set by the function "bmi160_set_accel_range"
- *   accel_range    | single/double tap threshold
- *  ----------------|---------------------
- *      2g          |  ((v_tap_thres_u8 + 1) * 62.5)mg
- *      4g          |  ((v_tap_thres_u8 + 1) * 125)mg
- *      8g          |  ((v_tap_thres_u8 + 1) * 250)mg
- *      16g         |  ((v_tap_thres_u8 + 1) * 500)mg
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_thres(
-u8 *v_tap_thres_u8);
- /*!
- *	@brief This API writes the threshold of the
- *	single/double tap interrupt in the register 0x64 bit 0 to 4
- *
- *
- *	@param v_tap_thres_u8 : The value of single/double tap threshold
- *
- *	@note single/double tap threshold changes according to Accel g range
- *	accel g range can be set by the function "bmi160_set_accel_range"
- *   accel_range    | single/double tap threshold
- *  ----------------|---------------------
- *      2g          |  ((v_tap_thres_u8 + 1) * 62.5)mg
- *      4g          |  ((v_tap_thres_u8 + 1) * 125)mg
- *      8g          |  ((v_tap_thres_u8 + 1) * 250)mg
- *      16g         |  ((v_tap_thres_u8 + 1) * 500)mg
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_thres(
-u8 v_tap_thres_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR ORIENT MODE CONFIGURATION*/
-/***************************************************************/
- /*!
- *	@brief This API reads the threshold for orientation interrupt
- *	from the register 0x65 bit 0 and 1
- *
- *  @param v_orient_mode_u8 : The value of threshold for orientation
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | symmetrical
- *  0x01     | high-asymmetrical
- *  0x02     | low-asymmetrical
- *  0x03     | symmetrical
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_mode(
-u8 *v_orient_mode_u8);
- /*!
- *	@brief This API writes the threshold for orientation interrupt
- *	from the register 0x65 bit 0 and 1
- *
- *  @param v_orient_mode_u8 : The value of threshold for orientation
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | symmetrical
- *  0x01     | high-asymmetrical
- *  0x02     | low-asymmetrical
- *  0x03     | symmetrical
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_mode(
-u8 v_orient_mode_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR ORIENT BLOCKING CONFIGURATION*/
-/***************************************************************/
-/*!
- *	@brief This API reads the orientation blocking mode
- *	that is used for the generation of the orientation interrupt.
- *	from the register 0x65 bit 2 and 3
- *
- *  @param v_orient_blocking_u8 : The value of orient blocking mode
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | No blocking
- *  0x01     | Theta blocking or acceleration in any axis > 1.5g
- *  0x02     | Theta blocking or acceleration slope in any axis >
- *   -       | 0.2g or acceleration in any axis > 1.5g
- *  0x03     | Theta blocking or acceleration slope in any axis >
- *   -       | 0.4g or acceleration in any axis >
- *   -       | 1.5g and value of orient is not stable
- *   -       | for at least 100 ms
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_blocking(
-u8 *v_orient_blocking_u8);
-/*!
- *	@brief This API writes the orientation blocking mode
- *	that is used for the generation of the orientation interrupt.
- *	in the register 0x65 bit 2 and 3
- *
- *  @param v_orient_blocking_u8 : The value of orient blocking mode
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | No blocking
- *  0x01     | Theta blocking or acceleration in any axis > 1.5g
- *  0x02     | Theta blocking or acceleration slope in any axis >
- *   -       | 0.2g or acceleration in any axis > 1.5g
- *  0x03     | Theta blocking or acceleration slope in any axis >
- *   -       | 0.4g or acceleration in any axis >
- *   -       | 1.5g and value of orient is not stable
- *   -       | for at least 100 ms
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_blocking(
-u8 v_orient_blocking_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR ORIENT HYSTERESIS CONFIGURATION*/
-/***************************************************************/
-/*!
- *	@brief This API reads the orientation interrupt
- *	hysteresis, from the register 0x64 bit 4 to 7
- *
- *
- *
- *  @param v_orient_hyst_u8 : The value of orient hysteresis
- *
- *	@note 1 LSB corresponds to 62.5 mg,
- *	irrespective of the selected Accel range
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_hyst(
-u8 *v_orient_hyst_u8);
-/*!
- *	@brief This API writes the orientation interrupt
- *	hysteresis, in the register 0x64 bit 4 to 7
- *
- *
- *
- *  @param v_orient_hyst_u8 : The value of orient hysteresis
- *
- *	@note 1 LSB corresponds to 62.5 mg,
- *	irrespective of the selected Accel range
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_hyst(
-u8 v_orient_hyst_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR ORIENT THETA CONFIGURATION*/
-/***************************************************************/
- /*!
- *	@brief This API reads the orientation
- *	blocking angle (0 to 44.8) from the register 0x66 bit 0 to 5
- *
- *  @param v_orient_theta_u8 : The value of Orient blocking angle
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_theta(
-u8 *v_orient_theta_u8);
- /*!
- *	@brief This API writes orientation
- *	blocking angle (0 to 44.8) in the register 0x66 bit 0 to 5
- *
- *  @param v_orient_theta_u8 : The value of Orient blocking angle
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_theta(
-u8 v_orient_theta_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR ORIENT OUTPUT ENABLE CONFIGURATION*/
-/***************************************************************/
-/*!
- *	@brief This API reads the orientation change
- *	of up/down bit from the register 0x66 bit 6
- *
- *  @param v_orient_ud_u8 : The value of orient change of up/down
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | Is ignored
- *  0x01     | Generates orientation interrupt
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_ud_enable(
-u8 *v_orient_ud_u8);
-/*!
- *	@brief This API writes orientation change
- *	of up/down bit in the register 0x66 bit 6
- *
- *  @param v_orient_ud_u8 : The value of orient change of up/down
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | Is ignored
- *  0x01     | Generates orientation interrupt
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_ud_enable(
-u8 v_orient_ud_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR ORIENT AXIS ENABLE CONFIGURATION*/
-/***************************************************************/
- /*!
- *	@brief This API reads orientation axes changes
- *	from the register 0x66 bit 7
- *
- *  @param v_orient_axes_u8 : The value of orient axes assignment
- *	value    |       Behaviour    | Name
- * ----------|--------------------|------
- *  0x00     | x = x, y = y, z = z|orient_ax_noex
- *  0x01     | x = y, y = z, z = x|orient_ax_ex
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_axes_enable(
-u8 *v_orient_axes_u8);
- /*!
- *	@brief This API writes orientation axes changes
- *	in the register 0x66 bit 7
- *
- *  @param v_orient_axes_u8 : The value of orient axes assignment
- *	value    |       Behaviour    | Name
- * ----------|--------------------|------
- *  0x00     | x = x, y = y, z = z|orient_ax_noex
- *  0x01     | x = y, y = z, z = x|orient_ax_ex
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_axes_enable(
-u8 v_orient_axes_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR FLAT THETA CONFIGURATION*/
-/***************************************************************/
- /*!
- *	@brief This API reads Flat angle (0 to 44.8) for flat interrupt
- *	from the register 0x67 bit 0 to 5
- *
- *  @param v_flat_theta_u8 : The value of flat angle
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_flat_theta(
-u8 *v_flat_theta_u8);
- /*!
- *	@brief This API writes Flat angle (0 to 44.8) for flat interrupt
- *	in the register 0x67 bit 0 to 5
- *
- *  @param v_flat_theta_u8 : The value of flat angle
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_flat_theta(
-u8 v_flat_theta_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR FLAT HOLD CONFIGURATION*/
-/***************************************************************/
-/*!
- *	@brief This API reads Flat interrupt hold time;
- *	from the register 0x68 bit 4 and 5
- *
- *  @param v_flat_hold_u8 : The value of flat hold time
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | 0ms
- *  0x01     | 512ms
- *  0x01     | 1024ms
- *  0x01     | 2048ms
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_flat_hold(
-u8 *v_flat_hold_u8);
-/*!
- *	@brief This API writes flat interrupt hold time in
- *	the register 0x68 bit 4 and 5
- *
- *  @param v_flat_hold_u8 : The value of flat hold time
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | 0ms
- *  0x01     | 512ms
- *  0x01     | 1024ms
- *  0x01     | 2048ms
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_flat_hold(
-u8 v_flat_hold_u8);
-/***************************************************************/
-/**\name	FUNCTION FOR FLAT HYSTERESIS CONFIGURATION*/
-/***************************************************************/
-/*!
- *	@brief This API reads flat interrupt hysteresis
- *	from the register 0x68 bit 0 to 3
- *
- *  @param v_flat_hyst_u8 : The value of flat hysteresis
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_flat_hyst(
-u8 *v_flat_hyst_u8);
-/*!
- *	@brief This API writes flat interrupt hysteresis
- *	in the register 0x68 bit 0 to 3
- *
- *  @param v_flat_hyst_u8 : The value of flat hysteresis
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_flat_hyst(
-u8 v_flat_hyst_u8);
-/***************************************************************/
-/**\name	FUNCTION FAST OFFSET COMPENSATION FOR ACCEL */
-/***************************************************************/
- /*!
- *	@brief This API reads Accel offset compensation
- *	target value for z-axis from the register 0x69 bit 0 and 1
- *
- *  @param v_foc_accel_z_u8 : the value of Accel offset compensation z axis
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | disable
- *  0x01     | +1g
- *  0x01     | -1g
- *  0x01     | 0g
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_accel_z(
-u8 *v_foc_accel_z_u8);
- /*!
- *	@brief This API writes Accel offset compensation
- *	target value for z-axis in the register 0x69 bit 0 and 1
- *
- *  @param v_foc_accel_z_u8 : the value of Accel offset compensation z axis
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | disable
- *  0x01     | +1g
- *  0x01     | -1g
- *  0x01     | 0g
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_foc_accel_z(
-u8 v_foc_accel_z_u8);
-/*!
- *	@brief This API reads Accel offset compensation
- *	target value for y-axis
- *	from the register 0x69 bit 2 and 3
- *
- *  @param v_foc_accel_y_u8 : the value of Accel offset compensation y axis
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | disable
- *  0x01     | +1g
- *  0x01     | -1g
- *  0x01     | 0g
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_accel_y(
-u8 *v_foc_accel_y_u8);
-/*!
- *	@brief This API writes Accel offset compensation
- *	target value for y-axis in the register 0x69 bit 2 and 3
- *
- *  @param v_foc_accel_y_u8 : the value of Accel offset compensation y axis
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | disable
- *  0x01     | +1g
- *  0x02     | -1g
- *  0x03     | 0g
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_foc_accel_y(
-u8 v_foc_accel_y_u8);
-/*!
- *	@brief This API reads Accel offset compensation
- *	target value for x-axis from the register 0x69 bit 4 and 5
- *
- *  @param v_foc_accel_x_u8 : the value of Accel offset compensation x axis
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | disable
- *  0x01     | +1g
- *  0x02     | -1g
- *  0x03     | 0g
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_accel_x(
-u8 *v_foc_accel_x_u8);
-/*!
- *	@brief This API writes Accel offset compensation
- *	target value for x-axis in the register 0x69 bit 4 and 5
- *
- *  @param v_foc_accel_x_u8 : the value of Accel offset compensation x axis
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | disable
- *  0x01     | +1g
- *  0x01     | -1g
- *  0x01     | 0g
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_foc_accel_x(
-u8 v_foc_accel_x_u8);
-/***************************************************************/
-/**\name	FUNCTION FAST OFFSET COMPENSATION FOR GYRO */
-/***************************************************************/
-/*!
- *	@brief This API writes the Gyro fast offset enable
- *	from the register 0x69 bit 6
- *
- *  @param v_foc_gyro_u8 : The value of Gyro fast offset enable
- *  value    |  Description
- * ----------|-------------
- *    0      | fast offset compensation disabled
- *    1      |  fast offset compensation enabled
- *
- *	@param v_gyro_off_x_s16 : The value of Gyro fast offset x axis data
- *	@param v_gyro_off_y_s16 : The value of Gyro fast offset y axis data
- *	@param v_gyro_off_z_s16 : The value of Gyro fast offset z axis data
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_foc_gyro_enable(
-u8 v_foc_gyro_u8, s16 *v_gyro_off_x_s16,
-s16 *v_gyro_off_y_s16, s16 *v_gyro_off_z_s16);
-
-/***************************************************/
-/**\name	FUNCTION FOR SPI MODE*/
-/***************************************************/
- /*!
- * @brief This API reads  SPI
- * Interface Mode for primary and OIS interface
- * from the register 0x6B bit 0
- *
- *  @param v_spi3_u8 : The value of SPI mode selection
- *  Value  |  Description
- * --------|-------------
- *   0     |  SPI 4-wire mode
- *   1     |  SPI 3-wire mode
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_spi3(
-u8 *v_spi3_u8);
-/*!
- * @brief This API configures SPI
- * Interface Mode for primary and OIS interface
- * in the register 0x6B bit 0
- *
- *  @param v_spi3_u8 : The value of SPI mode selection
- *  Value  |  Description
- * --------|-------------
- *   0     |  SPI 4-wire mode
- *   1     |  SPI 3-wire mode
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_spi3(
-u8 v_spi3_u8);
-/***************************************************/
-/**\name	FUNCTION FOR FOC GYRO */
-/***************************************************/
-/*!
- *	@brief This API reads the Gyro fast offset enable
- *	from the register 0x69 bit 6
- *
- *  @param v_foc_gyro_u8 : The value of Gyro fast offset enable
- *  value    |  Description
- * ----------|-------------
- *    0      | fast offset compensation disabled
- *    1      |  fast offset compensation enabled
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_gyro_enable(
-u8 *v_foc_gyro_u8);
-/***************************************************/
-/**\name	FUNCTION FOR I2C WATCHDOG TIMBER */
-/***************************************************/
-/*!
- *	@brief This API reads I2C Watchdog timer
- *	from the register 0x70 bit 1
- *
- *  @param v_i2c_wdt_u8 : The value of I2C watch dog timer
- *  Value  |  Description
- * --------|-------------
- *   0     |  I2C watchdog v_timeout_u8 after 1 ms
- *   1     |  I2C watchdog v_timeout_u8 after 50 ms
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_i2c_wdt_select(
-u8 *v_i2c_wdt_u8);
-/*!
- *	@brief This API writes the I2C Watchdog timer
- *	in the register 0x70 bit 1
- *
- *  @param v_i2c_wdt_u8 : The value of I2C watch dog timer
- *  Value  |  Description
- * --------|-------------
- *   0     |  I2C watchdog v_timeout_u8 after 1 ms
- *   1     |  I2C watchdog v_timeout_u8 after 50 ms
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE
-bmi160_set_i2c_wdt_select(u8 v_i2c_wdt_u8);
-/*!
- *	@brief This API reads the status of I2C watchdog enable
- *	from the register 0x70 bit 2
- *
- *  @param v_i2c_wdt_u8 : The value of I2C watchdog enable
- *  Value  |  Description
- * --------|-------------
- *   0     |  DISABLE
- *   1     |  ENABLE
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_i2c_wdt_enable(
-u8 *v_i2c_wdt_u8);
-/*!
- *	@brief This API enables the I2C watchdog
- *	 in the register 0x70 bit 2
- *
- *  @param v_i2c_wdt_u8 : The value of I2C watchdog enable
- *  Value  |  Description
- * --------|-------------
- *   0     |  DISABLE
- *   1     |  ENABLE
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_i2c_wdt_enable(
-u8 v_i2c_wdt_u8);
-/***************************************************/
-/**\name	FUNCTION FOR IF MODE*/
-/***************************************************/
-/*!
- * @brief This API reads the I2C interface configuration(if) mode
- * from the register 0x6B bit 4 and 5
- *
- *  @param  v_if_mode_u8 : The value of interface configuration mode
- *  Value  |  Description
- * --------|-------------
- *   0x00  |  Primary interface:autoconfig / secondary interface:off
- *   0x01  |  Primary interface:I2C / secondary interface:OIS
- *   0x02  |  Primary interface:autoconfig/secondary interface:Magnetometer
- *   0x03  |   Reserved
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_if_mode(
-u8 *v_if_mode_u8);
-/*!
- * @brief This API writes the I2C interface configuration(if) mode
- * in the register 0x6B bit 4 and 5
- *
- *  @param  v_if_mode_u8 : The value of interface configuration mode
- *  Value  |  Description
- * --------|-------------
- *   0x00  |  Primary interface:autoconfig / secondary interface:off
- *   0x01  |  Primary interface:I2C / secondary interface:OIS
- *   0x02  |  Primary interface:autoconfig/secondary interface:Magnetometer
- *   0x03  |   Reserved
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_if_mode(
-u8 v_if_mode_u8);
-/***************************************************/
-/**\name	FUNCTION FOR GYRO SLEEP TRIGGER INTERRUPT CONFIGURATION*/
-/***************************************************/
-/*!
- *	@brief This API reads the Gyro sleep trigger
- *	from the register 0x6C bit 0 to 2
- *
- *  @param v_gyro_sleep_trigger_u8 : The value of Gyro sleep trigger
- *  Value  |  Description
- * --------|-------------
- *   0x00  | nomotion: no / Not INT1 pin: no / INT2 pin: no
- *   0x01  | nomotion: no / Not INT1 pin: no / INT2 pin: yes
- *   0x02  | nomotion: no / Not INT1 pin: yes / INT2 pin: no
- *   0x03  | nomotion: no / Not INT1 pin: yes / INT2 pin: yes
- *   0x04  | nomotion: yes / Not INT1 pin: no / INT2 pin: no
- *   0x05  | anymotion: yes / Not INT1 pin: no / INT2 pin: yes
- *   0x06  | anymotion: yes / Not INT1 pin: yes / INT2 pin: no
- *   0x07  | anymotion: yes / Not INT1 pin: yes / INT2 pin: yes
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_sleep_trigger(
-u8 *v_gyro_sleep_trigger_u8);
-/*!
- *	@brief This API writes the Gyro sleep trigger
- *	in the register 0x6C bit 0 to 2
- *
- *  @param v_gyro_sleep_trigger_u8 : The value of Gyro sleep trigger
- *  Value  |  Description
- * --------|-------------
- *   0x00  | nomotion: no / Not INT1 pin: no / INT2 pin: no
- *   0x01  | nomotion: no / Not INT1 pin: no / INT2 pin: yes
- *   0x02  | nomotion: no / Not INT1 pin: yes / INT2 pin: no
- *   0x03  | nomotion: no / Not INT1 pin: yes / INT2 pin: yes
- *   0x04  | nomotion: yes / Not INT1 pin: no / INT2 pin: no
- *   0x05  | anymotion: yes / Not INT1 pin: no / INT2 pin: yes
- *   0x06  | anymotion: yes / Not INT1 pin: yes / INT2 pin: no
- *   0x07  | anymotion: yes / Not INT1 pin: yes / INT2 pin: yes
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_sleep_trigger(
-u8 v_gyro_sleep_trigger_u8);
-/*!
- *	@brief This API reads Gyro wakeup trigger
- *	from the register 0x6C bit 3 and 4
- *
- *  @param v_gyro_wakeup_trigger_u8 : The value of Gyro wakeup trigger
- *  Value  |  Description
- * --------|-------------
- *   0x00  | anymotion: no / INT1 pin: no
- *   0x01  | anymotion: no / INT1 pin: yes
- *   0x02  | anymotion: yes / INT1 pin: no
- *   0x03  | anymotion: yes / INT1 pin: yes
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_wakeup_trigger(
-u8 *v_gyro_wakeup_trigger_u8);
-/*!
- *	@brief This API writes Gyro wakeup trigger
- *	in the register 0x6C bit 3 and 4
- *
- *  @param v_gyro_wakeup_trigger_u8 : The value of Gyro wakeup trigger
- *  Value  |  Description
- * --------|-------------
- *   0x00  | anymotion: no / INT1 pin: no
- *   0x01  | anymotion: no / INT1 pin: yes
- *   0x02  | anymotion: yes / INT1 pin: no
- *   0x03  | anymotion: yes / INT1 pin: yes
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_wakeup_trigger(
-u8 v_gyro_wakeup_trigger_u8);
-/*!
- *	@brief This API reads target state for Gyro sleep mode
- *	from the register 0x6C bit 5
- *
- *  @param v_gyro_sleep_state_u8 : The value of Gyro sleep mode
- *  Value  |  Description
- * --------|-------------
- *   0x00  | Sleep transition to fast wake up state
- *   0x01  | Sleep transition to suspend state
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_sleep_state(
-u8 *v_gyro_sleep_state_u8);
-/*!
- *	@brief This API writes target state for Gyro sleep mode
- *	in the register 0x6C bit 5
- *
- *  @param v_gyro_sleep_state_u8 : The value of Gyro sleep mode
- *  Value  |  Description
- * --------|-------------
- *   0x00  | Sleep transition to fast wake up state
- *   0x01  | Sleep transition to suspend state
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_sleep_state(
-u8 v_gyro_sleep_state_u8);
-/*!
- *	@brief This API reads Gyro wakeup interrupt
- *	from the register 0x6C bit 6
- *
- *  @param v_gyro_wakeup_intr_u8 : The value of Gyro wakeup interrupt
- *  Value  |  Description
- * --------|-------------
- *   0x00  | DISABLE
- *   0x01  | ENABLE
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_wakeup_intr(
-u8 *v_gyro_wakeup_intr_u8);
-/*!
- *	@brief This API writes Gyro wakeup interrupt
- *	in the register 0x6C bit 6
- *
- *  @param v_gyro_wakeup_intr_u8 : The value of Gyro wakeup interrupt
- *  Value  |  Description
- * --------|-------------
- *   0x00  | DISABLE
- *   0x01  | ENABLE
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_wakeup_intr(
-u8 v_gyro_wakeup_intr_u8);
-/***************************************************/
-/**\name	FUNCTION FOR ACCEL SELF TEST */
-/***************************************************/
-/*!
- * @brief This API reads Accel selftest axis selected for self-test
- * functionality.
- *
- *  @param v_accel_selftest_axis_u8 :
- *	The value of Accel self test axis selection
- *  Value  |  Description
- * --------|-------------
- *   0x00  | disabled
- *   0x01  | x-axis
- *   0x02  | y-axis
- *   0x03  | z-axis
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_selftest_axis(
-u8 *acc_selftest_axis);
-/*!
- * @brief This API writes Accel self test axis for self-test
- * functionality.
- *
- *  @param v_accel_selftest_axis_u8 :
- *	The value of Accel self test axis selection
- *  Value  |  Description
- * --------|-------------
- *   0x00  | disabled
- *   0x01  | x-axis
- *   0x02  | y-axis
- *   0x03  | z-axis
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_selftest_axis(
-u8 acc_selftest_axis);
-/*!
- *	@brief This API reads Accel self test axis sign
- *	from the register 0x6D bit 2
- *
- *  @param v_accel_selftest_sign_u8: The value of Accel self test axis sign
- *  Value  |  Description
- * --------|-------------
- *   0x00  | negative
- *   0x01  | positive
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_selftest_sign(
-u8 *acc_selftest_sign);
-/*!
- *	@brief This API writes Accel self test axis sign
- *	in the register 0x6D bit 2
- *
- *  @param v_accel_selftest_sign_u8: The value of Accel self test axis sign
- *  Value  |  Description
- * --------|-------------
- *   0x00  | negative
- *   0x01  | positive
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_selftest_sign(
-u8 acc_selftest_sign);
-/*!
- *	@brief This API reads Accel self test amplitude
- *	from the register 0x6D bit 3
- *
- *
- *  @param v_accel_selftest_amp_u8 : The value of Accel self test amplitude
- *  Value  |  Description
- * --------|-------------
- *   0x00  | LOW
- *   0x01  | HIGH
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_selftest_amp(
-u8 *acc_selftest_amp);
-/*!
- *	@brief This API writes Accel self test amplitude
- *	in the register 0x6D bit 3
- *
- *
- *  @param v_accel_selftest_amp_u8 : The value of Accel self test amplitude
- *  Value  |  Description
- * --------|-------------
- *   0x00  | LOW
- *   0x01  | HIGH
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_selftest_amp(
-u8 acc_selftest_amp);
-/***************************************************/
-/**\name	FUNCTION FOR GYRO SELF TEST */
-/***************************************************/
-/*!
- *	@brief This API reads the Gyro self test trigger
- *
- *	@param v_gyro_selftest_start_u8: The value of Gyro self test start
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_selftest_start(
-u8 *v_gyro_selftest_start_u8);
-/*!
- *	@brief This API writes the Gyro self test trigger
- *
- *	@param v_gyro_selftest_start_u8: The value of Gyro self test start
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_selftest_start(
-u8 v_gyro_selftest_start_u8);
-/***************************************************/
-/**\name	FUNCTION FOR SPI/I2C ENABLE */
-/***************************************************/
- /*!
- * @brief This API reads the primary interface selection I2C or SPI
- *	from the register 0x70 bit 0
- *
- *  @param v_spi_enable_u8: The value of Interface selection
- *  Value  |  Description
- * --------|-------------
- *   0x00  | I2C Enable
- *   0x01  | I2C DISABLE
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_spi_enable(
-u8 *v_spi_enable_u8);
- /*!
- * @brief This API writes primary interface selection I2C or SPI
- *	in the register 0x70 bit 0
- *
- *  @param v_spi_enable_u8: The value of Interface selection
- *  Value  |  Description
- * --------|-------------
- *   0x00  | I2C Enable
- *   0x01  | I2C DISABLE
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_spi_enable(
-u8 v_spi_enable_u8);
-
-/***************************************************/
-/**\name	FUNCTION FOR ACCEL MANUAL OFFSET COMPENSATION */
-/***************************************************/
- /*!
- *	@brief This API reads the Accel manual offset compensation of x axis
- *	from the register 0x71 bit 0 to 7
- *
- *
- *
- *  @param v_accel_off_x_s8:
- *	The value of Accel manual offset compensation of x axis
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_offset_compensation_xaxis(
-s8 *v_accel_off_x_s8);
-/*!
- *	@brief This API writes the Accel manual offset compensation of x axis
- *	in the register 0x71 bit 0 to 7
- *
- *
- *
- *  @param v_accel_off_x_s8:
- *	The value of Accel manual offset compensation of x axis
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_offset_compensation_xaxis(
-s8 v_accel_off_x_s8);
-/*!
- *	@brief This API reads the  Accel manual offset compensation of y axis
- *	from the register 0x72 bit 0 to 7
- *
- *
- *
- *  @param v_accel_off_y_s8:
- *	The value of Accel manual offset compensation of y axis
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_offset_compensation_yaxis(
-s8 *v_accel_off_y_s8);
-/*!
- *	@brief This API writes the Accel manual offset compensation of y axis
- *	in the register 0x72 bit 0 to 7
- *
- *
- *
- *  @param v_accel_off_y_s8:
- *	The value of Accel manual offset compensation of y axis
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_offset_compensation_yaxis(
-s8 v_accel_off_y_s8);
-/*!
- *	@brief This API reads the Accel manual offset compensation of z axis
- *	from the register 0x73 bit 0 to 7
- *
- *
- *
- *  @param v_accel_off_z_s8:
- *	The value of Accel manual offset compensation of z axis
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_offset_compensation_zaxis(
-s8 *v_accel_off_z_s8);
-/*!
- *	@brief This API writes the Accel manual offset compensation of z axis
- *	in the register 0x73 bit 0 to 7
- *
- *
- *
- *  @param v_accel_off_z_s8:
- *	The value of Accel manual offset compensation of z axis
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_offset_compensation_zaxis(
-s8 v_accel_off_z_s8);
-/***************************************************/
-/**\name	FUNCTION FOR GYRO MANUAL OFFSET COMPENSATION */
-/***************************************************/
-/*!
- *	@brief This API reads the Gyro manual offset compensation of x axis
- *	from the register 0x74 bit 0 to 7 and 0x77 bit 0 and 1
- *
- *
- *
- *  @param v_gyro_off_x_s16:
- *	The value of Gyro manual offset compensation of x axis
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_offset_compensation_xaxis(
-s16 *v_gyro_off_x_s16);
-/*!
- *	@brief This API writes the Gyro manual offset compensation of x axis
- *	in the register 0x74 bit 0 to 7 and 0x77 bit 0 and 1
- *
- *
- *
- *  @param v_gyro_off_x_s16:
- *	The value of Gyro manual offset compensation of x axis
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_offset_compensation_xaxis(
-s16 v_gyro_off_x_s16);
-/*!
- *	@brief This API reads the Gyro manual offset compensation of y axis
- *	from the register 0x75 bit 0 to 7 and 0x77 bit 2 and 3
- *
- *
- *
- *  @param v_gyro_off_y_s16:
- *	The value of Gyro  manual offset compensation of y axis
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_offset_compensation_yaxis(
-s16 *v_gyro_off_y_s16);
-/*!
- *	@brief This API writes Gyro  manual offset compensation of y axis
- *	in the register 0x75 bit 0 to 7 and 0x77 bit 2 and 3
- *
- *
- *
- *  @param v_gyro_off_y_s16:
- *	The value of Gyro  manual offset compensation of y axis
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_offset_compensation_yaxis(
-s16 v_gyro_off_y_s16);
-/*!
- *	@brief This API reads the Gyro  manual offset compensation of z axis
- *	from the register 0x76 bit 0 to 7 and 0x77 bit 4 and 5
- *
- *
- *
- *  @param v_gyro_off_z_s16:
- *	The value of Gyro  manual offset compensation of z axis
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_offset_compensation_zaxis(
-s16 *v_gyro_off_z_s16);
-/*!
- *	@brief This API writes Gyro  manual offset compensation of z axis
- *	in the register 0x76 bit 0 to 7 and 0x77 bit 4 and 5
- *
- *
- *
- *  @param v_gyro_off_z_s16:
- *	The value of Gyro  manual offset compensation of z axis
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_offset_compensation_zaxis(
-s16 v_gyro_off_z_s16);
-/*!
- *	@brief This API writes Accel fast offset compensation
- *	from the register 0x69 bit 0 to 5
- *	@brief This API writes each axis individually
- *	FOC_X_AXIS - bit 4 and 5
- *	FOC_Y_AXIS - bit 2 and 3
- *	FOC_Z_AXIS - bit 0 and 1
- *
- *  @param  v_foc_accel_u8: The value of Accel offset compensation
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | disable
- *  0x01     | +1g
- *  0x01     | -1g
- *  0x01     | 0g
- *
- *  @param  v_axis_u8: The value of Accel offset axis selection
-  *	value    | axis
- * ----------|-------------------
- *  0        | FOC_X_AXIS
- *  1        | FOC_Y_AXIS
- *  2        | FOC_Z_AXIS
- *
- *	@param v_accel_offset_s8: The Accel offset value
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_foc_trigger(u8 axis,
-u8 foc_acc, s8 *accel_offset);
-/*!
- *	@brief This API writes fast Accel offset compensation
- *	for all axis in the register 0x69 bit 0 to 5
- *	FOC_X_AXIS - bit 4 and 5
- *	FOC_Y_AXIS - bit 2 and 3
- *	FOC_Z_AXIS - bit 0 and 1
- *
- *  @param  v_foc_accel_x_u8: The value of Accel offset x compensation
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | disable
- *  0x01     | +1g
- *  0x01     | -1g
- *  0x01     | 0g
- *
- *  @param  v_foc_accel_y_u8: The value of Accel offset y compensation
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | disable
- *  0x01     | +1g
- *  0x01     | -1g
- *  0x01     | 0g
- *
- *  @param  v_foc_accel_z_u8: The value of Accel offset z compensation
- *	value    | Behaviour
- * ----------|-------------------
- *  0x00     | disable
- *  0x01     | +1g
- *  0x01     | -1g
- *  0x01     | 0g
- *
- *  @param  v_accel_off_x_s8: The value of Accel offset x axis
- *  @param  v_accel_off_y_s8: The value of Accel offset y axis
- *  @param  v_accel_off_z_s8: The value of Accel offset z axis
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_accel_foc_trigger_xyz(u8 v_foc_accel_x_u8,
-u8 v_foc_accel_y_u8, u8 v_foc_accel_z_u8,
-s8 *acc_off_x, s8 *acc_off_y, s8 *acc_off_z);
-/***************************************************/
-/**\name	FUNCTION FOR ACCEL AND GYRO OFFSET ENABLE */
-/***************************************************/
-/*!
- *	@brief This API reads the Accel offset enable bit
- *	from the register 0x77 bit 6
- *
- *
- *
- *  @param v_accel_off_enable_u8: The value of Accel offset enable
- *  value    |  Description
- * ----------|--------------
- *   0x01    | ENABLE
- *   0x00    | DISABLE
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_offset_enable(
-u8 *acc_off_en);
-/*!
- *	@brief This API writes the Accel offset enable bit
- *	in the register 0x77 bit 6
- *
- *
- *
- *  @param v_accel_off_enable_u8: The value of Accel offset enable
- *  value    |  Description
- * ----------|--------------
- *   0x01    | ENABLE
- *   0x00    | DISABLE
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_offset_enable(
-u8 acc_off_en);
-/*!
- *	@brief This API reads the Accel offset enable bit
- *	from the register 0x77 bit 7
- *
- *
- *
- *  @param v_gyro_off_enable_u8: The value of Gyro  offset enable
- *  value    |  Description
- * ----------|--------------
- *   0x01    | ENABLE
- *   0x00    | DISABLE
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_offset_enable(
-u8 *v_gyro_off_enable_u8);
-/*!
- *	@brief This API writes the gyro offset enable bit
- *	in the register 0x77 bit 7
- *
- *
- *
- *  @param v_gyro_off_enable_u8: The value of Gyro  offset enable
- *  value    |  Description
- * ----------|--------------
- *   0x01    | ENABLE
- *   0x00    | DISABLE
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_offset_enable(
-u8 v_gyro_off_enable_u8);
-/***************************************************/
-/**\name	FUNCTION FOR STEP COUNTER INTERRUPT */
-/***************************************************/
-/*!
- *	@brief This API reads step counter output value
- *	from the register 0x78 and 0x79
- *
- *
- *
- *
- *  @param v_step_cnt_s16 : The value of step counter output
- *
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_step_count(s16 *v_step_cnt_s16);
- /*!
- *	@brief This API reads
- *	step counter configuration
- *	from the register 0x7A bit 0 to 7
- *	and also from the register 0x7B bit 0 to 2 and 4 to 7
- *
- *
- *  @param v_step_config_u16 : The value of step counter configuration
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_step_config(
-u16 *v_step_config_u16);
- /*!
- *	@brief This API writes the
- *	step counter configuration
- *	in the register 0x7A bit 0 to 7
- *	and also in the register 0x7B bit 0 to 2 and 4 to 7
- *
- *
- *  @param v_step_config_u16   :
- *	the value of step configuration
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_step_config(
-u16 v_step_config_u16);
- /*!
- *	@brief This API is used to get the step counter enable/disable status
- *	from the register 0x7B bit 3
- *
- *
- *  @param v_step_counter_u8 : The value of step counter enable
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_step_counter_enable(
-u8 *v_step_counter_u8);
- /*!
- *	@brief This API is used to enable step counter
- *	by setting the register 0x7B bit 3
- *
- *
- *  @param v_step_counter_u8 : The value of step counter enable
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_step_counter_enable(
-u8 v_step_counter_u8);
- /*!
- *	@brief This API is used to set step counter modes
- *
- *
- *  @param  v_step_mode_u8 : The value of step counter mode
- *  value    |   mode
- * ----------|-----------
- *   0       | BMI160_STEP_NORMAL_MODE
- *   1       | BMI160_STEP_SENSITIVE_MODE
- *   2       | BMI160_STEP_ROBUST_MODE
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
+/**
+ * Copyright (C) 2015 - 2016 Bosch Sensortec GmbH
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of the copyright holder nor the names of the
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
+ *
+ * The information provided is believed to be accurate and reliable.
+ * The copyright holder 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 the copyright holder.
+ *
+ * @file    bmi160.h
+ * @date    13 Apr 2017
+ * @version 3.5.0
+ * @brief
  *
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_step_mode(u8 v_step_mode_u8);
-/*!
- *	@brief This API is used to trigger the  signification motion
- *	interrupt
- *
- *
- *  @param  v_significant_u8 : The value of interrupt selection
- *  value    |  interrupt
- * ----------|-----------
- *   0       |  BMI160_MAP_INTR1
- *   1       |  BMI160_MAP_INTR2
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_map_significant_motion_intr(
-u8 v_significant_u8);
-/*!
- *	@brief This API is used to trigger the step detector
- *	interrupt
- *
- *
- *  @param  v_step_detector_u8 : The value of interrupt selection
- *  value    |  interrupt
- * ----------|-----------
- *   0       |  BMI160_MAP_INTR1
- *   1       |  BMI160_MAP_INTR2
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_map_step_detector_intr(
-u8 v_step_detector_u8);
- /*!
- *	@brief This API is used to clear the step counter interrupt
- *
- *
- *  @param  : None
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_clear_step_counter(void);
-/***************************************************/
-/**\name	FUNCTION FOR STEP COMMAND REGISTER WRITE */
-/***************************************************/
-/*!
- *	@brief This API writes the value to the register 0x7E bit 0 to 7
- *
- *
- *  @param  v_command_reg_u8 : The value to write command register
- *  value   |  Description
- * ---------|--------------------------------------------------------
- *	0x00	|	Reserved
- *  0x03	|	Starts fast offset calibration for the Accel and gyro
- *	0x10	|	Sets the PMU mode for the Accel to suspend
- *	0x11	|	Sets the PMU mode for the Accel to normal
- *	0x12	|	Sets the PMU mode for the Accel Lowpower
- *  0x14	|	Sets the PMU mode for the Gyro to suspend
- *	0x15	|	Sets the PMU mode for the Gyro to normal
- *	0x16	|	Reserved
- *	0x17	|	Sets the PMU mode for the Gyro to fast start-up
- *  0x18	|	Sets the PMU mode for the Mag to suspend
- *	0x19	|	Sets the PMU mode for the Mag to normal
- *	0x1A	|	Sets the PMU mode for the Mag to Lowpower
- *	0xB0	|	Clears all data in the FIFO
- *  0xB1	|	Resets the interrupt engine
- *	0xB2	|	step_cnt_clr Clears the step counter
- *	0xB6	|	Triggers a reset
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_command_register(
-u8 v_command_reg_u8);
 
-/***************************************************/
-/**\name	FUNCTION FOR BMM150 */
-/***************************************************/
- /*!
- *	@brief This function is used to initialize the bmm150 sensor
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bmm150_mag_interface_init(u8 *v_chip_id_u8);
- /*!
- *	@brief This function is used to set the Mag power control
- *	bit enable
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bmm150_mag_wakeup(void);
- /*!
- *	@brief This function is used to read the trim values of magnetometer
- *
- *	@note Before reading the Mag trimming values
- *	make sure the following two points are addressed
- *	@note
- *	1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note
- *	2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode.
- *		by using the function bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_bmm150_mag_trim(void);
- /*!
- *	@brief This function is used to read the compensated value of mag
- *	Before start reading the mag compensated data
- *	make sure the following two points are addressed
- *	@note
- *	1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note
- *	2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode.
- *		by using the function bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bmm150_mag_compensate_xyz(
-struct bmi160_mag_xyz_s32_t *mag_comp_xyz);
 /*!
- *	@brief This API is used to get the compensated BMM150-X axis data
- *
- *	Before start reading the Mag compensated X data
- *	make sure the following two points are addressed
- *	@note
- *	1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note
- *	2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode.
- *		by using the function bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
- *
- *
- *  @param  v_mag_data_x_s16 : The value of Mag raw X data
- *  @param  v_data_r_u16 : The value of Mag R data
- *
- *	@return compensated X axis data
- *
- */
-s32 bmi160_bmm150_mag_compensate_X(s16 v_mag_data_x_s16, u16 v_data_r_u16);
+ * @defgroup bmi160
+ * @brief
+ * @{*/
+
+#ifndef BMI160_H_
+#define BMI160_H_
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include "bmi160_defs.h"
+#ifdef __KERNEL__
+#include <bmi160_math.h>
+#else
+#include <math.h>
+#include <string.h>
+#include <stdlib.h>
+#endif
+
+
+/*********************** User function prototypes ************************/
+
 /*!
- *	@brief This API is used to get the compensated BMM150-Y axis data
- *
- *	Before reading the Mag compensated Y axis data
- *	make sure the following two points are addressed
- *	@note
- *	1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled then set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note
- *	2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode.
- *		by using the function bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
+ *  @brief This API is the entry point for sensor.It performs
+ *  the selection of I2C/SPI read mechanism according to the
+ *  selected interface and reads the chip-id of bmi160 sensor.
  *
+ *  @param[in,out] dev : Structure instance of bmi160_dev
+ *  @note : Refer user guide for detailed info.
  *
- *
- *  @param  v_mag_data_y_s16 : The value of Mag raw Y axis data
- *  @param  v_data_r_u16 : The value of Mag R data
- *
- *	@return results of compensated Y axis data
+ *  @return Result of API execution status
+ *  @retval zero -> Success / -ve value -> Error
  */
-s32 bmi160_bmm150_mag_compensate_Y(s16 v_mag_data_y_s16, u16 v_data_r_u16);
+int8_t bmi160_init(struct bmi160_dev *dev);
+
 /*!
- *	@brief This API is used to get the compensated BMM150-Z axis data
- *
- *	Before reading the Mag compensated Z data
- *	make sure the following two points are addressed
- *	@note
- *	1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled then set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note
- *	2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode.
- *		by using the function bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
+ * @brief This API reads the data from the given register address of sensor.
  *
+ * @param[in] reg_addr  : Register address from where the data to be read
+ * @param[out] data     : Pointer to data buffer to store the read data.
+ * @param[in] len       : No of bytes of data to be read.
+ * @param[in] dev       : Structure instance of bmi160_dev.
  *
- *
- *  @param  v_mag_data_z_s16 : The value of Mag raw Z data
- *  @param  v_data_r_u16 : The value of Mag R data
- *
- *	@return results of compensated Z axis data
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error
  */
-s32 bmi160_bmm150_mag_compensate_Z(s16 v_mag_data_z_s16, u16 v_data_r_u16);
+int8_t bmi160_get_regs(uint8_t reg_addr, uint8_t *data, uint16_t len, const struct bmi160_dev *dev);
+
 /*!
- *	@brief This API is used to set the pre-set modes of bmm150
- *	The pre-set mode setting depends on the data rate and xy and z
- *	repetitions
- *
- *	@note
- *	Before setting the Mag preset mode
- *	make sure the following two points are addressed
- *	@note
- *	1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note
- *	2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode by using the function
- *		bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
+ * @brief This API writes the given data to the register address
+ * of sensor.
  *
+ * @param[in] reg_addr  : Register address from where the data to be written.
+ * @param[in] data      : Pointer to data buffer which is to be written
+ * in the sensor.
+ * @param[in] len       : No of bytes of data to write..
+ * @param[in] dev       : Structure instance of bmi160_dev.
  *
- *  @param  v_mode_u8: The value of pre-set mode selection value
- *  value    |  pre_set mode
- * ----------|------------
- *   1       | BMI160_MAG_PRESETMODE_LOWPOWER
- *   2       | BMI160_MAG_PRESETMODE_REGULAR
- *   3       | BMI160_MAG_PRESETMODE_HIGHACCURACY
- *   4       | BMI160_MAG_PRESETMODE_ENHANCED
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_bmm150_mag_presetmode(u8 mode);
-/*!
- *	@brief This function is used to set the magnetometer
- *	power mode.
- *	@note
- *	Before setting the Mag power mode make sure the following
- *	two points are addressed
- *	@note
- *	1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled then set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note
- *	2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode by using the
- *		function bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
- *	@param v_mag_pow_mode_u8 : The value of Mag power mode
- *  value    |  mode
- * ----------|------------
- *   0       | FORCE_MODE
- *   1       | SUSPEND_MODE
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bmm150_mag_set_power_mode(u8 mag_pow_mode);
- /*!
- *	@brief This function is used to set the magnetometer
- *	power mode.
- *	@note Before setting the Mag power mode
- *	make sure the following points are addressed
- *		Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *
- *	@param v_mag_sec_if_pow_mode_u8 : The value of Mag power mode
- *  value    |  mode
- * ----------|------------
- *   0       | BMI160_MAG_FORCE_MODE
- *   1       | BMI160_MAG_SUSPEND_MODE
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_bmm150_mag_and_secondary_if_power_mode(
-u8 v_mag_sec_if_pow_mode_u8);
-#if defined AKM09911 || defined AKM09912
-/***************************************************/
-/**\name	FUNCTIONS FOR AKM09911 AND AKM09912*/
-/***************************************************/
+int8_t bmi160_set_regs(uint8_t reg_addr, uint8_t *data, uint16_t len, const struct bmi160_dev *dev);
 
-		/*!
-	 *	@brief Used to read the akm compensated values
-	*/
-	struct bmi160_bst_akm_xyz_t {
-	s32 x;/**<AKM09911 and AKM09912 X compensated data*/
-	s32 y;/**<AKM09911 and AKM09912 Y compensated data*/
-	s32 z;/**<AKM09911 and AKM09912 Z compensated data*/
-	};
-	/*!
-	*	@brief Structure for reading AKM compensating data
-	*/
-	struct bst_akm_sensitivity_data_t {
-	u8 asax;/**<AKM09911 and AKM09912 X sensitivity data*/
-	u8 asay;/**<AKM09911 and AKM09912 Y sensitivity data*/
-	u8 asaz;/**<AKM09911 and AKM09912 Z sensitivity data*/
-	};
-/*!
- *	@brief This function is used to initialize
- *	the AKM09911 and AKM09912 sensor
- *
- *
- *	@param v_akm_i2c_address_u8: The value of device address
- *	AKM sensor   |  Slave address
- * --------------|---------------------
- *  AKM09911     |  AKM09911_I2C_ADDR_1
- *     -         |  and AKM09911_I2C_ADDR_2
- *  AKM09912     |  AKM09912_I2C_ADDR_1
- *     -         |  AKM09912_I2C_ADDR_2
- *     -         |  AKM09912_I2C_ADDR_3
- *     -         |  AKM09912_I2C_ADDR_4
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_akm_mag_interface_init(
-u8 v_akm_i2c_address_u8);
-/*!
- *	@brief This function is used to read the sensitivity data of
- *	AKM09911 and AKM09912
- *
- *	@note Before reading the Mag sensitivity values
- *	make sure the following two points are addressed
- *	@note	1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note	2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode by using the function
- *		bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_bst_akm_sensitivity_data(void);
 /*!
- *	@brief This function is used to set the AKM09911 and AKM09912
- *	power mode.
- *	@note Before setting the AKM power mode
- *	make sure the following two points are addressed
- *	@note	1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled then set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note	2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode.
- *		by using the function bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
- *	@param v_akm_pow_mode_u8 : The value of akm power mode
- *  value   |    Description
- * ---------|--------------------
- *    0     |  AKM_POWER_DOWN_MODE
- *    1     |  AKM_SINGLE_MEAS_MODE
- *    2     |  FUSE_ROM_MODE
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
+ * @brief This API resets and restarts the device.
+ * All register values are overwritten with default parameters.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_akm_set_powermode(
-u8 v_akm_pow_mode_u8);
- /*!
- *	@brief This function is used to set the magnetometer
- *	power mode of AKM09911 and AKM09912
- *	@note Before setting the Mag power mode
- *	make sure the following two points are addressed
- *		Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled then set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
+ * @param[in] dev  : Structure instance of bmi160_dev.
  *
- *	@param v_mag_sec_if_pow_mode_u8 : The value of secondary if power mode
- *  value   |    Description
- * ---------|--------------------
- *    0     |  BMI160_MAG_FORCE_MODE
- *    1     |  BMI160_MAG_SUSPEND_MODE
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE
-bmi160_set_bst_akm_and_secondary_if_powermode(
-u8 v_mag_sec_if_pow_mode_u8);
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error.
+ */
+int8_t bmi160_soft_reset(const struct bmi160_dev *dev);
 
-#endif
-#ifdef AKM09911
-/***************************************************/
-/**\name	FUNCTIONS FOR AKM09911 */
-/***************************************************/
 /*!
- *	@brief This API is used to get the compensated X data
- *	of AKM09911 sensor
- *	Output of X is s32
- *	@note	Before start reading the Mag compensated X data
- *			make sure the following two points are addressed
- *	@note 1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note 2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode.
- *		by using the function bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
- *
- *  @param v_bst_akm_x_s16 : The value of X data
+ * @brief This API configures the power mode, range and bandwidth
+ * of sensor.
  *
- *	@return compensated X data value
+ * @param[in] dev    : Structure instance of bmi160_dev.
+ * @note : Refer user guide for detailed info.
  *
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error.
  */
-s32 bmi160_bst_akm09911_compensate_X(s16 v_bst_akm_x_s16);
+int8_t bmi160_set_sens_conf(struct bmi160_dev *dev);
+
 /*!
- *	@brief This API is used to get the compensated Y data
- *	of AKM09911 sensor
- *  Output of Y is s32
- *	@note	Before start reading the Mag compensated Y data
- *			make sure the following two points are addressed
- *	@note 1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note 2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode.
- *		by using the function bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
+ * @brief This API sets the power mode of the sensor.
  *
- *  @param v_bst_akm_y_s16 : The value of Y data
- *
- *	@return compensated Y data value
+ * @param[in] dev  : Structure instance of bmi160_dev.
  *
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error.
  */
-s32 bmi160_bst_akm09911_compensate_Y(s16 v_bst_akm_y_s16);
+int8_t bmi160_set_power_mode(struct bmi160_dev *dev);
+
 /*!
- *	@brief This API is used to get the compensated Z data
- *	of AKM09911 sensor
- *  Out put of Z is s32
- *	@note	Before start reading the Mag compensated Z data
- *			make sure the following two points are addressed
- *	@note 1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note 2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode.
- *		by using the function bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
+ * @brief This API reads sensor data, stores it in
+ * the bmi160_sensor_data structure pointer passed by the user.
+ * The user can ask for accel data ,gyro data or both sensor
+ * data using bmi160_select_sensor enum
  *
+ * @param[in] select_sensor    : enum to choose accel,gyro or both sensor data
+ * @param[out] accel    : Structure pointer to store accel data
+ * @param[out] gyro     : Structure pointer to store gyro data
+ * @param[in] dev       : Structure instance of bmi160_dev.
+ * @note : Refer user guide for detailed info.
  *
- *  @param v_bst_akm_z_s16 : The value of Z data
- *
- *	@return compensated Z data value
- *
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
  */
-s32 bmi160_bst_akm09911_compensate_Z(s16 v_bst_akm_z_s16);
- /*!
- *	@brief This function is used to read the compensated value of
- *	AKM09911
- *	@note Before start reading the Mag compensated data's
- *	make sure the following two points are addressed
- *	@note	1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note	2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode by using the function
- *		bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_akm09911_compensate_xyz(
-struct bmi160_bst_akm_xyz_t *bst_akm_xyz);
-#endif
- #ifdef AKM09912
- /***************************************************/
-/**\name	FUNCTIONS FOR AKM09912*/
-/***************************************************/
+int8_t bmi160_get_sensor_data(uint8_t select_sensor, struct bmi160_sensor_data *accel,
+				struct bmi160_sensor_data *gyro, const struct bmi160_dev *dev);
+
 /*!
- *	@brief This API is used to get the compensated X data
- *	of AKM09912 sensor
- *	Output of X is s32
- *	@note	Before start reading the Mag compensated X data
- *			make sure the following two points are addressed
- *	@note 1. Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note 2. And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode.
- *		by using the function bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
+ * @brief This API configures the necessary interrupt based on
+ *  the user settings in the bmi160_int_settg structure instance.
  *
+ * @param[in] int_config  : Structure instance of bmi160_int_settg.
+ * @param[in] dev         : Structure instance of bmi160_dev.
+ * @note : Refer user guide for detailed info.
  *
- *	@param v_bst_akm_x_s16 : The value of X data
- *
- *	@return compensated X data value
- *
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error
  */
-s32 bmi160_bst_akm09912_compensate_X(s16 v_bst_akm_x_s16);
+int8_t bmi160_set_int_config(struct bmi160_int_settg *int_config, struct bmi160_dev *dev);
+
 /*!
- *	@brief This API is used to get the compensated Y data
- *	of AKM09912 sensor
- *	@note	Before reading the Mag compensated Y data
- *		make sure the following two points are addressed
- *	@note 1. Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note 2. And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode by using the function
- *		bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
+ * @brief This API enables the step counter feature.
  *
- *  @param v_bst_akm_y_s16 : The value of Y data
- *
- *	@return compensated Y data value
+ * @param[in] step_cnt_enable	: value to enable or disable
+ * @param[in] dev		: Structure instance of bmi160_dev.
+ * @note : Refer user guide for detailed info.
  *
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error
  */
-s32 bmi160_bst_akm09912_compensate_Y(s16 v_bst_akm_y_s16);
+int8_t bmi160_set_step_counter(uint8_t step_cnt_enable, const struct bmi160_dev *dev);
+
 /*!
- *	@brief This API is used to get the compensated Z data
- *	of AKM09912
- *  Output of X is s32
- *	@note	Before start reading the Mag compensated Z data
- *			make sure the following two points are addressed
- *	@note 1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note 2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode.
- *		by using the function bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
- *
- *  @param v_bst_akm_z_s16 : The value of Z data
+ * @brief This API reads the step counter value.
  *
- *	@return compensated Z data value
+ * @param[in] step_val	  : Pointer to store the step counter value.
+ * @param[in] dev         : Structure instance of bmi160_dev.
+ * @note : Refer user guide for detailed info.
  *
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error
  */
-s32 bmi160_bst_akm09912_compensate_Z(s16 v_bst_akm_z_s16);
- /*!
- *	@brief This function is used to read the compensated value of
- *	AKM09912 sensor
- *	@note Before start reading the Mag compensated data's
- *	make sure the following two points are addressed
- *	@note	1.	Make sure the Mag interface is enabled or not,
- *		by using the bmi160_get_if_mode() function.
- *		If Mag interface is not enabled set the value of 0x02
- *		to the function bmi160_get_if_mode(0x02)
- *	@note	2.	And also confirm the secondary-interface power mode
- *		is not in the SUSPEND mode by using the function
- *		bmi160_get_mag_pmu_status().
- *		If the secondary-interface power mode is in SUSPEND mode
- *		set the value of 0x19(NORMAL mode)by using the
- *		bmi160_set_command_register(0x19) function.
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_akm09912_compensate_xyz(
-struct bmi160_bst_akm_xyz_t *bst_akm_xyz);
- #endif
+int8_t bmi160_read_step_counter(uint16_t *step_val, const struct bmi160_dev *dev);
 
-#ifdef FIFO_ENABLE
-/***************************************************/
-/**\name	FUNCTIONS FOR FIFO DATA READ */
-/***************************************************/
 /*!
- *	@brief This function is used to read the
- *	fifo data for  header less mode
- *
- *
- *
- *	@note Configure the below functions for FIFO header less mode
- *	@note 1. bmi160_set_fifo_down_gyro
- *	@note 2. bmi160_set_gyro_fifo_filter_data
- *	@note 3. bmi160_set_fifo_down_accel
- *	@note 4. bmi160_set_accel_fifo_filter_dat
- *	@note 5. bmi160_set_fifo_mag_enable
- *	@note 6. bmi160_set_fifo_accel_enable
- *	@note 7. bmi160_set_fifo_gyro_enable
- *	@note For interrupt configuration
- *	@note 1. bmi160_set_intr_fifo_full
- *	@note 2. bmi160_set_intr_fifo_wm
- *	@note 3. bmi160_set_fifo_tag_intr2_enable
- *	@note 4. bmi160_set_fifo_tag_intr1_enable
- *
- *	@note The FIFO reads the whole 1024 bytes of data and
- *	processing it.
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @brief This API reads the mention no of byte of data from the given
+ * register address of auxiliary sensor.
  *
+ * @param[in] reg_addr	  : Address of register to read.
+ * @param[in] aux_data	  : Pointer to store the read data.
+ * @param[in] len	  : No of bytes to read.
+ * @param[in] dev         : Structure instance of bmi160_dev.
+ * @note : Refer user guide for detailed info.
  *
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_fifo_headerless_mode(
-u8 v_mag_if_u8, struct bmi160_fifo_data_header_less_t *headerless_data);
+int8_t bmi160_aux_read(uint8_t reg_addr, uint8_t *aux_data, uint16_t len, const struct bmi160_dev *dev);
+
 /*!
- *	@brief This function is used to read the
- *	fifo data for header less mode according to user defined length
- *
- *
- *	@param v_fifo_user_length_u16: length of FIFO data to be read
- *	@param v_mag_if_mag_u8 : the Mag interface data
- *	@param fifo_data : the pointer to fifo_data_header_less_t structure
- *
- *	@note Configure the below functions for FIFO header less mode
- *	@note 1. bmi160_set_fifo_down_gyro
- *	@note 2. bmi160_set_gyro_fifo_filter_data
- *	@note 3. bmi160_set_fifo_down_accel
- *	@note 4. bmi160_set_accel_fifo_filter_dat
- *	@note 5. bmi160_set_fifo_mag_enable
- *	@note 6. bmi160_set_fifo_accel_enable
- *	@note 7. bmi160_set_fifo_gyro_enable
- *	@note For interrupt configuration
- *	@note 1. bmi160_set_intr_fifo_full
- *	@note 2. bmi160_set_intr_fifo_wm
- *	@note 3. bmi160_set_fifo_tag_intr2_enable
- *	@note 4. bmi160_set_fifo_tag_intr1_enable
- *
- *	@note The FIFO reads the whole 1024 bytes
- *	of data and process it.
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @brief This API writes the mention no of byte of data to the given
+ * register address of auxiliary sensor.
  *
+ * @param[in] reg_addr	  : Address of register to write.
+ * @param[in] aux_data	  : Pointer to write data.
+ * @param[in] len	  : No of bytes to write.
+ * @param[in] dev         : Structure instance of bmi160_dev.
+ * @note : Refer user guide for detailed info.
  *
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error
  */
-BMI160_RETURN_FUNCTION_TYPE
-bmi160_read_fifo_headerless_mode_user_defined_length(
-u16 v_fifo_user_length_u16,
-struct bmi160_fifo_data_header_less_t *fifo_data, u8 v_mag_if_mag_u8);
+int8_t bmi160_aux_write(uint8_t reg_addr, uint8_t *aux_data, uint16_t len, const struct bmi160_dev *dev);
+
 /*!
- *	@brief This function is used to read the
- *	fifo data of  header mode
- *
- *
- *	@note Configure the below functions for FIFO header mode
- *	@note 1. bmi160_set_fifo_down_gyro()
- *	@note 2. bmi160_set_gyro_fifo_filter_data()
- *	@note 3. bmi160_set_fifo_down_accel()
- *	@note 4. bmi160_set_accel_fifo_filter_dat()
- *	@note 5. bmi160_set_fifo_mag_enable()
- *	@note 6. bmi160_set_fifo_accel_enable()
- *	@note 7. bmi160_set_fifo_gyro_enable()
- *	@note 8. bmi160_set_fifo_header_enable()
- *	@note For interrupt configuration
- *	@note 1. bmi160_set_intr_fifo_full()
- *	@note 2. bmi160_set_intr_fifo_wm()
- *	@note 3. bmi160_set_fifo_tag_intr2_enable()
- *	@note 4. bmi160_set_fifo_tag_intr1_enable()
- *
- *	@note The FIFO reads the whole 1024 bytes
- *	of data and process it.
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @brief This API initialize the auxiliary sensor
+ * in order to access it.
  *
+ * @param[in] dev         : Structure instance of bmi160_dev.
+ * @note : Refer user guide for detailed info.
  *
+ * @return Result of API execution status
+ * @retval zero -> Success / -ve value -> Error
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_fifo_header_data(
-u8 v_mag_if_u8, struct bmi160_fifo_data_header_t *header_data);
+int8_t bmi160_aux_init(const struct bmi160_dev *dev);
+
 /*!
- *	@brief This function is used to read the
- *	fifo data of  header mode for user defined length
- *
+ * @brief This API is used to setup the auxiliary sensor of bmi160 in auto mode
+ * Thus enabling the auto update of 8 bytes of data from auxiliary sensor
+ * to BMI160 register address 0x04 to 0x0B
  *
- *	@note Configure the below functions for FIFO header mode
- *	@note 1. bmi160_set_fifo_down_gyro()
- *	@note 2. bmi160_set_gyro_fifo_filter_data()
- *	@note 3. bmi160_set_fifo_down_accel()
- *	@note 4. bmi160_set_accel_fifo_filter_dat()
- *	@note 5. bmi160_set_fifo_mag_enable()
- *	@note 6. bmi160_set_fifo_accel_enable()
- *	@note 7. bmi160_set_fifo_gyro_enable()
- *	@note 8. bmi160_set_fifo_header_enable()
- *	@note For interrupt configuration
- *	@note 1. bmi160_set_intr_fifo_full()
- *	@note 2. bmi160_set_intr_fifo_wm()
- *	@note 3. bmi160_set_fifo_tag_intr2_enable()
- *	@note 4. bmi160_set_fifo_tag_intr1_enable()
+ * @param[in] data_addr	   : Starting address of aux. sensor's data register
+ *                           (BMI160 registers 0x04 to 0x0B will be updated
+ *                           with 8 bytes of data from auxiliary sensor
+ *                           starting from this register address.)
+ * @param[in] dev	   : Structure instance of bmi160_dev.
  *
- *	@note The FIFO reads the whole 1024 bytes
- *	of data and process it.
+ * @note : Set the value of auxiliary polling rate by setting
+ *         dev->aux_cfg.aux_odr to the required value from the table
+ *         before calling this API
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ *   dev->aux_cfg.aux_odr  |   Auxiliary ODR (Hz)
+ *  -----------------------|-----------------------
+ *  BMI160_AUX_ODR_0_78HZ  |        25/32
+ *  BMI160_AUX_ODR_1_56HZ  |        25/16
+ *  BMI160_AUX_ODR_3_12HZ  |        25/8
+ *  BMI160_AUX_ODR_6_25HZ  |        25/4
+ *  BMI160_AUX_ODR_12_5HZ  |        25/2
+ *  BMI160_AUX_ODR_25HZ    |        25
+ *  BMI160_AUX_ODR_50HZ    |        50
+ *  BMI160_AUX_ODR_100HZ   |        100
+ *  BMI160_AUX_ODR_200HZ   |        200
+ *  BMI160_AUX_ODR_400HZ   |        400
+ *  BMI160_AUX_ODR_800HZ   |        800
  *
+ * @note : Other values of  dev->aux_cfg.aux_odr are reserved and not for use
  *
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_fifo_header_data_user_defined_length(
-u16 v_fifo_user_length_u16, u8 v_mag_if_mag_u8,
-struct bmi160_fifo_data_header_t *fifo_header_data);
-#endif
+int8_t bmi160_set_aux_auto_mode(uint8_t *data_addr, struct bmi160_dev *dev);
+
 /*!
- *	@brief This function is used to read the compensated xyz axis data of
- *	mag secondary interface
- *	@note v_mag_x_s16: The value of Mag x data
- *	@note v_mag_y_s16: The value of Mag y data
- *	@note v_mag_z_s16: The value of Mag z data
- *	@note v_mag_r_s16: The value of Mag r data
- *	@param v_mag_second_if_u8: The value of Mag selection
+ * @brief This API configures the 0x4C register and settings like
+ * Auxiliary sensor manual enable/ disable and aux burst read length.
  *
- *  value   |   v_mag_second_if_u8
- * ---------|----------------------
- *    0     |    BMM150
- *    1     |    AKM09911
- *    2     |    AKM09912
- *    3     |    YAS532
- *    4     |    YAS537
- *	@param mag_fifo_data: The value of compensated Mag xyz data
+ * @param[in] dev    : Structure instance of bmi160_dev.
  *
- *
- *  @return
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_second_if_mag_compensate_xyz(
-struct bmi160_mag_fifo_data_t mag_fifo_data,
-u8 v_mag_second_if_u8);
-#ifdef YAS537
-/***************************************************/
-/**\name	FUNCTIONS FOR YAMAHA-YAS537 */
-/***************************************************/
-/**
- * @struct yas_vector
- * @brief Stores the sensor data
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
  */
-struct yas_vector {
-	s32 yas537_vector_xyz[3]; /*!< vector data */
-};
-/*!
-* @brief YAMAHA-YAS532 struct
-* Calibration YAS532 data struct
-*/
-struct bst_yas537_calib_data_t {
-s8 a2;/**<YAS532 calib a2 data */
-s8 a3;/**<YAS532 calib a3 data */
-s8 a4;/**<YAS532 calib a4 data */
-s16 a5;/**<YAS532 calib a5 data */
-s8 a6;/**<YAS532 calib a6 data */
-s8 a7;/**<YAS532 calib a7 data */
-s8 a8;/**<YAS532 calib a8 data */
-s16 a9;/**<YAS532 calib a9 data */
-u8 k;/**<YAS532 calib k data */
-u8 ver;/**<YAS532 calib ver data*/
-};
-/*!
-* @brief YAS537 sensor initialization
-*/
-struct yas537_t {
-struct bst_yas537_calib_data_t calib_yas537;/**< calib data */
-s8 measure_state;/**< update measure state */
-s8 hard_offset[3];/**< offset write array*/
-u16 last_after_rcoil[3];/**< rcoil write array*/
-s32 coef[3];/**< coefficient data */
-s8 overflow;/**< over flow condition check */
-u8 dev_id;/**< device id information */
-u8 average;/**<average selection for offset configuration*/
-const s8 *transform;/**< transform condition check  */
-u16 last_raw[4];/**< raw data */
-struct yas_vector xyz; /*!< X, Y, Z measurement data of the sensor */
-};
+int8_t bmi160_config_aux_mode(const struct bmi160_dev *dev);
+
 /*!
- *	@brief This function is used to read the
- *	YAMAHA YAS537 xy1y2 data of fifo
- *
- *	@param a_xy1y2_u16: The value of xyy1 data
- *	@param v_over_flow_u8: The value of overflow
- *	@param v_rcoil_u8: The value of rcoil
- *	@param v_busy_u8: The value of busy flag
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @brief This API is used to read the raw uncompensated auxiliary sensor
+ * data of 8 bytes from BMI160 register address 0x04 to 0x0B
  *
+ * @param[in] aux_data	     : Pointer to user array of length 8 bytes
+ *                             Ensure that the aux_data array is of
+ *                             length 8 bytes
+ * @param[in] dev	     : Structure instance of bmi160_dev
  *
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas537_fifo_xyz_data(
-u16 *a_xy1y2_u16, u8 v_over_flow_u8, u8 v_rcoil_u8, u8 v_busy_u8);
+int8_t bmi160_read_aux_data_auto_mode(uint8_t *aux_data, const struct bmi160_dev *dev);
+
 /*!
- *	@brief This function used to init the YAMAHA-YAS537
- *
+ * @brief This is used to perform self test of accel/gyro of the BMI160 sensor
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ * @param[in] select_sensor  : enum to choose accel or gyro for self test
+ * @param[in] dev            : Structure instance of bmi160_dev
  *
+ * @note self test can be performed either for accel/gyro at any instant.
  *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas537_mag_interface_init(
-void);
-/*!
-*	@brief This function is used to read the
-*	YAMAHA YAS537 calibration data
-*
-*
-*	@param v_rcoil_u8 : The value of r coil
-*
-*
-*	@return results of bus communication function
-*	@retval 0 -> Success
-*	@retval -1 -> Error
-*
-*
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas537_calib_values(
-u8 v_rcoil_u8);
-/*!
- *	@brief This function is used for writing the data acquisition
- *	command register write in YAS537
- *	@param	v_command_reg_data_u8	:	the value of data acquisition
- *	acquisition_command  |   operation
- *  ---------------------|-------------------------
- *         0x17          | turn on the acquisition coil
- *         -             | set direction of the coil
- *         _             | (x and y as minus(-))
- *         _             | Deferred acquisition mode
- *        0x07           | turn on the acquisition coil
- *         _             | set direction of the coil
- *         _             | (x and y as minus(-))
- *         _             | Normal acquisition mode
- *        0x11           | turn OFF the acquisition coil
- *         _             | set direction of the coil
- *         _             | (x and y as plus(+))
- *         _             | Deferred acquisition mode
- *       0x01            | turn OFF the acquisition coil
- *        _              | set direction of the coil
- *        _              | (x and y as plus(+))
- *        _              | Normal acquisition mode
+ *     value of select_sensor       |  Inference
+ *----------------------------------|--------------------------------
+ *   BMI160_ACCEL_ONLY              | Accel self test enabled
+ *   BMI160_GYRO_ONLY               | Gyro self test enabled
+ *   BMI160_BOTH_ACCEL_AND_GYRO	    | NOT TO BE USED
  *
+ * @note The return value of this API gives us the result of self test.
  *
+ * @note Performing self test does soft reset of the sensor, User can
+ * set the desired settings after performing the self test.
  *
-  *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
+ * @return Result of API execution status
+ * @retval zero -> Success  / -ve value -> Error / +ve value -> Self-test fail
  *
+ *   Return value                  |   Result of self test
+ * --------------------------------|---------------------------------
+ *  BMI160_OK                      |  Self test success
+ *  BMI160_W_GYRO_SELF_TEST_FAIL   |  Gyro self test fail
+ *  BMI160_W_ACCEl_SELF_TEST_FAIL  |  Accel self test fail
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas537_acquisition_command_register(
-u8 v_command_reg_data_u8);
+int8_t bmi160_perform_self_test(uint8_t select_sensor, struct bmi160_dev *dev);
+
 /*!
- *	@brief This function is used to read the
- *	YAMAHA YAS537 xy1y2 data
- *
- *	@param v_coil_stat_u8: The value of R coil status
- *	@param v_busy_u8: The value of busy status
- *	@param v_temperature_u16: The value of temperature
- *	@param xy1y2: The value of raw xy1y2 data
- *	@param v_outflow_u8: The value of overflow
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
+ *  @brief This API reads the data from fifo buffer.
  *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas537_read_xy1y2_data(
-u8 *v_coil_stat_u8, u8 *v_busy_u8,
-u16 *v_temperature_u16, u16 *xy1y2, u8 *v_outflow_u8);
-/*!
- *	@brief This function is used to read the
- *	YAMAHA YAS537 xy1y2 data
+ *  @note User has to allocate the FIFO buffer along with
+ *  corresponding fifo length from his side before calling this API
+ *  as mentioned in the readme.md
  *
- *	@param v_outflow_u8: The value of overflow
- *	@param *vector_xyz : yas vector structure pointer
+ *  @note User must specify the number of bytes to read from the FIFO in
+ *  dev->fifo->length , It will be updated by the number of bytes actually
+ *  read from FIFO after calling this API
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ *  @param[in] dev     : Structure instance of bmi160_dev.
  *
+ *  @return Result of API execution status
+ *  @retval zero -> Success / -ve value -> Error
  *
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas537_measure_xyz_data(
-u8 *v_outflow_u8, struct yas_vector *vector_xyz);
-
-#endif
+int8_t bmi160_get_fifo_data(struct bmi160_dev const *dev);
 
-#ifdef YAS532
-/***************************************************/
-/**\name	FUNCTIONS FOR YAMAHA-YAS532 */
-/***************************************************/
-/*!
-* @brief YAMAHA-YAS532 struct
-* Calibration YAS532 data struct
-*/
-struct bst_yas532_calib_data_t {
-s32 cx;/**<YAS532 calib cx data */
-s32 cy1;/**<YAS532 calib cy1 data */
-s32 cy2;/**<YAS532 calib cy2 data */
-s32 a2;/**<YAS532 calib a2 data */
-s32 a3;/**<YAS532 calib a3 data */
-s32 a4;/**<YAS532 calib a4 data */
-s32 a5;/**<YAS532 calib a5 data */
-s32 a6;/**<YAS532 calib a6 data */
-s32 a7;/**<YAS532 calib a7 data */
-s32 a8;/**<YAS532 calib a8 data */
-s32 a9;/**<YAS532 calib a9 data */
-s32 k;/**<YAS532 calib k data */
-s8 rxy1y2[3];/**<YAS532 calib rxy1y2 data */
-u8 fxy1y2[3];/**<YAS532 calib fxy1y2 data */
-};
-/*!
-* @brief YAS532 Temperature structure
-*/
-#if 1 < YAS532_MAG_TEMPERATURE_LOG
-struct yas_temp_filter_t {
-u16 log[YAS532_MAG_TEMPERATURE_LOG];/**<YAS532 temp log array */
-u8 num;/**< used to increment the index */
-u8 idx;/**< used to increment the index */
-};
-#endif
-/*!
-* @brief YAS532 sensor initialization
-*/
-struct yas532_t {
-struct bst_yas532_calib_data_t calib_yas532;/**< calib data */
-s8 measure_state;/**< update measure state */
-s8 v_hard_offset_s8[3];/**< offset write array*/
-s32 coef[3];/**< co efficient data */
-s8 overflow;/**< over flow condition check */
-u8 dev_id;/**< device id information */
-const s8 *transform;/**< transform condition check  */
-#if 1 < YAS532_MAG_TEMPERATURE_LOG
-struct yas_temp_filter_t temp_data;/**< temp data */
-#endif
-u16 last_raw[4];/**< raw data */
-};
-/*!
-* @brief Used for reading the YAS532 XYZ data
-*/
-struct yas532_vector {
-s32 yas532_vector_xyz[3];/**< YAS532 compensated xyz data*/
-};
-/*!
-* @struct yas532_data
-* @brief Used for reading the YAS532 XYZ data
-*/
-struct yas532_data {
-s32 x;
-s32 y;
-s32 z;
-};
-/*!
- *	@brief This function is used to initlalize the YAMAHA-YAS532 sensor
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas532_mag_interface_init(
-void);
 /*!
- *	@brief This function used to set the YAS532 initial values
+ *  @brief This API writes fifo_flush command to command register.This
+ *  action clears all data in the Fifo without changing fifo configuration
+ *  settings.
  *
+ *  @param[in] dev     : Structure instance of bmi160_dev
  *
-  *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
+ *  @return Result of API execution status
+ *  @retval 0 -> Success
+ *  @retval Any non zero value -> Fail
  *
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_set_initial_values(void);
-/*!
- *	@brief This function is used to perform YAS532 offset correction
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_magnetic_measure_set_offset(
-void);
-/*!
- *	@brief This function used to read the
- *	YAMAHA YAS532 calibration data
- *
- *
-  *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
- *
+int8_t bmi160_set_fifo_flush(const struct bmi160_dev *dev);
+
+/*! @brief This API sets the FIFO configuration in the sensor.
  *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas532_calib_values(void);
-/*!
- *	@brief This function is used to calculate the
- *	linear data in YAS532 sensor.
+ *  @param[in] config : variable used to specify the FIFO
+ *  configurations which are to be enabled or disabled in the sensor.
  *
+ *  @note : User can set either set one or more or all FIFO configurations
+ *  by ORing the below mentioned macros.
+ *      config                  |   Value
+ *      ------------------------|---------------------------
+ *      BMI160_FIFO_TIME        |   0x02
+ *      BMI160_FIFO_TAG_INT2    |   0x04
+ *      BMI160_FIFO_TAG_INT1    |   0x08
+ *      BMI160_FIFO_HEADER      |   0x10
+ *      BMI160_FIFO_AUX         |   0x20
+ *      BMI160_FIFO_ACCEL	|   0x40
+ *      BMI160_FIFO_GYRO        |   0x80
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ *  @param[in] enable : Parameter used to enable or disable the above
+ *  FIFO configuration
+ *  @param[in] dev : Structure instance of bmi160_dev.
  *
+ *  @return status of bus communication result
+ *  @retval 0 -> Success
+ *  @retval Any non zero value -> Fail
  *
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_xy1y2_to_linear(
-u16 *v_xy1y2_u16, s32 *xy1y2_linear);
-/*!
- *	@brief This function is used to read the YAS532 sensor data
- *	@param	v_acquisition_command_u8: used to set the data acquisition
- *	acquisition_command  |   operation
- *  ---------------------|-------------------------
- *         0x17          | turn on the acquisition coil
- *         -             | set direction of the coil
- *         _             | (x and y as minus(-))
- *         _             | Deferred acquisition mode
- *        0x07           | turn on the acquisition coil
- *         _             | set direction of the coil
- *         _             | (x and y as minus(-))
- *         _             | Normal acquisition mode
- *        0x11           | turn OFF the acquisition coil
- *         _             | set direction of the coil
- *         _             | (x and y as plus(+))
- *         _             | Deferred acquisition mode
- *       0x01            | turn OFF the acquisition coil
- *        _              | set direction of the coil
- *        _              | (x and y as plus(+))
- *        _              | Normal acquisition mode
- *
- *	@param	v_busy_u8 : used to get the busy flag for sensor data read
- *	@param	v_temp_u16 : used to get the temperature data
- *	@param	v_xy1y2_u16 : used to get the sensor xy1y2 data
- *	@param	v_overflow_u8 : used to get the overflow data
+int8_t bmi160_set_fifo_config(uint8_t config, uint8_t enable, struct bmi160_dev const *dev);
+
+/*! @brief This API is used to configure the down sampling ratios of
+ *  the accel and gyro data for FIFO.Also, it configures filtered or
+ *  pre-filtered data for the fifo for accel and gyro.
  *
+ *  @param[in] fifo_down : variable used to specify the FIFO down
+ *  configurations which are to be enabled or disabled in the sensor.
  *
+ *  @note The user must select one among the following macros to
+ *  select down-sampling ratio for accel
+ *      config                               |   Value
+ *      -------------------------------------|---------------------------
+ *      BMI160_ACCEL_FIFO_DOWN_ZERO          |   0x00
+ *      BMI160_ACCEL_FIFO_DOWN_ONE           |   0x10
+ *      BMI160_ACCEL_FIFO_DOWN_TWO           |   0x20
+ *      BMI160_ACCEL_FIFO_DOWN_THREE         |   0x30
+ *      BMI160_ACCEL_FIFO_DOWN_FOUR          |   0x40
+ *      BMI160_ACCEL_FIFO_DOWN_FIVE          |   0x50
+ *      BMI160_ACCEL_FIFO_DOWN_SIX           |   0x60
+ *      BMI160_ACCEL_FIFO_DOWN_SEVEN         |   0x70
  *
-  *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ *  @note The user must select one among the following macros to
+ *  select down-sampling ratio for gyro
  *
+ *      config                               |   Value
+ *      -------------------------------------|---------------------------
+ *      BMI160_GYRO_FIFO_DOWN_ZERO           |   0x00
+ *      BMI160_GYRO_FIFO_DOWN_ONE            |   0x01
+ *      BMI160_GYRO_FIFO_DOWN_TWO            |   0x02
+ *      BMI160_GYRO_FIFO_DOWN_THREE          |   0x03
+ *      BMI160_GYRO_FIFO_DOWN_FOUR           |   0x04
+ *      BMI160_GYRO_FIFO_DOWN_FIVE           |   0x05
+ *      BMI160_GYRO_FIFO_DOWN_SIX            |   0x06
+ *      BMI160_GYRO_FIFO_DOWN_SEVEN          |   0x07
  *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_normal_measurement_data(
-u8 v_acquisition_command_u8, u8 *v_busy_u8,
-u16 *v_temp_u16, u16 *v_xy1y2_u16, u8 *v_overflow_u8);
-/*!
- *	@brief This function is used to read the YAS532 sensor data
- *	@param	v_acquisition_command_u8	:	the value of CMDR
- *	acquisition_command  |   operation
- *  ---------------------|-------------------------
- *         0x17          | turn on the acquisition coil
- *         -             | set direction of the coil
- *         _             | (x and y as minus(-))
- *         _             | Deferred acquisition mode
- *        0x07           | turn on the acquisition coil
- *         _             | set direction of the coil
- *         _             | (x and y as minus(-))
- *         _             | Normal acquisition mode
- *        0x11           | turn OFF the acquisition coil
- *         _             | set direction of the coil
- *         _             | (x and y as plus(+))
- *         _             | Deferred acquisition mode
- *       0x01            | turn OFF the acquisition coil
- *        _              | set direction of the coil
- *        _              | (x and y as plus(+))
- *        _              | Normal acquisition mode
+ *  @note The user can enable filtered accel data by the following macro
+ *      config                               |   Value
+ *      -------------------------------------|---------------------------
+ *      BMI160_ACCEL_FIFO_FILT_EN            |   0x80
  *
- * @param xyz_data : the vector xyz output
- * @param v_overflow_s8 : the value of overflow
- * @param v_temp_correction_u8 : the value of temperate correction enable
+ *  @note The user can enable filtered gyro data by the following macro
+ *      config                               |   Value
+ *      -------------------------------------|---------------------------
+ *      BMI160_GYRO_FIFO_FILT_EN             |   0x08
  *
+ *  @note : By ORing the above mentioned macros, the user can select
+ *  the required FIFO down config settings
  *
-  *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ *  @param[in] dev : Structure instance of bmi160_dev.
  *
+ *  @return status of bus communication result
+ *  @retval 0 -> Success
+ *  @retval Any non zero value -> Fail
  *
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_measurement_xyz_data(
-struct yas532_vector *xyz_data, u8 *v_overflow_s8, u8 v_temp_correction_u8,
-u8 v_acquisition_command_u8);
+int8_t bmi160_set_fifo_down(uint8_t fifo_down, const struct bmi160_dev *dev);
 
 /*!
- *	@brief This function is used to write the data acquisition
- *	command register in YAS532 sensor.
- *	@param v_command_reg_data_u8	:	the value of data acquisition
- *
- *	acquisition_command  |   operation
- *  ---------------------|-------------------------
- *         0x17          | turn on the acquisition coil
- *         -             | set direction of the coil
- *         _             | (x and y as minus(-))
- *         _             | Deferred acquisition mode
- *        0x07           | turn on the acquisition coil
- *         _             | set direction of the coil
- *         _             | (x and y as minus(-))
- *         _             | Normal acquisition mode
- *        0x11           | turn OFF the acquisition coil
- *         _             | set direction of the coil
- *         _             | (x and y as plus(+))
- *         _             | Deferred acquisition mode
- *       0x01            | turn OFF the acquisition coil
- *        _              | set direction of the coil
- *        _              | (x and y as plus(+))
- *        _              | Normal acquisition mode
- *
+ *  @brief This API sets the FIFO watermark level in the sensor.
  *
+ *  @note The FIFO watermark is issued when the FIFO fill level is
+ *  equal or above the watermark level and units of watermark is 4 bytes.
  *
-  *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ *  @param[in]  fifo_wm        : Variable used to set the FIFO water mark level
+ *  @param[in]  dev            : Structure instance of bmi160_dev
  *
+ *  @return Result of API execution status
+ *  @retval 0 -> Success
+ *  @retval Any non zero value -> Fail
  *
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_acquisition_command_register(
-u8 v_command_reg_data_u8);
+int8_t bmi160_set_fifo_wm(uint8_t fifo_wm, const struct bmi160_dev *dev);
+
 /*!
- *	@brief This function is used write the offset for YAS532 sensor
+ *  @brief This API parses and extracts the accelerometer frames from
+ *  FIFO data read by the "bmi160_get_fifo_data" API and stores it in
+ *  the "accel_data" structure instance.
  *
- *	@param	p_offset_s8	: The value of offset to write
+ *  @note The bmi160_extract_accel API should be called only after
+ *  reading the FIFO data by calling the bmi160_get_fifo_data() API.
  *
+ *  @param[out] accel_data    : Structure instance of bmi160_sensor_data
+ *                              where the accelerometer data in FIFO is stored.
+ *  @param[in,out] accel_length  : Number of valid accelerometer frames
+ *                              (x,y,z axes data) read out from fifo.
+ *  @param[in] dev            : Structure instance of bmi160_dev.
  *
-  *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ *  @note accel_length is updated with the number of valid accelerometer
+ *  frames extracted from fifo (1 accel frame   = 6 bytes) at the end of
+ *  execution of this API.
  *
+ *  @return Result of API execution status
+ *  @retval 0 -> Success
+ *  @retval Any non zero value -> Fail
  *
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_set_offset(
-const s8 *p_offset_s8);
+int8_t bmi160_extract_accel(struct bmi160_sensor_data *accel_data, uint8_t *accel_length, struct bmi160_dev const *dev);
+
 /*!
- *	@brief This function is used to read YAS532 sensor data
+ *  @brief This API parses and extracts the gyro frames from
+ *  FIFO data read by the "bmi160_get_fifo_data" API and stores it in
+ *  the "gyro_data" structure instance.
  *
+ *  @note The bmi160_extract_accel API should be called only after
+ *  reading the FIFO data by calling the bmi160_get_fifo_data() API.
  *
- * @param v_xy1y2_u16 : the vector xyz output
- * @param v_overflow_s8 : the value of overflow
- * @param v_temp_correction_u8 : the value of temperate correction enable
- * @param v_temp_u16 : the value of temperature
- * @param v_busy_u8 : the value denoting the sensor is busy
+ *  @param[out] gyro_data    : Structure instance of bmi160_sensor_data
+ *                             where the gyro data in FIFO is stored.
+ *  @param[in,out] gyro_length  : Number of valid gyro frames
+ *                             (x,y,z axes data) read out from fifo.
+ *  @param[in] dev           : Structure instance of bmi160_dev.
  *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval -1 -> Error
+ *  @note gyro_length is updated with the number of valid gyro
+ *  frames extracted from fifo (1 gyro frame   = 6 bytes) at the end of
+ *  execution of this API.
  *
+ *  @return Result of API execution status
+ *  @retval 0 -> Success
+ *  @retval Any non zero value -> Fail
  *
  */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_fifo_xyz_data(
-u16 *v_xy1y2_u16, u8 v_temp_correction_u8,
-s8 v_overflow_s8, u16 v_temp_u16, u8 v_busy_u8);
+int8_t bmi160_extract_gyro(struct bmi160_sensor_data *gyro_data, uint8_t *gyro_length, struct bmi160_dev const *dev);
 
+#ifdef __cplusplus
+}
 #endif
-#endif
 
+#endif /* BMI160_H_ */
+
+/** @}*/

+ 1205 - 0
bmi160_defs.h

@@ -0,0 +1,1205 @@
+/**
+ * Copyright (C) 2015 - 2016 Bosch Sensortec GmbH
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of the copyright holder nor the names of the
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
+ *
+ * The information provided is believed to be accurate and reliable.
+ * The copyright holder 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 the copyright holder.
+ *
+ * @file    bmi160_defs.h
+ * @date    13 Apr 2017
+ * @version 3.5.0
+ * @brief
+ *
+ */
+
+/*!
+ * @defgroup bmi160_defs
+ * @brief
+ * @{*/
+
+#ifndef BMI160_DEFS_H_
+#define BMI160_DEFS_H_
+
+/*************************** C types headers *****************************/
+#ifdef __KERNEL__
+#include <linux/types.h>
+#else
+#include <stdint.h>
+#include <stddef.h>
+#endif
+
+/*************************** C++ guard macro *****************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*************************** Common macros   *****************************/
+#if (LONG_MAX) > 0x7fffffff
+#define __have_long64 1
+#elif (LONG_MAX) == 0x7fffffff
+#define __have_long32 1
+#endif
+
+#if !defined(UINT8_C)
+#define INT8_C(x)       x
+#if (INT_MAX) > 0x7f
+#define UINT8_C(x)      x
+#else
+#define UINT8_C(x)      x##U
+#endif
+#endif
+
+#if !defined(UINT16_C)
+#define INT16_C(x)      x
+#if (INT_MAX) > 0x7fff
+#define UINT16_C(x)     x
+#else
+#define UINT16_C(x)     x##U
+#endif
+#endif
+
+#if !defined(INT32_C) && !defined(UINT32_C)
+#if __have_long32
+#define INT32_C(x)      x##L
+#define UINT32_C(x)     x##UL
+#else
+#define INT32_C(x)      x
+#define UINT32_C(x)     x##U
+#endif
+#endif
+
+#if !defined(INT64_C) && !defined(UINT64_C)
+#if __have_long64
+#define INT64_C(x)      x##L
+#define UINT64_C(x)     x##UL
+#else
+#define INT64_C(x)      x##LL
+#define UINT64_C(x)     x##ULL
+#endif
+#endif
+
+/*************************** Sensor macros   *****************************/
+/* Test for an endian machine */
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#define LITTLE_ENDIAN   1
+#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#define BIG_ENDIAN   1
+#else
+#error "Code does not support Endian format of the processor"
+#endif
+
+/** Mask definitions */
+#define BMI160_ACCEL_BW_MASK                    UINT8_C(0x70)
+#define BMI160_ACCEL_ODR_MASK                   UINT8_C(0x0F)
+#define BMI160_ACCEL_UNDERSAMPLING_MASK         UINT8_C(0x80)
+#define BMI160_ACCEL_RANGE_MASK                 UINT8_C(0x0F)
+#define BMI160_GYRO_BW_MASK                     UINT8_C(0x30)
+#define BMI160_GYRO_ODR_MASK                    UINT8_C(0x0F)
+#define BMI160_GYRO_RANGE_MSK                   UINT8_C(0x07)
+
+/** Mask definitions for INT_EN registers */
+#define BMI160_ANY_MOTION_X_INT_EN_MASK         UINT8_C(0x01)
+#define BMI160_HIGH_G_X_INT_EN_MASK             UINT8_C(0x01)
+#define BMI160_NO_MOTION_X_INT_EN_MASK          UINT8_C(0x01)
+#define BMI160_ANY_MOTION_Y_INT_EN_MASK         UINT8_C(0x02)
+#define BMI160_HIGH_G_Y_INT_EN_MASK             UINT8_C(0x02)
+#define BMI160_NO_MOTION_Y_INT_EN_MASK          UINT8_C(0x02)
+#define BMI160_ANY_MOTION_Z_INT_EN_MASK         UINT8_C(0x04)
+#define BMI160_HIGH_G_Z_INT_EN_MASK             UINT8_C(0x04)
+#define BMI160_NO_MOTION_Z_INT_EN_MASK          UINT8_C(0x04)
+#define BMI160_SIG_MOTION_INT_EN_MASK           UINT8_C(0x07)
+#define BMI160_ANY_MOTION_ALL_INT_EN_MASK	UINT8_C(0x07)
+#define BMI160_STEP_DETECT_INT_EN_MASK          UINT8_C(0x08)
+#define BMI160_DOUBLE_TAP_INT_EN_MASK           UINT8_C(0x10)
+#define BMI160_SINGLE_TAP_INT_EN_MASK           UINT8_C(0x20)
+#define BMI160_FIFO_FULL_INT_EN_MASK            UINT8_C(0x20)
+#define BMI160_ORIENT_INT_EN_MASK               UINT8_C(0x40)
+#define BMI160_FIFO_WATERMARK_INT_EN_MASK       UINT8_C(0x40)
+#define BMI160_LOW_G_INT_EN_MASK                UINT8_C(0x08)
+#define BMI160_STEP_DETECT_EN_MASK              UINT8_C(0x08)
+#define BMI160_FLAT_INT_EN_MASK                 UINT8_C(0x80)
+#define BMI160_DATA_RDY_INT_EN_MASK             UINT8_C(0x10)
+
+/** Mask definitions for INT_OUT_CTRL register */
+#define BMI160_INT1_EDGE_CTRL_MASK              UINT8_C(0x01)
+#define BMI160_INT1_OUTPUT_MODE_MASK            UINT8_C(0x04)
+#define BMI160_INT1_OUTPUT_TYPE_MASK            UINT8_C(0x02)
+#define BMI160_INT1_OUTPUT_EN_MASK              UINT8_C(0x08)
+#define BMI160_INT2_EDGE_CTRL_MASK              UINT8_C(0x10)
+#define BMI160_INT2_OUTPUT_MODE_MASK            UINT8_C(0x40)
+#define BMI160_INT2_OUTPUT_TYPE_MASK            UINT8_C(0x20)
+#define BMI160_INT2_OUTPUT_EN_MASK              UINT8_C(0x80)
+
+/** Mask definitions for INT_LATCH register */
+#define BMI160_INT1_INPUT_EN_MASK               UINT8_C(0x10)
+#define BMI160_INT2_INPUT_EN_MASK               UINT8_C(0x20)
+#define BMI160_INT_LATCH_MASK                   UINT8_C(0x0F)
+
+/** Mask definitions for INT_MAP register */
+#define BMI160_INT1_LOW_G_MASK                  UINT8_C(0x01)
+#define BMI160_INT1_HIGH_G_MASK                 UINT8_C(0x02)
+#define BMI160_INT1_SLOPE_MASK                  UINT8_C(0x04)
+#define BMI160_INT1_NO_MOTION_MASK              UINT8_C(0x08)
+#define BMI160_INT1_DOUBLE_TAP_MASK             UINT8_C(0x10)
+#define BMI160_INT1_SINGLE_TAP_MASK             UINT8_C(0x20)
+#define BMI160_INT1_FIFO_FULL_MASK              UINT8_C(0x20)
+#define BMI160_INT1_FIFO_WM_MASK		UINT8_C(0x40)
+#define BMI160_INT1_ORIENT_MASK                 UINT8_C(0x40)
+#define BMI160_INT1_FLAT_MASK                   UINT8_C(0x80)
+#define BMI160_INT1_DATA_READY_MASK             UINT8_C(0x80)
+#define BMI160_INT2_LOW_G_MASK                  UINT8_C(0x01)
+#define BMI160_INT1_LOW_STEP_DETECT_MASK        UINT8_C(0x01)
+#define BMI160_INT2_LOW_STEP_DETECT_MASK        UINT8_C(0x01)
+#define BMI160_INT2_HIGH_G_MASK                 UINT8_C(0x02)
+#define BMI160_INT2_FIFO_FULL_MASK              UINT8_C(0x02)
+#define BMI160_INT2_FIFO_WM_MASK		UINT8_C(0x04)
+#define BMI160_INT2_SLOPE_MASK                  UINT8_C(0x04)
+#define BMI160_INT2_DATA_READY_MASK             UINT8_C(0x08)
+#define BMI160_INT2_NO_MOTION_MASK              UINT8_C(0x08)
+#define BMI160_INT2_DOUBLE_TAP_MASK             UINT8_C(0x10)
+#define BMI160_INT2_SINGLE_TAP_MASK             UINT8_C(0x20)
+#define BMI160_INT2_ORIENT_MASK                 UINT8_C(0x40)
+#define BMI160_INT2_FLAT_MASK                   UINT8_C(0x80)
+
+/** Mask definitions for INT_DATA register */
+#define BMI160_TAP_SRC_INT_MASK                 UINT8_C(0x08)
+#define BMI160_LOW_HIGH_SRC_INT_MASK            UINT8_C(0x80)
+#define BMI160_MOTION_SRC_INT_MASK              UINT8_C(0x80)
+
+/** Mask definitions for INT_MOTION register */
+#define BMI160_SLOPE_INT_DUR_MASK               UINT8_C(0x03)
+#define BMI160_NO_MOTION_INT_DUR_MASK           UINT8_C(0xFC)
+#define BMI160_NO_MOTION_SEL_BIT_MASK           UINT8_C(0x01)
+
+/** Mask definitions for INT_TAP register */
+#define BMI160_TAP_DUR_MASK                     UINT8_C(0x07)
+#define BMI160_TAP_SHOCK_DUR_MASK               UINT8_C(0x40)
+#define BMI160_TAP_QUIET_DUR_MASK               UINT8_C(0x80)
+#define BMI160_TAP_THRES_MASK                   UINT8_C(0x1F)
+
+/** Mask definitions for INT_FLAT register */
+#define BMI160_FLAT_THRES_MASK                  UINT8_C(0x3F)
+#define BMI160_FLAT_HOLD_TIME_MASK              UINT8_C(0x30)
+#define BMI160_FLAT_HYST_MASK                   UINT8_C(0x07)
+
+/** Mask definitions for INT_LOWHIGH register */
+#define BMI160_LOW_G_HYST_MASK                  UINT8_C(0x03)
+#define BMI160_LOW_G_LOW_MODE_MASK              UINT8_C(0x04)
+#define BMI160_HIGH_G_HYST_MASK                 UINT8_C(0xC0)
+
+/** Mask definitions for INT_SIG_MOTION register */
+#define BMI160_SIG_MOTION_SEL_MASK              UINT8_C(0x02)
+#define BMI160_SIG_MOTION_SKIP_MASK             UINT8_C(0x0C)
+#define BMI160_SIG_MOTION_PROOF_MASK            UINT8_C(0x30)
+
+/** Mask definitions for INT_ORIENT register */
+#define BMI160_ORIENT_MODE_MASK                 UINT8_C(0x03)
+#define BMI160_ORIENT_BLOCK_MASK                UINT8_C(0x0C)
+#define BMI160_ORIENT_HYST_MASK                 UINT8_C(0xF0)
+#define BMI160_ORIENT_THETA_MASK                UINT8_C(0x3F)
+#define BMI160_ORIENT_UD_ENABLE                 UINT8_C(0x40)
+#define BMI160_AXES_EN_MASK                     UINT8_C(0x80)
+
+/** Mask definitions for FIFO_CONFIG register */
+#define BMI160_FIFO_GYRO			UINT8_C(0x80)
+#define BMI160_FIFO_ACCEL			UINT8_C(0x40)
+#define BMI160_FIFO_AUX				UINT8_C(0x20)
+#define BMI160_FIFO_TAG_INT1			UINT8_C(0x08)
+#define BMI160_FIFO_TAG_INT2			UINT8_C(0x04)
+#define BMI160_FIFO_TIME			UINT8_C(0x02)
+#define BMI160_FIFO_HEADER			UINT8_C(0x10)
+#define BMI160_FIFO_CONFIG_1_MASK               UINT8_C(0xFE)
+
+
+/** Mask definitions for STEP_CONF register */
+#define BMI160_STEP_COUNT_EN_BIT_MASK           UINT8_C(0x08)
+#define BMI160_STEP_DETECT_MIN_THRES_MASK       UINT8_C(0x18)
+#define BMI160_STEP_DETECT_STEPTIME_MIN_MASK    UINT8_C(0x07)
+#define BMI160_STEP_MIN_BUF_MASK                UINT8_C(0x07)
+
+/** Mask definition for FIFO Header Data Tag */
+#define BMI160_FIFO_TAG_INTR_MASK               UINT8_C(0xFC)
+
+/** Fifo byte counter mask definitions */
+#define BMI160_FIFO_BYTE_COUNTER_MASK           UINT8_C(0x07)
+
+/** Enable/disable bit value */
+#define BMI160_ENABLE                           UINT8_C(0x01)
+#define BMI160_DISABLE                          UINT8_C(0x00)
+
+/** Latch Duration */
+#define BMI160_LATCH_DUR_NONE                   UINT8_C(0x00)
+#define BMI160_LATCH_DUR_312_5_MICRO_SEC        UINT8_C(0x01)
+#define BMI160_LATCH_DUR_625_MICRO_SEC          UINT8_C(0x02)
+#define BMI160_LATCH_DUR_1_25_MILLI_SEC         UINT8_C(0x03)
+#define BMI160_LATCH_DUR_2_5_MILLI_SEC          UINT8_C(0x04)
+#define BMI160_LATCH_DUR_5_MILLI_SEC            UINT8_C(0x05)
+#define BMI160_LATCH_DUR_10_MILLI_SEC           UINT8_C(0x06)
+#define BMI160_LATCH_DUR_20_MILLI_SEC           UINT8_C(0x07)
+#define BMI160_LATCH_DUR_40_MILLI_SEC           UINT8_C(0x08)
+#define BMI160_LATCH_DUR_80_MILLI_SEC           UINT8_C(0x09)
+#define BMI160_LATCH_DUR_160_MILLI_SEC          UINT8_C(0x0A)
+#define BMI160_LATCH_DUR_320_MILLI_SEC          UINT8_C(0x0B)
+#define BMI160_LATCH_DUR_640_MILLI_SEC          UINT8_C(0x0C)
+#define BMI160_LATCH_DUR_1_28_SEC               UINT8_C(0x0D)
+#define BMI160_LATCH_DUR_2_56_SEC               UINT8_C(0x0E)
+#define BMI160_LATCHED                          UINT8_C(0x0F)
+
+/** BMI160 Register map */
+#define BMI160_CHIP_ID_ADDR		UINT8_C(0x00)
+#define BMI160_ERROR_REG_ADDR		UINT8_C(0x02)
+#define BMI160_AUX_DATA_ADDR		UINT8_C(0x04)
+#define BMI160_GYRO_DATA_ADDR		UINT8_C(0x0C)
+#define BMI160_ACCEL_DATA_ADDR		UINT8_C(0x12)
+#define BMI160_STATUS_ADDR		UINT8_C(0x1B)
+#define BMI160_FIFO_LENGTH_ADDR		UINT8_C(0x22)
+#define BMI160_FIFO_DATA_ADDR		UINT8_C(0x24)
+#define BMI160_ACCEL_CONFIG_ADDR	UINT8_C(0x40)
+#define BMI160_ACCEL_RANGE_ADDR		UINT8_C(0x41)
+#define BMI160_GYRO_CONFIG_ADDR		UINT8_C(0x42)
+#define BMI160_GYRO_RANGE_ADDR		UINT8_C(0x43)
+#define BMI160_AUX_ODR_ADDR		UINT8_C(0x44)
+#define BMI160_FIFO_DOWN_ADDR           UINT8_C(0x45)
+#define BMI160_FIFO_CONFIG_0_ADDR       UINT8_C(0x46)
+#define BMI160_FIFO_CONFIG_1_ADDR       UINT8_C(0x47)
+#define BMI160_AUX_IF_0_ADDR		UINT8_C(0x4B)
+#define BMI160_AUX_IF_1_ADDR		UINT8_C(0x4C)
+#define BMI160_AUX_IF_2_ADDR		UINT8_C(0x4D)
+#define BMI160_AUX_IF_3_ADDR		UINT8_C(0x4E)
+#define BMI160_AUX_IF_4_ADDR		UINT8_C(0x4F)
+
+#define BMI160_INT_ENABLE_0_ADDR         UINT8_C(0x50)
+#define BMI160_INT_ENABLE_1_ADDR         UINT8_C(0x51)
+#define BMI160_INT_ENABLE_2_ADDR         UINT8_C(0x52)
+#define BMI160_INT_OUT_CTRL_ADDR         UINT8_C(0x53)
+#define BMI160_INT_LATCH_ADDR            UINT8_C(0x54)
+#define BMI160_INT_MAP_0_ADDR            UINT8_C(0x55)
+#define BMI160_INT_MAP_1_ADDR            UINT8_C(0x56)
+#define BMI160_INT_MAP_2_ADDR            UINT8_C(0x57)
+#define BMI160_INT_DATA_0_ADDR           UINT8_C(0x58)
+#define BMI160_INT_DATA_1_ADDR           UINT8_C(0x59)
+#define BMI160_INT_LOWHIGH_0_ADDR        UINT8_C(0x5A)
+#define BMI160_INT_LOWHIGH_1_ADDR        UINT8_C(0x5B)
+#define BMI160_INT_LOWHIGH_2_ADDR        UINT8_C(0x5C)
+#define BMI160_INT_LOWHIGH_3_ADDR        UINT8_C(0x5D)
+#define BMI160_INT_LOWHIGH_4_ADDR        UINT8_C(0x5E)
+#define BMI160_INT_MOTION_0_ADDR         UINT8_C(0x5F)
+#define BMI160_INT_MOTION_1_ADDR         UINT8_C(0x60)
+#define BMI160_INT_MOTION_2_ADDR         UINT8_C(0x61)
+#define BMI160_INT_MOTION_3_ADDR         UINT8_C(0x62)
+#define BMI160_INT_TAP_0_ADDR            UINT8_C(0x63)
+#define BMI160_INT_TAP_1_ADDR            UINT8_C(0x64)
+#define BMI160_INT_ORIENT_0_ADDR         UINT8_C(0x65)
+#define BMI160_INT_ORIENT_1_ADDR         UINT8_C(0x66)
+#define BMI160_INT_FLAT_0_ADDR           UINT8_C(0x67)
+#define BMI160_INT_FLAT_1_ADDR           UINT8_C(0x68)
+#define BMI160_IF_CONF_ADDR		 UINT8_C(0x6B)
+#define BMI160_SELF_TEST_ADDR		 UINT8_C(0x6D)
+#define BMI160_INT_STEP_CNT_0_ADDR	 UINT8_C(0x78)
+#define BMI160_INT_STEP_CONFIG_0_ADDR    UINT8_C(0x7A)
+#define BMI160_INT_STEP_CONFIG_1_ADDR    UINT8_C(0x7B)
+#define BMI160_COMMAND_REG_ADDR		 UINT8_C(0x7E)
+#define BMI160_SPI_COMM_TEST_ADDR        UINT8_C(0x7F)
+#define BMI160_INTL_PULLUP_CONF_ADDR	 UINT8_C(0x85)
+
+/** Error code definitions */
+#define BMI160_OK                         INT8_C(0)
+#define BMI160_E_NULL_PTR                 INT8_C(-1)
+#define BMI160_E_COM_FAIL                 INT8_C(-2)
+#define BMI160_E_DEV_NOT_FOUND            INT8_C(-3)
+#define BMI160_E_OUT_OF_RANGE             INT8_C(-4)
+#define BMI160_E_INVALID_INPUT            INT8_C(-5)
+#define BMI160_E_ACCEL_ODR_BW_INVALID	  INT8_C(-6)
+#define BMI160_E_GYRO_ODR_BW_INVALID	  INT8_C(-7)
+#define BMI160_E_LWP_PRE_FLTR_INT_INVALID INT8_C(-8)
+#define BMI160_E_LWP_PRE_FLTR_INVALID	  INT8_C(-9)
+#define BMI160_E_AUX_NOT_FOUND		  INT8_C(-10)
+
+/**\name API warning codes */
+#define BMI160_W_GYRO_SELF_TEST_FAIL	INT8_C(1)
+#define BMI160_W_ACCEl_SELF_TEST_FAIL	INT8_C(2)
+
+/** BMI160 unique chip identifier */
+#define BMI160_CHIP_ID                   UINT8_C(0xD1)
+
+/** Soft reset command */
+#define BMI160_SOFT_RESET_CMD            UINT8_C(0xb6)
+#define BMI160_SOFT_RESET_DELAY_MS       UINT8_C(15)
+
+/* Delay in ms settings */
+#define BMI160_ACCEL_DELAY_MS            UINT8_C(5)
+#define BMI160_GYRO_DELAY_MS             UINT8_C(81)
+#define BMI160_ONE_MS_DELAY              UINT8_C(1)
+#define BMI160_AUX_COM_DELAY		 UINT8_C(10)
+#define BMI160_GYRO_SELF_TEST_DELAY	 UINT8_C(20)
+#define BMI160_ACCEL_SELF_TEST_DELAY	 UINT8_C(50)
+
+/** Self test configurations */
+#define BMI160_ACCEL_SELF_TEST_CONFIG		UINT8_C(0x2C)
+#define BMI160_ACCEL_SELF_TEST_POSITIVE_EN	UINT8_C(0x0D)
+#define BMI160_ACCEL_SELF_TEST_NEGATIVE_EN	UINT8_C(0x09)
+#define BMI160_ACCEL_SELF_TEST_LIMIT		UINT16_C(8192)
+
+/** Power mode settings */
+/* Accel power mode */
+#define BMI160_ACCEL_NORMAL_MODE         UINT8_C(0x11)
+#define BMI160_ACCEL_LOWPOWER_MODE       UINT8_C(0x12)
+#define BMI160_ACCEL_SUSPEND_MODE        UINT8_C(0x10)
+
+/* Gyro power mode */
+#define BMI160_GYRO_SUSPEND_MODE         UINT8_C(0x14)
+#define BMI160_GYRO_NORMAL_MODE          UINT8_C(0x15)
+#define BMI160_GYRO_FASTSTARTUP_MODE     UINT8_C(0x17)
+
+/* Aux power mode */
+#define BMI160_AUX_SUSPEND_MODE		UINT8_C(0x18)
+#define BMI160_AUX_NORMAL_MODE		UINT8_C(0x19)
+#define BMI160_AUX_LOWPOWER_MODE	UINT8_C(0x1A)
+
+/** Range settings */
+/* Accel Range */
+#define BMI160_ACCEL_RANGE_2G            UINT8_C(0x03)
+#define BMI160_ACCEL_RANGE_4G            UINT8_C(0x05)
+#define BMI160_ACCEL_RANGE_8G            UINT8_C(0x08)
+#define BMI160_ACCEL_RANGE_16G           UINT8_C(0x0C)
+
+/* Gyro Range */
+#define BMI160_GYRO_RANGE_2000_DPS       UINT8_C(0x00)
+#define BMI160_GYRO_RANGE_1000_DPS       UINT8_C(0x01)
+#define BMI160_GYRO_RANGE_500_DPS        UINT8_C(0x02)
+#define BMI160_GYRO_RANGE_250_DPS        UINT8_C(0x03)
+#define BMI160_GYRO_RANGE_125_DPS        UINT8_C(0x04)
+
+/** Bandwidth settings */
+/* Accel Bandwidth */
+#define BMI160_ACCEL_BW_OSR4_AVG1        UINT8_C(0x00)
+#define BMI160_ACCEL_BW_OSR2_AVG2        UINT8_C(0x01)
+#define BMI160_ACCEL_BW_NORMAL_AVG4      UINT8_C(0x02)
+#define BMI160_ACCEL_BW_CIC_AVG8         UINT8_C(0x03)
+#define BMI160_ACCEL_BW_RES_AVG16        UINT8_C(0x04)
+#define BMI160_ACCEL_BW_RES_AVG32        UINT8_C(0x05)
+#define BMI160_ACCEL_BW_RES_AVG64        UINT8_C(0x06)
+#define BMI160_ACCEL_BW_RES_AVG128       UINT8_C(0x07)
+
+#define BMI160_GYRO_BW_OSR4_MODE         UINT8_C(0x00)
+#define BMI160_GYRO_BW_OSR2_MODE         UINT8_C(0x01)
+#define BMI160_GYRO_BW_NORMAL_MODE       UINT8_C(0x02)
+#define BMI160_GYRO_BW_CIC_MODE          UINT8_C(0x03)
+
+/* Output Data Rate settings */
+/* Accel Output data rate */
+#define BMI160_ACCEL_ODR_RESERVED        UINT8_C(0x00)
+#define BMI160_ACCEL_ODR_0_78HZ          UINT8_C(0x01)
+#define BMI160_ACCEL_ODR_1_56HZ          UINT8_C(0x02)
+#define BMI160_ACCEL_ODR_3_12HZ          UINT8_C(0x03)
+#define BMI160_ACCEL_ODR_6_25HZ          UINT8_C(0x04)
+#define BMI160_ACCEL_ODR_12_5HZ          UINT8_C(0x05)
+#define BMI160_ACCEL_ODR_25HZ            UINT8_C(0x06)
+#define BMI160_ACCEL_ODR_50HZ            UINT8_C(0x07)
+#define BMI160_ACCEL_ODR_100HZ           UINT8_C(0x08)
+#define BMI160_ACCEL_ODR_200HZ           UINT8_C(0x09)
+#define BMI160_ACCEL_ODR_400HZ           UINT8_C(0x0A)
+#define BMI160_ACCEL_ODR_800HZ           UINT8_C(0x0B)
+#define BMI160_ACCEL_ODR_1600HZ          UINT8_C(0x0C)
+#define BMI160_ACCEL_ODR_RESERVED0       UINT8_C(0x0D)
+#define BMI160_ACCEL_ODR_RESERVED1       UINT8_C(0x0E)
+#define BMI160_ACCEL_ODR_RESERVED2       UINT8_C(0x0F)
+
+/* Gyro Output data rate */
+#define BMI160_GYRO_ODR_RESERVED         UINT8_C(0x00)
+#define BMI160_GYRO_ODR_25HZ             UINT8_C(0x06)
+#define BMI160_GYRO_ODR_50HZ             UINT8_C(0x07)
+#define BMI160_GYRO_ODR_100HZ            UINT8_C(0x08)
+#define BMI160_GYRO_ODR_200HZ            UINT8_C(0x09)
+#define BMI160_GYRO_ODR_400HZ            UINT8_C(0x0A)
+#define BMI160_GYRO_ODR_800HZ            UINT8_C(0x0B)
+#define BMI160_GYRO_ODR_1600HZ           UINT8_C(0x0C)
+#define BMI160_GYRO_ODR_3200HZ           UINT8_C(0x0D)
+
+/* Auxiliary sensor Output data rate */
+#define BMI160_AUX_ODR_RESERVED        UINT8_C(0x00)
+#define BMI160_AUX_ODR_0_78HZ          UINT8_C(0x01)
+#define BMI160_AUX_ODR_1_56HZ          UINT8_C(0x02)
+#define BMI160_AUX_ODR_3_12HZ          UINT8_C(0x03)
+#define BMI160_AUX_ODR_6_25HZ          UINT8_C(0x04)
+#define BMI160_AUX_ODR_12_5HZ          UINT8_C(0x05)
+#define BMI160_AUX_ODR_25HZ            UINT8_C(0x06)
+#define BMI160_AUX_ODR_50HZ            UINT8_C(0x07)
+#define BMI160_AUX_ODR_100HZ           UINT8_C(0x08)
+#define BMI160_AUX_ODR_200HZ           UINT8_C(0x09)
+#define BMI160_AUX_ODR_400HZ           UINT8_C(0x0A)
+#define BMI160_AUX_ODR_800HZ           UINT8_C(0x0B)
+
+/* Maximum limits definition */
+#define BMI160_ACCEL_ODR_MAX             UINT8_C(15)
+#define BMI160_ACCEL_BW_MAX              UINT8_C(2)
+#define BMI160_ACCEL_RANGE_MAX           UINT8_C(12)
+#define BMI160_GYRO_ODR_MAX              UINT8_C(13)
+#define BMI160_GYRO_BW_MAX               UINT8_C(2)
+#define BMI160_GYRO_RANGE_MAX            UINT8_C(4)
+
+/** FIFO_CONFIG Definitions */
+#define BMI160_FIFO_TIME_ENABLE          UINT8_C(0x02)
+#define BMI160_FIFO_TAG_INT2_ENABLE      UINT8_C(0x04)
+#define BMI160_FIFO_TAG_INT1_ENABLE      UINT8_C(0x08)
+#define BMI160_FIFO_HEAD_ENABLE          UINT8_C(0x10)
+#define BMI160_FIFO_M_ENABLE             UINT8_C(0x20)
+#define BMI160_FIFO_A_ENABLE             UINT8_C(0x40)
+#define BMI160_FIFO_M_A_ENABLE           UINT8_C(0x60)
+#define BMI160_FIFO_G_ENABLE             UINT8_C(0x80)
+#define BMI160_FIFO_M_G_ENABLE           UINT8_C(0xA0)
+#define BMI160_FIFO_G_A_ENABLE           UINT8_C(0xC0)
+#define BMI160_FIFO_M_G_A_ENABLE         UINT8_C(0xE0)
+
+
+/* Accel, gyro and aux. sensor length and also their combined
+ * length definitions in FIFO */
+#define BMI160_FIFO_G_LENGTH             UINT8_C(6)
+#define BMI160_FIFO_A_LENGTH             UINT8_C(6)
+#define BMI160_FIFO_M_LENGTH             UINT8_C(8)
+#define BMI160_FIFO_GA_LENGTH            UINT8_C(12)
+#define BMI160_FIFO_MA_LENGTH            UINT8_C(14)
+#define BMI160_FIFO_MG_LENGTH            UINT8_C(14)
+#define BMI160_FIFO_MGA_LENGTH           UINT8_C(20)
+
+
+/** FIFO Header Data definitions */
+#define BMI160_FIFO_HEAD_SKIP_FRAME      UINT8_C(0x40)
+#define BMI160_FIFO_HEAD_SENSOR_TIME     UINT8_C(0x44)
+#define BMI160_FIFO_HEAD_INPUT_CONFIG    UINT8_C(0x48)
+#define BMI160_FIFO_HEAD_OVER_READ       UINT8_C(0x80)
+#define BMI160_FIFO_HEAD_A               UINT8_C(0x84)
+#define BMI160_FIFO_HEAD_G               UINT8_C(0x88)
+#define BMI160_FIFO_HEAD_G_A             UINT8_C(0x8C)
+#define BMI160_FIFO_HEAD_M               UINT8_C(0x90)
+#define BMI160_FIFO_HEAD_M_A             UINT8_C(0x94)
+#define BMI160_FIFO_HEAD_M_G             UINT8_C(0x98)
+#define BMI160_FIFO_HEAD_M_G_A           UINT8_C(0x9C)
+
+
+/** FIFO sensor time length definitions */
+#define BMI160_SENSOR_TIME_LENGTH        UINT8_C(3)
+
+
+/** FIFO DOWN selection */
+/* Accel fifo down-sampling values*/
+#define  BMI160_ACCEL_FIFO_DOWN_ZERO     UINT8_C(0x00)
+#define  BMI160_ACCEL_FIFO_DOWN_ONE      UINT8_C(0x10)
+#define  BMI160_ACCEL_FIFO_DOWN_TWO      UINT8_C(0x20)
+#define  BMI160_ACCEL_FIFO_DOWN_THREE    UINT8_C(0x30)
+#define  BMI160_ACCEL_FIFO_DOWN_FOUR     UINT8_C(0x40)
+#define  BMI160_ACCEL_FIFO_DOWN_FIVE     UINT8_C(0x50)
+#define  BMI160_ACCEL_FIFO_DOWN_SIX      UINT8_C(0x60)
+#define  BMI160_ACCEL_FIFO_DOWN_SEVEN    UINT8_C(0x70)
+
+/* Gyro fifo down-smapling values*/
+#define  BMI160_GYRO_FIFO_DOWN_ZERO      UINT8_C(0x00)
+#define  BMI160_GYRO_FIFO_DOWN_ONE       UINT8_C(0x01)
+#define  BMI160_GYRO_FIFO_DOWN_TWO       UINT8_C(0x02)
+#define  BMI160_GYRO_FIFO_DOWN_THREE     UINT8_C(0x03)
+#define  BMI160_GYRO_FIFO_DOWN_FOUR      UINT8_C(0x04)
+#define  BMI160_GYRO_FIFO_DOWN_FIVE      UINT8_C(0x05)
+#define  BMI160_GYRO_FIFO_DOWN_SIX       UINT8_C(0x06)
+#define  BMI160_GYRO_FIFO_DOWN_SEVEN     UINT8_C(0x07)
+
+/* Accel Fifo filter enable*/
+#define  BMI160_ACCEL_FIFO_FILT_EN       UINT8_C(0x80)
+
+/* Gyro Fifo filter enable*/
+#define  BMI160_GYRO_FIFO_FILT_EN        UINT8_C(0x08)
+
+/** Definitions to check validity of FIFO frames */
+#define FIFO_CONFIG_MSB_CHECK            UINT8_C(0x80)
+#define FIFO_CONFIG_LSB_CHECK            UINT8_C(0x00)
+
+/** Array Parameter DefinItions */
+#define BMI160_SENSOR_TIME_LSB_BYTE      UINT8_C(0)
+#define BMI160_SENSOR_TIME_XLSB_BYTE     UINT8_C(1)
+#define BMI160_SENSOR_TIME_MSB_BYTE      UINT8_C(2)
+
+
+/** Interface settings */
+#define BMI160_SPI_INTF                  UINT8_C(1)
+#define BMI160_I2C_INTF                  UINT8_C(0)
+#define BMI160_SPI_RD_MASK               UINT8_C(0x80)
+#define BMI160_SPI_WR_MASK               UINT8_C(0x7F)
+
+/* Sensor & time select definition*/
+#define BMI160_ACCEL_SEL		UINT8_C(0x01)
+#define BMI160_GYRO_SEL			UINT8_C(0x02)
+#define BMI160_TIME_SEL			UINT8_C(0x04)
+
+/* Sensor select mask*/
+#define BMI160_SEN_SEL_MASK		UINT8_C(0x07)
+
+/* Error code mask */
+#define BMI160_ERR_REG_MASK		UINT8_C(0x0F)
+
+/* BMI160 I2C address */
+#define BMI160_I2C_ADDR                 UINT8_C(0x68)
+
+/* BMI160 secondary IF address */
+#define BMI160_AUX_BMM150_I2C_ADDR		UINT8_C(0x10)
+
+/** BMI160 Length definitions */
+#define BMI160_ONE                       UINT8_C(1)
+#define BMI160_TWO                       UINT8_C(2)
+#define BMI160_THREE                     UINT8_C(3)
+#define BMI160_FOUR                      UINT8_C(4)
+#define BMI160_FIVE                      UINT8_C(5)
+
+/** BMI160 fifo level Margin */
+#define BMI160_FIFO_LEVEL_MARGIN         UINT8_C(16)
+
+/** BMI160 fifo flush Command */
+#define BMI160_FIFO_FLUSH_VALUE          UINT8_C(0xB0)
+
+/** BMI160 fifo full interrupt position and mask */
+#define	BMI160_FIFO_FULL_INT_POS	UINT8_C(5)
+#define	BMI160_FIFO_FULL_INT_MSK	UINT8_C(0x20)
+#define	BMI160_FIFO_WTM_INT_POS		UINT8_C(6)
+#define	BMI160_FIFO_WTM_INT_MSK		UINT8_C(0x40)
+
+#define BMI160_FIFO_FULL_INT_PIN1_POS	UINT8_C(5)
+#define	BMI160_FIFO_FULL_INT_PIN1_MSK	UINT8_C(0x20)
+#define BMI160_FIFO_FULL_INT_PIN2_POS	UINT8_C(1)
+#define	BMI160_FIFO_FULL_INT_PIN2_MSK	UINT8_C(0x02)
+
+#define BMI160_FIFO_WTM_INT_PIN1_POS	UINT8_C(6)
+#define	BMI160_FIFO_WTM_INT_PIN1_MSK	UINT8_C(0x40)
+#define BMI160_FIFO_WTM_INT_PIN2_POS	UINT8_C(2)
+#define	BMI160_FIFO_WTM_INT_PIN2_MSK	UINT8_C(0x04)
+
+#define BMI160_MANUAL_MODE_EN_POS	UINT8_C(7)
+#define BMI160_MANUAL_MODE_EN_MSK	UINT8_C(0x80)
+#define BMI160_AUX_READ_BURST_POS	UINT8_C(0)
+#define BMI160_AUX_READ_BURST_MSK	UINT8_C(0x03)
+
+#define BMI160_GYRO_SELF_TEST_POS	UINT8_C(4)
+#define BMI160_GYRO_SELF_TEST_MSK	UINT8_C(0x10)
+#define BMI160_GYRO_SELF_TEST_STATUS_POS	UINT8_C(1)
+#define BMI160_GYRO_SELF_TEST_STATUS_MSK	UINT8_C(0x02)
+
+
+/* BIT SLICE GET AND SET FUNCTIONS */
+#define	BMI160_GET_BITS(regvar, bitname)\
+		((regvar & bitname##_MSK) >> bitname##_POS)
+#define	BMI160_SET_BITS(regvar, bitname, val)\
+		((regvar & ~bitname##_MSK) | \
+		((val<<bitname##_POS)&bitname##_MSK))
+
+#define BMI160_SET_BITS_POS_0(reg_data, bitname, data) \
+				((reg_data & ~(bitname##_MSK)) | \
+				(data & bitname##_MSK))
+
+#define BMI160_GET_BITS_POS_0(reg_data, bitname)  (reg_data & (bitname##_MSK))
+
+/*****************************************************************************/
+/* type definitions */
+typedef int8_t (*bmi160_com_fptr_t)(uint8_t dev_addr, uint8_t reg_addr,
+		uint8_t *data, uint16_t len);
+
+typedef void (*bmi160_delay_fptr_t)(uint32_t period);
+
+/*************************** Data structures *********************************/
+
+/*!
+ * @brief bmi160 sensor data structure which comprises of accel data
+ */
+struct bmi160_sensor_data {
+	/*! X-axis sensor data */
+	int16_t x;
+	/*! Y-axis sensor data */
+	int16_t y;
+	/*! Z-axis sensor data */
+	int16_t z;
+	/*! sensor time */
+	uint32_t sensortime;
+};
+
+/*!
+ * @brief FIFO aux. sensor data structure
+ */
+struct bmi160_aux_fifo_data {
+	/*! The value of aux. sensor x LSB data */
+	uint8_t aux_x_lsb;
+	/*! The value of aux. sensor x MSB data */
+	uint8_t aux_x_msb;
+	/*! The value of aux. sensor y LSB data */
+	uint8_t aux_y_lsb;
+	/*! The value of aux. sensor y MSB data */
+	uint8_t aux_y_msb;
+	/*! The value of aux. sensor z LSB data */
+	uint8_t aux_z_lsb;
+	/*! The value of aux. sensor z MSB data */
+	uint8_t aux_z_msb;
+	/*! The value of aux. sensor r for BMM150 LSB data */
+	uint8_t aux_r_y2_lsb;
+	/*! The value of aux. sensor r for BMM150 MSB data */
+	uint8_t aux_r_y2_msb;
+};
+
+/*!
+ * @brief bmi160 sensor select structure
+ */
+enum bmi160_select_sensor {
+	BMI160_ACCEL_ONLY = 1,
+	BMI160_GYRO_ONLY,
+	BMI160_BOTH_ACCEL_AND_GYRO
+};
+
+/*!
+ * @brief bmi160 sensor step detector mode structure
+ */
+enum bmi160_step_detect_mode {
+	BMI160_STEP_DETECT_NORMAL,
+	BMI160_STEP_DETECT_SENSITIVE,
+	BMI160_STEP_DETECT_ROBUST,
+	/*! Non recommended User defined setting */
+	BMI160_STEP_DETECT_USER_DEFINE
+};
+
+/*!
+ * @brief enum for auxiliary burst read selection
+ */
+enum bm160_aux_read_len {
+	BMI160_AUX_READ_LEN_0,
+	BMI160_AUX_READ_LEN_1,
+	BMI160_AUX_READ_LEN_2,
+	BMI160_AUX_READ_LEN_3
+};
+/*!
+ * @brief bmi160 sensor configuration structure
+ */
+struct bmi160_cfg {
+	/*! power mode */
+	uint8_t power;
+	/*! output data rate */
+	uint8_t odr;
+	/*! range */
+	uint8_t range;
+	/*! bandwidth */
+	uint8_t bw;
+};
+
+/*!
+ * @brief Aux sensor configuration structure
+ */
+struct bmi160_aux_cfg {
+	/*! Aux sensor, 1 - enable 0 - disable */
+	uint8_t aux_sensor_enable : 1;
+	/*! Aux manual/auto mode status */
+	uint8_t manual_enable : 1;
+	/*! Aux read burst length */
+	uint8_t aux_rd_burst_len : 2;
+	/*! output data rate */
+	uint8_t aux_odr :4;
+	/*! i2c addr of auxiliary sensor */
+	uint8_t aux_i2c_addr;
+};
+/*!
+ * @brief bmi160 interrupt channel selection structure
+ */
+enum bmi160_int_channel {
+	/*! interrupt Channel 1 */
+	BMI160_INT_CHANNEL_1,
+	/*! interrupt Channel 2 */
+	BMI160_INT_CHANNEL_2
+};
+
+enum bmi160_int_types {
+	/*! Slope/Any-motion interrupt */
+	BMI160_ACC_ANY_MOTION_INT,
+	/*! Significant motion interrupt */
+	BMI160_ACC_SIG_MOTION_INT,
+	/*! Step detector interrupt */
+	BMI160_STEP_DETECT_INT,
+	/*! double tap interrupt */
+	BMI160_ACC_DOUBLE_TAP_INT,
+	/*! single tap interrupt */
+	BMI160_ACC_SINGLE_TAP_INT,
+	/*! orientation interrupt */
+	BMI160_ACC_ORIENT_INT,
+	/*! flat interrupt */
+	BMI160_ACC_FLAT_INT,
+	/*! high-g interrupt */
+	BMI160_ACC_HIGH_G_INT,
+	/*! low-g interrupt */
+	BMI160_ACC_LOW_G_INT,
+	/*! slow/no-motion interrupt */
+	BMI160_ACC_SLOW_NO_MOTION_INT,
+	/*! data ready interrupt  */
+	BMI160_ACC_GYRO_DATA_RDY_INT,
+	/*! fifo full interrupt */
+	BMI160_ACC_GYRO_FIFO_FULL_INT,
+	/*! fifo watermark interrupt */
+	BMI160_ACC_GYRO_FIFO_WATERMARK_INT
+};
+
+/*!
+ * @brief bmi160 active state of any & sig motion interrupt.
+ */
+enum bmi160_any_sig_motion_active_interrupt_state {
+	/*! Both any & sig motion are disabled */
+	BMI160_BOTH_ANY_SIG_MOTION_DISABLED = -1,
+	/*! Any-motion selected */
+	BMI160_ANY_MOTION_ENABLED,
+	/*! Sig-motion selected */
+	BMI160_SIG_MOTION_ENABLED
+};
+
+struct bmi160_acc_tap_int_cfg {
+#if LITTLE_ENDIAN == 1
+	/*! tap threshold */
+	uint16_t tap_thr :5;
+	/*! tap shock */
+	uint16_t tap_shock :1;
+	/*! tap quiet */
+	uint16_t tap_quiet :1;
+	/*! tap duration */
+	uint16_t tap_dur :3;
+	/*! data source 0- filter & 1 pre-filter*/
+	uint16_t tap_data_src :1;
+	/*! tap enable, 1 - enable, 0 - disable */
+	uint16_t tap_en :1;
+#elif BIG_ENDIAN == 1
+	/*! tap enable, 1 - enable, 0 - disable */
+	uint16_t tap_en :1;
+	/*! data source 0- filter & 1 pre-filter*/
+	uint16_t tap_data_src :1;
+	/*! tap duration */
+	uint16_t tap_dur : 3;
+	/*! tap quiet */
+	uint16_t tap_quiet : 1;
+	/*! tap shock */
+	uint16_t tap_shock : 1;
+	/*! tap threshold */
+	uint16_t tap_thr : 5;
+#endif
+};
+
+struct bmi160_acc_any_mot_int_cfg {
+#if LITTLE_ENDIAN == 1
+	/*! 1 any-motion enable, 0 - any-motion disable */
+	uint8_t anymotion_en :1;
+	/*! slope interrupt x, 1 - enable, 0 - disable */
+	uint8_t anymotion_x :1;
+	/*! slope interrupt y, 1 - enable, 0 - disable */
+	uint8_t anymotion_y :1;
+	/*! slope interrupt z, 1 - enable, 0 - disable */
+	uint8_t anymotion_z :1;
+	/*! slope duration */
+	uint8_t anymotion_dur :2;
+	/*! data source 0- filter & 1 pre-filter*/
+	uint8_t anymotion_data_src :1;
+	/*! slope threshold */
+	uint8_t anymotion_thr;
+#elif BIG_ENDIAN == 1
+	/*! slope threshold */
+	uint8_t anymotion_thr;
+	/*! data source 0- filter & 1 pre-filter*/
+	uint8_t anymotion_data_src :1;
+	/*! slope duration */
+	uint8_t anymotion_dur : 2;
+	/*! slope interrupt z, 1 - enable, 0 - disable */
+	uint8_t anymotion_z : 1;
+	/*! slope interrupt y, 1 - enable, 0 - disable */
+	uint8_t anymotion_y : 1;
+	/*! slope interrupt x, 1 - enable, 0 - disable */
+	uint8_t anymotion_x : 1;
+	/*! 1 any-motion enable, 0 - any-motion disable */
+	uint8_t anymotion_en :1;
+#endif
+};
+
+struct bmi160_acc_sig_mot_int_cfg {
+#if LITTLE_ENDIAN == 1
+	/*! skip time of sig-motion interrupt */
+	uint8_t sig_mot_skip :2;
+	/*! proof time of sig-motion interrupt */
+	uint8_t sig_mot_proof :2;
+	/*! data source 0- filter & 1 pre-filter*/
+	uint8_t sig_data_src :1;
+	/*! 1 - enable sig, 0 - disable sig & enable anymotion */
+	uint8_t sig_en :1;
+	/*! sig-motion threshold */
+	uint8_t sig_mot_thres;
+#elif BIG_ENDIAN == 1
+	/*! sig-motion threshold */
+	uint8_t sig_mot_thres;
+	/*! 1 - enable sig, 0 - disable sig & enable anymotion */
+	uint8_t sig_en :1;
+	/*! data source 0- filter & 1 pre-filter*/
+	uint8_t sig_data_src :1;
+	/*! proof time of sig-motion interrupt */
+	uint8_t sig_mot_proof : 2;
+	/*! skip time of sig-motion interrupt */
+	uint8_t sig_mot_skip : 2;
+#endif
+};
+
+struct bmi160_acc_step_detect_int_cfg {
+#if LITTLE_ENDIAN == 1
+	/*! 1- step detector enable, 0- step detector disable */
+	uint16_t step_detector_en :1;
+	/*! minimum threshold */
+	uint16_t min_threshold :2;
+	/*! minimal detectable step time */
+	uint16_t steptime_min :3;
+	/*! enable step counter mode setting */
+	uint16_t step_detector_mode :2;
+	/*! minimum step buffer size*/
+	uint16_t step_min_buf :3;
+#elif BIG_ENDIAN == 1
+	/*! minimum step buffer size*/
+	uint16_t step_min_buf :3;
+	/*! enable step counter mode setting */
+	uint16_t step_detector_mode : 2;
+	/*! minimal detectable step time */
+	uint16_t steptime_min : 3;
+	/*! minimum threshold */
+	uint16_t min_threshold : 2;
+	/*! 1- step detector enable, 0- step detector disable */
+	uint16_t step_detector_en :1;
+#endif
+};
+
+struct bmi160_acc_no_motion_int_cfg {
+#if LITTLE_ENDIAN == 1
+	/*! no motion interrupt x */
+	uint16_t no_motion_x :1;
+	/*! no motion interrupt y */
+	uint16_t no_motion_y :1;
+	/*! no motion interrupt z */
+	uint16_t no_motion_z :1;
+	/*! no motion duration */
+	uint16_t no_motion_dur :6;
+	/*! no motion sel , 1 - enable no-motion ,0- enable slow-motion */
+	uint16_t no_motion_sel :1;
+	/*! data source 0- filter & 1 pre-filter*/
+	uint16_t no_motion_src :1;
+	/*! no motion threshold */
+	uint8_t no_motion_thres;
+#elif BIG_ENDIAN == 1
+	/*! no motion threshold */
+	uint8_t no_motion_thres;
+	/*! data source 0- filter & 1 pre-filter*/
+	uint16_t no_motion_src :1;
+	/*! no motion sel , 1 - enable no-motion ,0- enable slow-motion */
+	uint16_t no_motion_sel : 1;
+	/*! no motion duration */
+	uint16_t no_motion_dur : 6;
+	/* no motion interrupt z */
+	uint16_t no_motion_z :1;
+	/*! no motion interrupt y */
+	uint16_t no_motion_y :1;
+	/*! no motion interrupt x */
+	uint16_t no_motion_x :1;
+#endif
+};
+
+struct bmi160_acc_orient_int_cfg {
+#if LITTLE_ENDIAN == 1
+	/*! thresholds for switching between the different orientations */
+	uint16_t orient_mode :2;
+	/*! blocking_mode */
+	uint16_t orient_blocking :2;
+	/*! Orientation interrupt hysteresis */
+	uint16_t orient_hyst :4;
+	/*! Orientation interrupt theta */
+	uint16_t orient_theta :6;
+	/*! Enable/disable Orientation interrupt */
+	uint16_t orient_ud_en :1;
+	/*! exchange x- and z-axis in algorithm ,0 - z, 1 - x */
+	uint16_t axes_ex :1;
+	/*! 1 - orient enable, 0 - orient disable */
+	uint8_t orient_en :1;
+#elif BIG_ENDIAN == 1
+	/*! 1 - orient enable, 0 - orient disable */
+	uint8_t orient_en :1;
+	/*! exchange x- and z-axis in algorithm ,0 - z, 1 - x */
+	uint16_t axes_ex : 1;
+	/*! Enable/disable Orientation interrupt */
+	uint16_t orient_ud_en : 1;
+	/*! Orientation interrupt theta */
+	uint16_t orient_theta : 6;
+	/*! Orientation interrupt hysteresis */
+	uint16_t orient_hyst : 4;
+	/*! blocking_mode */
+	uint16_t orient_blocking : 2;
+	/*! thresholds for switching between the different orientations */
+	uint16_t orient_mode : 2;
+#endif
+};
+
+struct bmi160_acc_flat_detect_int_cfg {
+#if LITTLE_ENDIAN == 1
+	/*! flat threshold */
+	uint16_t flat_theta :6;
+	/*! flat interrupt hysteresis */
+	uint16_t flat_hy :3;
+	/*! delay time for which the flat value must remain stable for the
+	 * flat interrupt to be generated */
+	uint16_t flat_hold_time :2;
+	/*! 1 - flat enable, 0 - flat disable */
+	uint16_t flat_en :1;
+#elif BIG_ENDIAN == 1
+	/*! 1 - flat enable, 0 - flat disable */
+	uint16_t flat_en :1;
+	/*! delay time for which the flat value must remain stable for the
+	 * flat interrupt to be generated */
+	uint16_t flat_hold_time : 2;
+	/*! flat interrupt hysteresis */
+	uint16_t flat_hy : 3;
+	/*! flat threshold */
+	uint16_t flat_theta : 6;
+#endif
+};
+
+struct bmi160_acc_low_g_int_cfg {
+#if LITTLE_ENDIAN == 1
+	/*! low-g interrupt trigger delay */
+	uint8_t low_dur;
+	/*! low-g interrupt trigger threshold */
+	uint8_t low_thres;
+	/*! hysteresis of low-g interrupt */
+	uint8_t low_hyst :2;
+	/*! 0 - single-axis mode ,1 - axis-summing mode */
+	uint8_t low_mode :1;
+	/*! data source 0- filter & 1 pre-filter */
+	uint8_t low_data_src :1;
+	/*! 1 - enable low-g, 0 - disable low-g */
+	uint8_t low_en :1;
+#elif BIG_ENDIAN == 1
+	/*! 1 - enable low-g, 0 - disable low-g */
+	uint8_t low_en :1;
+	/*! data source 0- filter & 1 pre-filter */
+	uint8_t low_data_src :1;
+	/*! 0 - single-axis mode ,1 - axis-summing mode */
+	uint8_t low_mode : 1;
+	/*! hysteresis of low-g interrupt */
+	uint8_t low_hyst : 2;
+	/*! low-g interrupt trigger threshold */
+	uint8_t low_thres;
+	/*! low-g interrupt trigger delay */
+	uint8_t low_dur;
+#endif
+};
+
+struct bmi160_acc_high_g_int_cfg {
+#if LITTLE_ENDIAN == 1
+	/*! High-g interrupt x, 1 - enable, 0 - disable */
+	uint8_t high_g_x :1;
+	/*! High-g interrupt y, 1 - enable, 0 - disable */
+	uint8_t high_g_y :1;
+	/*! High-g interrupt z, 1 - enable, 0 - disable */
+	uint8_t high_g_z :1;
+	/*! High-g hysteresis  */
+	uint8_t high_hy :2;
+	/*! data source 0- filter & 1 pre-filter */
+	uint8_t high_data_src :1;
+	/*! High-g threshold */
+	uint8_t high_thres;
+	/*! High-g duration */
+	uint8_t high_dur;
+#elif BIG_ENDIAN == 1
+	/*! High-g duration */
+	uint8_t high_dur;
+	/*! High-g threshold */
+	uint8_t high_thres;
+	/*! data source 0- filter & 1 pre-filter */
+	uint8_t high_data_src :1;
+	/*! High-g hysteresis  */
+	uint8_t high_hy : 2;
+	/*! High-g interrupt z, 1 - enable, 0 - disable */
+	uint8_t high_g_z : 1;
+	/*! High-g interrupt y, 1 - enable, 0 - disable */
+	uint8_t high_g_y : 1;
+	/*! High-g interrupt x, 1 - enable, 0 - disable */
+	uint8_t high_g_x : 1;
+#endif
+};
+
+struct bmi160_int_pin_settg {
+#if LITTLE_ENDIAN == 1
+	/*! To enable either INT1 or INT2 pin as output.
+	 * 0- output disabled ,1- output enabled */
+	uint16_t output_en :1;
+	/*! 0 - push-pull 1- open drain,only valid if output_en is set 1 */
+	uint16_t output_mode :1;
+	/*! 0 - active low , 1 - active high level.
+	 * if output_en is 1,this applies to interrupts,else PMU_trigger */
+	uint16_t output_type :1;
+	/*! 0 - level trigger , 1 - edge trigger  */
+	uint16_t edge_ctrl :1;
+	/*! To enable either INT1 or INT2 pin as input.
+	 * 0 - input disabled ,1 - input enabled */
+	uint16_t input_en :1;
+	/*! latch duration*/
+	uint16_t latch_dur :4;
+#elif BIG_ENDIAN == 1
+	/*! latch duration*/
+	uint16_t latch_dur : 4;
+	/*! Latched,non-latched or temporary interrupt modes */
+	uint16_t input_en : 1;
+	/*! 1 - edge trigger, 0 - level trigger */
+	uint16_t edge_ctrl : 1;
+	/*! 0 - active low , 1 - active high level.
+	 * if output_en is 1,this applies to interrupts,else PMU_trigger */
+	uint16_t output_type : 1;
+	/*! 0 - push-pull , 1 - open drain,only valid if output_en is set 1 */
+	uint16_t output_mode : 1;
+	/*! To enable either INT1 or INT2 pin as output.
+	 * 0 - output disabled , 1 - output enabled */
+	uint16_t output_en : 1;
+#endif
+};
+
+union bmi160_int_type_cfg {
+	/*! Tap interrupt structure */
+	struct bmi160_acc_tap_int_cfg acc_tap_int;
+	/*! Slope interrupt structure */
+	struct bmi160_acc_any_mot_int_cfg acc_any_motion_int;
+	/*! Significant motion interrupt structure */
+	struct bmi160_acc_sig_mot_int_cfg acc_sig_motion_int;
+	/*! Step detector interrupt structure */
+	struct bmi160_acc_step_detect_int_cfg acc_step_detect_int;
+	/*! No motion interrupt structure */
+	struct bmi160_acc_no_motion_int_cfg acc_no_motion_int;
+	/*! Orientation interrupt structure */
+	struct bmi160_acc_orient_int_cfg acc_orient_int;
+	/*! Flat interrupt structure */
+	struct bmi160_acc_flat_detect_int_cfg acc_flat_int;
+	/*! Low-g interrupt structure */
+	struct bmi160_acc_low_g_int_cfg acc_low_g_int;
+	/*! High-g interrupt structure */
+	struct bmi160_acc_high_g_int_cfg acc_high_g_int;
+};
+
+struct bmi160_int_settg {
+	/*! Interrupt channel */
+	enum bmi160_int_channel int_channel;
+	/*! Select Interrupt */
+	enum bmi160_int_types int_type;
+	/*! Structure configuring Interrupt pins */
+	struct bmi160_int_pin_settg int_pin_settg;
+	/*! Union configures required interrupt */
+	union bmi160_int_type_cfg int_type_cfg;
+	/*! FIFO FULL INT 1-enable, 0-disable */
+	uint8_t fifo_full_int_en :1;
+	/*! FIFO WTM INT 1-enable, 0-disable */
+	uint8_t fifo_WTM_int_en :1;
+};
+
+/*!
+ *  @brief This structure holds the information for usage of
+ *  FIFO by the user.
+ */
+struct bmi160_fifo_frame {
+	/*! Data buffer of user defined length is to be mapped here */
+	uint8_t *data;
+	/*! While calling the API  "bmi160_get_fifo_data" , length stores
+	 *  number of bytes in FIFO to be read (specified by user as input)
+	 *  and after execution of the API ,number of FIFO data bytes
+	 *  available is provided as an output to user
+	 */
+	uint16_t length;
+	/*! FIFO time enable */
+	uint8_t fifo_time_enable;
+	/*! Enabling of the FIFO header to stream in header mode */
+	uint8_t fifo_header_enable;
+	/*! Streaming of the Accelerometer, Gyroscope
+	sensor data or both in FIFO */
+	uint8_t fifo_data_enable;
+	/*! Will be equal to length when no more frames are there to parse */
+	uint16_t accel_byte_start_idx;
+	/*! Will be equal to length when no more frames are there to parse */
+	uint16_t gyro_byte_start_idx;
+	/*! Will be equal to length when no more frames are there to parse */
+	uint16_t aux_byte_start_idx;
+	/*! Value of FIFO sensor time time */
+	uint32_t sensor_time;
+	/*! Value of Skipped frame counts */
+	uint8_t skipped_frame_count;
+};
+
+struct bmi160_dev {
+	/*! Chip Id */
+	uint8_t chip_id;
+	/*! Device Id */
+	uint8_t id;
+	/*! 0 - I2C , 1 - SPI Interface */
+	uint8_t interface;
+	/*! Hold active interrupts status for any and sig motion
+	 *  0 - Any-motion enable, 1 - Sig-motion enable,
+	 *  -1 neither any-motion nor sig-motion selected */
+	enum bmi160_any_sig_motion_active_interrupt_state any_sig_sel;
+	/*! Structure to configure Accel sensor */
+	struct bmi160_cfg accel_cfg;
+	/*! Structure to hold previous/old accel config parameters.
+	 * This is used at driver level to prevent overwriting of same
+	 * data, hence user does not change it in the code */
+	struct bmi160_cfg prev_accel_cfg;
+	/*! Structure to configure Gyro sensor */
+	struct bmi160_cfg gyro_cfg;
+	/*! Structure to hold previous/old gyro config parameters.
+	 * This is used at driver level to prevent overwriting of same
+	 * data, hence user does not change it in the code */
+	struct bmi160_cfg prev_gyro_cfg;
+	/*! Structure to configure the auxiliary sensor */
+	struct bmi160_aux_cfg aux_cfg;
+	/*! Structure to hold previous/old aux config parameters.
+	 * This is used at driver level to prevent overwriting of same
+	 * data, hence user does not change it in the code */
+	struct bmi160_aux_cfg prev_aux_cfg;
+	 /*! FIFO related configurations */
+	struct bmi160_fifo_frame *fifo;
+	/*! Read function pointer */
+	bmi160_com_fptr_t read;
+	/*! Write function pointer */
+	bmi160_com_fptr_t write;
+	/*!  Delay function pointer */
+	bmi160_delay_fptr_t delay_ms;
+};
+
+/*************************** C++ guard macro *****************************/
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BMI160_DEFS_H_ */

+ 0 - 839
bmi160_support.c

@@ -1,839 +0,0 @@
-/*
-****************************************************************************
-* Copyright (C) 2016 Bosch Sensortec GmbH
-*
-* bmi160_support.c
-* Date: 2016/06/22
-* Revision: 1.1.4 $
-*
-* Usage: Sensor Driver support file for BMI160 sensor
-*
-****************************************************************************
-* License:
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-*
-*   Redistributions of source code must retain the above copyright
-*   notice, this list of conditions and the following disclaimer.
-*
-*   Redistributions in binary form must reproduce the above copyright
-*   notice, this list of conditions and the following disclaimer in the
-*   documentation and/or other materials provided with the distribution.
-*
-*   Neither the name of the copyright holder nor the names of the
-*   contributors may be used to endorse or promote products derived from
-*   this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
-* OR CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-* OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO,
-* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-* ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
-*
-* The information provided is believed to be accurate and reliable.
-* The copyright holder 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 the copyright holder.
-**************************************************************************/
-
-#include "bmi160_support.h"
-#include "bmi160.h"
-/* Mapping the structure*/
-struct bmi160_t s_bmi160;
-/* Read the sensor data of accel, gyro and mag*/
-struct bmi160_gyro_t gyroxyz;
-struct bmi160_accel_t accelxyz;
-struct bmi160_mag_xyz_s32_t magxyz;
-
-/*!
- *	@brief This function used for initialize the sensor
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval 1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_initialize_sensor(void)
-{
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = BMI160_INIT_VALUE;
- /*	Based on the user need configure I2C or SPI interface.
-  *	It is sample code to explain how to use the bmi160 API*/
-	#ifdef INCLUDE_BMI160API
-	com_rslt = i2c_routine();
-	/*SPI_routine(); */
-	#endif
-/*
- *  This function used to assign the value/reference of
- *	the following parameters
- *	I2C address
- *	Bus Write
- *	Bus read
- *	company_id
- */
-	com_rslt += bmi160_init(&s_bmi160);
-	/**** standard 9Dof with FIFO output****/
-	com_rslt += bmi160_config_running_mode(STANDARD_UI_9DOF_FIFO);
-	return com_rslt;
-}
-/*!
- *	@brief This Function used to read the sensor data using
- *	different running mode
- *	@param v_running_mode_u8 : The value of running mode
- *      Description                |  value
- * --------------------------------|----------
- *  STANDARD_UI_9DOF_FIFO          |   0
- *	STANDARD_UI_IMU_FIFO           |   1
- *	STANDARD_UI_IMU                |   2
- *	STANDARD_UI_ADVANCEPOWERSAVE   |   3
- *	ACCEL_PEDOMETER                |   4
- *	APPLICATION_HEAD_TRACKING      |   5
- *	APPLICATION_NAVIGATION         |   6
- *	APPLICATION_REMOTE_CONTROL     |   7
- *	APPLICATION_INDOOR_NAVIGATION  |   8
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval 1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_config_running_mode(
-u8 v_running_mode_u8)
-{
-	struct gyro_sleep_setting gyr_setting;
-	struct bmi160_fifo_data_header_t header_data;
-
-	/* Variable used for get the status of mag interface*/
-	u8 v_mag_interface_u8 = BMI160_INIT_VALUE;
-	u8 v_bmm_chip_id_u8 = BMI160_INIT_VALUE;
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = ERROR;
-		/* Configure the gyro sleep setting based on your need*/
-	if (v_running_mode_u8 == STANDARD_UI_ADVANCEPOWERSAVE) {
-		gyr_setting. sleep_trigger = BMI160_SLEEP_TRIGGER;
-		gyr_setting. wakeup_trigger = BMI160_WAKEUP_TRIGGER;
-		gyr_setting. sleep_state = BMI160_SLEEP_STATE;
-		gyr_setting. wakeup_int = BMI160_WAKEUP_INTR;
-	}
-	/* The below code used for enable and
-	disable the secondary mag interface*/
-	com_rslt = bmi160_get_if_mode(&v_mag_interface_u8);
-	if (((v_running_mode_u8 == STANDARD_UI_IMU_FIFO) ||
-	(v_running_mode_u8 == STANDARD_UI_IMU) ||
-	(v_running_mode_u8 == STANDARD_UI_ADVANCEPOWERSAVE) ||
-	(v_running_mode_u8 == APPLICATION_NAVIGATION) ||
-	(v_running_mode_u8 == ACCEL_PEDOMETER) ||
-	(v_running_mode_u8 == APPLICATION_REMOTE_CONTROL) ||
-	(v_running_mode_u8 == APPLICATION_INDOOR_NAVIGATION))
-	&& (v_mag_interface_u8 == BMI160_MAG_INTERFACE_ON_PRIMARY_ON)) {
-		com_rslt +=
-		bmi160_set_bmm150_mag_and_secondary_if_power_mode(
-		MAG_SUSPEND_MODE);
-		s_bmi160.delay_msec(
-			BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		com_rslt += bmi160_set_if_mode(
-		BMI160_MAG_INTERFACE_OFF_PRIMARY_ON);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-	}
-	if (((v_running_mode_u8 == STANDARD_UI_9DOF_FIFO)
-		|| (v_running_mode_u8 == APPLICATION_HEAD_TRACKING) ||
-		(v_running_mode_u8 == APPLICATION_NAVIGATION)) &&
-		(v_mag_interface_u8 == BMI160_MAG_INTERFACE_OFF_PRIMARY_ON)) {
-			/* Init the magnetometer */
-			com_rslt += bmi160_bmm150_mag_interface_init(
-			&v_bmm_chip_id_u8);
-			/* bmi160_delay_ms in ms*/
-			s_bmi160.delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-	}
-	switch (v_running_mode_u8) {
-	case STANDARD_UI_9DOF_FIFO:
-		/*Set the accel mode as Normal write in the register 0x7E*/
-		com_rslt = bmi160_set_command_register(ACCEL_MODE_NORMAL);
-		/* bmi160_delay_ms in ms*/
-		s_bmi160.delay_msec(BMI160_MODE_SWITCHING_DELAY);
-		/*Set the gyro mode as Normal write in the register 0x7E*/
-		com_rslt += bmi160_set_command_register(GYRO_MODE_NORMAL);
-		/* bmi160_delay_ms in ms*/
-		s_bmi160.delay_msec(BMI160_MODE_SWITCHING_DELAY);
-		/* Set the accel bandwidth as Normal */
-		com_rslt += bmi160_set_accel_bw(BMI160_ACCEL_NORMAL_AVG4);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* Set the gryo bandwidth as Normal */
-		com_rslt += bmi160_set_gyro_bw(BMI160_GYRO_NORMAL_MODE);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* set gyro data rate as 100Hz*/
-		com_rslt += bmi160_set_gyro_output_data_rate(
-		BMI160_GYRO_OUTPUT_DATA_RATE_100HZ);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* set accel data rate as 100Hz*/
-		com_rslt += bmi160_set_accel_output_data_rate(
-		BMI160_ACCEL_OUTPUT_DATA_RATE_100HZ, BMI160_ACCEL_OSR4_AVG1);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/***** read FIFO data based on interrupt*****/
-		com_rslt += bmi160_interrupt_configuration();
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* Enable the FIFO header*/
-		com_rslt += bmi160_set_fifo_header_enable(FIFO_HEADER_ENABLE);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* Enable the FIFO mag*/
-		com_rslt += bmi160_set_fifo_mag_enable(FIFO_MAG_ENABLE);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* Enable the FIFO accel*/
-		com_rslt += bmi160_set_fifo_accel_enable(FIFO_ACCEL_ENABLE);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* Enable the FIFO gyro*/
-		com_rslt += bmi160_set_fifo_gyro_enable(FIFO_GYRO_ENABLE);
-		/* Enable the FIFO time*/
-		com_rslt += bmi160_set_fifo_time_enable(FIFO_TIME_ENABLE);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* Enable the FIFO water mark interrupt1*/
-		/* Enable FIFO water mark interrupts in INT_EN[1] */
-		com_rslt += bmi160_set_intr_enable_1(BMI160_FIFO_WM_ENABLE,
-		BMI160_ENABLE);
-		com_rslt += bmi160_set_intr_fifo_wm(BMI160_INIT_VALUE,
-		FIFO_WM_INTERRUPT_ENABLE);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* Enable the FIFO water mark interrupt2*/
-		com_rslt += bmi160_set_intr_fifo_wm(BMI160_ENABLE,
-		FIFO_WM_INTERRUPT_ENABLE);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* set the fifo water mark*/
-		com_rslt += bmi160_set_fifo_wm(BMI160_ENABLE_FIFO_WM);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* read the FIFO data*/
-		com_rslt +=  bmi160_read_fifo_header_data(BMI160_SEC_IF_BMM150,
-		&header_data);
-	break;
-	case STANDARD_UI_IMU_FIFO:
-		com_rslt = bmi160_set_command_register(ACCEL_MODE_NORMAL);
-				/* bmi160_delay_ms in ms*/
-		s_bmi160.delay_msec(BMI160_MODE_SWITCHING_DELAY);
-		/*Set the gyro mode as Normal write in the register 0x7E*/
-		com_rslt += bmi160_set_command_register(GYRO_MODE_NORMAL);
-				/* bmi160_delay_ms in ms*/
-		s_bmi160.delay_msec(BMI160_MODE_SWITCHING_DELAY);
-		/* Set the accel bandwidth as Normal */
-		com_rslt += bmi160_set_accel_bw(BMI160_ACCEL_NORMAL_AVG4);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* Set the gryo bandwidth as Normal */
-		com_rslt += bmi160_set_gyro_bw(BMI160_GYRO_NORMAL_MODE);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* set gyro data rate as 100Hz*/
-		com_rslt += bmi160_set_gyro_output_data_rate(
-			BMI160_GYRO_OUTPUT_DATA_RATE_100HZ);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* set accel data rate as 100Hz*/
-		com_rslt += bmi160_set_accel_output_data_rate(
-			BMI160_ACCEL_OUTPUT_DATA_RATE_100HZ,
-			BMI160_ACCEL_OSR4_AVG1);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/***** read FIFO data based on interrupt*****/
-		com_rslt += bmi160_interrupt_configuration();
-		/* Enable the FIFO header*/
-		com_rslt += bmi160_set_fifo_header_enable(FIFO_HEADER_ENABLE);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* Enable the FIFO accel*/
-		com_rslt += bmi160_set_fifo_accel_enable(FIFO_ACCEL_ENABLE);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* Enable the FIFO gyro*/
-		com_rslt += bmi160_set_fifo_gyro_enable(FIFO_GYRO_ENABLE);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* Enable the FIFO time*/
-		com_rslt += bmi160_set_fifo_time_enable(FIFO_TIME_ENABLE);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* Enable FIFO water mark interrupts in INT_EN[1] */
-		com_rslt += bmi160_set_intr_enable_1(BMI160_FIFO_WM_ENABLE,
-		BMI160_ENABLE);
-		/* Enable the FIFO water mark interrupt1*/
-		com_rslt += bmi160_set_intr_fifo_wm(BMI160_INIT_VALUE,
-		BMI160_ENABLE);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* Enable the FIFO water mark interrupt2*/
-		com_rslt += bmi160_set_intr_fifo_wm(BMI160_ENABLE,
-		BMI160_ENABLE);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* set the fifo water mark as 10*/
-		com_rslt += bmi160_set_fifo_wm(BMI160_ENABLE_FIFO_WM);
-		/* read the FIFO data*/
-		com_rslt +=  bmi160_read_fifo_header_data(BMI160_SEC_IF_BMM150,
-		&header_data);
-	break;
-	case STANDARD_UI_IMU:
-		/*Set the accel mode as Normal write in the register 0x7E*/
-		com_rslt = bmi160_set_command_register(ACCEL_MODE_NORMAL);
-				/* bmi160_delay_ms in ms*/
-		s_bmi160.delay_msec(BMI160_MODE_SWITCHING_DELAY);
-		/*Set the gyro mode as Normal write in the register 0x7E*/
-		com_rslt += bmi160_set_command_register(GYRO_MODE_NORMAL);
-				/* bmi160_delay_ms in ms*/
-		s_bmi160.delay_msec(BMI160_MODE_SWITCHING_DELAY);
-		/* Set the accel bandwidth as Normal */
-		com_rslt += bmi160_set_accel_bw(BMI160_ACCEL_NORMAL_AVG4);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* Set the gryo bandwidth as Normal */
-		com_rslt += bmi160_set_gyro_bw(BMI160_GYRO_NORMAL_MODE);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* set gyro data rate as 100Hz*/
-		com_rslt += bmi160_set_gyro_output_data_rate(
-			BMI160_GYRO_OUTPUT_DATA_RATE_100HZ);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* set accel data rate as 100Hz*/
-		com_rslt += bmi160_set_accel_output_data_rate(
-			BMI160_ACCEL_OUTPUT_DATA_RATE_100HZ,
-			BMI160_ACCEL_OSR4_AVG1);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* read gyro data*/
-		com_rslt += bmi160_read_gyro_xyz(&gyroxyz);
-		/* read accel data*/
-		com_rslt += bmi160_read_accel_xyz(&accelxyz);
-	break;
-	case STANDARD_UI_ADVANCEPOWERSAVE:
-		/*Set the accel mode as Normal write in the register 0x7E*/
-		com_rslt = bmi160_set_command_register(ACCEL_MODE_NORMAL);
-				/* bmi160_delay_ms in ms*/
-		s_bmi160.delay_msec(BMI160_MODE_SWITCHING_DELAY);
-		/* Set the accel bandwidth as Normal */
-		com_rslt += bmi160_set_accel_bw(BMI160_ACCEL_NORMAL_AVG4);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* Set the gryo bandwidth as Normal */
-		com_rslt += bmi160_set_gyro_bw(BMI160_GYRO_NORMAL_MODE);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* set gyro data rate as 100Hz*/
-		com_rslt += bmi160_set_gyro_output_data_rate(
-			BMI160_GYRO_OUTPUT_DATA_RATE_100HZ);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* set accel data rate as 100Hz*/
-		com_rslt += bmi160_set_accel_output_data_rate(
-			BMI160_ACCEL_OUTPUT_DATA_RATE_100HZ,
-			BMI160_ACCEL_OSR4_AVG1);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-
-		/* Enable any motion interrupt - x axis*/
-		com_rslt += bmi160_set_intr_enable_0(BMI160_ANY_MOTION_X_ENABLE,
-		BMI160_ENABLE);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* Enable any motion interrupt - y axis*/
-		com_rslt += bmi160_set_intr_enable_0(BMI160_ANY_MOTION_Y_ENABLE,
-		BMI160_ENABLE);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* Enable any motion interrupt - z axis*/
-		com_rslt += bmi160_set_intr_enable_0(BMI160_ANY_MOTION_Z_ENABLE,
-		BMI160_ENABLE);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* Enable no motion interrupt - x axis*/
-		com_rslt += bmi160_set_intr_enable_2(BMI160_NOMOTION_X_ENABLE,
-		BMI160_ENABLE);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* Enable no motion interrupt - y axis*/
-		com_rslt += bmi160_set_intr_enable_2(BMI160_NOMOTION_Y_ENABLE,
-		BMI160_ENABLE);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* Enable no motion interrupt - z axis*/
-		com_rslt += bmi160_set_intr_enable_2(BMI160_NOMOTION_Z_ENABLE,
-		BMI160_ENABLE);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* set the gyro sleep trigger*/
-		com_rslt += bmi160_set_gyro_sleep_trigger(
-		gyr_setting.sleep_trigger);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* set the gyro wakeup trigger*/
-		com_rslt += bmi160_set_gyro_wakeup_trigger(
-		gyr_setting.wakeup_trigger);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* set the gyro sleep state*/
-		com_rslt += bmi160_set_gyro_sleep_state(
-		gyr_setting.sleep_state);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* set the gyro wakeup interrupt*/
-		com_rslt += bmi160_set_gyro_wakeup_intr(gyr_setting.wakeup_int);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* read gyro data*/
-		com_rslt += bmi160_read_gyro_xyz(&gyroxyz);
-		/* read accel data*/
-		com_rslt += bmi160_read_accel_xyz(&accelxyz);
-	break;
-	case ACCEL_PEDOMETER:
-		/*Set the accel mode as Normal write in the register 0x7E*/
-		com_rslt = bmi160_set_command_register(ACCEL_LOWPOWER);
-				/* bmi160_delay_ms in ms*/
-		s_bmi160.delay_msec(BMI160_MODE_SWITCHING_DELAY);
-		/*Set the gyro mode as SUSPEND write in the register 0x7E*/
-		com_rslt += bmi160_set_command_register(GYRO_MODE_SUSPEND);
-				/* bmi160_delay_ms in ms*/
-		s_bmi160.delay_msec(BMI160_MODE_SWITCHING_DELAY);
-		/* Set the accel bandwidth as OSR4 */
-		com_rslt += bmi160_set_accel_bw(BMI160_ACCEL_OSR4_AVG1);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* set accel data rate as 25Hz*/
-		com_rslt += bmi160_set_accel_output_data_rate(
-			BMI160_ACCEL_OUTPUT_DATA_RATE_25HZ,
-			BMI160_ACCEL_OSR4_AVG1);
-		/* 10 not available*/
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* read accel data*/
-		com_rslt += bmi160_read_accel_xyz(&accelxyz);
-	break;
-	case APPLICATION_HEAD_TRACKING:
-		/*Set the accel mode as Normal write in the register 0x7E*/
-		com_rslt = bmi160_set_command_register(ACCEL_MODE_NORMAL);
-				/* bmi160_delay_ms in ms*/
-		s_bmi160.delay_msec(BMI160_MODE_SWITCHING_DELAY);
-		/*Set the gyro mode as Normal write in the register 0x7E*/
-		com_rslt += bmi160_set_command_register(GYRO_MODE_NORMAL);
-				/* bmi160_delay_ms in ms*/
-		s_bmi160.delay_msec(BMI160_MODE_SWITCHING_DELAY);
-		/* Set the accel bandwidth as Normal */
-		com_rslt += bmi160_set_accel_bw(BMI160_ACCEL_NORMAL_AVG4);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* Set the gryo bandwidth as Normal */
-		com_rslt += bmi160_set_gyro_bw(BMI160_GYRO_NORMAL_MODE);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* set gyro data rate as 1600Hz*/
-		com_rslt += bmi160_set_gyro_output_data_rate(
-		BMI160_GYRO_OUTPUT_DATA_RATE_1600HZ);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* set accel data rate as 1600Hz*/
-		com_rslt += bmi160_set_accel_output_data_rate(
-		BMI160_ACCEL_OUTPUT_DATA_RATE_1600HZ, BMI160_ACCEL_OSR4_AVG1);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* read gyro data*/
-		com_rslt += bmi160_read_gyro_xyz(&gyroxyz);
-		/* read accel data */
-		com_rslt += bmi160_read_accel_xyz(&accelxyz);
-		/* read mag data */
-		com_rslt += bmi160_bmm150_mag_compensate_xyz(&magxyz);
-	break;
-	case APPLICATION_NAVIGATION:
-		/*Set the accel mode as Normal write in the register 0x7E*/
-		com_rslt = bmi160_set_command_register(ACCEL_MODE_NORMAL);
-				/* bmi160_delay_ms in ms*/
-		s_bmi160.delay_msec(BMI160_MODE_SWITCHING_DELAY);
-		/*Set the gyro mode as Normal write in the register 0x7E*/
-		com_rslt += bmi160_set_command_register(GYRO_MODE_NORMAL);
-				/* bmi160_delay_ms in ms*/
-		s_bmi160.delay_msec(BMI160_MODE_SWITCHING_DELAY);
-		/* Set the accel bandwidth as OSRS4 */
-		com_rslt += bmi160_set_accel_bw(BMI160_ACCEL_OSR4_AVG1);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* Set the gryo bandwidth as Normal */
-		com_rslt += bmi160_set_gyro_bw(BMI160_GYRO_NORMAL_MODE);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* set gyro data rate as 200Hz*/
-		com_rslt += bmi160_set_gyro_output_data_rate(
-			BMI160_GYRO_OUTPUT_DATA_RATE_200HZ);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* set accel data rate as 200Hz*/
-		com_rslt += bmi160_set_accel_output_data_rate(
-			BMI160_ACCEL_OUTPUT_DATA_RATE_200HZ,
-			BMI160_ACCEL_OSR4_AVG1);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* read gyro data*/
-		com_rslt += bmi160_read_gyro_xyz(&gyroxyz);
-		/* read accel data */
-		com_rslt += bmi160_read_accel_xyz(&accelxyz);
-		/* read mag data*/
-		com_rslt += bmi160_bmm150_mag_compensate_xyz(&magxyz);
-	break;
-	case APPLICATION_REMOTE_CONTROL:
-		/*Set the accel mode as Normal write in the register 0x7E*/
-		com_rslt = bmi160_set_command_register(ACCEL_MODE_NORMAL);
-				/* bmi160_delay_ms in ms*/
-		s_bmi160.delay_msec(BMI160_MODE_SWITCHING_DELAY);
-		/*Set the gyro mode as Normal write in the register 0x7E*/
-		com_rslt += bmi160_set_command_register(GYRO_MODE_NORMAL);
-		/* bmi160_delay_ms in ms*/
-		s_bmi160.delay_msec(BMI160_MODE_SWITCHING_DELAY);
-		/* Set the accel bandwidth as OSRS4 */
-		com_rslt += bmi160_set_accel_bw(BMI160_ACCEL_OSR4_AVG1);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* Set the gryo bandwidth as OSR4 */
-		com_rslt += bmi160_set_gyro_bw(BMI160_GYRO_OSR4_MODE);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* set gyro data rate as 200Hz*/
-		com_rslt += bmi160_set_gyro_output_data_rate(
-			BMI160_GYRO_OUTPUT_DATA_RATE_200HZ);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* set accel data rate as 200Hz*/
-		com_rslt += bmi160_set_accel_output_data_rate(
-			BMI160_ACCEL_OUTPUT_DATA_RATE_200HZ,
-			BMI160_ACCEL_OSR4_AVG1);
-		s_bmi160.delay_msec(
-		BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* read gyro data */
-		com_rslt += bmi160_read_gyro_xyz(&gyroxyz);
-		/* read accel data*/
-		com_rslt += bmi160_read_accel_xyz(&accelxyz);
-	break;
-	case APPLICATION_INDOOR_NAVIGATION:
-		/*Set the accel mode as Normal write in the register 0x7E*/
-		com_rslt = bmi160_set_command_register(ACCEL_MODE_NORMAL);
-		s_bmi160.delay_msec(
-			BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/*Set the gyro mode as Normal write in the register 0x7E*/
-		com_rslt += bmi160_set_command_register(GYRO_MODE_NORMAL);
-		s_bmi160.delay_msec(
-			BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* Set the accel bandwidth as OSRS4 */
-		com_rslt += bmi160_set_accel_bw(BMI160_ACCEL_OSR4_AVG1);
-		s_bmi160.delay_msec(
-			BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* Set the gryo bandwidth as OSR4 */
-		com_rslt += bmi160_set_gyro_bw(BMI160_GYRO_OSR4_MODE);
-		s_bmi160.delay_msec(
-			BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* set gyro data rate as 200Hz*/
-		com_rslt += bmi160_set_gyro_output_data_rate(
-			BMI160_GYRO_OUTPUT_DATA_RATE_400HZ);
-		s_bmi160.delay_msec(
-			BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* set accel data rate as 200Hz*/
-		com_rslt += bmi160_set_accel_output_data_rate(
-			BMI160_ACCEL_OUTPUT_DATA_RATE_400HZ,
-			BMI160_ACCEL_OSR4_AVG1);
-		s_bmi160.delay_msec(
-			BMI160_GEN_READ_WRITE_DELAY);/* bmi160_delay_ms in ms*/
-		/* read gyro data*/
-		com_rslt += bmi160_read_gyro_xyz(&gyroxyz);
-		/* read accel data */
-		com_rslt += bmi160_read_accel_xyz(&accelxyz);
-		break;
-	}
-
-	return com_rslt;
-
-}
-/*!
- *	@brief This function used for interrupt configuration
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval 1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_interrupt_configuration(void)
-{
-	/* This variable used for provide the communication
-	results*/
-	BMI160_RETURN_FUNCTION_TYPE com_rslt = ERROR;
-
-	/* Configure the in/out control of interrupt1*/
-	com_rslt = bmi160_set_output_enable(BMI160_INIT_VALUE,
-	BMI160_ENABLE);
-	s_bmi160.delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-	/* Configure the in/out control of interrupt2*/
-	com_rslt += bmi160_set_output_enable(BMI160_ENABLE,
-	BMI160_ENABLE);
-	s_bmi160.delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-	/* Configure the interrupt1 active high
-	0x00 -	Active low
-	0x01 -	Active high*/
-	com_rslt += bmi160_set_intr_level(BMI160_INIT_VALUE,
-	BMI160_ENABLE);
-	s_bmi160.delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-	/* Configure the interrupt2 active high
-	0x00 -	Active low
-	0x01 -	Active high*/
-	com_rslt += bmi160_set_intr_level(BMI160_ENABLE,
-	BMI160_ENABLE);
-	s_bmi160.delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-	return com_rslt;
-}
-#ifdef INCLUDE_BMI160API
-#define MASK_DATA1	0xFF
-#define MASK_DATA2	0x80
-#define MASK_DATA3	0x7F
-/*!
- *	@brief Used for I2C initialization
- *	@note
- *	The following function is used to map the
- *	I2C bus read, write, bmi160_delay_ms and
- *	device address with global structure bmi160_t
-*/
-s8 i2c_routine(void)
-{
-/*--------------------------------------------------------------------------*
- *  By using bmi160 the following structure parameter can be accessed
- *	Bus write function pointer: BMI160_WR_FUNC_PTR
- *	Bus read function pointer: BMI160_RD_FUNC_PTR
- *	bmi160_delay_ms function pointer: bmi160_delay_ms_msec
- *	I2C address: dev_addr
- *--------------------------------------------------------------------------*/
-	struct_bmi160.bus_write = bmi160_i2c_bus_write;
-	struct_bmi160.bus_read = bmi160_i2c_bus_read;
-	struct_bmi160.delay_msec = bmi160_delay_ms;
-	struct_bmi160.dev_addr = BMI160_I2C_ADDR2;
-
-	return BMI160_INIT_VALUE;
-}
-/*!
- *	@brief Used for SPI initialization
- *	@note
- *	The following function is used to map the
- *	SPI bus read, write and bmi160_delay_ms
- *	with global structure bmi160
-*/
-s8 spi_routine(void)
-{
-/*--------------------------------------------------------------------------*
- *  By using bmi160 the following structure parameter can be accessed
- *	Bus write function pointer: BMI160_WR_FUNC_PTR
- *	Bus read function pointer: BMI160_RD_FUNC_PTR
- *	bmi160_delay_ms function pointer: bmi160_delay_ms_msec
- *--------------------------------------------------------------------------*/
-
-	struct_bmi160.bus_write = bmi160_spi_bus_write;
-	struct_bmi160.bus_read = bmi160_spi_bus_read;
-	struct_bmi160.delay_msec = bmi160_delay_ms;
-
-	return BMI160_INIT_VALUE;
-}
-/**************************************************************/
-/**\name I2C/SPI read write function */
-/**************************************************************/
-/*-------------------------------------------------------------------*
-*
-*	This is a sample code for read and write the data by using I2C/SPI
-*	Use either I2C or SPI based on your need
-*	Configure the below code to your SPI or I2C driver
-*
-*-----------------------------------------------------------------------*/
- /*!
- *	@brief : The function is used as I2C bus read
- *	@return : Status of the I2C read
- *	@param dev_addr : The device address of the sensor
- *	@param reg_addr : Address of the first register, will data is going to be read
- *	@param reg_data : This data read from the sensor, which is hold in an array
- *	@param cnt : The no of byte of data to be read
- */
-s8 bmi160_i2c_bus_read(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt)
-{
-	s32 ierror = BMI160_INIT_VALUE;
-	#ifdef INCLUDE_BMI160API
-	u8 array[I2C_BUFFER_LEN] = {BMI160_INIT_VALUE};
-	u8 stringpos = BMI160_INIT_VALUE;
-
-	array[BMI160_INIT_VALUE] = reg_addr;
-	/* Please take the below function as your reference
-	 * for read the data using I2C communication
-	 * add your I2C rad function here.
-	 * "IERROR = I2C_WRITE_READ_STRING(DEV_ADDR, ARRAY, ARRAY, 1, CNT)"
-	 * iError is an return value of SPI write function
-	 * Please select your valid return value
-     * In the driver SUCCESS defined as 0
-     * and FAILURE defined as -1
-	 */
-	for (stringpos = BMI160_INIT_VALUE; stringpos < cnt; stringpos++)
-		*(reg_data + stringpos) = array[stringpos];
-	#endif
-	return (s8)ierror;
-
-}
- /*!
- *	@brief : The function is used as I2C bus write
- *	@return : Status of the I2C write
- *	@param dev_addr : The device address of the sensor
- *	@param reg_addr : Address of the first register,
- *	will data is going to be written
- *	@param reg_data : It is a value hold in the array,
- *		will be used for write the value into the register
- *	@param cnt : The no of byte of data to be write
- */
-s8 bmi160_i2c_bus_write(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt)
-{
-	s32 ierror = BMI160_INIT_VALUE;
-	#ifdef INCLUDE_BMI160API
-	u8 array[I2C_BUFFER_LEN];
-	u8 stringpos = BMI160_INIT_VALUE;
-
-	array[0] = reg_addr;
-	for (stringpos = BMI160_INIT_VALUE; stringpos
-	< cnt; stringpos++)
-		array[stringpos + BMI160_GEN_READ_WRITE_DATA_LENGTH]
-		= *(reg_data + stringpos);
-	/*
-	* Please take the below function as your reference for
-	* write the data using I2C communication
-	* "IERROR = I2C_WRITE_STRING(DEV_ADDR, ARRAY, CNT+1)"
-	* add your I2C write function here
-	* iError is an return value of I2C read function
-	* Please select your valid return value
-	* In the driver SUCCESS defined as 0
-    * and FAILURE defined as -1
-	* Note :
-	* This is a full duplex operation,
-	* The first read data is discarded, for that extra write operation
-	* have to be initiated. For that cnt+1 operation done
-	* in the I2C write string function
-	* For more information please refer data sheet SPI communication:
-	*/
-	#endif
-	return (s8)ierror;
-}
-/*!
- *	@brief : The function is used as SPI bus read
- *	@return : Status of the SPI read
- *	@param dev_addr : The device address of the sensor
- *	@param reg_addr : Address of the first register,
- *	will data is going to be read
- *	@param reg_data : This data read from the sensor,
- *	which is hold in an array
- *	@param cnt : The no of byte of data to be read
- */
-s8 bmi160_spi_bus_read(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt)
-{
-	s32 ierror = BMI160_INIT_VALUE;
-	#ifdef INCLUDE_BMI160API
-
-	u8 array[SPI_BUFFER_LEN] = {MASK_DATA1};
-	u8 stringpos;
-	/*	For the SPI mode only 7 bits of register addresses are used.
-	The MSB of register address is declared the bit what functionality it is
-	read/write (read as 1/write as 0)*/
-	array[BMI160_INIT_VALUE] = reg_addr|MASK_DATA2;
-	/*
-	* Please take the below function as your reference for
-	* read the data using SPI communication
-	* " IERROR = SPI_READ_WRITE_STRING(ARRAY, ARRAY, CNT+1)"
-	* add your SPI read function here
-	* ierror is an return value of SPI read function
-	* Please select your valid return value
-	* In the driver SUCCESS defined as 0
-    * and FAILURE defined as -1
-	* Note :
-	* This is a full duplex operation,
-	* The first read data is discarded, for that extra write operation
-	* have to be initiated. For that cnt+1 operation done in the SPI read
-	* and write string function
-	* For more information please refer data sheet SPI communication:
-	*/
-	for (stringpos = BMI160_INIT_VALUE; stringpos
-	< cnt; stringpos++)
-		*(reg_data + stringpos) = array[stringpos
-		+ BMI160_GEN_READ_WRITE_DATA_LENGTH];
-	#endif
-	return (s8)ierror;
-}
-/*!
- *	@brief : The function is used as SPI bus write
- *	@return : Status of the SPI write
- *	@param dev_addr : The device address of the sensor
- *	@param reg_addr : Address of the first register,
- *	will data is going to be written
- *	@param reg_data : It is a value hold in the array,
- *		will be used for write the value into the register
- *	@param cnt : The no of byte of data to be write
- */
-s8 bmi160_spi_bus_write(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt)
-{
-	s32 ierror = BMI160_INIT_VALUE;
-	#ifdef INCLUDE_BMI160API
-
-	u8 array[SPI_BUFFER_LEN * C_BMI160_BYTE_COUNT];
-	u8 stringpos = BMI160_INIT_VALUE;
-
-	for (stringpos = BMI160_INIT_VALUE;
-	stringpos < cnt; stringpos++) {
-		/* the operation of (reg_addr++)&0x7F done:
-		because it ensure the
-		   0 and 1 of the given value
-		   It is done only for 8bit operation*/
-		array[stringpos * C_BMI160_BYTE_COUNT] =
-		(reg_addr++) & MASK_DATA3;
-		array[stringpos * C_BMI160_BYTE_COUNT +
-		BMI160_GEN_READ_WRITE_DATA_LENGTH] =
-		*(reg_data + stringpos);
-	}
-		/* Please take the below function as your reference
-	 * for write the data using SPI communication
-	 * add your SPI write function here.
-	 * "IERROR = SPI_WRITE_STRING(ARRAY, CNT*2)"
-	 * ierror is an return value of SPI write function
-	 * Please select your valid return value
-	 * In the driver SUCCESS defined as 0
-     * and FAILURE defined as -1
-	 */
-	 #endif
-	return (s8)ierror;
-}
-#endif
-/*!
- *	@brief This function is an example for delay
- *	@param msec: delay in milli seconds
- *	@return : communication result
- */
-void bmi160_delay_ms(u32 msec)
-{
- /* user delay*/
-}

+ 0 - 218
bmi160_support.h

@@ -1,218 +0,0 @@
-/*
-*
-****************************************************************************
-* Copyright (C) 2016 Bosch Sensortec GmbH
-*
-* File : bmi160_support.h
-*
-* Date : 2016/06/22
-*
-* Revision : 1.1.2 $
-*
-* Usage: Sensor Driver support file for BMI160 sensor
-*
-****************************************************************************
-*
-* \section License
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-*
-*   Redistributions of source code must retain the above copyright
-*   notice, this list of conditions and the following disclaimer.
-*
-*   Redistributions in binary form must reproduce the above copyright
-*   notice, this list of conditions and the following disclaimer in the
-*   documentation and/or other materials provided with the distribution.
-*
-*   Neither the name of the copyright holder nor the names of the
-*   contributors may be used to endorse or promote products derived from
-*   this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
-* OR CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-* OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO,
-* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-* ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
-*
-* The information provided is believed to be accurate and reliable.
-* The copyright holder 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 the copyright holder.
-**************************************************************************/
-
-/*! \file bmi160_support.h
-    \brief BMI160 Sensor Driver Support Header File */
-/* user defined code to be added here ... */
-#ifndef __BMI160_SUPPORT_H__
-#define __BMI160_SUPPORT_H__
-
-#include "bmi160.h"
-
-/*!
- * @brief struct used for assign the value for
- *	gyro sleep configuration
- */
-struct gyro_sleep_setting {
-	u8 sleep_trigger;/**< gyro sleep trigger configuration*/
-	u8 wakeup_trigger;/**< gyro wakeup trigger configuration*/
-	u8 sleep_state;/**< gyro sleep state configuration*/
-	u8 wakeup_int;/**< gyro wakeup interrupt configuration*/
-};
-/********************************/
-/**\name POWER MODES DEFINITION */
-/*******************************/
-#define ACCEL_MODE_NORMAL	(0x11)
-#define GYRO_MODE_NORMAL	(0x15)
-#define	ACCEL_LOWPOWER		(0X12)
-#define MAG_SUSPEND_MODE	(1)
-#define BMI160_MODE_SWITCHING_DELAY		(30)
-/********************************/
-/**\name RETURN TYPE */
-/*******************************/
-/* return type of communication routine*/
-#define BMI160_RETURN_FUNCTION_TYPE s8
-/********************************/
-/**\name RUNNING MODE DEFINITIONS */
-/*******************************/
-#define	STANDARD_UI_9DOF_FIFO			(0)
-#define	STANDARD_UI_IMU_FIFO			(1)
-#define	STANDARD_UI_IMU					(2)
-#define	STANDARD_UI_ADVANCEPOWERSAVE	(3)
-#define	ACCEL_PEDOMETER					(4)
-#define APPLICATION_HEAD_TRACKING		(5)
-#define APPLICATION_NAVIGATION			(6)
-#define APPLICATION_REMOTE_CONTROL		(7)
-#define APPLICATION_INDOOR_NAVIGATION	(8)
-/********************************/
-/**\name MAG INTERFACE */
-/*******************************/
-#define	C_BMI160_BYTE_COUNT	   (2)
-#define BMI160_SLEEP_STATE     (0x00)
-#define BMI160_WAKEUP_INTR     (0x00)
-#define BMI160_SLEEP_TRIGGER   (0x04)
-#define BMI160_WAKEUP_TRIGGER  (0x02)
-#define BMI160_ENABLE_FIFO_WM  (0x02)
-#define	BMI160_MAG_INTERFACE_OFF_PRIMARY_ON		(0x00)
-#define	BMI160_MAG_INTERFACE_ON_PRIMARY_ON		(0x02)
-/*!
- *	@brief This function used for initialize the sensor
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval 1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_initialize_sensor(void);
-/*!
- *	@brief This Function used to read the sensor data using
- *	different running mode
- *	@param v_running_mode_u8 : The value of running mode
- *      Description                |  value
- * --------------------------------|----------
- *  STANDARD_UI_9DOF_FIFO          |   0
- *	STANDARD_UI_IMU_FIFO           |   1
- *	STANDARD_UI_IMU                |   2
- *	STANDARD_UI_ADVANCEPOWERSAVE   |   3
- *	ACCEL_PEDOMETER                |   4
- *	APPLICATION_HEAD_TRACKING      |   5
- *	APPLICATION_NAVIGATION         |   6
- *	APPLICATION_REMOTE_CONTROL     |   7
- *	APPLICATION_INDOOR_NAVIGATION  |   8
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval 1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_config_running_mode(u8 v_running_mode_u8);
-/*!
- *	@brief This function used for interrupt configuration
- *
- *
- *	@return results of bus communication function
- *	@retval 0 -> Success
- *	@retval 1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_interrupt_configuration(void);
-/*!
- *	@brief This function is an example for delay
- *	@param msec: delay in milli seconds
- *	@return : communication result
- */
-void bmi160_delay_ms(u32 msec);
-
-#ifdef INCLUDE_BMI160API
-/*!
- *	@brief Used for I2C initialization
-*/
-s8 i2c_routine(void);
-/*!
- *	@brief Used for SPI initialization
-*/
-s8 spi_routine(void);
- /*!
- *	@brief : The function is used as I2C bus read
- *	@return : Status of the I2C read
- *	@param dev_addr : The device address of the sensor
- *	@param reg_addr : Address of the first register,
- *	will data is going to be read
- *	@param reg_data : This data read from the sensor,
- *	which is hold in an array
- *	@param cnt : The no of byte of data to be read
- */
-s8 bmi160_i2c_bus_read(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt);
- /*!
- *	@brief : The function is used as I2C bus write
- *	@return : Status of the I2C write
- *	@param dev_addr : The device address of the sensor
- *	@param reg_addr : Address of the first register,
- *	will data is going to be written
- *	@param reg_data : It is a value hold in the array,
- *		will be used for write the value into the register
- *	@param cnt : The no of byte of data to be write
- */
-s8 bmi160_i2c_bus_write(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt);
-/*!
- *	@brief : The function is used as SPI bus read
- *	@return : Status of the SPI read
- *	@param dev_addr : The device address of the sensor
- *	@param reg_addr : Address of the first register,
- *	will data is going to be read
- *	@param reg_data : This data read from the sensor,
- *	which is hold in an array
- *	@param cnt : The no of byte of data to be read
- */
-s8 bmi160_spi_bus_read(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt);
-/*!
- *	@brief : The function is used as SPI bus write
- *	@return : Status of the SPI write
- *	@param dev_addr : The device address of the sensor
- *	@param reg_addr : Address of the first register,
- *	will data is going to be written
- *	@param reg_data : It is a value hold in the array,
- *		will be used for write the value into the register
- *	@param cnt : The no of byte of data to be write
- */
-s8 bmi160_spi_bus_write(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt);
-#endif
-#endif

+ 46 - 0
changelog.md

@@ -0,0 +1,46 @@
+# Change Log
+All notable changes to bmi160 Sensor API will be documented in this file. 
+
+## v3.5.0, 13 Apr 2017
+
+#### Added
+* Self-test feature for accel and gyro added
+
+## v3.4.0, 31 Mar 2017
+
+#### Added
+* Auxiliary sensor interface in auto-mode(data-mode) support is implemented
+
+## v3.3.0, 31 Mar 2017
+
+#### Added
+* Extracting of gyro data from FIFO is implemented.
+
+## v3.2.1, 15 Mar 2017
+
+#### Changed
+* Aux init made compatible for all auxillary sensors.
+
+## v3.2.0, 09 Mar 2017
+
+#### Added
+* Reading FIFO data and extracting of accel data from FIFO implemented.
+* FIFO FULL Interrupt implemented only for Accel data.
+
+## v3.1.0, 15 Feb 2017
+
+#### Changed
+* Condition for gyro BW corrected in order to set for all BW modes.
+* Interrupt Active High level setting handled.
+* Existing step detector code corrected for recommended settings.
+* Disabling of step detector and step counter has been removed in low-g interrupt.
+
+#### Added
+* Error code implemented, if input parameter is out of range or invalid.
+* Source of data (filter & prefilter) setting handled for slope, no-motion, tap, sig, high-g & Low-g interrupt.
+* Error handling of Pre-filter data & Interrupt is done in low power mode. 
+* Burst write handled for low & suspended power mode.
+* Auxiliary read & write implemented in order to read the BMM150 data.
+* Interrupt disable mechanism added.
+
+