diff --git a/DataSync.md b/DataSync.md index ff3dadc..261e8eb 100644 --- a/DataSync.md +++ b/DataSync.md @@ -10,44 +10,24 @@ _Note: data synchronization is designed for applications requiring high bandwidt ## Concept Synchronized data means that the acquisition of the gyroscope and accelerometer data is happening at the same time and the signals have same propagation time. The time between motion to register read-out depends on the physical propagation time mainly caused by signal filtering path. The synchronization between accelerometer and gyroscope data to a common point of time and a common group delay can be realized with the approach described in the following sections. -The hardware interrupts pins (INT1 / INT3) of the BMI085 are used for data synchronization purposes and must be connected. The interrupt pin INT2 can be used for data ready notification to the host by BMI085. - -## Technical realization -The data synchronization feature requires physical interrupt pin’s connection of the sensors on the pcb and a special configuration of the BMI085. Requirements and the steps are described below. - -### Connection diagram +### Connection diagram (APP3.0) ``` - MCU BMI085 - +-----------+ +---------------+ - | | 8 | | 16 - | SCK +------------>| SCK INT1 |<-----+ - | | 9 | | 12 | - | MOSI +------------>| SDO INT3 |>-----+ - | | 15 | | - | MISO +<------+-----| SDO1 | - | | | 10 | | - | | +-----| SDO2 | - | | 14 | | - | ACC_CSB +------------>| CSB1 | - | | 5 | | - | GYRO_CSB +------------>| CSB2 | - | | 1 | | - | DATA_RDY +<------------| INT2 PS +------+ - | | | | | - +-----------+ +---------------+ | - | - --- + + INT2 A 1 JP3 2 INT4 G + ------------- (-|-) ------------ ``` For latency-critical multisensory applications, it is recommended to use SPI interface for fastest sensor data read (recommended SPI clock speed is >2MHz). +Further details in [https://www.bosch-sensortec.com/media/boschsensortec/downloads/shuttle_board_flyer/application_board_3_1/bst-bmi088-sf000.pdf](https://www.bosch-sensortec.com/media/boschsensortec/downloads/shuttle_board_flyer/application_board_3_1/bst-bmi088-sf000.pdf "Shuttle Board 3.0 Flyer") + ### Configuring BMI085 for data synchronization Include the bmi08x header -``` c -#include "bmi08x.h" +``` + #include "bmi08x.h" ``` Update variant of bmi08x_dev to BMI085_VARIANT to use the BMI085 sensor feature @@ -105,12 +85,11 @@ rslt = bmi08g_init(&dev); rslt = bmi08a_soft_reset(&bmi08xdev); -/*! Max read/write length (maximum supported length is 32). - To be set by the user */ +/* Read/write length */ bmi08xdev.read_write_len = 32; -/*set accel power mode */ +/* Set accel power mode */ bmi08xdev.accel_cfg.power = BMI08X_ACCEL_PM_ACTIVE; @@ -125,24 +104,24 @@ bmi08g_set_power_mode(&bmi08xdev); rslt = bmi08a_load_config_file(&bmi08xdev); -/*assign accel range setting*/ +/* Assign accel range setting*/ bmi08xdev.accel_cfg.range = BMI085_ACCEL_RANGE_4G; -/*assign gyro range setting*/ +/* Assign gyro range setting*/ bmi08xdev.gyro_cfg.range = BMI08X_GYRO_RANGE_2000_DPS; -/*! Mode (0 = off, 1 = 400Hz, 2 = 1kHz, 3 = 2kHz) */ +/* Mode (0 = off, 1 = 400Hz, 2 = 1kHz, 3 = 2kHz) */ sync_cfg.mode = BMI08X_ACCEL_DATA_SYNC_MODE_2000HZ; rslt = bmi08a_configure_data_synchronization(sync_cfg, &bmi08xdev); -/*set accel interrupt pin configuration*/ +/* Set accel interrupt pin configuration*/ -/*configure host data ready interrupt */ +/* Configure host data ready interrupt */ int_config.accel_int_config_1.int_channel = BMI08X_INT_CHANNEL_1; @@ -154,7 +133,7 @@ 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 */ +/* Configure Accel syncronization input interrupt pin */ int_config.accel_int_config_2.int_channel = BMI08X_INT_CHANNEL_2; @@ -166,7 +145,7 @@ 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*/ +/* Set gyro interrupt pin configuration*/ int_config.gyro_int_config_1.int_channel = BMI08X_INT_CHANNEL_3; diff --git a/LICENSE b/LICENSE index fcbe827..c1d37c3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved. +Copyright (c) 2022 Bosch Sensortec GmbH. All rights reserved. BSD-3-Clause diff --git a/bmi08a.c b/bmi08a.c index 623fd16..b0ce8b6 100644 --- a/bmi08a.c +++ b/bmi08a.c @@ -1,5 +1,5 @@ /** -* Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved. +* Copyright (c) 2022 Bosch Sensortec GmbH. All rights reserved. * * BSD-3-Clause * @@ -31,8 +31,8 @@ * POSSIBILITY OF SUCH DAMAGE. * * @file bmi08a.c -* @date 2021-06-22 -* @version v1.5.7 +* @date 2022-01-03 +* @version v1.5.8 * */ @@ -904,6 +904,22 @@ int8_t bmi08a_set_regs(uint8_t reg_addr, const uint8_t *reg_data, uint32_t len, { /* Writing to the register */ rslt = set_regs(reg_addr, reg_data, len, dev); + + /* Delay for suspended mode of the sensor is 450 us */ + if (dev->accel_cfg.power == BMI08X_ACCEL_PM_SUSPEND) + { + dev->delay_us(450, dev->intf_ptr_accel); + } + /* Delay for Normal mode of the sensor is 2 us */ + else if (dev->accel_cfg.power == BMI08X_ACCEL_PM_ACTIVE) + { + dev->delay_us(2, dev->intf_ptr_accel); + } + else + { + /* Invalid power input */ + rslt = BMI08X_E_INVALID_INPUT; + } } else { diff --git a/bmi08g.c b/bmi08g.c index 589e801..61d51d0 100644 --- a/bmi08g.c +++ b/bmi08g.c @@ -1,5 +1,5 @@ /** -* Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved. +* Copyright (c) 2022 Bosch Sensortec GmbH. All rights reserved. * * BSD-3-Clause * @@ -31,8 +31,8 @@ * POSSIBILITY OF SUCH DAMAGE. * * @file bmi08g.c -* @date 2021-06-22 -* @version v1.5.7 +* @date 2022-01-03 +* @version v1.5.8 * */ @@ -302,6 +302,22 @@ int8_t bmi08g_set_regs(uint8_t reg_addr, const uint8_t *reg_data, uint32_t len, { /* Writing to the register */ rslt = set_regs(reg_addr, reg_data, len, dev); + + /* Delay for suspended mode of the sensor is 450 us */ + if (dev->gyro_cfg.power == BMI08X_GYRO_PM_SUSPEND || dev->gyro_cfg.power == BMI08X_GYRO_PM_DEEP_SUSPEND) + { + dev->delay_us(450, dev->intf_ptr_gyro); + } + /* Delay for Normal mode of the sensor is 2 us */ + else if (dev->gyro_cfg.power == BMI08X_GYRO_PM_NORMAL) + { + dev->delay_us(2, dev->intf_ptr_gyro); + } + else + { + /* Invalid power input */ + rslt = BMI08X_E_INVALID_INPUT; + } } else { diff --git a/bmi08x.h b/bmi08x.h index 5ecdd95..6dd534f 100644 --- a/bmi08x.h +++ b/bmi08x.h @@ -1,5 +1,5 @@ /** -* Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved. +* Copyright (c) 2022 Bosch Sensortec GmbH. All rights reserved. * * BSD-3-Clause * @@ -31,8 +31,8 @@ * POSSIBILITY OF SUCH DAMAGE. * * @file bmi08x.h -* @date 2021-06-22 -* @version v1.5.7 +* @date 2022-01-03 +* @version v1.5.8 * */ diff --git a/bmi08x_defs.h b/bmi08x_defs.h index 30aae7d..5d570d8 100644 --- a/bmi08x_defs.h +++ b/bmi08x_defs.h @@ -1,5 +1,5 @@ /** -* Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved. +* Copyright (c) 2022 Bosch Sensortec GmbH. All rights reserved. * * BSD-3-Clause * @@ -31,8 +31,8 @@ * POSSIBILITY OF SUCH DAMAGE. * * @file bmi08x_defs.h -* @date 2021-06-22 -* @version v1.5.7 +* @date 2022-01-03 +* @version v1.5.8 * */ @@ -1118,7 +1118,7 @@ struct bmi08x_dev /*! Config stream data buffer address will be assigned */ const uint8_t *config_file_ptr; - /*! Max read/write length (maximum supported length is 32). + /*! Max read/write length * To be set by the user */ uint8_t read_write_len; diff --git a/examples/accel_fifo_full/accel_fifo_full.c b/examples/accel_fifo_full/accel_fifo_full.c index 251f058..98b0b7d 100644 --- a/examples/accel_fifo_full/accel_fifo_full.c +++ b/examples/accel_fifo_full/accel_fifo_full.c @@ -1,5 +1,5 @@ /** - * Copyright (C) 2021 Bosch Sensortec GmbH + * Copyright (C) 2022 Bosch Sensortec GmbH * * SPDX-License-Identifier: BSD-3-Clause */ diff --git a/examples/accel_fifo_watermark/accel_fifo_watermark.c b/examples/accel_fifo_watermark/accel_fifo_watermark.c index 6e8cd36..2d1ad0b 100644 --- a/examples/accel_fifo_watermark/accel_fifo_watermark.c +++ b/examples/accel_fifo_watermark/accel_fifo_watermark.c @@ -1,5 +1,5 @@ /** - * Copyright (C) 2021 Bosch Sensortec GmbH + * Copyright (C) 2022 Bosch Sensortec GmbH * * SPDX-License-Identifier: BSD-3-Clause */ diff --git a/examples/common/common.c b/examples/common/common.c index 43618da..5a85344 100644 --- a/examples/common/common.c +++ b/examples/common/common.c @@ -1,5 +1,5 @@ /** - * Copyright (C) 2021 Bosch Sensortec GmbH. All rights reserved. + * Copyright (C) 2022 Bosch Sensortec GmbH. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -114,7 +114,6 @@ int8_t bmi08x_interface_init(struct bmi08x_dev *bmi08x, uint8_t intf, uint8_t va printf( "! Warning - BMI085 sensor shuttle and BMI088 variant used \n ," "This application will not support this combination \n"); - exit(COINES_E_FAILURE); } if ((board_info.shuttle_id == BMI088_SHUTTLE_ID) && (variant == BMI085_VARIANT)) @@ -122,7 +121,6 @@ int8_t bmi08x_interface_init(struct bmi08x_dev *bmi08x, uint8_t intf, uint8_t va printf( "! Warning - BMI088 sensor shuttle and BMI085 variant used \n ," "This application will not support this combination \n"); - exit(COINES_E_FAILURE); } if ((board_info.shuttle_id != BMI085_SHUTTLE_ID) && (board_info.shuttle_id != BMI088_SHUTTLE_ID)) @@ -130,7 +128,6 @@ int8_t bmi08x_interface_init(struct bmi08x_dev *bmi08x, uint8_t intf, uint8_t va printf( "! Warning invalid sensor shuttle (neither BMI085 nor BMI088 used) \n ," "This application will not support this sensor \n"); - exit(COINES_E_FAILURE); } } diff --git a/examples/common/common.h b/examples/common/common.h index c5d23d4..2761018 100644 --- a/examples/common/common.h +++ b/examples/common/common.h @@ -1,5 +1,5 @@ /**\ - * Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved. + * Copyright (c) 2022 Bosch Sensortec GmbH. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause **/ diff --git a/examples/gyro_fifo_full/gyro_fifo_full.c b/examples/gyro_fifo_full/gyro_fifo_full.c index 984739b..2ea5bc6 100644 --- a/examples/gyro_fifo_full/gyro_fifo_full.c +++ b/examples/gyro_fifo_full/gyro_fifo_full.c @@ -1,5 +1,5 @@ /**\ - * Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved. + * Copyright (c) 2022 Bosch Sensortec GmbH. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ diff --git a/examples/gyro_fifo_watermark/gyro_fifo_watermark.c b/examples/gyro_fifo_watermark/gyro_fifo_watermark.c index eee6359..26b6cfa 100644 --- a/examples/gyro_fifo_watermark/gyro_fifo_watermark.c +++ b/examples/gyro_fifo_watermark/gyro_fifo_watermark.c @@ -1,5 +1,5 @@ /**\ - * Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved. + * Copyright (c) 2022 Bosch Sensortec GmbH. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ diff --git a/examples/interrupt_streaming_pc/interrupt_streaming_pc.c b/examples/interrupt_streaming_pc/interrupt_streaming_pc.c index 02e592b..d7c9fca 100644 --- a/examples/interrupt_streaming_pc/interrupt_streaming_pc.c +++ b/examples/interrupt_streaming_pc/interrupt_streaming_pc.c @@ -1,5 +1,5 @@ /** - * Copyright (C) 2021 Bosch Sensortec GmbH + * Copyright (C) 2022 Bosch Sensortec GmbH * * SPDX-License-Identifier: BSD-3-Clause */ diff --git a/examples/polling_streaming_pc/polling_streaming_pc.c b/examples/polling_streaming_pc/polling_streaming_pc.c index 1acd8db..0e94686 100644 --- a/examples/polling_streaming_pc/polling_streaming_pc.c +++ b/examples/polling_streaming_pc/polling_streaming_pc.c @@ -1,5 +1,5 @@ /** - * Copyright (C) 2021 Bosch Sensortec GmbH + * Copyright (C) 2022 Bosch Sensortec GmbH * * SPDX-License-Identifier: BSD-3-Clause */ @@ -177,99 +177,105 @@ void read_sensor_data(void) int buffer_index = 0; float x = 0.0, y = 0.0, z = 0.0; - memset(&bmi08x_accel_stream_buffer[0], 0, COINES_STREAM_RSP_BUF_SIZE); - rslt = coines_read_stream_sensor_data(1, 1, &bmi08x_accel_stream_buffer[0], &valid_sample_count); - if (rslt == COINES_SUCCESS) + if (bmi08xdev.accel_cfg.power == BMI08X_ACCEL_PM_ACTIVE) { - buffer_index = 0; - printf("\nACCEL DATA \n"); - printf("Accel data in LSB units and Gravity data in m/s^2\n"); - printf("Accel data range : 16G for BMI085 and 24G for BMI088\n\n"); - - if (valid_sample_count > 100) + memset(&bmi08x_accel_stream_buffer[0], 0, COINES_STREAM_RSP_BUF_SIZE); + rslt = coines_read_stream_sensor_data(1, 1, &bmi08x_accel_stream_buffer[0], &valid_sample_count); + if (rslt == COINES_SUCCESS) { - valid_sample_count = 100; - } + buffer_index = 0; + printf("\nACCEL DATA \n"); + printf("Accel data in LSB units and Gravity data in m/s^2\n"); + printf("Accel data range : 16G for BMI085 and 24G for BMI088\n\n"); - for (idx = 0; idx < valid_sample_count; idx++) - { - if (bmi08xdev.intf == BMI08X_SPI_INTF) + if (valid_sample_count > 100) { - buffer_index++; /*dummy byte; ignore for SPI */ + valid_sample_count = 100; } - lsb = bmi08x_accel_stream_buffer[buffer_index++]; - msb = bmi08x_accel_stream_buffer[buffer_index++]; - ax = (msb << 8) | lsb; - - lsb = bmi08x_accel_stream_buffer[buffer_index++]; - msb = bmi08x_accel_stream_buffer[buffer_index++]; - ay = (msb << 8) | lsb; - - lsb = bmi08x_accel_stream_buffer[buffer_index++]; - msb = bmi08x_accel_stream_buffer[buffer_index++]; - az = (msb << 8) | lsb; - - printf("ACCEL[%d] Acc_Raw_X : %-5d Acc_Raw_Y : %-5d Acc_Raw_Z : %-5d ", idx, ax, ay, az); - - if (bmi08xdev.variant == BMI085_VARIANT) - { - /* Converting lsb to meter per second squared for 16 bit accelerometer at 16G range. */ - x = lsb_to_mps2(ax, 16, 16); - y = lsb_to_mps2(ay, 16, 16); - z = lsb_to_mps2(az, 16, 16); - } - else if (bmi08xdev.variant == BMI088_VARIANT) + for (idx = 0; idx < valid_sample_count; idx++) { - /* Converting lsb to meter per second squared for 16 bit accelerometer at 24G range. */ - x = lsb_to_mps2(ax, 24, 16); - y = lsb_to_mps2(ay, 24, 16); - z = lsb_to_mps2(az, 24, 16); + if (bmi08xdev.intf == BMI08X_SPI_INTF) + { + buffer_index++; /*dummy byte; ignore for SPI */ + } + + lsb = bmi08x_accel_stream_buffer[buffer_index++]; + msb = bmi08x_accel_stream_buffer[buffer_index++]; + ax = (msb << 8) | lsb; + + lsb = bmi08x_accel_stream_buffer[buffer_index++]; + msb = bmi08x_accel_stream_buffer[buffer_index++]; + ay = (msb << 8) | lsb; + + lsb = bmi08x_accel_stream_buffer[buffer_index++]; + msb = bmi08x_accel_stream_buffer[buffer_index++]; + az = (msb << 8) | lsb; + + printf("ACCEL[%d] Acc_Raw_X : %-5d Acc_Raw_Y : %-5d Acc_Raw_Z : %-5d ", idx, ax, ay, az); + + if (bmi08xdev.variant == BMI085_VARIANT) + { + /* Converting lsb to meter per second squared for 16 bit accelerometer at 16G range. */ + x = lsb_to_mps2(ax, 16, 16); + y = lsb_to_mps2(ay, 16, 16); + z = lsb_to_mps2(az, 16, 16); + } + else if (bmi08xdev.variant == BMI088_VARIANT) + { + /* Converting lsb to meter per second squared for 16 bit accelerometer at 24G range. */ + x = lsb_to_mps2(ax, 24, 16); + y = lsb_to_mps2(ay, 24, 16); + z = lsb_to_mps2(az, 24, 16); + } + + /* Print the data in m/s2. */ + printf("\t Acc_ms2_X = %4.2f Acc_ms2_Y = %4.2f Acc_ms2_Z = %4.2f\n", x, y, z); } - - /* Print the data in m/s2. */ - printf("\t Acc_ms2_X = %4.2f Acc_ms2_Y = %4.2f Acc_ms2_Z = %4.2f\n", x, y, z); } } - memset(&bmi08x_gyro_stream_buffer[0], 0, COINES_STREAM_RSP_BUF_SIZE); - rslt = coines_read_stream_sensor_data(2, 1, &bmi08x_gyro_stream_buffer[0], &valid_sample_count); - if (rslt == COINES_SUCCESS) + if (bmi08xdev.gyro_cfg.power == BMI08X_GYRO_PM_NORMAL) { - buffer_index = 0; - printf("\n\nGYRO DATA \n"); - printf("Gyro data in LSB units and degrees per second\n"); - printf("Gyro data range : 250 dps for BMI085 and BMI088\n\n"); - - if (valid_sample_count > 100) + memset(&bmi08x_gyro_stream_buffer[0], 0, COINES_STREAM_RSP_BUF_SIZE); + rslt = coines_read_stream_sensor_data(2, 1, &bmi08x_gyro_stream_buffer[0], &valid_sample_count); + if (rslt == COINES_SUCCESS) { - valid_sample_count = 100; - } + buffer_index = 0; + printf("\n\nGYRO DATA \n"); + printf("Gyro data in LSB units and degrees per second\n"); + printf("Gyro data range : 250 dps for BMI085 and BMI088\n\n"); - for (idx = 0; idx < valid_sample_count; idx++) - { + if (valid_sample_count > 100) + { + valid_sample_count = 100; + } + + for (idx = 0; idx < valid_sample_count; idx++) + { - lsb = bmi08x_gyro_stream_buffer[buffer_index++]; - msb = bmi08x_gyro_stream_buffer[buffer_index++]; - gx = (msb << 8) | lsb; + lsb = bmi08x_gyro_stream_buffer[buffer_index++]; + msb = bmi08x_gyro_stream_buffer[buffer_index++]; + gx = (msb << 8) | lsb; - lsb = bmi08x_gyro_stream_buffer[buffer_index++]; - msb = bmi08x_gyro_stream_buffer[buffer_index++]; - gy = (msb << 8) | lsb; + lsb = bmi08x_gyro_stream_buffer[buffer_index++]; + msb = bmi08x_gyro_stream_buffer[buffer_index++]; + gy = (msb << 8) | lsb; - lsb = bmi08x_gyro_stream_buffer[buffer_index++]; - msb = bmi08x_gyro_stream_buffer[buffer_index++]; - gz = (msb << 8) | lsb; + lsb = bmi08x_gyro_stream_buffer[buffer_index++]; + msb = bmi08x_gyro_stream_buffer[buffer_index++]; + gz = (msb << 8) | lsb; - printf("GYRO[%d] Gyr_Raw_X : %-5d Gyr_Raw_Y : %-5d Gyr_Raw_Z : %-5d ", idx, gx, gy, gz); + printf("GYRO[%d] Gyr_Raw_X : %-5d Gyr_Raw_Y : %-5d Gyr_Raw_Z : %-5d ", idx, gx, gy, gz); - /* Converting lsb to degree per second for 16 bit gyro at 250 dps range. */ - x = lsb_to_dps(gx, 250, 16); - y = lsb_to_dps(gy, 250, 16); - z = lsb_to_dps(gz, 250, 16); + /* Converting lsb to degree per second for 16 bit gyro at 250 dps range. */ + x = lsb_to_dps(gx, 250, 16); + y = lsb_to_dps(gy, 250, 16); + z = lsb_to_dps(gz, 250, 16); - /* Print the data in dps. */ - printf("\t Gyr_DPS_X = %4.2f Gyr_DPS_Y = %4.2f Gyr_DPS_Z = %4.2f\n", x, y, z); + /* Print the data in dps. */ + printf("\t Gyr_DPS_X = %4.2f Gyr_DPS_Y = %4.2f Gyr_DPS_Z = %4.2f\n", x, y, z); + } } } } diff --git a/examples/read_sensor_data/read_sensor_data.c b/examples/read_sensor_data/read_sensor_data.c index 216062e..8e25dac 100644 --- a/examples/read_sensor_data/read_sensor_data.c +++ b/examples/read_sensor_data/read_sensor_data.c @@ -1,5 +1,5 @@ /** - * Copyright (C) 2021 Bosch Sensortec GmbH + * Copyright (C) 2022 Bosch Sensortec GmbH * * SPDX-License-Identifier: BSD-3-Clause */ @@ -266,79 +266,85 @@ int main(void) if (rslt == BMI08X_OK) { - printf("\nACCEL DATA\n"); - printf("Accel data in LSB units and Gravity data in m/s^2\n"); - printf("Accel data range : 16G for BMI085 and 24G for BMI088\n\n"); - - while (times_to_read < 10) + if (bmi08xdev.accel_cfg.power == BMI08X_ACCEL_PM_ACTIVE) { - rslt = bmi08a_get_data_int_status(&status, &bmi08xdev); - bmi08x_error_codes_print_result("bmi08a_get_data_int_status", rslt); + printf("\nACCEL DATA\n"); + printf("Accel data in LSB units and Gravity data in m/s^2\n"); + printf("Accel data range : 16G for BMI085 and 24G for BMI088\n\n"); - if (status & BMI08X_ACCEL_DATA_READY_INT) + while (times_to_read < 10) { - rslt = bmi08a_get_data(&bmi08x_accel, &bmi08xdev); - bmi08x_error_codes_print_result("bmi08a_get_data", rslt); - - printf("ACCEL[%d] Acc_Raw_X : %d Acc_Raw_Y : %d Acc_Raw_Z : %d ", - times_to_read, - bmi08x_accel.x, - bmi08x_accel.y, - bmi08x_accel.z); + rslt = bmi08a_get_data_int_status(&status, &bmi08xdev); + bmi08x_error_codes_print_result("bmi08a_get_data_int_status", rslt); - if (bmi08xdev.variant == BMI085_VARIANT) - { - /* Converting lsb to meter per second squared for 16 bit accelerometer at 16G range. */ - x = lsb_to_mps2(bmi08x_accel.x, 16, 16); - y = lsb_to_mps2(bmi08x_accel.y, 16, 16); - z = lsb_to_mps2(bmi08x_accel.z, 16, 16); - } - else if (bmi08xdev.variant == BMI088_VARIANT) + if (status & BMI08X_ACCEL_DATA_READY_INT) { - /* Converting lsb to meter per second squared for 16 bit accelerometer at 24G range. */ - x = lsb_to_mps2(bmi08x_accel.x, 24, 16); - y = lsb_to_mps2(bmi08x_accel.y, 24, 16); - z = lsb_to_mps2(bmi08x_accel.z, 24, 16); + rslt = bmi08a_get_data(&bmi08x_accel, &bmi08xdev); + bmi08x_error_codes_print_result("bmi08a_get_data", rslt); + + printf("ACCEL[%d] Acc_Raw_X : %d Acc_Raw_Y : %d Acc_Raw_Z : %d ", + times_to_read, + bmi08x_accel.x, + bmi08x_accel.y, + bmi08x_accel.z); + + if (bmi08xdev.variant == BMI085_VARIANT) + { + /* Converting lsb to meter per second squared for 16 bit accelerometer at 16G range. */ + x = lsb_to_mps2(bmi08x_accel.x, 16, 16); + y = lsb_to_mps2(bmi08x_accel.y, 16, 16); + z = lsb_to_mps2(bmi08x_accel.z, 16, 16); + } + else if (bmi08xdev.variant == BMI088_VARIANT) + { + /* Converting lsb to meter per second squared for 16 bit accelerometer at 24G range. */ + x = lsb_to_mps2(bmi08x_accel.x, 24, 16); + y = lsb_to_mps2(bmi08x_accel.y, 24, 16); + z = lsb_to_mps2(bmi08x_accel.z, 24, 16); + } + + /* Print the data in m/s2. */ + printf("\t Acc_ms2_X = %4.2f, Acc_ms2_Y = %4.2f, Acc_ms2_Z = %4.2f\n", x, y, z); + + times_to_read = times_to_read + 1; } - - /* Print the data in m/s2. */ - printf("\t Acc_ms2_X = %4.2f, Acc_ms2_Y = %4.2f, Acc_ms2_Z = %4.2f\n", x, y, z); - - times_to_read = times_to_read + 1; } } - times_to_read = 0; - - printf("\n\nGYRO DATA\n"); - printf("Gyro data in LSB units and degrees per second\n"); - printf("Gyro data range : 250 dps for BMI085 and BMI088\n\n"); - - while (times_to_read < 10) + if (bmi08xdev.gyro_cfg.power == BMI08X_GYRO_PM_NORMAL) { - rslt = bmi08g_get_data_int_status(&status, &bmi08xdev); - bmi08x_error_codes_print_result("bmi08g_get_data_int_status", rslt); + times_to_read = 0; + + printf("\n\nGYRO DATA\n"); + printf("Gyro data in LSB units and degrees per second\n"); + printf("Gyro data range : 250 dps for BMI085 and BMI088\n\n"); - if (status & BMI08X_GYRO_DATA_READY_INT) + while (times_to_read < 10) { - rslt = bmi08g_get_data(&bmi08x_gyro, &bmi08xdev); - bmi08x_error_codes_print_result("bmi08g_get_data", rslt); + rslt = bmi08g_get_data_int_status(&status, &bmi08xdev); + bmi08x_error_codes_print_result("bmi08g_get_data_int_status", rslt); - printf("GYRO[%d] Gyr_Raw_X : %d Gyr_Raw_Y : %d Gyr_Raw_Z : %d ", - times_to_read, - bmi08x_gyro.x, - bmi08x_gyro.y, - bmi08x_gyro.z); + if (status & BMI08X_GYRO_DATA_READY_INT) + { + rslt = bmi08g_get_data(&bmi08x_gyro, &bmi08xdev); + bmi08x_error_codes_print_result("bmi08g_get_data", rslt); + + printf("GYRO[%d] Gyr_Raw_X : %d Gyr_Raw_Y : %d Gyr_Raw_Z : %d ", + times_to_read, + bmi08x_gyro.x, + bmi08x_gyro.y, + bmi08x_gyro.z); - /* Converting lsb to degree per second for 16 bit gyro at 250 dps range. */ - x = lsb_to_dps(bmi08x_gyro.x, 250, 16); - y = lsb_to_dps(bmi08x_gyro.y, 250, 16); - z = lsb_to_dps(bmi08x_gyro.z, 250, 16); + /* Converting lsb to degree per second for 16 bit gyro at 250 dps range. */ + x = lsb_to_dps(bmi08x_gyro.x, 250, 16); + y = lsb_to_dps(bmi08x_gyro.y, 250, 16); + z = lsb_to_dps(bmi08x_gyro.z, 250, 16); - /* Print the data in dps. */ - printf("\t Gyr_DPS_X = %4.2f , Gyr_DPS_Y = %4.2f , Gyr_DPS_Z = %4.2f\n", x, y, z); + /* Print the data in dps. */ + printf("\t Gyr_DPS_X = %4.2f , Gyr_DPS_Y = %4.2f , Gyr_DPS_Z = %4.2f\n", x, y, z); - times_to_read = times_to_read + 1; + times_to_read = times_to_read + 1; + } } } } diff --git a/examples/read_synchronized_data_mcu/read_synchronized_data_mcu.c b/examples/read_synchronized_data_mcu/read_synchronized_data_mcu.c index 9174433..13fe018 100644 --- a/examples/read_synchronized_data_mcu/read_synchronized_data_mcu.c +++ b/examples/read_synchronized_data_mcu/read_synchronized_data_mcu.c @@ -1,5 +1,5 @@ /** - * Copyright (C) 2021 Bosch Sensortec GmbH + * Copyright (C) 2022 Bosch Sensortec GmbH * * SPDX-License-Identifier: BSD-3-Clause */ @@ -118,8 +118,7 @@ static int8_t init_bmi08x(void) rslt = bmi08a_soft_reset(&bmi08xdev); bmi08x_error_codes_print_result("bmi08a_soft_reset", rslt); - /* Max read/write length (maximum supported length is 32). - To be set by the user */ + /* Read/write length */ bmi08xdev.read_write_len = 32; printf("Uploading BMI08X data synchronization feature config !\n");