Skip to content

Commit

Permalink
- Linux compatibility issue fixed
Browse files Browse the repository at this point in the history
- FIFO Sensortime access is updated
- Try concept used in bmi160_init API
  • Loading branch information
BST-Github-Admin committed Nov 28, 2017
1 parent dcc6447 commit ded000f
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 61 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
28 changes: 17 additions & 11 deletions bmi160.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
*/
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -1955,16 +1960,17 @@ 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 */
dev->fifo->length = bytes_to_read;
}

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) {
Expand Down
6 changes: 4 additions & 2 deletions bmi160.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
*/
Expand All @@ -54,6 +54,7 @@
#ifndef BMI160_H_
#define BMI160_H_

/*************************** C++ guard macro *****************************/
#ifdef __cplusplus
extern "C"
{
Expand Down Expand Up @@ -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
Expand Down
73 changes: 28 additions & 45 deletions bmi160_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
*/
Expand All @@ -63,56 +63,36 @@
#include <stddef.h>
#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

Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -1426,9 +1413,5 @@ struct bmi160_dev {
bmi160_delay_fptr_t delay_ms;
};

/*************************** C++ guard macro *****************************/
#ifdef __cplusplus
}
#endif

#endif /* BMI160_DEFS_H_ */
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit ded000f

Please sign in to comment.