Example host software to display SpO2 or Heart Rate on wrist using the MAX32664GWEC or MAXREFDES101 with IR/Red LED board. It is recommended that the MAX32664 be loaded with the latest Maxim supplied algorithm (.msbl file).

Dependencies:   Maxim_Sensor_Hub_Communications BMI160 demoUI max32630hsp3

Fork of Host_Software_MAX32664GWEC_SpO2_HR by mehmet gok

Files at this revision

API Documentation at this revision

Comitter:
gmehmet
Date:
Mon Dec 17 11:20:26 2018 +0000
Parent:
6:f2bd1cff0796
Child:
8:5c9d43f84ab8
Commit message:
commit 24

Changed in this revision

accelerometer.lib Show annotated file Show diff for this revision Revisions of this file
accelerometer/bmi160.cpp Show diff for this revision Revisions of this file
accelerometer/bmi160.h Show diff for this revision Revisions of this file
accelerometer/bmi160_i2c.cpp Show diff for this revision Revisions of this file
accelerometer/bmi160_spi.cpp Show diff for this revision Revisions of this file
demoUI.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/accelerometer.lib	Mon Dec 17 11:20:26 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/gmehmet/code/accelerometer/#6ae45b98ab03
--- a/accelerometer/bmi160.cpp	Mon Dec 17 10:44:03 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,723 +0,0 @@
-/**********************************************************************
-* Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a
-* copy of this software and associated documentation files (the "Software"),
-* to deal in the Software without restriction, including without limitation
-* the rights to use, copy, modify, merge, publish, distribute, sublicense,
-* and/or sell copies of the Software, and to permit persons to whom the
-* Software is furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included
-* in all copies or substantial portions of the Software.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
-* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-* OTHER DEALINGS IN THE SOFTWARE.
-*
-* Except as contained in this notice, the name of Maxim Integrated
-* Products, Inc. shall not be used except as stated in the Maxim Integrated
-* Products, Inc. Branding Policy.
-*
-* The mere transfer of this software does not imply any licenses
-* of trade secrets, proprietary technology, copyrights, patents,
-* trademarks, maskwork rights, or any other form of intellectual
-* property whatsoever. Maxim Integrated Products, Inc. retains all
-* ownership rights.
-**********************************************************************/
-
-
-#include "bmi160.h"
-
-
-const struct BMI160::AccConfig BMI160::DEFAULT_ACC_CONFIG = {SENS_2G,
-                                                             ACC_US_OFF,
-                                                             ACC_BWP_2,
-                                                             ACC_ODR_8};
-
-const struct BMI160::GyroConfig BMI160::DEFAULT_GYRO_CONFIG = {DPS_2000,
-                                                               GYRO_BWP_2,
-                                                               GYRO_ODR_8};
-
-
-//*****************************************************************************
-int32_t BMI160::setSensorPowerMode(Sensors sensor, PowerModes pwrMode)
-{
-    int32_t rtnVal = -1;
-
-    switch(sensor)
-    {
-        case MAG:
-            rtnVal = writeRegister(CMD, (MAG_SET_PMU_MODE | pwrMode));
-        break;
-
-        case GYRO:
-            rtnVal = writeRegister(CMD, (GYR_SET_PMU_MODE | pwrMode));
-        break;
-
-        case ACC:
-            rtnVal = writeRegister(CMD, (ACC_SET_PMU_MODE | pwrMode));
-        break;
-
-        default:
-            rtnVal = -1;
-        break;
-    }
-
-    return rtnVal;
-}
-
-
-//*****************************************************************************
-int32_t BMI160::setSensorConfig(const AccConfig &config)
-{
-    uint8_t data[2];
-
-    data[0] = ((config.us << ACC_US_POS) | (config.bwp << ACC_BWP_POS) |
-               (config.odr << ACC_ODR_POS));
-    data[1] = config.range;
-
-    return writeBlock(ACC_CONF, ACC_RANGE, data);
-}
-
-
-//*****************************************************************************
-int32_t BMI160::setSensorConfig(const GyroConfig &config)
-{
-    uint8_t data[2];
-
-    data[0] = ((config.bwp << GYRO_BWP_POS) | (config.odr << GYRO_ODR_POS));
-    data[1] = config.range;
-
-    return writeBlock(GYR_CONF, GYR_RANGE, data);
-}
-
-
-//*****************************************************************************
-int32_t BMI160::getSensorConfig(AccConfig &config)
-{
-    uint8_t data[2];
-    int32_t rtnVal = readBlock(ACC_CONF, ACC_RANGE, data);
-
-    if(rtnVal == RTN_NO_ERROR)
-    {
-        config.range = static_cast<BMI160::AccRange>(
-        (data[1] & ACC_RANGE_MASK));
-        config.us = static_cast<BMI160::AccUnderSampling>(
-        ((data[0] & ACC_US_MASK) >> ACC_US_POS));
-        config.bwp = static_cast<BMI160::AccBandWidthParam>(
-        ((data[0] & ACC_BWP_MASK) >> ACC_BWP_POS));
-        config.odr = static_cast<BMI160::AccOutputDataRate>(
-        ((data[0] & ACC_ODR_MASK) >> ACC_ODR_POS));
-    }
-
-    return rtnVal;
-}
-
-
-//*****************************************************************************
-int32_t BMI160::getSensorConfig(GyroConfig &config)
-{
-    uint8_t data[2];
-    int32_t rtnVal = readBlock(GYR_CONF, GYR_RANGE, data);
-
-    if(rtnVal == RTN_NO_ERROR)
-    {
-        config.range = static_cast<BMI160::GyroRange>(
-        (data[1] & GYRO_RANGE_MASK));
-        config.bwp = static_cast<BMI160::GyroBandWidthParam>(
-        ((data[0] & GYRO_BWP_MASK) >> GYRO_BWP_POS));
-        config.odr = static_cast<BMI160::GyroOutputDataRate>(
-        ((data[0] & GYRO_ODR_MASK) >> GYRO_ODR_POS));
-    }
-
-    return rtnVal;
-}
-
-
-//*****************************************************************************
-int32_t BMI160::getSensorAxis(SensorAxis axis, AxisData &data, AccRange range)
-{
-    uint8_t localData[2];
-    int32_t rtnVal;
-
-    switch(axis)
-    {
-        case X_AXIS:
-            rtnVal = readBlock(DATA_14, DATA_15, localData);
-        break;
-
-        case Y_AXIS:
-            rtnVal = readBlock(DATA_16, DATA_17, localData);
-        break;
-
-        case Z_AXIS:
-            rtnVal = readBlock(DATA_18, DATA_19, localData);
-        break;
-
-        default:
-            rtnVal = -1;
-        break;
-    }
-
-    if(rtnVal == RTN_NO_ERROR)
-    {
-        data.raw = ((localData[1] << 8) | localData[0]);
-        switch(range)
-        {
-            case SENS_2G:
-                data.scaled = (data.raw/SENS_2G_LSB_PER_G);
-            break;
-
-            case SENS_4G:
-                data.scaled = (data.raw/SENS_4G_LSB_PER_G);
-            break;
-
-            case SENS_8G:
-                data.scaled = (data.raw/SENS_8G_LSB_PER_G);
-            break;
-
-            case SENS_16G:
-                data.scaled = (data.raw/SENS_16G_LSB_PER_G);
-            break;
-        }
-    }
-
-    return rtnVal;
-}
-
-
-//*****************************************************************************
-int32_t BMI160::getSensorAxis(SensorAxis axis, AxisData &data, GyroRange range)
-{
-    uint8_t localData[2];
-    int32_t rtnVal;
-
-    switch(axis)
-    {
-        case X_AXIS:
-            rtnVal = readBlock(DATA_8, DATA_9, localData);
-        break;
-
-        case Y_AXIS:
-            rtnVal = readBlock(DATA_10, DATA_11, localData);
-        break;
-
-        case Z_AXIS:
-            rtnVal = readBlock(DATA_12, DATA_13, localData);
-        break;
-
-        default:
-            rtnVal = -1;
-        break;
-    }
-
-    if(rtnVal == RTN_NO_ERROR)
-    {
-        data.raw = ((localData[1] << 8) | localData[0]);
-        switch(range)
-        {
-            case DPS_2000:
-                data.scaled = (data.raw/SENS_2000_DPS_LSB_PER_DPS);
-            break;
-
-            case DPS_1000:
-                data.scaled = (data.raw/SENS_1000_DPS_LSB_PER_DPS);
-            break;
-
-            case DPS_500:
-                data.scaled = (data.raw/SENS_500_DPS_LSB_PER_DPS);
-            break;
-
-            case DPS_250:
-                data.scaled = (data.raw/SENS_250_DPS_LSB_PER_DPS);
-            break;
-
-            case DPS_125:
-                data.scaled = (data.raw/SENS_125_DPS_LSB_PER_DPS);
-            break;
-        }
-    }
-
-    return rtnVal;
-}
-
-
-//*****************************************************************************
-int32_t BMI160::getSensorXYZ(SensorData &data, AccRange range)
-{
-    uint8_t localData[6];
-    int32_t rtnVal = readBlock(DATA_14, DATA_19, localData);
-
-	if (m_use_irq == true && bmi160_irq_asserted == false)
-		return -1;
-
-	bmi160_irq_asserted = false;
-    if(rtnVal == RTN_NO_ERROR)
-    {
-        data.xAxis.raw = ((localData[1] << 8) | localData[0]);
-        data.yAxis.raw = ((localData[3] << 8) | localData[2]);
-        data.zAxis.raw = ((localData[5] << 8) | localData[4]);
-
-        switch(range)
-        {
-            case SENS_2G:
-                data.xAxis.scaled = (data.xAxis.raw/SENS_2G_LSB_PER_G);
-                data.yAxis.scaled = (data.yAxis.raw/SENS_2G_LSB_PER_G);
-                data.zAxis.scaled = (data.zAxis.raw/SENS_2G_LSB_PER_G);
-            break;
-
-            case SENS_4G:
-                data.xAxis.scaled = (data.xAxis.raw/SENS_4G_LSB_PER_G);
-                data.yAxis.scaled = (data.yAxis.raw/SENS_4G_LSB_PER_G);
-                data.zAxis.scaled = (data.zAxis.raw/SENS_4G_LSB_PER_G);
-            break;
-
-            case SENS_8G:
-                data.xAxis.scaled = (data.xAxis.raw/SENS_8G_LSB_PER_G);
-                data.yAxis.scaled = (data.yAxis.raw/SENS_8G_LSB_PER_G);
-                data.zAxis.scaled = (data.zAxis.raw/SENS_8G_LSB_PER_G);
-            break;
-
-            case SENS_16G:
-                data.xAxis.scaled = (data.xAxis.raw/SENS_16G_LSB_PER_G);
-                data.yAxis.scaled = (data.yAxis.raw/SENS_16G_LSB_PER_G);
-                data.zAxis.scaled = (data.zAxis.raw/SENS_16G_LSB_PER_G);
-            break;
-        }
-    }
-
-    return rtnVal;
-}
-
-
-//*****************************************************************************
-int32_t BMI160::getSensorXYZ(SensorData &data, GyroRange range)
-{
-    uint8_t localData[6];
-    int32_t rtnVal = readBlock(DATA_8, DATA_13, localData);
-
-    if(rtnVal == RTN_NO_ERROR)
-    {
-        data.xAxis.raw = ((localData[1] << 8) | localData[0]);
-        data.yAxis.raw = ((localData[3] << 8) | localData[2]);
-        data.zAxis.raw = ((localData[5] << 8) | localData[4]);
-
-        switch(range)
-        {
-            case DPS_2000:
-                data.xAxis.scaled = (data.xAxis.raw/SENS_2000_DPS_LSB_PER_DPS);
-                data.yAxis.scaled = (data.yAxis.raw/SENS_2000_DPS_LSB_PER_DPS);
-                data.zAxis.scaled = (data.zAxis.raw/SENS_2000_DPS_LSB_PER_DPS);
-            break;
-
-            case DPS_1000:
-                data.xAxis.scaled = (data.xAxis.raw/SENS_1000_DPS_LSB_PER_DPS);
-                data.yAxis.scaled = (data.yAxis.raw/SENS_1000_DPS_LSB_PER_DPS);
-                data.zAxis.scaled = (data.zAxis.raw/SENS_1000_DPS_LSB_PER_DPS);
-            break;
-
-            case DPS_500:
-                data.xAxis.scaled = (data.xAxis.raw/SENS_500_DPS_LSB_PER_DPS);
-                data.yAxis.scaled = (data.yAxis.raw/SENS_500_DPS_LSB_PER_DPS);
-                data.zAxis.scaled = (data.zAxis.raw/SENS_500_DPS_LSB_PER_DPS);
-            break;
-
-            case DPS_250:
-                data.xAxis.scaled = (data.xAxis.raw/SENS_250_DPS_LSB_PER_DPS);
-                data.yAxis.scaled = (data.yAxis.raw/SENS_250_DPS_LSB_PER_DPS);
-                data.zAxis.scaled = (data.zAxis.raw/SENS_250_DPS_LSB_PER_DPS);
-            break;
-
-            case DPS_125:
-                data.xAxis.scaled = (data.xAxis.raw/SENS_125_DPS_LSB_PER_DPS);
-                data.yAxis.scaled = (data.yAxis.raw/SENS_125_DPS_LSB_PER_DPS);
-                data.zAxis.scaled = (data.zAxis.raw/SENS_125_DPS_LSB_PER_DPS);
-            break;
-        }
-    }
-
-    return rtnVal;
-}
-
-
-//*****************************************************************************
-int32_t BMI160::getSensorXYZandSensorTime(SensorData &data,
-                                          SensorTime &sensorTime,
-                                          AccRange range)
-{
-    uint8_t localData[9];
-    int32_t rtnVal = readBlock(DATA_14, SENSORTIME_2, localData);
-    if(rtnVal == RTN_NO_ERROR)
-    {
-        data.xAxis.raw = ((localData[1] << 8) | localData[0]);
-        data.yAxis.raw = ((localData[3] << 8) | localData[2]);
-        data.zAxis.raw = ((localData[5] << 8) | localData[4]);
-
-        switch(range)
-        {
-            case SENS_2G:
-                data.xAxis.scaled = (data.xAxis.raw/SENS_2G_LSB_PER_G);
-                data.yAxis.scaled = (data.yAxis.raw/SENS_2G_LSB_PER_G);
-                data.zAxis.scaled = (data.zAxis.raw/SENS_2G_LSB_PER_G);
-            break;
-
-            case SENS_4G:
-                data.xAxis.scaled = (data.xAxis.raw/SENS_4G_LSB_PER_G);
-                data.yAxis.scaled = (data.yAxis.raw/SENS_4G_LSB_PER_G);
-                data.zAxis.scaled = (data.zAxis.raw/SENS_4G_LSB_PER_G);
-            break;
-
-            case SENS_8G:
-                data.xAxis.scaled = (data.xAxis.raw/SENS_8G_LSB_PER_G);
-                data.yAxis.scaled = (data.yAxis.raw/SENS_8G_LSB_PER_G);
-                data.zAxis.scaled = (data.zAxis.raw/SENS_8G_LSB_PER_G);
-            break;
-
-            case SENS_16G:
-                data.xAxis.scaled = (data.xAxis.raw/SENS_16G_LSB_PER_G);
-                data.yAxis.scaled = (data.yAxis.raw/SENS_16G_LSB_PER_G);
-                data.zAxis.scaled = (data.zAxis.raw/SENS_16G_LSB_PER_G);
-            break;
-        }
-
-        sensorTime.raw = ((localData[8] << 16) | (localData[7] << 8) |
-                           localData[6]);
-        sensorTime.seconds = (sensorTime.raw * SENSOR_TIME_LSB);
-    }
-
-    return rtnVal;
-}
-
-
-//*****************************************************************************
-int32_t BMI160::getSensorXYZandSensorTime(SensorData &data,
-                                          SensorTime &sensorTime,
-                                          GyroRange range)
-{
-    uint8_t localData[16];
-    int32_t rtnVal = readBlock(DATA_8, SENSORTIME_2, localData);
-    if(rtnVal == RTN_NO_ERROR)
-    {
-        data.xAxis.raw = ((localData[1] << 8) | localData[0]);
-        data.yAxis.raw = ((localData[3] << 8) | localData[2]);
-        data.zAxis.raw = ((localData[5] << 8) | localData[4]);
-
-        switch(range)
-        {
-            case DPS_2000:
-                data.xAxis.scaled = (data.xAxis.raw/SENS_2000_DPS_LSB_PER_DPS);
-                data.yAxis.scaled = (data.yAxis.raw/SENS_2000_DPS_LSB_PER_DPS);
-                data.zAxis.scaled = (data.zAxis.raw/SENS_2000_DPS_LSB_PER_DPS);
-            break;
-
-            case DPS_1000:
-                data.xAxis.scaled = (data.xAxis.raw/SENS_1000_DPS_LSB_PER_DPS);
-                data.yAxis.scaled = (data.yAxis.raw/SENS_1000_DPS_LSB_PER_DPS);
-                data.zAxis.scaled = (data.zAxis.raw/SENS_1000_DPS_LSB_PER_DPS);
-            break;
-
-            case DPS_500:
-                data.xAxis.scaled = (data.xAxis.raw/SENS_500_DPS_LSB_PER_DPS);
-                data.yAxis.scaled = (data.yAxis.raw/SENS_500_DPS_LSB_PER_DPS);
-                data.zAxis.scaled = (data.zAxis.raw/SENS_500_DPS_LSB_PER_DPS);
-            break;
-
-            case DPS_250:
-                data.xAxis.scaled = (data.xAxis.raw/SENS_250_DPS_LSB_PER_DPS);
-                data.yAxis.scaled = (data.yAxis.raw/SENS_250_DPS_LSB_PER_DPS);
-                data.zAxis.scaled = (data.zAxis.raw/SENS_250_DPS_LSB_PER_DPS);
-            break;
-
-            case DPS_125:
-                data.xAxis.scaled = (data.xAxis.raw/SENS_125_DPS_LSB_PER_DPS);
-                data.yAxis.scaled = (data.yAxis.raw/SENS_125_DPS_LSB_PER_DPS);
-                data.zAxis.scaled = (data.zAxis.raw/SENS_125_DPS_LSB_PER_DPS);
-            break;
-        }
-
-        sensorTime.raw = ((localData[14] << 16) | (localData[13] << 8) |
-                           localData[12]);
-        sensorTime.seconds = (sensorTime.raw * SENSOR_TIME_LSB);
-    }
-
-    return rtnVal;
-}
-
-
-//*****************************************************************************
-int32_t BMI160::getGyroAccXYZandSensorTime(SensorData &accData,
-                                           SensorData &gyroData,
-                                           SensorTime &sensorTime,
-                                           AccRange accRange,
-                                           GyroRange gyroRange)
-{
-    uint8_t localData[16];
-    int32_t rtnVal = readBlock(DATA_8, SENSORTIME_2, localData);
-    if(rtnVal == RTN_NO_ERROR)
-    {
-        gyroData.xAxis.raw = ((localData[1] << 8) | localData[0]);
-        gyroData.yAxis.raw = ((localData[3] << 8) | localData[2]);
-        gyroData.zAxis.raw = ((localData[5] << 8) | localData[4]);
-
-        accData.xAxis.raw = ((localData[7] << 8) | localData[6]);
-        accData.yAxis.raw = ((localData[9] << 8) | localData[8]);
-        accData.zAxis.raw = ((localData[11] << 8) | localData[10]);
-
-        switch(gyroRange)
-        {
-            case DPS_2000:
-                gyroData.xAxis.scaled = (gyroData.xAxis.raw/SENS_2000_DPS_LSB_PER_DPS);
-                gyroData.yAxis.scaled = (gyroData.yAxis.raw/SENS_2000_DPS_LSB_PER_DPS);
-                gyroData.zAxis.scaled = (gyroData.zAxis.raw/SENS_2000_DPS_LSB_PER_DPS);
-            break;
-
-            case DPS_1000:
-                gyroData.xAxis.scaled = (gyroData.xAxis.raw/SENS_1000_DPS_LSB_PER_DPS);
-                gyroData.yAxis.scaled = (gyroData.yAxis.raw/SENS_1000_DPS_LSB_PER_DPS);
-                gyroData.zAxis.scaled = (gyroData.zAxis.raw/SENS_1000_DPS_LSB_PER_DPS);
-            break;
-
-            case DPS_500:
-                gyroData.xAxis.scaled = (gyroData.xAxis.raw/SENS_500_DPS_LSB_PER_DPS);
-                gyroData.yAxis.scaled = (gyroData.yAxis.raw/SENS_500_DPS_LSB_PER_DPS);
-                gyroData.zAxis.scaled = (gyroData.zAxis.raw/SENS_500_DPS_LSB_PER_DPS);
-            break;
-
-            case DPS_250:
-                gyroData.xAxis.scaled = (gyroData.xAxis.raw/SENS_250_DPS_LSB_PER_DPS);
-                gyroData.yAxis.scaled = (gyroData.yAxis.raw/SENS_250_DPS_LSB_PER_DPS);
-                gyroData.zAxis.scaled = (gyroData.zAxis.raw/SENS_250_DPS_LSB_PER_DPS);
-            break;
-
-            case DPS_125:
-                gyroData.xAxis.scaled = (gyroData.xAxis.raw/SENS_125_DPS_LSB_PER_DPS);
-                gyroData.yAxis.scaled = (gyroData.yAxis.raw/SENS_125_DPS_LSB_PER_DPS);
-                gyroData.zAxis.scaled = (gyroData.zAxis.raw/SENS_125_DPS_LSB_PER_DPS);
-            break;
-        }
-
-        switch(accRange)
-        {
-            case SENS_2G:
-                accData.xAxis.scaled = (accData.xAxis.raw/SENS_2G_LSB_PER_G);
-                accData.yAxis.scaled = (accData.yAxis.raw/SENS_2G_LSB_PER_G);
-                accData.zAxis.scaled = (accData.zAxis.raw/SENS_2G_LSB_PER_G);
-            break;
-
-            case SENS_4G:
-                accData.xAxis.scaled = (accData.xAxis.raw/SENS_4G_LSB_PER_G);
-                accData.yAxis.scaled = (accData.yAxis.raw/SENS_4G_LSB_PER_G);
-                accData.zAxis.scaled = (accData.zAxis.raw/SENS_4G_LSB_PER_G);
-            break;
-
-            case SENS_8G:
-                accData.xAxis.scaled = (accData.xAxis.raw/SENS_8G_LSB_PER_G);
-                accData.yAxis.scaled = (accData.yAxis.raw/SENS_8G_LSB_PER_G);
-                accData.zAxis.scaled = (accData.zAxis.raw/SENS_8G_LSB_PER_G);
-            break;
-
-            case SENS_16G:
-                accData.xAxis.scaled = (accData.xAxis.raw/SENS_16G_LSB_PER_G);
-                accData.yAxis.scaled = (accData.yAxis.raw/SENS_16G_LSB_PER_G);
-                accData.zAxis.scaled = (accData.zAxis.raw/SENS_16G_LSB_PER_G);
-            break;
-        }
-
-        sensorTime.raw = ((localData[14] << 16) | (localData[13] << 8) |
-                           localData[12]);
-        sensorTime.seconds = (sensorTime.raw * SENSOR_TIME_LSB);
-    }
-
-    return rtnVal;
-}
-
-int32_t BMI160::setSampleRate(int sample_rate)
-{
-	int sr_reg_val = -1;
-	int i;
-	const uint16_t odr_table[][2] = {
-	    {25, GYRO_ODR_6}, ///<25Hz
-        {50, GYRO_ODR_7}, ///<50Hz
-        {100, GYRO_ODR_8}, ///<100Hz
-        {200, GYRO_ODR_9}, ///<200Hz
-        {400, GYRO_ODR_10}, ///<400Hz
-        {800, GYRO_ODR_11}, ///<800Hz
-        {1600, GYRO_ODR_12}, ///<1600Hz
-        {3200, GYRO_ODR_13}, ///<3200Hz
-	};
-
-	int num_sr = sizeof(odr_table)/sizeof(odr_table[0]);
-	for (i = 0; i < num_sr; i++) {
-		if (sample_rate == odr_table[i][0]) {
-			sr_reg_val = odr_table[i][1];
-			break;
-		}
-	}
-
-	if (sr_reg_val == -1)
-		return -2;
-
-	AccConfig accConfigRead;
-	if (getSensorConfig(accConfigRead) == BMI160::RTN_NO_ERROR) {
-	accConfigRead.odr = (AccOutputDataRate)sr_reg_val;
-		return setSensorConfig(accConfigRead) == BMI160::RTN_NO_ERROR ? 0 : -1;
-	} else
-		return -1;
-}
-
-
-//*****************************************************************************
-int32_t BMI160::getSensorTime(SensorTime &sensorTime)
-{
-    uint8_t localData[3];
-    int32_t rtnVal = readBlock(SENSORTIME_0, SENSORTIME_2, localData);
-
-    if(rtnVal == RTN_NO_ERROR)
-    {
-        sensorTime.raw = ((localData[2] << 16) | (localData[1] << 8) |
-                           localData[0]);
-        sensorTime.seconds = (sensorTime.raw * SENSOR_TIME_LSB);
-    }
-
-    return rtnVal;
-}
-
-
-//*****************************************************************************
-int32_t BMI160::getTemperature(float *temp)
-{
-    uint8_t data[2];
-    uint16_t rawTemp;
-
-    int32_t rtnVal = readBlock(TEMPERATURE_0, TEMPERATURE_1, data);
-    if(rtnVal == RTN_NO_ERROR)
-    {
-        rawTemp = ((data[1] << 8) | data[0]);
-        if(rawTemp & 0x8000)
-        {
-            *temp = (23.0F - ((0x10000 - rawTemp)/512.0F));
-        }
-        else
-        {
-            *temp = ((rawTemp/512.0F) + 23.0F);
-        }
-    }
-
-    return rtnVal;
-}
-
-//***********************************************************************************
-int32_t BMI160::BMI160_DefaultInitalize(){
-
-		//soft reset the accelerometer
-		writeRegister(CMD ,SOFT_RESET);
-		wait(0.1);
-
-	    //Power up sensors in normal mode
-	    if(setSensorPowerMode(BMI160::GYRO, BMI160::SUSPEND) != BMI160::RTN_NO_ERROR){
-	        printf("Failed to set gyroscope power mode\n");
-	    }
-
-	    wait(0.1);
-
-	    if(setSensorPowerMode(BMI160::ACC, BMI160::NORMAL) != BMI160::RTN_NO_ERROR){
-	        printf("Failed to set accelerometer power mode\n");
-	    }
-	    wait(0.1);
-
-	    BMI160::AccConfig accConfig;
-	    BMI160::AccConfig accConfigRead;
-	    accConfig.range = BMI160::SENS_2G;
-	    accConfig.us = BMI160::ACC_US_OFF;
-	    accConfig.bwp = BMI160::ACC_BWP_2;
-	    accConfig.odr = BMI160::ACC_ODR_6;
-	    if(setSensorConfig(accConfig) == BMI160::RTN_NO_ERROR)
-	    {
-	        if(getSensorConfig(accConfigRead) == BMI160::RTN_NO_ERROR)
-	        {
-	            if((accConfig.range != accConfigRead.range) ||
-	                    (accConfig.us != accConfigRead.us) ||
-	                    (accConfig.bwp != accConfigRead.bwp) ||
-	                    (accConfig.odr != accConfigRead.odr))
-	            {
-	                printf("ACC read data desn't equal set data\n\n");
-	                printf("ACC Set Range = %d\n", accConfig.range);
-	                printf("ACC Set UnderSampling = %d\n", accConfig.us);
-	                printf("ACC Set BandWidthParam = %d\n", accConfig.bwp);
-	                printf("ACC Set OutputDataRate = %d\n\n", accConfig.odr);
-	                printf("ACC Read Range = %d\n", accConfigRead.range);
-	                printf("ACC Read UnderSampling = %d\n", accConfigRead.us);
-	                printf("ACC Read BandWidthParam = %d\n", accConfigRead.bwp);
-	                printf("ACC Read OutputDataRate = %d\n\n", accConfigRead.odr);
-	            }
-
-	        }
-	        else
-	        {
-	             printf("Failed to read back accelerometer configuration\n");
-	        }
-	    }
-	    else
-	    {
-	        printf("Failed to set accelerometer configuration\n");
-	    }
-	    return 0;
-}
-
-//***********************************************************************************
-int32_t BMI160::enable_data_ready_interrupt() {
-	uint8_t data = 0;
-	uint8_t temp = 0;
-	int32_t result;
-
-	result = readRegister(INT_EN_1, &data);
-	temp = data & ~0x10;
-	data = temp | ((1 << 4) & 0x10);
-	/* Writing data to INT ENABLE 1 Address */
-	result |= writeRegister(INT_EN_1, data);
-
-	// configure in_out ctrl
-	//bmi160_get_regs(BMI160_INT_OUT_CTRL_ADDR, &data, 1, dev);
-	result |= readRegister(INT_OUT_CTRL, &data);
-	data = 0x09;
-	result |= writeRegister(INT_OUT_CTRL,data);
-
-	//config int latch
-	//bmi160_get_regs(BMI160_INT_LATCH_ADDR, &data, 1, dev);
-	result |= readRegister(INT_LATCH, &data);
-	data = 0x0F;
-	result |= writeRegister(INT_LATCH, data);
-
-	//bmi160_get_regs(BMI160_INT_MAP_1_ADDR, &data, 1, dev);
-	result |= readRegister(INT_MAP_1, &data);
-	data = 0x80;
-	result |= writeRegister(INT_MAP_1, data);
-
-	if(result != 0){
-		printf("BMI160::%s failed.\r\n", __func__);
-		return -1;
-	}
-
-	m_bmi160_irq->disable_irq();
-	m_bmi160_irq->mode(PullUp);
-	m_bmi160_irq->fall(this, &BMI160::irq_handler);
-	m_bmi160_irq->enable_irq();
-	return 0;
-}
-
-void BMI160::irq_handler() {
-	bmi160_irq_asserted = true;
-}
-
-int32_t BMI160::reset() {
-	if (m_use_irq)
-		m_bmi160_irq->disable_irq();
-	bmi160_irq_asserted = false;
-	writeRegister(CMD, SOFT_RESET);
-	return 0;
-}
--- a/accelerometer/bmi160.h	Mon Dec 17 10:44:03 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,845 +0,0 @@
-/**********************************************************************
-* Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a
-* copy of this software and associated documentation files (the "Software"),
-* to deal in the Software without restriction, including without limitation
-* the rights to use, copy, modify, merge, publish, distribute, sublicense,
-* and/or sell copies of the Software, and to permit persons to whom the
-* Software is furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included
-* in all copies or substantial portions of the Software.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
-* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-* OTHER DEALINGS IN THE SOFTWARE.
-*
-* Except as contained in this notice, the name of Maxim Integrated
-* Products, Inc. shall not be used except as stated in the Maxim Integrated
-* Products, Inc. Branding Policy.
-*
-* The mere transfer of this software does not imply any licenses
-* of trade secrets, proprietary technology, copyrights, patents,
-* trademarks, maskwork rights, or any other form of intellectual
-* property whatsoever. Maxim Integrated Products, Inc. retains all
-* ownership rights.
-**********************************************************************/
-
-
-#ifndef BMI160_H
-#define BMI160_H
-
-#include "mbed.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
-navigation which require highly accurate, real-time sensor data.
-
-In full operation mode, with both the accelerometer and gyroscope enabled, the
-current consumption is typically 950 μA, enabling always-on applications in
-battery driven devices. It is available in a compact 14-pin 2.5 x 3.0 x 0.8 mm³
-LGA package."
-
-This class is an abstract base class and can not be instaniated, use BMI160_I2C
-or BMI160_SPI.
-*/
-class BMI160
-{
-public:
-
-    ///Return value on success.
-    static const uint8_t RTN_NO_ERROR = 0;
-
-    ///Sensor types
-    enum Sensors
-    {
-        MAG = 0, ///<Optional external sensor
-        GYRO,    ///<Angular rate sensor
-        ACC      ///<g sensor
-    };
-
-    ///Sensor Axis
-    enum SensorAxis
-    {
-        X_AXIS = 0,
-        Y_AXIS,
-        Z_AXIS
-    };
-
-    ///Structure for axis data
-    struct AxisData
-    {
-        int16_t raw;  ///<Axis raw data
-        float scaled; ///<Axis scaled data
-    };
-
-    ///Structure for sensor time data
-    struct SensorTime
-    {
-        uint32_t raw;  ///<raw SensorTime
-        float seconds; ///<SensorTime as seconds
-    };
-
-    ///Period of internal counter
-    static const float SENSOR_TIME_LSB = 39e-6;
-
-    ///Structure for holding sensor data
-    struct SensorData
-    {
-        AxisData xAxis; ///<Sensor X axis data
-        AxisData yAxis; ///<Sensor Y axis data
-        AxisData zAxis; ///<Sensor Z axis data
-    };
-
-
-    ///BMI160 registers
-    enum Registers
-    {
-        CHIP_ID = 0x00,  ///<Chip Identification.
-        ERR_REG = 0x02,  ///<Reports sensor error flags.  Flags reset when read.
-        PMU_STATUS,      ///<Reports current power mode for sensors.
-        DATA_0,          ///<MAG_X axis bits7:0
-        DATA_1,          ///<MAG_X axis bits15:8
-        DATA_2,          ///<MAG_Y axis bits7:0
-        DATA_3,          ///<MAG_Y axis bits15:8
-        DATA_4,          ///<MAG_Z axis bits7:0
-        DATA_5,          ///<MAG_Z axis bits15:8
-        DATA_6,          ///<RHALL bits7:0
-        DATA_7,          ///<RHALL bits15:8
-        DATA_8,          ///<GYR_X axis bits7:0
-        DATA_9,          ///<GYR_X axis bits15:8
-        DATA_10,         ///<GYR_Y axis bits7:0
-        DATA_11,         ///<GYR_Y axis bits15:8
-        DATA_12,         ///<GYR_Z axis bits7:0
-        DATA_13,         ///<GYR_Z axis bits15:8
-        DATA_14,         ///<ACC_X axis bits7:0
-        DATA_15,         ///<ACC_X axis bits15:8
-        DATA_16,         ///<ACC_Y axis bits7:0
-        DATA_17,         ///<ACC_Y axis bits15:8
-        DATA_18,         ///<ACC_Z axis bits7:0
-        DATA_19,         ///<ACC_Z axis bits15:8
-        SENSORTIME_0,    ///<24bit counter synchronized with data, bits7:0
-        SENSORTIME_1,    ///<24bit counter synchronized with data, bits15:8
-        SENSORTIME_2,    ///<24bit counter synchronized with data, bits23:16
-        STATUS,          ///<Reports sensors status flags
-        INT_STATUS_0,    ///<Contains interrupt status flags
-        INT_STATUS_1,    ///<Contains interrupt status flags
-        INT_STATUS_2,    ///<Contains interrupt status flags
-        INT_STATUS_3,    ///<Contains interrupt status flags
-        TEMPERATURE_0,   ///<Contains temperature of sensor, bits7:0
-        TEMPERATURE_1,   ///<Contains temperature of sensor, bits15:8
-        FIFO_LENGTH_0,   ///<Current fill level of FIFO, bits7:0
-        FIFO_LENGTH_1,   ///<Current fill level of FIFO, bits10:8
-        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_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
-                         ///<for FIFO
-        FIFO_CONFIG_0,   ///<Sets FIFO Watermark
-        FIFO_CONFIG_1,   ///<Sets which sensor data is available in FIFO,
-                         ///<Header/Headerless mode, Ext Int tagging, Sensortime
-        MAG_IF_0 = 0x4B, ///<Magnetometer 7-bit I2C address, bits7:1
-        MAG_IF_1,        ///<Magnetometer interface configuration
-        MAG_IF_2,        ///<Magnetometer address to read
-        MAG_IF_3,        ///<Magnetometer address to write
-        MAG_IF_4,        ///<Magnetometer data to write
-        INT_EN_0,        ///<Interrupt enable bits
-        INT_EN_1,        ///<Interrupt enable bits
-        INT_EN_2,        ///<Interrupt enable bits
-        INT_OUT_CTRL,    ///<Contains the behavioral configuration of INT pins
-        INT_LATCH,       ///<Contains the interrupt rest bit and the interrupt
-                         ///<mode selection
-        INT_MAP_0,       ///<Controls which interrupt signals are mapped to the
-                         ///<INT1 and INT2 pins
-        INT_MAP_1,       ///<Controls which interrupt signals are mapped to the
-                         ///<INT1 and INT2 pins
-        INT_MAP_2,       ///<Controls which interrupt signals are mapped to the
-                         ///<INT1 and INT2 pins
-        INT_DATA_0,      ///<Contains the data source definition for the two
-                         ///<interrupt groups
-        INT_DATA_1,      ///<Contains the data source definition for the two
-                         ///<interrupt groups
-        INT_LOWHIGH_0,   ///<Contains the configuration for the low g interrupt
-        INT_LOWHIGH_1,   ///<Contains the configuration for the low g interrupt
-        INT_LOWHIGH_2,   ///<Contains the configuration for the low g interrupt
-        INT_LOWHIGH_3,   ///<Contains the configuration for the low g interrupt
-        INT_LOWHIGH_4,   ///<Contains the configuration for the low g interrupt
-        INT_MOTION_0,    ///<Contains the configuration for the any motion and
-                         ///<no motion interrupts
-        INT_MOTION_1,    ///<Contains the configuration for the any motion and
-                         ///<no motion interrupts
-        INT_MOTION_2,    ///<Contains the configuration for the any motion and
-                         ///<no motion interrupts
-        INT_MOTION_3,    ///<Contains the configuration for the any motion and
-                         ///<no motion interrupts
-        INT_TAP_0,       ///<Contains the configuration for the tap interrupts
-        INT_TAP_1,       ///<Contains the configuration for the tap interrupts
-        INT_ORIENT_0,    ///<Contains the configuration for the oeientation
-                         ///<interrupt
-        INT_ORIENT_1,    ///<Contains the configuration for the oeientation
-                         ///<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
-                         ///<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
-        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
-        STEP_CONF_1,     ///<Contains configuration of the step detector
-        CMD = 0x7E       ///<Command register triggers operations like
-                         ///<softreset, NVM programming, etc.
-    };
-
-
-    ///@name ERR_REG(0x02)
-    ///Error register data
-    ///@{
-
-    static const uint8_t FATAL_ERR_MASK = 0x01;
-    static const uint8_t FATAL_ERR_POS = 0x00;
-    static const uint8_t ERR_CODE_MASK = 0x1E;
-    static const uint8_t ERR_CODE_POS = 0x01;
-    static const uint8_t I2C_FAIL_ERR_MASK = 0x20;
-    static const uint8_t I2C_FAIL_ERR_POS = 0x05;
-    static const uint8_t DROP_CMD_ERR_MASK = 0x40;
-    static const uint8_t DROP_CMD_ERR_POS = 0x06;
-    static const uint8_t MAG_DRDY_ERR_MASK = 0x80;
-    static const uint8_t MAG_DRDY_ERR_POS = 0x08;
-
-    ///Enumerated error codes
-    enum ErrorCodes
-    {
-        NO_ERROR = 0,        ///<No Error
-        ERROR_1,             ///<Listed as error
-        ERROR_2,             ///<Listed as error
-        LPM_INT_PFD,         ///<Low-power mode and interrupt uses pre-filtered
-                             ///<data
-        ODR_MISMATCH = 0x06, ///<ODRs of enabled sensors in headerless mode do
-                             ///<not match
-        PFD_USED_LPM         ///<Pre-filtered data are used in low power mode
-    };
-    ///@}
-
-
-    ///@name ACC_CONF(0x40) and ACC_RANGE(0x41)
-    ///Data for configuring accelerometer
-    ///@{
-
-    static const uint8_t ACC_ODR_MASK = 0x0F;
-    static const uint8_t ACC_ODR_POS = 0x00;
-    static const uint8_t ACC_BWP_MASK = 0x70;
-    static const uint8_t ACC_BWP_POS = 0x04;
-    static const uint8_t ACC_US_MASK = 0x80;
-    static const uint8_t ACC_US_POS = 0x07;
-    static const uint8_t ACC_RANGE_MASK = 0x0F;
-    static const uint8_t ACC_RANGE_POS = 0x00;
-
-    ///Accelerometer output data rates
-    enum AccOutputDataRate
-    {
-        ACC_ODR_1 = 1,  ///< 25/32Hz
-        ACC_ODR_2,      ///< 25/16Hz
-        ACC_ODR_3,      ///< 25/8Hz
-        ACC_ODR_4,      ///< 25/4Hz
-        ACC_ODR_5,      ///< 25/2Hz
-        ACC_ODR_6,      ///< 25Hz
-        ACC_ODR_7,      ///< 50Hz
-        ACC_ODR_8,      ///< 100Hz
-        ACC_ODR_9,      ///< 200Hz
-        ACC_ODR_10,     ///< 400Hz
-        ACC_ODR_11,     ///< 800Hz
-        ACC_ODR_12      ///< 1600Hz
-    };
-
-    ///Accelerometer bandwidth parameters
-    enum AccBandWidthParam
-    {
-        ACC_BWP_0 = 0, ///< Average 1 cycle;  when acc_us = 0 OSR4
-        ACC_BWP_1,     ///< Average 2 cycles; when acc_us = 0 OSR2
-        ACC_BWP_2,     ///< Average 4 cycles; when acc_us = 0 normal mode
-        ACC_BWP_3,     ///< Average 8 cycles
-        ACC_BWP_4,     ///< Average 16 cycles
-        ACC_BWP_5,     ///< Average 32 cycles
-        ACC_BWP_6,     ///< Average 64 cycles
-        ACC_BWP_7      ///< Average 128 cycles
-    };
-
-    ///Accelerometer undersampling
-    enum AccUnderSampling
-    {
-        ACC_US_OFF = 0,
-        ACC_US_ON
-    };
-
-    ///Accelerometer ranges
-    enum AccRange
-    {
-        SENS_2G = 0x03,  ///<Accelerometer range +-2G
-        SENS_4G = 0x05,  ///<Accelerometer range +-4G
-        SENS_8G = 0x08,  ///<Accelerometer range +-8G
-        SENS_16G = 0x0C ///<Accelerometer range +-16G
-    };
-
-    static const float SENS_2G_LSB_PER_G = 16384.0F;
-    static const float SENS_4G_LSB_PER_G = 8192.0F;
-    static const float SENS_8G_LSB_PER_G = 4096.0F;
-    static const float SENS_16G_LSB_PER_G = 2048.0F;
-
-    ///Accelerometer configuration data structure
-    struct AccConfig
-    {
-        AccRange range;        ///<Accelerometer range
-        AccUnderSampling us;   ///<Accelerometr undersampling mode
-        AccBandWidthParam bwp; ///<Accelerometer bandwidth param
-        AccOutputDataRate odr; ///<Accelerometr output data rate
-    };
-
-    ///Accelerometer default configuration
-    static const AccConfig DEFAULT_ACC_CONFIG;
-    ///@}
-
-
-    ///@name GYR_CONF(0x42) and GYR_RANGE(0x43)
-    ///Data for configuring gyroscope
-    ///@{
-
-    static const uint8_t GYRO_ODR_MASK = 0x0F;
-    static const uint8_t GYRO_ODR_POS = 0x00;
-    static const uint8_t GYRO_BWP_MASK = 0x30;
-    static const uint8_t GYRO_BWP_POS = 0x04;
-    static const uint8_t GYRO_RANGE_MASK = 0x07;
-    static const uint8_t GYRO_RANGE_POS = 0x00;
-
-    ///Gyroscope output data rates
-    enum GyroOutputDataRate
-    {
-        GYRO_ODR_6 = 0x06,  ///<25Hz
-        GYRO_ODR_7 = 0x07,  ///<50Hz
-        GYRO_ODR_8 = 0x08,  ///<100Hz
-        GYRO_ODR_9 = 0x09,  ///<200Hz
-        GYRO_ODR_10 = 0x0A, ///<400Hz
-        GYRO_ODR_11 = 0x0B, ///<800Hz
-        GYRO_ODR_12 = 0x0C, ///<1600Hz
-        GYRO_ODR_13 = 0x0D  ///<3200Hz
-    };
-
-    ///Gyroscope bandwidth paramaters
-    enum GyroBandWidthParam
-    {
-        GYRO_BWP_0 = 0, ///<OSR4 Over Sampling Rate of 4
-        GYRO_BWP_1,     ///<OSR2 Over Sampling Rate of 2
-        GYRO_BWP_2      ///<Normal Mode, Equidistant Sampling
-    };
-
-    ///Gyroscope ranges
-    enum GyroRange
-    {
-        DPS_2000 = 0, ///<+-2000dps, 16.4LSB/dps
-        DPS_1000,     ///<+-1000dps, 32.8LSB/dps
-        DPS_500,      ///<+-500dps, 65.6LSB/dps
-        DPS_250,      ///<+-250dps, 131.2LSB/dps
-        DPS_125       ///<+-125dps, 262.4LSB/dps,
-    };
-
-    static const float SENS_2000_DPS_LSB_PER_DPS = 16.4F;
-    static const float SENS_1000_DPS_LSB_PER_DPS = 32.8F;
-    static const float SENS_500_DPS_LSB_PER_DPS = 65.6F;
-    static const float SENS_250_DPS_LSB_PER_DPS = 131.2F;
-    static const float SENS_125_DPS_LSB_PER_DPS = 262.4F;
-
-    ///Gyroscope configuration data structure
-    struct GyroConfig
-    {
-        GyroRange range;        ///<Gyroscope range
-        GyroBandWidthParam bwp; ///<Gyroscope bandwidth param
-        GyroOutputDataRate odr; ///<Gyroscope output data rate
-    };
-
-    ///Gyroscope default configuration
-    static const GyroConfig DEFAULT_GYRO_CONFIG;
-    ///@}
-
-
-    ///Enumerated power modes
-    enum PowerModes
-    {
-        SUSPEND = 0,  ///<Acc and Gyro, No sampling, No FIFO data readout
-        NORMAL,       ///<Acc and Gyro, Full chip operation
-        LOW_POWER,    ///<Acc duty-cycling between suspend and normal
-        FAST_START_UP ///<Gyro start up delay time to normal mode <= 10 ms
-    };
-
-
-    ///Enumerated commands used with CMD register
-    enum Commands
-    {
-        START_FOC = 0x03,        ///<Starts Fast Offset Calibrartion
-        ACC_SET_PMU_MODE = 0x10, ///<Sets acc power mode
-        GYR_SET_PMU_MODE = 0x14, ///<Sets gyro power mode
-        MAG_SET_PMU_MODE = 0x18, ///<Sets mag power mode
-        PROG_NVM = 0xA0,         ///<Writes NVM backed registers into NVM
-        FIFO_FLUSH = 0xB0,       ///<Clears FIFO
-        INT_RESET,               ///<Clears interrupt engine, INT_STATUS, and
-                                 ///<the interrupt pin
-        STEP_CNT_CLR,            ///<Triggers reset of the step counter
-        SOFT_RESET = 0xB6        ///<Triggers a reset including a reboot.
-    };
-
-
-    ///@brief BMI160 Destructor.\n
-    ///
-    ///On Entry:
-    ///@param[in] none
-    ///
-    ///On Exit:
-    ///@param[out] none
-    ///
-    ///@returns none
-    virtual ~BMI160(){ }
-
-
-    ///@brief Reads a single register.\n
-    ///
-    ///On Entry:
-    ///@param[in] data - pointer to memory for storing read data
-    ///
-    ///On Exit:
-    ///@param[out] data - holds contents of read register on success
-    ///
-    ///@returns 0 on success, non 0 on failure
-    virtual int32_t readRegister(Registers reg, uint8_t *data) = 0;
-
-
-    ///@brief Writes a single register.\n
-    ///
-    ///On Entry:
-    ///@param[in] data - data to write to register
-    ///
-    ///On Exit:
-    ///@param[out] none
-    ///
-    ///@returns 0 on success, non 0 on failure
-    virtual int32_t writeRegister(Registers reg, const uint8_t data) = 0;
-
-
-    ///@brief Reads a block of registers.\n
-    ///@detail User must ensure that all registers between 'startReg' and
-    ///'stopReg' exist and are readable.  Function reads up to, including,
-    ///'stopReg'.\n
-    ///
-    ///On Entry:
-    ///@param[in] startReg - register to start reading from
-    ///@param[in] stopReg - register to stop reading from
-    ///@param[in] data - pointer to memory for storing read data
-    ///
-    ///On Exit:
-    ///@param[out] data - holds contents of read registers on success
-    ///
-    ///@returns 0 on success, non 0 on failure
-    virtual int32_t readBlock(Registers startReg, Registers stopReg,
-    uint8_t *data) = 0;
-
-
-    ///@brief Writes a block of registers.\n
-    ///@detail User must ensure that all registers between 'startReg' and
-    ///'stopReg' exist and are writeable.  Function writes up to, including,
-    ///'stopReg'.\n
-    ///
-    ///On Entry:
-    ///@param[in] startReg - register to start writing at
-    ///@param[in] stopReg - register to stop writing at
-    ///@param[in] data - pointer to data to write to registers
-    ///
-    ///On Exit:
-    ///@param[out] none
-    ///
-    ///@returns 0 on success, non 0 on failure
-    virtual int32_t writeBlock(Registers startReg, Registers stopReg,
-    const uint8_t *data) = 0;
-
-
-    ///@brief Sets sensors power mode through CMD register.\n
-    ///@details Observe command execution times given in datasheet.\n
-    ///
-    ///On Entry:
-    ///@param[in] sensor - Sensor which power mode we are setting
-    ///@param[in] pwrMode - Desired powermode of the sensor
-    ///
-    ///On Exit:
-    ///@param[out]
-    ///
-    ///@returns 0 on success, non 0 on failure
-    int32_t setSensorPowerMode(Sensors sensor, PowerModes pwrMode);
-
-
-    ///@brief Configure sensor.\n
-    ///
-    ///On Entry:
-    ///@param[in] config - sSensor configuration data structure
-    ///
-    ///On Exit:
-    ///@param[out] none
-    ///
-    ///@returns 0 on success, non 0 on failure
-    int32_t setSensorConfig(const AccConfig &config);
-    int32_t setSensorConfig(const GyroConfig &config);
-
-
-    ///@brief Get sensor configuration.\n
-    ///
-    ///On Entry:
-    ///@param[in] config - Sensor configuration data structure
-    ///
-    ///On Exit:
-    ///@param[out] config - on success, holds sensor's current
-    ///configuration
-    ///
-    ///@returns 0 on success, non 0 on failure
-    int32_t getSensorConfig(AccConfig &config);
-    int32_t getSensorConfig(GyroConfig &config);
-
-
-    ///@brief Get sensor axis.\n
-    ///
-    ///On Entry:
-    ///@param[in] axis - Sensor axis
-    ///@param[in] data - AxisData structure
-    ///@param[in] range - Sensor range
-    ///
-    ///On Exit:
-    ///@param[out] data - Structure holds raw and scaled axis data
-    ///
-    ///@returns 0 on success, non 0 on failure
-    int32_t getSensorAxis(SensorAxis axis, AxisData &data, AccRange range);
-    int32_t getSensorAxis(SensorAxis axis, AxisData &data, GyroRange range);
-
-
-    ///@brief Get sensor xyz axis.\n
-    ///
-    ///On Entry:
-    ///@param[in] data - SensorData structure
-    ///@param[in] range - Sensor range
-    ///
-    ///On Exit:
-    ///@param[out] data - Structure holds raw and scaled data for all three axis
-    ///
-    ///@returns 0 on success, non 0 on failure
-    int32_t getSensorXYZ(SensorData &data, AccRange range);
-    int32_t getSensorXYZ(SensorData &data, GyroRange range);
-
-
-    ///@brief Get sensor xyz axis and sensor time.\n
-    ///
-    ///On Entry:
-    ///@param[in] data - SensorData structure
-    ///@param[in] sensorTime - SensorTime structure for data
-    ///@param[in] range - Sensor range
-    ///
-    ///On Exit:
-    ///@param[out] data - Structure holds raw and scaled data for all three axis
-    ///@param[out] sensorTime - Holds sensor time on success
-    ///
-    ///@returns 0 on success, non 0 on failure
-    int32_t getSensorXYZandSensorTime(SensorData &data, SensorTime &sensorTime,
-                                      AccRange range);
-    int32_t getSensorXYZandSensorTime(SensorData &data, SensorTime &sensorTime,
-                                      GyroRange range);
-
-
-    ///@brief Get Gyroscope/Accelerometer data and sensor time.\n
-    ///
-    ///On Entry:
-    ///@param[in] accData -  Sensor data structure for accelerometer
-    ///@param[in] gyroData - Sensor data structure for gyroscope
-    ///@param[in] sensorTime - SensorTime data structure
-    ///@param[in] accRange - Accelerometer range
-    ///@param[in] gyroRange - Gyroscope range
-    ///
-    ///On Exit:
-    ///@param[out] accData -  Synchronized accelerometer data
-    ///@param[out] gyroData - Synchronized gyroscope data
-    ///@param[out] sensorTime - Synchronized sensor time
-    ///
-    ///@returns 0 on success, non 0 on failure
-    int32_t getGyroAccXYZandSensorTime(SensorData &accData,
-                                       SensorData &gyroData,
-                                       SensorTime &sensorTime,
-                                       AccRange accRange, GyroRange gyroRange);
-
-
-    ///@brief Get sensor time.\n
-    ///
-    ///On Entry:
-    ///@param[in] sensorTime - SensorTime structure for data
-    ///
-    ///On Exit:
-    ///@param[out] sensorTime - Holds sensor time on success
-    ///
-    ///@returns returns 0 on success, non 0 on failure
-    int32_t getSensorTime(SensorTime &sensorTime);
-
-
-    ///@brief Get die temperature.\n
-    ///
-    ///On Entry:
-    ///@param[in] temp - pointer to float for temperature
-    ///
-    ///On Exit:
-    ///@param[out] temp - on success, holds the die temperature
-    ///
-    ///@returns 0 on success, non 0 on failure
-    int32_t getTemperature(float *temp);
-
-    // Initialize BMI160 with default parameters:
-    // set GYRO: Suspended, Acc Normal Mode, ODR:25 Hz
-    int32_t BMI160_DefaultInitalize();
-
-    //
-    //
-    int32_t enable_data_ready_interrupt();
-
-	//
-	// Set sample rate
-	// This function can be alled after BMI160_DefaultInitalize
-	int32_t setSampleRate(int sample_rate);
-
-	/// @brief Soft reset
-	///
-	int32_t reset();
-
-private:
-	bool m_use_irq;
-	bool bmi160_irq_asserted;
-	InterruptIn *m_bmi160_irq;
-	void irq_handler();
-
-protected:
-	BMI160(InterruptIn *int_pin): m_bmi160_irq(int_pin), m_use_irq(true) {
-		bmi160_irq_asserted = false;
-	}
-
-	BMI160(): m_use_irq(false) { }
-};
-
-
-/**
-@brief BMI160_I2C - supports BMI160 object with I2C interface
-*/
-class BMI160_I2C: public BMI160
-{
-public:
-
-    ///BMI160 default I2C address.
-    static const uint8_t I2C_ADRS_SDO_LO = 0x68;
-    ///BMI160 optional I2C address.
-    static const uint8_t I2C_ADRS_SDO_HI = 0x69;
-
-
-    ///@brief BMI160_I2C Constructor.\n
-    ///
-    ///On Entry:
-    ///@param[in] i2cBus - reference to I2C bus for this device
-    ///@param[in] i2cAdrs - 7-bit I2C address
-    ///
-    ///On Exit:
-    ///@param[out] none
-    ///
-    ///@returns none
-    BMI160_I2C(I2C *i2cBus, uint8_t i2cAdrs);
-
-    ///@brief BMI160_I2C Constructor.\n
-    ///
-    ///On Entry:
-    ///@param[in] i2cBus - reference to I2C bus for this device
-    ///@param[in] i2cAdrs - 7-bit I2C address
-    ///@param[in] int_pin - Interrupt pin
-    ///
-    ///On Exit:
-    ///@param[out] none
-    ///
-    ///@returns none
-	BMI160_I2C(I2C *i2cBus, uint8_t i2cAdrs, InterruptIn *int_pin);
-
-    ///@brief Reads a single register.\n
-    ///
-    ///On Entry:
-    ///@param[in] data - pointer to memory for storing read data
-    ///
-    ///On Exit:
-    ///@param[out] data - holds contents of read register on success
-    ///
-    ///@returns 0 on success, non 0 on failure
-    virtual int32_t readRegister(Registers reg, uint8_t *data);
-
-
-    ///@brief Writes a single register.\n
-    ///
-    ///On Entry:
-    ///@param[in] data - data to write to register
-    ///
-    ///On Exit:
-    ///@param[out] none
-    ///
-    ///@returns 0 on success, non 0 on failure
-    virtual int32_t writeRegister(Registers reg, const uint8_t data);
-
-
-    ///@brief Reads a block of registers.\n
-    ///@detail User must ensure that all registers between 'startReg' and
-    ///'stopReg' exist and are readable.  Function reads up to, including,
-    ///'stopReg'.\n
-    ///
-    ///On Entry:
-    ///@param[in] startReg - register to start reading from
-    ///@param[in] stopReg - register to stop reading from
-    ///@param[in] data - pointer to memory for storing read data
-    ///
-    ///On Exit:
-    ///@param[out] data - holds contents of read registers on success
-    ///
-    ///@returns 0 on success, non 0 on failure
-    virtual int32_t readBlock(Registers startReg, Registers stopReg,
-    uint8_t *data);
-
-
-    ///@brief Writes a block of registers.\n
-    ///@detail User must ensure that all registers between 'startReg' and
-    ///'stopReg' exist and are writeable.  Function writes up to, including,
-    ///'stopReg'.\n
-    ///
-    ///On Entry:
-    ///@param[in] startReg - register to start writing at
-    ///@param[in] stopReg - register to stop writing at
-    ///@param[in] data - pointer to data to write to registers
-    ///
-    ///On Exit:
-    ///@param[out] none
-    ///
-    ///@returns 0 on success, non 0 on failure
-    virtual int32_t writeBlock(Registers startReg, Registers stopReg,
-    const uint8_t *data);
-
-private:
-    I2C *m_i2cBus;
-    uint8_t m_Wadrs, m_Radrs;
-};
-
-
-/**
-@brief BMI160_SPI - supports BMI160 object with SPI interface
-*/
-class BMI160_SPI: public BMI160
-{
-public:
-
-    ///@brief BMI160_SPI Constructor.\n
-    ///
-    ///On Entry:
-    ///@param[in] spiBus - reference to SPI bus for this device
-    ///@param[in] cs - reference to DigitalOut used for chip select
-    ///
-    ///On Exit:
-    ///@param[out] none
-    ///
-    ///@returns none
-    BMI160_SPI(SPI *spiBus, DigitalOut &cs);
-
-
-    ///@brief Reads a single register.\n
-    ///
-    ///On Entry:
-    ///@param[in] data - pointer to memory for storing read data
-    ///
-    ///On Exit:
-    ///@param[out] data - holds contents of read register on success
-    ///
-    ///@returns 0 on success, non 0 on failure
-    virtual int32_t readRegister(Registers reg, uint8_t *data);
-
-
-    ///@brief Writes a single register.\n
-    ///
-    ///On Entry:
-    ///@param[in] data - data to write to register
-    ///
-    ///On Exit:
-    ///@param[out] none
-    ///
-    ///@returns 0 on success, non 0 on failure
-    virtual int32_t writeRegister(Registers reg, const uint8_t data);
-
-
-    ///@brief Reads a block of registers.\n
-    ///@detail User must ensure that all registers between 'startReg' and
-    ///'stopReg' exist and are readable.  Function reads up to, including,
-    ///'stopReg'.\n
-    ///
-    ///On Entry:
-    ///@param[in] startReg - register to start reading from
-    ///@param[in] stopReg - register to stop reading from
-    ///@param[in] data - pointer to memory for storing read data
-    ///
-    ///On Exit:
-    ///@param[out] data - holds contents of read registers on success
-    ///
-    ///@returns 0 on success, non 0 on failure
-    virtual int32_t readBlock(Registers startReg, Registers stopReg,
-    uint8_t *data);
-
-
-    ///@brief Writes a block of registers.\n
-    ///@detail User must ensure that all registers between 'startReg' and
-    ///'stopReg' exist and are writeable.  Function writes up to, including,
-    ///'stopReg'.\n
-    ///
-    ///On Entry:
-    ///@param[in] startReg - register to start writing at
-    ///@param[in] stopReg - register to stop writing at
-    ///@param[in] data - pointer to data to write to registers
-    ///
-    ///On Exit:
-    ///@param[out] none
-    ///
-    ///@returns 0 on success, non 0 on failure
-    virtual int32_t writeBlock(Registers startReg, Registers stopReg,
-    const uint8_t *data);
-
-private:
-
-    SPI *m_spiBus;
-    DigitalOut m_cs;
-};
-
-#endif /* BMI160_H */
-
-
-///@brief fx documentation template.\n
-///
-///On Entry:
-///@param[in] none
-///
-///On Exit:
-///@param[out] none
-///
-///@returns none
--- a/accelerometer/bmi160_i2c.cpp	Mon Dec 17 10:44:03 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,103 +0,0 @@
-/**********************************************************************
-* Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a
-* copy of this software and associated documentation files (the "Software"),
-* to deal in the Software without restriction, including without limitation
-* the rights to use, copy, modify, merge, publish, distribute, sublicense,
-* and/or sell copies of the Software, and to permit persons to whom the
-* Software is furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included
-* in all copies or substantial portions of the Software.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
-* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-* OTHER DEALINGS IN THE SOFTWARE.
-*
-* Except as contained in this notice, the name of Maxim Integrated
-* Products, Inc. shall not be used except as stated in the Maxim Integrated
-* Products, Inc. Branding Policy.
-*
-* The mere transfer of this software does not imply any licenses
-* of trade secrets, proprietary technology, copyrights, patents,
-* trademarks, maskwork rights, or any other form of intellectual
-* property whatsoever. Maxim Integrated Products, Inc. retains all
-* ownership rights.
-**********************************************************************/
-
-
-#include "bmi160.h"
-
-
-//*****************************************************************************
-BMI160_I2C::BMI160_I2C(I2C *i2cBus, uint8_t i2cAdrs)
-:m_i2cBus(i2cBus), m_Wadrs(i2cAdrs << 1), m_Radrs((i2cAdrs << 1) | 1)
-{
-
-}
-
-BMI160_I2C::BMI160_I2C(I2C *i2cBus, uint8_t i2cAdrs, InterruptIn *int_pin)
-:m_i2cBus(i2cBus), m_Wadrs(i2cAdrs << 1), m_Radrs((i2cAdrs << 1) | 1), BMI160(int_pin)
-{
-
-}
-
-//*****************************************************************************
-int32_t BMI160_I2C::readRegister(Registers reg, uint8_t *data)
-{
-    int32_t rtnVal = -1;
-    char packet[] = {static_cast<char>(reg)};
-
-    if(m_i2cBus->write(m_Wadrs, packet, 1) == 0)
-    {
-        rtnVal = m_i2cBus->read(m_Radrs, reinterpret_cast<char *>(data), 1);
-    }
-
-    return rtnVal;
-}
-
-
-//*****************************************************************************
-int32_t BMI160_I2C::writeRegister(Registers reg, const uint8_t data)
-{
-    char packet[] = {static_cast<char>(reg), static_cast<char>(data)};
-
-    return m_i2cBus->write(m_Wadrs, packet, sizeof(packet));
-}
-
-
-//*****************************************************************************
-int32_t BMI160_I2C::readBlock(Registers startReg, Registers stopReg,
-uint8_t *data)
-{
-    int32_t rtnVal = -1;
-    int32_t numBytes = ((stopReg - startReg) + 1);
-    char packet[] = {static_cast<char>(startReg)};
-
-    if(m_i2cBus->write(m_Wadrs, packet, 1) == 0)
-    {
-        rtnVal = m_i2cBus->read(m_Radrs, reinterpret_cast<char *>(data), numBytes);
-    }
-
-    return rtnVal;
-}
-
-
-//*****************************************************************************
-int32_t BMI160_I2C::writeBlock(Registers startReg, Registers stopReg,
-const uint8_t *data)
-{
-    int32_t numBytes = ((stopReg - startReg) + 1);
-    char packet[numBytes + 1];
-
-    packet[0] = static_cast<char>(startReg);
-
-    memcpy(packet + 1, data, numBytes);
-
-    return m_i2cBus->write(m_Wadrs, packet, sizeof(packet));
-}
--- a/accelerometer/bmi160_spi.cpp	Mon Dec 17 10:44:03 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/**********************************************************************
-* Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a
-* copy of this software and associated documentation files (the "Software"),
-* to deal in the Software without restriction, including without limitation
-* the rights to use, copy, modify, merge, publish, distribute, sublicense,
-* and/or sell copies of the Software, and to permit persons to whom the
-* Software is furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included
-* in all copies or substantial portions of the Software.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
-* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-* OTHER DEALINGS IN THE SOFTWARE.
-*
-* Except as contained in this notice, the name of Maxim Integrated
-* Products, Inc. shall not be used except as stated in the Maxim Integrated
-* Products, Inc. Branding Policy.
-*
-* The mere transfer of this software does not imply any licenses
-* of trade secrets, proprietary technology, copyrights, patents,
-* trademarks, maskwork rights, or any other form of intellectual
-* property whatsoever. Maxim Integrated Products, Inc. retains all
-* ownership rights.
-**********************************************************************/
-
-
-#include "bmi160.h"
-
-
-//*****************************************************************************
-BMI160_SPI::BMI160_SPI(SPI *spiBus, DigitalOut &cs)
-:m_spiBus(spiBus), m_cs(cs)
-{
-
-}
-
-
-//*****************************************************************************
-int32_t BMI160_SPI::readRegister(Registers reg, uint8_t *data)
-{
-    int32_t rtnVal = -1;
-
-    return rtnVal;
-}
-
-
-//*****************************************************************************
-int32_t BMI160_SPI::writeRegister(Registers reg, const uint8_t data)
-{
-    int32_t rtnVal = -1;
-
-    return rtnVal;
-}
-
-
-//*****************************************************************************
-int32_t BMI160_SPI::readBlock(Registers startReg, Registers stopReg,
-uint8_t *data)
-{
-    int32_t rtnVal = -1;
-
-    return rtnVal;
-}
-
-
-//*****************************************************************************
-int32_t BMI160_SPI::writeBlock(Registers startReg, Registers stopReg,
-const uint8_t *data)
-{
-    int32_t rtnVal = -1;
-
-    return rtnVal;
-}
--- a/demoUI.lib	Mon Dec 17 10:44:03 2018 +0000
+++ b/demoUI.lib	Mon Dec 17 11:20:26 2018 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/users/gmehmet/code/demoUI/#5b8e9710eca1
+https://os.mbed.com/users/gmehmet/code/demoUI/#74ca5c764550