Skip to content

Commit

Permalink
Updated interfaces, fixed bugs, simplified file structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
BST-Github-Admin authored and kegov committed Jun 9, 2020
1 parent c9695c8 commit becf8fa
Show file tree
Hide file tree
Showing 16 changed files with 3,207 additions and 2,238 deletions.
111 changes: 75 additions & 36 deletions DataSync.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,128 +49,167 @@ Include the bmi08x header
``` c
#include "bmi08x.h"
```
Include the bmi085 variant header

``` c
#include "bmi085.h"
```
Update variant of bmi08x_dev to BMI085_VARIANT to use the BMI085 sensor feature

Enable the below macro in bmi08x_defs.h to use the BMI085 sensor feature

``` c
/** \name enable bmi085 sensor */
#ifndef BMI08X_ENABLE_BMI085
#define BMI08X_ENABLE_BMI085 1
#endif
```
dev.variant = BMI085_VARIANT;
```

To initialize BMI085 for data synchronization, an instance of the bmi08x structure should be created. The following parameters are required to be updated in the structure by the user:


Parameters | Details
--------------|-----------------------------------
_accel_id_ | device address of I2C interface (if intf is BMI08X_I2C_INTF)
_gyro_id_ | device address of I2C interface (if intf is BMI08X_I2C_INTF)
_intf_ | I2C or SPI
_read_ | read through I2C/SPI interface
_write_ | write through I2C/SPI interface
_delay_ms_ | delay
Parameters | Details
--------------------|--------------------------------------------------------
_intf_ptr_accel_ | Interface pointer that can hold Accel device address
_intf_ptr_gyro_ | Interface pointer that can hold Gyro device address
_intf_ | I2C or SPI
_read_ | read through I2C/SPI interface
_write_ | write through I2C/SPI interface
_delay_us_ | delay in microseconds
_variant_ | BMI085_VARIANT


##### _Initialize through SPI interface_

The following code is simplified code, for example no checking of return values is added, to make it easier to read the code.

``` c
int8_t rslt;

uint8_t acc_dev_addr = 0;
uint8_t gyro_dev_addr = 0;

struct bmi08x_dev bmi08xdev = {
.accel_id = 0,
.gyro_id = 0,
struct bmi08x_dev dev = {

.intf_ptr_accel = &acc_dev_addr,
.intf_ptr_gyro = &gyro_dev_addr,
.intf = BMI08X_SPI_INTF,
.read = user_spi_read,
.write = user_spi_write,
.delay_ms = user_delay_milli_sec
.delay_us = user_delay_milli_sec,
.variant = BMI085_VARIANT
};

int16_t rslt;
/* Initializing the bmi085 sensors the below functions */

/* To Initialize accel sensor */

rslt = bmi08a_init(&dev);

/* To Initialize gyro sensor */

rslt = bmi08g_init(&dev);

/* Initialize bmi085 sensors (accel & gyro)*/
rslt = bmi085_init(&bmi08xdev);
/* Reset the accelerometer and wait for 1 ms - delay taken care inside the function */

rslt = bmi08a_soft_reset(&bmi08xdev);


/*! Max read/write length (maximum supported length is 32).
To be set by the user */

bmi08xdev.read_write_len = 32;

/*set accel power mode */

bmi08xdev.accel_cfg.power = BMI08X_ACCEL_PM_ACTIVE;

rslt = bmi08a_set_power_mode(&bmi08xdev);

bmi08xdev.gyro_cfg.power = BMI08X_GYRO_PM_NORMAL;

bmi08g_set_power_mode(&bmi08xdev);

/* API uploads the bmi08x config file onto the device and wait for 150ms
to enable the data synchronization - delay taken care inside the function */
rslt = bmi085_apply_config_file(&bmi08xdev);

rslt = bmi08a_load_config_file(&bmi08xdev);

/*assign accel range setting*/

bmi08xdev.accel_cfg.range = BMI085_ACCEL_RANGE_4G;

/*assign gyro range setting*/

bmi08xdev.gyro_cfg.range = BMI08X_GYRO_RANGE_2000_DPS;

/*! Mode (0 = off, 1 = 400Hz, 2 = 1kHz, 3 = 2kHz) */

sync_cfg.mode = BMI08X_ACCEL_DATA_SYNC_MODE_2000HZ;
rslt = bmi085_configure_data_synchronization(sync_cfg, &bmi08xdev);

rslt = bmi08a_configure_data_synchronization(sync_cfg, &bmi08xdev);


/*set accel interrupt pin configuration*/

/*configure host data ready interrupt */

int_config.accel_int_config_1.int_channel = BMI08X_INT_CHANNEL_1;

int_config.accel_int_config_1.int_type = BMI08X_ACCEL_SYNC_INPUT;

int_config.accel_int_config_1.int_pin_cfg.output_mode = BMI08X_INT_MODE_PUSH_PULL;

int_config.accel_int_config_1.int_pin_cfg.lvl = BMI08X_INT_ACTIVE_HIGH;

int_config.accel_int_config_1.int_pin_cfg.enable_int_pin = BMI08X_ENABLE;

/*configure Accel syncronization input interrupt pin */

int_config.accel_int_config_2.int_channel = BMI08X_INT_CHANNEL_2;

int_config.accel_int_config_2.int_type = BMI08X_ACCEL_SYNC_DATA_RDY_INT;

int_config.accel_int_config_2.int_pin_cfg.output_mode = BMI08X_INT_MODE_PUSH_PULL;

int_config.accel_int_config_2.int_pin_cfg.lvl = BMI08X_INT_ACTIVE_HIGH;

int_config.accel_int_config_2.int_pin_cfg.enable_int_pin = BMI08X_ENABLE;

/*set gyro interrupt pin configuration*/

int_config.gyro_int_config_1.int_channel = BMI08X_INT_CHANNEL_3;

int_config.gyro_int_config_1.int_type = BMI08X_GYRO_DATA_RDY_INT;

int_config.gyro_int_config_1.int_pin_cfg.enable_int_pin = BMI08X_ENABLE;

int_config.gyro_int_config_1.int_pin_cfg.lvl = BMI08X_INT_ACTIVE_HIGH;

int_config.gyro_int_config_1.int_pin_cfg.output_mode = BMI08X_INT_MODE_PUSH_PULL;

int_config.gyro_int_config_2.int_channel = BMI08X_INT_CHANNEL_4;

int_config.gyro_int_config_2.int_type = BMI08X_GYRO_DATA_RDY_INT;

int_config.gyro_int_config_2.int_pin_cfg.enable_int_pin = BMI08X_DISABLE;

int_config.gyro_int_config_2.int_pin_cfg.lvl = BMI08X_INT_ACTIVE_HIGH;

int_config.gyro_int_config_2.int_pin_cfg.output_mode = BMI08X_INT_MODE_PUSH_PULL;

/* Enable synchronization interrupt pin */
rslt = bmi085_set_data_sync_int_config(&int_config, &bmi08xdev);
```

rslt = bmi08a_set_data_sync_int_config(&int_config, &bmi08xdev);

#### Read out raw accel data
```c

/* Declare an instance of the sensor data structure for accel */

static struct bmi08x_sensor_data accel_bmi085;

rslt = bmi08a_get_data(&accel_bmi085, &bmi08xdev);

```

#### Read out synchronized data
```c

/* Declare an instance of the sensor data structure for accel */

static struct bmi08x_sensor_data accel_bmi085;

/* Declare an instance of the sensor data structure for gyro */

static struct bmi08x_sensor_data gyro_bmi085;

rslt = bmi085_get_synchronized_data(&accel_bmi085,&gyro_bmi085, &bmi08xdev);
```
rslt = bmi08a_get_synchronized_data(&accel_bmi085,&gyro_bmi085, &bmi08xdev);

Loading

0 comments on commit becf8fa

Please sign in to comment.