diff --git a/LICENSE b/LICENSE index 7d08b66..fcbe827 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2020 Bosch Sensortec GmbH. All rights reserved. +Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved. BSD-3-Clause diff --git a/bmi08a.c b/bmi08a.c index 98c41ab..623fd16 100644 --- a/bmi08a.c +++ b/bmi08a.c @@ -1,40 +1,40 @@ /** - * Copyright (c) 2020 Bosch Sensortec GmbH. All rights reserved. - * - * BSD-3-Clause - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @file bmi08a.c - * @date 2020-12-11 - * @version v1.5.5 - * - */ +* Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved. +* +* BSD-3-Clause +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* +* 3. Neither the name of the copyright holder nor the names of its +* contributors may be used to endorse or promote products derived from +* this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +* POSSIBILITY OF SUCH DAMAGE. +* +* @file bmi08a.c +* @date 2021-06-22 +* @version v1.5.7 +* +*/ /*! \file bmi08a.c * \brief Sensor Driver for BMI08x family of sensors */ @@ -722,15 +722,16 @@ static int8_t set_fifo_wm_int(const struct bmi08x_accel_int_channel_cfg *int_con */ static int8_t set_fifo_full_int(const struct bmi08x_accel_int_channel_cfg *int_config, struct bmi08x_dev *dev); -/****************************************************************************/ - -/**\name Extern Declarations - ****************************************************************************/ - -/****************************************************************************/ - -/**\name Globals - ****************************************************************************/ +/* @brief This API is used to write the binary configuration in the sensor + * + * @param[in] dev : Structure instance of bmi08x_dev. + * + * @return Result of API execution status + * @retval 0 -> Success + * @retval < 0 -> Fail + * + */ +static int8_t write_config_file(struct bmi08x_dev *dev); /****************************************************************************/ @@ -812,111 +813,7 @@ int8_t bmi08a_load_config_file(struct bmi08x_dev *dev) dev->config_file_ptr = bmi08x_config_file; /* Upload binary */ - rslt = bmi08a_write_config_file(dev); - } - - return rslt; -} - -/*! - * @brief This API is used to write the binary configuration in the sensor. - */ -int8_t bmi08a_write_config_file(struct bmi08x_dev *dev) -{ - int8_t rslt; - - /* Config loading disable*/ - uint8_t config_load = BMI08X_DISABLE; - uint8_t current_acc_pwr_ctrl = BMI08X_DISABLE; - uint8_t aps_disable = BMI08X_DISABLE; - uint16_t index = 0; - uint8_t reg_data = 0; - - /* Check for null pointer in the device structure */ - rslt = null_ptr_check(dev); - - /* Check if config file pointer is not null */ - if ((rslt == BMI08X_OK) && (dev->config_file_ptr != NULL)) - { - /* Check whether the read/write length is valid */ - if (dev->read_write_len > 0) - { - /* Get accel status */ - rslt = bmi08a_get_regs(BMI08X_REG_ACCEL_PWR_CTRL, ¤t_acc_pwr_ctrl, 1, dev); - - if (rslt == BMI08X_OK) - { - /* Disable advanced power save mode */ - rslt = bmi08a_set_regs(BMI08X_REG_ACCEL_PWR_CONF, &aps_disable, 1, dev); - - if (rslt == BMI08X_OK) - { - rslt = bmi08a_set_regs(BMI08X_REG_ACCEL_PWR_CTRL, &config_load, 1, dev); - - if (rslt == BMI08X_OK) - { - /* Delay required to switch power modes */ - dev->delay_us(BMI08X_MS_TO_US(BMI08X_POWER_CONFIG_DELAY), dev->intf_ptr_accel); - - /* Disable config loading */ - rslt = bmi08a_set_regs(BMI08X_REG_ACCEL_INIT_CTRL, &config_load, 1, dev); - } - } - } - - if (rslt == BMI08X_OK) - { - for (index = 0; index < BMI08X_CONFIG_STREAM_SIZE; - index += dev->read_write_len) - { - /* Write the config stream */ - rslt = stream_transfer_write((dev->config_file_ptr + index), index, dev); - - dev->delay_us(5000, dev->intf_ptr_accel); - } - - if (rslt == BMI08X_OK) - { - /* Enable config loading and FIFO mode */ - config_load = BMI08X_ENABLE; - - rslt = bmi08a_set_regs(BMI08X_REG_ACCEL_INIT_CTRL, &config_load, 1, dev); - - if (rslt == BMI08X_OK) - { - /* Wait till ASIC is initialized. Refer the data-sheet for more information */ - dev->delay_us(BMI08X_MS_TO_US(BMI08X_ASIC_INIT_TIME_MS), dev->intf_ptr_accel); - - /* Check for config initialization status (1 = OK)*/ - rslt = bmi08a_get_regs(BMI08X_REG_ACCEL_INTERNAL_STAT, ®_data, 1, dev); - } - } - - if (rslt == BMI08X_OK && reg_data != 1) - { - rslt = BMI08X_E_CONFIG_STREAM_ERROR; - } - else - { - /* Restore accel */ - rslt = bmi08a_set_regs(BMI08X_REG_ACCEL_PWR_CTRL, ¤t_acc_pwr_ctrl, 1, dev); - - if (rslt == BMI08X_OK) - { - /* Delay required to switch power modes */ - dev->delay_us(BMI08X_MS_TO_US(BMI08X_POWER_CONFIG_DELAY), dev->intf_ptr_accel); - } - } - } - } - else - { - rslt = BMI08X_E_RD_WR_LENGTH_INVALID; - } - } - else - { - rslt = BMI08X_E_NULL_PTR; + rslt = write_config_file(dev); } return rslt; @@ -1657,6 +1554,9 @@ int8_t bmi08a_read_fifo_data(struct bmi08x_fifo_frame *fifo, struct bmi08x_dev * /* Variable to define error */ int8_t rslt; + /* Variable to store available fifo length */ + uint16_t fifo_length; + /* Array to store FIFO configuration data */ uint8_t config_data = 0; @@ -1670,8 +1570,29 @@ int8_t bmi08a_read_fifo_data(struct bmi08x_fifo_frame *fifo, struct bmi08x_dev * /* Clear the FIFO data structure */ reset_fifo_frame_structure(fifo); - /* Read FIFO data */ - rslt = bmi08a_get_regs(addr, fifo->data, fifo->length, dev); + if (dev->intf == BMI08X_SPI_INTF) + { + /* SPI mask added */ + addr = addr | BMI08X_SPI_RD_MASK; + } + + /* Read available fifo length */ + rslt = bmi08a_get_fifo_length(&fifo_length, dev); + + if (rslt == BMI08X_OK) + { + fifo->length = fifo_length + dev->dummy_byte; + + /* Read FIFO data */ + dev->intf_rslt = dev->read(addr, fifo->data, (uint32_t)fifo->length, dev->intf_ptr_accel); + + /* If interface read fails, update rslt variable with communication failure */ + if (dev->intf_rslt != BMI08X_INTF_RET_SUCCESS) + { + rslt = BMI08X_E_COM_FAIL; + } + } + if (rslt == BMI08X_OK) { /* Get the set FIFO frame configurations */ @@ -1804,6 +1725,15 @@ int8_t bmi08a_extract_accel(struct bmi08x_sensor_data *accel_data, rslt = null_ptr_check(dev); if ((rslt == BMI08X_OK) && (accel_data != NULL) && (accel_length != NULL) && (fifo != NULL)) { + /* Check if this is the first iteration of data unpacking + * if yes, then consider dummy byte on SPI + */ + if (fifo->acc_byte_start_idx == 0) + { + /* Dummy byte included */ + fifo->acc_byte_start_idx = dev->dummy_byte; + } + /* Parsing the FIFO data in header mode */ rslt = extract_acc_header_mode(accel_data, accel_length, fifo); } @@ -2070,7 +2000,7 @@ static int8_t null_ptr_check(const struct bmi08x_dev *dev) int8_t rslt; if ((dev == NULL) || (dev->read == NULL) || (dev->write == NULL) || (dev->delay_us == NULL) || - (dev->intf_ptr_accel == NULL) || (dev->intf_ptr_gyro == NULL)) + (dev->intf_ptr_accel == NULL)) { /* Device structure pointer is not valid */ rslt = BMI08X_E_NULL_PTR; @@ -2091,8 +2021,7 @@ static int8_t get_regs(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, struct { int8_t rslt = BMI08X_OK; uint16_t index; - uint32_t temp_len = len + dev->dummy_byte; - uint8_t temp_buff[temp_len]; + uint8_t temp_buff[BMI08X_MAX_LEN]; if (dev->intf == BMI08X_SPI_INTF) { @@ -2101,7 +2030,7 @@ static int8_t get_regs(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, struct } /* Read the data from the register */ - dev->intf_rslt = dev->read(reg_addr, temp_buff, temp_len, dev->intf_ptr_accel); + dev->intf_rslt = dev->read(reg_addr, temp_buff, (len + dev->dummy_byte), dev->intf_ptr_accel); if (dev->intf_rslt == BMI08X_INTF_RET_SUCCESS) { @@ -2518,7 +2447,7 @@ static int8_t unpack_skipped_frame(uint16_t *data_index, struct bmi08x_fifo_fram int8_t rslt = BMI08X_OK; /* Validate data index */ - if ((*data_index) >= fifo->length) + if (((*data_index) + BMI08X_FIFO_SKIP_FRM_LENGTH) > fifo->length) { /* Update the data index to the last byte */ (*data_index) = fifo->length; @@ -2604,7 +2533,7 @@ static int8_t unpack_accel_frame(struct bmi08x_sensor_data *acc, case BMI08X_FIFO_HEADER_ACC_FRM: /* Partially read, then skip the data */ - if (((*idx) + fifo->acc_frm_len) > fifo->length) + if (((*idx) + BMI08X_FIFO_ACCEL_LENGTH) > fifo->length) { /* Update the data index as complete*/ (*idx) = fifo->length; @@ -2901,4 +2830,86 @@ static int8_t set_fifo_full_int(const struct bmi08x_accel_int_channel_cfg *int_c return rslt; } +/* + * @brief This API is used to write the binary configuration in the sensor + */ +static int8_t write_config_file(struct bmi08x_dev *dev) +{ + int8_t rslt; + + /* Config loading disable */ + uint8_t config_load = BMI08X_DISABLE; + + /* APS disable */ + uint8_t aps_disable = BMI08X_DISABLE; + + uint16_t index = 0; + uint8_t reg_data = 0; + + /* Check for null pointer in the device structure */ + rslt = null_ptr_check(dev); + + /* Check if config file pointer is not null */ + if ((rslt == BMI08X_OK) && (dev->config_file_ptr != NULL)) + { + /* Check whether the read/write length is valid */ + if (dev->read_write_len > 0) + { + /* Disable advanced power save mode */ + rslt = bmi08a_set_regs(BMI08X_REG_ACCEL_PWR_CONF, &aps_disable, 1, dev); + + if (rslt == BMI08X_OK) + { + /* Wait until APS disable is set. Refer the data-sheet for more information */ + dev->delay_us(450, dev->intf_ptr_accel); + + /* Disable config loading */ + rslt = bmi08a_set_regs(BMI08X_REG_ACCEL_INIT_CTRL, &config_load, 1, dev); + } + + if (rslt == BMI08X_OK) + { + for (index = 0; index < BMI08X_CONFIG_STREAM_SIZE; + index += dev->read_write_len) + { + /* Write the config stream */ + rslt = stream_transfer_write((dev->config_file_ptr + index), index, dev); + } + + if (rslt == BMI08X_OK) + { + /* Enable config loading and FIFO mode */ + config_load = BMI08X_ENABLE; + + rslt = bmi08a_set_regs(BMI08X_REG_ACCEL_INIT_CTRL, &config_load, 1, dev); + + if (rslt == BMI08X_OK) + { + /* Wait till ASIC is initialized. Refer the data-sheet for more information */ + dev->delay_us(BMI08X_MS_TO_US(BMI08X_ASIC_INIT_TIME_MS), dev->intf_ptr_accel); + + /* Check for config initialization status (1 = OK)*/ + rslt = bmi08a_get_regs(BMI08X_REG_ACCEL_INTERNAL_STAT, ®_data, 1, dev); + } + } + + if (rslt == BMI08X_OK && reg_data != 1) + { + rslt = BMI08X_E_CONFIG_STREAM_ERROR; + } + } + } + else + { + rslt = BMI08X_E_RD_WR_LENGTH_INVALID; + } + } + else + { + rslt = BMI08X_E_NULL_PTR; + } + + return rslt; +} + /*! @endcond */ diff --git a/bmi08g.c b/bmi08g.c index e0812eb..589e801 100644 --- a/bmi08g.c +++ b/bmi08g.c @@ -1,40 +1,40 @@ /** - * Copyright (c) 2020 Bosch Sensortec GmbH. All rights reserved. - * - * BSD-3-Clause - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @file bmi08g.c - * @date 2020-12-11 - * @version v1.5.5 - * - */ +* Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved. +* +* BSD-3-Clause +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* +* 3. Neither the name of the copyright holder nor the names of its +* contributors may be used to endorse or promote products derived from +* this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +* POSSIBILITY OF SUCH DAMAGE. +* +* @file bmi08g.c +* @date 2021-06-22 +* @version v1.5.7 +* +*/ /*! \file bmi08g.c * \brief Sensor Driver for BMI08X family of sensors */ @@ -906,7 +906,7 @@ static int8_t null_ptr_check(const struct bmi08x_dev *dev) int8_t rslt; if ((dev == NULL) || (dev->read == NULL) || (dev->write == NULL) || (dev->delay_us == NULL) || - (dev->intf_ptr_accel == NULL) || (dev->intf_ptr_gyro == NULL)) + (dev->intf_ptr_gyro == NULL)) { /* Device structure pointer is not valid */ rslt = BMI08X_E_NULL_PTR; diff --git a/bmi08x.h b/bmi08x.h index a69a414..5ecdd95 100644 --- a/bmi08x.h +++ b/bmi08x.h @@ -1,40 +1,40 @@ /** - * Copyright (c) 2020 Bosch Sensortec GmbH. All rights reserved. - * - * BSD-3-Clause - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @file bmi08x.h - * @date 2020-12-11 - * @version v1.5.5 - * - */ +* Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved. +* +* BSD-3-Clause +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* +* 3. Neither the name of the copyright holder nor the names of its +* contributors may be used to endorse or promote products derived from +* this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +* POSSIBILITY OF SUCH DAMAGE. +* +* @file bmi08x.h +* @date 2021-06-22 +* @version v1.5.7 +* +*/ /*! \file bmi08x.h * \brief Sensor Driver for BMI08x family of sensors */ @@ -93,23 +93,6 @@ int8_t bmi08a_init(struct bmi08x_dev *dev); * @brief Uploads config file onto the device */ -/*! - * \ingroup bmi08aApiConfig - * \page bmi08a_api_bmi08a_write_config_file bmi08a_write_config_file - * \code - * int8_t bmi088_write_config_file(struct bmi08x_dev *dev); - * \endcode - * @details This API is used to write the binary configuration in the sensor - * - * @param[in] dev : Structure instance of bmi08x_dev. - * - * @return Result of API execution status - * @retval 0 -> Success - * @retval < 0 -> Fail - * - */ -int8_t bmi08a_write_config_file(struct bmi08x_dev *dev); - /*! * \ingroup bmi08aApiConfig * \page bmi08a_api_bmi08a_load_config_file bmi08a_load_config_file diff --git a/bmi08x_defs.h b/bmi08x_defs.h index 327496c..30aae7d 100644 --- a/bmi08x_defs.h +++ b/bmi08x_defs.h @@ -1,5 +1,5 @@ /** -* Copyright (c) 2020 Bosch Sensortec GmbH. All rights reserved. +* Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved. * * BSD-3-Clause * @@ -31,8 +31,8 @@ * POSSIBILITY OF SUCH DAMAGE. * * @file bmi08x_defs.h -* @date 2020-12-11 -* @version v1.5.5 +* @date 2021-06-22 +* @version v1.5.7 * */ @@ -231,9 +231,9 @@ #define BMI08X_GYRO_FIFO_FULL_INT UINT8_C(0x10) /**\name Accel Bandwidth */ -#define BMI08X_ACCEL_BW_OSR4 UINT8_C(0x00) -#define BMI08X_ACCEL_BW_OSR2 UINT8_C(0x01) -#define BMI08X_ACCEL_BW_NORMAL UINT8_C(0x02) +#define BMI08X_ACCEL_BW_OSR4 UINT8_C(0x08) +#define BMI08X_ACCEL_BW_OSR2 UINT8_C(0x09) +#define BMI08X_ACCEL_BW_NORMAL UINT8_C(0x0A) /**\name BMI085 Accel Range */ #define BMI085_ACCEL_RANGE_2G UINT8_C(0x00) @@ -297,7 +297,7 @@ /**\name Mask definitions for odr, bandwidth and range */ #define BMI08X_ACCEL_ODR_MASK UINT8_C(0x0F) -#define BMI08X_ACCEL_BW_MASK UINT8_C(0x70) +#define BMI08X_ACCEL_BW_MASK UINT8_C(0xF0) #define BMI08X_ACCEL_RANGE_MASK UINT8_C(0x03) /**\name Position definitions for odr, bandwidth and range */ @@ -571,10 +571,16 @@ #define BMI08X_DISABLE UINT8_C(0) #define BMI08X_ENABLE UINT8_C(1) -/*! @name To define warnings for FIFO activity */ +/**\name To define warnings for FIFO activity */ #define BMI08X_W_FIFO_EMPTY INT8_C(1) #define BMI08X_W_PARTIAL_READ INT8_C(2) +/**\name Maximum length to read */ +#define BMI08X_MAX_LEN UINT8_C(128) + +/**\name Sensortime resolution in seconds */ +#define BMI08X_SENSORTIME_RESOLUTION 0.0000390625f + /**\name Constant values macros */ #define BMI08X_SENSOR_DATA_SYNC_TIME_MS UINT8_C(1) #define BMI08X_DELAY_BETWEEN_WRITES_MS UINT8_C(1) @@ -1067,12 +1073,6 @@ struct bmi08x_fifo_frame /*! Water-mark level for water-mark interrupt */ uint16_t wm_lvl; - /*! Accelerometer frame length */ - uint8_t acc_frm_len; - - /*! Gyro frame length */ - uint8_t gyr_frm_len; - /*! FIFO accelerometer configurations */ struct bmi08x_accel_fifo_config acc_fifo_conf; diff --git a/examples/accel_fifo_full/accel_fifo_full.c b/examples/accel_fifo_full/accel_fifo_full.c index 3dfd5c4..251f058 100644 --- a/examples/accel_fifo_full/accel_fifo_full.c +++ b/examples/accel_fifo_full/accel_fifo_full.c @@ -1,11 +1,7 @@ /** - * Copyright (C) 2020 Bosch Sensortec GmbH + * Copyright (C) 2021 Bosch Sensortec GmbH * * SPDX-License-Identifier: BSD-3-Clause - * - * @file accel_fifo_full.c - * @brief Example file how to read bmi08x accel FIFO full data - * */ /*********************************************************************/ @@ -83,6 +79,13 @@ static int8_t init_bmi08x(void) bmi08x_error_codes_print_result("bmi08g_init", rslt); } + if (rslt == BMI08X_OK) + { + printf("Uploading config file !\n"); + rslt = bmi08a_load_config_file(&bmi08xdev); + bmi08x_error_codes_print_result("bmi08a_load_config_file", rslt); + } + if (rslt == BMI08X_OK) { bmi08xdev.accel_cfg.odr = BMI08X_ACCEL_ODR_1600_HZ; @@ -101,11 +104,9 @@ static int8_t init_bmi08x(void) rslt = bmi08a_set_power_mode(&bmi08xdev); bmi08x_error_codes_print_result("bmi08a_set_power_mode", rslt); - coines_delay_msec(10); rslt = bmi08a_set_meas_conf(&bmi08xdev); bmi08x_error_codes_print_result("bmi08a_set_meas_conf", rslt); - coines_delay_msec(10); bmi08xdev.gyro_cfg.odr = BMI08X_GYRO_BW_230_ODR_2000_HZ; bmi08xdev.gyro_cfg.range = BMI08X_GYRO_RANGE_250_DPS; @@ -114,11 +115,9 @@ static int8_t init_bmi08x(void) rslt = bmi08g_set_power_mode(&bmi08xdev); bmi08x_error_codes_print_result("bmi08g_set_power_mode", rslt); - coines_delay_msec(10); rslt = bmi08g_set_meas_conf(&bmi08xdev); bmi08x_error_codes_print_result("bmi08g_set_meas_conf", rslt); - coines_delay_msec(10); } return rslt; @@ -235,10 +234,6 @@ int main(void) if (rslt == BMI08X_OK) { - /* Update FIFO structure */ - fifo_frame.data = fifo_data; - fifo_frame.length = BMI08X_ACC_FIFO_RAW_DATA_USER_LENGTH; - config.accel_en = BMI08X_ENABLE; /* Set FIFO configuration by enabling accelerometer */ @@ -254,6 +249,10 @@ int main(void) { printf("\nIteration : %d\n", try); + /* Update FIFO structure */ + fifo_frame.data = fifo_data; + fifo_frame.length = BMI08X_ACC_FIFO_RAW_DATA_USER_LENGTH; + accel_length = BMI08X_ACC_FIFO_FULL_EXTRACTED_DATA_FRAME_COUNT; rslt = bmi08a_get_fifo_length(&fifo_length, &bmi08xdev); @@ -266,9 +265,6 @@ int main(void) if (rslt == BMI08X_OK) { - /* Delay to read FIFO with microcontroller */ - bmi08xdev.delay_us(1000, bmi08xdev.intf_ptr_accel); - /* Read FIFO data */ rslt = bmi08a_read_fifo_data(&fifo_frame, &bmi08xdev); bmi08x_error_codes_print_result("bmi08a_read_fifo_data", rslt); @@ -292,7 +288,7 @@ int main(void) rslt = bmi08a_get_sensor_time(&bmi08xdev, &sensor_time); bmi08x_error_codes_print_result("bmi08a_get_sensor_time", rslt); - printf("Sensor time : %lu\n", sensor_time); + printf("Sensor time : %.4lf s\n", (sensor_time * BMI08X_SENSORTIME_RESOLUTION)); } try++; diff --git a/examples/accel_fifo_watermark/accel_fifo_watermark.c b/examples/accel_fifo_watermark/accel_fifo_watermark.c index 3be38ad..6e8cd36 100644 --- a/examples/accel_fifo_watermark/accel_fifo_watermark.c +++ b/examples/accel_fifo_watermark/accel_fifo_watermark.c @@ -1,11 +1,7 @@ /** - * Copyright (C) 2020 Bosch Sensortec GmbH + * Copyright (C) 2021 Bosch Sensortec GmbH * * SPDX-License-Identifier: BSD-3-Clause - * - * @file accel_fifo_watermark.c - * @brief Example file how to read bmi08x accel FIFO watermark data - * */ /*********************************************************************/ @@ -90,6 +86,13 @@ static int8_t init_bmi08x(void) bmi08x_error_codes_print_result("bmi08g_init", rslt); } + if (rslt == BMI08X_OK) + { + printf("Uploading config file !\n"); + rslt = bmi08a_load_config_file(&bmi08xdev); + bmi08x_error_codes_print_result("bmi08a_load_config_file", rslt); + } + if (rslt == BMI08X_OK) { bmi08xdev.accel_cfg.odr = BMI08X_ACCEL_ODR_1600_HZ; @@ -108,11 +111,9 @@ static int8_t init_bmi08x(void) rslt = bmi08a_set_power_mode(&bmi08xdev); bmi08x_error_codes_print_result("bmi08a_set_power_mode", rslt); - coines_delay_msec(10); rslt = bmi08a_set_meas_conf(&bmi08xdev); bmi08x_error_codes_print_result("bmi08a_set_meas_conf", rslt); - coines_delay_msec(10); bmi08xdev.gyro_cfg.odr = BMI08X_GYRO_BW_230_ODR_2000_HZ; bmi08xdev.gyro_cfg.range = BMI08X_GYRO_RANGE_250_DPS; @@ -121,11 +122,9 @@ static int8_t init_bmi08x(void) rslt = bmi08g_set_power_mode(&bmi08xdev); bmi08x_error_codes_print_result("bmi08g_set_power_mode", rslt); - coines_delay_msec(10); rslt = bmi08g_set_meas_conf(&bmi08xdev); bmi08x_error_codes_print_result("bmi08g_set_meas_conf", rslt); - coines_delay_msec(10); } return rslt; @@ -248,10 +247,6 @@ int main(void) rslt = bmi08a_set_fifo_wm(BMI08X_ACC_FIFO_WATERMARK_LEVEL, &bmi08xdev); bmi08x_error_codes_print_result("bmi08a_set_fifo_wm", rslt); - /* Update FIFO structure */ - fifo_frame.data = fifo_data; - fifo_frame.length = BMI08X_ACC_FIFO_RAW_DATA_USER_LENGTH; - config.accel_en = BMI08X_ENABLE; /* Set FIFO configuration by enabling accelerometer */ @@ -267,6 +262,10 @@ int main(void) { printf("\nIteration : %d\n", try); + /* Update FIFO structure */ + fifo_frame.data = fifo_data; + fifo_frame.length = BMI08X_ACC_FIFO_RAW_DATA_USER_LENGTH; + accel_length = BMI08X_ACC_FIFO_WM_EXTRACTED_DATA_FRAME_COUNT; rslt = bmi08a_get_fifo_length(&fifo_length, &bmi08xdev); @@ -284,9 +283,6 @@ int main(void) if (rslt == BMI08X_OK) { - /* Delay to read FIFO with microcontroller */ - bmi08xdev.delay_us(1000, bmi08xdev.intf_ptr_accel); - /* Read FIFO data */ rslt = bmi08a_read_fifo_data(&fifo_frame, &bmi08xdev); bmi08x_error_codes_print_result("bmi08a_read_fifo_data", rslt); @@ -310,7 +306,7 @@ int main(void) rslt = bmi08a_get_sensor_time(&bmi08xdev, &sensor_time); bmi08x_error_codes_print_result("bmi08a_get_sensor_time", rslt); - printf("Sensor time : %lu\n", sensor_time); + printf("Sensor time : %.4lf s\n", (sensor_time * BMI08X_SENSORTIME_RESOLUTION)); } try++; diff --git a/examples/common/common.c b/examples/common/common.c index bf635dd..43618da 100644 --- a/examples/common/common.c +++ b/examples/common/common.c @@ -1,5 +1,5 @@ /** - * Copyright (C) 2020 Bosch Sensortec GmbH. All rights reserved. + * Copyright (C) 2021 Bosch Sensortec GmbH. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -8,8 +8,7 @@ #include #include -#include "coines.h" -#include "bmi08x_defs.h" +#include "common.h" /******************************************************************************/ /*! Macro definitions */ @@ -110,9 +109,27 @@ int8_t bmi08x_interface_init(struct bmi08x_dev *bmi08x, uint8_t intf, uint8_t va if (result == COINES_SUCCESS) { + if ((board_info.shuttle_id == BMI085_SHUTTLE_ID) && (variant == BMI088_VARIANT)) + { + 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)) + { + 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)) { - printf("! Warning invalid sensor shuttle \n ," "This application will not support this sensor \n"); + printf( + "! Warning invalid sensor shuttle (neither BMI085 nor BMI088 used) \n ," + "This application will not support this sensor \n"); exit(COINES_E_FAILURE); } } @@ -135,10 +152,7 @@ int8_t bmi08x_interface_init(struct bmi08x_dev *bmi08x, uint8_t intf, uint8_t va /* SDO pin is made low for selecting I2C address 0x76*/ coines_set_pin_config(COINES_SHUTTLE_PIN_8, COINES_PIN_DIRECTION_OUT, COINES_PIN_VALUE_LOW); - /* set the sensor interface as I2C with 400kHz speed - Use I2C Fast mode (400kHz) for reliable operation with high ODR/sampling time - See Readme.txt - NOTE section for details*/ - coines_config_i2c_bus(COINES_I2C_BUS_0, COINES_I2C_FAST_MODE); + coines_config_i2c_bus(COINES_I2C_BUS_0, COINES_I2C_STANDARD_MODE); coines_delay_msec(10); /* PS pin is made high for selecting I2C protocol (gyroscope)*/ @@ -246,6 +260,10 @@ void bmi08x_error_codes_print_result(const char api_name[], int8_t rslt) { printf("Error [%d] : Feature not supported\r\n", rslt); } + else if (rslt == BMI08X_W_FIFO_EMPTY) + { + printf("Warning [%d] : FIFO empty\r\n", rslt); + } else { printf("Error [%d] : Unknown error code\r\n", rslt); @@ -260,5 +278,14 @@ void bmi08x_error_codes_print_result(const char api_name[], int8_t rslt) */ void bmi08x_coines_deinit(void) { + fflush(stdout); + + coines_set_shuttleboard_vdd_vddio_config(0, 0); + coines_delay_msec(100); + + /* Coines interface reset */ + coines_soft_reset(); + coines_delay_msec(100); + coines_close_comm_intf(COINES_COMM_INTF_USB); } diff --git a/examples/common/common.h b/examples/common/common.h index 96b5fe4..c5d23d4 100644 --- a/examples/common/common.h +++ b/examples/common/common.h @@ -1,5 +1,5 @@ /**\ - * Copyright (c) 2020 Bosch Sensortec GmbH. All rights reserved. + * Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause **/ @@ -13,6 +13,8 @@ extern "C" { #endif #include + +#include "coines.h" #include "bmi08x_defs.h" /*! diff --git a/examples/gyro_fifo_full/gyro_fifo_full.c b/examples/gyro_fifo_full/gyro_fifo_full.c index 73de3d8..984739b 100644 --- a/examples/gyro_fifo_full/gyro_fifo_full.c +++ b/examples/gyro_fifo_full/gyro_fifo_full.c @@ -1,10 +1,7 @@ /**\ - * Copyright (c) 2020 Bosch Sensortec GmbH. All rights reserved. + * Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause - * - * @file gyro_fifo_full.c - * @brief Example file how to read bmi08x gyro FIFO watermark data */ /******************************************************************************/ @@ -81,11 +78,9 @@ static int8_t init_bmi08x(void) rslt = bmi08a_set_power_mode(&bmi08xdev); bmi08x_error_codes_print_result("bmi08a_set_power_mode", rslt); - coines_delay_msec(10); rslt = bmi08a_set_meas_conf(&bmi08xdev); bmi08x_error_codes_print_result("bmi08a_set_meas_conf", rslt); - coines_delay_msec(10); bmi08xdev.gyro_cfg.odr = BMI08X_GYRO_BW_32_ODR_100_HZ; bmi08xdev.gyro_cfg.range = BMI08X_GYRO_RANGE_125_DPS; @@ -94,11 +89,10 @@ static int8_t init_bmi08x(void) rslt = bmi08g_set_power_mode(&bmi08xdev); bmi08x_error_codes_print_result("bmi08g_set_power_mode", rslt); - coines_delay_msec(10); rslt = bmi08g_set_meas_conf(&bmi08xdev); bmi08x_error_codes_print_result("bmi08g_set_meas_conf", rslt); - coines_delay_msec(10); + coines_delay_msec(1); } return rslt; @@ -237,9 +231,6 @@ int main(void) rslt = bmi08g_get_fifo_length(&gyr_conf, &fifo); bmi08x_error_codes_print_result("bmi08g_get_fifo_length", rslt); - /* Delay to read FIFO with microcontroller */ - bmi08xdev.delay_us(1000, bmi08xdev.intf_ptr_gyro); - /* Read FIFO data */ rslt = bmi08g_read_fifo_data(&fifo, &bmi08xdev); bmi08x_error_codes_print_result("bmi08g_read_fifo_data", rslt); diff --git a/examples/gyro_fifo_watermark/gyro_fifo_watermark.c b/examples/gyro_fifo_watermark/gyro_fifo_watermark.c index 5944785..eee6359 100644 --- a/examples/gyro_fifo_watermark/gyro_fifo_watermark.c +++ b/examples/gyro_fifo_watermark/gyro_fifo_watermark.c @@ -1,10 +1,7 @@ /**\ - * Copyright (c) 2020 Bosch Sensortec GmbH. All rights reserved. + * Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause - * - * @file gyro_fifo_watermark.c - * @brief Example file how to read bmi08x gyro FIFO watermark data */ /******************************************************************************/ @@ -84,11 +81,9 @@ static int8_t init_bmi08x(void) rslt = bmi08a_set_power_mode(&bmi08xdev); bmi08x_error_codes_print_result("bmi08a_set_power_mode", rslt); - coines_delay_msec(10); rslt = bmi08a_set_meas_conf(&bmi08xdev); bmi08x_error_codes_print_result("bmi08a_set_meas_conf", rslt); - coines_delay_msec(10); bmi08xdev.gyro_cfg.odr = BMI08X_GYRO_BW_32_ODR_100_HZ; bmi08xdev.gyro_cfg.range = BMI08X_GYRO_RANGE_125_DPS; @@ -97,11 +92,9 @@ static int8_t init_bmi08x(void) rslt = bmi08g_set_power_mode(&bmi08xdev); bmi08x_error_codes_print_result("bmi08g_set_power_mode", rslt); - coines_delay_msec(10); rslt = bmi08g_set_meas_conf(&bmi08xdev); bmi08x_error_codes_print_result("bmi08g_set_meas_conf", rslt); - coines_delay_msec(10); } return rslt; @@ -249,9 +242,6 @@ int main(void) rslt = bmi08g_get_fifo_length(&gyr_conf, &fifo); bmi08x_error_codes_print_result("bmi08g_get_fifo_length", rslt); - /* Delay to read FIFO with microcontroller */ - bmi08xdev.delay_us(1000, bmi08xdev.intf_ptr_gyro); - /* Read FIFO data */ rslt = bmi08g_read_fifo_data(&fifo, &bmi08xdev); bmi08x_error_codes_print_result("bmi08g_read_fifo_data", rslt); diff --git a/examples/interrupt_streaming_pc/interrupt_streaming_pc.c b/examples/interrupt_streaming_pc/interrupt_streaming_pc.c index 3404a77..02e592b 100644 --- a/examples/interrupt_streaming_pc/interrupt_streaming_pc.c +++ b/examples/interrupt_streaming_pc/interrupt_streaming_pc.c @@ -1,11 +1,7 @@ /** - * Copyright (C) 2020 Bosch Sensortec GmbH + * Copyright (C) 2021 Bosch Sensortec GmbH * * SPDX-License-Identifier: BSD-3-Clause - * - * @file interrupt_streaming.c - * @brief Example file to stream bmi08x sensor data using LIB COINES - * */ /*********************************************************************/ @@ -384,12 +380,18 @@ static int8_t init_bmi08x(void) bmi08x_error_codes_print_result("bmi08g_init", rslt); } + if (rslt == BMI08X_OK) + { + printf("Uploading config file !\n"); + rslt = bmi08a_load_config_file(&bmi08xdev); + bmi08x_error_codes_print_result("bmi08a_load_config_file", rslt); + } + if (rslt == BMI08X_OK) { printf("BMI08x initialization success !\n"); printf("Accel chip ID - 0x%x\n", bmi08xdev.accel_chip_id); printf("Gyro chip ID - 0x%x\n", bmi08xdev.gyro_chip_id); - coines_delay_msec(100); bmi08xdev.accel_cfg.odr = BMI08X_ACCEL_ODR_1600_HZ; @@ -407,11 +409,9 @@ static int8_t init_bmi08x(void) rslt = bmi08a_set_power_mode(&bmi08xdev); bmi08x_error_codes_print_result("bmi08a_set_power_mode", rslt); - coines_delay_msec(10); rslt = bmi08a_set_meas_conf(&bmi08xdev); bmi08x_error_codes_print_result("bmi08a_set_meas_conf", rslt); - coines_delay_msec(10); bmi08xdev.gyro_cfg.odr = BMI08X_GYRO_BW_230_ODR_2000_HZ; bmi08xdev.gyro_cfg.range = BMI08X_GYRO_RANGE_250_DPS; @@ -420,11 +420,9 @@ static int8_t init_bmi08x(void) rslt = bmi08g_set_power_mode(&bmi08xdev); bmi08x_error_codes_print_result("bmi08g_set_power_mode", rslt); - coines_delay_msec(10); rslt = bmi08g_set_meas_conf(&bmi08xdev); bmi08x_error_codes_print_result("bmi08g_set_meas_conf", rslt); - coines_delay_msec(10); if ((rslt == BMI08X_OK) && (bmi08xdev.accel_cfg.power == BMI08X_ACCEL_PM_SUSPEND && diff --git a/examples/polling_streaming_pc/polling_streaming_pc.c b/examples/polling_streaming_pc/polling_streaming_pc.c index d791482..1acd8db 100644 --- a/examples/polling_streaming_pc/polling_streaming_pc.c +++ b/examples/polling_streaming_pc/polling_streaming_pc.c @@ -1,11 +1,7 @@ /** - * Copyright (C) 2020 Bosch Sensortec GmbH + * Copyright (C) 2021 Bosch Sensortec GmbH * * SPDX-License-Identifier: BSD-3-Clause - * - * @file polling_streaming.c - * @brief Example file to stream bmi08x sensor data using LIB COINES - * */ /*********************************************************************/ @@ -302,8 +298,13 @@ static int8_t init_bmi08x(void) if (rslt == BMI08X_OK) { - coines_delay_msec(100); + printf("Uploading config file !\n"); + rslt = bmi08a_load_config_file(&bmi08xdev); + bmi08x_error_codes_print_result("bmi08a_load_config_file", rslt); + } + if (rslt == BMI08X_OK) + { bmi08xdev.accel_cfg.odr = BMI08X_ACCEL_ODR_1600_HZ; if (bmi08xdev.variant == BMI085_VARIANT) @@ -320,11 +321,9 @@ static int8_t init_bmi08x(void) rslt = bmi08a_set_power_mode(&bmi08xdev); bmi08x_error_codes_print_result("bmi08a_set_power_mode", rslt); - coines_delay_msec(10); rslt = bmi08a_set_meas_conf(&bmi08xdev); bmi08x_error_codes_print_result("bmi08a_set_meas_conf", rslt); - coines_delay_msec(10); bmi08xdev.gyro_cfg.odr = BMI08X_GYRO_BW_230_ODR_2000_HZ; bmi08xdev.gyro_cfg.range = BMI08X_GYRO_RANGE_250_DPS; @@ -333,11 +332,9 @@ static int8_t init_bmi08x(void) rslt = bmi08g_set_power_mode(&bmi08xdev); bmi08x_error_codes_print_result("bmi08g_set_power_mode", rslt); - coines_delay_msec(10); rslt = bmi08g_set_meas_conf(&bmi08xdev); bmi08x_error_codes_print_result("bmi08g_set_meas_conf", rslt); - coines_delay_msec(10); } return rslt; diff --git a/examples/read_sensor_data/read_sensor_data.c b/examples/read_sensor_data/read_sensor_data.c index 98f25d9..216062e 100644 --- a/examples/read_sensor_data/read_sensor_data.c +++ b/examples/read_sensor_data/read_sensor_data.c @@ -1,11 +1,7 @@ /** - * Copyright (C) 2020 Bosch Sensortec GmbH + * Copyright (C) 2021 Bosch Sensortec GmbH * * SPDX-License-Identifier: BSD-3-Clause - * - * @file read_sensor_data.c - * @brief Example file how to read bmi08x sensor data using LIB COINES - * */ /*********************************************************************/ @@ -106,6 +102,13 @@ static int8_t init_bmi08x(void) bmi08x_error_codes_print_result("bmi08g_init", rslt); } + if (rslt == BMI08X_OK) + { + printf("Uploading config file !\n"); + rslt = bmi08a_load_config_file(&bmi08xdev); + bmi08x_error_codes_print_result("bmi08a_load_config_file", rslt); + } + if (rslt == BMI08X_OK) { bmi08xdev.accel_cfg.odr = BMI08X_ACCEL_ODR_1600_HZ; @@ -124,11 +127,9 @@ static int8_t init_bmi08x(void) rslt = bmi08a_set_power_mode(&bmi08xdev); bmi08x_error_codes_print_result("bmi08a_set_power_mode", rslt); - coines_delay_msec(10); rslt = bmi08a_set_meas_conf(&bmi08xdev); bmi08x_error_codes_print_result("bmi08a_set_meas_conf", rslt); - coines_delay_msec(10); bmi08xdev.gyro_cfg.odr = BMI08X_GYRO_BW_230_ODR_2000_HZ; bmi08xdev.gyro_cfg.range = BMI08X_GYRO_RANGE_250_DPS; @@ -137,11 +138,9 @@ static int8_t init_bmi08x(void) rslt = bmi08g_set_power_mode(&bmi08xdev); bmi08x_error_codes_print_result("bmi08g_set_power_mode", rslt); - coines_delay_msec(10); rslt = bmi08g_set_meas_conf(&bmi08xdev); bmi08x_error_codes_print_result("bmi08g_set_meas_conf", rslt); - coines_delay_msec(10); } return rslt; @@ -305,7 +304,6 @@ int main(void) /* 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); - coines_delay_msec(10); times_to_read = times_to_read + 1; } } @@ -340,7 +338,6 @@ int main(void) /* 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); - coines_delay_msec(10); 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 46e3728..9174433 100644 --- a/examples/read_synchronized_data_mcu/read_synchronized_data_mcu.c +++ b/examples/read_synchronized_data_mcu/read_synchronized_data_mcu.c @@ -1,11 +1,7 @@ /** - * Copyright (C) 2020 Bosch Sensortec GmbH + * Copyright (C) 2021 Bosch Sensortec GmbH * * SPDX-License-Identifier: BSD-3-Clause - * - * @file read_synchronized_data_mcu.c - * @brief Example file how to read bmi08x sensor data using LIB COINES - * */ /*********************************************************************/ @@ -126,6 +122,10 @@ static int8_t init_bmi08x(void) To be set by the user */ bmi08xdev.read_write_len = 32; + printf("Uploading BMI08X data synchronization feature config !\n"); + rslt = bmi08a_load_config_file(&bmi08xdev); + bmi08x_error_codes_print_result("bmi08a_load_config_file", rslt); + /* Set accel power mode */ bmi08xdev.accel_cfg.power = BMI08X_ACCEL_PM_ACTIVE; rslt = bmi08a_set_power_mode(&bmi08xdev); @@ -141,36 +141,27 @@ static int8_t init_bmi08x(void) if ((bmi08xdev.accel_cfg.power == BMI08X_ACCEL_PM_ACTIVE) && (bmi08xdev.gyro_cfg.power == BMI08X_GYRO_PM_NORMAL)) { - printf("Uploading BMI08X data synchronization feature config !\n"); - /* API uploads the bmi08x config file onto the device */ if (rslt == BMI08X_OK) { - rslt = bmi08a_load_config_file(&bmi08xdev); - bmi08x_error_codes_print_result("bmi08a_load_config_file", rslt); - - /* Wait for 150ms to enable the data synchronization --delay taken care inside the function */ - if (rslt == BMI08X_OK) + /* Assign accel range setting */ + if (bmi08xdev.variant == BMI085_VARIANT) { - /* Assign accel range setting */ - if (bmi08xdev.variant == BMI085_VARIANT) - { - bmi08xdev.accel_cfg.range = BMI085_ACCEL_RANGE_16G; - } - else if (bmi08xdev.variant == BMI088_VARIANT) - { - bmi08xdev.accel_cfg.range = BMI088_ACCEL_RANGE_24G; - } - - /* 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_400HZ; - - rslt = bmi08a_configure_data_synchronization(sync_cfg, &bmi08xdev); - bmi08x_error_codes_print_result("bmi08a_configure_data_synchronization", rslt); + bmi08xdev.accel_cfg.range = BMI085_ACCEL_RANGE_16G; } + else if (bmi08xdev.variant == BMI088_VARIANT) + { + bmi08xdev.accel_cfg.range = BMI088_ACCEL_RANGE_24G; + } + + /* 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_400HZ; + + rslt = bmi08a_configure_data_synchronization(sync_cfg, &bmi08xdev); + bmi08x_error_codes_print_result("bmi08a_configure_data_synchronization", rslt); } if (rslt == BMI08X_OK)