BMI160 Initial

Dependents:   MAX32630HSP3_IMU_HelloWorld MAX32630HSP3_IMU_HelloWorld MAX32630HSP3_Pitch_Charles Maxim_Squeeks

Revision:
21:0b28b9d13164
Parent:
20:a521606048bb
--- a/bmi160.h	Fri May 04 13:35:59 2018 +0300
+++ b/bmi160.h	Tue Dec 04 09:50:52 2018 +0000
@@ -36,6 +36,19 @@
 
 #include "mbed.h"
 
+#include "bmi160_defs.h"
+
+#include <math.h>
+//#include <bmi160_math.h>
+/*
+#ifdef __KERNEL__
+
+#else
+
+#include <string.h>
+*/
+#include <stdlib.h>
+
 /**
 @brief The BMI160 is a small, low power, low noise 16-bit inertial measurement
 unit designed for use in mobile applications like augmented reality or indoor
@@ -71,7 +84,7 @@
         Y_AXIS,
         Z_AXIS
     };
-    
+   
     ///Structure for axis data
     struct AxisData
     {
@@ -136,7 +149,7 @@
         FIFO_DATA,       ///<FIFO data read out register, burst read
         ACC_CONF = 0x40, ///<Set ODR, bandwidth, and read mode of accelerometer
         ACC_RANGE,       ///<Sets accelerometer g-range
-        GYR_CONF,        ///<Set ODR, bandwidth, and read mode of gyroscope
+        GYR_CONF = 0x42,        ///<Set ODR, bandwidth, and read mode of gyroscope
         GYR_RANGE,       ///<Sets gyroscope angular rate measurement range
         MAG_CONF,        ///<Sets ODR of magnetometer interface
         FIFO_DOWNS,      ///<Sets down sampling ratios of accel and gyro data 
@@ -186,20 +199,20 @@
                          ///<interrupt
         INT_FLAT_0,      ///<Contains the configuration for the flat interrupt
         INT_FLAT_1,      ///<Contains the configuration for the flat interrupt
-        FOC_CONF,        ///<Contains configuration for the fast offset 
+        FOC_CONF = 0x69,        ///<Contains configuration for the fast offset 
                          ///<compensation for the accelerometer and gyroscope
         CONF,            ///<Configuration of sensor, nvm_prog_en bit
         IF_CONF,         ///<Contains settings for the digital interface
         PMU_TRIGGER,     ///<Sets trigger conditions to change gyro power modes
         SELF_TEST,       ///<Self test configuration
         NV_CONF = 0x70,  ///<Contains settings for the digital interface
-        OFFSET_0,        ///<Contains offset comp values for acc_off_x7:0
-        OFFSET_1,        ///<Contains offset comp values for acc_off_y7:0
-        OFFSET_2,        ///<Contains offset comp values for acc_off_z7:0
-        OFFSET_3,        ///<Contains offset comp values for gyr_off_x7:0
-        OFFSET_4,        ///<Contains offset comp values for gyr_off_y7:0
-        OFFSET_5,        ///<Contains offset comp values for gyr_off_z7:0
-        OFFSET_6,        ///<gyr/acc offset enable bit and gyr_off_(zyx) bits9:8
+        OFFSET_0 = 0x71,        ///<Contains offset comp values for acc_off_x7:0
+        OFFSET_1 = 0x71,        ///<Contains offset comp values for acc_off_y7:0
+        OFFSET_2 = 0x71,        ///<Contains offset comp values for acc_off_z7:0
+        OFFSET_3 = 0x74,        ///<Contains offset comp values for gyr_off_x7:0
+        OFFSET_4 = 0x75,        ///<Contains offset comp values for gyr_off_y7:0
+        OFFSET_5 = 0x76,        ///<Contains offset comp values for gyr_off_z7:0
+        OFFSET_6 = 0x77,        ///<gyr/acc offset enable bit and gyr_off_(zyx) bits9:8
         STEP_CNT_0,      ///<Step counter bits 15:8
         STEP_CNT_1,      ///<Step counter bits 7:0
         STEP_CONF_0,     ///<Contains configuration of the step detector
@@ -224,6 +237,10 @@
     static const uint8_t MAG_DRDY_ERR_MASK = 0x80;
     static const uint8_t MAG_DRDY_ERR_POS = 0x08;
     
+    static const uint8_t FOC_VALUE = 0x7D;
+    static const uint8_t FOC_START = 0x03;
+    static const uint8_t FOC_ENABLE_GYR_ACC = 0xC0;
+    
     ///Enumerated error codes
     enum ErrorCodes
     {
@@ -251,6 +268,7 @@
     static const uint8_t ACC_US_POS = 0x07;
     static const uint8_t ACC_RANGE_MASK = 0x0F;
     static const uint8_t ACC_RANGE_POS = 0x00;
+    static const uint8_t GYRO_RANGE_500 = 0x02;
     
     ///Accelerometer output data rates
     enum AccOutputDataRate
@@ -298,6 +316,10 @@
         SENS_16G = 0x0C ///<Accelerometer range +-16G
     };
     
+   
+    
+  
+    
     ///Accelerometer configuration data structure
     struct AccConfig
     {
@@ -586,7 +608,9 @@
     int32_t getSensorTime(SensorTime &sensorTime);
     
     
-    ///@brief Get die temperature.\n
+    
+    
+    ///@brief Get die temperature.\n 
     ///
     ///On Entry:
     ///@param[in] temp - pointer to float for temperature 
@@ -788,3 +812,7 @@
 ///@param[out] none
 ///
 ///@returns none
+int8_t start_foc(struct bmi160_dev *dev);
+
+int8_t bmi160_start_foc(const struct bmi160_foc_conf *foc_conf, struct bmi160_offsets *offset,
+                struct bmi160_dev const *dev);
\ No newline at end of file