From ded000f17297b6e130990197b6a87773a1347995 Mon Sep 17 00:00:00 2001 From: Bosch Sensortec Date: Tue, 28 Nov 2017 10:12:57 +0100 Subject: [PATCH] - Linux compatibility issue fixed - FIFO Sensortime access is updated - Try concept used in bmi160_init API --- README.md | 6 ++--- bmi160.c | 28 ++++++++++++-------- bmi160.h | 6 +++-- bmi160_defs.h | 73 ++++++++++++++++++++------------------------------- changelog.md | 6 +++++ 5 files changed, 58 insertions(+), 61 deletions(-) diff --git a/README.md b/README.md index ed2f5fb..ec0d69f 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,9 @@ The sensor driver package includes bmi160.h, bmi160.c and bmi160_defs.h files ## Version File | Version | Date --------------|---------|--------------- -bmi160.c | 3.7.3 | 20 Nov 2017 -bmi160.h | 3.7.3 | 20 Nov 2017 -bmi160_defs.h | 3.7.3 | 20 Nov 2017 +bmi160.c | 3.7.4 | 24 Nov 2017 +bmi160.h | 3.7.4 | 24 Nov 2017 +bmi160_defs.h | 3.7.4 | 24 Nov 2017 ## Integration details * Integrate bmi160.h, bmi160_defs.h and bmi160.c file in to your project. diff --git a/bmi160.c b/bmi160.c index feff25f..c337947 100644 --- a/bmi160.c +++ b/bmi160.c @@ -40,8 +40,8 @@ * patent rights of the copyright holder. * * @file bmi160.c - * @date 20 Nov 2017 - * @version 3.7.3 + * @date 24 Nov 2017 + * @version 3.7.4 * @brief * */ @@ -77,7 +77,7 @@ const uint8_t int_mask_lookup_table[13] = { /*! * @brief This API configures the pins to fire the - * interrupt signal when it occurs. + * interrupt signal when it occurs * * @param[in] int_config : Structure instance of bmi160_int_settg. * @param[in] dev : Structure instance of bmi160_dev. @@ -1423,7 +1423,10 @@ int8_t bmi160_init(struct bmi160_dev *dev) { int8_t rslt; uint8_t data; - uint8_t chip_id; + uint8_t try = 3; + + /* Assign chip id as zero */ + dev->chip_id = 0; /* Null-pointer check */ rslt = null_ptr_check(dev); @@ -1434,11 +1437,13 @@ int8_t bmi160_init(struct bmi160_dev *dev) 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; + while ((try--) && (dev->chip_id != BMI160_CHIP_ID)) { + /* Read chip_id */ + rslt = bmi160_get_regs(BMI160_CHIP_ID_ADDR, &dev->chip_id, 1, dev); + } + + if ((rslt == BMI160_OK) && (dev->chip_id == BMI160_CHIP_ID)) { dev->any_sig_sel = BMI160_BOTH_ANY_SIG_MOTION_DISABLED; /* Soft reset */ rslt = bmi160_soft_reset(dev); @@ -1955,6 +1960,7 @@ int8_t bmi160_get_fifo_data(struct bmi160_dev const *dev) 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 */ @@ -1962,9 +1968,9 @@ int8_t bmi160_get_fifo_data(struct bmi160_dev const *dev) } 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; + && (bytes_to_read + BMI160_FIFO_BYTES_OVERREAD <= user_fifo_len)) { + /* Handling case of sensor time availability*/ + dev->fifo->length = dev->fifo->length + BMI160_FIFO_BYTES_OVERREAD; } if (dev->interface == BMI160_SPI_INTF) { diff --git a/bmi160.h b/bmi160.h index 0193f74..74e9720 100644 --- a/bmi160.h +++ b/bmi160.h @@ -40,8 +40,8 @@ * patent rights of the copyright holder. * * @file bmi160.h - * @date 20 Nov 2017 - * @version 3.7.3 + * @date 24 Nov 2017 + * @version 3.7.4 * @brief * */ @@ -54,6 +54,7 @@ #ifndef BMI160_H_ #define BMI160_H_ +/*************************** C++ guard macro *****************************/ #ifdef __cplusplus extern "C" { @@ -650,6 +651,7 @@ int8_t bmi160_update_nvm(struct bmi160_dev const *dev); int8_t bmi160_get_int_status(enum bmi160_int_status_sel int_status_sel, union bmi160_int_status *int_status, struct bmi160_dev const *dev); +/*************************** C++ guard macro *****************************/ #ifdef __cplusplus } #endif diff --git a/bmi160_defs.h b/bmi160_defs.h index 13d0533..3c6954e 100644 --- a/bmi160_defs.h +++ b/bmi160_defs.h @@ -40,8 +40,8 @@ * patent rights of the copyright holder. * * @file bmi160_defs.h - * @date 20 Nov 2017 - * @version 3.7.3 + * @date 24 Nov 2017 + * @version 3.7.4 * @brief * */ @@ -63,56 +63,36 @@ #include #endif -/*************************** C++ guard macro *****************************/ -#ifdef __cplusplus -extern "C" -{ -#endif - /*************************** Common macros *****************************/ -#ifdef __KERNEL__ -#if (LONG_MAX) > 0x7fffffff -#define __have_long64 1 -#elif (LONG_MAX) == 0x7fffffff -#define __have_long32 1 -#endif -#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 +#if !defined(UINT8_C) && !defined(INT8_C) +#define INT8_C(x) S8_C(x) +#define UINT8_C(x) U8_C(x) #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 +#if !defined(UINT16_C) && !defined(INT16_C) +#define INT16_C(x) S16_C(x) +#define UINT16_C(x) U16_C(x) #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 +#define INT32_C(x) S32_C(x) +#define UINT32_C(x) U32_C(x) #endif #if !defined(INT64_C) && !defined(UINT64_C) -#if __have_long64 -#define INT64_C(x) x##L -#define UINT64_C(x) x##UL +#define INT64_C(x) S64_C(x) +#define UINT64_C(x) U64_C(x) +#endif + +/**@}*/ + +/**\name C standard macros */ +#ifndef NULL +#ifdef __cplusplus +#define NULL 0 #else -#define INT64_C(x) x##LL -#define UINT64_C(x) x##ULL +#define NULL ((void *) 0) #endif #endif @@ -498,6 +478,13 @@ extern "C" #define BMI160_FIFO_G_A_ENABLE UINT8_C(0xC0) #define BMI160_FIFO_M_G_A_ENABLE UINT8_C(0xE0) +/* Macro to specify the number of bytes over-read from the + * FIFO in order to get the sensor time at the end of FIFO */ +#ifndef BMI160_FIFO_BYTES_OVERREAD +#define BMI160_FIFO_BYTES_OVERREAD UINT8_C(25) +#endif + + /* Accel, gyro and aux. sensor length and also their combined * length definitions in FIFO */ @@ -1426,9 +1413,5 @@ struct bmi160_dev { bmi160_delay_fptr_t delay_ms; }; -/*************************** C++ guard macro *****************************/ -#ifdef __cplusplus -} -#endif #endif /* BMI160_DEFS_H_ */ diff --git a/changelog.md b/changelog.md index c90f700..d9faed6b6 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,12 @@ # Change Log All notable changes to bmi160 Sensor API will be documented in this file. +## v3.7.4, 24 Nov 2017 +#### Added + - Linux compatibility issue fixed + - FIFO Sensortime access is updated + - Try concept used in bmi160_init API + ## v3.7.3, 20 Nov 2017 #### Added - Provided support for FIFO tagging feature by adding