BNO055 library using Bosch's code

Committer:
gume
Date:
Sat Jul 01 01:24:03 2017 +0000
Revision:
0:1f82672b8755
Initial commit. Library based on Bosch's code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gume 0:1f82672b8755 1 /*
gume 0:1f82672b8755 2 *
gume 0:1f82672b8755 3 ****************************************************************************
gume 0:1f82672b8755 4 * Copyright (C) 2015 - 2016 Bosch Sensortec GmbH
gume 0:1f82672b8755 5 *
gume 0:1f82672b8755 6 * File : bno055.c
gume 0:1f82672b8755 7 *
gume 0:1f82672b8755 8 * Date : 2016/03/14
gume 0:1f82672b8755 9 *
gume 0:1f82672b8755 10 * Revision : 2.0.3 $
gume 0:1f82672b8755 11 *
gume 0:1f82672b8755 12 * Usage: Sensor Driver file for BNO055 sensor
gume 0:1f82672b8755 13 *
gume 0:1f82672b8755 14 ****************************************************************************
gume 0:1f82672b8755 15 * \section License
gume 0:1f82672b8755 16 *
gume 0:1f82672b8755 17 * Redistribution and use in source and binary forms, with or without
gume 0:1f82672b8755 18 * modification, are permitted provided that the following conditions are met:
gume 0:1f82672b8755 19 *
gume 0:1f82672b8755 20 * Redistributions of source code must retain the above copyright
gume 0:1f82672b8755 21 * notice, this list of conditions and the following disclaimer.
gume 0:1f82672b8755 22 *
gume 0:1f82672b8755 23 * Redistributions in binary form must reproduce the above copyright
gume 0:1f82672b8755 24 * notice, this list of conditions and the following disclaimer in the
gume 0:1f82672b8755 25 * documentation and/or other materials provided with the distribution.
gume 0:1f82672b8755 26 *
gume 0:1f82672b8755 27 * Neither the name of the copyright holder nor the names of the
gume 0:1f82672b8755 28 * contributors may be used to endorse or promote products derived from
gume 0:1f82672b8755 29 * this software without specific prior written permission.
gume 0:1f82672b8755 30 *
gume 0:1f82672b8755 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
gume 0:1f82672b8755 32 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
gume 0:1f82672b8755 33 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
gume 0:1f82672b8755 34 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
gume 0:1f82672b8755 35 * DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
gume 0:1f82672b8755 36 * OR CONTRIBUTORS BE LIABLE FOR ANY
gume 0:1f82672b8755 37 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
gume 0:1f82672b8755 38 * OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO,
gume 0:1f82672b8755 39 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
gume 0:1f82672b8755 40 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
gume 0:1f82672b8755 41 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
gume 0:1f82672b8755 42 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
gume 0:1f82672b8755 43 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
gume 0:1f82672b8755 44 * ANY WAY OUT OF THE USE OF THIS
gume 0:1f82672b8755 45 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
gume 0:1f82672b8755 46 *
gume 0:1f82672b8755 47 * The information provided is believed to be accurate and reliable.
gume 0:1f82672b8755 48 * The copyright holder assumes no responsibility
gume 0:1f82672b8755 49 * for the consequences of use
gume 0:1f82672b8755 50 * of such information nor for any infringement of patents or
gume 0:1f82672b8755 51 * other rights of third parties which may result from its use.
gume 0:1f82672b8755 52 * No license is granted by implication or otherwise under any patent or
gume 0:1f82672b8755 53 * patent rights of the copyright holder.
gume 0:1f82672b8755 54 **************************************************************************/
gume 0:1f82672b8755 55
gume 0:1f82672b8755 56 /*********************************************************/
gume 0:1f82672b8755 57 /* INCLUDES */
gume 0:1f82672b8755 58 /*******************************************************/
gume 0:1f82672b8755 59 #include "BNO055.h"
gume 0:1f82672b8755 60 /*! file <BNO055 >
gume 0:1f82672b8755 61 brief <Sensor driver for BNO055> */
gume 0:1f82672b8755 62 /* STRUCTURE DEFINITIONS */
gume 0:1f82672b8755 63 /*static*/ struct bno055_t *p_bno055;
gume 0:1f82672b8755 64
gume 0:1f82672b8755 65 /* LOCAL FUNCTIONS */
gume 0:1f82672b8755 66 /*!
gume 0:1f82672b8755 67 * @brief
gume 0:1f82672b8755 68 * This API is used for initialize
gume 0:1f82672b8755 69 * bus read, bus write function pointers,device
gume 0:1f82672b8755 70 * address,accel revision id, gyro revision id
gume 0:1f82672b8755 71 * mag revision id, software revision id, boot loader
gume 0:1f82672b8755 72 * revision id and page id
gume 0:1f82672b8755 73 *
gume 0:1f82672b8755 74 * @param bno055 - structure pointer
gume 0:1f82672b8755 75 *
gume 0:1f82672b8755 76 *
gume 0:1f82672b8755 77 * @return results of bus communication function
gume 0:1f82672b8755 78 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 79 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 80 *
gume 0:1f82672b8755 81 * @note While changing the parameter of the bno055_t
gume 0:1f82672b8755 82 * consider the following point:
gume 0:1f82672b8755 83 * Changing the reference value of the parameter
gume 0:1f82672b8755 84 * will changes the local copy or local reference
gume 0:1f82672b8755 85 * make sure your changes will not
gume 0:1f82672b8755 86 * affect the reference value of the parameter
gume 0:1f82672b8755 87 * (Better case don't change the reference value of the parameter)
gume 0:1f82672b8755 88 */
gume 0:1f82672b8755 89 BNO055_RETURN_FUNCTION_TYPE bno055_init(struct bno055_t *bno055)
gume 0:1f82672b8755 90 {
gume 0:1f82672b8755 91 /* Variable used to return value of
gume 0:1f82672b8755 92 communication routine*/
gume 0:1f82672b8755 93 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 94 u8 data_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 95 u8 bno055_page_zero_u8 = BNO055_PAGE_ZERO;
gume 0:1f82672b8755 96 /* Array holding the Software revision id
gume 0:1f82672b8755 97 */
gume 0:1f82672b8755 98 u8 a_SW_ID_u8[BNO055_REV_ID_SIZE] = {
gume 0:1f82672b8755 99 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 100 /* stuct parameters are assign to bno055*/
gume 0:1f82672b8755 101 p_bno055 = bno055;
gume 0:1f82672b8755 102 /* Write the default page as zero*/
gume 0:1f82672b8755 103 com_rslt = p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 104 (p_bno055->dev_addr,
gume 0:1f82672b8755 105 BNO055_PAGE_ID_REG, &bno055_page_zero_u8, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 106 /* Read the chip id of the sensor from page
gume 0:1f82672b8755 107 zero 0x00 register*/
gume 0:1f82672b8755 108 com_rslt += p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 109 (p_bno055->dev_addr,
gume 0:1f82672b8755 110 BNO055_CHIP_ID_REG, &data_u8, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 111 p_bno055->chip_id = data_u8;
gume 0:1f82672b8755 112 /* Read the accel revision id from page
gume 0:1f82672b8755 113 zero 0x01 register*/
gume 0:1f82672b8755 114 com_rslt += p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 115 (p_bno055->dev_addr,
gume 0:1f82672b8755 116 BNO055_ACCEL_REV_ID_REG, &data_u8, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 117 p_bno055->accel_rev_id = data_u8;
gume 0:1f82672b8755 118 /* Read the mag revision id from page
gume 0:1f82672b8755 119 zero 0x02 register*/
gume 0:1f82672b8755 120 com_rslt += p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 121 (p_bno055->dev_addr,
gume 0:1f82672b8755 122 BNO055_MAG_REV_ID_REG, &data_u8, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 123 p_bno055->mag_rev_id = data_u8;
gume 0:1f82672b8755 124 /* Read the gyro revision id from page
gume 0:1f82672b8755 125 zero 0x02 register*/
gume 0:1f82672b8755 126 com_rslt += p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 127 (p_bno055->dev_addr,
gume 0:1f82672b8755 128 BNO055_GYRO_REV_ID_REG, &data_u8, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 129 p_bno055->gyro_rev_id = data_u8;
gume 0:1f82672b8755 130 /* Read the boot loader revision from page
gume 0:1f82672b8755 131 zero 0x06 register*/
gume 0:1f82672b8755 132 com_rslt += p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 133 (p_bno055->dev_addr,
gume 0:1f82672b8755 134 BNO055_BL_REV_ID_REG, &data_u8, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 135 p_bno055->bl_rev_id = data_u8;
gume 0:1f82672b8755 136 /* Read the software revision id from page
gume 0:1f82672b8755 137 zero 0x04 and 0x05 register( 2 bytes of data)*/
gume 0:1f82672b8755 138 com_rslt += p_bno055->BNO055_BUS_READ_FUNC(p_bno055->dev_addr,
gume 0:1f82672b8755 139 BNO055_SW_REV_ID_LSB_REG,
gume 0:1f82672b8755 140 a_SW_ID_u8, BNO055_LSB_MSB_READ_LENGTH);
gume 0:1f82672b8755 141 a_SW_ID_u8[BNO055_SW_ID_LSB] = BNO055_GET_BITSLICE(
gume 0:1f82672b8755 142 a_SW_ID_u8[BNO055_SW_ID_LSB],
gume 0:1f82672b8755 143 BNO055_SW_REV_ID_LSB);
gume 0:1f82672b8755 144 p_bno055->sw_rev_id = (u16)
gume 0:1f82672b8755 145 ((((u32)((u8)a_SW_ID_u8[BNO055_SW_ID_MSB])) <<
gume 0:1f82672b8755 146 BNO055_SHIFT_EIGHT_BITS) | (a_SW_ID_u8[BNO055_SW_ID_LSB]));
gume 0:1f82672b8755 147 /* Read the page id from the register 0x07*/
gume 0:1f82672b8755 148 com_rslt += p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 149 (p_bno055->dev_addr,
gume 0:1f82672b8755 150 BNO055_PAGE_ID_REG, &data_u8, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 151 p_bno055->page_id = data_u8;
gume 0:1f82672b8755 152
gume 0:1f82672b8755 153 return com_rslt;
gume 0:1f82672b8755 154 }
gume 0:1f82672b8755 155 /*!
gume 0:1f82672b8755 156 * @brief
gume 0:1f82672b8755 157 * This API gives data to the given register and
gume 0:1f82672b8755 158 * the data is written in the corresponding register address
gume 0:1f82672b8755 159 *
gume 0:1f82672b8755 160 * @param addr_u8 : Address of the register
gume 0:1f82672b8755 161 * @param data_u8 : Data to be written to the register
gume 0:1f82672b8755 162 * @param len_u8 : Length of the Data
gume 0:1f82672b8755 163 *
gume 0:1f82672b8755 164 * @return results of bus communication function
gume 0:1f82672b8755 165 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 166 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 167 *
gume 0:1f82672b8755 168 *
gume 0:1f82672b8755 169 */
gume 0:1f82672b8755 170 BNO055_RETURN_FUNCTION_TYPE bno055_write_register(u8 addr_u8,
gume 0:1f82672b8755 171 u8 *data_u8, u8 len_u8)
gume 0:1f82672b8755 172 {
gume 0:1f82672b8755 173 /* Variable used to return value of
gume 0:1f82672b8755 174 communication routine*/
gume 0:1f82672b8755 175 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 176 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 177 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 178 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 179 } else {
gume 0:1f82672b8755 180 /* Write the values of respective given register */
gume 0:1f82672b8755 181 com_rslt = p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 182 (p_bno055->dev_addr, addr_u8, data_u8, len_u8);
gume 0:1f82672b8755 183 }
gume 0:1f82672b8755 184 return com_rslt;
gume 0:1f82672b8755 185 }
gume 0:1f82672b8755 186 /*!
gume 0:1f82672b8755 187 * @brief This API reads the data from
gume 0:1f82672b8755 188 * the given register address
gume 0:1f82672b8755 189 *
gume 0:1f82672b8755 190 * @param addr_u8 : Address of the register
gume 0:1f82672b8755 191 * @param data_u8 : address of the variable,
gume 0:1f82672b8755 192 * read value will be kept
gume 0:1f82672b8755 193 * @param len_u8 : Length of the data
gume 0:1f82672b8755 194 *
gume 0:1f82672b8755 195 *
gume 0:1f82672b8755 196 * @return results of bus communication function
gume 0:1f82672b8755 197 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 198 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 199 *
gume 0:1f82672b8755 200 */
gume 0:1f82672b8755 201 BNO055_RETURN_FUNCTION_TYPE bno055_read_register(u8 addr_u8,
gume 0:1f82672b8755 202 u8 *data_u8, u8 len_u8)
gume 0:1f82672b8755 203 {
gume 0:1f82672b8755 204 /* Variable used to return value of
gume 0:1f82672b8755 205 communication routine*/
gume 0:1f82672b8755 206 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 207 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 208 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 209 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 210 } else {
gume 0:1f82672b8755 211 /* Read the value from given register*/
gume 0:1f82672b8755 212 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 213 (p_bno055->dev_addr, addr_u8, data_u8, len_u8);
gume 0:1f82672b8755 214 }
gume 0:1f82672b8755 215 return com_rslt;
gume 0:1f82672b8755 216 }
gume 0:1f82672b8755 217 /*!
gume 0:1f82672b8755 218 * @brief This API reads chip id
gume 0:1f82672b8755 219 * from register 0x00 it is a byte of data
gume 0:1f82672b8755 220 *
gume 0:1f82672b8755 221 *
gume 0:1f82672b8755 222 * @param chip_id_u8 : The chip id value 0xA0
gume 0:1f82672b8755 223 *
gume 0:1f82672b8755 224 * @return results of bus communication function
gume 0:1f82672b8755 225 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 226 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 227 */
gume 0:1f82672b8755 228 BNO055_RETURN_FUNCTION_TYPE bno055_read_chip_id(u8 *chip_id_u8)
gume 0:1f82672b8755 229 {
gume 0:1f82672b8755 230 /* Variable used to return value of
gume 0:1f82672b8755 231 communication routine*/
gume 0:1f82672b8755 232 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 233 u8 data_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 234 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 235 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 236 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 237 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 238 } else {
gume 0:1f82672b8755 239 /*condition check for page, chip id is
gume 0:1f82672b8755 240 available in the page zero*/
gume 0:1f82672b8755 241 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 242 /* Write the page zero*/
gume 0:1f82672b8755 243 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 244 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 245 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 246 /* Read the chip id*/
gume 0:1f82672b8755 247 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 248 (p_bno055->dev_addr,
gume 0:1f82672b8755 249 BNO055_CHIP_ID_REG, &data_u8,
gume 0:1f82672b8755 250 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 251 *chip_id_u8 = data_u8;
gume 0:1f82672b8755 252 } else {
gume 0:1f82672b8755 253 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 254 }
gume 0:1f82672b8755 255 }
gume 0:1f82672b8755 256 return com_rslt;
gume 0:1f82672b8755 257 }
gume 0:1f82672b8755 258 /*!
gume 0:1f82672b8755 259 * @brief This API reads software revision id
gume 0:1f82672b8755 260 * from register 0x04 and 0x05 it is a two byte of data
gume 0:1f82672b8755 261 *
gume 0:1f82672b8755 262 * @param sw_id_u8 : The SW revision id
gume 0:1f82672b8755 263 *
gume 0:1f82672b8755 264 * @return results of bus communication function
gume 0:1f82672b8755 265 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 266 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 267 *
gume 0:1f82672b8755 268 *
gume 0:1f82672b8755 269 */
gume 0:1f82672b8755 270 BNO055_RETURN_FUNCTION_TYPE bno055_read_sw_rev_id(u16 *sw_id_u8)
gume 0:1f82672b8755 271 {
gume 0:1f82672b8755 272 /* Variable used to return value of
gume 0:1f82672b8755 273 communication routine*/
gume 0:1f82672b8755 274 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 275 /* array having the software revision id
gume 0:1f82672b8755 276 data_u8[0] - LSB
gume 0:1f82672b8755 277 data_u8[1] - MSB*/
gume 0:1f82672b8755 278 u8 data_u8[BNO055_REV_ID_SIZE] = {BNO055_INIT_VALUE,
gume 0:1f82672b8755 279 BNO055_INIT_VALUE};
gume 0:1f82672b8755 280 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 281 /* Check the struct p_bno055 is empty*/
gume 0:1f82672b8755 282 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 283 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 284 } else {
gume 0:1f82672b8755 285 /*condition check for page, chip id is
gume 0:1f82672b8755 286 available in the page zero*/
gume 0:1f82672b8755 287 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 288 /* Write the page zero*/
gume 0:1f82672b8755 289 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 290 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 291 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 292 /* Read the two byte value of software
gume 0:1f82672b8755 293 revision id*/
gume 0:1f82672b8755 294 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 295 (p_bno055->dev_addr,
gume 0:1f82672b8755 296 BNO055_SW_REV_ID_LSB_REG,
gume 0:1f82672b8755 297 data_u8, BNO055_LSB_MSB_READ_LENGTH);
gume 0:1f82672b8755 298 data_u8[BNO055_SW_ID_LSB] =
gume 0:1f82672b8755 299 BNO055_GET_BITSLICE(data_u8[BNO055_SW_ID_LSB],
gume 0:1f82672b8755 300 BNO055_SW_REV_ID_LSB);
gume 0:1f82672b8755 301 *sw_id_u8 = (u16)
gume 0:1f82672b8755 302 ((((u32)((u8)data_u8[BNO055_SW_ID_MSB])) <<
gume 0:1f82672b8755 303 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 304 | (data_u8[BNO055_SW_ID_LSB]));
gume 0:1f82672b8755 305 } else {
gume 0:1f82672b8755 306 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 307 }
gume 0:1f82672b8755 308 }
gume 0:1f82672b8755 309 return com_rslt;
gume 0:1f82672b8755 310 }
gume 0:1f82672b8755 311 /*!
gume 0:1f82672b8755 312 * @brief This API reads page id
gume 0:1f82672b8755 313 * from register 0x07 it is a byte of data
gume 0:1f82672b8755 314 *
gume 0:1f82672b8755 315 *
gume 0:1f82672b8755 316 * @param page_id_u8 : The value of page id
gume 0:1f82672b8755 317 *
gume 0:1f82672b8755 318 * BNO055_PAGE_ZERO -> 0x00
gume 0:1f82672b8755 319 * BNO055_PAGE_ONE -> 0x01
gume 0:1f82672b8755 320 *
gume 0:1f82672b8755 321 * @return results of bus communication function
gume 0:1f82672b8755 322 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 323 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 324 *
gume 0:1f82672b8755 325 *
gume 0:1f82672b8755 326 */
gume 0:1f82672b8755 327 BNO055_RETURN_FUNCTION_TYPE bno055_read_page_id(u8 *page_id_u8)
gume 0:1f82672b8755 328 {
gume 0:1f82672b8755 329 /* Variable used to return value of
gume 0:1f82672b8755 330 communication routine*/
gume 0:1f82672b8755 331 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 332 u8 data_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 333 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 334 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 335 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 336 } else {
gume 0:1f82672b8755 337 /* Read the page id form 0x07*/
gume 0:1f82672b8755 338 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 339 (p_bno055->dev_addr,
gume 0:1f82672b8755 340 BNO055_PAGE_ID_REG, &data_u8, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 341 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 342 data_u8 = BNO055_GET_BITSLICE(data_u8,
gume 0:1f82672b8755 343 BNO055_PAGE_ID);
gume 0:1f82672b8755 344 *page_id_u8 = data_u8;
gume 0:1f82672b8755 345 p_bno055->page_id = data_u8;
gume 0:1f82672b8755 346 } else {
gume 0:1f82672b8755 347 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 348 }
gume 0:1f82672b8755 349 }
gume 0:1f82672b8755 350 return com_rslt;
gume 0:1f82672b8755 351 }
gume 0:1f82672b8755 352 /*!
gume 0:1f82672b8755 353 * @brief This API used to write
gume 0:1f82672b8755 354 * the page id register 0x07
gume 0:1f82672b8755 355 *
gume 0:1f82672b8755 356 * @param page_id_u8 : The value of page id
gume 0:1f82672b8755 357 *
gume 0:1f82672b8755 358 * BNO055_PAGE_ZERO -> 0x00
gume 0:1f82672b8755 359 * BNO055_PAGE_ONE -> 0x01
gume 0:1f82672b8755 360 *
gume 0:1f82672b8755 361 * @return results of bus communication function
gume 0:1f82672b8755 362 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 363 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 364 *
gume 0:1f82672b8755 365 *
gume 0:1f82672b8755 366 */
gume 0:1f82672b8755 367 BNO055_RETURN_FUNCTION_TYPE bno055_write_page_id(u8 page_id_u8)
gume 0:1f82672b8755 368 {
gume 0:1f82672b8755 369 /* Variable used to return value of
gume 0:1f82672b8755 370 communication routine*/
gume 0:1f82672b8755 371 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 372 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 373 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 374 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 375 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 376 } else {
gume 0:1f82672b8755 377 /* Read the current page*/
gume 0:1f82672b8755 378 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 379 (p_bno055->dev_addr,
gume 0:1f82672b8755 380 BNO055_PAGE_ID_REG, &data_u8r,
gume 0:1f82672b8755 381 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 382 /* Check condition for communication BNO055_SUCCESS*/
gume 0:1f82672b8755 383 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 384 data_u8r = BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 385 BNO055_PAGE_ID, page_id_u8);
gume 0:1f82672b8755 386 /* Write the page id*/
gume 0:1f82672b8755 387 com_rslt += p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 388 (p_bno055->dev_addr,
gume 0:1f82672b8755 389 BNO055_PAGE_ID_REG,
gume 0:1f82672b8755 390 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 391 if (com_rslt == BNO055_SUCCESS)
gume 0:1f82672b8755 392 p_bno055->page_id = page_id_u8;
gume 0:1f82672b8755 393 } else {
gume 0:1f82672b8755 394 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 395 }
gume 0:1f82672b8755 396 }
gume 0:1f82672b8755 397 return com_rslt;
gume 0:1f82672b8755 398 }
gume 0:1f82672b8755 399 /*!
gume 0:1f82672b8755 400 * @brief This API reads accel revision id
gume 0:1f82672b8755 401 * from register 0x01 it is a byte of value
gume 0:1f82672b8755 402 *
gume 0:1f82672b8755 403 * @param accel_rev_id_u8 : The accel revision id 0xFB
gume 0:1f82672b8755 404 *
gume 0:1f82672b8755 405 * @return results of bus communication function
gume 0:1f82672b8755 406 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 407 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 408 *
gume 0:1f82672b8755 409 *
gume 0:1f82672b8755 410 */
gume 0:1f82672b8755 411 BNO055_RETURN_FUNCTION_TYPE bno055_read_accel_rev_id(
gume 0:1f82672b8755 412 u8 *accel_rev_id_u8)
gume 0:1f82672b8755 413 {
gume 0:1f82672b8755 414 /* Variable used to return value of
gume 0:1f82672b8755 415 communication routine*/
gume 0:1f82672b8755 416 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 417 u8 data_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 418 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 419 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 420 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 421 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 422 } else {
gume 0:1f82672b8755 423 /*condition check for page, chip id is
gume 0:1f82672b8755 424 available in the page zero*/
gume 0:1f82672b8755 425 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 426 /* Write the page zero*/
gume 0:1f82672b8755 427 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 428 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 429 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 430 /* Read the accel revision id */
gume 0:1f82672b8755 431 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 432 (p_bno055->dev_addr,
gume 0:1f82672b8755 433 BNO055_ACCEL_REV_ID_REG,
gume 0:1f82672b8755 434 &data_u8, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 435 *accel_rev_id_u8 = data_u8;
gume 0:1f82672b8755 436 } else {
gume 0:1f82672b8755 437 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 438 }
gume 0:1f82672b8755 439 }
gume 0:1f82672b8755 440 return com_rslt;
gume 0:1f82672b8755 441 }
gume 0:1f82672b8755 442 /*!
gume 0:1f82672b8755 443 * @brief This API reads mag revision id
gume 0:1f82672b8755 444 * from register 0x02 it is a byte of value
gume 0:1f82672b8755 445 *
gume 0:1f82672b8755 446 * @param mag_rev_id_u8 : The mag revision id 0x32
gume 0:1f82672b8755 447 *
gume 0:1f82672b8755 448 * @return results of bus communication function
gume 0:1f82672b8755 449 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 450 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 451 *
gume 0:1f82672b8755 452 *
gume 0:1f82672b8755 453 */
gume 0:1f82672b8755 454 BNO055_RETURN_FUNCTION_TYPE bno055_read_mag_rev_id(
gume 0:1f82672b8755 455 u8 *mag_rev_id_u8)
gume 0:1f82672b8755 456 {
gume 0:1f82672b8755 457 /* Variable used to return value of
gume 0:1f82672b8755 458 communication routine*/
gume 0:1f82672b8755 459 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 460 u8 data_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 461 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 462 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 463 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 464 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 465 } else {
gume 0:1f82672b8755 466 /*condition check for page, chip id is
gume 0:1f82672b8755 467 available in the page zero*/
gume 0:1f82672b8755 468 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 469 /* Write the page zero*/
gume 0:1f82672b8755 470 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 471 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 472 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 473 /* Read the mag revision id */
gume 0:1f82672b8755 474 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 475 (p_bno055->dev_addr,
gume 0:1f82672b8755 476 BNO055_MAG_REV_ID_REG,
gume 0:1f82672b8755 477 &data_u8, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 478 *mag_rev_id_u8 = data_u8;
gume 0:1f82672b8755 479 } else {
gume 0:1f82672b8755 480 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 481 }
gume 0:1f82672b8755 482 }
gume 0:1f82672b8755 483 return com_rslt;
gume 0:1f82672b8755 484 }
gume 0:1f82672b8755 485 /*!
gume 0:1f82672b8755 486 * @brief This API reads gyro revision id
gume 0:1f82672b8755 487 * from register 0x03 it is a byte of value
gume 0:1f82672b8755 488 *
gume 0:1f82672b8755 489 * @param gyro_rev_id_u8 : The gyro revision id 0xF0
gume 0:1f82672b8755 490 *
gume 0:1f82672b8755 491 *
gume 0:1f82672b8755 492 *
gume 0:1f82672b8755 493 * @return results of bus communication function
gume 0:1f82672b8755 494 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 495 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 496 *
gume 0:1f82672b8755 497 *
gume 0:1f82672b8755 498 */
gume 0:1f82672b8755 499 BNO055_RETURN_FUNCTION_TYPE bno055_read_gyro_rev_id(
gume 0:1f82672b8755 500 u8 *gyro_rev_id_u8)
gume 0:1f82672b8755 501 {
gume 0:1f82672b8755 502 /* Variable used to return value of
gume 0:1f82672b8755 503 communication routine*/
gume 0:1f82672b8755 504 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 505 u8 data_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 506 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 507 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 508 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 509 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 510 } else {
gume 0:1f82672b8755 511 /*condition check for page, chip id is
gume 0:1f82672b8755 512 available in the page zero*/
gume 0:1f82672b8755 513 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 514 /* Write the page zero*/
gume 0:1f82672b8755 515 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 516 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 517 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 518 /* Read the gyro revision id */
gume 0:1f82672b8755 519 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 520 (p_bno055->dev_addr,
gume 0:1f82672b8755 521 BNO055_GYRO_REV_ID_REG,
gume 0:1f82672b8755 522 &data_u8, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 523 *gyro_rev_id_u8 = data_u8;
gume 0:1f82672b8755 524 } else {
gume 0:1f82672b8755 525 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 526 }
gume 0:1f82672b8755 527 }
gume 0:1f82672b8755 528 return com_rslt;
gume 0:1f82672b8755 529 }
gume 0:1f82672b8755 530 /*!
gume 0:1f82672b8755 531 * @brief This API used to read boot loader revision id
gume 0:1f82672b8755 532 * from register 0x06 it is a byte of value
gume 0:1f82672b8755 533 *
gume 0:1f82672b8755 534 * @param bl_rev_id_u8 : The boot loader revision id
gume 0:1f82672b8755 535 *
gume 0:1f82672b8755 536 *
gume 0:1f82672b8755 537 * @return results of bus communication function
gume 0:1f82672b8755 538 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 539 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 540 *
gume 0:1f82672b8755 541 *
gume 0:1f82672b8755 542 */
gume 0:1f82672b8755 543 BNO055_RETURN_FUNCTION_TYPE bno055_read_bl_rev_id(
gume 0:1f82672b8755 544 u8 *bl_rev_id_u8)
gume 0:1f82672b8755 545 {
gume 0:1f82672b8755 546 /* Variable used to return value of
gume 0:1f82672b8755 547 communication routine*/
gume 0:1f82672b8755 548 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 549 u8 data_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 550 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 551 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 552 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 553 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 554 } else {
gume 0:1f82672b8755 555 /*condition check for page, chip id is
gume 0:1f82672b8755 556 available in the page zero*/
gume 0:1f82672b8755 557 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 558 /* Write the page zero*/
gume 0:1f82672b8755 559 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 560 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 561 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 562 /* Read the boot loader revision id */
gume 0:1f82672b8755 563 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 564 (p_bno055->dev_addr,
gume 0:1f82672b8755 565 BNO055_BL_REV_ID_REG,
gume 0:1f82672b8755 566 &data_u8, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 567 *bl_rev_id_u8 = data_u8;
gume 0:1f82672b8755 568 } else {
gume 0:1f82672b8755 569 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 570 }
gume 0:1f82672b8755 571 }
gume 0:1f82672b8755 572 return com_rslt;
gume 0:1f82672b8755 573 }
gume 0:1f82672b8755 574 /*!
gume 0:1f82672b8755 575 * @brief This API reads acceleration data X values
gume 0:1f82672b8755 576 * from register 0x08 and 0x09 it is a two byte data
gume 0:1f82672b8755 577 *
gume 0:1f82672b8755 578 *
gume 0:1f82672b8755 579 *
gume 0:1f82672b8755 580 *
gume 0:1f82672b8755 581 * @param accel_x_s16 : The X raw data
gume 0:1f82672b8755 582 *
gume 0:1f82672b8755 583 *
gume 0:1f82672b8755 584 *
gume 0:1f82672b8755 585 * @return results of bus communication function
gume 0:1f82672b8755 586 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 587 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 588 *
gume 0:1f82672b8755 589 *
gume 0:1f82672b8755 590 */
gume 0:1f82672b8755 591 BNO055_RETURN_FUNCTION_TYPE bno055_read_accel_x(s16 *accel_x_s16)
gume 0:1f82672b8755 592 {
gume 0:1f82672b8755 593 /* Variable used to return value of
gume 0:1f82672b8755 594 communication routine*/
gume 0:1f82672b8755 595 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 596 /* Array holding the accel x value
gume 0:1f82672b8755 597 data_u8[BNO055_SENSOR_DATA_LSB] - x-LSB
gume 0:1f82672b8755 598 data_u8[BNO055_SENSOR_DATA_MSB] - x-MSB
gume 0:1f82672b8755 599 */
gume 0:1f82672b8755 600 u8 data_u8[BNO055_ACCEL_DATA_SIZE] = {BNO055_INIT_VALUE,
gume 0:1f82672b8755 601 BNO055_INIT_VALUE};
gume 0:1f82672b8755 602 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 603 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 604 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 605 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 606 } else {
gume 0:1f82672b8755 607 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 608 /* Write the page zero*/
gume 0:1f82672b8755 609 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 610 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 611 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 612 /* Read the accel x axis two byte value*/
gume 0:1f82672b8755 613 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 614 (p_bno055->dev_addr,
gume 0:1f82672b8755 615 BNO055_ACCEL_DATA_X_LSB_VALUEX_REG,
gume 0:1f82672b8755 616 data_u8, BNO055_LSB_MSB_READ_LENGTH);
gume 0:1f82672b8755 617 data_u8[BNO055_SENSOR_DATA_LSB] =
gume 0:1f82672b8755 618 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_LSB],
gume 0:1f82672b8755 619 BNO055_ACCEL_DATA_X_LSB_VALUEX);
gume 0:1f82672b8755 620 data_u8[BNO055_SENSOR_DATA_MSB] =
gume 0:1f82672b8755 621 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_MSB],
gume 0:1f82672b8755 622 BNO055_ACCEL_DATA_X_MSB_VALUEX);
gume 0:1f82672b8755 623 *accel_x_s16 = (s16)((((s32)
gume 0:1f82672b8755 624 (s8)(data_u8[BNO055_SENSOR_DATA_MSB])) <<
gume 0:1f82672b8755 625 (BNO055_SHIFT_EIGHT_BITS))
gume 0:1f82672b8755 626 | (data_u8[BNO055_SENSOR_DATA_LSB]));
gume 0:1f82672b8755 627 } else {
gume 0:1f82672b8755 628 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 629 }
gume 0:1f82672b8755 630 }
gume 0:1f82672b8755 631 return com_rslt;
gume 0:1f82672b8755 632 }
gume 0:1f82672b8755 633 /*!
gume 0:1f82672b8755 634 * @brief This API reads acceleration data Y values
gume 0:1f82672b8755 635 * from register 0x0A and 0x0B it is a two byte data
gume 0:1f82672b8755 636 *
gume 0:1f82672b8755 637 *
gume 0:1f82672b8755 638 *
gume 0:1f82672b8755 639 *
gume 0:1f82672b8755 640 * @param accel_y_s16 : The Y raw data
gume 0:1f82672b8755 641 *
gume 0:1f82672b8755 642 *
gume 0:1f82672b8755 643 *
gume 0:1f82672b8755 644 * @return results of bus communication function
gume 0:1f82672b8755 645 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 646 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 647 *
gume 0:1f82672b8755 648 *
gume 0:1f82672b8755 649 */
gume 0:1f82672b8755 650 BNO055_RETURN_FUNCTION_TYPE bno055_read_accel_y(s16 *accel_y_s16)
gume 0:1f82672b8755 651 {
gume 0:1f82672b8755 652 /* Variable used to return value of
gume 0:1f82672b8755 653 communication routine*/
gume 0:1f82672b8755 654 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 655 /* Array holding the accel y value
gume 0:1f82672b8755 656 data_u8[BNO055_SENSOR_DATA_LSB] - y-LSB
gume 0:1f82672b8755 657 data_u8[BNO055_SENSOR_DATA_MSB] - y-MSB
gume 0:1f82672b8755 658 */
gume 0:1f82672b8755 659 u8 data_u8[BNO055_ACCEL_DATA_SIZE] = {BNO055_INIT_VALUE,
gume 0:1f82672b8755 660 BNO055_INIT_VALUE};
gume 0:1f82672b8755 661 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 662 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 663 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 664 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 665 } else {
gume 0:1f82672b8755 666 /*condition check for page, chip id is
gume 0:1f82672b8755 667 available in the page zero*/
gume 0:1f82672b8755 668 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 669 /* Write the page zero*/
gume 0:1f82672b8755 670 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 671 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 672 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 673 /* Read the accel y axis two byte value*/
gume 0:1f82672b8755 674 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 675 (p_bno055->dev_addr,
gume 0:1f82672b8755 676 BNO055_ACCEL_DATA_Y_LSB_VALUEY_REG,
gume 0:1f82672b8755 677 data_u8, BNO055_LSB_MSB_READ_LENGTH);
gume 0:1f82672b8755 678 data_u8[BNO055_SENSOR_DATA_LSB] =
gume 0:1f82672b8755 679 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_LSB],
gume 0:1f82672b8755 680 BNO055_ACCEL_DATA_Y_LSB_VALUEY);
gume 0:1f82672b8755 681 data_u8[BNO055_SENSOR_DATA_MSB] =
gume 0:1f82672b8755 682 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_MSB],
gume 0:1f82672b8755 683 BNO055_ACCEL_DATA_Y_MSB_VALUEY);
gume 0:1f82672b8755 684 *accel_y_s16 = (s16)((((s32)
gume 0:1f82672b8755 685 ((s8)data_u8[BNO055_SENSOR_DATA_MSB])) <<
gume 0:1f82672b8755 686 BNO055_SHIFT_EIGHT_BITS) |
gume 0:1f82672b8755 687 (data_u8[BNO055_SENSOR_DATA_LSB]));
gume 0:1f82672b8755 688 } else {
gume 0:1f82672b8755 689 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 690 }
gume 0:1f82672b8755 691 }
gume 0:1f82672b8755 692 return com_rslt;
gume 0:1f82672b8755 693 }
gume 0:1f82672b8755 694 /*!
gume 0:1f82672b8755 695 * @brief This API reads acceleration data z values
gume 0:1f82672b8755 696 * from register 0x0C and 0x0D it is a two byte data
gume 0:1f82672b8755 697 *
gume 0:1f82672b8755 698 *
gume 0:1f82672b8755 699 *
gume 0:1f82672b8755 700 *
gume 0:1f82672b8755 701 * @param accel_z_s16 : The z raw data
gume 0:1f82672b8755 702 *
gume 0:1f82672b8755 703 *
gume 0:1f82672b8755 704 *
gume 0:1f82672b8755 705 * @return results of bus communication function
gume 0:1f82672b8755 706 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 707 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 708 *
gume 0:1f82672b8755 709 *
gume 0:1f82672b8755 710 */
gume 0:1f82672b8755 711 BNO055_RETURN_FUNCTION_TYPE bno055_read_accel_z(s16 *accel_z_s16)
gume 0:1f82672b8755 712 {
gume 0:1f82672b8755 713 /* Variable used to return value of
gume 0:1f82672b8755 714 communication routine*/
gume 0:1f82672b8755 715 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 716 /* Array holding the accel z value
gume 0:1f82672b8755 717 data_u8[BNO055_SENSOR_DATA_LSB] - z-LSB
gume 0:1f82672b8755 718 data_u8[BNO055_SENSOR_DATA_MSB] - z-MSB
gume 0:1f82672b8755 719 */
gume 0:1f82672b8755 720 u8 data_u8[BNO055_ACCEL_DATA_SIZE] = {BNO055_INIT_VALUE,
gume 0:1f82672b8755 721 BNO055_INIT_VALUE};
gume 0:1f82672b8755 722 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 723 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 724 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 725 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 726 } else {
gume 0:1f82672b8755 727 /*condition check for page, chip id is
gume 0:1f82672b8755 728 available in the page zero*/
gume 0:1f82672b8755 729 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 730 /* Write the page zero*/
gume 0:1f82672b8755 731 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 732 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 733 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 734 /* Read the accel z axis two byte value*/
gume 0:1f82672b8755 735 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 736 (p_bno055->dev_addr,
gume 0:1f82672b8755 737 BNO055_ACCEL_DATA_Z_LSB_VALUEZ_REG,
gume 0:1f82672b8755 738 data_u8, BNO055_LSB_MSB_READ_LENGTH);
gume 0:1f82672b8755 739 data_u8[BNO055_SENSOR_DATA_LSB] =
gume 0:1f82672b8755 740 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_LSB],
gume 0:1f82672b8755 741 BNO055_ACCEL_DATA_Z_LSB_VALUEZ);
gume 0:1f82672b8755 742 data_u8[BNO055_SENSOR_DATA_MSB] =
gume 0:1f82672b8755 743 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_MSB],
gume 0:1f82672b8755 744 BNO055_ACCEL_DATA_Z_MSB_VALUEZ);
gume 0:1f82672b8755 745 *accel_z_s16 = (s16)((((s32)
gume 0:1f82672b8755 746 ((s8)data_u8[BNO055_SENSOR_DATA_MSB])) <<
gume 0:1f82672b8755 747 BNO055_SHIFT_EIGHT_BITS) |
gume 0:1f82672b8755 748 (data_u8[BNO055_SENSOR_DATA_LSB]));
gume 0:1f82672b8755 749 } else {
gume 0:1f82672b8755 750 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 751 }
gume 0:1f82672b8755 752 }
gume 0:1f82672b8755 753 return com_rslt;
gume 0:1f82672b8755 754 }
gume 0:1f82672b8755 755 /*!
gume 0:1f82672b8755 756 * @brief This API reads acceleration data xyz values
gume 0:1f82672b8755 757 * from register 0x08 to 0x0D it is a six byte data
gume 0:1f82672b8755 758 *
gume 0:1f82672b8755 759 *
gume 0:1f82672b8755 760 * @param accel : The value of accel xyz data
gume 0:1f82672b8755 761 *
gume 0:1f82672b8755 762 * Parameter | result
gume 0:1f82672b8755 763 * --------- | -----------------
gume 0:1f82672b8755 764 * x | The accel x data
gume 0:1f82672b8755 765 * y | The accel y data
gume 0:1f82672b8755 766 * z | The accel z data
gume 0:1f82672b8755 767 *
gume 0:1f82672b8755 768 *
gume 0:1f82672b8755 769 *
gume 0:1f82672b8755 770 * @return results of bus communication function
gume 0:1f82672b8755 771 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 772 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 773 *
gume 0:1f82672b8755 774 */
gume 0:1f82672b8755 775 BNO055_RETURN_FUNCTION_TYPE bno055_read_accel_xyz(
gume 0:1f82672b8755 776 struct bno055_accel_t *accel)
gume 0:1f82672b8755 777 {
gume 0:1f82672b8755 778 /* Variable used to return value of
gume 0:1f82672b8755 779 communication routine*/
gume 0:1f82672b8755 780 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 781 /* Array holding the accel xyz value
gume 0:1f82672b8755 782 data_u8[BNO055_SENSOR_DATA_XYZ_X_LSB] - x->LSB
gume 0:1f82672b8755 783 data_u8[BNO055_SENSOR_DATA_XYZ_X_MSB] - x->MSB
gume 0:1f82672b8755 784 data_u8[BNO055_SENSOR_DATA_XYZ_Y_LSB] - y->MSB
gume 0:1f82672b8755 785 data_u8[BNO055_SENSOR_DATA_XYZ_Y_MSB] - y->MSB
gume 0:1f82672b8755 786 data_u8[BNO055_SENSOR_DATA_XYZ_Z_LSB] - z->MSB
gume 0:1f82672b8755 787 data_u8[BNO055_SENSOR_DATA_XYZ_Z_MSB] - z->MSB
gume 0:1f82672b8755 788 */
gume 0:1f82672b8755 789 u8 data_u8[BNO055_ACCEL_XYZ_DATA_SIZE] = {
gume 0:1f82672b8755 790 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 791 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 792 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 793 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 794 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 795 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 796 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 797 } else {
gume 0:1f82672b8755 798 /*condition check for page, chip id is
gume 0:1f82672b8755 799 available in the page zero*/
gume 0:1f82672b8755 800 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 801 /* Write the page zero*/
gume 0:1f82672b8755 802 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 803 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 804 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 805 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 806 (p_bno055->dev_addr,
gume 0:1f82672b8755 807 BNO055_ACCEL_DATA_X_LSB_VALUEX_REG,
gume 0:1f82672b8755 808 data_u8, BNO055_ACCEL_XYZ_DATA_SIZE);
gume 0:1f82672b8755 809 /* Data X*/
gume 0:1f82672b8755 810 data_u8[BNO055_SENSOR_DATA_XYZ_X_LSB] =
gume 0:1f82672b8755 811 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 812 data_u8[BNO055_SENSOR_DATA_XYZ_X_LSB],
gume 0:1f82672b8755 813 BNO055_ACCEL_DATA_X_LSB_VALUEX);
gume 0:1f82672b8755 814 data_u8[BNO055_SENSOR_DATA_XYZ_X_MSB] =
gume 0:1f82672b8755 815 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 816 data_u8[BNO055_SENSOR_DATA_XYZ_X_MSB],
gume 0:1f82672b8755 817 BNO055_ACCEL_DATA_X_MSB_VALUEX);
gume 0:1f82672b8755 818 accel->x = (s16)((((s32)
gume 0:1f82672b8755 819 ((s8)data_u8[BNO055_SENSOR_DATA_XYZ_X_MSB])) <<
gume 0:1f82672b8755 820 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 821 | (data_u8[BNO055_SENSOR_DATA_XYZ_X_LSB]));
gume 0:1f82672b8755 822 /* Data Y*/
gume 0:1f82672b8755 823 data_u8[BNO055_SENSOR_DATA_XYZ_Y_LSB] =
gume 0:1f82672b8755 824 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 825 data_u8[BNO055_SENSOR_DATA_XYZ_Y_LSB],
gume 0:1f82672b8755 826 BNO055_ACCEL_DATA_Y_LSB_VALUEY);
gume 0:1f82672b8755 827 data_u8[BNO055_SENSOR_DATA_XYZ_Y_MSB] =
gume 0:1f82672b8755 828 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 829 data_u8[BNO055_SENSOR_DATA_XYZ_Y_MSB],
gume 0:1f82672b8755 830 BNO055_ACCEL_DATA_Y_MSB_VALUEY);
gume 0:1f82672b8755 831 accel->y = (s16)((((s32)
gume 0:1f82672b8755 832 ((s8)data_u8[BNO055_SENSOR_DATA_XYZ_Y_MSB])) <<
gume 0:1f82672b8755 833 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 834 | (data_u8[BNO055_SENSOR_DATA_XYZ_Y_LSB]));
gume 0:1f82672b8755 835 /* Data Z*/
gume 0:1f82672b8755 836 data_u8[BNO055_SENSOR_DATA_XYZ_Z_LSB] =
gume 0:1f82672b8755 837 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 838 data_u8[BNO055_SENSOR_DATA_XYZ_Z_LSB],
gume 0:1f82672b8755 839 BNO055_ACCEL_DATA_Z_LSB_VALUEZ);
gume 0:1f82672b8755 840 data_u8[BNO055_SENSOR_DATA_XYZ_Z_MSB] =
gume 0:1f82672b8755 841 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 842 data_u8[BNO055_SENSOR_DATA_XYZ_Z_MSB],
gume 0:1f82672b8755 843 BNO055_ACCEL_DATA_Z_MSB_VALUEZ);
gume 0:1f82672b8755 844 accel->z = (s16)((((s32)
gume 0:1f82672b8755 845 ((s8)data_u8[BNO055_SENSOR_DATA_XYZ_Z_MSB])) <<
gume 0:1f82672b8755 846 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 847 | (data_u8[BNO055_SENSOR_DATA_XYZ_Z_LSB]));
gume 0:1f82672b8755 848 } else {
gume 0:1f82672b8755 849 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 850 }
gume 0:1f82672b8755 851 }
gume 0:1f82672b8755 852 return com_rslt;
gume 0:1f82672b8755 853 }
gume 0:1f82672b8755 854 /*!
gume 0:1f82672b8755 855 * @brief This API reads mag data x values
gume 0:1f82672b8755 856 * from register 0x0E and 0x0F it is a two byte data
gume 0:1f82672b8755 857 *
gume 0:1f82672b8755 858 *
gume 0:1f82672b8755 859 *
gume 0:1f82672b8755 860 *
gume 0:1f82672b8755 861 * @param mag_x_s16 : The x raw data
gume 0:1f82672b8755 862 *
gume 0:1f82672b8755 863 *
gume 0:1f82672b8755 864 *
gume 0:1f82672b8755 865 * @return results of bus communication function
gume 0:1f82672b8755 866 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 867 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 868 *
gume 0:1f82672b8755 869 *
gume 0:1f82672b8755 870 *
gume 0:1f82672b8755 871 */
gume 0:1f82672b8755 872 BNO055_RETURN_FUNCTION_TYPE bno055_read_mag_x(s16 *mag_x_s16)
gume 0:1f82672b8755 873 {
gume 0:1f82672b8755 874 /* Variable used to return value of
gume 0:1f82672b8755 875 communication routine*/
gume 0:1f82672b8755 876 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 877 /* Array holding the mag x value
gume 0:1f82672b8755 878 data_u8[BNO055_SENSOR_DATA_LSB] - x->LSB
gume 0:1f82672b8755 879 data_u8[BNO055_SENSOR_DATA_MSB] - x->MSB
gume 0:1f82672b8755 880 */
gume 0:1f82672b8755 881 u8 data_u8[BNO055_MAG_DATA_SIZE] = {BNO055_INIT_VALUE,
gume 0:1f82672b8755 882 BNO055_INIT_VALUE};
gume 0:1f82672b8755 883 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 884 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 885 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 886 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 887 } else {
gume 0:1f82672b8755 888 /*condition check for page, chip id is
gume 0:1f82672b8755 889 available in the page zero*/
gume 0:1f82672b8755 890 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 891 /* Write the page zero*/
gume 0:1f82672b8755 892 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 893 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 894 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 895 /*Read the mag x two bytes of data */
gume 0:1f82672b8755 896 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 897 (p_bno055->dev_addr,
gume 0:1f82672b8755 898 BNO055_MAG_DATA_X_LSB_VALUEX_REG,
gume 0:1f82672b8755 899 data_u8, BNO055_LSB_MSB_READ_LENGTH);
gume 0:1f82672b8755 900 data_u8[BNO055_SENSOR_DATA_LSB] =
gume 0:1f82672b8755 901 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_LSB],
gume 0:1f82672b8755 902 BNO055_MAG_DATA_X_LSB_VALUEX);
gume 0:1f82672b8755 903 data_u8[BNO055_SENSOR_DATA_MSB] =
gume 0:1f82672b8755 904 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_MSB],
gume 0:1f82672b8755 905 BNO055_MAG_DATA_X_MSB_VALUEX);
gume 0:1f82672b8755 906 *mag_x_s16 = (s16)((((s32)
gume 0:1f82672b8755 907 ((s8)data_u8[BNO055_SENSOR_DATA_MSB])) <<
gume 0:1f82672b8755 908 BNO055_SHIFT_EIGHT_BITS) | (
gume 0:1f82672b8755 909 data_u8[BNO055_SENSOR_DATA_LSB]));
gume 0:1f82672b8755 910 } else {
gume 0:1f82672b8755 911 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 912 }
gume 0:1f82672b8755 913 }
gume 0:1f82672b8755 914 return com_rslt;
gume 0:1f82672b8755 915 }
gume 0:1f82672b8755 916 /*!
gume 0:1f82672b8755 917 * @brief This API reads mag data y values
gume 0:1f82672b8755 918 * from register 0x10 and 0x11 it is a two byte data
gume 0:1f82672b8755 919 *
gume 0:1f82672b8755 920 *
gume 0:1f82672b8755 921 *
gume 0:1f82672b8755 922 *
gume 0:1f82672b8755 923 * @param mag_y_s16 : The y raw data
gume 0:1f82672b8755 924 *
gume 0:1f82672b8755 925 *
gume 0:1f82672b8755 926 *
gume 0:1f82672b8755 927 * @return results of bus communication function
gume 0:1f82672b8755 928 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 929 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 930 *
gume 0:1f82672b8755 931 *
gume 0:1f82672b8755 932 */
gume 0:1f82672b8755 933 BNO055_RETURN_FUNCTION_TYPE bno055_read_mag_y(s16 *mag_y_s16)
gume 0:1f82672b8755 934 {
gume 0:1f82672b8755 935 /* Variable used to return value of
gume 0:1f82672b8755 936 communication routine*/
gume 0:1f82672b8755 937 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 938 /* Array holding the mag y value
gume 0:1f82672b8755 939 data_u8[BNO055_SENSOR_DATA_LSB] - y->LSB
gume 0:1f82672b8755 940 data_u8[BNO055_SENSOR_DATA_MSB] - y->MSB
gume 0:1f82672b8755 941 */
gume 0:1f82672b8755 942 u8 data_u8[BNO055_MAG_DATA_SIZE] = {
gume 0:1f82672b8755 943 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 944 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 945 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 946 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 947 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 948 } else {
gume 0:1f82672b8755 949 /*condition check for page, chip id is
gume 0:1f82672b8755 950 available in the page zero*/
gume 0:1f82672b8755 951 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 952 /* Write the page zero*/
gume 0:1f82672b8755 953 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 954 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 955 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 956 /*Read the mag y two bytes of data */
gume 0:1f82672b8755 957 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 958 (p_bno055->dev_addr,
gume 0:1f82672b8755 959 BNO055_MAG_DATA_Y_LSB_VALUEY_REG,
gume 0:1f82672b8755 960 data_u8, BNO055_LSB_MSB_READ_LENGTH);
gume 0:1f82672b8755 961 data_u8[BNO055_SENSOR_DATA_LSB] =
gume 0:1f82672b8755 962 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_LSB],
gume 0:1f82672b8755 963 BNO055_MAG_DATA_Y_LSB_VALUEY);
gume 0:1f82672b8755 964 data_u8[BNO055_SENSOR_DATA_MSB] =
gume 0:1f82672b8755 965 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_MSB],
gume 0:1f82672b8755 966 BNO055_MAG_DATA_Y_MSB_VALUEY);
gume 0:1f82672b8755 967 *mag_y_s16 = (s16)((((s32)
gume 0:1f82672b8755 968 ((s8)data_u8[BNO055_SENSOR_DATA_MSB])) <<
gume 0:1f82672b8755 969 BNO055_SHIFT_EIGHT_BITS) |
gume 0:1f82672b8755 970 (data_u8[BNO055_SENSOR_DATA_LSB]));
gume 0:1f82672b8755 971 } else {
gume 0:1f82672b8755 972 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 973 }
gume 0:1f82672b8755 974 }
gume 0:1f82672b8755 975 return com_rslt;
gume 0:1f82672b8755 976 }
gume 0:1f82672b8755 977 /*!
gume 0:1f82672b8755 978 * @brief This API reads mag data z values
gume 0:1f82672b8755 979 * from register 0x12 and 0x13 it is a two byte data
gume 0:1f82672b8755 980 *
gume 0:1f82672b8755 981 *
gume 0:1f82672b8755 982 *
gume 0:1f82672b8755 983 *
gume 0:1f82672b8755 984 * @param mag_z_s16 : The z raw data
gume 0:1f82672b8755 985 *
gume 0:1f82672b8755 986 *
gume 0:1f82672b8755 987 *
gume 0:1f82672b8755 988 * @return results of bus communication function
gume 0:1f82672b8755 989 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 990 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 991 *
gume 0:1f82672b8755 992 *
gume 0:1f82672b8755 993 *
gume 0:1f82672b8755 994 */
gume 0:1f82672b8755 995 BNO055_RETURN_FUNCTION_TYPE bno055_read_mag_z(s16 *mag_z_s16)
gume 0:1f82672b8755 996 {
gume 0:1f82672b8755 997 /* Variable used to return value of
gume 0:1f82672b8755 998 communication routine*/
gume 0:1f82672b8755 999 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1000 /* Array holding the mag z value
gume 0:1f82672b8755 1001 data_u8[BNO055_SENSOR_DATA_LSB] - z->LSB
gume 0:1f82672b8755 1002 data_u8[BNO055_SENSOR_DATA_MSB] - z->MSB
gume 0:1f82672b8755 1003 */
gume 0:1f82672b8755 1004 u8 data_u8[BNO055_MAG_DATA_SIZE] = {
gume 0:1f82672b8755 1005 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 1006 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 1007 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 1008 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 1009 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 1010 } else {
gume 0:1f82672b8755 1011 /*condition check for page, chip id is
gume 0:1f82672b8755 1012 available in the page zero*/
gume 0:1f82672b8755 1013 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 1014 /* Write the page zero*/
gume 0:1f82672b8755 1015 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 1016 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 1017 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 1018 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 1019 (p_bno055->dev_addr,
gume 0:1f82672b8755 1020 BNO055_MAG_DATA_Z_LSB_VALUEZ_REG,
gume 0:1f82672b8755 1021 data_u8, BNO055_LSB_MSB_READ_LENGTH);
gume 0:1f82672b8755 1022 /*Read the mag z two bytes of data */
gume 0:1f82672b8755 1023 data_u8[BNO055_SENSOR_DATA_LSB] =
gume 0:1f82672b8755 1024 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_LSB],
gume 0:1f82672b8755 1025 BNO055_MAG_DATA_Z_LSB_VALUEZ);
gume 0:1f82672b8755 1026 data_u8[BNO055_SENSOR_DATA_MSB] =
gume 0:1f82672b8755 1027 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_MSB],
gume 0:1f82672b8755 1028 BNO055_MAG_DATA_Z_MSB_VALUEZ);
gume 0:1f82672b8755 1029 *mag_z_s16 = (s16)((((s32)
gume 0:1f82672b8755 1030 ((s8)data_u8[BNO055_SENSOR_DATA_MSB])) <<
gume 0:1f82672b8755 1031 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 1032 | (data_u8[BNO055_SENSOR_DATA_LSB]));
gume 0:1f82672b8755 1033 } else {
gume 0:1f82672b8755 1034 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1035 }
gume 0:1f82672b8755 1036 }
gume 0:1f82672b8755 1037 return com_rslt;
gume 0:1f82672b8755 1038 }
gume 0:1f82672b8755 1039 /*!
gume 0:1f82672b8755 1040 * @brief This API reads mag data xyz values
gume 0:1f82672b8755 1041 * from register 0x0E to 0x13 it is a six byte data
gume 0:1f82672b8755 1042 *
gume 0:1f82672b8755 1043 *
gume 0:1f82672b8755 1044 * @param mag : The mag xyz values
gume 0:1f82672b8755 1045 *
gume 0:1f82672b8755 1046 * Parameter | result
gume 0:1f82672b8755 1047 * --------- | -----------------
gume 0:1f82672b8755 1048 * x | The mag x data
gume 0:1f82672b8755 1049 * y | The mag y data
gume 0:1f82672b8755 1050 * z | The mag z data
gume 0:1f82672b8755 1051 *
gume 0:1f82672b8755 1052 *
gume 0:1f82672b8755 1053 *
gume 0:1f82672b8755 1054 * @return results of bus communication function
gume 0:1f82672b8755 1055 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 1056 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 1057 *
gume 0:1f82672b8755 1058 */
gume 0:1f82672b8755 1059 BNO055_RETURN_FUNCTION_TYPE bno055_read_mag_xyz(struct bno055_mag_t *mag)
gume 0:1f82672b8755 1060 {
gume 0:1f82672b8755 1061 /* Variable used to return value of
gume 0:1f82672b8755 1062 communication routine*/
gume 0:1f82672b8755 1063 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1064 /* Array holding the mag xyz value
gume 0:1f82672b8755 1065 data_u8[BNO055_SENSOR_DATA_XYZ_X_LSB] - x->LSB
gume 0:1f82672b8755 1066 data_u8[BNO055_SENSOR_DATA_XYZ_X_MSB] - x->MSB
gume 0:1f82672b8755 1067 data_u8[BNO055_SENSOR_DATA_XYZ_Y_LSB] - y->MSB
gume 0:1f82672b8755 1068 data_u8[BNO055_SENSOR_DATA_XYZ_Y_MSB] - y->MSB
gume 0:1f82672b8755 1069 data_u8[BNO055_SENSOR_DATA_XYZ_Z_LSB] - z->MSB
gume 0:1f82672b8755 1070 data_u8[BNO055_SENSOR_DATA_XYZ_Z_MSB] - z->MSB
gume 0:1f82672b8755 1071 */
gume 0:1f82672b8755 1072 u8 data_u8[BNO055_MAG_XYZ_DATA_SIZE] = {
gume 0:1f82672b8755 1073 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 1074 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 1075 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 1076 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 1077 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 1078 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 1079 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 1080 } else {
gume 0:1f82672b8755 1081 /*condition check for page, chip id is
gume 0:1f82672b8755 1082 available in the page zero*/
gume 0:1f82672b8755 1083 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 1084 /* Write the page zero*/
gume 0:1f82672b8755 1085 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 1086 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 1087 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 1088 /*Read the six byte value of mag xyz*/
gume 0:1f82672b8755 1089 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 1090 (p_bno055->dev_addr,
gume 0:1f82672b8755 1091 BNO055_MAG_DATA_X_LSB_VALUEX_REG,
gume 0:1f82672b8755 1092 data_u8, BNO055_MAG_XYZ_DATA_SIZE);
gume 0:1f82672b8755 1093 /* Data X*/
gume 0:1f82672b8755 1094 data_u8[BNO055_SENSOR_DATA_XYZ_X_LSB] =
gume 0:1f82672b8755 1095 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1096 data_u8[BNO055_SENSOR_DATA_XYZ_X_LSB],
gume 0:1f82672b8755 1097 BNO055_MAG_DATA_X_LSB_VALUEX);
gume 0:1f82672b8755 1098 data_u8[BNO055_SENSOR_DATA_XYZ_X_MSB] =
gume 0:1f82672b8755 1099 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1100 data_u8[BNO055_SENSOR_DATA_XYZ_X_MSB],
gume 0:1f82672b8755 1101 BNO055_MAG_DATA_X_MSB_VALUEX);
gume 0:1f82672b8755 1102 mag->x = (s16)((((s32)
gume 0:1f82672b8755 1103 ((s8)data_u8[BNO055_SENSOR_DATA_XYZ_X_MSB])) <<
gume 0:1f82672b8755 1104 BNO055_SHIFT_EIGHT_BITS) |
gume 0:1f82672b8755 1105 (data_u8[BNO055_SENSOR_DATA_XYZ_X_LSB]));
gume 0:1f82672b8755 1106 /* Data Y*/
gume 0:1f82672b8755 1107 data_u8[BNO055_SENSOR_DATA_XYZ_Y_LSB] =
gume 0:1f82672b8755 1108 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1109 data_u8[BNO055_SENSOR_DATA_XYZ_Y_LSB],
gume 0:1f82672b8755 1110 BNO055_MAG_DATA_Y_LSB_VALUEY);
gume 0:1f82672b8755 1111 data_u8[BNO055_SENSOR_DATA_XYZ_Y_MSB] =
gume 0:1f82672b8755 1112 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1113 data_u8[BNO055_SENSOR_DATA_XYZ_Y_MSB],
gume 0:1f82672b8755 1114 BNO055_MAG_DATA_Y_MSB_VALUEY);
gume 0:1f82672b8755 1115 mag->y = (s16)((((s32)
gume 0:1f82672b8755 1116 ((s8)data_u8[BNO055_SENSOR_DATA_XYZ_Y_MSB])) <<
gume 0:1f82672b8755 1117 BNO055_SHIFT_EIGHT_BITS) |
gume 0:1f82672b8755 1118 (data_u8[BNO055_SENSOR_DATA_XYZ_Y_LSB]));
gume 0:1f82672b8755 1119 /* Data Z*/
gume 0:1f82672b8755 1120 data_u8[BNO055_SENSOR_DATA_XYZ_Z_LSB] =
gume 0:1f82672b8755 1121 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1122 data_u8[BNO055_SENSOR_DATA_XYZ_Z_LSB],
gume 0:1f82672b8755 1123 BNO055_MAG_DATA_Z_LSB_VALUEZ);
gume 0:1f82672b8755 1124 data_u8[BNO055_SENSOR_DATA_XYZ_Z_MSB] =
gume 0:1f82672b8755 1125 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1126 data_u8[BNO055_SENSOR_DATA_XYZ_Z_MSB],
gume 0:1f82672b8755 1127 BNO055_MAG_DATA_Z_MSB_VALUEZ);
gume 0:1f82672b8755 1128 mag->z = (s16)((((s32)
gume 0:1f82672b8755 1129 ((s8)data_u8[BNO055_SENSOR_DATA_XYZ_Z_MSB])) <<
gume 0:1f82672b8755 1130 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 1131 | (data_u8[BNO055_SENSOR_DATA_XYZ_Z_LSB]));
gume 0:1f82672b8755 1132 } else {
gume 0:1f82672b8755 1133 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1134 }
gume 0:1f82672b8755 1135 }
gume 0:1f82672b8755 1136 return com_rslt;
gume 0:1f82672b8755 1137 }
gume 0:1f82672b8755 1138 /*!
gume 0:1f82672b8755 1139 * @brief This API reads gyro data x values
gume 0:1f82672b8755 1140 * from register 0x14 and 0x15 it is a two byte data
gume 0:1f82672b8755 1141 *
gume 0:1f82672b8755 1142 *
gume 0:1f82672b8755 1143 *
gume 0:1f82672b8755 1144 *
gume 0:1f82672b8755 1145 * @param gyro_x_s16 : The x raw data
gume 0:1f82672b8755 1146 *
gume 0:1f82672b8755 1147 *
gume 0:1f82672b8755 1148 *
gume 0:1f82672b8755 1149 * @return results of bus communication function
gume 0:1f82672b8755 1150 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 1151 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 1152 *
gume 0:1f82672b8755 1153 *
gume 0:1f82672b8755 1154 */
gume 0:1f82672b8755 1155 BNO055_RETURN_FUNCTION_TYPE bno055_read_gyro_x(s16 *gyro_x_s16)
gume 0:1f82672b8755 1156 {
gume 0:1f82672b8755 1157 /* Variable used to return value of
gume 0:1f82672b8755 1158 communication routine*/
gume 0:1f82672b8755 1159 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1160 u8 data_u8[BNO055_GYRO_DATA_SIZE] = {
gume 0:1f82672b8755 1161 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 1162 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 1163 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 1164 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 1165 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 1166 } else {
gume 0:1f82672b8755 1167 /*condition check for page, chip id is
gume 0:1f82672b8755 1168 available in the page zero*/
gume 0:1f82672b8755 1169 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 1170 /* Write the page zero*/
gume 0:1f82672b8755 1171 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 1172 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 1173 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 1174 /* Read the gyro 16 bit x value*/
gume 0:1f82672b8755 1175 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 1176 (p_bno055->dev_addr,
gume 0:1f82672b8755 1177 BNO055_GYRO_DATA_X_LSB_VALUEX_REG,
gume 0:1f82672b8755 1178 data_u8, BNO055_LSB_MSB_READ_LENGTH);
gume 0:1f82672b8755 1179 data_u8[BNO055_SENSOR_DATA_LSB] =
gume 0:1f82672b8755 1180 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_LSB],
gume 0:1f82672b8755 1181 BNO055_GYRO_DATA_X_LSB_VALUEX);
gume 0:1f82672b8755 1182 data_u8[BNO055_SENSOR_DATA_MSB] =
gume 0:1f82672b8755 1183 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_MSB],
gume 0:1f82672b8755 1184 BNO055_GYRO_DATA_X_MSB_VALUEX);
gume 0:1f82672b8755 1185 *gyro_x_s16 = (s16)((((s32)
gume 0:1f82672b8755 1186 ((s8)data_u8[BNO055_SENSOR_DATA_MSB])) <<
gume 0:1f82672b8755 1187 BNO055_SHIFT_EIGHT_BITS) |
gume 0:1f82672b8755 1188 (data_u8[BNO055_SENSOR_DATA_LSB]));
gume 0:1f82672b8755 1189 } else {
gume 0:1f82672b8755 1190 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1191 }
gume 0:1f82672b8755 1192 }
gume 0:1f82672b8755 1193 return com_rslt;
gume 0:1f82672b8755 1194 }
gume 0:1f82672b8755 1195 /*!
gume 0:1f82672b8755 1196 * @brief This API reads gyro data y values
gume 0:1f82672b8755 1197 * from register 0x16 and 0x17 it is a two byte data
gume 0:1f82672b8755 1198 *
gume 0:1f82672b8755 1199 *
gume 0:1f82672b8755 1200 *
gume 0:1f82672b8755 1201 *
gume 0:1f82672b8755 1202 * @param gyro_y_s16 : The y raw data
gume 0:1f82672b8755 1203 *
gume 0:1f82672b8755 1204 *
gume 0:1f82672b8755 1205 *
gume 0:1f82672b8755 1206 * @return results of bus communication function
gume 0:1f82672b8755 1207 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 1208 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 1209 *
gume 0:1f82672b8755 1210 *
gume 0:1f82672b8755 1211 */
gume 0:1f82672b8755 1212 BNO055_RETURN_FUNCTION_TYPE bno055_read_gyro_y(s16 *gyro_y_s16)
gume 0:1f82672b8755 1213 {
gume 0:1f82672b8755 1214 /* Variable used to return value of
gume 0:1f82672b8755 1215 communication routine*/
gume 0:1f82672b8755 1216 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1217 u8 data_u8[BNO055_GYRO_DATA_SIZE] = {
gume 0:1f82672b8755 1218 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 1219 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 1220 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 1221 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 1222 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 1223 } else {
gume 0:1f82672b8755 1224 /*condition check for page, chip id is
gume 0:1f82672b8755 1225 available in the page zero*/
gume 0:1f82672b8755 1226 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 1227 /* Write the page zero*/
gume 0:1f82672b8755 1228 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 1229 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 1230 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 1231 /* Read the value of gyro y */
gume 0:1f82672b8755 1232 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 1233 (p_bno055->dev_addr,
gume 0:1f82672b8755 1234 BNO055_GYRO_DATA_Y_LSB_VALUEY_REG,
gume 0:1f82672b8755 1235 data_u8, BNO055_LSB_MSB_READ_LENGTH);
gume 0:1f82672b8755 1236 data_u8[BNO055_SENSOR_DATA_LSB] =
gume 0:1f82672b8755 1237 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_LSB],
gume 0:1f82672b8755 1238 BNO055_GYRO_DATA_Y_LSB_VALUEY);
gume 0:1f82672b8755 1239 data_u8[BNO055_SENSOR_DATA_MSB] =
gume 0:1f82672b8755 1240 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_MSB],
gume 0:1f82672b8755 1241 BNO055_GYRO_DATA_Y_MSB_VALUEY);
gume 0:1f82672b8755 1242 *gyro_y_s16 = (s16)((((s32)
gume 0:1f82672b8755 1243 ((s8)data_u8[BNO055_SENSOR_DATA_MSB])) <<
gume 0:1f82672b8755 1244 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 1245 | (data_u8[BNO055_SENSOR_DATA_LSB]));
gume 0:1f82672b8755 1246 } else {
gume 0:1f82672b8755 1247 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1248 }
gume 0:1f82672b8755 1249 }
gume 0:1f82672b8755 1250 return com_rslt;
gume 0:1f82672b8755 1251 }
gume 0:1f82672b8755 1252 /*!
gume 0:1f82672b8755 1253 * @brief This API reads gyro data z values
gume 0:1f82672b8755 1254 * from register 0x18 and 0x19 it is a two byte data
gume 0:1f82672b8755 1255 *
gume 0:1f82672b8755 1256 * @param gyro_z_s16 : The z raw data
gume 0:1f82672b8755 1257 *
gume 0:1f82672b8755 1258 * @return results of bus communication function
gume 0:1f82672b8755 1259 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 1260 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 1261 *
gume 0:1f82672b8755 1262 *
gume 0:1f82672b8755 1263 */
gume 0:1f82672b8755 1264 BNO055_RETURN_FUNCTION_TYPE bno055_read_gyro_z(s16 *gyro_z_s16)
gume 0:1f82672b8755 1265 {
gume 0:1f82672b8755 1266 /* Variable used to return value of
gume 0:1f82672b8755 1267 communication routine*/
gume 0:1f82672b8755 1268 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1269 u8 data_u8[BNO055_GYRO_DATA_SIZE] = {
gume 0:1f82672b8755 1270 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 1271 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 1272 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 1273 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 1274 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 1275 } else {
gume 0:1f82672b8755 1276 /*condition check for page, chip id is
gume 0:1f82672b8755 1277 available in the page zero*/
gume 0:1f82672b8755 1278 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 1279 /* Write the page zero*/
gume 0:1f82672b8755 1280 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 1281 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 1282 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 1283 /* Read the gyro z 16 bit value*/
gume 0:1f82672b8755 1284 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 1285 (p_bno055->dev_addr,
gume 0:1f82672b8755 1286 BNO055_GYRO_DATA_Z_LSB_VALUEZ_REG,
gume 0:1f82672b8755 1287 data_u8, BNO055_LSB_MSB_READ_LENGTH);
gume 0:1f82672b8755 1288 data_u8[BNO055_SENSOR_DATA_LSB] =
gume 0:1f82672b8755 1289 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_LSB],
gume 0:1f82672b8755 1290 BNO055_GYRO_DATA_Z_LSB_VALUEZ);
gume 0:1f82672b8755 1291 data_u8[BNO055_SENSOR_DATA_MSB] =
gume 0:1f82672b8755 1292 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_MSB],
gume 0:1f82672b8755 1293 BNO055_GYRO_DATA_Z_MSB_VALUEZ);
gume 0:1f82672b8755 1294 *gyro_z_s16 = (s16)((((s32)
gume 0:1f82672b8755 1295 ((s8)data_u8[BNO055_SENSOR_DATA_MSB])) <<
gume 0:1f82672b8755 1296 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 1297 | (data_u8[BNO055_SENSOR_DATA_LSB]));
gume 0:1f82672b8755 1298 } else {
gume 0:1f82672b8755 1299 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1300 }
gume 0:1f82672b8755 1301 }
gume 0:1f82672b8755 1302 return com_rslt;
gume 0:1f82672b8755 1303 }
gume 0:1f82672b8755 1304 /*!
gume 0:1f82672b8755 1305 * @brief This API reads gyro data xyz values
gume 0:1f82672b8755 1306 * from register 0x14 to 0x19 it is a six byte data
gume 0:1f82672b8755 1307 *
gume 0:1f82672b8755 1308 *
gume 0:1f82672b8755 1309 * @param gyro : The value of gyro xyz data's
gume 0:1f82672b8755 1310 *
gume 0:1f82672b8755 1311 * Parameter | result
gume 0:1f82672b8755 1312 * --------- | -----------------
gume 0:1f82672b8755 1313 * x | The gyro x data
gume 0:1f82672b8755 1314 * y | The gyro y data
gume 0:1f82672b8755 1315 * z | The gyro z data
gume 0:1f82672b8755 1316 *
gume 0:1f82672b8755 1317 *
gume 0:1f82672b8755 1318 *
gume 0:1f82672b8755 1319 * @return results of bus communication function
gume 0:1f82672b8755 1320 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 1321 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 1322 *
gume 0:1f82672b8755 1323 */
gume 0:1f82672b8755 1324 BNO055_RETURN_FUNCTION_TYPE bno055_read_gyro_xyz(struct bno055_gyro_t *gyro)
gume 0:1f82672b8755 1325 {
gume 0:1f82672b8755 1326 /* Variable used to return value of
gume 0:1f82672b8755 1327 communication routine*/
gume 0:1f82672b8755 1328 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1329 /* Array holding the gyro xyz value
gume 0:1f82672b8755 1330 data_u8[BNO055_SENSOR_DATA_XYZ_X_LSB] - x->LSB
gume 0:1f82672b8755 1331 data_u8[BNO055_SENSOR_DATA_XYZ_X_MSB] - x->MSB
gume 0:1f82672b8755 1332 data_u8[BNO055_SENSOR_DATA_XYZ_Y_LSB] - y->MSB
gume 0:1f82672b8755 1333 data_u8[BNO055_SENSOR_DATA_XYZ_Y_MSB] - y->MSB
gume 0:1f82672b8755 1334 data_u8[BNO055_SENSOR_DATA_XYZ_Z_LSB] - z->MSB
gume 0:1f82672b8755 1335 data_u8[BNO055_SENSOR_DATA_XYZ_Z_MSB] - z->MSB
gume 0:1f82672b8755 1336 */
gume 0:1f82672b8755 1337 u8 data_u8[BNO055_GYRO_XYZ_DATA_SIZE] = {
gume 0:1f82672b8755 1338 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 1339 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 1340 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 1341 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 1342 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 1343 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 1344 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 1345 } else {
gume 0:1f82672b8755 1346 /*condition check for page, chip id is
gume 0:1f82672b8755 1347 available in the page zero*/
gume 0:1f82672b8755 1348 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 1349 /* Write the page zero*/
gume 0:1f82672b8755 1350 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 1351 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 1352 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 1353 /* Read the six bytes data of gyro xyz*/
gume 0:1f82672b8755 1354 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 1355 (p_bno055->dev_addr,
gume 0:1f82672b8755 1356 BNO055_GYRO_DATA_X_LSB_VALUEX_REG,
gume 0:1f82672b8755 1357 data_u8, BNO055_GYRO_XYZ_DATA_SIZE);
gume 0:1f82672b8755 1358 /* Data x*/
gume 0:1f82672b8755 1359 data_u8[BNO055_SENSOR_DATA_XYZ_X_LSB] =
gume 0:1f82672b8755 1360 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1361 data_u8[BNO055_SENSOR_DATA_XYZ_X_LSB],
gume 0:1f82672b8755 1362 BNO055_GYRO_DATA_X_LSB_VALUEX);
gume 0:1f82672b8755 1363 data_u8[BNO055_SENSOR_DATA_XYZ_X_MSB] =
gume 0:1f82672b8755 1364 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1365 data_u8[BNO055_SENSOR_DATA_XYZ_X_MSB],
gume 0:1f82672b8755 1366 BNO055_GYRO_DATA_X_MSB_VALUEX);
gume 0:1f82672b8755 1367 gyro->x = (s16)((((s32)
gume 0:1f82672b8755 1368 ((s8)data_u8[BNO055_SENSOR_DATA_XYZ_X_MSB])) <<
gume 0:1f82672b8755 1369 BNO055_SHIFT_EIGHT_BITS) |
gume 0:1f82672b8755 1370 (data_u8[BNO055_SENSOR_DATA_XYZ_X_LSB]));
gume 0:1f82672b8755 1371 /* Data y*/
gume 0:1f82672b8755 1372 data_u8[BNO055_SENSOR_DATA_XYZ_Y_LSB] =
gume 0:1f82672b8755 1373 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1374 data_u8[BNO055_SENSOR_DATA_XYZ_Y_LSB],
gume 0:1f82672b8755 1375 BNO055_GYRO_DATA_Y_LSB_VALUEY);
gume 0:1f82672b8755 1376 data_u8[BNO055_SENSOR_DATA_XYZ_Y_MSB] =
gume 0:1f82672b8755 1377 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1378 data_u8[BNO055_SENSOR_DATA_XYZ_Y_MSB],
gume 0:1f82672b8755 1379 BNO055_GYRO_DATA_Y_MSB_VALUEY);
gume 0:1f82672b8755 1380 gyro->y = (s16)((((s32)
gume 0:1f82672b8755 1381 ((s8)data_u8[BNO055_SENSOR_DATA_XYZ_Y_MSB])) <<
gume 0:1f82672b8755 1382 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 1383 | (data_u8[BNO055_SENSOR_DATA_XYZ_Y_LSB]));
gume 0:1f82672b8755 1384 /* Data z*/
gume 0:1f82672b8755 1385 data_u8[BNO055_SENSOR_DATA_XYZ_Z_LSB] =
gume 0:1f82672b8755 1386 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1387 data_u8[BNO055_SENSOR_DATA_XYZ_Z_LSB],
gume 0:1f82672b8755 1388 BNO055_GYRO_DATA_Z_LSB_VALUEZ);
gume 0:1f82672b8755 1389 data_u8[BNO055_SENSOR_DATA_XYZ_Z_MSB] =
gume 0:1f82672b8755 1390 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1391 data_u8[BNO055_SENSOR_DATA_XYZ_Z_MSB],
gume 0:1f82672b8755 1392 BNO055_GYRO_DATA_Z_MSB_VALUEZ);
gume 0:1f82672b8755 1393 gyro->z = (s16)((((s32)
gume 0:1f82672b8755 1394 ((s8)data_u8[BNO055_SENSOR_DATA_XYZ_Z_MSB])) <<
gume 0:1f82672b8755 1395 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 1396 | (data_u8[BNO055_SENSOR_DATA_XYZ_Z_LSB]));
gume 0:1f82672b8755 1397 } else {
gume 0:1f82672b8755 1398 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1399 }
gume 0:1f82672b8755 1400 }
gume 0:1f82672b8755 1401 return com_rslt;
gume 0:1f82672b8755 1402 }
gume 0:1f82672b8755 1403 /*!
gume 0:1f82672b8755 1404 * @brief This API reads gyro data z values
gume 0:1f82672b8755 1405 * from register 0x1A and 0x1B it is a two byte data
gume 0:1f82672b8755 1406 *
gume 0:1f82672b8755 1407 * @param euler_h_s16 : The raw h data
gume 0:1f82672b8755 1408 *
gume 0:1f82672b8755 1409 * @return results of bus communication function
gume 0:1f82672b8755 1410 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 1411 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 1412 *
gume 0:1f82672b8755 1413 */
gume 0:1f82672b8755 1414 BNO055_RETURN_FUNCTION_TYPE bno055_read_euler_h(s16 *euler_h_s16)
gume 0:1f82672b8755 1415 {
gume 0:1f82672b8755 1416 /* Variable used to return value of
gume 0:1f82672b8755 1417 communication routine*/
gume 0:1f82672b8755 1418 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1419 /* Array holding the Euler h value
gume 0:1f82672b8755 1420 data_u8[BNO055_SENSOR_DATA_EULER_LSB] - h->LSB
gume 0:1f82672b8755 1421 data_u8[BNO055_SENSOR_DATA_EULER_MSB] - h->MSB
gume 0:1f82672b8755 1422 */
gume 0:1f82672b8755 1423 u8 data_u8[BNO055_EULER_DATA_SIZE] = {
gume 0:1f82672b8755 1424 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 1425 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 1426 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 1427 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 1428 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 1429 } else {
gume 0:1f82672b8755 1430 /*condition check for page, chip id is
gume 0:1f82672b8755 1431 available in the page zero*/
gume 0:1f82672b8755 1432 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 1433 /* Write the page zero*/
gume 0:1f82672b8755 1434 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 1435 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 1436 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 1437 /* Read the eulre heading data*/
gume 0:1f82672b8755 1438 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 1439 (p_bno055->dev_addr,
gume 0:1f82672b8755 1440 BNO055_EULER_H_LSB_VALUEH_REG,
gume 0:1f82672b8755 1441 data_u8, BNO055_LSB_MSB_READ_LENGTH);
gume 0:1f82672b8755 1442 data_u8[BNO055_SENSOR_DATA_EULER_LSB] =
gume 0:1f82672b8755 1443 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1444 data_u8[BNO055_SENSOR_DATA_EULER_LSB],
gume 0:1f82672b8755 1445 BNO055_EULER_H_LSB_VALUEH);
gume 0:1f82672b8755 1446 data_u8[BNO055_SENSOR_DATA_EULER_MSB] =
gume 0:1f82672b8755 1447 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1448 data_u8[BNO055_SENSOR_DATA_EULER_MSB],
gume 0:1f82672b8755 1449 BNO055_EULER_H_MSB_VALUEH);
gume 0:1f82672b8755 1450 *euler_h_s16 = (s16)((((s32)
gume 0:1f82672b8755 1451 ((s8)data_u8[BNO055_SENSOR_DATA_EULER_MSB])) <<
gume 0:1f82672b8755 1452 BNO055_SHIFT_EIGHT_BITS) |
gume 0:1f82672b8755 1453 (data_u8[BNO055_SENSOR_DATA_EULER_LSB]));
gume 0:1f82672b8755 1454 } else {
gume 0:1f82672b8755 1455 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1456 }
gume 0:1f82672b8755 1457 }
gume 0:1f82672b8755 1458 return com_rslt;
gume 0:1f82672b8755 1459 }
gume 0:1f82672b8755 1460 /*!
gume 0:1f82672b8755 1461 * @brief This API reads Euler data r values
gume 0:1f82672b8755 1462 * from register 0x1C and 0x1D it is a two byte data
gume 0:1f82672b8755 1463 *
gume 0:1f82672b8755 1464 * @param euler_r_s16 : The raw r data
gume 0:1f82672b8755 1465 *
gume 0:1f82672b8755 1466 * @return results of bus communication function
gume 0:1f82672b8755 1467 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 1468 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 1469 *
gume 0:1f82672b8755 1470 */
gume 0:1f82672b8755 1471 BNO055_RETURN_FUNCTION_TYPE bno055_read_euler_r(s16 *euler_r_s16)
gume 0:1f82672b8755 1472 {
gume 0:1f82672b8755 1473 /* Variable used to return value of
gume 0:1f82672b8755 1474 communication routine*/
gume 0:1f82672b8755 1475 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1476 /* Array holding the Euler r value
gume 0:1f82672b8755 1477 data_u8[BNO055_SENSOR_DATA_EULER_LSB] - r->LSB
gume 0:1f82672b8755 1478 data_u8[BNO055_SENSOR_DATA_EULER_MSB] - r->MSB
gume 0:1f82672b8755 1479 */
gume 0:1f82672b8755 1480 u8 data_u8[BNO055_EULER_DATA_SIZE] = {
gume 0:1f82672b8755 1481 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 1482 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 1483 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 1484 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 1485 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 1486 } else {
gume 0:1f82672b8755 1487 /*condition check for page, chip id is
gume 0:1f82672b8755 1488 available in the page zero*/
gume 0:1f82672b8755 1489 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 1490 /* Write the page zero*/
gume 0:1f82672b8755 1491 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 1492 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 1493 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 1494 /* Read the Euler roll data*/
gume 0:1f82672b8755 1495 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 1496 (p_bno055->dev_addr,
gume 0:1f82672b8755 1497 BNO055_EULER_R_LSB_VALUER_REG,
gume 0:1f82672b8755 1498 data_u8, BNO055_LSB_MSB_READ_LENGTH);
gume 0:1f82672b8755 1499 data_u8[BNO055_SENSOR_DATA_EULER_LSB] =
gume 0:1f82672b8755 1500 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1501 data_u8[BNO055_SENSOR_DATA_EULER_LSB],
gume 0:1f82672b8755 1502 BNO055_EULER_R_LSB_VALUER);
gume 0:1f82672b8755 1503 data_u8[BNO055_SENSOR_DATA_EULER_MSB] =
gume 0:1f82672b8755 1504 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1505 data_u8[BNO055_SENSOR_DATA_EULER_MSB],
gume 0:1f82672b8755 1506 BNO055_EULER_R_MSB_VALUER);
gume 0:1f82672b8755 1507 *euler_r_s16 = (s16)((((s32)
gume 0:1f82672b8755 1508 ((s8)data_u8[BNO055_SENSOR_DATA_EULER_MSB])) <<
gume 0:1f82672b8755 1509 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 1510 | (data_u8[BNO055_SENSOR_DATA_EULER_LSB]));
gume 0:1f82672b8755 1511 } else {
gume 0:1f82672b8755 1512 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1513 }
gume 0:1f82672b8755 1514 }
gume 0:1f82672b8755 1515 return com_rslt;
gume 0:1f82672b8755 1516 }
gume 0:1f82672b8755 1517 /*!
gume 0:1f82672b8755 1518 * @brief This API reads Euler data p values
gume 0:1f82672b8755 1519 * from register 0x1E and 0x1F it is a two byte data
gume 0:1f82672b8755 1520 *
gume 0:1f82672b8755 1521 * @param euler_p_s16 : The raw p data
gume 0:1f82672b8755 1522 *
gume 0:1f82672b8755 1523 * @return results of bus communication function
gume 0:1f82672b8755 1524 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 1525 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 1526 *
gume 0:1f82672b8755 1527 *
gume 0:1f82672b8755 1528 */
gume 0:1f82672b8755 1529 BNO055_RETURN_FUNCTION_TYPE bno055_read_euler_p(s16 *euler_p_s16)
gume 0:1f82672b8755 1530 {
gume 0:1f82672b8755 1531 /* Variable used to return value of
gume 0:1f82672b8755 1532 communication routine*/
gume 0:1f82672b8755 1533 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1534 /* Array holding the Euler p value
gume 0:1f82672b8755 1535 data_u8[BNO055_SENSOR_DATA_EULER_LSB] - p->LSB
gume 0:1f82672b8755 1536 data_u8[BNO055_SENSOR_DATA_EULER_MSB] - p->MSB
gume 0:1f82672b8755 1537 */
gume 0:1f82672b8755 1538 u8 data_u8[BNO055_EULER_DATA_SIZE] = {
gume 0:1f82672b8755 1539 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 1540 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 1541 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 1542 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 1543 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 1544 } else {
gume 0:1f82672b8755 1545 /*condition check for page, chip id is
gume 0:1f82672b8755 1546 available in the page zero*/
gume 0:1f82672b8755 1547 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 1548 /* Write the page zero*/
gume 0:1f82672b8755 1549 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 1550 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 1551 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 1552 /* Read the Euler p data*/
gume 0:1f82672b8755 1553 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 1554 (p_bno055->dev_addr,
gume 0:1f82672b8755 1555 BNO055_EULER_P_LSB_VALUEP_REG,
gume 0:1f82672b8755 1556 data_u8, BNO055_LSB_MSB_READ_LENGTH);
gume 0:1f82672b8755 1557 data_u8[BNO055_SENSOR_DATA_EULER_LSB] =
gume 0:1f82672b8755 1558 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1559 data_u8[BNO055_SENSOR_DATA_EULER_LSB],
gume 0:1f82672b8755 1560 BNO055_EULER_P_LSB_VALUEP);
gume 0:1f82672b8755 1561 data_u8[BNO055_SENSOR_DATA_EULER_MSB] =
gume 0:1f82672b8755 1562 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1563 data_u8[BNO055_SENSOR_DATA_EULER_MSB],
gume 0:1f82672b8755 1564 BNO055_EULER_P_MSB_VALUEP);
gume 0:1f82672b8755 1565 *euler_p_s16 = (s16)((((s32)
gume 0:1f82672b8755 1566 ((s8)data_u8[BNO055_SENSOR_DATA_EULER_MSB])) <<
gume 0:1f82672b8755 1567 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 1568 | (data_u8[BNO055_SENSOR_DATA_EULER_LSB]));
gume 0:1f82672b8755 1569 } else {
gume 0:1f82672b8755 1570 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1571 }
gume 0:1f82672b8755 1572 }
gume 0:1f82672b8755 1573 return com_rslt;
gume 0:1f82672b8755 1574 }
gume 0:1f82672b8755 1575 /*!
gume 0:1f82672b8755 1576 * @brief This API reads Euler data hrp values
gume 0:1f82672b8755 1577 * from register 0x1A to 0x1F it is a six byte data
gume 0:1f82672b8755 1578 *
gume 0:1f82672b8755 1579 *
gume 0:1f82672b8755 1580 * @param euler : The Euler hrp data's
gume 0:1f82672b8755 1581 *
gume 0:1f82672b8755 1582 * Parameter | result
gume 0:1f82672b8755 1583 * --------- | -----------------
gume 0:1f82672b8755 1584 * h | The Euler h data
gume 0:1f82672b8755 1585 * r | The Euler r data
gume 0:1f82672b8755 1586 * p | The Euler p data
gume 0:1f82672b8755 1587 *
gume 0:1f82672b8755 1588 *
gume 0:1f82672b8755 1589 * @return results of bus communication function
gume 0:1f82672b8755 1590 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 1591 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 1592 *
gume 0:1f82672b8755 1593 */
gume 0:1f82672b8755 1594 BNO055_RETURN_FUNCTION_TYPE bno055_read_euler_hrp(
gume 0:1f82672b8755 1595 struct bno055_euler_t *euler)
gume 0:1f82672b8755 1596 {
gume 0:1f82672b8755 1597 /* Variable used to return value of
gume 0:1f82672b8755 1598 communication routine*/
gume 0:1f82672b8755 1599 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1600 /* Array holding the Euler hrp value
gume 0:1f82672b8755 1601 data_u8[BNO055_SENSOR_DATA_EULER_HRP_H_LSB] - h->LSB
gume 0:1f82672b8755 1602 data_u8[BNO055_SENSOR_DATA_EULER_HRP_H_MSB] - h->MSB
gume 0:1f82672b8755 1603 data_u8[BNO055_SENSOR_DATA_EULER_HRP_R_LSB] - r->MSB
gume 0:1f82672b8755 1604 data_u8[BNO055_SENSOR_DATA_EULER_HRP_R_MSB] - r->MSB
gume 0:1f82672b8755 1605 data_u8[BNO055_SENSOR_DATA_EULER_HRP_P_LSB] - p->MSB
gume 0:1f82672b8755 1606 data_u8[BNO055_SENSOR_DATA_EULER_HRP_P_MSB] - p->MSB
gume 0:1f82672b8755 1607 */
gume 0:1f82672b8755 1608 u8 data_u8[BNO055_EULER_HRP_DATA_SIZE] = {
gume 0:1f82672b8755 1609 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 1610 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 1611 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 1612 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 1613 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 1614 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 1615 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 1616 } else {
gume 0:1f82672b8755 1617 /*condition check for page, chip id is
gume 0:1f82672b8755 1618 available in the page zero*/
gume 0:1f82672b8755 1619 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 1620 /* Write the page zero*/
gume 0:1f82672b8755 1621 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 1622 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 1623 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 1624 /* Read the six byte of Euler hrp data*/
gume 0:1f82672b8755 1625 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 1626 (p_bno055->dev_addr,
gume 0:1f82672b8755 1627 BNO055_EULER_H_LSB_VALUEH_REG,
gume 0:1f82672b8755 1628 data_u8, BNO055_EULER_HRP_DATA_SIZE);
gume 0:1f82672b8755 1629 /* Data h*/
gume 0:1f82672b8755 1630 data_u8[BNO055_SENSOR_DATA_EULER_HRP_H_LSB] =
gume 0:1f82672b8755 1631 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1632 data_u8[BNO055_SENSOR_DATA_EULER_HRP_H_LSB],
gume 0:1f82672b8755 1633 BNO055_EULER_H_LSB_VALUEH);
gume 0:1f82672b8755 1634 data_u8[BNO055_SENSOR_DATA_EULER_HRP_H_MSB] =
gume 0:1f82672b8755 1635 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1636 data_u8[BNO055_SENSOR_DATA_EULER_HRP_H_MSB],
gume 0:1f82672b8755 1637 BNO055_EULER_H_MSB_VALUEH);
gume 0:1f82672b8755 1638 euler->h = (s16)((((s32)
gume 0:1f82672b8755 1639 ((s8)data_u8[BNO055_SENSOR_DATA_EULER_HRP_H_MSB])) <<
gume 0:1f82672b8755 1640 BNO055_SHIFT_EIGHT_BITS) |
gume 0:1f82672b8755 1641 (data_u8[BNO055_SENSOR_DATA_EULER_HRP_H_LSB]));
gume 0:1f82672b8755 1642 /* Data r*/
gume 0:1f82672b8755 1643 data_u8[BNO055_SENSOR_DATA_EULER_HRP_R_LSB] =
gume 0:1f82672b8755 1644 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1645 data_u8[BNO055_SENSOR_DATA_EULER_HRP_R_LSB],
gume 0:1f82672b8755 1646 BNO055_EULER_R_LSB_VALUER);
gume 0:1f82672b8755 1647 data_u8[BNO055_SENSOR_DATA_EULER_HRP_R_MSB] =
gume 0:1f82672b8755 1648 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1649 data_u8[BNO055_SENSOR_DATA_EULER_HRP_R_MSB],
gume 0:1f82672b8755 1650 BNO055_EULER_R_MSB_VALUER);
gume 0:1f82672b8755 1651 euler->r = (s16)((((s32)
gume 0:1f82672b8755 1652 ((s8)data_u8[BNO055_SENSOR_DATA_EULER_HRP_R_MSB])) <<
gume 0:1f82672b8755 1653 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 1654 | (data_u8[BNO055_SENSOR_DATA_EULER_HRP_R_LSB]));
gume 0:1f82672b8755 1655 /* Data p*/
gume 0:1f82672b8755 1656 data_u8[BNO055_SENSOR_DATA_EULER_HRP_P_LSB] =
gume 0:1f82672b8755 1657 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1658 data_u8[BNO055_SENSOR_DATA_EULER_HRP_P_LSB],
gume 0:1f82672b8755 1659 BNO055_EULER_P_LSB_VALUEP);
gume 0:1f82672b8755 1660 data_u8[BNO055_SENSOR_DATA_EULER_HRP_P_MSB] =
gume 0:1f82672b8755 1661 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1662 data_u8[BNO055_SENSOR_DATA_EULER_HRP_P_MSB],
gume 0:1f82672b8755 1663 BNO055_EULER_P_MSB_VALUEP);
gume 0:1f82672b8755 1664 euler->p = (s16)((((s32)
gume 0:1f82672b8755 1665 ((s8)data_u8[BNO055_SENSOR_DATA_EULER_HRP_P_MSB])) <<
gume 0:1f82672b8755 1666 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 1667 | (data_u8[BNO055_SENSOR_DATA_EULER_HRP_P_LSB]));
gume 0:1f82672b8755 1668 } else {
gume 0:1f82672b8755 1669 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1670 }
gume 0:1f82672b8755 1671 }
gume 0:1f82672b8755 1672 return com_rslt;
gume 0:1f82672b8755 1673 }
gume 0:1f82672b8755 1674 /*!
gume 0:1f82672b8755 1675 * @brief This API reads quaternion data w values
gume 0:1f82672b8755 1676 * from register 0x20 and 0x21 it is a two byte data
gume 0:1f82672b8755 1677 *
gume 0:1f82672b8755 1678 * @param quaternion_w_s16 : The raw w data
gume 0:1f82672b8755 1679 *
gume 0:1f82672b8755 1680 * @return results of bus communication function
gume 0:1f82672b8755 1681 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 1682 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 1683 *
gume 0:1f82672b8755 1684 *
gume 0:1f82672b8755 1685 */
gume 0:1f82672b8755 1686 BNO055_RETURN_FUNCTION_TYPE bno055_read_quaternion_w(
gume 0:1f82672b8755 1687 s16 *quaternion_w_s16)
gume 0:1f82672b8755 1688 {
gume 0:1f82672b8755 1689 /* Variable used to return value of
gume 0:1f82672b8755 1690 communication routine*/
gume 0:1f82672b8755 1691 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1692 /* Array holding the Quaternion w value
gume 0:1f82672b8755 1693 data_u8[BNO055_SENSOR_DATA_QUATERNION_LSB] - w->LSB
gume 0:1f82672b8755 1694 data_u8[BNO055_SENSOR_DATA_QUATERNION_MSB] - w->MSB
gume 0:1f82672b8755 1695 */
gume 0:1f82672b8755 1696 u8 data_u8[BNO055_QUATERNION_DATA_SIZE] = {
gume 0:1f82672b8755 1697 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 1698 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 1699 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 1700 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 1701 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 1702 } else {
gume 0:1f82672b8755 1703 /*condition check for page, chip id is
gume 0:1f82672b8755 1704 available in the page zero*/
gume 0:1f82672b8755 1705 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 1706 /* Write the page zero*/
gume 0:1f82672b8755 1707 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 1708 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 1709 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 1710 /* Read the two byte value
gume 0:1f82672b8755 1711 of quaternion w data*/
gume 0:1f82672b8755 1712 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 1713 (p_bno055->dev_addr,
gume 0:1f82672b8755 1714 BNO055_QUATERNION_DATA_W_LSB_VALUEW_REG,
gume 0:1f82672b8755 1715 data_u8, BNO055_LSB_MSB_READ_LENGTH);
gume 0:1f82672b8755 1716 data_u8[BNO055_SENSOR_DATA_QUATERNION_LSB] =
gume 0:1f82672b8755 1717 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1718 data_u8[BNO055_SENSOR_DATA_QUATERNION_LSB],
gume 0:1f82672b8755 1719 BNO055_QUATERNION_DATA_W_LSB_VALUEW);
gume 0:1f82672b8755 1720 data_u8[BNO055_SENSOR_DATA_QUATERNION_MSB] =
gume 0:1f82672b8755 1721 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1722 data_u8[BNO055_SENSOR_DATA_QUATERNION_MSB],
gume 0:1f82672b8755 1723 BNO055_QUATERNION_DATA_W_MSB_VALUEW);
gume 0:1f82672b8755 1724 *quaternion_w_s16 = (s16)((((s32)
gume 0:1f82672b8755 1725 ((s8)data_u8[BNO055_SENSOR_DATA_QUATERNION_MSB])) <<
gume 0:1f82672b8755 1726 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 1727 | (data_u8[BNO055_SENSOR_DATA_QUATERNION_LSB]));
gume 0:1f82672b8755 1728 } else {
gume 0:1f82672b8755 1729 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1730 }
gume 0:1f82672b8755 1731 }
gume 0:1f82672b8755 1732 return com_rslt;
gume 0:1f82672b8755 1733 }
gume 0:1f82672b8755 1734 /*!
gume 0:1f82672b8755 1735 * @brief This API reads quaternion data x values
gume 0:1f82672b8755 1736 * from register 0x22 and 0x23 it is a two byte data
gume 0:1f82672b8755 1737 *
gume 0:1f82672b8755 1738 * @param quaternion_x_s16 : The raw x data
gume 0:1f82672b8755 1739 *
gume 0:1f82672b8755 1740 * @return results of bus communication function
gume 0:1f82672b8755 1741 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 1742 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 1743 *
gume 0:1f82672b8755 1744 *
gume 0:1f82672b8755 1745 */
gume 0:1f82672b8755 1746 BNO055_RETURN_FUNCTION_TYPE bno055_read_quaternion_x(
gume 0:1f82672b8755 1747 s16 *quaternion_x_s16)
gume 0:1f82672b8755 1748 {
gume 0:1f82672b8755 1749 /* Variable used to return value of
gume 0:1f82672b8755 1750 communication routine*/
gume 0:1f82672b8755 1751 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1752 /* Array holding the quaternion x value
gume 0:1f82672b8755 1753 data_u8[BNO055_SENSOR_DATA_QUATERNION_LSB] - x->LSB
gume 0:1f82672b8755 1754 data_u8[BNO055_SENSOR_DATA_QUATERNION_MSB] - x->MSB
gume 0:1f82672b8755 1755 */
gume 0:1f82672b8755 1756 u8 data_u8[BNO055_QUATERNION_DATA_SIZE] = {BNO055_INIT_VALUE,
gume 0:1f82672b8755 1757 BNO055_INIT_VALUE};
gume 0:1f82672b8755 1758 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 1759 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 1760 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 1761 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 1762 } else {
gume 0:1f82672b8755 1763 /*condition check for page, chip id is
gume 0:1f82672b8755 1764 available in the page zero*/
gume 0:1f82672b8755 1765 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 1766 /* Write the page zero*/
gume 0:1f82672b8755 1767 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 1768 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 1769 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 1770 /* Read the two byte value
gume 0:1f82672b8755 1771 of quaternion x data*/
gume 0:1f82672b8755 1772 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 1773 (p_bno055->dev_addr,
gume 0:1f82672b8755 1774 BNO055_QUATERNION_DATA_X_LSB_VALUEX_REG,
gume 0:1f82672b8755 1775 data_u8, BNO055_LSB_MSB_READ_LENGTH);
gume 0:1f82672b8755 1776 data_u8[BNO055_SENSOR_DATA_QUATERNION_LSB] =
gume 0:1f82672b8755 1777 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1778 data_u8[BNO055_SENSOR_DATA_QUATERNION_LSB],
gume 0:1f82672b8755 1779 BNO055_QUATERNION_DATA_X_LSB_VALUEX);
gume 0:1f82672b8755 1780 data_u8[BNO055_SENSOR_DATA_QUATERNION_MSB] =
gume 0:1f82672b8755 1781 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1782 data_u8[BNO055_SENSOR_DATA_QUATERNION_MSB],
gume 0:1f82672b8755 1783 BNO055_QUATERNION_DATA_X_MSB_VALUEX);
gume 0:1f82672b8755 1784 *quaternion_x_s16 = (s16)((((s32)
gume 0:1f82672b8755 1785 ((s8)data_u8[BNO055_SENSOR_DATA_QUATERNION_MSB])) <<
gume 0:1f82672b8755 1786 BNO055_SHIFT_EIGHT_BITS) |
gume 0:1f82672b8755 1787 (data_u8[BNO055_SENSOR_DATA_QUATERNION_LSB]));
gume 0:1f82672b8755 1788 } else {
gume 0:1f82672b8755 1789 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1790 }
gume 0:1f82672b8755 1791 }
gume 0:1f82672b8755 1792 return com_rslt;
gume 0:1f82672b8755 1793 }
gume 0:1f82672b8755 1794 /*!
gume 0:1f82672b8755 1795 * @brief This API reads quaternion data y values
gume 0:1f82672b8755 1796 * from register 0x24 and 0x25 it is a two byte data
gume 0:1f82672b8755 1797 *
gume 0:1f82672b8755 1798 * @param quaternion_y_s16 : The raw y data
gume 0:1f82672b8755 1799 *
gume 0:1f82672b8755 1800 * @return results of bus communication function
gume 0:1f82672b8755 1801 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 1802 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 1803 *
gume 0:1f82672b8755 1804 *
gume 0:1f82672b8755 1805 */
gume 0:1f82672b8755 1806 BNO055_RETURN_FUNCTION_TYPE bno055_read_quaternion_y(
gume 0:1f82672b8755 1807 s16 *quaternion_y_s16)
gume 0:1f82672b8755 1808 {
gume 0:1f82672b8755 1809 /* Variable used to return value of
gume 0:1f82672b8755 1810 communication routine*/
gume 0:1f82672b8755 1811 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1812 /* Array holding the quaternion y value
gume 0:1f82672b8755 1813 data_u8[BNO055_SENSOR_DATA_QUATERNION_LSB] - y->LSB
gume 0:1f82672b8755 1814 data_u8[BNO055_SENSOR_DATA_QUATERNION_MSB] - y->MSB
gume 0:1f82672b8755 1815 */
gume 0:1f82672b8755 1816 u8 data_u8[BNO055_QUATERNION_DATA_SIZE] = {BNO055_INIT_VALUE,
gume 0:1f82672b8755 1817 BNO055_INIT_VALUE};
gume 0:1f82672b8755 1818 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 1819 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 1820 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 1821 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 1822 } else {
gume 0:1f82672b8755 1823 /*condition check for page, chip id is
gume 0:1f82672b8755 1824 available in the page zero*/
gume 0:1f82672b8755 1825 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 1826 /* Write the page zero*/
gume 0:1f82672b8755 1827 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 1828 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 1829 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 1830 /* Read the two byte value
gume 0:1f82672b8755 1831 of quaternion y data*/
gume 0:1f82672b8755 1832 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 1833 (p_bno055->dev_addr,
gume 0:1f82672b8755 1834 BNO055_QUATERNION_DATA_Y_LSB_VALUEY_REG,
gume 0:1f82672b8755 1835 data_u8, BNO055_LSB_MSB_READ_LENGTH);
gume 0:1f82672b8755 1836 data_u8[BNO055_SENSOR_DATA_QUATERNION_LSB] =
gume 0:1f82672b8755 1837 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1838 data_u8[BNO055_SENSOR_DATA_QUATERNION_LSB],
gume 0:1f82672b8755 1839 BNO055_QUATERNION_DATA_Y_LSB_VALUEY);
gume 0:1f82672b8755 1840 data_u8[BNO055_SENSOR_DATA_QUATERNION_MSB] =
gume 0:1f82672b8755 1841 BNO055_GET_BITSLICE
gume 0:1f82672b8755 1842 (data_u8[BNO055_SENSOR_DATA_QUATERNION_MSB],
gume 0:1f82672b8755 1843 BNO055_QUATERNION_DATA_Y_MSB_VALUEY);
gume 0:1f82672b8755 1844 *quaternion_y_s16 = (s16)((((s32)
gume 0:1f82672b8755 1845 ((s8)data_u8[BNO055_SENSOR_DATA_QUATERNION_MSB])) <<
gume 0:1f82672b8755 1846 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 1847 | (data_u8[BNO055_SENSOR_DATA_QUATERNION_LSB]));
gume 0:1f82672b8755 1848 } else {
gume 0:1f82672b8755 1849 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1850 }
gume 0:1f82672b8755 1851 }
gume 0:1f82672b8755 1852 return com_rslt;
gume 0:1f82672b8755 1853 }
gume 0:1f82672b8755 1854 /*!
gume 0:1f82672b8755 1855 * @brief This API reads quaternion data z values
gume 0:1f82672b8755 1856 * from register 0x26 and 0x27 it is a two byte data
gume 0:1f82672b8755 1857 *
gume 0:1f82672b8755 1858 * @param quaternion_z_s16 : The raw z data
gume 0:1f82672b8755 1859 *
gume 0:1f82672b8755 1860 * @return results of bus communication function
gume 0:1f82672b8755 1861 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 1862 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 1863 *
gume 0:1f82672b8755 1864 *
gume 0:1f82672b8755 1865 */
gume 0:1f82672b8755 1866 BNO055_RETURN_FUNCTION_TYPE bno055_read_quaternion_z(
gume 0:1f82672b8755 1867 s16 *quaternion_z_s16)
gume 0:1f82672b8755 1868 {
gume 0:1f82672b8755 1869 /* Variable used to return value of
gume 0:1f82672b8755 1870 communication routine*/
gume 0:1f82672b8755 1871 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1872 /* Array holding the quaternion z value
gume 0:1f82672b8755 1873 data_u8[BNO055_SENSOR_DATA_QUATERNION_LSB] - z->LSB
gume 0:1f82672b8755 1874 data_u8[BNO055_SENSOR_DATA_QUATERNION_MSB] - z->MSB
gume 0:1f82672b8755 1875 */
gume 0:1f82672b8755 1876 u8 data_u8[BNO055_QUATERNION_DATA_SIZE] = {
gume 0:1f82672b8755 1877 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 1878 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 1879 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 1880 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 1881 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 1882 } else {
gume 0:1f82672b8755 1883 /*condition check for page, chip id is
gume 0:1f82672b8755 1884 available in the page zero*/
gume 0:1f82672b8755 1885 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 1886 /* Write the page zero*/
gume 0:1f82672b8755 1887 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 1888 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 1889 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 1890 /* Read the two byte value
gume 0:1f82672b8755 1891 of quaternion z data*/
gume 0:1f82672b8755 1892 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 1893 (p_bno055->dev_addr,
gume 0:1f82672b8755 1894 BNO055_QUATERNION_DATA_Z_LSB_VALUEZ_REG,
gume 0:1f82672b8755 1895 data_u8, BNO055_LSB_MSB_READ_LENGTH);
gume 0:1f82672b8755 1896 data_u8[BNO055_SENSOR_DATA_QUATERNION_LSB] =
gume 0:1f82672b8755 1897 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1898 data_u8[BNO055_SENSOR_DATA_QUATERNION_LSB],
gume 0:1f82672b8755 1899 BNO055_QUATERNION_DATA_Z_LSB_VALUEZ);
gume 0:1f82672b8755 1900 data_u8[BNO055_SENSOR_DATA_QUATERNION_MSB] =
gume 0:1f82672b8755 1901 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1902 data_u8[BNO055_SENSOR_DATA_QUATERNION_MSB],
gume 0:1f82672b8755 1903 BNO055_QUATERNION_DATA_Z_MSB_VALUEZ);
gume 0:1f82672b8755 1904 *quaternion_z_s16 = (s16)((((s32)
gume 0:1f82672b8755 1905 ((s8)data_u8[BNO055_SENSOR_DATA_QUATERNION_MSB])) <<
gume 0:1f82672b8755 1906 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 1907 | (data_u8[BNO055_SENSOR_DATA_QUATERNION_LSB]));
gume 0:1f82672b8755 1908 } else {
gume 0:1f82672b8755 1909 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1910 }
gume 0:1f82672b8755 1911 }
gume 0:1f82672b8755 1912 return com_rslt;
gume 0:1f82672b8755 1913 }
gume 0:1f82672b8755 1914 /*!
gume 0:1f82672b8755 1915 * @brief This API reads Quaternion data wxyz values
gume 0:1f82672b8755 1916 * from register 0x20 to 0x27 it is a six byte data
gume 0:1f82672b8755 1917 *
gume 0:1f82672b8755 1918 *
gume 0:1f82672b8755 1919 * @param quaternion : The value of quaternion wxyz data's
gume 0:1f82672b8755 1920 *
gume 0:1f82672b8755 1921 * Parameter | result
gume 0:1f82672b8755 1922 * --------- | -----------------
gume 0:1f82672b8755 1923 * w | The quaternion w data
gume 0:1f82672b8755 1924 * x | The quaternion x data
gume 0:1f82672b8755 1925 * y | The quaternion y data
gume 0:1f82672b8755 1926 * z | The quaternion z data
gume 0:1f82672b8755 1927 *
gume 0:1f82672b8755 1928 *
gume 0:1f82672b8755 1929 *
gume 0:1f82672b8755 1930 * @return results of bus communication function
gume 0:1f82672b8755 1931 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 1932 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 1933 *
gume 0:1f82672b8755 1934 */
gume 0:1f82672b8755 1935 BNO055_RETURN_FUNCTION_TYPE bno055_read_quaternion_wxyz(
gume 0:1f82672b8755 1936 struct bno055_quaternion_t *quaternion)
gume 0:1f82672b8755 1937 {
gume 0:1f82672b8755 1938 /* Variable used to return value of
gume 0:1f82672b8755 1939 communication routine*/
gume 0:1f82672b8755 1940 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 1941 /* Array holding the quaternion wxyz value
gume 0:1f82672b8755 1942 data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_W_LSB] - w->LSB
gume 0:1f82672b8755 1943 data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_W_MSB] - w->MSB
gume 0:1f82672b8755 1944 data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_X_LSB] - x->LSB
gume 0:1f82672b8755 1945 data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_X_MSB] - x->MSB
gume 0:1f82672b8755 1946 data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_Y_LSB] - y->MSB
gume 0:1f82672b8755 1947 data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_Y_MSB] - y->MSB
gume 0:1f82672b8755 1948 data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_Z_LSB] - z->MSB
gume 0:1f82672b8755 1949 data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_Z_MSB] - z->MSB
gume 0:1f82672b8755 1950 */
gume 0:1f82672b8755 1951 u8 data_u8[BNO055_QUATERNION_WXYZ_DATA_SIZE] = {
gume 0:1f82672b8755 1952 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 1953 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 1954 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 1955 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 1956 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 1957 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 1958 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 1959 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 1960 } else {
gume 0:1f82672b8755 1961 /*condition check for page, chip id is
gume 0:1f82672b8755 1962 available in the page zero*/
gume 0:1f82672b8755 1963 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 1964 /* Write the page zero*/
gume 0:1f82672b8755 1965 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 1966 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 1967 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 1968 /* Read the eight byte value
gume 0:1f82672b8755 1969 of quaternion wxyz data*/
gume 0:1f82672b8755 1970 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 1971 (p_bno055->dev_addr,
gume 0:1f82672b8755 1972 BNO055_QUATERNION_DATA_W_LSB_VALUEW_REG,
gume 0:1f82672b8755 1973 data_u8, BNO055_QUATERNION_WXYZ_DATA_SIZE);
gume 0:1f82672b8755 1974 /* Data W*/
gume 0:1f82672b8755 1975 data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_W_LSB] =
gume 0:1f82672b8755 1976 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1977 data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_W_LSB],
gume 0:1f82672b8755 1978 BNO055_QUATERNION_DATA_W_LSB_VALUEW);
gume 0:1f82672b8755 1979 data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_W_MSB] =
gume 0:1f82672b8755 1980 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1981 data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_W_MSB],
gume 0:1f82672b8755 1982 BNO055_QUATERNION_DATA_W_MSB_VALUEW);
gume 0:1f82672b8755 1983 quaternion->w = (s16)((((s32)((s8)
gume 0:1f82672b8755 1984 data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_W_MSB])) <<
gume 0:1f82672b8755 1985 BNO055_SHIFT_EIGHT_BITS) |
gume 0:1f82672b8755 1986 (data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_W_LSB]));
gume 0:1f82672b8755 1987 /* Data X*/
gume 0:1f82672b8755 1988 data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_X_LSB] =
gume 0:1f82672b8755 1989 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1990 data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_X_LSB],
gume 0:1f82672b8755 1991 BNO055_QUATERNION_DATA_X_LSB_VALUEX);
gume 0:1f82672b8755 1992 data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_X_MSB] =
gume 0:1f82672b8755 1993 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 1994 data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_X_MSB],
gume 0:1f82672b8755 1995 BNO055_QUATERNION_DATA_X_MSB_VALUEX);
gume 0:1f82672b8755 1996 quaternion->x = (s16)((((s32)((s8)
gume 0:1f82672b8755 1997 data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_X_MSB])) <<
gume 0:1f82672b8755 1998 BNO055_SHIFT_EIGHT_BITS) |
gume 0:1f82672b8755 1999 (data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_X_LSB]));
gume 0:1f82672b8755 2000 /* Data Y*/
gume 0:1f82672b8755 2001 data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_Y_LSB] =
gume 0:1f82672b8755 2002 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 2003 data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_Y_LSB],
gume 0:1f82672b8755 2004 BNO055_QUATERNION_DATA_Y_LSB_VALUEY);
gume 0:1f82672b8755 2005 data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_Y_MSB] =
gume 0:1f82672b8755 2006 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 2007 data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_Y_MSB],
gume 0:1f82672b8755 2008 BNO055_QUATERNION_DATA_Y_MSB_VALUEY);
gume 0:1f82672b8755 2009 quaternion->y = (s16)((((s32)((s8)
gume 0:1f82672b8755 2010 data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_Y_MSB])) <<
gume 0:1f82672b8755 2011 BNO055_SHIFT_EIGHT_BITS) |
gume 0:1f82672b8755 2012 (data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_Y_LSB]));
gume 0:1f82672b8755 2013 /* Data Z*/
gume 0:1f82672b8755 2014 data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_Z_LSB] =
gume 0:1f82672b8755 2015 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 2016 data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_Z_LSB],
gume 0:1f82672b8755 2017 BNO055_QUATERNION_DATA_Z_LSB_VALUEZ);
gume 0:1f82672b8755 2018 data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_Z_MSB] =
gume 0:1f82672b8755 2019 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 2020 data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_Z_MSB],
gume 0:1f82672b8755 2021 BNO055_QUATERNION_DATA_Z_MSB_VALUEZ);
gume 0:1f82672b8755 2022 quaternion->z = (s16)((((s32)((s8)
gume 0:1f82672b8755 2023 data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_Z_MSB])) <<
gume 0:1f82672b8755 2024 BNO055_SHIFT_EIGHT_BITS) |
gume 0:1f82672b8755 2025 (data_u8[BNO055_SENSOR_DATA_QUATERNION_WXYZ_Z_LSB]));
gume 0:1f82672b8755 2026 } else {
gume 0:1f82672b8755 2027 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2028 }
gume 0:1f82672b8755 2029 }
gume 0:1f82672b8755 2030 return com_rslt;
gume 0:1f82672b8755 2031 }
gume 0:1f82672b8755 2032 /*!
gume 0:1f82672b8755 2033 * @brief This API reads Linear accel data x values
gume 0:1f82672b8755 2034 * from register 0x29 and 0x2A it is a two byte data
gume 0:1f82672b8755 2035 *
gume 0:1f82672b8755 2036 * @param linear_accel_x_s16 : The raw x data
gume 0:1f82672b8755 2037 *
gume 0:1f82672b8755 2038 * @return results of bus communication function
gume 0:1f82672b8755 2039 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 2040 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 2041 *
gume 0:1f82672b8755 2042 *
gume 0:1f82672b8755 2043 */
gume 0:1f82672b8755 2044 BNO055_RETURN_FUNCTION_TYPE bno055_read_linear_accel_x(
gume 0:1f82672b8755 2045 s16 *linear_accel_x_s16)
gume 0:1f82672b8755 2046 {
gume 0:1f82672b8755 2047 /* Variable used to return value of
gume 0:1f82672b8755 2048 communication routine*/
gume 0:1f82672b8755 2049 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2050 /* Array holding the linear accel x value
gume 0:1f82672b8755 2051 data_u8[BNO055_SENSOR_DATA_LSB] - x->LSB
gume 0:1f82672b8755 2052 data_u8[BNO055_SENSOR_DATA_MSB] - x->MSB
gume 0:1f82672b8755 2053 */
gume 0:1f82672b8755 2054 u8 data_u8[BNO055_ACCEL_DATA_SIZE] = {
gume 0:1f82672b8755 2055 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 2056 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 2057 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 2058 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 2059 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 2060 } else {
gume 0:1f82672b8755 2061 /*condition check for page, chip id is
gume 0:1f82672b8755 2062 available in the page zero*/
gume 0:1f82672b8755 2063 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 2064 /* Write the page zero*/
gume 0:1f82672b8755 2065 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 2066 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 2067 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 2068 /* Read the two byte value
gume 0:1f82672b8755 2069 of linear accel x data*/
gume 0:1f82672b8755 2070 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 2071 (p_bno055->dev_addr,
gume 0:1f82672b8755 2072 BNO055_LINEAR_ACCEL_DATA_X_LSB_VALUEX_REG,
gume 0:1f82672b8755 2073 data_u8, BNO055_LSB_MSB_READ_LENGTH);
gume 0:1f82672b8755 2074 data_u8[BNO055_SENSOR_DATA_LSB] =
gume 0:1f82672b8755 2075 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_LSB],
gume 0:1f82672b8755 2076 BNO055_LINEAR_ACCEL_DATA_X_LSB_VALUEX);
gume 0:1f82672b8755 2077 data_u8[BNO055_SENSOR_DATA_MSB] =
gume 0:1f82672b8755 2078 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_MSB],
gume 0:1f82672b8755 2079 BNO055_LINEAR_ACCEL_DATA_X_MSB_VALUEX);
gume 0:1f82672b8755 2080 *linear_accel_x_s16 = (s16)((((s32)
gume 0:1f82672b8755 2081 ((s8)data_u8[BNO055_SENSOR_DATA_MSB])) <<
gume 0:1f82672b8755 2082 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 2083 | (data_u8[BNO055_SENSOR_DATA_LSB]));
gume 0:1f82672b8755 2084 } else {
gume 0:1f82672b8755 2085 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2086 }
gume 0:1f82672b8755 2087 }
gume 0:1f82672b8755 2088 return com_rslt;
gume 0:1f82672b8755 2089 }
gume 0:1f82672b8755 2090 /*!
gume 0:1f82672b8755 2091 * @brief This API reads Linear accel data x values
gume 0:1f82672b8755 2092 * from register 0x2B and 0x2C it is a two byte data
gume 0:1f82672b8755 2093 *
gume 0:1f82672b8755 2094 * @param linear_accel_y_s16 : The raw y data
gume 0:1f82672b8755 2095 *
gume 0:1f82672b8755 2096 * @return results of bus communication function
gume 0:1f82672b8755 2097 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 2098 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 2099 *
gume 0:1f82672b8755 2100 *
gume 0:1f82672b8755 2101 */
gume 0:1f82672b8755 2102 BNO055_RETURN_FUNCTION_TYPE bno055_read_linear_accel_y(
gume 0:1f82672b8755 2103 s16 *linear_accel_y_s16)
gume 0:1f82672b8755 2104 {
gume 0:1f82672b8755 2105 /* Variable used to return value of
gume 0:1f82672b8755 2106 communication routine*/
gume 0:1f82672b8755 2107 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2108 /* Array holding the linear accel y value
gume 0:1f82672b8755 2109 data_u8[BNO055_SENSOR_DATA_LSB] - y->LSB
gume 0:1f82672b8755 2110 data_u8[BNO055_SENSOR_DATA_MSB] - y->MSB
gume 0:1f82672b8755 2111 */
gume 0:1f82672b8755 2112 u8 data_u8[BNO055_ACCEL_DATA_SIZE] = {
gume 0:1f82672b8755 2113 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 2114 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 2115 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 2116 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 2117 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 2118 } else {
gume 0:1f82672b8755 2119 /*condition check for page, chip id is
gume 0:1f82672b8755 2120 available in the page zero*/
gume 0:1f82672b8755 2121 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 2122 /* Write the page zero*/
gume 0:1f82672b8755 2123 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 2124 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 2125 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 2126 /* Read the two byte value
gume 0:1f82672b8755 2127 of linear accel y data*/
gume 0:1f82672b8755 2128 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 2129 (p_bno055->dev_addr,
gume 0:1f82672b8755 2130 BNO055_LINEAR_ACCEL_DATA_Y_LSB_VALUEY_REG,
gume 0:1f82672b8755 2131 data_u8, BNO055_LSB_MSB_READ_LENGTH);
gume 0:1f82672b8755 2132 data_u8[BNO055_SENSOR_DATA_LSB] =
gume 0:1f82672b8755 2133 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_LSB],
gume 0:1f82672b8755 2134 BNO055_LINEAR_ACCEL_DATA_Y_LSB_VALUEY);
gume 0:1f82672b8755 2135 data_u8[BNO055_SENSOR_DATA_MSB] =
gume 0:1f82672b8755 2136 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_MSB],
gume 0:1f82672b8755 2137 BNO055_LINEAR_ACCEL_DATA_Y_MSB_VALUEY);
gume 0:1f82672b8755 2138 *linear_accel_y_s16 = (s16)((((s32)
gume 0:1f82672b8755 2139 ((s8)data_u8[BNO055_SENSOR_DATA_MSB])) <<
gume 0:1f82672b8755 2140 BNO055_SHIFT_EIGHT_BITS) | (
gume 0:1f82672b8755 2141 data_u8[BNO055_SENSOR_DATA_LSB]));
gume 0:1f82672b8755 2142 } else {
gume 0:1f82672b8755 2143 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2144 }
gume 0:1f82672b8755 2145 }
gume 0:1f82672b8755 2146 return com_rslt;
gume 0:1f82672b8755 2147 }
gume 0:1f82672b8755 2148 /*!
gume 0:1f82672b8755 2149 * @brief This API reads Linear accel data x values
gume 0:1f82672b8755 2150 * from register 0x2C and 0x2D it is a two byte data
gume 0:1f82672b8755 2151 *
gume 0:1f82672b8755 2152 * @param linear_accel_z_s16 : The raw z data
gume 0:1f82672b8755 2153 *
gume 0:1f82672b8755 2154 * @return results of bus communication function
gume 0:1f82672b8755 2155 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 2156 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 2157 *
gume 0:1f82672b8755 2158 *
gume 0:1f82672b8755 2159 */
gume 0:1f82672b8755 2160 BNO055_RETURN_FUNCTION_TYPE bno055_read_linear_accel_z(
gume 0:1f82672b8755 2161 s16 *linear_accel_z_s16)
gume 0:1f82672b8755 2162 {
gume 0:1f82672b8755 2163 /* Variable used to return value of
gume 0:1f82672b8755 2164 communication routine*/
gume 0:1f82672b8755 2165 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2166 /* Array holding the linear accel z value
gume 0:1f82672b8755 2167 data_u8[BNO055_SENSOR_DATA_LSB] - z->LSB
gume 0:1f82672b8755 2168 data_u8[BNO055_SENSOR_DATA_MSB] - z->MSB
gume 0:1f82672b8755 2169 */
gume 0:1f82672b8755 2170 u8 data_u8[BNO055_ACCEL_DATA_SIZE] = {
gume 0:1f82672b8755 2171 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 2172 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 2173 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 2174 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 2175 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 2176 } else {
gume 0:1f82672b8755 2177 /*condition check for page, chip id is
gume 0:1f82672b8755 2178 available in the page zero*/
gume 0:1f82672b8755 2179 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 2180 /* Write the page zero*/
gume 0:1f82672b8755 2181 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 2182 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 2183 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 2184 /* Read the two byte value
gume 0:1f82672b8755 2185 of linear accel z data*/
gume 0:1f82672b8755 2186 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 2187 (p_bno055->dev_addr,
gume 0:1f82672b8755 2188 BNO055_LINEAR_ACCEL_DATA_Z_LSB_VALUEZ_REG,
gume 0:1f82672b8755 2189 data_u8, BNO055_LSB_MSB_READ_LENGTH);
gume 0:1f82672b8755 2190 data_u8[BNO055_SENSOR_DATA_LSB] =
gume 0:1f82672b8755 2191 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_LSB],
gume 0:1f82672b8755 2192 BNO055_LINEAR_ACCEL_DATA_Z_LSB_VALUEZ);
gume 0:1f82672b8755 2193 data_u8[BNO055_SENSOR_DATA_MSB] =
gume 0:1f82672b8755 2194 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_MSB],
gume 0:1f82672b8755 2195 BNO055_LINEAR_ACCEL_DATA_Z_MSB_VALUEZ);
gume 0:1f82672b8755 2196 *linear_accel_z_s16 = (s16)((((s32)
gume 0:1f82672b8755 2197 ((s8)data_u8[BNO055_SENSOR_DATA_MSB])) <<
gume 0:1f82672b8755 2198 BNO055_SHIFT_EIGHT_BITS) | (
gume 0:1f82672b8755 2199 data_u8[BNO055_SENSOR_DATA_LSB]));
gume 0:1f82672b8755 2200 } else {
gume 0:1f82672b8755 2201 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2202 }
gume 0:1f82672b8755 2203 }
gume 0:1f82672b8755 2204 return com_rslt;
gume 0:1f82672b8755 2205 }
gume 0:1f82672b8755 2206 /*!
gume 0:1f82672b8755 2207 * @brief This API reads Linear accel data xyz values
gume 0:1f82672b8755 2208 * from register 0x28 to 0x2D it is a six byte data
gume 0:1f82672b8755 2209 *
gume 0:1f82672b8755 2210 *
gume 0:1f82672b8755 2211 * @param linear_accel : The value of linear accel xyz data's
gume 0:1f82672b8755 2212 *
gume 0:1f82672b8755 2213 * Parameter | result
gume 0:1f82672b8755 2214 * --------- | -----------------
gume 0:1f82672b8755 2215 * x | The linear accel x data
gume 0:1f82672b8755 2216 * y | The linear accel y data
gume 0:1f82672b8755 2217 * z | The linear accel z data
gume 0:1f82672b8755 2218 *
gume 0:1f82672b8755 2219 *
gume 0:1f82672b8755 2220 * @return results of bus communication function
gume 0:1f82672b8755 2221 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 2222 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 2223 */
gume 0:1f82672b8755 2224 BNO055_RETURN_FUNCTION_TYPE bno055_read_linear_accel_xyz(
gume 0:1f82672b8755 2225 struct bno055_linear_accel_t *linear_accel)
gume 0:1f82672b8755 2226 {
gume 0:1f82672b8755 2227 /* Variable used to return value of
gume 0:1f82672b8755 2228 communication routine*/
gume 0:1f82672b8755 2229 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2230 /* Array holding the linear accel xyz value
gume 0:1f82672b8755 2231 data_u8[BNO055_SENSOR_DATA_XYZ_X_LSB] - x->LSB
gume 0:1f82672b8755 2232 data_u8[BNO055_SENSOR_DATA_XYZ_X_MSB] - x->MSB
gume 0:1f82672b8755 2233 data_u8[BNO055_SENSOR_DATA_XYZ_Y_LSB] - y->MSB
gume 0:1f82672b8755 2234 data_u8[BNO055_SENSOR_DATA_XYZ_Y_MSB] - y->MSB
gume 0:1f82672b8755 2235 data_u8[BNO055_SENSOR_DATA_XYZ_Z_LSB] - z->MSB
gume 0:1f82672b8755 2236 data_u8[BNO055_SENSOR_DATA_XYZ_Z_MSB] - z->MSB
gume 0:1f82672b8755 2237 */
gume 0:1f82672b8755 2238 u8 data_u8[BNO055_ACCEL_XYZ_DATA_SIZE] = {
gume 0:1f82672b8755 2239 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 2240 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 2241 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 2242 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 2243 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 2244 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 2245 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 2246 } else {
gume 0:1f82672b8755 2247 /*condition check for page, chip id is
gume 0:1f82672b8755 2248 available in the page zero*/
gume 0:1f82672b8755 2249 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 2250 /* Write the page zero*/
gume 0:1f82672b8755 2251 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 2252 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 2253 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 2254 /* Read the six byte value
gume 0:1f82672b8755 2255 of linear accel xyz data*/
gume 0:1f82672b8755 2256 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 2257 (p_bno055->dev_addr,
gume 0:1f82672b8755 2258 BNO055_LINEAR_ACCEL_DATA_X_LSB_VALUEX_REG,
gume 0:1f82672b8755 2259 data_u8, BNO055_ACCEL_XYZ_DATA_SIZE);
gume 0:1f82672b8755 2260 /* Data x*/
gume 0:1f82672b8755 2261 data_u8[BNO055_SENSOR_DATA_XYZ_X_LSB] =
gume 0:1f82672b8755 2262 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 2263 data_u8[BNO055_SENSOR_DATA_XYZ_X_LSB],
gume 0:1f82672b8755 2264 BNO055_LINEAR_ACCEL_DATA_X_LSB_VALUEX);
gume 0:1f82672b8755 2265 data_u8[BNO055_SENSOR_DATA_XYZ_X_MSB] =
gume 0:1f82672b8755 2266 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 2267 data_u8[BNO055_SENSOR_DATA_XYZ_X_MSB],
gume 0:1f82672b8755 2268 BNO055_LINEAR_ACCEL_DATA_X_MSB_VALUEX);
gume 0:1f82672b8755 2269 linear_accel->x = (s16)((((s32)
gume 0:1f82672b8755 2270 ((s8)data_u8[BNO055_SENSOR_DATA_XYZ_X_MSB])) <<
gume 0:1f82672b8755 2271 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 2272 | (data_u8[BNO055_SENSOR_DATA_XYZ_X_LSB]));
gume 0:1f82672b8755 2273 /* Data y*/
gume 0:1f82672b8755 2274 data_u8[BNO055_SENSOR_DATA_XYZ_Y_LSB] =
gume 0:1f82672b8755 2275 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 2276 data_u8[BNO055_SENSOR_DATA_XYZ_Y_LSB],
gume 0:1f82672b8755 2277 BNO055_LINEAR_ACCEL_DATA_Y_LSB_VALUEY);
gume 0:1f82672b8755 2278 data_u8[BNO055_SENSOR_DATA_XYZ_Y_MSB] =
gume 0:1f82672b8755 2279 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 2280 data_u8[BNO055_SENSOR_DATA_XYZ_Y_MSB],
gume 0:1f82672b8755 2281 BNO055_LINEAR_ACCEL_DATA_Y_MSB_VALUEY);
gume 0:1f82672b8755 2282 linear_accel->y = (s16)((((s32)
gume 0:1f82672b8755 2283 ((s8)data_u8[BNO055_SENSOR_DATA_XYZ_Y_MSB])) <<
gume 0:1f82672b8755 2284 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 2285 | (data_u8[BNO055_SENSOR_DATA_XYZ_Y_LSB]));
gume 0:1f82672b8755 2286 /* Data z*/
gume 0:1f82672b8755 2287 data_u8[BNO055_SENSOR_DATA_XYZ_Z_LSB] =
gume 0:1f82672b8755 2288 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 2289 data_u8[BNO055_SENSOR_DATA_XYZ_Z_LSB],
gume 0:1f82672b8755 2290 BNO055_LINEAR_ACCEL_DATA_Z_LSB_VALUEZ);
gume 0:1f82672b8755 2291 data_u8[BNO055_SENSOR_DATA_XYZ_Z_MSB] =
gume 0:1f82672b8755 2292 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 2293 data_u8[BNO055_SENSOR_DATA_XYZ_Z_MSB],
gume 0:1f82672b8755 2294 BNO055_LINEAR_ACCEL_DATA_Z_MSB_VALUEZ);
gume 0:1f82672b8755 2295 linear_accel->z = (s16)((((s32)
gume 0:1f82672b8755 2296 ((s8)data_u8[BNO055_SENSOR_DATA_XYZ_Z_MSB])) <<
gume 0:1f82672b8755 2297 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 2298 | (data_u8[BNO055_SENSOR_DATA_XYZ_Z_LSB]));
gume 0:1f82672b8755 2299 } else {
gume 0:1f82672b8755 2300 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2301 }
gume 0:1f82672b8755 2302 }
gume 0:1f82672b8755 2303 return com_rslt;
gume 0:1f82672b8755 2304 }
gume 0:1f82672b8755 2305 /*!
gume 0:1f82672b8755 2306 * @brief This API reads gravity data x values
gume 0:1f82672b8755 2307 * from register 0x2E and 0x2F it is a two byte data
gume 0:1f82672b8755 2308 *
gume 0:1f82672b8755 2309 * @param gravity_x_s16 : The raw x data
gume 0:1f82672b8755 2310 *
gume 0:1f82672b8755 2311 * @return results of bus communication function
gume 0:1f82672b8755 2312 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 2313 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 2314 *
gume 0:1f82672b8755 2315 *
gume 0:1f82672b8755 2316 */
gume 0:1f82672b8755 2317 BNO055_RETURN_FUNCTION_TYPE bno055_read_gravity_x(
gume 0:1f82672b8755 2318 s16 *gravity_x_s16)
gume 0:1f82672b8755 2319 {
gume 0:1f82672b8755 2320 /* Variable used to return value of
gume 0:1f82672b8755 2321 communication routine*/
gume 0:1f82672b8755 2322 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2323 /* Array holding the gravity x value
gume 0:1f82672b8755 2324 data_u8[BNO055_SENSOR_DATA_LSB] - x->LSB
gume 0:1f82672b8755 2325 data_u8[BNO055_SENSOR_DATA_MSB] - x->MSB
gume 0:1f82672b8755 2326 */
gume 0:1f82672b8755 2327 u8 data_u8[BNO055_GRAVITY_DATA_SIZE] = {
gume 0:1f82672b8755 2328 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 2329 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 2330 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 2331 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 2332 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 2333 } else {
gume 0:1f82672b8755 2334 /*condition check for page, chip id is
gume 0:1f82672b8755 2335 available in the page zero*/
gume 0:1f82672b8755 2336 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 2337 /* Write the page zero*/
gume 0:1f82672b8755 2338 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 2339 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 2340 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 2341 /* Read the two byte value
gume 0:1f82672b8755 2342 of gravity x data*/
gume 0:1f82672b8755 2343 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 2344 (p_bno055->dev_addr,
gume 0:1f82672b8755 2345 BNO055_GRAVITY_DATA_X_LSB_VALUEX_REG,
gume 0:1f82672b8755 2346 data_u8, BNO055_LSB_MSB_READ_LENGTH);
gume 0:1f82672b8755 2347 data_u8[BNO055_SENSOR_DATA_LSB] =
gume 0:1f82672b8755 2348 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_LSB],
gume 0:1f82672b8755 2349 BNO055_GRAVITY_DATA_X_LSB_VALUEX);
gume 0:1f82672b8755 2350 data_u8[BNO055_SENSOR_DATA_MSB] =
gume 0:1f82672b8755 2351 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_MSB],
gume 0:1f82672b8755 2352 BNO055_GRAVITY_DATA_X_MSB_VALUEX);
gume 0:1f82672b8755 2353 *gravity_x_s16 = (s16)((((s32)
gume 0:1f82672b8755 2354 ((s8)data_u8[BNO055_SENSOR_DATA_MSB])) <<
gume 0:1f82672b8755 2355 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 2356 | (data_u8[BNO055_SENSOR_DATA_LSB]));
gume 0:1f82672b8755 2357 } else {
gume 0:1f82672b8755 2358 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2359 }
gume 0:1f82672b8755 2360 }
gume 0:1f82672b8755 2361 return com_rslt;
gume 0:1f82672b8755 2362 }
gume 0:1f82672b8755 2363 /*!
gume 0:1f82672b8755 2364 * @brief This API reads gravity data y values
gume 0:1f82672b8755 2365 * from register 0x30 and 0x31 it is a two byte data
gume 0:1f82672b8755 2366 *
gume 0:1f82672b8755 2367 * @param gravity_y_s16 : The raw y data
gume 0:1f82672b8755 2368 *
gume 0:1f82672b8755 2369 * @return results of bus communication function
gume 0:1f82672b8755 2370 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 2371 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 2372 *
gume 0:1f82672b8755 2373 *
gume 0:1f82672b8755 2374 */
gume 0:1f82672b8755 2375 BNO055_RETURN_FUNCTION_TYPE bno055_read_gravity_y(
gume 0:1f82672b8755 2376 s16 *gravity_y_s16)
gume 0:1f82672b8755 2377 {
gume 0:1f82672b8755 2378 /* Variable used to return value of
gume 0:1f82672b8755 2379 communication routine*/
gume 0:1f82672b8755 2380 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2381 /* Array holding the gravity y value
gume 0:1f82672b8755 2382 data_u8[BNO055_SENSOR_DATA_LSB] - y->LSB
gume 0:1f82672b8755 2383 data_u8[BNO055_SENSOR_DATA_MSB] - y->MSB
gume 0:1f82672b8755 2384 */
gume 0:1f82672b8755 2385 u8 data_u8[BNO055_GRAVITY_DATA_SIZE] = {
gume 0:1f82672b8755 2386 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 2387 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 2388 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 2389 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 2390 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 2391 } else {
gume 0:1f82672b8755 2392 /*condition check for page, chip id is
gume 0:1f82672b8755 2393 available in the page zero*/
gume 0:1f82672b8755 2394 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 2395 /* Write the page zero*/
gume 0:1f82672b8755 2396 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 2397 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 2398 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 2399 /* Read the two byte value
gume 0:1f82672b8755 2400 of gravity y data*/
gume 0:1f82672b8755 2401 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 2402 (p_bno055->dev_addr,
gume 0:1f82672b8755 2403 BNO055_GRAVITY_DATA_Y_LSB_VALUEY_REG,
gume 0:1f82672b8755 2404 data_u8, BNO055_LSB_MSB_READ_LENGTH);
gume 0:1f82672b8755 2405 data_u8[BNO055_SENSOR_DATA_LSB] =
gume 0:1f82672b8755 2406 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_LSB],
gume 0:1f82672b8755 2407 BNO055_GRAVITY_DATA_Y_LSB_VALUEY);
gume 0:1f82672b8755 2408 data_u8[BNO055_SENSOR_DATA_MSB] =
gume 0:1f82672b8755 2409 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_MSB],
gume 0:1f82672b8755 2410 BNO055_GRAVITY_DATA_Y_MSB_VALUEY);
gume 0:1f82672b8755 2411 *gravity_y_s16 = (s16)((((s32)
gume 0:1f82672b8755 2412 ((s8)data_u8[BNO055_SENSOR_DATA_MSB])) <<
gume 0:1f82672b8755 2413 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 2414 | (data_u8[BNO055_SENSOR_DATA_LSB]));
gume 0:1f82672b8755 2415 } else {
gume 0:1f82672b8755 2416 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2417 }
gume 0:1f82672b8755 2418 }
gume 0:1f82672b8755 2419 return com_rslt;
gume 0:1f82672b8755 2420 }
gume 0:1f82672b8755 2421 /*!
gume 0:1f82672b8755 2422 * @brief This API reads gravity data z values
gume 0:1f82672b8755 2423 * from register 0x32 and 0x33 it is a two byte data
gume 0:1f82672b8755 2424 *
gume 0:1f82672b8755 2425 * @param gravity_z_s16 : The raw z data
gume 0:1f82672b8755 2426 *
gume 0:1f82672b8755 2427 * @return results of bus communication function
gume 0:1f82672b8755 2428 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 2429 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 2430 *
gume 0:1f82672b8755 2431 *
gume 0:1f82672b8755 2432 */
gume 0:1f82672b8755 2433 BNO055_RETURN_FUNCTION_TYPE bno055_read_gravity_z(
gume 0:1f82672b8755 2434 s16 *gravity_z_s16)
gume 0:1f82672b8755 2435 {
gume 0:1f82672b8755 2436 /* Variable used to return value of
gume 0:1f82672b8755 2437 communication routine*/
gume 0:1f82672b8755 2438 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2439 /* Array holding the gravity z value
gume 0:1f82672b8755 2440 data_u8[BNO055_SENSOR_DATA_LSB] - z->LSB
gume 0:1f82672b8755 2441 data_u8[BNO055_SENSOR_DATA_MSB] - z->MSB
gume 0:1f82672b8755 2442 */
gume 0:1f82672b8755 2443 u8 data_u8[BNO055_GRAVITY_DATA_SIZE] = {
gume 0:1f82672b8755 2444 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 2445 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 2446 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 2447 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 2448 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 2449 } else {
gume 0:1f82672b8755 2450 /*condition check for page, chip id is
gume 0:1f82672b8755 2451 available in the page zero*/
gume 0:1f82672b8755 2452 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 2453 /* Write the page zero*/
gume 0:1f82672b8755 2454 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 2455 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 2456 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 2457 /* Read the two byte value
gume 0:1f82672b8755 2458 of gravity z data*/
gume 0:1f82672b8755 2459 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 2460 (p_bno055->dev_addr,
gume 0:1f82672b8755 2461 BNO055_GRAVITY_DATA_Z_LSB_VALUEZ_REG,
gume 0:1f82672b8755 2462 data_u8, BNO055_LSB_MSB_READ_LENGTH);
gume 0:1f82672b8755 2463 data_u8[BNO055_SENSOR_DATA_LSB] =
gume 0:1f82672b8755 2464 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_LSB],
gume 0:1f82672b8755 2465 BNO055_GRAVITY_DATA_Z_LSB_VALUEZ);
gume 0:1f82672b8755 2466 data_u8[BNO055_SENSOR_DATA_MSB] =
gume 0:1f82672b8755 2467 BNO055_GET_BITSLICE(data_u8[BNO055_SENSOR_DATA_MSB],
gume 0:1f82672b8755 2468 BNO055_GRAVITY_DATA_Z_MSB_VALUEZ);
gume 0:1f82672b8755 2469 *gravity_z_s16 = (s16)((((s32)
gume 0:1f82672b8755 2470 ((s8)data_u8[BNO055_SENSOR_DATA_MSB])) <<
gume 0:1f82672b8755 2471 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 2472 | (data_u8[BNO055_SENSOR_DATA_LSB]));
gume 0:1f82672b8755 2473 } else {
gume 0:1f82672b8755 2474 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2475 }
gume 0:1f82672b8755 2476 }
gume 0:1f82672b8755 2477 return com_rslt;
gume 0:1f82672b8755 2478 }
gume 0:1f82672b8755 2479 /*!
gume 0:1f82672b8755 2480 * @brief This API reads gravity data xyz values
gume 0:1f82672b8755 2481 * from register 0x2E to 0x33 it is a six byte data
gume 0:1f82672b8755 2482 *
gume 0:1f82672b8755 2483 *
gume 0:1f82672b8755 2484 * @param gravity : The value of gravity xyz data's
gume 0:1f82672b8755 2485 *
gume 0:1f82672b8755 2486 * Parameter | result
gume 0:1f82672b8755 2487 * --------- | -----------------
gume 0:1f82672b8755 2488 * x | The gravity x data
gume 0:1f82672b8755 2489 * y | The gravity y data
gume 0:1f82672b8755 2490 * z | The gravity z data
gume 0:1f82672b8755 2491 *
gume 0:1f82672b8755 2492 *
gume 0:1f82672b8755 2493 * @return results of bus communication function
gume 0:1f82672b8755 2494 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 2495 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 2496 *
gume 0:1f82672b8755 2497 */
gume 0:1f82672b8755 2498 BNO055_RETURN_FUNCTION_TYPE bno055_read_gravity_xyz(
gume 0:1f82672b8755 2499 struct bno055_gravity_t *gravity)
gume 0:1f82672b8755 2500 {
gume 0:1f82672b8755 2501 /* Variable used to return value of
gume 0:1f82672b8755 2502 communication routine*/
gume 0:1f82672b8755 2503 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2504 /* Array holding the gravity xyz value
gume 0:1f82672b8755 2505 data_u8[BNO055_SENSOR_DATA_XYZ_X_LSB] - x->LSB
gume 0:1f82672b8755 2506 data_u8[BNO055_SENSOR_DATA_XYZ_X_MSB] - x->MSB
gume 0:1f82672b8755 2507 data_u8[BNO055_SENSOR_DATA_XYZ_Y_LSB] - y->MSB
gume 0:1f82672b8755 2508 data_u8[BNO055_SENSOR_DATA_XYZ_Y_MSB] - y->MSB
gume 0:1f82672b8755 2509 data_u8[BNO055_SENSOR_DATA_XYZ_Z_LSB] - z->MSB
gume 0:1f82672b8755 2510 data_u8[BNO055_SENSOR_DATA_XYZ_Z_MSB] - z->MSB
gume 0:1f82672b8755 2511 */
gume 0:1f82672b8755 2512 u8 data_u8[BNO055_GRAVITY_XYZ_DATA_SIZE] = {
gume 0:1f82672b8755 2513 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 2514 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 2515 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 2516 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 2517 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 2518 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 2519 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 2520 } else {
gume 0:1f82672b8755 2521 /*condition check for page, chip id is
gume 0:1f82672b8755 2522 available in the page zero*/
gume 0:1f82672b8755 2523 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 2524 /* Write the page zero*/
gume 0:1f82672b8755 2525 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 2526 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 2527 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 2528 /* Read the six byte value
gume 0:1f82672b8755 2529 of gravity xyz data*/
gume 0:1f82672b8755 2530 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 2531 (p_bno055->dev_addr,
gume 0:1f82672b8755 2532 BNO055_GRAVITY_DATA_X_LSB_VALUEX_REG,
gume 0:1f82672b8755 2533 data_u8, BNO055_GRAVITY_XYZ_DATA_SIZE);
gume 0:1f82672b8755 2534 /* Data x*/
gume 0:1f82672b8755 2535 data_u8[BNO055_SENSOR_DATA_XYZ_X_LSB] =
gume 0:1f82672b8755 2536 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 2537 data_u8[BNO055_SENSOR_DATA_XYZ_X_LSB],
gume 0:1f82672b8755 2538 BNO055_GRAVITY_DATA_X_LSB_VALUEX);
gume 0:1f82672b8755 2539 data_u8[BNO055_SENSOR_DATA_XYZ_X_MSB] =
gume 0:1f82672b8755 2540 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 2541 data_u8[BNO055_SENSOR_DATA_XYZ_X_MSB],
gume 0:1f82672b8755 2542 BNO055_GRAVITY_DATA_X_MSB_VALUEX);
gume 0:1f82672b8755 2543 gravity->x = (s16)(((s32)
gume 0:1f82672b8755 2544 ((s8)data_u8[BNO055_SENSOR_DATA_XYZ_X_MSB]) <<
gume 0:1f82672b8755 2545 BNO055_SHIFT_EIGHT_BITS) |
gume 0:1f82672b8755 2546 (data_u8[BNO055_SENSOR_DATA_XYZ_X_LSB]));
gume 0:1f82672b8755 2547 /* Data y*/
gume 0:1f82672b8755 2548 data_u8[BNO055_SENSOR_DATA_XYZ_Y_LSB] =
gume 0:1f82672b8755 2549 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 2550 data_u8[BNO055_SENSOR_DATA_XYZ_Y_LSB],
gume 0:1f82672b8755 2551 BNO055_GRAVITY_DATA_Y_LSB_VALUEY);
gume 0:1f82672b8755 2552 data_u8[BNO055_SENSOR_DATA_XYZ_Y_MSB] =
gume 0:1f82672b8755 2553 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 2554 data_u8[BNO055_SENSOR_DATA_XYZ_Y_MSB],
gume 0:1f82672b8755 2555 BNO055_GRAVITY_DATA_Y_MSB_VALUEY);
gume 0:1f82672b8755 2556 gravity->y = (s16)((((s32)
gume 0:1f82672b8755 2557 ((s8)data_u8[BNO055_SENSOR_DATA_XYZ_Y_MSB])) <<
gume 0:1f82672b8755 2558 BNO055_SHIFT_EIGHT_BITS) | (
gume 0:1f82672b8755 2559 data_u8[BNO055_SENSOR_DATA_XYZ_Y_LSB]));
gume 0:1f82672b8755 2560 /* Data z*/
gume 0:1f82672b8755 2561 data_u8[BNO055_SENSOR_DATA_XYZ_Z_LSB] =
gume 0:1f82672b8755 2562 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 2563 data_u8[BNO055_SENSOR_DATA_XYZ_Z_LSB],
gume 0:1f82672b8755 2564 BNO055_GRAVITY_DATA_Z_LSB_VALUEZ);
gume 0:1f82672b8755 2565 data_u8[BNO055_SENSOR_DATA_XYZ_Z_MSB] =
gume 0:1f82672b8755 2566 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 2567 data_u8[BNO055_SENSOR_DATA_XYZ_Z_MSB],
gume 0:1f82672b8755 2568 BNO055_GRAVITY_DATA_Z_MSB_VALUEZ);
gume 0:1f82672b8755 2569 gravity->z = (s16)((((s32)
gume 0:1f82672b8755 2570 ((s8)data_u8[BNO055_SENSOR_DATA_XYZ_Z_MSB])) <<
gume 0:1f82672b8755 2571 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 2572 | (data_u8[BNO055_SENSOR_DATA_XYZ_Z_LSB]));
gume 0:1f82672b8755 2573 } else {
gume 0:1f82672b8755 2574 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2575 }
gume 0:1f82672b8755 2576 }
gume 0:1f82672b8755 2577 return com_rslt;
gume 0:1f82672b8755 2578 }
gume 0:1f82672b8755 2579 /*!
gume 0:1f82672b8755 2580 * @brief This API reads temperature values
gume 0:1f82672b8755 2581 * from register 0x33 it is a byte data
gume 0:1f82672b8755 2582 *
gume 0:1f82672b8755 2583 * @param temp_s8 : The raw temperature data
gume 0:1f82672b8755 2584 *
gume 0:1f82672b8755 2585 * @return results of bus communication function
gume 0:1f82672b8755 2586 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 2587 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 2588 *
gume 0:1f82672b8755 2589 *
gume 0:1f82672b8755 2590 */
gume 0:1f82672b8755 2591 BNO055_RETURN_FUNCTION_TYPE bno055_read_temp_data(s8 *temp_s8)
gume 0:1f82672b8755 2592 {
gume 0:1f82672b8755 2593 /* Variable used to return value of
gume 0:1f82672b8755 2594 communication routine*/
gume 0:1f82672b8755 2595 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2596 u8 data_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 2597 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 2598 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 2599 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 2600 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 2601 } else {
gume 0:1f82672b8755 2602 /*condition check for page, chip id is
gume 0:1f82672b8755 2603 available in the page zero*/
gume 0:1f82672b8755 2604 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 2605 /* Write the page zero*/
gume 0:1f82672b8755 2606 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 2607 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 2608 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 2609 /* Read the raw temperature data */
gume 0:1f82672b8755 2610 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 2611 (p_bno055->dev_addr,
gume 0:1f82672b8755 2612 BNO055_TEMP_REG, &data_u8,
gume 0:1f82672b8755 2613 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 2614 *temp_s8 = data_u8;
gume 0:1f82672b8755 2615 } else {
gume 0:1f82672b8755 2616 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2617 }
gume 0:1f82672b8755 2618 }
gume 0:1f82672b8755 2619 return com_rslt;
gume 0:1f82672b8755 2620 }
gume 0:1f82672b8755 2621 #ifdef BNO055_FLOAT_ENABLE
gume 0:1f82672b8755 2622 /*!
gume 0:1f82672b8755 2623 * @brief This API is used to convert the accel x raw data
gume 0:1f82672b8755 2624 * to meterpersecseq output as float
gume 0:1f82672b8755 2625 *
gume 0:1f82672b8755 2626 * @param accel_x_f : The accel x meterpersecseq data
gume 0:1f82672b8755 2627 *
gume 0:1f82672b8755 2628 *
gume 0:1f82672b8755 2629 *
gume 0:1f82672b8755 2630 * @return results of bus communication function
gume 0:1f82672b8755 2631 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 2632 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 2633 *
gume 0:1f82672b8755 2634 *
gume 0:1f82672b8755 2635 */
gume 0:1f82672b8755 2636 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_accel_x_msq(
gume 0:1f82672b8755 2637 float *accel_x_f)
gume 0:1f82672b8755 2638 {
gume 0:1f82672b8755 2639 /* Variable used to return value of
gume 0:1f82672b8755 2640 communication routine*/
gume 0:1f82672b8755 2641 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2642 s16 reg_accel_x_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 2643 float data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 2644 u8 accel_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 2645 /* Read the current accel unit and set the
gume 0:1f82672b8755 2646 unit as m/s2 if the unit is in mg*/
gume 0:1f82672b8755 2647 com_rslt = bno055_get_accel_unit(&accel_unit_u8);
gume 0:1f82672b8755 2648 if (accel_unit_u8 != BNO055_ACCEL_UNIT_MSQ)
gume 0:1f82672b8755 2649 com_rslt += bno055_set_accel_unit(BNO055_ACCEL_UNIT_MSQ);
gume 0:1f82672b8755 2650 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 2651 /* Read the accel raw x data*/
gume 0:1f82672b8755 2652 com_rslt += bno055_read_accel_x(&reg_accel_x_s16);
gume 0:1f82672b8755 2653 p_bno055->delay_msec(BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 2654 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 2655 /* Convert the raw accel x to m/s2*/
gume 0:1f82672b8755 2656 data_f =
gume 0:1f82672b8755 2657 (float)(reg_accel_x_s16/BNO055_ACCEL_DIV_MSQ);
gume 0:1f82672b8755 2658 *accel_x_f = data_f;
gume 0:1f82672b8755 2659 } else {
gume 0:1f82672b8755 2660 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2661 }
gume 0:1f82672b8755 2662 } else {
gume 0:1f82672b8755 2663 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2664 }
gume 0:1f82672b8755 2665 return com_rslt;
gume 0:1f82672b8755 2666 }
gume 0:1f82672b8755 2667 /*!
gume 0:1f82672b8755 2668 * @brief This API is used to convert the accel x raw data
gume 0:1f82672b8755 2669 * to millig output as float
gume 0:1f82672b8755 2670 *
gume 0:1f82672b8755 2671 * @param accel_x_f : The accel x millig data
gume 0:1f82672b8755 2672 *
gume 0:1f82672b8755 2673 *
gume 0:1f82672b8755 2674 *
gume 0:1f82672b8755 2675 * @return results of bus communication function
gume 0:1f82672b8755 2676 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 2677 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 2678 *
gume 0:1f82672b8755 2679 *
gume 0:1f82672b8755 2680 *
gume 0:1f82672b8755 2681 */
gume 0:1f82672b8755 2682 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_accel_x_mg(
gume 0:1f82672b8755 2683 float *accel_x_f)
gume 0:1f82672b8755 2684 {
gume 0:1f82672b8755 2685 /* Variable used to return value of
gume 0:1f82672b8755 2686 communication routine*/
gume 0:1f82672b8755 2687 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2688 s16 reg_accel_x_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 2689 float data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 2690 u8 accel_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 2691 /* Read the current accel unit and set the
gume 0:1f82672b8755 2692 unit as mg if the unit is in m/s2*/
gume 0:1f82672b8755 2693 com_rslt = bno055_get_accel_unit(&accel_unit_u8);
gume 0:1f82672b8755 2694 if (accel_unit_u8 != BNO055_ACCEL_UNIT_MG)
gume 0:1f82672b8755 2695 com_rslt += bno055_set_accel_unit(BNO055_ACCEL_UNIT_MG);
gume 0:1f82672b8755 2696 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 2697 /* Read the accel raw x data*/
gume 0:1f82672b8755 2698 com_rslt += bno055_read_accel_x(&reg_accel_x_s16);
gume 0:1f82672b8755 2699 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 2700 /* Convert the raw accel x to m/s2*/
gume 0:1f82672b8755 2701 data_f =
gume 0:1f82672b8755 2702 (float)(reg_accel_x_s16/BNO055_ACCEL_DIV_MG);
gume 0:1f82672b8755 2703 *accel_x_f = data_f;
gume 0:1f82672b8755 2704 } else {
gume 0:1f82672b8755 2705 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2706 }
gume 0:1f82672b8755 2707 } else {
gume 0:1f82672b8755 2708 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2709 }
gume 0:1f82672b8755 2710 return com_rslt;
gume 0:1f82672b8755 2711 }
gume 0:1f82672b8755 2712 /*!
gume 0:1f82672b8755 2713 * @brief This API is used to convert the accel x raw data
gume 0:1f82672b8755 2714 * to meterpersecseq output as float
gume 0:1f82672b8755 2715 *
gume 0:1f82672b8755 2716 * @param accel_y_f : The accel y meterpersecseq data
gume 0:1f82672b8755 2717 *
gume 0:1f82672b8755 2718 *
gume 0:1f82672b8755 2719 *
gume 0:1f82672b8755 2720 * @return results of bus communication function
gume 0:1f82672b8755 2721 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 2722 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 2723 *
gume 0:1f82672b8755 2724 *
gume 0:1f82672b8755 2725 */
gume 0:1f82672b8755 2726 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_accel_y_msq(
gume 0:1f82672b8755 2727 float *accel_y_f)
gume 0:1f82672b8755 2728 {
gume 0:1f82672b8755 2729 /* Variable used to return value of
gume 0:1f82672b8755 2730 communication routine*/
gume 0:1f82672b8755 2731 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2732 s16 reg_accel_y_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 2733 float data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 2734 u8 accel_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 2735 /* Read the current accel unit and set the
gume 0:1f82672b8755 2736 unit as m/s2 if the unit is in mg*/
gume 0:1f82672b8755 2737 com_rslt = bno055_get_accel_unit(&accel_unit_u8);
gume 0:1f82672b8755 2738 if (accel_unit_u8 != BNO055_ACCEL_UNIT_MSQ)
gume 0:1f82672b8755 2739 com_rslt += bno055_set_accel_unit(BNO055_ACCEL_UNIT_MSQ);
gume 0:1f82672b8755 2740 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 2741 com_rslt += bno055_read_accel_y(&reg_accel_y_s16);
gume 0:1f82672b8755 2742 p_bno055->delay_msec(BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 2743 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 2744 /* Convert the raw accel y to m/s2*/
gume 0:1f82672b8755 2745 data_f =
gume 0:1f82672b8755 2746 (float)(reg_accel_y_s16/BNO055_ACCEL_DIV_MSQ);
gume 0:1f82672b8755 2747 *accel_y_f = data_f;
gume 0:1f82672b8755 2748 } else {
gume 0:1f82672b8755 2749 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2750 }
gume 0:1f82672b8755 2751 } else {
gume 0:1f82672b8755 2752 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2753 }
gume 0:1f82672b8755 2754 return com_rslt;
gume 0:1f82672b8755 2755 }
gume 0:1f82672b8755 2756 /*!
gume 0:1f82672b8755 2757 * @brief This API is used to convert the accel y raw data
gume 0:1f82672b8755 2758 * to millig output as float
gume 0:1f82672b8755 2759 *
gume 0:1f82672b8755 2760 * @param accel_y_f : The accel y millig data
gume 0:1f82672b8755 2761 *
gume 0:1f82672b8755 2762 *
gume 0:1f82672b8755 2763 *
gume 0:1f82672b8755 2764 * @return results of bus communication function
gume 0:1f82672b8755 2765 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 2766 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 2767 *
gume 0:1f82672b8755 2768 */
gume 0:1f82672b8755 2769 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_accel_y_mg(
gume 0:1f82672b8755 2770 float *accel_y_f)
gume 0:1f82672b8755 2771 {
gume 0:1f82672b8755 2772 /* Variable used to return value of
gume 0:1f82672b8755 2773 communication routine*/
gume 0:1f82672b8755 2774 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2775 s16 reg_accel_y_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 2776 float data = BNO055_INIT_VALUE;
gume 0:1f82672b8755 2777 u8 accel_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 2778 /* Read the current accel unit and set the
gume 0:1f82672b8755 2779 unit as mg if the unit is in m/s2*/
gume 0:1f82672b8755 2780 com_rslt = bno055_get_accel_unit(&accel_unit_u8);
gume 0:1f82672b8755 2781 if (accel_unit_u8 != BNO055_ACCEL_UNIT_MG)
gume 0:1f82672b8755 2782 com_rslt += bno055_set_accel_unit(BNO055_ACCEL_UNIT_MG);
gume 0:1f82672b8755 2783 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 2784 /* Read the accel raw z data*/
gume 0:1f82672b8755 2785 com_rslt += bno055_read_accel_y(&reg_accel_y_s16);
gume 0:1f82672b8755 2786 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 2787 /* Convert the raw accel z to mg*/
gume 0:1f82672b8755 2788 data = (float)(
gume 0:1f82672b8755 2789 reg_accel_y_s16/BNO055_ACCEL_DIV_MG);
gume 0:1f82672b8755 2790 *accel_y_f = data;
gume 0:1f82672b8755 2791 } else {
gume 0:1f82672b8755 2792 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2793 }
gume 0:1f82672b8755 2794 } else {
gume 0:1f82672b8755 2795 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2796 }
gume 0:1f82672b8755 2797 return com_rslt;
gume 0:1f82672b8755 2798 }
gume 0:1f82672b8755 2799 /*!
gume 0:1f82672b8755 2800 * @brief This API is used to convert the accel z raw data
gume 0:1f82672b8755 2801 * to meterpersecseq output as float
gume 0:1f82672b8755 2802 *
gume 0:1f82672b8755 2803 * @param accel_z_f : The accel z meterpersecseq data
gume 0:1f82672b8755 2804 *
gume 0:1f82672b8755 2805 *
gume 0:1f82672b8755 2806 *
gume 0:1f82672b8755 2807 * @return results of bus communication function
gume 0:1f82672b8755 2808 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 2809 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 2810 *
gume 0:1f82672b8755 2811 *
gume 0:1f82672b8755 2812 */
gume 0:1f82672b8755 2813 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_accel_z_msq(
gume 0:1f82672b8755 2814 float *accel_z_f)
gume 0:1f82672b8755 2815 {
gume 0:1f82672b8755 2816 /* Variable used to return value of
gume 0:1f82672b8755 2817 communication routine*/
gume 0:1f82672b8755 2818 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2819 s16 reg_accel_z_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 2820 float data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 2821 u8 accel_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 2822 /* Read the current accel unit and set the
gume 0:1f82672b8755 2823 unit as m/s2 if the unit is in mg*/
gume 0:1f82672b8755 2824 com_rslt = bno055_get_accel_unit(&accel_unit_u8);
gume 0:1f82672b8755 2825 if (accel_unit_u8 != BNO055_ACCEL_UNIT_MSQ)
gume 0:1f82672b8755 2826 com_rslt += bno055_set_accel_unit(BNO055_ACCEL_UNIT_MSQ);
gume 0:1f82672b8755 2827 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 2828 /* Read the accel raw z data*/
gume 0:1f82672b8755 2829 com_rslt += bno055_read_accel_z(&reg_accel_z_s16);
gume 0:1f82672b8755 2830 p_bno055->delay_msec(BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 2831 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 2832 /* Convert the raw accel z to m/s2*/
gume 0:1f82672b8755 2833 data_f =
gume 0:1f82672b8755 2834 (float)(reg_accel_z_s16/BNO055_ACCEL_DIV_MSQ);
gume 0:1f82672b8755 2835 *accel_z_f = data_f;
gume 0:1f82672b8755 2836 } else {
gume 0:1f82672b8755 2837 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2838 }
gume 0:1f82672b8755 2839 } else {
gume 0:1f82672b8755 2840 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2841 }
gume 0:1f82672b8755 2842 return com_rslt;
gume 0:1f82672b8755 2843 }
gume 0:1f82672b8755 2844 /*!
gume 0:1f82672b8755 2845 * @brief This API is used to convert the accel z raw data
gume 0:1f82672b8755 2846 * to millig output as float
gume 0:1f82672b8755 2847 *
gume 0:1f82672b8755 2848 * @param accel_z_f : The accel z millig data
gume 0:1f82672b8755 2849 *
gume 0:1f82672b8755 2850 *
gume 0:1f82672b8755 2851 *
gume 0:1f82672b8755 2852 * @return results of bus communication function
gume 0:1f82672b8755 2853 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 2854 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 2855 *
gume 0:1f82672b8755 2856 *
gume 0:1f82672b8755 2857 */
gume 0:1f82672b8755 2858 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_accel_z_mg(
gume 0:1f82672b8755 2859 float *accel_z_f)
gume 0:1f82672b8755 2860 {
gume 0:1f82672b8755 2861 /* Variable used to return value of
gume 0:1f82672b8755 2862 communication routine*/
gume 0:1f82672b8755 2863 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2864 s16 reg_accel_z_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 2865 float data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 2866 u8 accel_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 2867 /* Read the current accel unit and set the
gume 0:1f82672b8755 2868 unit as mg if the unit is in m/s2 */
gume 0:1f82672b8755 2869 com_rslt = bno055_get_accel_unit(&accel_unit_u8);
gume 0:1f82672b8755 2870 if (accel_unit_u8 != BNO055_ACCEL_UNIT_MG)
gume 0:1f82672b8755 2871 com_rslt += bno055_set_accel_unit(BNO055_ACCEL_UNIT_MG);
gume 0:1f82672b8755 2872 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 2873 /* Read the accel raw z data*/
gume 0:1f82672b8755 2874 com_rslt += bno055_read_accel_z(&reg_accel_z_s16);
gume 0:1f82672b8755 2875 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 2876 /* Convert the raw accel x to mg*/
gume 0:1f82672b8755 2877 data_f =
gume 0:1f82672b8755 2878 (float)(reg_accel_z_s16/BNO055_ACCEL_DIV_MG);
gume 0:1f82672b8755 2879 *accel_z_f = data_f;
gume 0:1f82672b8755 2880 } else {
gume 0:1f82672b8755 2881 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2882 }
gume 0:1f82672b8755 2883 } else {
gume 0:1f82672b8755 2884 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2885 }
gume 0:1f82672b8755 2886 return com_rslt;
gume 0:1f82672b8755 2887 }
gume 0:1f82672b8755 2888 /*!
gume 0:1f82672b8755 2889 * @brief This API is used to convert the accel xyz raw data
gume 0:1f82672b8755 2890 * to meterpersecseq output as float
gume 0:1f82672b8755 2891 *
gume 0:1f82672b8755 2892 * @param accel_xyz : The meterpersecseq data of accel xyz
gume 0:1f82672b8755 2893 *
gume 0:1f82672b8755 2894 * Parameter | result
gume 0:1f82672b8755 2895 * --------- | -----------------
gume 0:1f82672b8755 2896 * x | meterpersecseq data of accel
gume 0:1f82672b8755 2897 * y | meterpersecseq data of accel
gume 0:1f82672b8755 2898 * z | meterpersecseq data of accel
gume 0:1f82672b8755 2899 *
gume 0:1f82672b8755 2900 * @return results of bus communication function
gume 0:1f82672b8755 2901 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 2902 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 2903 *
gume 0:1f82672b8755 2904 *
gume 0:1f82672b8755 2905 */
gume 0:1f82672b8755 2906 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_accel_xyz_msq(
gume 0:1f82672b8755 2907 struct bno055_accel_float_t *accel_xyz)
gume 0:1f82672b8755 2908 {
gume 0:1f82672b8755 2909 /* Variable used to return value of
gume 0:1f82672b8755 2910 communication routine*/
gume 0:1f82672b8755 2911 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2912 struct bno055_accel_t reg_accel_xyz = {
gume 0:1f82672b8755 2913 BNO055_INIT_VALUE, BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 2914 u8 accel_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 2915 /* Read the current accel unit and set the
gume 0:1f82672b8755 2916 unit as m/s2 if the unit is in mg*/
gume 0:1f82672b8755 2917 com_rslt = bno055_get_accel_unit(&accel_unit_u8);
gume 0:1f82672b8755 2918 if (accel_unit_u8 != BNO055_ACCEL_UNIT_MSQ)
gume 0:1f82672b8755 2919 com_rslt += bno055_set_accel_unit(BNO055_ACCEL_UNIT_MSQ);
gume 0:1f82672b8755 2920 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 2921 /* Read the accel raw xyz data*/
gume 0:1f82672b8755 2922 com_rslt += bno055_read_accel_xyz(&reg_accel_xyz);
gume 0:1f82672b8755 2923 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 2924 /* Convert the accel raw xyz to meterpersecseq*/
gume 0:1f82672b8755 2925 accel_xyz->x =
gume 0:1f82672b8755 2926 (float)(reg_accel_xyz.x/BNO055_ACCEL_DIV_MSQ);
gume 0:1f82672b8755 2927 accel_xyz->y =
gume 0:1f82672b8755 2928 (float)(reg_accel_xyz.y/BNO055_ACCEL_DIV_MSQ);
gume 0:1f82672b8755 2929 accel_xyz->z =
gume 0:1f82672b8755 2930 (float)(reg_accel_xyz.z/BNO055_ACCEL_DIV_MSQ);
gume 0:1f82672b8755 2931 } else {
gume 0:1f82672b8755 2932 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2933 }
gume 0:1f82672b8755 2934 } else {
gume 0:1f82672b8755 2935 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2936 }
gume 0:1f82672b8755 2937 return com_rslt;
gume 0:1f82672b8755 2938 }
gume 0:1f82672b8755 2939 /*!
gume 0:1f82672b8755 2940 * @brief This API is used to convert the accel xyz raw data
gume 0:1f82672b8755 2941 * to millig output as float
gume 0:1f82672b8755 2942 *
gume 0:1f82672b8755 2943 * @param accel_xyz : The millig data of accel xyz
gume 0:1f82672b8755 2944 *
gume 0:1f82672b8755 2945 * Parameter | result
gume 0:1f82672b8755 2946 * --------- | -----------------
gume 0:1f82672b8755 2947 * x | millig data of accel
gume 0:1f82672b8755 2948 * y | millig data of accel
gume 0:1f82672b8755 2949 * z | millig data of accel
gume 0:1f82672b8755 2950 *
gume 0:1f82672b8755 2951 *
gume 0:1f82672b8755 2952 * @return results of bus communication function
gume 0:1f82672b8755 2953 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 2954 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 2955 *
gume 0:1f82672b8755 2956 *
gume 0:1f82672b8755 2957 */
gume 0:1f82672b8755 2958 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_accel_xyz_mg(
gume 0:1f82672b8755 2959 struct bno055_accel_float_t *accel_xyz)
gume 0:1f82672b8755 2960 {
gume 0:1f82672b8755 2961 /* Variable used to return value of
gume 0:1f82672b8755 2962 communication routine*/
gume 0:1f82672b8755 2963 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2964 struct bno055_accel_t reg_accel_xyz = {
gume 0:1f82672b8755 2965 BNO055_INIT_VALUE, BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 2966 u8 accel_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 2967 /* Read the current accel unit and set the
gume 0:1f82672b8755 2968 unit as mg if the unit is in m/s2*/
gume 0:1f82672b8755 2969 com_rslt = bno055_get_accel_unit(&accel_unit_u8);
gume 0:1f82672b8755 2970 if (accel_unit_u8 != BNO055_ACCEL_UNIT_MG)
gume 0:1f82672b8755 2971 com_rslt += bno055_set_accel_unit(BNO055_ACCEL_UNIT_MG);
gume 0:1f82672b8755 2972 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 2973 /* Read the accel raw y data*/
gume 0:1f82672b8755 2974 com_rslt += bno055_read_accel_xyz(&reg_accel_xyz);
gume 0:1f82672b8755 2975 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 2976 /*Convert the accel raw xyz to millig */
gume 0:1f82672b8755 2977 accel_xyz->x =
gume 0:1f82672b8755 2978 (float)(reg_accel_xyz.x/BNO055_ACCEL_DIV_MG);
gume 0:1f82672b8755 2979 accel_xyz->y =
gume 0:1f82672b8755 2980 (float)(reg_accel_xyz.y/BNO055_ACCEL_DIV_MG);
gume 0:1f82672b8755 2981 accel_xyz->z =
gume 0:1f82672b8755 2982 (float)(reg_accel_xyz.z/BNO055_ACCEL_DIV_MG);
gume 0:1f82672b8755 2983 } else {
gume 0:1f82672b8755 2984 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2985 }
gume 0:1f82672b8755 2986 } else {
gume 0:1f82672b8755 2987 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 2988 }
gume 0:1f82672b8755 2989 return com_rslt;
gume 0:1f82672b8755 2990 }
gume 0:1f82672b8755 2991 /*!
gume 0:1f82672b8755 2992 * @brief This API is used to convert the mag x raw data
gume 0:1f82672b8755 2993 * to microTesla output as float
gume 0:1f82672b8755 2994 *
gume 0:1f82672b8755 2995 * @param mag_x_f : The mag x microTesla data
gume 0:1f82672b8755 2996 *
gume 0:1f82672b8755 2997 *
gume 0:1f82672b8755 2998 *
gume 0:1f82672b8755 2999 * @return results of bus communication function
gume 0:1f82672b8755 3000 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 3001 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 3002 *
gume 0:1f82672b8755 3003 *
gume 0:1f82672b8755 3004 */
gume 0:1f82672b8755 3005 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_mag_x_uT(
gume 0:1f82672b8755 3006 float *mag_x_f)
gume 0:1f82672b8755 3007 {
gume 0:1f82672b8755 3008 /* Variable used to return value of
gume 0:1f82672b8755 3009 communication routine*/
gume 0:1f82672b8755 3010 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3011 s16 reg_mag_x_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3012 float data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3013 /* Read raw mag x data */
gume 0:1f82672b8755 3014 com_rslt = bno055_read_mag_x(&reg_mag_x_s16);
gume 0:1f82672b8755 3015 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3016 /* Convert the raw mag x to microTesla*/
gume 0:1f82672b8755 3017 data_f = (float)(reg_mag_x_s16/BNO055_MAG_DIV_UT);
gume 0:1f82672b8755 3018 *mag_x_f = data_f;
gume 0:1f82672b8755 3019 } else {
gume 0:1f82672b8755 3020 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3021 }
gume 0:1f82672b8755 3022 return com_rslt;
gume 0:1f82672b8755 3023 }
gume 0:1f82672b8755 3024 /*!
gume 0:1f82672b8755 3025 * @brief This API is used to convert the mag y raw data
gume 0:1f82672b8755 3026 * to microTesla output as float
gume 0:1f82672b8755 3027 *
gume 0:1f82672b8755 3028 * @param mag_y_f : The mag y microTesla data
gume 0:1f82672b8755 3029 *
gume 0:1f82672b8755 3030 *
gume 0:1f82672b8755 3031 *
gume 0:1f82672b8755 3032 * @return results of bus communication function
gume 0:1f82672b8755 3033 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 3034 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 3035 *
gume 0:1f82672b8755 3036 */
gume 0:1f82672b8755 3037 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_mag_y_uT(
gume 0:1f82672b8755 3038 float *mag_y_f)
gume 0:1f82672b8755 3039 {
gume 0:1f82672b8755 3040 /* Variable used to return value of
gume 0:1f82672b8755 3041 communication routine*/
gume 0:1f82672b8755 3042 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3043 s16 reg_mag_y_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3044 float data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3045 /* Read raw mag y data */
gume 0:1f82672b8755 3046 com_rslt = bno055_read_mag_y(&reg_mag_y_s16);
gume 0:1f82672b8755 3047 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3048 /* Convert the raw mag y to microTesla*/
gume 0:1f82672b8755 3049 data_f = (float)(reg_mag_y_s16/BNO055_MAG_DIV_UT);
gume 0:1f82672b8755 3050 *mag_y_f = data_f;
gume 0:1f82672b8755 3051 } else {
gume 0:1f82672b8755 3052 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3053 }
gume 0:1f82672b8755 3054 return com_rslt;
gume 0:1f82672b8755 3055 }
gume 0:1f82672b8755 3056 /*!
gume 0:1f82672b8755 3057 * @brief This API is used to convert the mag z raw data
gume 0:1f82672b8755 3058 * to microTesla output as float
gume 0:1f82672b8755 3059 *
gume 0:1f82672b8755 3060 * @param mag_z_f : The mag z microTesla data
gume 0:1f82672b8755 3061 *
gume 0:1f82672b8755 3062 *
gume 0:1f82672b8755 3063 *
gume 0:1f82672b8755 3064 * @return results of bus communication function
gume 0:1f82672b8755 3065 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 3066 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 3067 *
gume 0:1f82672b8755 3068 */
gume 0:1f82672b8755 3069 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_mag_z_uT(
gume 0:1f82672b8755 3070 float *mag_z_f)
gume 0:1f82672b8755 3071 {
gume 0:1f82672b8755 3072 /* Variable used to return value of
gume 0:1f82672b8755 3073 communication routine*/
gume 0:1f82672b8755 3074 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3075 s16 reg_mag_z_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3076 float data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3077 /* Read raw mag z data */
gume 0:1f82672b8755 3078 com_rslt = bno055_read_mag_z(&reg_mag_z_s16);
gume 0:1f82672b8755 3079 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3080 /* Convert the raw mag z to microTesla*/
gume 0:1f82672b8755 3081 data_f = (float)(reg_mag_z_s16/BNO055_MAG_DIV_UT);
gume 0:1f82672b8755 3082 *mag_z_f = data_f;
gume 0:1f82672b8755 3083 } else {
gume 0:1f82672b8755 3084 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3085 }
gume 0:1f82672b8755 3086 return com_rslt;
gume 0:1f82672b8755 3087 }
gume 0:1f82672b8755 3088 /*!
gume 0:1f82672b8755 3089 * @brief This API is used to convert the mag yz raw data
gume 0:1f82672b8755 3090 * to microTesla output as float
gume 0:1f82672b8755 3091 *
gume 0:1f82672b8755 3092 * @param mag_xyz_data : The microTesla data of mag xyz
gume 0:1f82672b8755 3093 *
gume 0:1f82672b8755 3094 * Parameter | result
gume 0:1f82672b8755 3095 * --------- | -----------------
gume 0:1f82672b8755 3096 * x | microTesla data of mag
gume 0:1f82672b8755 3097 * y | microTesla data of mag
gume 0:1f82672b8755 3098 * z | microTesla data of mag
gume 0:1f82672b8755 3099 *
gume 0:1f82672b8755 3100 *
gume 0:1f82672b8755 3101 * @return results of bus communication function
gume 0:1f82672b8755 3102 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 3103 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 3104 *
gume 0:1f82672b8755 3105 */
gume 0:1f82672b8755 3106 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_mag_xyz_uT(
gume 0:1f82672b8755 3107 struct bno055_mag_float_t *mag_xyz_data)
gume 0:1f82672b8755 3108 {
gume 0:1f82672b8755 3109 /* Variable used to return value of
gume 0:1f82672b8755 3110 communication routine*/
gume 0:1f82672b8755 3111 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3112 struct bno055_mag_t mag_xyz = {
gume 0:1f82672b8755 3113 BNO055_INIT_VALUE, BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 3114 /* Read raw mag x data */
gume 0:1f82672b8755 3115 com_rslt = bno055_read_mag_xyz(&mag_xyz);
gume 0:1f82672b8755 3116 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3117 /* Convert mag raw xyz to microTesla*/
gume 0:1f82672b8755 3118 mag_xyz_data->x = (float)(mag_xyz.x/BNO055_MAG_DIV_UT);
gume 0:1f82672b8755 3119 mag_xyz_data->y = (float)(mag_xyz.y/BNO055_MAG_DIV_UT);
gume 0:1f82672b8755 3120 mag_xyz_data->z = (float)(mag_xyz.z/BNO055_MAG_DIV_UT);
gume 0:1f82672b8755 3121 } else {
gume 0:1f82672b8755 3122 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3123 }
gume 0:1f82672b8755 3124
gume 0:1f82672b8755 3125 return com_rslt;
gume 0:1f82672b8755 3126 }
gume 0:1f82672b8755 3127 /*!
gume 0:1f82672b8755 3128 * @brief This API is used to convert the gyro x raw data
gume 0:1f82672b8755 3129 * to dps output as float
gume 0:1f82672b8755 3130 *
gume 0:1f82672b8755 3131 * @param gyro_x_f : The gyro x dps float data
gume 0:1f82672b8755 3132 *
gume 0:1f82672b8755 3133 *
gume 0:1f82672b8755 3134 *
gume 0:1f82672b8755 3135 * @return results of bus communication function
gume 0:1f82672b8755 3136 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 3137 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 3138 */
gume 0:1f82672b8755 3139 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_gyro_x_dps(
gume 0:1f82672b8755 3140 float *gyro_x_f)
gume 0:1f82672b8755 3141 {
gume 0:1f82672b8755 3142 /* Variable used to return value of
gume 0:1f82672b8755 3143 communication routine*/
gume 0:1f82672b8755 3144 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3145 s16 reg_gyro_x_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3146 float data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3147 u8 gyro_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3148 /* Read the current gyro unit and set the
gume 0:1f82672b8755 3149 unit as dps if the unit is in rps */
gume 0:1f82672b8755 3150 com_rslt = bno055_get_gyro_unit(&gyro_unit_u8);
gume 0:1f82672b8755 3151 if (gyro_unit_u8 != BNO055_GYRO_UNIT_DPS)
gume 0:1f82672b8755 3152 com_rslt += bno055_set_gyro_unit(BNO055_GYRO_UNIT_DPS);
gume 0:1f82672b8755 3153 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3154 /* Read gyro raw x data */
gume 0:1f82672b8755 3155 com_rslt += bno055_read_gyro_x(&reg_gyro_x_s16);
gume 0:1f82672b8755 3156 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3157 /* Convert the raw gyro x to dps*/
gume 0:1f82672b8755 3158 data_f =
gume 0:1f82672b8755 3159 (float)(reg_gyro_x_s16/BNO055_GYRO_DIV_DPS);
gume 0:1f82672b8755 3160 *gyro_x_f = data_f;
gume 0:1f82672b8755 3161 } else {
gume 0:1f82672b8755 3162 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3163 }
gume 0:1f82672b8755 3164 } else {
gume 0:1f82672b8755 3165 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3166 }
gume 0:1f82672b8755 3167 return com_rslt;
gume 0:1f82672b8755 3168 }
gume 0:1f82672b8755 3169 /*!
gume 0:1f82672b8755 3170 * @brief This API is used to convert the gyro x raw data
gume 0:1f82672b8755 3171 * to rps output as float
gume 0:1f82672b8755 3172 *
gume 0:1f82672b8755 3173 * @param gyro_x_f : The gyro x dps float data
gume 0:1f82672b8755 3174 *
gume 0:1f82672b8755 3175 *
gume 0:1f82672b8755 3176 *
gume 0:1f82672b8755 3177 * @return results of bus communication function
gume 0:1f82672b8755 3178 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 3179 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 3180 *
gume 0:1f82672b8755 3181 */
gume 0:1f82672b8755 3182 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_gyro_x_rps(
gume 0:1f82672b8755 3183 float *gyro_x_f)
gume 0:1f82672b8755 3184 {
gume 0:1f82672b8755 3185 /* Variable used to return value of
gume 0:1f82672b8755 3186 communication routine*/
gume 0:1f82672b8755 3187 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3188 s16 reg_gyro_x_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3189 float data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3190 u8 gyro_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3191 /* Read the current gyro unit and set the
gume 0:1f82672b8755 3192 unit as rps if the unit is in dps */
gume 0:1f82672b8755 3193 com_rslt = bno055_get_gyro_unit(&gyro_unit_u8);
gume 0:1f82672b8755 3194 if (gyro_unit_u8 != BNO055_GYRO_UNIT_RPS)
gume 0:1f82672b8755 3195 com_rslt += bno055_set_gyro_unit(BNO055_GYRO_UNIT_RPS);
gume 0:1f82672b8755 3196 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3197 /* Read gyro raw x data */
gume 0:1f82672b8755 3198 com_rslt += bno055_read_gyro_x(&reg_gyro_x_s16);
gume 0:1f82672b8755 3199 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3200 /* Convert the raw gyro x to rps*/
gume 0:1f82672b8755 3201 data_f =
gume 0:1f82672b8755 3202 (float)(reg_gyro_x_s16/BNO055_GYRO_DIV_RPS);
gume 0:1f82672b8755 3203 *gyro_x_f = data_f;
gume 0:1f82672b8755 3204 } else {
gume 0:1f82672b8755 3205 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3206 }
gume 0:1f82672b8755 3207 } else {
gume 0:1f82672b8755 3208 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3209 }
gume 0:1f82672b8755 3210 return com_rslt;
gume 0:1f82672b8755 3211 }
gume 0:1f82672b8755 3212 /*!
gume 0:1f82672b8755 3213 * @brief This API is used to convert the gyro y raw data
gume 0:1f82672b8755 3214 * to dps output as float
gume 0:1f82672b8755 3215 *
gume 0:1f82672b8755 3216 * @param gyro_y_f : The gyro y dps float data
gume 0:1f82672b8755 3217 *
gume 0:1f82672b8755 3218 *
gume 0:1f82672b8755 3219 *
gume 0:1f82672b8755 3220 * @return results of bus communication function
gume 0:1f82672b8755 3221 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 3222 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 3223 *
gume 0:1f82672b8755 3224 */
gume 0:1f82672b8755 3225 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_gyro_y_dps(
gume 0:1f82672b8755 3226 float *gyro_y_f)
gume 0:1f82672b8755 3227 {
gume 0:1f82672b8755 3228 /* Variable used to return value of
gume 0:1f82672b8755 3229 communication routine*/
gume 0:1f82672b8755 3230 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3231 s16 reg_gyro_y_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3232 float data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3233 u8 gyro_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3234 /* Read the current gyro unit and set the
gume 0:1f82672b8755 3235 unit as dps if the unit is in rps */
gume 0:1f82672b8755 3236 com_rslt = bno055_get_gyro_unit(&gyro_unit_u8);
gume 0:1f82672b8755 3237 if (gyro_unit_u8 != BNO055_GYRO_UNIT_DPS)
gume 0:1f82672b8755 3238 com_rslt += bno055_set_gyro_unit(BNO055_GYRO_UNIT_DPS);
gume 0:1f82672b8755 3239 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3240 /* Read gyro raw y data */
gume 0:1f82672b8755 3241 com_rslt += bno055_read_gyro_y(&reg_gyro_y_s16);
gume 0:1f82672b8755 3242 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3243 /* Convert the raw gyro x to dps*/
gume 0:1f82672b8755 3244 data_f =
gume 0:1f82672b8755 3245 (float)(reg_gyro_y_s16/BNO055_GYRO_DIV_DPS);
gume 0:1f82672b8755 3246 *gyro_y_f = data_f;
gume 0:1f82672b8755 3247 } else {
gume 0:1f82672b8755 3248 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3249 }
gume 0:1f82672b8755 3250 } else {
gume 0:1f82672b8755 3251 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3252 }
gume 0:1f82672b8755 3253 return com_rslt;
gume 0:1f82672b8755 3254 }
gume 0:1f82672b8755 3255 /*!
gume 0:1f82672b8755 3256 * @brief This API is used to convert the gyro y raw data
gume 0:1f82672b8755 3257 * to rps output as float
gume 0:1f82672b8755 3258 *
gume 0:1f82672b8755 3259 * @param gyro_y_f : The gyro y dps float data
gume 0:1f82672b8755 3260 *
gume 0:1f82672b8755 3261 *
gume 0:1f82672b8755 3262 *
gume 0:1f82672b8755 3263 * @return results of bus communication function
gume 0:1f82672b8755 3264 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 3265 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 3266 *
gume 0:1f82672b8755 3267 *
gume 0:1f82672b8755 3268 */
gume 0:1f82672b8755 3269 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_gyro_y_rps(
gume 0:1f82672b8755 3270 float *gyro_y_f)
gume 0:1f82672b8755 3271 {
gume 0:1f82672b8755 3272 /* Variable used to return value of
gume 0:1f82672b8755 3273 communication routine*/
gume 0:1f82672b8755 3274 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3275 s16 reg_gyro_y_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3276 float data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3277 u8 gyro_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3278 /* Read the current gyro unit and set the
gume 0:1f82672b8755 3279 unit as rps if the unit is in dps */
gume 0:1f82672b8755 3280 com_rslt = bno055_get_gyro_unit(&gyro_unit_u8);
gume 0:1f82672b8755 3281 if (gyro_unit_u8 != BNO055_GYRO_UNIT_RPS)
gume 0:1f82672b8755 3282 com_rslt += bno055_set_gyro_unit(BNO055_GYRO_UNIT_RPS);
gume 0:1f82672b8755 3283 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3284 /* Read gyro raw y data */
gume 0:1f82672b8755 3285 com_rslt += bno055_read_gyro_y(&reg_gyro_y_s16);
gume 0:1f82672b8755 3286 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3287 /* Convert the raw gyro x to rps*/
gume 0:1f82672b8755 3288 data_f =
gume 0:1f82672b8755 3289 (float)(reg_gyro_y_s16/BNO055_GYRO_DIV_RPS);
gume 0:1f82672b8755 3290 *gyro_y_f = data_f;
gume 0:1f82672b8755 3291 } else {
gume 0:1f82672b8755 3292 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3293 }
gume 0:1f82672b8755 3294 } else {
gume 0:1f82672b8755 3295 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3296 }
gume 0:1f82672b8755 3297 return com_rslt;
gume 0:1f82672b8755 3298 }
gume 0:1f82672b8755 3299 /*!
gume 0:1f82672b8755 3300 * @brief This API is used to convert the gyro z raw data
gume 0:1f82672b8755 3301 * to dps output as float
gume 0:1f82672b8755 3302 *
gume 0:1f82672b8755 3303 * @param gyro_z_f : The gyro z dps float data
gume 0:1f82672b8755 3304 *
gume 0:1f82672b8755 3305 *
gume 0:1f82672b8755 3306 *
gume 0:1f82672b8755 3307 * @return results of bus communication function
gume 0:1f82672b8755 3308 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 3309 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 3310 *
gume 0:1f82672b8755 3311 */
gume 0:1f82672b8755 3312 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_gyro_z_dps(
gume 0:1f82672b8755 3313 float *gyro_z_f)
gume 0:1f82672b8755 3314 {
gume 0:1f82672b8755 3315 /* Variable used to return value of
gume 0:1f82672b8755 3316 communication routine*/
gume 0:1f82672b8755 3317 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3318 s16 reg_gyro_z_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3319 float data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3320 u8 gyro_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3321 /* Read the current gyro unit and set the
gume 0:1f82672b8755 3322 unit as dps if the unit is in rps */
gume 0:1f82672b8755 3323 com_rslt = bno055_get_gyro_unit(&gyro_unit_u8);
gume 0:1f82672b8755 3324 if (gyro_unit_u8 != BNO055_GYRO_UNIT_DPS)
gume 0:1f82672b8755 3325 com_rslt += bno055_set_gyro_unit(BNO055_GYRO_UNIT_DPS);
gume 0:1f82672b8755 3326 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3327 /* Read gyro raw z data */
gume 0:1f82672b8755 3328 com_rslt += bno055_read_gyro_z(&reg_gyro_z_s16);
gume 0:1f82672b8755 3329 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3330 /* Convert the raw gyro x to dps*/
gume 0:1f82672b8755 3331 data_f =
gume 0:1f82672b8755 3332 (float)(reg_gyro_z_s16/BNO055_GYRO_DIV_DPS);
gume 0:1f82672b8755 3333 *gyro_z_f = data_f;
gume 0:1f82672b8755 3334 } else {
gume 0:1f82672b8755 3335 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3336 }
gume 0:1f82672b8755 3337 } else {
gume 0:1f82672b8755 3338 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3339 }
gume 0:1f82672b8755 3340 return com_rslt;
gume 0:1f82672b8755 3341 }
gume 0:1f82672b8755 3342 /*!
gume 0:1f82672b8755 3343 * @brief This API is used to convert the gyro z raw data
gume 0:1f82672b8755 3344 * to rps output as float
gume 0:1f82672b8755 3345 *
gume 0:1f82672b8755 3346 * @param gyro_z_f : The gyro z rps float data
gume 0:1f82672b8755 3347 *
gume 0:1f82672b8755 3348 *
gume 0:1f82672b8755 3349 *
gume 0:1f82672b8755 3350 * @return results of bus communication function
gume 0:1f82672b8755 3351 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 3352 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 3353 *
gume 0:1f82672b8755 3354 */
gume 0:1f82672b8755 3355 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_gyro_z_rps(
gume 0:1f82672b8755 3356 float *gyro_z_f)
gume 0:1f82672b8755 3357 {
gume 0:1f82672b8755 3358 /* Variable used to return value of
gume 0:1f82672b8755 3359 communication routine*/
gume 0:1f82672b8755 3360 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3361 s16 reg_gyro_z_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3362 float data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3363 u8 gyro_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3364 /* Read the current gyro unit and set the
gume 0:1f82672b8755 3365 unit as rps if the unit is in dps */
gume 0:1f82672b8755 3366 com_rslt = bno055_get_gyro_unit(&gyro_unit_u8);
gume 0:1f82672b8755 3367 if (gyro_unit_u8 != BNO055_GYRO_UNIT_RPS)
gume 0:1f82672b8755 3368 com_rslt += bno055_set_gyro_unit(BNO055_GYRO_UNIT_RPS);
gume 0:1f82672b8755 3369 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3370 /* Read gyro raw x data */
gume 0:1f82672b8755 3371 com_rslt += bno055_read_gyro_z(&reg_gyro_z_s16);
gume 0:1f82672b8755 3372 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3373 /* Convert the raw gyro x to rps*/
gume 0:1f82672b8755 3374 data_f =
gume 0:1f82672b8755 3375 (float)(reg_gyro_z_s16/BNO055_GYRO_DIV_RPS);
gume 0:1f82672b8755 3376 *gyro_z_f = data_f;
gume 0:1f82672b8755 3377 } else {
gume 0:1f82672b8755 3378 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3379 }
gume 0:1f82672b8755 3380 } else {
gume 0:1f82672b8755 3381 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3382 }
gume 0:1f82672b8755 3383 return com_rslt;
gume 0:1f82672b8755 3384 }
gume 0:1f82672b8755 3385 /*!
gume 0:1f82672b8755 3386 * @brief This API is used to convert the gyro xyz raw data
gume 0:1f82672b8755 3387 * to dps output as float
gume 0:1f82672b8755 3388 *
gume 0:1f82672b8755 3389 * @param gyro_xyz_data : The dps data of gyro xyz
gume 0:1f82672b8755 3390 *
gume 0:1f82672b8755 3391 * Parameter | result
gume 0:1f82672b8755 3392 * --------- | -----------------
gume 0:1f82672b8755 3393 * x | dps data of gyro
gume 0:1f82672b8755 3394 * y | dps data of gyro
gume 0:1f82672b8755 3395 * z | dps data of gyro
gume 0:1f82672b8755 3396 *
gume 0:1f82672b8755 3397 *
gume 0:1f82672b8755 3398 * @return results of bus communication function
gume 0:1f82672b8755 3399 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 3400 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 3401 *
gume 0:1f82672b8755 3402 *
gume 0:1f82672b8755 3403 */
gume 0:1f82672b8755 3404 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_gyro_xyz_dps(
gume 0:1f82672b8755 3405 struct bno055_gyro_float_t *gyro_xyz_data)
gume 0:1f82672b8755 3406 {
gume 0:1f82672b8755 3407 /* Variable used to return value of
gume 0:1f82672b8755 3408 communication routine*/
gume 0:1f82672b8755 3409 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3410 struct bno055_gyro_t gyro_xyz = {
gume 0:1f82672b8755 3411 BNO055_INIT_VALUE, BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 3412 u8 gyro_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3413 /* Read the current gyro unit and set the
gume 0:1f82672b8755 3414 unit as dps if the unit is in rps */
gume 0:1f82672b8755 3415 com_rslt = bno055_get_gyro_unit(&gyro_unit_u8);
gume 0:1f82672b8755 3416 if (gyro_unit_u8 != BNO055_GYRO_UNIT_DPS)
gume 0:1f82672b8755 3417 com_rslt += bno055_set_gyro_unit(BNO055_GYRO_UNIT_DPS);
gume 0:1f82672b8755 3418 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3419 /* Read gyro raw xyz data */
gume 0:1f82672b8755 3420 com_rslt += bno055_read_gyro_xyz(&gyro_xyz);
gume 0:1f82672b8755 3421 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3422 /* Convert gyro raw xyz to dps*/
gume 0:1f82672b8755 3423 gyro_xyz_data->x =
gume 0:1f82672b8755 3424 (float)(gyro_xyz.x/BNO055_GYRO_DIV_DPS);
gume 0:1f82672b8755 3425 gyro_xyz_data->y =
gume 0:1f82672b8755 3426 (float)(gyro_xyz.y/BNO055_GYRO_DIV_DPS);
gume 0:1f82672b8755 3427 gyro_xyz_data->z =
gume 0:1f82672b8755 3428 (float)(gyro_xyz.z/BNO055_GYRO_DIV_DPS);
gume 0:1f82672b8755 3429 } else {
gume 0:1f82672b8755 3430 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3431 }
gume 0:1f82672b8755 3432 } else {
gume 0:1f82672b8755 3433 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3434 }
gume 0:1f82672b8755 3435 return com_rslt;
gume 0:1f82672b8755 3436 }
gume 0:1f82672b8755 3437 /*!
gume 0:1f82672b8755 3438 * @brief This API is used to convert the gyro xyz raw data
gume 0:1f82672b8755 3439 * to rps output as float
gume 0:1f82672b8755 3440 *
gume 0:1f82672b8755 3441 * @param gyro_xyz_data : The rps data of gyro xyz
gume 0:1f82672b8755 3442 *
gume 0:1f82672b8755 3443 * Parameter | result
gume 0:1f82672b8755 3444 * --------- | -----------------
gume 0:1f82672b8755 3445 * x | rps data of gyro
gume 0:1f82672b8755 3446 * y | rps data of gyro
gume 0:1f82672b8755 3447 * z | rps data of gyro
gume 0:1f82672b8755 3448 *
gume 0:1f82672b8755 3449 *
gume 0:1f82672b8755 3450 * @return results of bus communication function
gume 0:1f82672b8755 3451 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 3452 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 3453 *
gume 0:1f82672b8755 3454 *
gume 0:1f82672b8755 3455 */
gume 0:1f82672b8755 3456 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_gyro_xyz_rps(
gume 0:1f82672b8755 3457 struct bno055_gyro_float_t *gyro_xyz_data)
gume 0:1f82672b8755 3458 {
gume 0:1f82672b8755 3459 /* Variable used to return value of
gume 0:1f82672b8755 3460 communication routine*/
gume 0:1f82672b8755 3461 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3462 struct bno055_gyro_t gyro_xyz = {BNO055_INIT_VALUE,
gume 0:1f82672b8755 3463 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 3464 u8 gyro_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3465 /* Read the current gyro unit and set the
gume 0:1f82672b8755 3466 unit as rps if the unit is in dps */
gume 0:1f82672b8755 3467 com_rslt = bno055_get_gyro_unit(&gyro_unit_u8);
gume 0:1f82672b8755 3468 if (gyro_unit_u8 != BNO055_GYRO_UNIT_RPS)
gume 0:1f82672b8755 3469 com_rslt += bno055_set_gyro_unit(BNO055_GYRO_UNIT_RPS);
gume 0:1f82672b8755 3470 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3471 /* Read gyro raw xyz data */
gume 0:1f82672b8755 3472 com_rslt += bno055_read_gyro_xyz(&gyro_xyz);
gume 0:1f82672b8755 3473 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3474 /* Convert gyro raw xyz to rps*/
gume 0:1f82672b8755 3475 gyro_xyz_data->x =
gume 0:1f82672b8755 3476 (float)(gyro_xyz.x/BNO055_GYRO_DIV_RPS);
gume 0:1f82672b8755 3477 gyro_xyz_data->y =
gume 0:1f82672b8755 3478 (float)(gyro_xyz.y/BNO055_GYRO_DIV_RPS);
gume 0:1f82672b8755 3479 gyro_xyz_data->z =
gume 0:1f82672b8755 3480 (float)(gyro_xyz.z/BNO055_GYRO_DIV_RPS);
gume 0:1f82672b8755 3481 } else {
gume 0:1f82672b8755 3482 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3483 }
gume 0:1f82672b8755 3484 } else {
gume 0:1f82672b8755 3485 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3486 }
gume 0:1f82672b8755 3487 return com_rslt;
gume 0:1f82672b8755 3488 }
gume 0:1f82672b8755 3489 /*!
gume 0:1f82672b8755 3490 * @brief This API is used to convert the Euler h raw data
gume 0:1f82672b8755 3491 * to degree output as float
gume 0:1f82672b8755 3492 *
gume 0:1f82672b8755 3493 * @param euler_h_f : The float value of Euler h degree
gume 0:1f82672b8755 3494 *
gume 0:1f82672b8755 3495 * @return results of bus communication function
gume 0:1f82672b8755 3496 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 3497 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 3498 *
gume 0:1f82672b8755 3499 *
gume 0:1f82672b8755 3500 */
gume 0:1f82672b8755 3501 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_euler_h_deg(
gume 0:1f82672b8755 3502 float *euler_h_f)
gume 0:1f82672b8755 3503 {
gume 0:1f82672b8755 3504 /* Variable used to return value of
gume 0:1f82672b8755 3505 communication routine*/
gume 0:1f82672b8755 3506 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3507 s16 reg_euler_h_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3508 float data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3509 u8 euler_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3510 /* Read the current Euler unit and set the
gume 0:1f82672b8755 3511 unit as degree if the unit is in radians */
gume 0:1f82672b8755 3512 com_rslt = bno055_get_euler_unit(&euler_unit_u8);
gume 0:1f82672b8755 3513 if (euler_unit_u8 != BNO055_EULER_UNIT_DEG)
gume 0:1f82672b8755 3514 com_rslt += bno055_set_euler_unit(BNO055_EULER_UNIT_DEG);
gume 0:1f82672b8755 3515 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3516 /* Read Euler raw h data*/
gume 0:1f82672b8755 3517 com_rslt += bno055_read_euler_h(&reg_euler_h_s16);
gume 0:1f82672b8755 3518 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3519 /* Convert raw Euler h data to degree*/
gume 0:1f82672b8755 3520 data_f =
gume 0:1f82672b8755 3521 (float)(reg_euler_h_s16/BNO055_EULER_DIV_DEG);
gume 0:1f82672b8755 3522 *euler_h_f = data_f;
gume 0:1f82672b8755 3523 } else {
gume 0:1f82672b8755 3524 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3525 }
gume 0:1f82672b8755 3526 } else {
gume 0:1f82672b8755 3527 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3528 }
gume 0:1f82672b8755 3529 return com_rslt;
gume 0:1f82672b8755 3530 }
gume 0:1f82672b8755 3531 /*!
gume 0:1f82672b8755 3532 * @brief This API is used to convert the Euler h raw data
gume 0:1f82672b8755 3533 * to radians output as float
gume 0:1f82672b8755 3534 *
gume 0:1f82672b8755 3535 * @param euler_h_f : The float value of Euler h radians
gume 0:1f82672b8755 3536 *
gume 0:1f82672b8755 3537 * @return results of bus communication function
gume 0:1f82672b8755 3538 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 3539 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 3540 *
gume 0:1f82672b8755 3541 *
gume 0:1f82672b8755 3542 */
gume 0:1f82672b8755 3543 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_euler_h_rad(
gume 0:1f82672b8755 3544 float *euler_h_f)
gume 0:1f82672b8755 3545 {
gume 0:1f82672b8755 3546 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3547 s16 reg_euler_h_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3548 float data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3549 u8 euler_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3550
gume 0:1f82672b8755 3551 com_rslt = bno055_get_euler_unit(&euler_unit_u8);
gume 0:1f82672b8755 3552 if (euler_unit_u8 != BNO055_EULER_UNIT_RAD)
gume 0:1f82672b8755 3553 /* Read the current Euler unit and set the
gume 0:1f82672b8755 3554 unit as radians if the unit is in degree */
gume 0:1f82672b8755 3555 com_rslt += bno055_set_euler_unit(BNO055_EULER_UNIT_RAD);
gume 0:1f82672b8755 3556 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3557 /* Read Euler raw h data*/
gume 0:1f82672b8755 3558 com_rslt += bno055_read_euler_h(&reg_euler_h_s16);
gume 0:1f82672b8755 3559 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3560 /* Convert raw Euler h data to degree*/
gume 0:1f82672b8755 3561 data_f =
gume 0:1f82672b8755 3562 (float)(reg_euler_h_s16/BNO055_EULER_DIV_RAD);
gume 0:1f82672b8755 3563 *euler_h_f = data_f;
gume 0:1f82672b8755 3564 } else {
gume 0:1f82672b8755 3565 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3566 }
gume 0:1f82672b8755 3567 } else {
gume 0:1f82672b8755 3568 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3569 }
gume 0:1f82672b8755 3570 return com_rslt;
gume 0:1f82672b8755 3571 }
gume 0:1f82672b8755 3572 /*!
gume 0:1f82672b8755 3573 * @brief This API is used to convert the Euler r raw data
gume 0:1f82672b8755 3574 * to degree output as float
gume 0:1f82672b8755 3575 *
gume 0:1f82672b8755 3576 * @param euler_r_f : The float value of Euler r degree
gume 0:1f82672b8755 3577 *
gume 0:1f82672b8755 3578 * @return results of bus communication function
gume 0:1f82672b8755 3579 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 3580 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 3581 *
gume 0:1f82672b8755 3582 */
gume 0:1f82672b8755 3583 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_euler_r_deg(
gume 0:1f82672b8755 3584 float *euler_r_f)
gume 0:1f82672b8755 3585 {
gume 0:1f82672b8755 3586 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3587 s16 reg_euler_r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3588 float data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3589 u8 euler_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3590 /* Read the current Euler unit and set the
gume 0:1f82672b8755 3591 unit as degree if the unit is in radians */
gume 0:1f82672b8755 3592 com_rslt = bno055_get_euler_unit(&euler_unit_u8);
gume 0:1f82672b8755 3593 if (euler_unit_u8 != BNO055_EULER_UNIT_DEG)
gume 0:1f82672b8755 3594 com_rslt += bno055_set_euler_unit(BNO055_EULER_UNIT_DEG);
gume 0:1f82672b8755 3595 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3596 /* Read Euler raw r data*/
gume 0:1f82672b8755 3597 com_rslt += bno055_read_euler_r(&reg_euler_r);
gume 0:1f82672b8755 3598 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3599 /* Convert raw Euler r data to degree*/
gume 0:1f82672b8755 3600 data_f = (float)(
gume 0:1f82672b8755 3601 reg_euler_r/BNO055_EULER_DIV_DEG);
gume 0:1f82672b8755 3602 *euler_r_f = data_f;
gume 0:1f82672b8755 3603 } else {
gume 0:1f82672b8755 3604 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3605 }
gume 0:1f82672b8755 3606 } else {
gume 0:1f82672b8755 3607 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3608 }
gume 0:1f82672b8755 3609 return com_rslt;
gume 0:1f82672b8755 3610 }
gume 0:1f82672b8755 3611 /*!
gume 0:1f82672b8755 3612 * @brief This API is used to convert the Euler r raw data
gume 0:1f82672b8755 3613 * to radians output as float
gume 0:1f82672b8755 3614 *
gume 0:1f82672b8755 3615 * @param euler_r_f : The float value of Euler r radians
gume 0:1f82672b8755 3616 *
gume 0:1f82672b8755 3617 * @return results of bus communication function
gume 0:1f82672b8755 3618 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 3619 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 3620 *
gume 0:1f82672b8755 3621 */
gume 0:1f82672b8755 3622 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_euler_r_rad(
gume 0:1f82672b8755 3623 float *euler_r_f)
gume 0:1f82672b8755 3624 {
gume 0:1f82672b8755 3625 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3626 s16 reg_euler_r_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3627 float data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3628 u8 euler_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3629 /* Read the current Euler unit and set the
gume 0:1f82672b8755 3630 unit as radians if the unit is in degree */
gume 0:1f82672b8755 3631 com_rslt = bno055_get_euler_unit(&euler_unit_u8);
gume 0:1f82672b8755 3632 if (euler_unit_u8 != BNO055_EULER_UNIT_RAD)
gume 0:1f82672b8755 3633 com_rslt += bno055_set_euler_unit(BNO055_EULER_UNIT_RAD);
gume 0:1f82672b8755 3634 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3635 /* Read Euler raw r data*/
gume 0:1f82672b8755 3636 com_rslt += bno055_read_euler_r(&reg_euler_r_f);
gume 0:1f82672b8755 3637 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3638 /* Convert raw Euler r data to radians*/
gume 0:1f82672b8755 3639 data_f =
gume 0:1f82672b8755 3640 (float)(reg_euler_r_f/BNO055_EULER_DIV_RAD);
gume 0:1f82672b8755 3641 *euler_r_f = data_f;
gume 0:1f82672b8755 3642 } else {
gume 0:1f82672b8755 3643 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3644 }
gume 0:1f82672b8755 3645 } else {
gume 0:1f82672b8755 3646 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3647 }
gume 0:1f82672b8755 3648 return com_rslt;
gume 0:1f82672b8755 3649 }
gume 0:1f82672b8755 3650 /*!
gume 0:1f82672b8755 3651 * @brief This API is used to convert the Euler p raw data
gume 0:1f82672b8755 3652 * to degree output as float
gume 0:1f82672b8755 3653 *
gume 0:1f82672b8755 3654 * @param euler_p_f : The float value of Euler p degree
gume 0:1f82672b8755 3655 *
gume 0:1f82672b8755 3656 * @return results of bus communication function
gume 0:1f82672b8755 3657 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 3658 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 3659 *
gume 0:1f82672b8755 3660 */
gume 0:1f82672b8755 3661 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_euler_p_deg(
gume 0:1f82672b8755 3662 float *euler_p_f)
gume 0:1f82672b8755 3663 {
gume 0:1f82672b8755 3664 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3665 s16 reg_euler_p_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3666 float data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3667 u8 euler_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3668 /* Read the current Euler unit and set the
gume 0:1f82672b8755 3669 unit as degree if the unit is in radians */
gume 0:1f82672b8755 3670 com_rslt = bno055_get_euler_unit(&euler_unit_u8);
gume 0:1f82672b8755 3671 if (euler_unit_u8 != BNO055_EULER_UNIT_DEG)
gume 0:1f82672b8755 3672 com_rslt += bno055_set_euler_unit(BNO055_EULER_UNIT_DEG);
gume 0:1f82672b8755 3673 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3674 /* Read Euler raw p data*/
gume 0:1f82672b8755 3675 com_rslt += bno055_read_euler_p(&reg_euler_p_f);
gume 0:1f82672b8755 3676 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3677 /* Convert raw Euler p data to degree*/
gume 0:1f82672b8755 3678 data_f =
gume 0:1f82672b8755 3679 (float)(reg_euler_p_f/BNO055_EULER_DIV_DEG);
gume 0:1f82672b8755 3680 *euler_p_f = data_f;
gume 0:1f82672b8755 3681 } else {
gume 0:1f82672b8755 3682 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3683 }
gume 0:1f82672b8755 3684 } else {
gume 0:1f82672b8755 3685 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3686 }
gume 0:1f82672b8755 3687 return com_rslt;
gume 0:1f82672b8755 3688 }
gume 0:1f82672b8755 3689 /*!
gume 0:1f82672b8755 3690 * @brief This API is used to convert the Euler p raw data
gume 0:1f82672b8755 3691 * to radians output as float
gume 0:1f82672b8755 3692 *
gume 0:1f82672b8755 3693 * @param euler_p_f : The float value of Euler p radians
gume 0:1f82672b8755 3694 *
gume 0:1f82672b8755 3695 * @return results of bus communication function
gume 0:1f82672b8755 3696 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 3697 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 3698 *
gume 0:1f82672b8755 3699 *
gume 0:1f82672b8755 3700 */
gume 0:1f82672b8755 3701 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_euler_p_rad(
gume 0:1f82672b8755 3702 float *euler_p_f)
gume 0:1f82672b8755 3703 {
gume 0:1f82672b8755 3704 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3705 s16 reg_euler_p_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3706 float data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3707 u8 euler_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3708 /* Read the current Euler unit and set the
gume 0:1f82672b8755 3709 unit as radians if the unit is in degree */
gume 0:1f82672b8755 3710 com_rslt = bno055_get_euler_unit(&euler_unit_u8);
gume 0:1f82672b8755 3711 if (euler_unit_u8 != BNO055_EULER_UNIT_RAD)
gume 0:1f82672b8755 3712 com_rslt += bno055_set_euler_unit(BNO055_EULER_UNIT_RAD);
gume 0:1f82672b8755 3713 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3714 /* Read Euler raw r data*/
gume 0:1f82672b8755 3715 com_rslt += bno055_read_euler_p(&reg_euler_p_f);
gume 0:1f82672b8755 3716 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3717 /* Convert raw Euler r data to radians*/
gume 0:1f82672b8755 3718 data_f =
gume 0:1f82672b8755 3719 (float)(reg_euler_p_f/BNO055_EULER_DIV_RAD);
gume 0:1f82672b8755 3720 *euler_p_f = data_f;
gume 0:1f82672b8755 3721 } else {
gume 0:1f82672b8755 3722 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3723 }
gume 0:1f82672b8755 3724 } else {
gume 0:1f82672b8755 3725 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3726 }
gume 0:1f82672b8755 3727 return com_rslt;
gume 0:1f82672b8755 3728 }
gume 0:1f82672b8755 3729 /*!
gume 0:1f82672b8755 3730 * @brief This API is used to convert the Euler hrp raw data
gume 0:1f82672b8755 3731 * to degree output as float
gume 0:1f82672b8755 3732 *
gume 0:1f82672b8755 3733 * @param euler_hpr : The degree data of Euler hrp
gume 0:1f82672b8755 3734 *
gume 0:1f82672b8755 3735 * Parameter | result
gume 0:1f82672b8755 3736 * --------- | -----------------
gume 0:1f82672b8755 3737 * h | degree data of Euler
gume 0:1f82672b8755 3738 * r | degree data of Euler
gume 0:1f82672b8755 3739 * p | degree data of Euler
gume 0:1f82672b8755 3740 *
gume 0:1f82672b8755 3741 *
gume 0:1f82672b8755 3742 * @return results of bus communication function
gume 0:1f82672b8755 3743 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 3744 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 3745 *
gume 0:1f82672b8755 3746 */
gume 0:1f82672b8755 3747 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_euler_hpr_deg(
gume 0:1f82672b8755 3748 struct bno055_euler_float_t *euler_hpr)
gume 0:1f82672b8755 3749 {
gume 0:1f82672b8755 3750 /* Variable used to return value of
gume 0:1f82672b8755 3751 communication routine*/
gume 0:1f82672b8755 3752 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3753 struct bno055_euler_t reg_euler = {BNO055_INIT_VALUE,
gume 0:1f82672b8755 3754 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 3755 u8 euler_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3756 /* Read the current Euler unit and set the
gume 0:1f82672b8755 3757 unit as degree if the unit is in radians */
gume 0:1f82672b8755 3758 com_rslt = bno055_get_euler_unit(&euler_unit_u8);
gume 0:1f82672b8755 3759 if (euler_unit_u8 != BNO055_EULER_UNIT_DEG)
gume 0:1f82672b8755 3760 com_rslt += bno055_set_euler_unit(BNO055_EULER_UNIT_DEG);
gume 0:1f82672b8755 3761 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3762 /* Read Euler raw hrp data*/
gume 0:1f82672b8755 3763 com_rslt += bno055_read_euler_hrp(&reg_euler);
gume 0:1f82672b8755 3764 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3765 /* Convert raw Euler hrp to degree*/
gume 0:1f82672b8755 3766 euler_hpr->h =
gume 0:1f82672b8755 3767 (float)(reg_euler.h/BNO055_EULER_DIV_DEG);
gume 0:1f82672b8755 3768 euler_hpr->p =
gume 0:1f82672b8755 3769 (float)(reg_euler.p/BNO055_EULER_DIV_DEG);
gume 0:1f82672b8755 3770 euler_hpr->r =
gume 0:1f82672b8755 3771 (float)(reg_euler.r/BNO055_EULER_DIV_DEG);
gume 0:1f82672b8755 3772 } else {
gume 0:1f82672b8755 3773 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3774 }
gume 0:1f82672b8755 3775 } else {
gume 0:1f82672b8755 3776 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3777 }
gume 0:1f82672b8755 3778 return com_rslt;
gume 0:1f82672b8755 3779 }
gume 0:1f82672b8755 3780 /*!
gume 0:1f82672b8755 3781 * @brief This API is used to convert the Euler xyz raw data
gume 0:1f82672b8755 3782 * to radians output as float
gume 0:1f82672b8755 3783 *
gume 0:1f82672b8755 3784 * @param euler_hpr : The radians data of Euler hrp
gume 0:1f82672b8755 3785 *
gume 0:1f82672b8755 3786 * Parameter | result
gume 0:1f82672b8755 3787 * --------- | -----------------
gume 0:1f82672b8755 3788 * h | radians data of Euler
gume 0:1f82672b8755 3789 * r | radians data of Euler
gume 0:1f82672b8755 3790 * p | radians data of Euler
gume 0:1f82672b8755 3791 *
gume 0:1f82672b8755 3792 *
gume 0:1f82672b8755 3793 * @return results of bus communication function
gume 0:1f82672b8755 3794 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 3795 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 3796 *
gume 0:1f82672b8755 3797 */
gume 0:1f82672b8755 3798 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_euler_hpr_rad(
gume 0:1f82672b8755 3799 struct bno055_euler_float_t *euler_hpr)
gume 0:1f82672b8755 3800 {
gume 0:1f82672b8755 3801 /* Variable used to return value of
gume 0:1f82672b8755 3802 communication routine*/
gume 0:1f82672b8755 3803 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3804 struct bno055_euler_t reg_euler = {BNO055_INIT_VALUE,
gume 0:1f82672b8755 3805 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 3806 u8 euler_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3807 /* Read the current Euler unit and set the
gume 0:1f82672b8755 3808 unit as radians if the unit is in degree */
gume 0:1f82672b8755 3809 com_rslt = bno055_get_euler_unit(&euler_unit_u8);
gume 0:1f82672b8755 3810 if (euler_unit_u8 != BNO055_EULER_UNIT_RAD)
gume 0:1f82672b8755 3811 com_rslt += bno055_set_euler_unit(BNO055_EULER_UNIT_RAD);
gume 0:1f82672b8755 3812 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3813 /* Read Euler raw hrp data*/
gume 0:1f82672b8755 3814 com_rslt += bno055_read_euler_hrp(&reg_euler);
gume 0:1f82672b8755 3815 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3816 /* Convert raw hrp to radians */
gume 0:1f82672b8755 3817 euler_hpr->h =
gume 0:1f82672b8755 3818 (float)(reg_euler.h/BNO055_EULER_DIV_RAD);
gume 0:1f82672b8755 3819 euler_hpr->p =
gume 0:1f82672b8755 3820 (float)(reg_euler.p/BNO055_EULER_DIV_RAD);
gume 0:1f82672b8755 3821 euler_hpr->r =
gume 0:1f82672b8755 3822 (float)(reg_euler.r/BNO055_EULER_DIV_RAD);
gume 0:1f82672b8755 3823 } else {
gume 0:1f82672b8755 3824 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3825 }
gume 0:1f82672b8755 3826 } else {
gume 0:1f82672b8755 3827 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3828 }
gume 0:1f82672b8755 3829 return com_rslt;
gume 0:1f82672b8755 3830 }
gume 0:1f82672b8755 3831 /*!
gume 0:1f82672b8755 3832 * @brief This API is used to convert the linear
gume 0:1f82672b8755 3833 * accel x raw data to meterpersecseq output as float
gume 0:1f82672b8755 3834 *
gume 0:1f82672b8755 3835 * @param linear_accel_x_f : The float value of linear accel x meterpersecseq
gume 0:1f82672b8755 3836 *
gume 0:1f82672b8755 3837 * @return results of bus communication function
gume 0:1f82672b8755 3838 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 3839 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 3840 */
gume 0:1f82672b8755 3841 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_linear_accel_x_msq(
gume 0:1f82672b8755 3842 float *linear_accel_x_f)
gume 0:1f82672b8755 3843 {
gume 0:1f82672b8755 3844 /* Variable used to return value of
gume 0:1f82672b8755 3845 communication routine*/
gume 0:1f82672b8755 3846 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3847 s16 reg_linear_accel_x_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3848 float data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3849 /* Read the raw x of linear accel */
gume 0:1f82672b8755 3850 com_rslt = bno055_read_linear_accel_x(&reg_linear_accel_x_s16);
gume 0:1f82672b8755 3851 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3852 /* Convert the raw linear accel x to m/s2*/
gume 0:1f82672b8755 3853 data_f =
gume 0:1f82672b8755 3854 (float)(reg_linear_accel_x_s16/BNO055_LINEAR_ACCEL_DIV_MSQ);
gume 0:1f82672b8755 3855 *linear_accel_x_f = data_f;
gume 0:1f82672b8755 3856 } else {
gume 0:1f82672b8755 3857 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3858 }
gume 0:1f82672b8755 3859 return com_rslt;
gume 0:1f82672b8755 3860 }
gume 0:1f82672b8755 3861 /*!
gume 0:1f82672b8755 3862 * @brief This API is used to convert the linear
gume 0:1f82672b8755 3863 * accel y raw data to meterpersecseq output as float
gume 0:1f82672b8755 3864 *
gume 0:1f82672b8755 3865 * @param linear_accel_y_f : The float value of linear accel y meterpersecseq
gume 0:1f82672b8755 3866 *
gume 0:1f82672b8755 3867 * @return results of bus communication function
gume 0:1f82672b8755 3868 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 3869 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 3870 */
gume 0:1f82672b8755 3871 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_linear_accel_y_msq(
gume 0:1f82672b8755 3872 float *linear_accel_y_f)
gume 0:1f82672b8755 3873 {
gume 0:1f82672b8755 3874 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3875 s16 reg_linear_accel_y = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3876 float data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3877 /* Read the raw y of linear accel */
gume 0:1f82672b8755 3878 com_rslt = bno055_read_linear_accel_y(&reg_linear_accel_y);
gume 0:1f82672b8755 3879 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3880 /* Convert the raw linear accel x to m/s2*/
gume 0:1f82672b8755 3881 data_f = (float)
gume 0:1f82672b8755 3882 (reg_linear_accel_y/BNO055_LINEAR_ACCEL_DIV_MSQ);
gume 0:1f82672b8755 3883 *linear_accel_y_f = data_f;
gume 0:1f82672b8755 3884 } else {
gume 0:1f82672b8755 3885 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3886 }
gume 0:1f82672b8755 3887 return com_rslt;
gume 0:1f82672b8755 3888 }
gume 0:1f82672b8755 3889 /*!
gume 0:1f82672b8755 3890 * @brief This API is used to convert the linear
gume 0:1f82672b8755 3891 * accel z raw data to meterpersecseq output as float
gume 0:1f82672b8755 3892 *
gume 0:1f82672b8755 3893 * @param linear_accel_z_f : The float value of linear accel z meterpersecseq
gume 0:1f82672b8755 3894 *
gume 0:1f82672b8755 3895 * @return results of bus communication function
gume 0:1f82672b8755 3896 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 3897 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 3898 *
gume 0:1f82672b8755 3899 */
gume 0:1f82672b8755 3900 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_linear_accel_z_msq(
gume 0:1f82672b8755 3901 float *linear_accel_z_f)
gume 0:1f82672b8755 3902 {
gume 0:1f82672b8755 3903 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3904 s16 reg_linear_accel_z = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3905 float data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3906 /* Read the raw x of linear accel */
gume 0:1f82672b8755 3907 com_rslt = bno055_read_linear_accel_z(&reg_linear_accel_z);
gume 0:1f82672b8755 3908 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3909 /* Convert the raw linear accel z to m/s2*/
gume 0:1f82672b8755 3910 data_f = (float)
gume 0:1f82672b8755 3911 (reg_linear_accel_z/BNO055_LINEAR_ACCEL_DIV_MSQ);
gume 0:1f82672b8755 3912 *linear_accel_z_f = data_f;
gume 0:1f82672b8755 3913 } else {
gume 0:1f82672b8755 3914 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3915 }
gume 0:1f82672b8755 3916 return com_rslt;
gume 0:1f82672b8755 3917 }
gume 0:1f82672b8755 3918 /*!
gume 0:1f82672b8755 3919 * @brief This API is used to convert the linear accel xyz raw data
gume 0:1f82672b8755 3920 * to meterpersecseq output as float
gume 0:1f82672b8755 3921 *
gume 0:1f82672b8755 3922 * @param linear_accel_xyz : The meterpersecseq data of linear accel xyz
gume 0:1f82672b8755 3923 *
gume 0:1f82672b8755 3924 * Parameter | result
gume 0:1f82672b8755 3925 * --------- | -----------------
gume 0:1f82672b8755 3926 * x | meterpersecseq data of linear accel
gume 0:1f82672b8755 3927 * y | meterpersecseq data of linear accel
gume 0:1f82672b8755 3928 * z | meterpersecseq data of linear accel
gume 0:1f82672b8755 3929 *
gume 0:1f82672b8755 3930 *
gume 0:1f82672b8755 3931 * @return results of bus communication function
gume 0:1f82672b8755 3932 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 3933 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 3934 *
gume 0:1f82672b8755 3935 *
gume 0:1f82672b8755 3936 */
gume 0:1f82672b8755 3937 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_linear_accel_xyz_msq(
gume 0:1f82672b8755 3938 struct bno055_linear_accel_float_t *linear_accel_xyz)
gume 0:1f82672b8755 3939 {
gume 0:1f82672b8755 3940 /* Variable used to return value of
gume 0:1f82672b8755 3941 communication routine*/
gume 0:1f82672b8755 3942 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3943 struct bno055_linear_accel_t reg_linear_accel = {
gume 0:1f82672b8755 3944 BNO055_INIT_VALUE, BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 3945 /* Read the raw x of linear accel */
gume 0:1f82672b8755 3946 com_rslt = bno055_read_linear_accel_xyz(&reg_linear_accel);
gume 0:1f82672b8755 3947 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3948 linear_accel_xyz->x =
gume 0:1f82672b8755 3949 (float)(reg_linear_accel.x/BNO055_LINEAR_ACCEL_DIV_MSQ);
gume 0:1f82672b8755 3950 linear_accel_xyz->y =
gume 0:1f82672b8755 3951 (float)(reg_linear_accel.y/BNO055_LINEAR_ACCEL_DIV_MSQ);
gume 0:1f82672b8755 3952 linear_accel_xyz->z =
gume 0:1f82672b8755 3953 (float)(reg_linear_accel.z/BNO055_LINEAR_ACCEL_DIV_MSQ);
gume 0:1f82672b8755 3954 } else {
gume 0:1f82672b8755 3955 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3956 }
gume 0:1f82672b8755 3957 return com_rslt;
gume 0:1f82672b8755 3958 }
gume 0:1f82672b8755 3959 /*!
gume 0:1f82672b8755 3960 * @brief This API is used to convert the gravity
gume 0:1f82672b8755 3961 * x raw data to meterpersecseq output as float
gume 0:1f82672b8755 3962 *
gume 0:1f82672b8755 3963 * @param gravity_x_f : The float value of gravity x meterpersecseq
gume 0:1f82672b8755 3964 *
gume 0:1f82672b8755 3965 * @return results of bus communication function
gume 0:1f82672b8755 3966 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 3967 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 3968 *
gume 0:1f82672b8755 3969 *
gume 0:1f82672b8755 3970 */
gume 0:1f82672b8755 3971 BNO055_RETURN_FUNCTION_TYPE bno055_convert_gravity_float_x_msq(
gume 0:1f82672b8755 3972 float *gravity_x_f)
gume 0:1f82672b8755 3973 {
gume 0:1f82672b8755 3974 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3975 s16 reg_gravity_x_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3976 float data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 3977 /* Read raw gravity of x*/
gume 0:1f82672b8755 3978 com_rslt = bno055_read_gravity_x(&reg_gravity_x_s16);
gume 0:1f82672b8755 3979 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 3980 /* Convert the raw gravity x to m/s2*/
gume 0:1f82672b8755 3981 data_f = (float)(reg_gravity_x_s16/BNO055_GRAVITY_DIV_MSQ);
gume 0:1f82672b8755 3982 *gravity_x_f = data_f;
gume 0:1f82672b8755 3983 } else {
gume 0:1f82672b8755 3984 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 3985 }
gume 0:1f82672b8755 3986 return com_rslt;
gume 0:1f82672b8755 3987 }
gume 0:1f82672b8755 3988 /*!
gume 0:1f82672b8755 3989 * @brief This API is used to convert the gravity
gume 0:1f82672b8755 3990 * y raw data to meterpersecseq output as float
gume 0:1f82672b8755 3991 *
gume 0:1f82672b8755 3992 * @param gravity_y_f : The float value of gravity y meterpersecseq
gume 0:1f82672b8755 3993 *
gume 0:1f82672b8755 3994 * @return results of bus communication function
gume 0:1f82672b8755 3995 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 3996 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 3997 *
gume 0:1f82672b8755 3998 *
gume 0:1f82672b8755 3999 */
gume 0:1f82672b8755 4000 BNO055_RETURN_FUNCTION_TYPE bno055_convert_gravity_float_y_msq(
gume 0:1f82672b8755 4001 float *gravity_y_f)
gume 0:1f82672b8755 4002 {
gume 0:1f82672b8755 4003 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4004 s16 reg_gravity_y_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4005 float data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4006 /* Read raw gravity of y*/
gume 0:1f82672b8755 4007 com_rslt = bno055_read_gravity_y(&reg_gravity_y_s16);
gume 0:1f82672b8755 4008 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4009 /* Convert the raw gravity y to m/s2*/
gume 0:1f82672b8755 4010 data_f = (float)(reg_gravity_y_s16/BNO055_GRAVITY_DIV_MSQ);
gume 0:1f82672b8755 4011 *gravity_y_f = data_f;
gume 0:1f82672b8755 4012 } else {
gume 0:1f82672b8755 4013 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4014 }
gume 0:1f82672b8755 4015 return com_rslt;
gume 0:1f82672b8755 4016 }
gume 0:1f82672b8755 4017 /*!
gume 0:1f82672b8755 4018 * @brief This API is used to convert the gravity
gume 0:1f82672b8755 4019 * z raw data to meterpersecseq output as float
gume 0:1f82672b8755 4020 *
gume 0:1f82672b8755 4021 * @param gravity_z_f : The float value of gravity z meterpersecseq
gume 0:1f82672b8755 4022 *
gume 0:1f82672b8755 4023 * @return results of bus communication function
gume 0:1f82672b8755 4024 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 4025 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 4026 *
gume 0:1f82672b8755 4027 */
gume 0:1f82672b8755 4028 BNO055_RETURN_FUNCTION_TYPE bno055_convert_gravity_float_z_msq(
gume 0:1f82672b8755 4029 float *gravity_z_f)
gume 0:1f82672b8755 4030 {
gume 0:1f82672b8755 4031 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4032 s16 reg_gravity_z_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4033 float data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4034 /* Read raw gravity of z */
gume 0:1f82672b8755 4035 com_rslt = bno055_read_gravity_z(&reg_gravity_z_s16);
gume 0:1f82672b8755 4036 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4037 /* Convert the raw gravity z to m/s2*/
gume 0:1f82672b8755 4038 data_f = (float)(reg_gravity_z_s16/BNO055_GRAVITY_DIV_MSQ);
gume 0:1f82672b8755 4039 *gravity_z_f = data_f;
gume 0:1f82672b8755 4040 } else {
gume 0:1f82672b8755 4041 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4042 }
gume 0:1f82672b8755 4043 return com_rslt;
gume 0:1f82672b8755 4044 }
gume 0:1f82672b8755 4045 /*!
gume 0:1f82672b8755 4046 * @brief This API is used to convert the gravity xyz raw data
gume 0:1f82672b8755 4047 * to meterpersecseq output as float
gume 0:1f82672b8755 4048 *
gume 0:1f82672b8755 4049 * @param gravity_xyz : The meterpersecseq data of gravity xyz
gume 0:1f82672b8755 4050 *
gume 0:1f82672b8755 4051 * Parameter | result
gume 0:1f82672b8755 4052 * --------- | -----------------
gume 0:1f82672b8755 4053 * x | meterpersecseq data of gravity
gume 0:1f82672b8755 4054 * y | meterpersecseq data of gravity
gume 0:1f82672b8755 4055 * z | meterpersecseq data of gravity
gume 0:1f82672b8755 4056 *
gume 0:1f82672b8755 4057 *
gume 0:1f82672b8755 4058 * @return results of bus communication function
gume 0:1f82672b8755 4059 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 4060 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 4061 *
gume 0:1f82672b8755 4062 *
gume 0:1f82672b8755 4063 */
gume 0:1f82672b8755 4064 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_gravity_xyz_msq(
gume 0:1f82672b8755 4065 struct bno055_gravity_float_t *gravity_xyz)
gume 0:1f82672b8755 4066 {
gume 0:1f82672b8755 4067 /* Variable used to return value of
gume 0:1f82672b8755 4068 communication routine*/
gume 0:1f82672b8755 4069 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4070 struct bno055_gravity_t reg_gravity_xyz = {
gume 0:1f82672b8755 4071 BNO055_INIT_VALUE, BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 4072 /* Read raw gravity of xyz */
gume 0:1f82672b8755 4073 com_rslt = bno055_read_gravity_xyz(&reg_gravity_xyz);
gume 0:1f82672b8755 4074 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4075 /* Convert raw gravity xyz to meterpersecseq */
gume 0:1f82672b8755 4076 gravity_xyz->x =
gume 0:1f82672b8755 4077 (float)(reg_gravity_xyz.x/BNO055_GRAVITY_DIV_MSQ);
gume 0:1f82672b8755 4078 gravity_xyz->y =
gume 0:1f82672b8755 4079 (float)(reg_gravity_xyz.y/BNO055_GRAVITY_DIV_MSQ);
gume 0:1f82672b8755 4080 gravity_xyz->z =
gume 0:1f82672b8755 4081 (float)(reg_gravity_xyz.z/BNO055_GRAVITY_DIV_MSQ);
gume 0:1f82672b8755 4082 } else {
gume 0:1f82672b8755 4083 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4084 }
gume 0:1f82672b8755 4085 return com_rslt;
gume 0:1f82672b8755 4086 }
gume 0:1f82672b8755 4087 /*!
gume 0:1f82672b8755 4088 * @brief This API is used to convert the temperature
gume 0:1f82672b8755 4089 * data to Fahrenheit output as float
gume 0:1f82672b8755 4090 *
gume 0:1f82672b8755 4091 * @param temp_f : The float value of temperature Fahrenheit
gume 0:1f82672b8755 4092 *
gume 0:1f82672b8755 4093 * @return results of bus communication function
gume 0:1f82672b8755 4094 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 4095 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 4096 *
gume 0:1f82672b8755 4097 *
gume 0:1f82672b8755 4098 */
gume 0:1f82672b8755 4099 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_temp_fahrenheit(
gume 0:1f82672b8755 4100 float *temp_f)
gume 0:1f82672b8755 4101 {
gume 0:1f82672b8755 4102 /* Variable used to return value of
gume 0:1f82672b8755 4103 communication routine*/
gume 0:1f82672b8755 4104 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4105 s8 reg_temp_s8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4106 float data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4107 u8 temp_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4108 /* Read the current temperature unit and set the
gume 0:1f82672b8755 4109 unit as Fahrenheit if the unit is in Celsius */
gume 0:1f82672b8755 4110 com_rslt = bno055_get_temp_unit(&temp_unit_u8);
gume 0:1f82672b8755 4111 if (temp_unit_u8 != BNO055_TEMP_UNIT_FAHRENHEIT)
gume 0:1f82672b8755 4112 com_rslt += bno055_set_temp_unit(BNO055_TEMP_UNIT_FAHRENHEIT);
gume 0:1f82672b8755 4113 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4114 /* Read the raw temperature data */
gume 0:1f82672b8755 4115 com_rslt += bno055_read_temp_data(&reg_temp_s8);
gume 0:1f82672b8755 4116 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4117 /* Convert raw temperature data to Fahrenheit*/
gume 0:1f82672b8755 4118 data_f = (float)
gume 0:1f82672b8755 4119 (reg_temp_s8/BNO055_TEMP_DIV_FAHRENHEIT);
gume 0:1f82672b8755 4120 *temp_f = data_f;
gume 0:1f82672b8755 4121 } else {
gume 0:1f82672b8755 4122 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4123 }
gume 0:1f82672b8755 4124 } else {
gume 0:1f82672b8755 4125 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4126 }
gume 0:1f82672b8755 4127 return com_rslt;
gume 0:1f82672b8755 4128 }
gume 0:1f82672b8755 4129 /*!
gume 0:1f82672b8755 4130 * @brief This API is used to convert the temperature
gume 0:1f82672b8755 4131 * data to Celsius output as float
gume 0:1f82672b8755 4132 *
gume 0:1f82672b8755 4133 * @param temp_f : The float value of temperature Celsius
gume 0:1f82672b8755 4134 *
gume 0:1f82672b8755 4135 * @return results of bus communication function
gume 0:1f82672b8755 4136 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 4137 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 4138 *
gume 0:1f82672b8755 4139 *
gume 0:1f82672b8755 4140 *
gume 0:1f82672b8755 4141 */
gume 0:1f82672b8755 4142 BNO055_RETURN_FUNCTION_TYPE bno055_convert_float_temp_celsius(
gume 0:1f82672b8755 4143 float *temp_f)
gume 0:1f82672b8755 4144 {
gume 0:1f82672b8755 4145 /* Variable used to return value of
gume 0:1f82672b8755 4146 communication routine*/
gume 0:1f82672b8755 4147 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4148 s8 reg_temp_s8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4149 float data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4150 u8 temp_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4151 /* Read the current temperature unit and set the
gume 0:1f82672b8755 4152 unit as Fahrenheit if the unit is in Celsius */
gume 0:1f82672b8755 4153 com_rslt = bno055_get_temp_unit(&temp_unit_u8);
gume 0:1f82672b8755 4154 if (temp_unit_u8 != BNO055_TEMP_UNIT_CELSIUS)
gume 0:1f82672b8755 4155 com_rslt += bno055_set_temp_unit(BNO055_TEMP_UNIT_CELSIUS);
gume 0:1f82672b8755 4156 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4157 /* Read the raw temperature data */
gume 0:1f82672b8755 4158 com_rslt += bno055_read_temp_data(&reg_temp_s8);
gume 0:1f82672b8755 4159 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4160 /* Convert raw temperature data to Fahrenheit*/
gume 0:1f82672b8755 4161 data_f =
gume 0:1f82672b8755 4162 (float)(reg_temp_s8/BNO055_TEMP_DIV_CELSIUS);
gume 0:1f82672b8755 4163 *temp_f = data_f;
gume 0:1f82672b8755 4164 } else {
gume 0:1f82672b8755 4165 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4166 }
gume 0:1f82672b8755 4167 } else {
gume 0:1f82672b8755 4168 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4169 }
gume 0:1f82672b8755 4170 return com_rslt;
gume 0:1f82672b8755 4171 }
gume 0:1f82672b8755 4172 #endif
gume 0:1f82672b8755 4173 #ifdef BNO055_DOUBLE_ENABLE
gume 0:1f82672b8755 4174 /*!
gume 0:1f82672b8755 4175 * @brief This API is used to convert the accel x raw data
gume 0:1f82672b8755 4176 * to meterpersecseq output as double
gume 0:1f82672b8755 4177 *
gume 0:1f82672b8755 4178 * @param accel_x_d : The accel x meterpersecseq data
gume 0:1f82672b8755 4179 *
gume 0:1f82672b8755 4180 *
gume 0:1f82672b8755 4181 *
gume 0:1f82672b8755 4182 * @return results of bus communication function
gume 0:1f82672b8755 4183 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 4184 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 4185 *
gume 0:1f82672b8755 4186 *
gume 0:1f82672b8755 4187 */
gume 0:1f82672b8755 4188 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_accel_x_msq(
gume 0:1f82672b8755 4189 double *accel_x_d)
gume 0:1f82672b8755 4190 {
gume 0:1f82672b8755 4191 /* Variable used to return value of
gume 0:1f82672b8755 4192 communication routine*/
gume 0:1f82672b8755 4193 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4194 s16 reg_accel_x_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4195 double data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4196 u8 accel_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4197 /* Read the current accel unit and set the
gume 0:1f82672b8755 4198 unit as m/s2 if the unit is in mg*/
gume 0:1f82672b8755 4199 com_rslt = bno055_get_accel_unit(&accel_unit_u8);
gume 0:1f82672b8755 4200 if (accel_unit_u8 != BNO055_ACCEL_UNIT_MSQ)
gume 0:1f82672b8755 4201 com_rslt += bno055_set_accel_unit(BNO055_ACCEL_UNIT_MSQ);
gume 0:1f82672b8755 4202 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4203 /* Read the accel raw y data*/
gume 0:1f82672b8755 4204 com_rslt += bno055_read_accel_x(&reg_accel_x_s16);
gume 0:1f82672b8755 4205 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4206 /* Convert the raw x to m/s2 */
gume 0:1f82672b8755 4207 data_f =
gume 0:1f82672b8755 4208 (double)(reg_accel_x_s16/BNO055_ACCEL_DIV_MSQ);
gume 0:1f82672b8755 4209 *accel_x_d = data_f;
gume 0:1f82672b8755 4210 } else {
gume 0:1f82672b8755 4211 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4212 }
gume 0:1f82672b8755 4213 } else {
gume 0:1f82672b8755 4214 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4215 }
gume 0:1f82672b8755 4216 return com_rslt;
gume 0:1f82672b8755 4217 }
gume 0:1f82672b8755 4218 /*!
gume 0:1f82672b8755 4219 * @brief This API is used to convert the accel x raw data
gume 0:1f82672b8755 4220 * to millig output as double
gume 0:1f82672b8755 4221 *
gume 0:1f82672b8755 4222 * @param accel_x_d : The accel x millig data
gume 0:1f82672b8755 4223 *
gume 0:1f82672b8755 4224 *
gume 0:1f82672b8755 4225 *
gume 0:1f82672b8755 4226 * @return results of bus communication function
gume 0:1f82672b8755 4227 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 4228 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 4229 *
gume 0:1f82672b8755 4230 *
gume 0:1f82672b8755 4231 *
gume 0:1f82672b8755 4232 */
gume 0:1f82672b8755 4233 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_accel_x_mg(
gume 0:1f82672b8755 4234 double *accel_x_d)
gume 0:1f82672b8755 4235 {
gume 0:1f82672b8755 4236 /* Variable used to return value of
gume 0:1f82672b8755 4237 communication routine*/
gume 0:1f82672b8755 4238 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4239 s16 reg_accel_x_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4240 double data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4241 u8 accel_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4242 /* Read the current accel unit and set the
gume 0:1f82672b8755 4243 unit as mg if the unit is in m/s2*/
gume 0:1f82672b8755 4244 com_rslt = bno055_get_accel_unit(&accel_unit_u8);
gume 0:1f82672b8755 4245 if (accel_unit_u8 != BNO055_ACCEL_UNIT_MG)
gume 0:1f82672b8755 4246 com_rslt += bno055_set_accel_unit(BNO055_ACCEL_UNIT_MG);
gume 0:1f82672b8755 4247 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4248 /* Read the accel raw y data*/
gume 0:1f82672b8755 4249 com_rslt += bno055_read_accel_x(&reg_accel_x_s16);
gume 0:1f82672b8755 4250 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4251 /* Convert the raw x to mg */
gume 0:1f82672b8755 4252 data_f =
gume 0:1f82672b8755 4253 (double)(reg_accel_x_s16/BNO055_ACCEL_DIV_MG);
gume 0:1f82672b8755 4254 *accel_x_d = data_f;
gume 0:1f82672b8755 4255 } else {
gume 0:1f82672b8755 4256 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4257 }
gume 0:1f82672b8755 4258 } else {
gume 0:1f82672b8755 4259 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4260 }
gume 0:1f82672b8755 4261 return com_rslt;
gume 0:1f82672b8755 4262 }
gume 0:1f82672b8755 4263 /*!
gume 0:1f82672b8755 4264 * @brief This API is used to convert the accel y raw data
gume 0:1f82672b8755 4265 * to meterpersecseq output as double
gume 0:1f82672b8755 4266 *
gume 0:1f82672b8755 4267 * @param accel_y_d : The accel y meterpersecseq data
gume 0:1f82672b8755 4268 *
gume 0:1f82672b8755 4269 *
gume 0:1f82672b8755 4270 *
gume 0:1f82672b8755 4271 * @return results of bus communication function
gume 0:1f82672b8755 4272 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 4273 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 4274 *
gume 0:1f82672b8755 4275 *
gume 0:1f82672b8755 4276 *
gume 0:1f82672b8755 4277 */
gume 0:1f82672b8755 4278 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_accel_y_msq(
gume 0:1f82672b8755 4279 double *accel_y_d)
gume 0:1f82672b8755 4280 {
gume 0:1f82672b8755 4281 /* Variable used to return value of
gume 0:1f82672b8755 4282 communication routine*/
gume 0:1f82672b8755 4283 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4284 s16 reg_accel_y_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4285 double data_f = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4286 u8 accel_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4287 /* Read the current accel unit and set the
gume 0:1f82672b8755 4288 unit as m/s2 if the unit is in mg*/
gume 0:1f82672b8755 4289 com_rslt = bno055_get_accel_unit(&accel_unit_u8);
gume 0:1f82672b8755 4290 if (accel_unit_u8 != BNO055_ACCEL_UNIT_MSQ)
gume 0:1f82672b8755 4291 com_rslt += bno055_set_accel_unit(BNO055_ACCEL_UNIT_MSQ);
gume 0:1f82672b8755 4292 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4293 /* Read the accel raw y data*/
gume 0:1f82672b8755 4294 com_rslt += bno055_read_accel_y(&reg_accel_y_s16);
gume 0:1f82672b8755 4295 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4296 /* Convert the raw x to m/s2 */
gume 0:1f82672b8755 4297 data_f =
gume 0:1f82672b8755 4298 (double)(reg_accel_y_s16/BNO055_ACCEL_DIV_MSQ);
gume 0:1f82672b8755 4299 *accel_y_d = data_f;
gume 0:1f82672b8755 4300 } else {
gume 0:1f82672b8755 4301 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4302 }
gume 0:1f82672b8755 4303 } else {
gume 0:1f82672b8755 4304 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4305 }
gume 0:1f82672b8755 4306 return com_rslt;
gume 0:1f82672b8755 4307 }
gume 0:1f82672b8755 4308 /*!
gume 0:1f82672b8755 4309 * @brief This API is used to convert the accel y raw data
gume 0:1f82672b8755 4310 * to millig output as double
gume 0:1f82672b8755 4311 *
gume 0:1f82672b8755 4312 * @param accel_y_d : The accel y millig data
gume 0:1f82672b8755 4313 *
gume 0:1f82672b8755 4314 *
gume 0:1f82672b8755 4315 *
gume 0:1f82672b8755 4316 * @return results of bus communication function
gume 0:1f82672b8755 4317 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 4318 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 4319 *
gume 0:1f82672b8755 4320 *
gume 0:1f82672b8755 4321 */
gume 0:1f82672b8755 4322 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_accel_y_mg(
gume 0:1f82672b8755 4323 double *accel_y_d)
gume 0:1f82672b8755 4324 {
gume 0:1f82672b8755 4325 /* Variable used to return value of
gume 0:1f82672b8755 4326 communication routine*/
gume 0:1f82672b8755 4327 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4328 s16 reg_accel_y_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4329 double data_d = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4330 u8 accel_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4331 /* Read the current accel unit and set the
gume 0:1f82672b8755 4332 unit as mg if the unit is in m/s2*/
gume 0:1f82672b8755 4333 com_rslt = bno055_get_accel_unit(&accel_unit_u8);
gume 0:1f82672b8755 4334 if (accel_unit_u8 != BNO055_ACCEL_UNIT_MG)
gume 0:1f82672b8755 4335 com_rslt += bno055_set_accel_unit(BNO055_ACCEL_UNIT_MG);
gume 0:1f82672b8755 4336 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4337 /* Read the accel raw y data*/
gume 0:1f82672b8755 4338 com_rslt += bno055_read_accel_y(&reg_accel_y_s16);
gume 0:1f82672b8755 4339 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4340 /* Convert the raw y to mg */
gume 0:1f82672b8755 4341 data_d =
gume 0:1f82672b8755 4342 (double)(reg_accel_y_s16/BNO055_ACCEL_DIV_MG);
gume 0:1f82672b8755 4343 *accel_y_d = data_d;
gume 0:1f82672b8755 4344 } else {
gume 0:1f82672b8755 4345 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4346 }
gume 0:1f82672b8755 4347 } else {
gume 0:1f82672b8755 4348 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4349 }
gume 0:1f82672b8755 4350 return com_rslt;
gume 0:1f82672b8755 4351 }
gume 0:1f82672b8755 4352 /*!
gume 0:1f82672b8755 4353 * @brief This API is used to convert the accel z raw data
gume 0:1f82672b8755 4354 * to meterpersecseq output as double
gume 0:1f82672b8755 4355 *
gume 0:1f82672b8755 4356 * @param accel_z_d : The accel z meterpersecseq data
gume 0:1f82672b8755 4357 *
gume 0:1f82672b8755 4358 *
gume 0:1f82672b8755 4359 *
gume 0:1f82672b8755 4360 * @return results of bus communication function
gume 0:1f82672b8755 4361 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 4362 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 4363 */
gume 0:1f82672b8755 4364 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_accel_z_msq(
gume 0:1f82672b8755 4365 double *accel_z_d)
gume 0:1f82672b8755 4366 {
gume 0:1f82672b8755 4367 /* Variable used to return value of
gume 0:1f82672b8755 4368 communication routine*/
gume 0:1f82672b8755 4369 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4370 s16 reg_accel_z_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4371 double data_d = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4372 u8 accel_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4373 /* Read the current accel unit and set the
gume 0:1f82672b8755 4374 unit as m/s2 if the unit is in mg*/
gume 0:1f82672b8755 4375 com_rslt = bno055_get_accel_unit(&accel_unit_u8);
gume 0:1f82672b8755 4376 if (accel_unit_u8 != BNO055_ACCEL_UNIT_MSQ)
gume 0:1f82672b8755 4377 com_rslt += bno055_set_accel_unit(BNO055_ACCEL_UNIT_MSQ);
gume 0:1f82672b8755 4378 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4379 /* Read the accel raw z data*/
gume 0:1f82672b8755 4380 com_rslt += bno055_read_accel_z(&reg_accel_z_s16);
gume 0:1f82672b8755 4381 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4382 /* Convert the raw z to m/s2 */
gume 0:1f82672b8755 4383 data_d =
gume 0:1f82672b8755 4384 (double)(reg_accel_z_s16/BNO055_ACCEL_DIV_MSQ);
gume 0:1f82672b8755 4385 *accel_z_d = data_d;
gume 0:1f82672b8755 4386 } else {
gume 0:1f82672b8755 4387 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4388 }
gume 0:1f82672b8755 4389 } else {
gume 0:1f82672b8755 4390 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4391 }
gume 0:1f82672b8755 4392 return com_rslt;
gume 0:1f82672b8755 4393 }
gume 0:1f82672b8755 4394 /*!
gume 0:1f82672b8755 4395 * @brief This API is used to convert the accel z raw data
gume 0:1f82672b8755 4396 * to millig output as double
gume 0:1f82672b8755 4397 *
gume 0:1f82672b8755 4398 * @param accel_z_d : The accel z millig data
gume 0:1f82672b8755 4399 *
gume 0:1f82672b8755 4400 *
gume 0:1f82672b8755 4401 *
gume 0:1f82672b8755 4402 * @return results of bus communication function
gume 0:1f82672b8755 4403 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 4404 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 4405 *
gume 0:1f82672b8755 4406 */
gume 0:1f82672b8755 4407 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_accel_z_mg(
gume 0:1f82672b8755 4408 double *accel_z_d)
gume 0:1f82672b8755 4409 {
gume 0:1f82672b8755 4410 /* Variable used to return value of
gume 0:1f82672b8755 4411 communication routine*/
gume 0:1f82672b8755 4412 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4413 s16 reg_accel_z_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4414 double data_d = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4415 u8 accel_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4416 /* Read the current accel unit and set the
gume 0:1f82672b8755 4417 unit as mg if the unit is in m/s2*/
gume 0:1f82672b8755 4418 com_rslt = bno055_get_accel_unit(&accel_unit_u8);
gume 0:1f82672b8755 4419 if (accel_unit_u8 != BNO055_ACCEL_UNIT_MG)
gume 0:1f82672b8755 4420 com_rslt += bno055_set_accel_unit(BNO055_ACCEL_UNIT_MG);
gume 0:1f82672b8755 4421 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4422 /* Read the accel raw z data*/
gume 0:1f82672b8755 4423 com_rslt += bno055_read_accel_z(&reg_accel_z_s16);
gume 0:1f82672b8755 4424 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4425 /* Convert the raw z to mg */
gume 0:1f82672b8755 4426 data_d =
gume 0:1f82672b8755 4427 (double)(reg_accel_z_s16/BNO055_ACCEL_DIV_MG);
gume 0:1f82672b8755 4428 *accel_z_d = data_d;
gume 0:1f82672b8755 4429 } else {
gume 0:1f82672b8755 4430 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4431 }
gume 0:1f82672b8755 4432 } else {
gume 0:1f82672b8755 4433 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4434 }
gume 0:1f82672b8755 4435 return com_rslt;
gume 0:1f82672b8755 4436 }
gume 0:1f82672b8755 4437 /*!
gume 0:1f82672b8755 4438 * @brief This API is used to convert the accel xyz raw data
gume 0:1f82672b8755 4439 * to meterpersecseq output as double
gume 0:1f82672b8755 4440 *
gume 0:1f82672b8755 4441 * @param accel_xyz : The meterpersecseq data of accel xyz
gume 0:1f82672b8755 4442 *
gume 0:1f82672b8755 4443 * Parameter | result
gume 0:1f82672b8755 4444 * --------- | -----------------
gume 0:1f82672b8755 4445 * x | meterpersecseq data of accel
gume 0:1f82672b8755 4446 * y | meterpersecseq data of accel
gume 0:1f82672b8755 4447 * z | meterpersecseq data of accel
gume 0:1f82672b8755 4448 *
gume 0:1f82672b8755 4449 *
gume 0:1f82672b8755 4450 * @return results of bus communication function
gume 0:1f82672b8755 4451 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 4452 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 4453 *
gume 0:1f82672b8755 4454 *
gume 0:1f82672b8755 4455 */
gume 0:1f82672b8755 4456 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_accel_xyz_msq(
gume 0:1f82672b8755 4457 struct bno055_accel_double_t *accel_xyz)
gume 0:1f82672b8755 4458 {
gume 0:1f82672b8755 4459 /* Variable used to return value of
gume 0:1f82672b8755 4460 communication routine*/
gume 0:1f82672b8755 4461 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4462 struct bno055_accel_t reg_accel_xyz = {
gume 0:1f82672b8755 4463 BNO055_INIT_VALUE, BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 4464 u8 accel_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4465 /* Read the current accel unit and set the
gume 0:1f82672b8755 4466 unit as m/s2 if the unit is in mg*/
gume 0:1f82672b8755 4467 com_rslt = bno055_get_accel_unit(&accel_unit_u8);
gume 0:1f82672b8755 4468 if (accel_unit_u8 != BNO055_ACCEL_UNIT_MSQ)
gume 0:1f82672b8755 4469 com_rslt += bno055_set_accel_unit(BNO055_ACCEL_UNIT_MSQ);
gume 0:1f82672b8755 4470 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4471 /* Read the accel raw xyz data*/
gume 0:1f82672b8755 4472 com_rslt += bno055_read_accel_xyz(&reg_accel_xyz);
gume 0:1f82672b8755 4473 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4474 /* Convert raw xyz to m/s2*/
gume 0:1f82672b8755 4475 accel_xyz->x =
gume 0:1f82672b8755 4476 (double)(reg_accel_xyz.x/BNO055_ACCEL_DIV_MSQ);
gume 0:1f82672b8755 4477 accel_xyz->y =
gume 0:1f82672b8755 4478 (double)(reg_accel_xyz.y/BNO055_ACCEL_DIV_MSQ);
gume 0:1f82672b8755 4479 accel_xyz->z =
gume 0:1f82672b8755 4480 (double)(reg_accel_xyz.z/BNO055_ACCEL_DIV_MSQ);
gume 0:1f82672b8755 4481 } else {
gume 0:1f82672b8755 4482 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4483 }
gume 0:1f82672b8755 4484 } else {
gume 0:1f82672b8755 4485 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4486 }
gume 0:1f82672b8755 4487 return com_rslt;
gume 0:1f82672b8755 4488 }
gume 0:1f82672b8755 4489 /*!
gume 0:1f82672b8755 4490 * @brief This API is used to convert the accel xyz raw data
gume 0:1f82672b8755 4491 * to millig output as double
gume 0:1f82672b8755 4492 *
gume 0:1f82672b8755 4493 * @param accel_xyz : The millig data of accel xyz
gume 0:1f82672b8755 4494 *
gume 0:1f82672b8755 4495 * Parameter | result
gume 0:1f82672b8755 4496 * --------- | -----------------
gume 0:1f82672b8755 4497 * x | millig data of accel
gume 0:1f82672b8755 4498 * y | millig data of accel
gume 0:1f82672b8755 4499 * z | millig data of accel
gume 0:1f82672b8755 4500 *
gume 0:1f82672b8755 4501 *
gume 0:1f82672b8755 4502 * @return results of bus communication function
gume 0:1f82672b8755 4503 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 4504 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 4505 *
gume 0:1f82672b8755 4506 */
gume 0:1f82672b8755 4507 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_accel_xyz_mg(
gume 0:1f82672b8755 4508 struct bno055_accel_double_t *accel_xyz)
gume 0:1f82672b8755 4509 {
gume 0:1f82672b8755 4510 /* Variable used to return value of
gume 0:1f82672b8755 4511 communication routine*/
gume 0:1f82672b8755 4512 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4513 struct bno055_accel_t reg_accel_xyz = {
gume 0:1f82672b8755 4514 BNO055_INIT_VALUE, BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 4515 u8 accel_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4516 /* Read the current accel unit and set the
gume 0:1f82672b8755 4517 unit as m/s2 if the unit is in mg*/
gume 0:1f82672b8755 4518 com_rslt = bno055_get_accel_unit(&accel_unit_u8);
gume 0:1f82672b8755 4519 if (accel_unit_u8 != BNO055_ACCEL_UNIT_MG)
gume 0:1f82672b8755 4520 com_rslt += bno055_set_accel_unit(BNO055_ACCEL_UNIT_MG);
gume 0:1f82672b8755 4521 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4522 /* Read the accel raw xyz data*/
gume 0:1f82672b8755 4523 com_rslt += bno055_read_accel_xyz(&reg_accel_xyz);
gume 0:1f82672b8755 4524 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4525 /* Convert raw xyz to mg*/
gume 0:1f82672b8755 4526 accel_xyz->x =
gume 0:1f82672b8755 4527 (double)(reg_accel_xyz.x/BNO055_ACCEL_DIV_MG);
gume 0:1f82672b8755 4528 accel_xyz->y =
gume 0:1f82672b8755 4529 (double)(reg_accel_xyz.y/BNO055_ACCEL_DIV_MG);
gume 0:1f82672b8755 4530 accel_xyz->z =
gume 0:1f82672b8755 4531 (double)(reg_accel_xyz.z/BNO055_ACCEL_DIV_MG);
gume 0:1f82672b8755 4532 } else {
gume 0:1f82672b8755 4533 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4534 }
gume 0:1f82672b8755 4535 } else {
gume 0:1f82672b8755 4536 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4537 }
gume 0:1f82672b8755 4538 return com_rslt;
gume 0:1f82672b8755 4539 }
gume 0:1f82672b8755 4540 /*!
gume 0:1f82672b8755 4541 * @brief This API is used to convert the mag x raw data
gume 0:1f82672b8755 4542 * to microTesla output as double
gume 0:1f82672b8755 4543 *
gume 0:1f82672b8755 4544 * @param mag_x_d : The mag x microTesla data
gume 0:1f82672b8755 4545 *
gume 0:1f82672b8755 4546 *
gume 0:1f82672b8755 4547 *
gume 0:1f82672b8755 4548 * @return results of bus communication function
gume 0:1f82672b8755 4549 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 4550 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 4551 *
gume 0:1f82672b8755 4552 *
gume 0:1f82672b8755 4553 *
gume 0:1f82672b8755 4554 */
gume 0:1f82672b8755 4555 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_mag_x_uT(
gume 0:1f82672b8755 4556 double *mag_x_d)
gume 0:1f82672b8755 4557 {
gume 0:1f82672b8755 4558 /* Variable used to return value of
gume 0:1f82672b8755 4559 communication routine*/
gume 0:1f82672b8755 4560 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4561 s16 reg_mag_x_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4562 double data_d = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4563 /* Read raw mag x data */
gume 0:1f82672b8755 4564 com_rslt = bno055_read_mag_x(&reg_mag_x_s16);
gume 0:1f82672b8755 4565 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4566 /* Convert raw mag x to microTesla */
gume 0:1f82672b8755 4567 data_d = (double)(reg_mag_x_s16/BNO055_MAG_DIV_UT);
gume 0:1f82672b8755 4568 *mag_x_d = data_d;
gume 0:1f82672b8755 4569 } else {
gume 0:1f82672b8755 4570 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4571 }
gume 0:1f82672b8755 4572 return com_rslt;
gume 0:1f82672b8755 4573 }
gume 0:1f82672b8755 4574 /*!
gume 0:1f82672b8755 4575 * @brief This API is used to convert the mag y raw data
gume 0:1f82672b8755 4576 * to microTesla output as double
gume 0:1f82672b8755 4577 *
gume 0:1f82672b8755 4578 * @param mag_y_d : The mag y microTesla data
gume 0:1f82672b8755 4579 *
gume 0:1f82672b8755 4580 *
gume 0:1f82672b8755 4581 *
gume 0:1f82672b8755 4582 * @return results of bus communication function
gume 0:1f82672b8755 4583 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 4584 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 4585 *
gume 0:1f82672b8755 4586 *
gume 0:1f82672b8755 4587 */
gume 0:1f82672b8755 4588 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_mag_y_uT(
gume 0:1f82672b8755 4589 double *mag_y_d)
gume 0:1f82672b8755 4590 {
gume 0:1f82672b8755 4591 /* Variable used to return value of
gume 0:1f82672b8755 4592 communication routine*/
gume 0:1f82672b8755 4593 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4594 s16 reg_mag_y_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4595 double data_d = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4596 /* Read raw mag y data */
gume 0:1f82672b8755 4597 com_rslt = bno055_read_mag_y(&reg_mag_y_s16);
gume 0:1f82672b8755 4598 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4599 /* Convert raw mag y to microTesla */
gume 0:1f82672b8755 4600 data_d = (double)(reg_mag_y_s16/BNO055_MAG_DIV_UT);
gume 0:1f82672b8755 4601 *mag_y_d = data_d;
gume 0:1f82672b8755 4602 } else {
gume 0:1f82672b8755 4603 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4604 }
gume 0:1f82672b8755 4605 return com_rslt;
gume 0:1f82672b8755 4606 }
gume 0:1f82672b8755 4607 /*!
gume 0:1f82672b8755 4608 * @brief This API is used to convert the mag z raw data
gume 0:1f82672b8755 4609 * to microTesla output as double
gume 0:1f82672b8755 4610 *
gume 0:1f82672b8755 4611 * @param mag_z_d : The mag z microTesla data
gume 0:1f82672b8755 4612 *
gume 0:1f82672b8755 4613 *
gume 0:1f82672b8755 4614 *
gume 0:1f82672b8755 4615 * @return results of bus communication function
gume 0:1f82672b8755 4616 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 4617 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 4618 *
gume 0:1f82672b8755 4619 *
gume 0:1f82672b8755 4620 */
gume 0:1f82672b8755 4621 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_mag_z_uT(
gume 0:1f82672b8755 4622 double *mag_z_d)
gume 0:1f82672b8755 4623 {
gume 0:1f82672b8755 4624 /* Variable used to return value of
gume 0:1f82672b8755 4625 communication routine*/
gume 0:1f82672b8755 4626 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4627 s16 reg_mag_z_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4628 double data_d = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4629 /* Read raw mag x */
gume 0:1f82672b8755 4630 com_rslt = bno055_read_mag_z(&reg_mag_z_s16);
gume 0:1f82672b8755 4631 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4632 /* Convert raw mag x to microTesla */
gume 0:1f82672b8755 4633 data_d = (double)(reg_mag_z_s16/BNO055_MAG_DIV_UT);
gume 0:1f82672b8755 4634 *mag_z_d = data_d;
gume 0:1f82672b8755 4635 } else {
gume 0:1f82672b8755 4636 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4637 }
gume 0:1f82672b8755 4638 return com_rslt;
gume 0:1f82672b8755 4639 }
gume 0:1f82672b8755 4640 /*!
gume 0:1f82672b8755 4641 * @brief This API is used to convert the mag yz raw data
gume 0:1f82672b8755 4642 * to microTesla output as double
gume 0:1f82672b8755 4643 *
gume 0:1f82672b8755 4644 * @param mag_xyz : The microTesla data of mag xyz
gume 0:1f82672b8755 4645 *
gume 0:1f82672b8755 4646 * Parameter | result
gume 0:1f82672b8755 4647 * --------- | -----------------
gume 0:1f82672b8755 4648 * x | microTesla data of mag
gume 0:1f82672b8755 4649 * y | microTesla data of mag
gume 0:1f82672b8755 4650 * z | microTesla data of mag
gume 0:1f82672b8755 4651 *
gume 0:1f82672b8755 4652 *
gume 0:1f82672b8755 4653 * @return results of bus communication function
gume 0:1f82672b8755 4654 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 4655 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 4656 *
gume 0:1f82672b8755 4657 */
gume 0:1f82672b8755 4658 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_mag_xyz_uT(
gume 0:1f82672b8755 4659 struct bno055_mag_double_t *mag_xyz)
gume 0:1f82672b8755 4660 {
gume 0:1f82672b8755 4661 /* Variable used to return value of
gume 0:1f82672b8755 4662 communication routine*/
gume 0:1f82672b8755 4663 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4664 struct bno055_mag_t reg_mag_xyz = {
gume 0:1f82672b8755 4665 BNO055_INIT_VALUE, BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 4666 /* Read raw mag xyz data */
gume 0:1f82672b8755 4667 com_rslt = bno055_read_mag_xyz(&reg_mag_xyz);
gume 0:1f82672b8755 4668 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4669 /* Convert raw mag xyz to microTesla*/
gume 0:1f82672b8755 4670 mag_xyz->x =
gume 0:1f82672b8755 4671 (double)(reg_mag_xyz.x/BNO055_MAG_DIV_UT);
gume 0:1f82672b8755 4672 mag_xyz->y =
gume 0:1f82672b8755 4673 (double)(reg_mag_xyz.y/BNO055_MAG_DIV_UT);
gume 0:1f82672b8755 4674 mag_xyz->z =
gume 0:1f82672b8755 4675 (double)(reg_mag_xyz.z/BNO055_MAG_DIV_UT);
gume 0:1f82672b8755 4676 } else {
gume 0:1f82672b8755 4677 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4678 }
gume 0:1f82672b8755 4679
gume 0:1f82672b8755 4680 return com_rslt;
gume 0:1f82672b8755 4681 }
gume 0:1f82672b8755 4682 /*!
gume 0:1f82672b8755 4683 * @brief This API is used to convert the gyro x raw data
gume 0:1f82672b8755 4684 * to dps output as double
gume 0:1f82672b8755 4685 *
gume 0:1f82672b8755 4686 * @param gyro_x_d : The gyro x dps double data
gume 0:1f82672b8755 4687 *
gume 0:1f82672b8755 4688 *
gume 0:1f82672b8755 4689 *
gume 0:1f82672b8755 4690 * @return results of bus communication function
gume 0:1f82672b8755 4691 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 4692 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 4693 *
gume 0:1f82672b8755 4694 *
gume 0:1f82672b8755 4695 */
gume 0:1f82672b8755 4696 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_gyro_x_dps(
gume 0:1f82672b8755 4697 double *gyro_x_d)
gume 0:1f82672b8755 4698 {
gume 0:1f82672b8755 4699 /* Variable used to return value of
gume 0:1f82672b8755 4700 communication routine*/
gume 0:1f82672b8755 4701 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4702 s16 reg_gyro_x_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4703 double data_d = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4704 u8 gyro_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4705 /* Read the current gyro unit and set the
gume 0:1f82672b8755 4706 unit as dps if the unit is in rps */
gume 0:1f82672b8755 4707 com_rslt = bno055_get_gyro_unit(&gyro_unit_u8);
gume 0:1f82672b8755 4708 if (gyro_unit_u8 != BNO055_GYRO_UNIT_DPS)
gume 0:1f82672b8755 4709 com_rslt += bno055_set_gyro_unit(BNO055_GYRO_UNIT_DPS);
gume 0:1f82672b8755 4710 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4711 /* Read gyro raw x data */
gume 0:1f82672b8755 4712 com_rslt += bno055_read_gyro_x(&reg_gyro_x_s16);
gume 0:1f82672b8755 4713 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4714 /* Convert raw gyro x to dps */
gume 0:1f82672b8755 4715 data_d =
gume 0:1f82672b8755 4716 (double)(reg_gyro_x_s16/BNO055_GYRO_DIV_DPS);
gume 0:1f82672b8755 4717 *gyro_x_d = data_d;
gume 0:1f82672b8755 4718 } else {
gume 0:1f82672b8755 4719 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4720 }
gume 0:1f82672b8755 4721 } else {
gume 0:1f82672b8755 4722 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4723 }
gume 0:1f82672b8755 4724 return com_rslt;
gume 0:1f82672b8755 4725 }
gume 0:1f82672b8755 4726 /*!
gume 0:1f82672b8755 4727 * @brief This API is used to convert the gyro x raw data
gume 0:1f82672b8755 4728 * to rps output as double
gume 0:1f82672b8755 4729 *
gume 0:1f82672b8755 4730 * @param gyro_x_d : The gyro x dps double data
gume 0:1f82672b8755 4731 *
gume 0:1f82672b8755 4732 *
gume 0:1f82672b8755 4733 *
gume 0:1f82672b8755 4734 * @return results of bus communication function
gume 0:1f82672b8755 4735 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 4736 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 4737 *
gume 0:1f82672b8755 4738 *
gume 0:1f82672b8755 4739 */
gume 0:1f82672b8755 4740 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_gyro_x_rps(
gume 0:1f82672b8755 4741 double *gyro_x_d)
gume 0:1f82672b8755 4742 {
gume 0:1f82672b8755 4743 /* Variable used to return value of
gume 0:1f82672b8755 4744 communication routine*/
gume 0:1f82672b8755 4745 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4746 s16 reg_gyro_x_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4747 double data_d = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4748 u8 gyro_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4749 /* Read the current gyro unit and set the
gume 0:1f82672b8755 4750 unit as rps if the unit is in dps */
gume 0:1f82672b8755 4751 com_rslt = bno055_get_gyro_unit(&gyro_unit_u8);
gume 0:1f82672b8755 4752 if (gyro_unit_u8 != BNO055_GYRO_UNIT_RPS)
gume 0:1f82672b8755 4753 com_rslt += bno055_set_gyro_unit(BNO055_GYRO_UNIT_RPS);
gume 0:1f82672b8755 4754 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4755 /* Read gyro raw x data */
gume 0:1f82672b8755 4756 com_rslt += bno055_read_gyro_x(&reg_gyro_x_s16);
gume 0:1f82672b8755 4757 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4758 /* Convert raw gyro x to rps */
gume 0:1f82672b8755 4759 data_d =
gume 0:1f82672b8755 4760 (double)(reg_gyro_x_s16/BNO055_GYRO_DIV_RPS);
gume 0:1f82672b8755 4761 *gyro_x_d = data_d;
gume 0:1f82672b8755 4762 } else {
gume 0:1f82672b8755 4763 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4764 }
gume 0:1f82672b8755 4765 } else {
gume 0:1f82672b8755 4766 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4767 }
gume 0:1f82672b8755 4768 return com_rslt;
gume 0:1f82672b8755 4769 }
gume 0:1f82672b8755 4770 /*!
gume 0:1f82672b8755 4771 * @brief This API is used to convert the gyro y raw data
gume 0:1f82672b8755 4772 * to dps output as double
gume 0:1f82672b8755 4773 *
gume 0:1f82672b8755 4774 * @param gyro_y_d : The gyro y dps double data
gume 0:1f82672b8755 4775 *
gume 0:1f82672b8755 4776 *
gume 0:1f82672b8755 4777 *
gume 0:1f82672b8755 4778 * @return results of bus communication function
gume 0:1f82672b8755 4779 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 4780 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 4781 *
gume 0:1f82672b8755 4782 *
gume 0:1f82672b8755 4783 */
gume 0:1f82672b8755 4784 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_gyro_y_dps(
gume 0:1f82672b8755 4785 double *gyro_y_d)
gume 0:1f82672b8755 4786 {
gume 0:1f82672b8755 4787 /* Variable used to return value of
gume 0:1f82672b8755 4788 communication routine*/
gume 0:1f82672b8755 4789 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4790 s16 reg_gyro_y_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4791 double data_d = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4792 u8 gyro_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4793 /* Read the current gyro unit and set the
gume 0:1f82672b8755 4794 unit as dps if the unit is in rps */
gume 0:1f82672b8755 4795 com_rslt = bno055_get_gyro_unit(&gyro_unit_u8);
gume 0:1f82672b8755 4796 if (gyro_unit_u8 != BNO055_GYRO_UNIT_DPS)
gume 0:1f82672b8755 4797 com_rslt += bno055_set_gyro_unit(BNO055_GYRO_UNIT_DPS);
gume 0:1f82672b8755 4798 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4799 /* Read gyro raw y data */
gume 0:1f82672b8755 4800 com_rslt += bno055_read_gyro_y(&reg_gyro_y_s16);
gume 0:1f82672b8755 4801 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4802 /* Convert raw gyro y to dps */
gume 0:1f82672b8755 4803 data_d =
gume 0:1f82672b8755 4804 (double)(reg_gyro_y_s16/BNO055_GYRO_DIV_DPS);
gume 0:1f82672b8755 4805 *gyro_y_d = data_d;
gume 0:1f82672b8755 4806 } else {
gume 0:1f82672b8755 4807 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4808 }
gume 0:1f82672b8755 4809 } else {
gume 0:1f82672b8755 4810 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4811 }
gume 0:1f82672b8755 4812 return com_rslt;
gume 0:1f82672b8755 4813 }
gume 0:1f82672b8755 4814 /*!
gume 0:1f82672b8755 4815 * @brief This API is used to convert the gyro y raw data
gume 0:1f82672b8755 4816 * to rps output as double
gume 0:1f82672b8755 4817 *
gume 0:1f82672b8755 4818 * @param gyro_y_d : The gyro y dps double data
gume 0:1f82672b8755 4819 *
gume 0:1f82672b8755 4820 *
gume 0:1f82672b8755 4821 *
gume 0:1f82672b8755 4822 * @return results of bus communication function
gume 0:1f82672b8755 4823 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 4824 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 4825 *
gume 0:1f82672b8755 4826 *
gume 0:1f82672b8755 4827 */
gume 0:1f82672b8755 4828 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_gyro_y_rps(
gume 0:1f82672b8755 4829 double *gyro_y_d)
gume 0:1f82672b8755 4830 {
gume 0:1f82672b8755 4831 /* Variable used to return value of
gume 0:1f82672b8755 4832 communication routine*/
gume 0:1f82672b8755 4833 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4834 s16 reg_gyro_y_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4835 double data_d = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4836 u8 gyro_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4837 /* Read the current gyro unit and set the
gume 0:1f82672b8755 4838 unit as rps if the unit is in dps */
gume 0:1f82672b8755 4839 com_rslt = bno055_get_gyro_unit(&gyro_unit_u8);
gume 0:1f82672b8755 4840 if (gyro_unit_u8 != BNO055_GYRO_UNIT_RPS)
gume 0:1f82672b8755 4841 com_rslt += bno055_set_gyro_unit(BNO055_GYRO_UNIT_RPS);
gume 0:1f82672b8755 4842 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4843 /* Read gyro raw y data */
gume 0:1f82672b8755 4844 com_rslt += bno055_read_gyro_y(&reg_gyro_y_s16);
gume 0:1f82672b8755 4845 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4846 /* Convert raw gyro y to rps */
gume 0:1f82672b8755 4847 data_d =
gume 0:1f82672b8755 4848 (double)(reg_gyro_y_s16/BNO055_GYRO_DIV_RPS);
gume 0:1f82672b8755 4849 *gyro_y_d = data_d;
gume 0:1f82672b8755 4850 } else {
gume 0:1f82672b8755 4851 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4852 }
gume 0:1f82672b8755 4853 } else {
gume 0:1f82672b8755 4854 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4855 }
gume 0:1f82672b8755 4856 return com_rslt;
gume 0:1f82672b8755 4857 }
gume 0:1f82672b8755 4858 /*!
gume 0:1f82672b8755 4859 * @brief This API is used to convert the gyro z raw data
gume 0:1f82672b8755 4860 * to dps output as double
gume 0:1f82672b8755 4861 *
gume 0:1f82672b8755 4862 * @param gyro_z_d : The gyro z dps double data
gume 0:1f82672b8755 4863 *
gume 0:1f82672b8755 4864 *
gume 0:1f82672b8755 4865 *
gume 0:1f82672b8755 4866 * @return results of bus communication function
gume 0:1f82672b8755 4867 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 4868 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 4869 *
gume 0:1f82672b8755 4870 *
gume 0:1f82672b8755 4871 */
gume 0:1f82672b8755 4872 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_gyro_z_dps(
gume 0:1f82672b8755 4873 double *gyro_z_d)
gume 0:1f82672b8755 4874 {
gume 0:1f82672b8755 4875 /* Variable used to return value of
gume 0:1f82672b8755 4876 communication routine*/
gume 0:1f82672b8755 4877 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4878 s16 reg_gyro_z_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4879 double data_d = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4880 u8 gyro_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4881 /* Read the current gyro unit and set the
gume 0:1f82672b8755 4882 unit as dps if the unit is in rps */
gume 0:1f82672b8755 4883 com_rslt = bno055_get_gyro_unit(&gyro_unit_u8);
gume 0:1f82672b8755 4884 if (gyro_unit_u8 != BNO055_GYRO_UNIT_DPS)
gume 0:1f82672b8755 4885 com_rslt += bno055_set_gyro_unit(BNO055_GYRO_UNIT_DPS);
gume 0:1f82672b8755 4886 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4887 /* Read gyro raw z data */
gume 0:1f82672b8755 4888 com_rslt += bno055_read_gyro_z(&reg_gyro_z_s16);
gume 0:1f82672b8755 4889 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4890 /* Convert raw gyro z to dps */
gume 0:1f82672b8755 4891 data_d =
gume 0:1f82672b8755 4892 (double)(reg_gyro_z_s16/BNO055_GYRO_DIV_DPS);
gume 0:1f82672b8755 4893 *gyro_z_d = data_d;
gume 0:1f82672b8755 4894 } else {
gume 0:1f82672b8755 4895 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4896 }
gume 0:1f82672b8755 4897 } else {
gume 0:1f82672b8755 4898 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4899 }
gume 0:1f82672b8755 4900 return com_rslt;
gume 0:1f82672b8755 4901 }
gume 0:1f82672b8755 4902 /*!
gume 0:1f82672b8755 4903 * @brief This API is used to convert the gyro z raw data
gume 0:1f82672b8755 4904 * to rps output as double
gume 0:1f82672b8755 4905 *
gume 0:1f82672b8755 4906 * @param gyro_z_d : The gyro z rps double data
gume 0:1f82672b8755 4907 *
gume 0:1f82672b8755 4908 *
gume 0:1f82672b8755 4909 *
gume 0:1f82672b8755 4910 * @return results of bus communication function
gume 0:1f82672b8755 4911 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 4912 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 4913 *
gume 0:1f82672b8755 4914 *
gume 0:1f82672b8755 4915 */
gume 0:1f82672b8755 4916 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_gyro_z_rps(
gume 0:1f82672b8755 4917 double *gyro_z_d)
gume 0:1f82672b8755 4918 {
gume 0:1f82672b8755 4919 /* Variable used to return value of
gume 0:1f82672b8755 4920 communication routine*/
gume 0:1f82672b8755 4921 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4922 s16 reg_gyro_z_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4923 double data_d = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4924 u8 gyro_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4925 /* Read the current gyro unit and set the
gume 0:1f82672b8755 4926 unit as rps if the unit is in dps */
gume 0:1f82672b8755 4927 com_rslt = bno055_get_gyro_unit(&gyro_unit_u8);
gume 0:1f82672b8755 4928 if (gyro_unit_u8 != BNO055_GYRO_UNIT_RPS)
gume 0:1f82672b8755 4929 com_rslt += bno055_set_gyro_unit(BNO055_GYRO_UNIT_RPS);
gume 0:1f82672b8755 4930 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4931 /* Read gyro raw x data */
gume 0:1f82672b8755 4932 com_rslt += bno055_read_gyro_z(&reg_gyro_z_s16);
gume 0:1f82672b8755 4933 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4934 /* Convert raw gyro x to rps */
gume 0:1f82672b8755 4935 data_d =
gume 0:1f82672b8755 4936 (double)(reg_gyro_z_s16/BNO055_GYRO_DIV_RPS);
gume 0:1f82672b8755 4937 *gyro_z_d = data_d;
gume 0:1f82672b8755 4938 } else {
gume 0:1f82672b8755 4939 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4940 }
gume 0:1f82672b8755 4941 } else {
gume 0:1f82672b8755 4942 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4943 }
gume 0:1f82672b8755 4944 return com_rslt;
gume 0:1f82672b8755 4945 }
gume 0:1f82672b8755 4946 /*!
gume 0:1f82672b8755 4947 * @brief This API is used to convert the gyro xyz raw data
gume 0:1f82672b8755 4948 * to dps output as double
gume 0:1f82672b8755 4949 *
gume 0:1f82672b8755 4950 * @param gyro_xyz : The dps data of gyro xyz
gume 0:1f82672b8755 4951 *
gume 0:1f82672b8755 4952 * Parameter | result
gume 0:1f82672b8755 4953 * --------- | -----------------
gume 0:1f82672b8755 4954 * x | dps data of gyro
gume 0:1f82672b8755 4955 * y | dps data of gyro
gume 0:1f82672b8755 4956 * z | dps data of gyro
gume 0:1f82672b8755 4957 *
gume 0:1f82672b8755 4958 *
gume 0:1f82672b8755 4959 * @return results of bus communication function
gume 0:1f82672b8755 4960 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 4961 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 4962 *
gume 0:1f82672b8755 4963 */
gume 0:1f82672b8755 4964 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_gyro_xyz_dps(
gume 0:1f82672b8755 4965 struct bno055_gyro_double_t *gyro_xyz)
gume 0:1f82672b8755 4966 {
gume 0:1f82672b8755 4967 /* Variable used to return value of
gume 0:1f82672b8755 4968 communication routine*/
gume 0:1f82672b8755 4969 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4970 struct bno055_gyro_t reg_gyro_xyz = {
gume 0:1f82672b8755 4971 BNO055_INIT_VALUE, BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 4972 u8 gyro_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 4973 /* Read the current gyro unit and set the
gume 0:1f82672b8755 4974 unit as dps if the unit is in rps */
gume 0:1f82672b8755 4975 com_rslt = bno055_get_gyro_unit(&gyro_unit_u8);
gume 0:1f82672b8755 4976 if (gyro_unit_u8 != BNO055_GYRO_UNIT_DPS)
gume 0:1f82672b8755 4977 com_rslt += bno055_set_gyro_unit(BNO055_GYRO_UNIT_DPS);
gume 0:1f82672b8755 4978 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4979 /* Read gyro raw xyz data */
gume 0:1f82672b8755 4980 com_rslt += bno055_read_gyro_xyz(&reg_gyro_xyz);
gume 0:1f82672b8755 4981 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 4982 /* Convert gyro raw xyz to dps*/
gume 0:1f82672b8755 4983 gyro_xyz->x =
gume 0:1f82672b8755 4984 (double)(reg_gyro_xyz.x/BNO055_GYRO_DIV_DPS);
gume 0:1f82672b8755 4985 gyro_xyz->y =
gume 0:1f82672b8755 4986 (double)(reg_gyro_xyz.y/BNO055_GYRO_DIV_DPS);
gume 0:1f82672b8755 4987 gyro_xyz->z =
gume 0:1f82672b8755 4988 (double)(reg_gyro_xyz.z/BNO055_GYRO_DIV_DPS);
gume 0:1f82672b8755 4989 } else {
gume 0:1f82672b8755 4990 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4991 }
gume 0:1f82672b8755 4992 } else {
gume 0:1f82672b8755 4993 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 4994 }
gume 0:1f82672b8755 4995 return com_rslt;
gume 0:1f82672b8755 4996 }
gume 0:1f82672b8755 4997 /*!
gume 0:1f82672b8755 4998 * @brief This API is used to convert the gyro xyz raw data
gume 0:1f82672b8755 4999 * to rps output as double
gume 0:1f82672b8755 5000 *
gume 0:1f82672b8755 5001 * @param gyro_xyz : The rps data of gyro xyz
gume 0:1f82672b8755 5002 *
gume 0:1f82672b8755 5003 * Parameter | result
gume 0:1f82672b8755 5004 * --------- | -----------------
gume 0:1f82672b8755 5005 * x | rps data of gyro
gume 0:1f82672b8755 5006 * y | rps data of gyro
gume 0:1f82672b8755 5007 * z | rps data of gyro
gume 0:1f82672b8755 5008 *
gume 0:1f82672b8755 5009 *
gume 0:1f82672b8755 5010 * @return results of bus communication function
gume 0:1f82672b8755 5011 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 5012 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 5013 *
gume 0:1f82672b8755 5014 */
gume 0:1f82672b8755 5015 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_gyro_xyz_rps(
gume 0:1f82672b8755 5016 struct bno055_gyro_double_t *gyro_xyz)
gume 0:1f82672b8755 5017 {
gume 0:1f82672b8755 5018 /* Variable used to return value of
gume 0:1f82672b8755 5019 communication routine*/
gume 0:1f82672b8755 5020 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5021 struct bno055_gyro_t reg_gyro_xyz = {
gume 0:1f82672b8755 5022 BNO055_INIT_VALUE, BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 5023 u8 gyro_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5024 /* Read the current gyro unit and set the
gume 0:1f82672b8755 5025 unit as rps if the unit is in dps */
gume 0:1f82672b8755 5026 com_rslt = bno055_get_gyro_unit(&gyro_unit_u8);
gume 0:1f82672b8755 5027 if (gyro_unit_u8 != BNO055_GYRO_UNIT_RPS)
gume 0:1f82672b8755 5028 com_rslt += bno055_set_gyro_unit(BNO055_GYRO_UNIT_RPS);
gume 0:1f82672b8755 5029 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5030 /* Read gyro raw x data */
gume 0:1f82672b8755 5031 com_rslt += bno055_read_gyro_xyz(&reg_gyro_xyz);
gume 0:1f82672b8755 5032 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5033 /* Convert the raw gyro xyz to rps*/
gume 0:1f82672b8755 5034 gyro_xyz->x =
gume 0:1f82672b8755 5035 (double)(reg_gyro_xyz.x/BNO055_GYRO_DIV_RPS);
gume 0:1f82672b8755 5036 gyro_xyz->y =
gume 0:1f82672b8755 5037 (double)(reg_gyro_xyz.y/BNO055_GYRO_DIV_RPS);
gume 0:1f82672b8755 5038 gyro_xyz->z =
gume 0:1f82672b8755 5039 (double)(reg_gyro_xyz.z/BNO055_GYRO_DIV_RPS);
gume 0:1f82672b8755 5040 } else {
gume 0:1f82672b8755 5041 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5042 }
gume 0:1f82672b8755 5043 } else {
gume 0:1f82672b8755 5044 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5045 }
gume 0:1f82672b8755 5046 return com_rslt;
gume 0:1f82672b8755 5047 }
gume 0:1f82672b8755 5048 /*!
gume 0:1f82672b8755 5049 * @brief This API is used to convert the Euler h raw data
gume 0:1f82672b8755 5050 * to degree output as double
gume 0:1f82672b8755 5051 *
gume 0:1f82672b8755 5052 * @param euler_h_d : The double value of Euler h degree
gume 0:1f82672b8755 5053 *
gume 0:1f82672b8755 5054 * @return results of bus communication function
gume 0:1f82672b8755 5055 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 5056 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 5057 *
gume 0:1f82672b8755 5058 *
gume 0:1f82672b8755 5059 */
gume 0:1f82672b8755 5060 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_euler_h_deg(
gume 0:1f82672b8755 5061 double *euler_h_d)
gume 0:1f82672b8755 5062 {
gume 0:1f82672b8755 5063 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5064 s16 reg_euler_h_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5065 double data_d = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5066 u8 euler_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5067 /* Read the current Euler unit and set the
gume 0:1f82672b8755 5068 unit as degree if the unit is in radians */
gume 0:1f82672b8755 5069 com_rslt = bno055_get_euler_unit(&euler_unit_u8);
gume 0:1f82672b8755 5070 if (euler_unit_u8 != BNO055_EULER_UNIT_DEG)
gume 0:1f82672b8755 5071 com_rslt += bno055_set_euler_unit(BNO055_EULER_UNIT_DEG);
gume 0:1f82672b8755 5072 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5073 /* Read Euler raw h data*/
gume 0:1f82672b8755 5074 com_rslt += bno055_read_euler_h(&reg_euler_h_s16);
gume 0:1f82672b8755 5075 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5076 /* Convert raw Euler h to degree */
gume 0:1f82672b8755 5077 data_d =
gume 0:1f82672b8755 5078 (double)(reg_euler_h_s16/BNO055_EULER_DIV_DEG);
gume 0:1f82672b8755 5079 *euler_h_d = data_d;
gume 0:1f82672b8755 5080 } else {
gume 0:1f82672b8755 5081 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5082 }
gume 0:1f82672b8755 5083 } else {
gume 0:1f82672b8755 5084 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5085 }
gume 0:1f82672b8755 5086 return com_rslt;
gume 0:1f82672b8755 5087 }
gume 0:1f82672b8755 5088 /*!
gume 0:1f82672b8755 5089 * @brief This API is used to convert the Euler h raw data
gume 0:1f82672b8755 5090 * to radians output as double
gume 0:1f82672b8755 5091 *
gume 0:1f82672b8755 5092 * @param euler_h_d : The double value of Euler h radians
gume 0:1f82672b8755 5093 *
gume 0:1f82672b8755 5094 * @return results of bus communication function
gume 0:1f82672b8755 5095 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 5096 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 5097 *
gume 0:1f82672b8755 5098 *
gume 0:1f82672b8755 5099 */
gume 0:1f82672b8755 5100 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_euler_h_rad(
gume 0:1f82672b8755 5101 double *euler_h_d)
gume 0:1f82672b8755 5102 {
gume 0:1f82672b8755 5103 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5104 s16 reg_euler_h_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5105 double data_d = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5106 u8 euler_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5107 /* Read the current Euler unit and set the
gume 0:1f82672b8755 5108 unit as radians if the unit is in degree */
gume 0:1f82672b8755 5109 com_rslt = bno055_get_euler_unit(&euler_unit_u8);
gume 0:1f82672b8755 5110 if (euler_unit_u8 != BNO055_EULER_UNIT_RAD)
gume 0:1f82672b8755 5111 com_rslt += bno055_set_euler_unit(BNO055_EULER_UNIT_RAD);
gume 0:1f82672b8755 5112 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5113 /* Read Euler raw h data*/
gume 0:1f82672b8755 5114 com_rslt += bno055_read_euler_h(&reg_euler_h_s16);
gume 0:1f82672b8755 5115 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5116 /* Convert raw Euler h to radians */
gume 0:1f82672b8755 5117 data_d =
gume 0:1f82672b8755 5118 (double)(reg_euler_h_s16/BNO055_EULER_DIV_RAD);
gume 0:1f82672b8755 5119 *euler_h_d = data_d;
gume 0:1f82672b8755 5120 } else {
gume 0:1f82672b8755 5121 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5122 }
gume 0:1f82672b8755 5123 } else {
gume 0:1f82672b8755 5124 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5125 }
gume 0:1f82672b8755 5126 return com_rslt;
gume 0:1f82672b8755 5127 }
gume 0:1f82672b8755 5128 /*!
gume 0:1f82672b8755 5129 * @brief This API is used to convert the Euler r raw data
gume 0:1f82672b8755 5130 * to degree output as double
gume 0:1f82672b8755 5131 *
gume 0:1f82672b8755 5132 * @param euler_r_d : The double value of Euler r degree
gume 0:1f82672b8755 5133 *
gume 0:1f82672b8755 5134 * @return results of bus communication function
gume 0:1f82672b8755 5135 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 5136 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 5137 *
gume 0:1f82672b8755 5138 *
gume 0:1f82672b8755 5139 */
gume 0:1f82672b8755 5140 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_euler_r_deg(
gume 0:1f82672b8755 5141 double *euler_r_d)
gume 0:1f82672b8755 5142 {
gume 0:1f82672b8755 5143 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5144 s16 reg_euler_r_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5145 double data_d = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5146 u8 euler_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5147 /* Read the current Euler unit and set the
gume 0:1f82672b8755 5148 unit as degree if the unit is in radians */
gume 0:1f82672b8755 5149 com_rslt = bno055_get_euler_unit(&euler_unit_u8);
gume 0:1f82672b8755 5150 if (euler_unit_u8 != BNO055_EULER_UNIT_DEG)
gume 0:1f82672b8755 5151 com_rslt += bno055_set_euler_unit(BNO055_EULER_UNIT_DEG);
gume 0:1f82672b8755 5152 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5153 /* Read Euler raw r data*/
gume 0:1f82672b8755 5154 com_rslt += bno055_read_euler_r(&reg_euler_r_s16);
gume 0:1f82672b8755 5155 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5156 /* Convert raw Euler r to degree */
gume 0:1f82672b8755 5157 data_d =
gume 0:1f82672b8755 5158 (double)(reg_euler_r_s16/BNO055_EULER_DIV_DEG);
gume 0:1f82672b8755 5159 *euler_r_d = data_d;
gume 0:1f82672b8755 5160 } else {
gume 0:1f82672b8755 5161 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5162 }
gume 0:1f82672b8755 5163 } else {
gume 0:1f82672b8755 5164 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5165 }
gume 0:1f82672b8755 5166 return com_rslt;
gume 0:1f82672b8755 5167 }
gume 0:1f82672b8755 5168 /*!
gume 0:1f82672b8755 5169 * @brief This API is used to convert the Euler r raw data
gume 0:1f82672b8755 5170 * to radians output as double
gume 0:1f82672b8755 5171 *
gume 0:1f82672b8755 5172 * @param euler_r_d : The double value of Euler r radians
gume 0:1f82672b8755 5173 *
gume 0:1f82672b8755 5174 * @return results of bus communication function
gume 0:1f82672b8755 5175 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 5176 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 5177 *
gume 0:1f82672b8755 5178 *
gume 0:1f82672b8755 5179 */
gume 0:1f82672b8755 5180 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_euler_r_rad(
gume 0:1f82672b8755 5181 double *euler_r_d)
gume 0:1f82672b8755 5182 {
gume 0:1f82672b8755 5183 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5184 s16 reg_euler_r_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5185 double data_d = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5186 u8 euler_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5187 /* Read the current Euler unit and set the
gume 0:1f82672b8755 5188 unit as radians if the unit is in degree */
gume 0:1f82672b8755 5189 com_rslt = bno055_get_euler_unit(&euler_unit_u8);
gume 0:1f82672b8755 5190 if (euler_unit_u8 != BNO055_EULER_UNIT_RAD)
gume 0:1f82672b8755 5191 com_rslt += bno055_set_euler_unit(BNO055_EULER_UNIT_RAD);
gume 0:1f82672b8755 5192 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5193 /* Read Euler raw r data*/
gume 0:1f82672b8755 5194 com_rslt += bno055_read_euler_r(&reg_euler_r_s16);
gume 0:1f82672b8755 5195 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5196 /* Convert raw Euler r to radians */
gume 0:1f82672b8755 5197 data_d =
gume 0:1f82672b8755 5198 (double)(reg_euler_r_s16/BNO055_EULER_DIV_RAD);
gume 0:1f82672b8755 5199 *euler_r_d = data_d;
gume 0:1f82672b8755 5200 } else {
gume 0:1f82672b8755 5201 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5202 }
gume 0:1f82672b8755 5203 } else {
gume 0:1f82672b8755 5204 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5205 }
gume 0:1f82672b8755 5206 return com_rslt;
gume 0:1f82672b8755 5207 }
gume 0:1f82672b8755 5208 /*!
gume 0:1f82672b8755 5209 * @brief This API is used to convert the Euler p raw data
gume 0:1f82672b8755 5210 * to degree output as double
gume 0:1f82672b8755 5211 *
gume 0:1f82672b8755 5212 * @param euler_p_d : The double value of Euler p degree
gume 0:1f82672b8755 5213 *
gume 0:1f82672b8755 5214 * @return results of bus communication function
gume 0:1f82672b8755 5215 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 5216 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 5217 *
gume 0:1f82672b8755 5218 *
gume 0:1f82672b8755 5219 */
gume 0:1f82672b8755 5220 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_euler_p_deg(
gume 0:1f82672b8755 5221 double *euler_p_d)
gume 0:1f82672b8755 5222 {
gume 0:1f82672b8755 5223 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5224 s16 reg_euler_p_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5225 double data_d = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5226 u8 euler_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5227 /* Read the current Euler unit and set the
gume 0:1f82672b8755 5228 unit as degree if the unit is in radians */
gume 0:1f82672b8755 5229 com_rslt = bno055_get_euler_unit(&euler_unit_u8);
gume 0:1f82672b8755 5230 if (euler_unit_u8 != BNO055_EULER_UNIT_DEG)
gume 0:1f82672b8755 5231 com_rslt += bno055_set_euler_unit(BNO055_EULER_UNIT_DEG);
gume 0:1f82672b8755 5232 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5233 /* Read Euler raw p data*/
gume 0:1f82672b8755 5234 com_rslt += bno055_read_euler_p(&reg_euler_p_s16);
gume 0:1f82672b8755 5235 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5236 /* Convert raw Euler p to degree*/
gume 0:1f82672b8755 5237 data_d =
gume 0:1f82672b8755 5238 (double)(reg_euler_p_s16/BNO055_EULER_DIV_DEG);
gume 0:1f82672b8755 5239 *euler_p_d = data_d;
gume 0:1f82672b8755 5240 } else {
gume 0:1f82672b8755 5241 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5242 }
gume 0:1f82672b8755 5243 } else {
gume 0:1f82672b8755 5244 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5245 }
gume 0:1f82672b8755 5246 return com_rslt;
gume 0:1f82672b8755 5247 }
gume 0:1f82672b8755 5248 /*!
gume 0:1f82672b8755 5249 * @brief This API is used to convert the Euler p raw data
gume 0:1f82672b8755 5250 * to radians output as double
gume 0:1f82672b8755 5251 *
gume 0:1f82672b8755 5252 * @param euler_p_d : The double value of Euler p radians
gume 0:1f82672b8755 5253 *
gume 0:1f82672b8755 5254 * @return results of bus communication function
gume 0:1f82672b8755 5255 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 5256 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 5257 *
gume 0:1f82672b8755 5258 *
gume 0:1f82672b8755 5259 */
gume 0:1f82672b8755 5260
gume 0:1f82672b8755 5261 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_euler_p_rad(
gume 0:1f82672b8755 5262 double *euler_p_d)
gume 0:1f82672b8755 5263 {
gume 0:1f82672b8755 5264 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5265 s16 reg_euler_p_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5266 double data_d = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5267 u8 euler_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5268 /* Read the current Euler unit and set the
gume 0:1f82672b8755 5269 unit as radians if the unit is in degree */
gume 0:1f82672b8755 5270 com_rslt = bno055_get_euler_unit(&euler_unit_u8);
gume 0:1f82672b8755 5271 if (euler_unit_u8 != BNO055_EULER_UNIT_RAD)
gume 0:1f82672b8755 5272 com_rslt += bno055_set_euler_unit(BNO055_EULER_UNIT_RAD);
gume 0:1f82672b8755 5273 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5274 /* Read Euler raw p data*/
gume 0:1f82672b8755 5275 com_rslt += bno055_read_euler_p(&reg_euler_p_s16);
gume 0:1f82672b8755 5276 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5277 /* Convert raw p to radians*/
gume 0:1f82672b8755 5278 data_d =
gume 0:1f82672b8755 5279 (double)(reg_euler_p_s16/BNO055_EULER_DIV_RAD);
gume 0:1f82672b8755 5280 *euler_p_d = data_d;
gume 0:1f82672b8755 5281 } else {
gume 0:1f82672b8755 5282 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5283 }
gume 0:1f82672b8755 5284 } else {
gume 0:1f82672b8755 5285 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5286 }
gume 0:1f82672b8755 5287 return com_rslt;
gume 0:1f82672b8755 5288 }
gume 0:1f82672b8755 5289 /*!
gume 0:1f82672b8755 5290 * @brief This API is used to convert the Euler hpr raw data
gume 0:1f82672b8755 5291 * to degree output as double
gume 0:1f82672b8755 5292 *
gume 0:1f82672b8755 5293 * @param euler_hpr : The degree data of Euler hpr
gume 0:1f82672b8755 5294 *
gume 0:1f82672b8755 5295 * Parameter | result
gume 0:1f82672b8755 5296 * --------- | -----------------
gume 0:1f82672b8755 5297 * h | degree data of Euler
gume 0:1f82672b8755 5298 * r | degree data of Euler
gume 0:1f82672b8755 5299 * p | degree data of Euler
gume 0:1f82672b8755 5300 *
gume 0:1f82672b8755 5301 *
gume 0:1f82672b8755 5302 * @return results of bus communication function
gume 0:1f82672b8755 5303 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 5304 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 5305 *
gume 0:1f82672b8755 5306 */
gume 0:1f82672b8755 5307
gume 0:1f82672b8755 5308 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_euler_hpr_deg(
gume 0:1f82672b8755 5309 struct bno055_euler_double_t *euler_hpr)
gume 0:1f82672b8755 5310 {
gume 0:1f82672b8755 5311 /* Variable used to return value of
gume 0:1f82672b8755 5312 communication routine*/
gume 0:1f82672b8755 5313 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5314 struct bno055_euler_t reg_euler = {BNO055_INIT_VALUE,
gume 0:1f82672b8755 5315 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 5316 u8 euler_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5317 /* Read the current Euler unit and set the
gume 0:1f82672b8755 5318 unit as degree if the unit is in radians */
gume 0:1f82672b8755 5319 com_rslt = bno055_get_euler_unit(&euler_unit_u8);
gume 0:1f82672b8755 5320 if (euler_unit_u8 != BNO055_EULER_UNIT_DEG)
gume 0:1f82672b8755 5321 com_rslt += bno055_set_euler_unit(BNO055_EULER_UNIT_DEG);
gume 0:1f82672b8755 5322 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5323 /* Read Euler raw h data*/
gume 0:1f82672b8755 5324 com_rslt += bno055_read_euler_hrp(&reg_euler);
gume 0:1f82672b8755 5325 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5326 /* Convert raw Euler hrp to degree*/
gume 0:1f82672b8755 5327 euler_hpr->h =
gume 0:1f82672b8755 5328 (double)(reg_euler.h/BNO055_EULER_DIV_DEG);
gume 0:1f82672b8755 5329 euler_hpr->p =
gume 0:1f82672b8755 5330 (double)(reg_euler.p/BNO055_EULER_DIV_DEG);
gume 0:1f82672b8755 5331 euler_hpr->r =
gume 0:1f82672b8755 5332 (double)(reg_euler.r/BNO055_EULER_DIV_DEG);
gume 0:1f82672b8755 5333 } else {
gume 0:1f82672b8755 5334 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5335 }
gume 0:1f82672b8755 5336 } else {
gume 0:1f82672b8755 5337 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5338 }
gume 0:1f82672b8755 5339 return com_rslt;
gume 0:1f82672b8755 5340 }
gume 0:1f82672b8755 5341 /*!
gume 0:1f82672b8755 5342 * @brief This API is used to convert the Euler hpr raw data
gume 0:1f82672b8755 5343 * to radians output as double
gume 0:1f82672b8755 5344 *
gume 0:1f82672b8755 5345 * @param euler_hpr : The radians data of Euler hpr
gume 0:1f82672b8755 5346 *
gume 0:1f82672b8755 5347 * Parameter | result
gume 0:1f82672b8755 5348 * --------- | -----------------
gume 0:1f82672b8755 5349 * h | radians data of Euler
gume 0:1f82672b8755 5350 * r | radians data of Euler
gume 0:1f82672b8755 5351 * p | radians data of Euler
gume 0:1f82672b8755 5352 *
gume 0:1f82672b8755 5353 *
gume 0:1f82672b8755 5354 * @return results of bus communication function
gume 0:1f82672b8755 5355 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 5356 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 5357 *
gume 0:1f82672b8755 5358 */
gume 0:1f82672b8755 5359
gume 0:1f82672b8755 5360 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_euler_hpr_rad(
gume 0:1f82672b8755 5361 struct bno055_euler_double_t *euler_hpr)
gume 0:1f82672b8755 5362 {
gume 0:1f82672b8755 5363 /* Variable used to return value of
gume 0:1f82672b8755 5364 communication routine*/
gume 0:1f82672b8755 5365 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5366 struct bno055_euler_t reg_euler = {BNO055_INIT_VALUE,
gume 0:1f82672b8755 5367 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 5368 u8 euler_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5369 /* Read the current Euler unit and set the
gume 0:1f82672b8755 5370 unit as radians if the unit is in degree */
gume 0:1f82672b8755 5371 com_rslt = bno055_get_euler_unit(&euler_unit_u8);
gume 0:1f82672b8755 5372 if (euler_unit_u8 != BNO055_EULER_UNIT_RAD)
gume 0:1f82672b8755 5373 com_rslt = bno055_set_euler_unit(BNO055_EULER_UNIT_RAD);
gume 0:1f82672b8755 5374 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5375 /* Read the raw hrp */
gume 0:1f82672b8755 5376 com_rslt = bno055_read_euler_hrp(&reg_euler);
gume 0:1f82672b8755 5377 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5378 /* Convert raw Euler hrp to radians*/
gume 0:1f82672b8755 5379 euler_hpr->h =
gume 0:1f82672b8755 5380 (double)(reg_euler.h/BNO055_EULER_DIV_RAD);
gume 0:1f82672b8755 5381 euler_hpr->p =
gume 0:1f82672b8755 5382 (double)(reg_euler.p/BNO055_EULER_DIV_RAD);
gume 0:1f82672b8755 5383 euler_hpr->r =
gume 0:1f82672b8755 5384 (double)(reg_euler.r/BNO055_EULER_DIV_RAD);
gume 0:1f82672b8755 5385 } else {
gume 0:1f82672b8755 5386 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5387 }
gume 0:1f82672b8755 5388 } else {
gume 0:1f82672b8755 5389 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5390 }
gume 0:1f82672b8755 5391 return com_rslt;
gume 0:1f82672b8755 5392 }
gume 0:1f82672b8755 5393 /*!
gume 0:1f82672b8755 5394 * @brief This API is used to convert the linear
gume 0:1f82672b8755 5395 * accel x raw data to meterpersecseq output as double
gume 0:1f82672b8755 5396 *
gume 0:1f82672b8755 5397 * @param linear_accel_x_d : The double value of
gume 0:1f82672b8755 5398 * linear accel x meterpersecseq
gume 0:1f82672b8755 5399 *
gume 0:1f82672b8755 5400 * @return results of bus communication function
gume 0:1f82672b8755 5401 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 5402 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 5403 *
gume 0:1f82672b8755 5404 *
gume 0:1f82672b8755 5405 */
gume 0:1f82672b8755 5406
gume 0:1f82672b8755 5407 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_linear_accel_x_msq(
gume 0:1f82672b8755 5408 double *linear_accel_x_d)
gume 0:1f82672b8755 5409 {
gume 0:1f82672b8755 5410 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5411 s16 reg_linear_accel_x_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5412 double data_d = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5413 /* Read the raw x of linear accel */
gume 0:1f82672b8755 5414 com_rslt = bno055_read_linear_accel_x(&reg_linear_accel_x_s16);
gume 0:1f82672b8755 5415 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5416 /* Convert the raw x to m/s2 */
gume 0:1f82672b8755 5417 data_d = (double)
gume 0:1f82672b8755 5418 (reg_linear_accel_x_s16/BNO055_LINEAR_ACCEL_DIV_MSQ);
gume 0:1f82672b8755 5419 *linear_accel_x_d = data_d;
gume 0:1f82672b8755 5420 } else {
gume 0:1f82672b8755 5421 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5422 }
gume 0:1f82672b8755 5423 return com_rslt;
gume 0:1f82672b8755 5424 }
gume 0:1f82672b8755 5425 /*!
gume 0:1f82672b8755 5426 * @brief This API is used to convert the linear
gume 0:1f82672b8755 5427 * accel y raw data to meterpersecseq output as double
gume 0:1f82672b8755 5428 *
gume 0:1f82672b8755 5429 * @param linear_accel_y_d : The double value of
gume 0:1f82672b8755 5430 * linear accel y meterpersecseq
gume 0:1f82672b8755 5431 *
gume 0:1f82672b8755 5432 * @return results of bus communication function
gume 0:1f82672b8755 5433 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 5434 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 5435 *
gume 0:1f82672b8755 5436 *
gume 0:1f82672b8755 5437 */
gume 0:1f82672b8755 5438
gume 0:1f82672b8755 5439 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_linear_accel_y_msq(
gume 0:1f82672b8755 5440 double *linear_accel_y_d)
gume 0:1f82672b8755 5441 {
gume 0:1f82672b8755 5442 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5443 s16 reg_linear_accel_y_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5444 double data_d = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5445 /* Read the raw x of linear accel */
gume 0:1f82672b8755 5446 com_rslt = bno055_read_linear_accel_y(&reg_linear_accel_y_s16);
gume 0:1f82672b8755 5447 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5448 /* Convert the raw y to m/s2 */
gume 0:1f82672b8755 5449 data_d = (double)
gume 0:1f82672b8755 5450 (reg_linear_accel_y_s16/BNO055_LINEAR_ACCEL_DIV_MSQ);
gume 0:1f82672b8755 5451 *linear_accel_y_d = data_d;
gume 0:1f82672b8755 5452 } else {
gume 0:1f82672b8755 5453 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5454 }
gume 0:1f82672b8755 5455 return com_rslt;
gume 0:1f82672b8755 5456 }
gume 0:1f82672b8755 5457 /*!
gume 0:1f82672b8755 5458 * @brief This API is used to convert the linear
gume 0:1f82672b8755 5459 * accel z raw data to meterpersecseq output as double
gume 0:1f82672b8755 5460 *
gume 0:1f82672b8755 5461 * @param linear_accel_z_d : The double value of
gume 0:1f82672b8755 5462 * linear accel z meterpersecseq
gume 0:1f82672b8755 5463 *
gume 0:1f82672b8755 5464 * @return results of bus communication function
gume 0:1f82672b8755 5465 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 5466 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 5467 *
gume 0:1f82672b8755 5468 *
gume 0:1f82672b8755 5469 */
gume 0:1f82672b8755 5470
gume 0:1f82672b8755 5471 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_linear_accel_z_msq(
gume 0:1f82672b8755 5472 double *linear_accel_z_d)
gume 0:1f82672b8755 5473 {
gume 0:1f82672b8755 5474 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5475 s16 reg_linear_accel_z_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5476 double data_d = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5477 /* Read the raw x of linear accel */
gume 0:1f82672b8755 5478 com_rslt = bno055_read_linear_accel_z(&reg_linear_accel_z_s16);
gume 0:1f82672b8755 5479 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5480 /* Convert the raw z to m/s2 */
gume 0:1f82672b8755 5481 data_d =
gume 0:1f82672b8755 5482 (double)(reg_linear_accel_z_s16/BNO055_LINEAR_ACCEL_DIV_MSQ);
gume 0:1f82672b8755 5483 *linear_accel_z_d = data_d;
gume 0:1f82672b8755 5484 } else {
gume 0:1f82672b8755 5485 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5486 }
gume 0:1f82672b8755 5487 return com_rslt;
gume 0:1f82672b8755 5488 }
gume 0:1f82672b8755 5489 /*!
gume 0:1f82672b8755 5490 * @brief This API is used to convert the linear accel xyz raw data
gume 0:1f82672b8755 5491 * to meterpersecseq output as double
gume 0:1f82672b8755 5492 *
gume 0:1f82672b8755 5493 * @param linear_accel_xyz : The meterpersecseq data of linear accel xyz
gume 0:1f82672b8755 5494 *
gume 0:1f82672b8755 5495 * Parameter | result
gume 0:1f82672b8755 5496 * --------- | -----------------
gume 0:1f82672b8755 5497 * x | meterpersecseq data of linear accel
gume 0:1f82672b8755 5498 * y | meterpersecseq data of linear accel
gume 0:1f82672b8755 5499 * z | meterpersecseq data of linear accel
gume 0:1f82672b8755 5500 *
gume 0:1f82672b8755 5501 *
gume 0:1f82672b8755 5502 * @return results of bus communication function
gume 0:1f82672b8755 5503 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 5504 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 5505 *
gume 0:1f82672b8755 5506 */
gume 0:1f82672b8755 5507
gume 0:1f82672b8755 5508 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_linear_accel_xyz_msq(
gume 0:1f82672b8755 5509 struct bno055_linear_accel_double_t *linear_accel_xyz)
gume 0:1f82672b8755 5510 {
gume 0:1f82672b8755 5511 /* Variable used to return value of
gume 0:1f82672b8755 5512 communication routine*/
gume 0:1f82672b8755 5513 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5514 struct bno055_linear_accel_t reg_linear_accel_xyz = {
gume 0:1f82672b8755 5515 BNO055_INIT_VALUE, BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 5516 /* Read the raw xyz of linear accel */
gume 0:1f82672b8755 5517 com_rslt = bno055_read_linear_accel_xyz(&reg_linear_accel_xyz);
gume 0:1f82672b8755 5518 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5519 /* Convert the raw xyz of linear accel to m/s2 */
gume 0:1f82672b8755 5520 linear_accel_xyz->x =
gume 0:1f82672b8755 5521 (double)(reg_linear_accel_xyz.x/BNO055_LINEAR_ACCEL_DIV_MSQ);
gume 0:1f82672b8755 5522 linear_accel_xyz->y =
gume 0:1f82672b8755 5523 (double)(reg_linear_accel_xyz.y/BNO055_LINEAR_ACCEL_DIV_MSQ);
gume 0:1f82672b8755 5524 linear_accel_xyz->z =
gume 0:1f82672b8755 5525 (double)(reg_linear_accel_xyz.z/BNO055_LINEAR_ACCEL_DIV_MSQ);
gume 0:1f82672b8755 5526 } else {
gume 0:1f82672b8755 5527 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5528 }
gume 0:1f82672b8755 5529 return com_rslt;
gume 0:1f82672b8755 5530 }
gume 0:1f82672b8755 5531 /*!
gume 0:1f82672b8755 5532 * @brief This API is used to convert the gravity
gume 0:1f82672b8755 5533 * x raw data to meterpersecseq output as double
gume 0:1f82672b8755 5534 *
gume 0:1f82672b8755 5535 * @param gravity_x_d : The double value of gravity x meterpersecseq
gume 0:1f82672b8755 5536 *
gume 0:1f82672b8755 5537 * @return results of bus communication function
gume 0:1f82672b8755 5538 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 5539 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 5540 *
gume 0:1f82672b8755 5541 *
gume 0:1f82672b8755 5542 */
gume 0:1f82672b8755 5543 BNO055_RETURN_FUNCTION_TYPE bno055_convert_gravity_double_x_msq(
gume 0:1f82672b8755 5544 double *gravity_x_d)
gume 0:1f82672b8755 5545 {
gume 0:1f82672b8755 5546 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5547 s16 reg_gravity_x_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5548 double data_d = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5549 /* Read raw gravity of x*/
gume 0:1f82672b8755 5550 com_rslt = bno055_read_gravity_x(&reg_gravity_x_s16);
gume 0:1f82672b8755 5551 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5552 /* Convert raw gravity of x to m/s2 */
gume 0:1f82672b8755 5553 data_d =
gume 0:1f82672b8755 5554 (double)(reg_gravity_x_s16/BNO055_GRAVITY_DIV_MSQ);
gume 0:1f82672b8755 5555 *gravity_x_d = data_d;
gume 0:1f82672b8755 5556 } else {
gume 0:1f82672b8755 5557 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5558 }
gume 0:1f82672b8755 5559 return com_rslt;
gume 0:1f82672b8755 5560 }
gume 0:1f82672b8755 5561 /*!
gume 0:1f82672b8755 5562 * @brief This API is used to convert the gravity
gume 0:1f82672b8755 5563 * y raw data to meterpersecseq output as double
gume 0:1f82672b8755 5564 *
gume 0:1f82672b8755 5565 * @param gravity_y_d : The double value of gravity y meterpersecseq
gume 0:1f82672b8755 5566 *
gume 0:1f82672b8755 5567 * @return results of bus communication function
gume 0:1f82672b8755 5568 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 5569 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 5570 *
gume 0:1f82672b8755 5571 *
gume 0:1f82672b8755 5572 */
gume 0:1f82672b8755 5573 BNO055_RETURN_FUNCTION_TYPE bno055_convert_gravity_double_y_msq(
gume 0:1f82672b8755 5574 double *gravity_y_d)
gume 0:1f82672b8755 5575 {
gume 0:1f82672b8755 5576 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5577 s16 reg_gravity_y_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5578 double data_d = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5579 /* Read raw gravity of y */
gume 0:1f82672b8755 5580 com_rslt = bno055_read_gravity_y(&reg_gravity_y_s16);
gume 0:1f82672b8755 5581 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5582 /* convert raw gravity of y to m/s2 */
gume 0:1f82672b8755 5583 data_d =
gume 0:1f82672b8755 5584 (double)(reg_gravity_y_s16/BNO055_GRAVITY_DIV_MSQ);
gume 0:1f82672b8755 5585 *gravity_y_d = data_d;
gume 0:1f82672b8755 5586 } else {
gume 0:1f82672b8755 5587 com_rslt += BNO055_ERROR;
gume 0:1f82672b8755 5588 }
gume 0:1f82672b8755 5589 return com_rslt;
gume 0:1f82672b8755 5590 }
gume 0:1f82672b8755 5591 /*!
gume 0:1f82672b8755 5592 * @brief This API is used to convert the gravity
gume 0:1f82672b8755 5593 * z raw data to meterpersecseq output as double
gume 0:1f82672b8755 5594 *
gume 0:1f82672b8755 5595 * @param gravity_z_d : The double value of gravity z meterpersecseq
gume 0:1f82672b8755 5596 *
gume 0:1f82672b8755 5597 * @return results of bus communication function
gume 0:1f82672b8755 5598 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 5599 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 5600 *
gume 0:1f82672b8755 5601 *
gume 0:1f82672b8755 5602 */
gume 0:1f82672b8755 5603 BNO055_RETURN_FUNCTION_TYPE bno055_convert_gravity_double_z_msq(
gume 0:1f82672b8755 5604 double *gravity_z_d)
gume 0:1f82672b8755 5605 {
gume 0:1f82672b8755 5606 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5607 s16 reg_gravity_z_s16 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5608 double data_d = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5609 /* Read raw gravity of z */
gume 0:1f82672b8755 5610 com_rslt = bno055_read_gravity_z(&reg_gravity_z_s16);
gume 0:1f82672b8755 5611 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5612 /* Convert raw gravity of z to m/s2 */
gume 0:1f82672b8755 5613 data_d =
gume 0:1f82672b8755 5614 (double)(reg_gravity_z_s16/BNO055_GRAVITY_DIV_MSQ);
gume 0:1f82672b8755 5615 *gravity_z_d = data_d;
gume 0:1f82672b8755 5616 } else {
gume 0:1f82672b8755 5617 com_rslt += BNO055_ERROR;
gume 0:1f82672b8755 5618 }
gume 0:1f82672b8755 5619 return com_rslt;
gume 0:1f82672b8755 5620 }
gume 0:1f82672b8755 5621 /*!
gume 0:1f82672b8755 5622 * @brief This API is used to convert the gravity xyz raw data
gume 0:1f82672b8755 5623 * to meterpersecseq output as double
gume 0:1f82672b8755 5624 *
gume 0:1f82672b8755 5625 * @param gravity_xyz : The meterpersecseq data of gravity xyz
gume 0:1f82672b8755 5626 *
gume 0:1f82672b8755 5627 * Parameter | result
gume 0:1f82672b8755 5628 * --------- | -----------------
gume 0:1f82672b8755 5629 * x | meterpersecseq data of gravity
gume 0:1f82672b8755 5630 * y | meterpersecseq data of gravity
gume 0:1f82672b8755 5631 * z | meterpersecseq data of gravity
gume 0:1f82672b8755 5632 *
gume 0:1f82672b8755 5633 *
gume 0:1f82672b8755 5634 * @return results of bus communication function
gume 0:1f82672b8755 5635 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 5636 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 5637 *
gume 0:1f82672b8755 5638 */
gume 0:1f82672b8755 5639 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_gravity_xyz_msq(
gume 0:1f82672b8755 5640 struct bno055_gravity_double_t *gravity_xyz)
gume 0:1f82672b8755 5641 {
gume 0:1f82672b8755 5642 /* Variable used to return value of
gume 0:1f82672b8755 5643 communication routine*/
gume 0:1f82672b8755 5644 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5645 struct bno055_gravity_t reg_gravity_xyz = {
gume 0:1f82672b8755 5646 BNO055_INIT_VALUE, BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 5647 /* Read raw gravity of xyz */
gume 0:1f82672b8755 5648 com_rslt = bno055_read_gravity_xyz(&reg_gravity_xyz);
gume 0:1f82672b8755 5649 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5650 /* Convert raw gravity of xyz to m/s2 */
gume 0:1f82672b8755 5651 gravity_xyz->x =
gume 0:1f82672b8755 5652 (double)(reg_gravity_xyz.x/BNO055_GRAVITY_DIV_MSQ);
gume 0:1f82672b8755 5653 gravity_xyz->y =
gume 0:1f82672b8755 5654 (double)(reg_gravity_xyz.y/BNO055_GRAVITY_DIV_MSQ);
gume 0:1f82672b8755 5655 gravity_xyz->z =
gume 0:1f82672b8755 5656 (double)(reg_gravity_xyz.z/BNO055_GRAVITY_DIV_MSQ);
gume 0:1f82672b8755 5657 } else {
gume 0:1f82672b8755 5658 com_rslt += BNO055_ERROR;
gume 0:1f82672b8755 5659 }
gume 0:1f82672b8755 5660 return com_rslt;
gume 0:1f82672b8755 5661 }
gume 0:1f82672b8755 5662 /*!
gume 0:1f82672b8755 5663 * @brief This API is used to convert the temperature
gume 0:1f82672b8755 5664 * data to Fahrenheit output as double
gume 0:1f82672b8755 5665 *
gume 0:1f82672b8755 5666 * @param temp_d : The double value of temperature Fahrenheit
gume 0:1f82672b8755 5667 *
gume 0:1f82672b8755 5668 * @return results of bus communication function
gume 0:1f82672b8755 5669 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 5670 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 5671 *
gume 0:1f82672b8755 5672 *
gume 0:1f82672b8755 5673 */
gume 0:1f82672b8755 5674 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_temp_fahrenheit(
gume 0:1f82672b8755 5675 double *temp_d)
gume 0:1f82672b8755 5676 {
gume 0:1f82672b8755 5677 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5678 s8 reg_temp_s8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5679 double data_d = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5680 u8 temp_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5681 /* Read the current temperature unit and set the
gume 0:1f82672b8755 5682 unit as Fahrenheit if the unit is in Celsius */
gume 0:1f82672b8755 5683 com_rslt = bno055_get_temp_unit(&temp_unit_u8);
gume 0:1f82672b8755 5684 if (temp_unit_u8 != BNO055_TEMP_UNIT_FAHRENHEIT)
gume 0:1f82672b8755 5685 com_rslt += bno055_set_temp_unit(BNO055_TEMP_UNIT_FAHRENHEIT);
gume 0:1f82672b8755 5686 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5687 /* Read the raw temperature data */
gume 0:1f82672b8755 5688 com_rslt += bno055_read_temp_data(&reg_temp_s8);
gume 0:1f82672b8755 5689 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5690 /* Convert raw temperature data to Fahrenheit*/
gume 0:1f82672b8755 5691 data_d = (double)(reg_temp_s8/
gume 0:1f82672b8755 5692 BNO055_TEMP_DIV_FAHRENHEIT);
gume 0:1f82672b8755 5693 *temp_d = data_d;
gume 0:1f82672b8755 5694 } else {
gume 0:1f82672b8755 5695 com_rslt += BNO055_ERROR;
gume 0:1f82672b8755 5696 }
gume 0:1f82672b8755 5697 } else {
gume 0:1f82672b8755 5698 com_rslt += BNO055_ERROR;
gume 0:1f82672b8755 5699 }
gume 0:1f82672b8755 5700 return com_rslt;
gume 0:1f82672b8755 5701 }
gume 0:1f82672b8755 5702 /*!
gume 0:1f82672b8755 5703 * @brief This API is used to convert the temperature
gume 0:1f82672b8755 5704 * data to Celsius output as double
gume 0:1f82672b8755 5705 *
gume 0:1f82672b8755 5706 * @param temp_d : The double value of temperature Celsius
gume 0:1f82672b8755 5707 *
gume 0:1f82672b8755 5708 * @return results of bus communication function
gume 0:1f82672b8755 5709 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 5710 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 5711 *
gume 0:1f82672b8755 5712 *
gume 0:1f82672b8755 5713 */
gume 0:1f82672b8755 5714 BNO055_RETURN_FUNCTION_TYPE bno055_convert_double_temp_celsius(
gume 0:1f82672b8755 5715 double *temp_d)
gume 0:1f82672b8755 5716 {
gume 0:1f82672b8755 5717 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5718 s8 reg_temp_s8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5719 double data_d = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5720 u8 temp_unit_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5721 /* Read the current temperature unit and set the
gume 0:1f82672b8755 5722 unit as Fahrenheit if the unit is in Celsius */
gume 0:1f82672b8755 5723 com_rslt = bno055_get_temp_unit(&temp_unit_u8);
gume 0:1f82672b8755 5724 if (temp_unit_u8 != BNO055_TEMP_UNIT_CELSIUS)
gume 0:1f82672b8755 5725 com_rslt += bno055_set_temp_unit(BNO055_TEMP_UNIT_CELSIUS);
gume 0:1f82672b8755 5726 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5727 /* Read the raw temperature data */
gume 0:1f82672b8755 5728 com_rslt += bno055_read_temp_data(&reg_temp_s8);
gume 0:1f82672b8755 5729 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 5730 /* Convert raw temperature data to Fahrenheit*/
gume 0:1f82672b8755 5731 data_d =
gume 0:1f82672b8755 5732 (double)(reg_temp_s8/BNO055_TEMP_DIV_CELSIUS);
gume 0:1f82672b8755 5733 *temp_d = data_d;
gume 0:1f82672b8755 5734 } else {
gume 0:1f82672b8755 5735 com_rslt += BNO055_ERROR;
gume 0:1f82672b8755 5736 }
gume 0:1f82672b8755 5737 } else {
gume 0:1f82672b8755 5738 com_rslt += BNO055_ERROR;
gume 0:1f82672b8755 5739 }
gume 0:1f82672b8755 5740 return com_rslt;
gume 0:1f82672b8755 5741 }
gume 0:1f82672b8755 5742 #endif
gume 0:1f82672b8755 5743 /*!
gume 0:1f82672b8755 5744 * @brief This API used to read
gume 0:1f82672b8755 5745 * mag calibration status from register from 0x35 bit 0 and 1
gume 0:1f82672b8755 5746 *
gume 0:1f82672b8755 5747 * @param mag_calib_u8 : The value of mag calib status
gume 0:1f82672b8755 5748 *
gume 0:1f82672b8755 5749 *
gume 0:1f82672b8755 5750 * @return results of bus communication function
gume 0:1f82672b8755 5751 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 5752 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 5753 *
gume 0:1f82672b8755 5754 */
gume 0:1f82672b8755 5755 BNO055_RETURN_FUNCTION_TYPE bno055_get_mag_calib_stat(
gume 0:1f82672b8755 5756 u8 *mag_calib_u8)
gume 0:1f82672b8755 5757 {
gume 0:1f82672b8755 5758 /* Variable used to return value of
gume 0:1f82672b8755 5759 communication routine*/
gume 0:1f82672b8755 5760 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5761 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5762 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 5763 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 5764 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 5765 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 5766 } else {
gume 0:1f82672b8755 5767 /*condition check for page, mag calib
gume 0:1f82672b8755 5768 available in the page zero*/
gume 0:1f82672b8755 5769 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 5770 /* Write the page zero*/
gume 0:1f82672b8755 5771 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 5772 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 5773 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 5774 /* Read the mag calib stat_s8 */
gume 0:1f82672b8755 5775 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 5776 (p_bno055->dev_addr,
gume 0:1f82672b8755 5777 BNO055_MAG_CALIB_STAT_REG,
gume 0:1f82672b8755 5778 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 5779 *mag_calib_u8 =
gume 0:1f82672b8755 5780 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 5781 BNO055_MAG_CALIB_STAT);
gume 0:1f82672b8755 5782 } else {
gume 0:1f82672b8755 5783 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5784 }
gume 0:1f82672b8755 5785 }
gume 0:1f82672b8755 5786 return com_rslt;
gume 0:1f82672b8755 5787 }
gume 0:1f82672b8755 5788 /*!
gume 0:1f82672b8755 5789 * @brief This API used to read
gume 0:1f82672b8755 5790 * accel calibration status from register from 0x35 bit 2 and 3
gume 0:1f82672b8755 5791 *
gume 0:1f82672b8755 5792 * @param accel_calib_u8 : The value of accel calib status
gume 0:1f82672b8755 5793 *
gume 0:1f82672b8755 5794 *
gume 0:1f82672b8755 5795 * @return results of bus communication function
gume 0:1f82672b8755 5796 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 5797 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 5798 *
gume 0:1f82672b8755 5799 */
gume 0:1f82672b8755 5800 BNO055_RETURN_FUNCTION_TYPE bno055_get_accel_calib_stat(
gume 0:1f82672b8755 5801 u8 *accel_calib_u8)
gume 0:1f82672b8755 5802 {
gume 0:1f82672b8755 5803 /* Variable used to return value of
gume 0:1f82672b8755 5804 communication routine*/
gume 0:1f82672b8755 5805 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5806 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5807 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 5808 /* Check the struct p_bno055 is empty*/
gume 0:1f82672b8755 5809 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 5810 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 5811 } else {
gume 0:1f82672b8755 5812 /*condition check for page, accel calib
gume 0:1f82672b8755 5813 available in the page zero*/
gume 0:1f82672b8755 5814 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 5815 /* Write the page zero*/
gume 0:1f82672b8755 5816 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 5817 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 5818 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 5819 /* Read the accel calib stat_s8 */
gume 0:1f82672b8755 5820 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 5821 (p_bno055->dev_addr,
gume 0:1f82672b8755 5822 BNO055_ACCEL_CALIB_STAT_REG,
gume 0:1f82672b8755 5823 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 5824 *accel_calib_u8 =
gume 0:1f82672b8755 5825 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 5826 BNO055_ACCEL_CALIB_STAT);
gume 0:1f82672b8755 5827 } else {
gume 0:1f82672b8755 5828 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5829 }
gume 0:1f82672b8755 5830 }
gume 0:1f82672b8755 5831 return com_rslt;
gume 0:1f82672b8755 5832 }
gume 0:1f82672b8755 5833 /*!
gume 0:1f82672b8755 5834 * @brief This API used to read
gume 0:1f82672b8755 5835 * gyro calibration status from register from 0x35 bit 4 and 5
gume 0:1f82672b8755 5836 *
gume 0:1f82672b8755 5837 * @param gyro_calib_u8 : The value of gyro calib status
gume 0:1f82672b8755 5838 *
gume 0:1f82672b8755 5839 *
gume 0:1f82672b8755 5840 * @return results of bus communication function
gume 0:1f82672b8755 5841 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 5842 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 5843 *
gume 0:1f82672b8755 5844 */
gume 0:1f82672b8755 5845 BNO055_RETURN_FUNCTION_TYPE bno055_get_gyro_calib_stat(
gume 0:1f82672b8755 5846 u8 *gyro_calib_u8)
gume 0:1f82672b8755 5847 {
gume 0:1f82672b8755 5848 /* Variable used to return value of
gume 0:1f82672b8755 5849 communication routine*/
gume 0:1f82672b8755 5850 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5851 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5852 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 5853 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 5854 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 5855 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 5856 } else {
gume 0:1f82672b8755 5857 /*condition check for page, gyro calib
gume 0:1f82672b8755 5858 available in the page zero*/
gume 0:1f82672b8755 5859 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 5860 /* Write the page zero*/
gume 0:1f82672b8755 5861 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 5862 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 5863 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 5864 /* Read the gyro calib status */
gume 0:1f82672b8755 5865 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 5866 (p_bno055->dev_addr,
gume 0:1f82672b8755 5867 BNO055_GYRO_CALIB_STAT_REG,
gume 0:1f82672b8755 5868 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 5869 *gyro_calib_u8 =
gume 0:1f82672b8755 5870 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 5871 BNO055_GYRO_CALIB_STAT);
gume 0:1f82672b8755 5872 } else {
gume 0:1f82672b8755 5873 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5874 }
gume 0:1f82672b8755 5875 }
gume 0:1f82672b8755 5876 return com_rslt;
gume 0:1f82672b8755 5877 }
gume 0:1f82672b8755 5878 /*!
gume 0:1f82672b8755 5879 * @brief This API used to read
gume 0:1f82672b8755 5880 * system calibration status from register from 0x35 bit 6 and 7
gume 0:1f82672b8755 5881 *
gume 0:1f82672b8755 5882 * @param sys_calib_u8 : The value of system calib status
gume 0:1f82672b8755 5883 *
gume 0:1f82672b8755 5884 *
gume 0:1f82672b8755 5885 * @return results of bus communication function
gume 0:1f82672b8755 5886 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 5887 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 5888 *
gume 0:1f82672b8755 5889 */
gume 0:1f82672b8755 5890 BNO055_RETURN_FUNCTION_TYPE bno055_get_sys_calib_stat(
gume 0:1f82672b8755 5891 u8 *sys_calib_u8)
gume 0:1f82672b8755 5892 {
gume 0:1f82672b8755 5893 /* Variable used to return value of
gume 0:1f82672b8755 5894 communication routine*/
gume 0:1f82672b8755 5895 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5896 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5897 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 5898 /* Check the struct p_bno055 is empty*/
gume 0:1f82672b8755 5899 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 5900 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 5901 } else {
gume 0:1f82672b8755 5902 /*condition check for page,system calib
gume 0:1f82672b8755 5903 available in the page zero*/
gume 0:1f82672b8755 5904 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 5905 /* Write the page zero*/
gume 0:1f82672b8755 5906 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 5907 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 5908 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 5909 /* Read the system calib */
gume 0:1f82672b8755 5910 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 5911 (p_bno055->dev_addr,
gume 0:1f82672b8755 5912 BNO055_SYS_CALIB_STAT_REG,
gume 0:1f82672b8755 5913 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 5914 *sys_calib_u8 =
gume 0:1f82672b8755 5915 BNO055_GET_BITSLICE(data_u8r, BNO055_SYS_CALIB_STAT);
gume 0:1f82672b8755 5916 } else {
gume 0:1f82672b8755 5917 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5918 }
gume 0:1f82672b8755 5919 }
gume 0:1f82672b8755 5920 return com_rslt;
gume 0:1f82672b8755 5921 }
gume 0:1f82672b8755 5922 /*!
gume 0:1f82672b8755 5923 * @brief This API used to read
gume 0:1f82672b8755 5924 * all calibration status from register from 0x35
gume 0:1f82672b8755 5925 *
gume 0:1f82672b8755 5926 * @param all_calib_u8 : The value of system calib status
gume 0:1f82672b8755 5927 *
gume 0:1f82672b8755 5928 *
gume 0:1f82672b8755 5929 * @return results of bus communication function
gume 0:1f82672b8755 5930 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 5931 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 5932 *
gume 0:1f82672b8755 5933 */
gume 0:1f82672b8755 5934 BNO055_RETURN_FUNCTION_TYPE bno055_get_all_calib_stat(
gume 0:1f82672b8755 5935 u8 *all_calib_u8)
gume 0:1f82672b8755 5936 {
gume 0:1f82672b8755 5937 /* Variable used to return value of
gume 0:1f82672b8755 5938 communication routine*/
gume 0:1f82672b8755 5939 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5940 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5941 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 5942 /* Check the struct p_bno055 is empty*/
gume 0:1f82672b8755 5943 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 5944 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 5945 } else {
gume 0:1f82672b8755 5946 /*condition check for page,system calib
gume 0:1f82672b8755 5947 available in the page zero*/
gume 0:1f82672b8755 5948 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 5949 /* Write the page zero*/
gume 0:1f82672b8755 5950 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 5951 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 5952 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 5953 /* Read the system calib */
gume 0:1f82672b8755 5954 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 5955 (p_bno055->dev_addr,
gume 0:1f82672b8755 5956 BNO055_ALL_CALIB_STAT_REG,
gume 0:1f82672b8755 5957 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 5958 *all_calib_u8 =
gume 0:1f82672b8755 5959 BNO055_GET_BITSLICE(data_u8r, BNO055_ALL_CALIB_STAT);
gume 0:1f82672b8755 5960 } else {
gume 0:1f82672b8755 5961 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5962 }
gume 0:1f82672b8755 5963 }
gume 0:1f82672b8755 5964 return com_rslt;
gume 0:1f82672b8755 5965 }
gume 0:1f82672b8755 5966 /*!
gume 0:1f82672b8755 5967 * @brief This API used to read
gume 0:1f82672b8755 5968 * self test of accel from register from 0x36 bit 0
gume 0:1f82672b8755 5969 *
gume 0:1f82672b8755 5970 * @param selftest_accel_u8 : The value of self test of accel
gume 0:1f82672b8755 5971 *
gume 0:1f82672b8755 5972 * selftest_accel_u8 | result
gume 0:1f82672b8755 5973 * -------------------- | ---------------------
gume 0:1f82672b8755 5974 * 0x00 | indicates test failed
gume 0:1f82672b8755 5975 * 0x01 | indicated test passed
gume 0:1f82672b8755 5976 *
gume 0:1f82672b8755 5977 * @return results of bus communication function
gume 0:1f82672b8755 5978 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 5979 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 5980 *
gume 0:1f82672b8755 5981 */
gume 0:1f82672b8755 5982 BNO055_RETURN_FUNCTION_TYPE bno055_get_selftest_accel(
gume 0:1f82672b8755 5983 u8 *selftest_accel_u8)
gume 0:1f82672b8755 5984 {
gume 0:1f82672b8755 5985 /* Variable used to return value of
gume 0:1f82672b8755 5986 communication routine*/
gume 0:1f82672b8755 5987 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 5988 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 5989 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 5990 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 5991 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 5992 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 5993 } else {
gume 0:1f82672b8755 5994 /*condition check for page, accel self test is
gume 0:1f82672b8755 5995 available in the page zero*/
gume 0:1f82672b8755 5996 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 5997 /* Write the page zero*/
gume 0:1f82672b8755 5998 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 5999 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 6000 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 6001 /* Read the accel self test */
gume 0:1f82672b8755 6002 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 6003 (p_bno055->dev_addr,
gume 0:1f82672b8755 6004 BNO055_SELFTEST_ACCEL_REG,
gume 0:1f82672b8755 6005 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 6006 *selftest_accel_u8 =
gume 0:1f82672b8755 6007 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 6008 BNO055_SELFTEST_ACCEL);
gume 0:1f82672b8755 6009 } else {
gume 0:1f82672b8755 6010 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6011 }
gume 0:1f82672b8755 6012 }
gume 0:1f82672b8755 6013 return com_rslt;
gume 0:1f82672b8755 6014 }
gume 0:1f82672b8755 6015 /*!
gume 0:1f82672b8755 6016 * @brief This API used to read
gume 0:1f82672b8755 6017 * self test of mag from register from 0x36 bit 1
gume 0:1f82672b8755 6018 *
gume 0:1f82672b8755 6019 * @param selftest_mag_u8 : The value of self test of mag
gume 0:1f82672b8755 6020 *
gume 0:1f82672b8755 6021 * selftest_mag_u8 | result
gume 0:1f82672b8755 6022 * -------------------- | ---------------------
gume 0:1f82672b8755 6023 * 0x00 | indicates test failed
gume 0:1f82672b8755 6024 * 0x01 | indicated test passed
gume 0:1f82672b8755 6025 *
gume 0:1f82672b8755 6026 * @return results of bus communication function
gume 0:1f82672b8755 6027 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 6028 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 6029 *
gume 0:1f82672b8755 6030 */
gume 0:1f82672b8755 6031 BNO055_RETURN_FUNCTION_TYPE bno055_get_selftest_mag(
gume 0:1f82672b8755 6032 u8 *selftest_mag_u8)
gume 0:1f82672b8755 6033 {
gume 0:1f82672b8755 6034 /* Variable used to return value of
gume 0:1f82672b8755 6035 communication routine*/
gume 0:1f82672b8755 6036 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6037 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 6038 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 6039 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 6040 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 6041 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 6042 } else {
gume 0:1f82672b8755 6043 /*condition check for page, self test of mag is
gume 0:1f82672b8755 6044 available in the page zero*/
gume 0:1f82672b8755 6045 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 6046 /* Write the page zero*/
gume 0:1f82672b8755 6047 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 6048 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 6049 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 6050 /* Read the mag self test */
gume 0:1f82672b8755 6051 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 6052 (p_bno055->dev_addr,
gume 0:1f82672b8755 6053 BNO055_SELFTEST_MAG_REG, &data_u8r,
gume 0:1f82672b8755 6054 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 6055 *selftest_mag_u8 =
gume 0:1f82672b8755 6056 BNO055_GET_BITSLICE(data_u8r, BNO055_SELFTEST_MAG);
gume 0:1f82672b8755 6057 } else {
gume 0:1f82672b8755 6058 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6059 }
gume 0:1f82672b8755 6060 }
gume 0:1f82672b8755 6061 return com_rslt;
gume 0:1f82672b8755 6062 }
gume 0:1f82672b8755 6063 /*!
gume 0:1f82672b8755 6064 * @brief This API used to read
gume 0:1f82672b8755 6065 * self test of gyro from register from 0x36 bit 2
gume 0:1f82672b8755 6066 *
gume 0:1f82672b8755 6067 * @param selftest_gyro_u8 : The value of self test of gyro
gume 0:1f82672b8755 6068 *
gume 0:1f82672b8755 6069 * selftest_gyro_u8 | result
gume 0:1f82672b8755 6070 * -------------------- | ---------------------
gume 0:1f82672b8755 6071 * 0x00 | indicates test failed
gume 0:1f82672b8755 6072 * 0x01 | indicated test passed
gume 0:1f82672b8755 6073 *
gume 0:1f82672b8755 6074 * @return results of bus communication function
gume 0:1f82672b8755 6075 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 6076 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 6077 *
gume 0:1f82672b8755 6078 */
gume 0:1f82672b8755 6079 BNO055_RETURN_FUNCTION_TYPE bno055_get_selftest_gyro(
gume 0:1f82672b8755 6080 u8 *selftest_gyro_u8)
gume 0:1f82672b8755 6081 {
gume 0:1f82672b8755 6082 /* Variable used to return value of
gume 0:1f82672b8755 6083 communication routine*/
gume 0:1f82672b8755 6084 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6085 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 6086 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 6087 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 6088 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 6089 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 6090 } else {
gume 0:1f82672b8755 6091 /*condition check for page self test of gyro is
gume 0:1f82672b8755 6092 available in the page zero*/
gume 0:1f82672b8755 6093 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 6094 /* Write the page zero*/
gume 0:1f82672b8755 6095 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 6096 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 6097 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 6098 /* Read the gyro self test */
gume 0:1f82672b8755 6099 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 6100 (p_bno055->dev_addr,
gume 0:1f82672b8755 6101 BNO055_SELFTEST_GYRO_REG, &data_u8r,
gume 0:1f82672b8755 6102 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 6103 *selftest_gyro_u8 =
gume 0:1f82672b8755 6104 BNO055_GET_BITSLICE(data_u8r, BNO055_SELFTEST_GYRO);
gume 0:1f82672b8755 6105 } else {
gume 0:1f82672b8755 6106 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6107 }
gume 0:1f82672b8755 6108 }
gume 0:1f82672b8755 6109 return com_rslt;
gume 0:1f82672b8755 6110 }
gume 0:1f82672b8755 6111 /*!
gume 0:1f82672b8755 6112 * @brief This API used to read
gume 0:1f82672b8755 6113 * self test of micro controller from register from 0x36 bit 3
gume 0:1f82672b8755 6114 *
gume 0:1f82672b8755 6115 * @param selftest_mcu_u8 : The value of self test of micro controller
gume 0:1f82672b8755 6116 *
gume 0:1f82672b8755 6117 * selftest_mcu_u8 | result
gume 0:1f82672b8755 6118 * -------------------- | ---------------------
gume 0:1f82672b8755 6119 * 0x00 | indicates test failed
gume 0:1f82672b8755 6120 * 0x01 | indicated test passed
gume 0:1f82672b8755 6121 *
gume 0:1f82672b8755 6122 * @return results of bus communication function
gume 0:1f82672b8755 6123 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 6124 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 6125 *
gume 0:1f82672b8755 6126 */
gume 0:1f82672b8755 6127 BNO055_RETURN_FUNCTION_TYPE bno055_get_selftest_mcu(
gume 0:1f82672b8755 6128 u8 *selftest_mcu_u8)
gume 0:1f82672b8755 6129 {
gume 0:1f82672b8755 6130 /* Variable used to return value of
gume 0:1f82672b8755 6131 communication routine*/
gume 0:1f82672b8755 6132 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6133 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 6134 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 6135 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 6136 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 6137 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 6138 } else {
gume 0:1f82672b8755 6139 /*condition check for page self test of micro controller
gume 0:1f82672b8755 6140 is available in the page zero*/
gume 0:1f82672b8755 6141 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 6142 /* Write the page zero*/
gume 0:1f82672b8755 6143 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 6144 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 6145 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 6146 /* Read the self test of micro controller*/
gume 0:1f82672b8755 6147 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 6148 (p_bno055->dev_addr,
gume 0:1f82672b8755 6149 BNO055_SELFTEST_MCU_REG, &data_u8r,
gume 0:1f82672b8755 6150 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 6151 *selftest_mcu_u8 =
gume 0:1f82672b8755 6152 BNO055_GET_BITSLICE(data_u8r, BNO055_SELFTEST_MCU);
gume 0:1f82672b8755 6153 } else {
gume 0:1f82672b8755 6154 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6155 }
gume 0:1f82672b8755 6156 }
gume 0:1f82672b8755 6157 return com_rslt;
gume 0:1f82672b8755 6158 }
gume 0:1f82672b8755 6159 /*!
gume 0:1f82672b8755 6160 * @brief This API used to read the stat_s8 of
gume 0:1f82672b8755 6161 * gyro anymotion interrupt from register from 0x37 bit 2
gume 0:1f82672b8755 6162 *
gume 0:1f82672b8755 6163 * @param gyro_any_motion_u8 : The value of gyro anymotion interrupt
gume 0:1f82672b8755 6164 *
gume 0:1f82672b8755 6165 * gyro_any_motion_u8 | result
gume 0:1f82672b8755 6166 * -------------------- | ---------------------
gume 0:1f82672b8755 6167 * 0x00 | indicates no interrupt triggered
gume 0:1f82672b8755 6168 * 0x01 | indicates interrupt triggered
gume 0:1f82672b8755 6169 *
gume 0:1f82672b8755 6170 * @return results of bus communication function
gume 0:1f82672b8755 6171 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 6172 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 6173 *
gume 0:1f82672b8755 6174 * @note Gyro anymotion interrupt can be BNO055_BIT_ENABLE
gume 0:1f82672b8755 6175 * by the following APIs
gume 0:1f82672b8755 6176 *
gume 0:1f82672b8755 6177 * bno055_set_intr_mask_gyro_any_motion()
gume 0:1f82672b8755 6178 *
gume 0:1f82672b8755 6179 * bno055_set_intr_gyro_any_motion()
gume 0:1f82672b8755 6180 *
gume 0:1f82672b8755 6181 */
gume 0:1f82672b8755 6182 BNO055_RETURN_FUNCTION_TYPE bno055_get_intr_stat_gyro_any_motion(
gume 0:1f82672b8755 6183 u8 *gyro_any_motion_u8)
gume 0:1f82672b8755 6184 {
gume 0:1f82672b8755 6185 /* Variable used to return value of
gume 0:1f82672b8755 6186 communication routine*/
gume 0:1f82672b8755 6187 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6188 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 6189 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 6190 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 6191 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 6192 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 6193 } else {
gume 0:1f82672b8755 6194 /*condition check for page, gyro anymotion interrupt
gume 0:1f82672b8755 6195 status is available in the page zero*/
gume 0:1f82672b8755 6196 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 6197 /* Write the page zero*/
gume 0:1f82672b8755 6198 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 6199 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 6200 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 6201 /* Read the gyro anymotion interrupt stat_s8*/
gume 0:1f82672b8755 6202 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 6203 (p_bno055->dev_addr,
gume 0:1f82672b8755 6204 BNO055_INTR_STAT_GYRO_ANY_MOTION_REG,
gume 0:1f82672b8755 6205 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 6206 *gyro_any_motion_u8 =
gume 0:1f82672b8755 6207 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 6208 BNO055_INTR_STAT_GYRO_ANY_MOTION);
gume 0:1f82672b8755 6209 } else {
gume 0:1f82672b8755 6210 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6211 }
gume 0:1f82672b8755 6212 }
gume 0:1f82672b8755 6213 return com_rslt;
gume 0:1f82672b8755 6214 }
gume 0:1f82672b8755 6215 /*!
gume 0:1f82672b8755 6216 * @brief This API used to read the stat_s8 of
gume 0:1f82672b8755 6217 * gyro highrate interrupt from register from 0x37 bit 3
gume 0:1f82672b8755 6218 *
gume 0:1f82672b8755 6219 * @param gyro_highrate_u8 : The value of gyro highrate interrupt
gume 0:1f82672b8755 6220 *
gume 0:1f82672b8755 6221 * gyro_highrate_u8 | result
gume 0:1f82672b8755 6222 * ------------------- | ---------------------
gume 0:1f82672b8755 6223 * 0x00 | indicates no interrupt triggered
gume 0:1f82672b8755 6224 * 0x01 | indicates interrupt triggered
gume 0:1f82672b8755 6225 *
gume 0:1f82672b8755 6226 * @return results of bus communication function
gume 0:1f82672b8755 6227 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 6228 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 6229 *
gume 0:1f82672b8755 6230 * @note Gyro highrate interrupt can be configured
gume 0:1f82672b8755 6231 * by the following APIs
gume 0:1f82672b8755 6232 *
gume 0:1f82672b8755 6233 * bno055_set_intr_mask_gyro_highrate()
gume 0:1f82672b8755 6234 *
gume 0:1f82672b8755 6235 * bno055_set_intr_gyro_highrate()
gume 0:1f82672b8755 6236 */
gume 0:1f82672b8755 6237 BNO055_RETURN_FUNCTION_TYPE bno055_get_intr_stat_gyro_highrate(
gume 0:1f82672b8755 6238 u8 *gyro_highrate_u8)
gume 0:1f82672b8755 6239 {
gume 0:1f82672b8755 6240 /* Variable used to return value of
gume 0:1f82672b8755 6241 communication routine*/
gume 0:1f82672b8755 6242 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6243 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 6244 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 6245 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 6246 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 6247 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 6248 } else {
gume 0:1f82672b8755 6249 /*condition check for page, gyro highrate is
gume 0:1f82672b8755 6250 available in the page zero*/
gume 0:1f82672b8755 6251 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 6252 /* Write the page zero*/
gume 0:1f82672b8755 6253 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 6254 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 6255 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 6256 /* Read the gyro highrate interrupt stat_s8*/
gume 0:1f82672b8755 6257 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 6258 (p_bno055->dev_addr,
gume 0:1f82672b8755 6259 BNO055_INTR_STAT_GYRO_HIGHRATE_REG,
gume 0:1f82672b8755 6260 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 6261 *gyro_highrate_u8 =
gume 0:1f82672b8755 6262 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 6263 BNO055_INTR_STAT_GYRO_HIGHRATE);
gume 0:1f82672b8755 6264 } else {
gume 0:1f82672b8755 6265 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6266 }
gume 0:1f82672b8755 6267 }
gume 0:1f82672b8755 6268 return com_rslt;
gume 0:1f82672b8755 6269 }
gume 0:1f82672b8755 6270 /*!
gume 0:1f82672b8755 6271 * @brief This API used to read the stat_s8 of
gume 0:1f82672b8755 6272 * accel highg interrupt from register from 0x37 bit 5
gume 0:1f82672b8755 6273 *
gume 0:1f82672b8755 6274 * @param accel_high_g_u8 : The value of accel highg interrupt
gume 0:1f82672b8755 6275 *
gume 0:1f82672b8755 6276 * accel_high_g_u8 | result
gume 0:1f82672b8755 6277 * ------------------- | ---------------------
gume 0:1f82672b8755 6278 * 0x00 | indicates no interrupt triggered
gume 0:1f82672b8755 6279 * 0x01 | indicates interrupt triggered
gume 0:1f82672b8755 6280 *
gume 0:1f82672b8755 6281 * @return results of bus communication function
gume 0:1f82672b8755 6282 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 6283 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 6284 *
gume 0:1f82672b8755 6285 * @note Accel highg interrupt can be configured
gume 0:1f82672b8755 6286 * by the following APIs
gume 0:1f82672b8755 6287 *
gume 0:1f82672b8755 6288 * bno055_set_intr_mask_accel_high_g()
gume 0:1f82672b8755 6289 *
gume 0:1f82672b8755 6290 * bno055_set_intr_accel_high_g()
gume 0:1f82672b8755 6291 *
gume 0:1f82672b8755 6292 */
gume 0:1f82672b8755 6293 BNO055_RETURN_FUNCTION_TYPE bno055_get_intr_stat_accel_high_g(
gume 0:1f82672b8755 6294 u8 *accel_high_g_u8)
gume 0:1f82672b8755 6295 {
gume 0:1f82672b8755 6296 /* Variable used to return value of
gume 0:1f82672b8755 6297 communication routine*/
gume 0:1f82672b8755 6298 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6299 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 6300 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 6301 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 6302 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 6303 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 6304 } else {
gume 0:1f82672b8755 6305 /*condition check for page, accel highg is
gume 0:1f82672b8755 6306 available in the page zero*/
gume 0:1f82672b8755 6307 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 6308 /* Write the page zero*/
gume 0:1f82672b8755 6309 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 6310 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 6311 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 6312 /* Read the accel highg interrupt stat_s8 */
gume 0:1f82672b8755 6313 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 6314 (p_bno055->dev_addr,
gume 0:1f82672b8755 6315 BNO055_INTR_STAT_ACCEL_HIGH_G_REG,
gume 0:1f82672b8755 6316 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 6317 *accel_high_g_u8 =
gume 0:1f82672b8755 6318 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 6319 BNO055_INTR_STAT_ACCEL_HIGH_G);
gume 0:1f82672b8755 6320 } else {
gume 0:1f82672b8755 6321 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6322 }
gume 0:1f82672b8755 6323 }
gume 0:1f82672b8755 6324 return com_rslt;
gume 0:1f82672b8755 6325 }
gume 0:1f82672b8755 6326 /*!
gume 0:1f82672b8755 6327 * @brief This API used to read the stat_s8 of
gume 0:1f82672b8755 6328 * accel anymotion interrupt from register from 0x37 bit 6
gume 0:1f82672b8755 6329 *
gume 0:1f82672b8755 6330 * @param accel_any_motion_u8 : The value of accel anymotion interrupt
gume 0:1f82672b8755 6331 *
gume 0:1f82672b8755 6332 * accel_any_motion_u8 | result
gume 0:1f82672b8755 6333 * ------------------- | ---------------------
gume 0:1f82672b8755 6334 * 0x00 | indicates no interrupt triggered
gume 0:1f82672b8755 6335 * 0x01 | indicates interrupt triggered
gume 0:1f82672b8755 6336 *
gume 0:1f82672b8755 6337 * @return results of bus communication function
gume 0:1f82672b8755 6338 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 6339 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 6340 *
gume 0:1f82672b8755 6341 * @note Accel anymotion interrupt can be configured
gume 0:1f82672b8755 6342 * by the following APIs
gume 0:1f82672b8755 6343 *
gume 0:1f82672b8755 6344 * bno055_set_intr_mask_accel_any_motion()
gume 0:1f82672b8755 6345 *
gume 0:1f82672b8755 6346 * bno055_set_intr_accel_any_motion()
gume 0:1f82672b8755 6347 */
gume 0:1f82672b8755 6348 BNO055_RETURN_FUNCTION_TYPE bno055_get_intr_stat_accel_any_motion(
gume 0:1f82672b8755 6349 u8 *accel_any_motion_u8)
gume 0:1f82672b8755 6350 {
gume 0:1f82672b8755 6351 /* Variable used to return value of
gume 0:1f82672b8755 6352 communication routine*/
gume 0:1f82672b8755 6353 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6354 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 6355 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 6356 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 6357 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 6358 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 6359 } else {
gume 0:1f82672b8755 6360 /*condition check for page, accel anymotion is
gume 0:1f82672b8755 6361 available in the page zero*/
gume 0:1f82672b8755 6362 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 6363 /* Write the page zero*/
gume 0:1f82672b8755 6364 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 6365 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 6366 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 6367 /* Read the accel anymotion interrupt stat_s8 */
gume 0:1f82672b8755 6368 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 6369 (p_bno055->dev_addr,
gume 0:1f82672b8755 6370 BNO055_INTR_STAT_ACCEL_ANY_MOTION_REG,
gume 0:1f82672b8755 6371 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 6372 *accel_any_motion_u8 =
gume 0:1f82672b8755 6373 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 6374 BNO055_INTR_STAT_ACCEL_ANY_MOTION);
gume 0:1f82672b8755 6375 } else {
gume 0:1f82672b8755 6376 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6377 }
gume 0:1f82672b8755 6378 }
gume 0:1f82672b8755 6379 return com_rslt;
gume 0:1f82672b8755 6380 }
gume 0:1f82672b8755 6381 /*!
gume 0:1f82672b8755 6382 * @brief This API used to read the stat_s8 of
gume 0:1f82672b8755 6383 * accel nomotion/slowmotion interrupt from register from 0x37 bit 6
gume 0:1f82672b8755 6384 *
gume 0:1f82672b8755 6385 * @param accel_no_motion_u8 : The value of accel
gume 0:1f82672b8755 6386 * nomotion/slowmotion interrupt
gume 0:1f82672b8755 6387 *
gume 0:1f82672b8755 6388 * accel_no_motion_u8 | result
gume 0:1f82672b8755 6389 * ------------------- | ---------------------
gume 0:1f82672b8755 6390 * 0x00 | indicates no interrupt triggered
gume 0:1f82672b8755 6391 * 0x01 | indicates interrupt triggered
gume 0:1f82672b8755 6392 *
gume 0:1f82672b8755 6393 * @return results of bus communication function
gume 0:1f82672b8755 6394 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 6395 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 6396 *
gume 0:1f82672b8755 6397 * @note Accel nomotion/slowmotion interrupt can be configured
gume 0:1f82672b8755 6398 * by the following APIs
gume 0:1f82672b8755 6399 *
gume 0:1f82672b8755 6400 * bno055_set_intr_mask_accel_nomotion()
gume 0:1f82672b8755 6401 *
gume 0:1f82672b8755 6402 * bno055_set_intr_accel_nomotion()
gume 0:1f82672b8755 6403 */
gume 0:1f82672b8755 6404 BNO055_RETURN_FUNCTION_TYPE bno055_get_intr_stat_accel_no_motion(
gume 0:1f82672b8755 6405 u8 *accel_no_motion_u8)
gume 0:1f82672b8755 6406 {
gume 0:1f82672b8755 6407 /* Variable used to return value of
gume 0:1f82672b8755 6408 communication routine*/
gume 0:1f82672b8755 6409 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6410 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 6411 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 6412 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 6413 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 6414 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 6415 } else {
gume 0:1f82672b8755 6416 /*condition check for page, accel
gume 0:1f82672b8755 6417 nomotion/slowmotion interrupt
gume 0:1f82672b8755 6418 is available in the page zero*/
gume 0:1f82672b8755 6419 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 6420 /* Write the page zero*/
gume 0:1f82672b8755 6421 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 6422 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 6423 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 6424 /* Read the stat_s8 of accel
gume 0:1f82672b8755 6425 nomotion/slowmotion interrupt*/
gume 0:1f82672b8755 6426 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 6427 (p_bno055->dev_addr,
gume 0:1f82672b8755 6428 BNO055_INTR_STAT_ACCEL_NO_MOTION_REG,
gume 0:1f82672b8755 6429 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 6430 *accel_no_motion_u8 =
gume 0:1f82672b8755 6431 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 6432 BNO055_INTR_STAT_ACCEL_NO_MOTION);
gume 0:1f82672b8755 6433 } else {
gume 0:1f82672b8755 6434 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6435 }
gume 0:1f82672b8755 6436 }
gume 0:1f82672b8755 6437 return com_rslt;
gume 0:1f82672b8755 6438 }
gume 0:1f82672b8755 6439 /*!
gume 0:1f82672b8755 6440 * @brief This API is used to read status of main clock
gume 0:1f82672b8755 6441 * from the register 0x38 bit 0
gume 0:1f82672b8755 6442 *
gume 0:1f82672b8755 6443 * @param stat_main_clk_u8 : the status of main clock
gume 0:1f82672b8755 6444 *
gume 0:1f82672b8755 6445 *
gume 0:1f82672b8755 6446 * @return results of bus communication function
gume 0:1f82672b8755 6447 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 6448 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 6449 *
gume 0:1f82672b8755 6450 */
gume 0:1f82672b8755 6451 BNO055_RETURN_FUNCTION_TYPE bno055_get_stat_main_clk(
gume 0:1f82672b8755 6452 u8 *stat_main_clk_u8)
gume 0:1f82672b8755 6453 {
gume 0:1f82672b8755 6454 /* Variable used to return value of
gume 0:1f82672b8755 6455 communication routine*/
gume 0:1f82672b8755 6456 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6457 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 6458 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 6459 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 6460 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 6461 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 6462 } else {
gume 0:1f82672b8755 6463 /*condition check for page, status of main clk is
gume 0:1f82672b8755 6464 available in the page zero*/
gume 0:1f82672b8755 6465 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 6466 /* Write the page zero*/
gume 0:1f82672b8755 6467 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 6468 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 6469 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 6470 /* Read the status of main clk */
gume 0:1f82672b8755 6471 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 6472 (p_bno055->dev_addr,
gume 0:1f82672b8755 6473 BNO055_SYS_MAIN_CLK_REG,
gume 0:1f82672b8755 6474 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 6475 *stat_main_clk_u8 =
gume 0:1f82672b8755 6476 BNO055_GET_BITSLICE(data_u8r, BNO055_SYS_MAIN_CLK);
gume 0:1f82672b8755 6477 } else {
gume 0:1f82672b8755 6478 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6479 }
gume 0:1f82672b8755 6480 }
gume 0:1f82672b8755 6481 return com_rslt;
gume 0:1f82672b8755 6482 }
gume 0:1f82672b8755 6483 /*!
gume 0:1f82672b8755 6484 * @brief This API is used to read system status
gume 0:1f82672b8755 6485 * code from the register 0x39 it is a byte of data
gume 0:1f82672b8755 6486 *
gume 0:1f82672b8755 6487 * @param sys_stat_u8 : the status of system
gume 0:1f82672b8755 6488 *
gume 0:1f82672b8755 6489 *
gume 0:1f82672b8755 6490 * @return results of bus communication function
gume 0:1f82672b8755 6491 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 6492 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 6493 *
gume 0:1f82672b8755 6494 */
gume 0:1f82672b8755 6495 BNO055_RETURN_FUNCTION_TYPE bno055_get_sys_stat_code(
gume 0:1f82672b8755 6496 u8 *sys_stat_u8)
gume 0:1f82672b8755 6497 {
gume 0:1f82672b8755 6498 /* Variable used to return value of
gume 0:1f82672b8755 6499 communication routine*/
gume 0:1f82672b8755 6500 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6501 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 6502 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 6503 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 6504 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 6505 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 6506 } else {
gume 0:1f82672b8755 6507 /*condition check for page, the status of system is
gume 0:1f82672b8755 6508 available in the page zero*/
gume 0:1f82672b8755 6509 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 6510 /* Write the page zero*/
gume 0:1f82672b8755 6511 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 6512 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 6513 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 6514 /* Read the the status of system*/
gume 0:1f82672b8755 6515 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 6516 (p_bno055->dev_addr,
gume 0:1f82672b8755 6517 BNO055_SYS_STAT_CODE_REG,
gume 0:1f82672b8755 6518 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 6519 *sys_stat_u8 =
gume 0:1f82672b8755 6520 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 6521 BNO055_SYS_STAT_CODE);
gume 0:1f82672b8755 6522 } else {
gume 0:1f82672b8755 6523 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6524 }
gume 0:1f82672b8755 6525 }
gume 0:1f82672b8755 6526 return com_rslt;
gume 0:1f82672b8755 6527 }
gume 0:1f82672b8755 6528 /*!
gume 0:1f82672b8755 6529 * @brief This API is used to read system BNO055_ERROR
gume 0:1f82672b8755 6530 * code from the register 0x3A it is a byte of data
gume 0:1f82672b8755 6531 *
gume 0:1f82672b8755 6532 * @param sys_error_u8 : The value of system BNO055_ERROR code
gume 0:1f82672b8755 6533 *
gume 0:1f82672b8755 6534 *
gume 0:1f82672b8755 6535 * @return results of bus communication function
gume 0:1f82672b8755 6536 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 6537 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 6538 *
gume 0:1f82672b8755 6539 *
gume 0:1f82672b8755 6540 */
gume 0:1f82672b8755 6541 BNO055_RETURN_FUNCTION_TYPE bno055_get_sys_error_code(
gume 0:1f82672b8755 6542 u8 *sys_error_u8)
gume 0:1f82672b8755 6543 {
gume 0:1f82672b8755 6544 /* Variable used to return value of
gume 0:1f82672b8755 6545 communication routine*/
gume 0:1f82672b8755 6546 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6547 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 6548 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 6549 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 6550 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 6551 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 6552 } else {
gume 0:1f82672b8755 6553 /*condition check for page, system BNO055_ERROR code is
gume 0:1f82672b8755 6554 available in the page zero*/
gume 0:1f82672b8755 6555 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 6556 /* Write the page zero*/
gume 0:1f82672b8755 6557 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 6558 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 6559 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 6560 /* Read the system BNO055_ERROR code*/
gume 0:1f82672b8755 6561 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 6562 (p_bno055->dev_addr,
gume 0:1f82672b8755 6563 BNO055_SYS_ERROR_CODE_REG,
gume 0:1f82672b8755 6564 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 6565 *sys_error_u8 =
gume 0:1f82672b8755 6566 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 6567 BNO055_SYS_ERROR_CODE);
gume 0:1f82672b8755 6568 } else {
gume 0:1f82672b8755 6569 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6570 }
gume 0:1f82672b8755 6571 }
gume 0:1f82672b8755 6572 return com_rslt;
gume 0:1f82672b8755 6573 }
gume 0:1f82672b8755 6574 /*!
gume 0:1f82672b8755 6575 * @brief This API used to read the accel unit
gume 0:1f82672b8755 6576 * from register from 0x3B bit 0
gume 0:1f82672b8755 6577 *
gume 0:1f82672b8755 6578 * @param accel_unit_u8 : The value of accel unit
gume 0:1f82672b8755 6579 *
gume 0:1f82672b8755 6580 * accel_unit_u8 | result
gume 0:1f82672b8755 6581 * ------------- | ---------------
gume 0:1f82672b8755 6582 * 0x00 | BNO055_ACCEL_UNIT_MSQ
gume 0:1f82672b8755 6583 * 0x01 | BNO055_ACCEL_UNIT_MG
gume 0:1f82672b8755 6584 *
gume 0:1f82672b8755 6585 * @return results of bus communication function
gume 0:1f82672b8755 6586 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 6587 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 6588 *
gume 0:1f82672b8755 6589 */
gume 0:1f82672b8755 6590 BNO055_RETURN_FUNCTION_TYPE bno055_get_accel_unit(
gume 0:1f82672b8755 6591 u8 *accel_unit_u8)
gume 0:1f82672b8755 6592 {
gume 0:1f82672b8755 6593 /* Variable used to return value of
gume 0:1f82672b8755 6594 communication routine*/
gume 0:1f82672b8755 6595 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6596 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 6597 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 6598 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 6599 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 6600 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 6601 } else {
gume 0:1f82672b8755 6602 /*condition check for page, accel unit is
gume 0:1f82672b8755 6603 available in the page zero*/
gume 0:1f82672b8755 6604 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 6605 /* Write the page zero*/
gume 0:1f82672b8755 6606 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 6607 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 6608 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 6609 /* Read the accel unit */
gume 0:1f82672b8755 6610 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 6611 (p_bno055->dev_addr,
gume 0:1f82672b8755 6612 BNO055_ACCEL_UNIT_REG,
gume 0:1f82672b8755 6613 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 6614 *accel_unit_u8 =
gume 0:1f82672b8755 6615 BNO055_GET_BITSLICE(data_u8r, BNO055_ACCEL_UNIT);
gume 0:1f82672b8755 6616 } else {
gume 0:1f82672b8755 6617 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6618 }
gume 0:1f82672b8755 6619 }
gume 0:1f82672b8755 6620 return com_rslt;
gume 0:1f82672b8755 6621 }
gume 0:1f82672b8755 6622 /*!
gume 0:1f82672b8755 6623 * @brief This API used to write the accel unit
gume 0:1f82672b8755 6624 * from register from 0x3B bit 0
gume 0:1f82672b8755 6625 *
gume 0:1f82672b8755 6626 * @param accel_unit_u8 : The value of accel unit
gume 0:1f82672b8755 6627 *
gume 0:1f82672b8755 6628 * accel_unit_u8 | result
gume 0:1f82672b8755 6629 * ------------- | ---------------
gume 0:1f82672b8755 6630 * 0x00 | BNO055_ACCEL_UNIT_MSQ
gume 0:1f82672b8755 6631 * 0x01 | BNO055_ACCEL_UNIT_MG
gume 0:1f82672b8755 6632 *
gume 0:1f82672b8755 6633 * @return results of bus communication function
gume 0:1f82672b8755 6634 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 6635 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 6636 *
gume 0:1f82672b8755 6637 *
gume 0:1f82672b8755 6638 */
gume 0:1f82672b8755 6639 BNO055_RETURN_FUNCTION_TYPE bno055_set_accel_unit(
gume 0:1f82672b8755 6640 u8 accel_unit_u8)
gume 0:1f82672b8755 6641 {
gume 0:1f82672b8755 6642 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6643 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 6644 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 6645 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 6646 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 6647 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 6648 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 6649 } else {
gume 0:1f82672b8755 6650 /* The write operation effective only if the operation
gume 0:1f82672b8755 6651 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 6652 current operation mode and set the config mode */
gume 0:1f82672b8755 6653 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 6654 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 6655 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 6656 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 6657 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 6658 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 6659 /* Write the accel unit */
gume 0:1f82672b8755 6660 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 6661 (p_bno055->dev_addr,
gume 0:1f82672b8755 6662 BNO055_ACCEL_UNIT_REG,
gume 0:1f82672b8755 6663 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 6664 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 6665 data_u8r =
gume 0:1f82672b8755 6666 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 6667 BNO055_ACCEL_UNIT, accel_unit_u8);
gume 0:1f82672b8755 6668 com_rslt +=
gume 0:1f82672b8755 6669 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 6670 (p_bno055->dev_addr,
gume 0:1f82672b8755 6671 BNO055_ACCEL_UNIT_REG,
gume 0:1f82672b8755 6672 &data_u8r,
gume 0:1f82672b8755 6673 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 6674 }
gume 0:1f82672b8755 6675 } else {
gume 0:1f82672b8755 6676 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6677 }
gume 0:1f82672b8755 6678 } else {
gume 0:1f82672b8755 6679 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6680 }
gume 0:1f82672b8755 6681 }
gume 0:1f82672b8755 6682 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 6683 /* set the operation mode
gume 0:1f82672b8755 6684 of previous operation mode*/
gume 0:1f82672b8755 6685 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 6686 (prev_opmode_u8);
gume 0:1f82672b8755 6687 return com_rslt;
gume 0:1f82672b8755 6688 }
gume 0:1f82672b8755 6689 /*!
gume 0:1f82672b8755 6690 * @brief This API used to read the gyro unit
gume 0:1f82672b8755 6691 * from register from 0x3B bit 1
gume 0:1f82672b8755 6692 *
gume 0:1f82672b8755 6693 * @param gyro_unit_u8 : The value of accel unit
gume 0:1f82672b8755 6694 *
gume 0:1f82672b8755 6695 * gyro_unit_u8 | result
gume 0:1f82672b8755 6696 * ------------- | -----------
gume 0:1f82672b8755 6697 * 0x00 | BNO055_GYRO_UNIT_DPS
gume 0:1f82672b8755 6698 * 0x01 | BNO055_GYRO_UNIT_RPS
gume 0:1f82672b8755 6699 *
gume 0:1f82672b8755 6700 * @return results of bus communication function
gume 0:1f82672b8755 6701 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 6702 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 6703 *
gume 0:1f82672b8755 6704 *
gume 0:1f82672b8755 6705 */
gume 0:1f82672b8755 6706 BNO055_RETURN_FUNCTION_TYPE bno055_get_gyro_unit(
gume 0:1f82672b8755 6707 u8 *gyro_unit_u8)
gume 0:1f82672b8755 6708 {
gume 0:1f82672b8755 6709 /* Variable used to return value of
gume 0:1f82672b8755 6710 communication routine*/
gume 0:1f82672b8755 6711 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6712 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 6713 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 6714 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 6715 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 6716 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 6717 } else {
gume 0:1f82672b8755 6718 /*condition check for page, gyro unit is
gume 0:1f82672b8755 6719 available in the page zero*/
gume 0:1f82672b8755 6720 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 6721 /* Write the page zero*/
gume 0:1f82672b8755 6722 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 6723 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 6724 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 6725 /* Read the gyro unit */
gume 0:1f82672b8755 6726 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 6727 (p_bno055->dev_addr,
gume 0:1f82672b8755 6728 BNO055_GYRO_UNIT_REG,
gume 0:1f82672b8755 6729 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 6730 *gyro_unit_u8 =
gume 0:1f82672b8755 6731 BNO055_GET_BITSLICE(data_u8r, BNO055_GYRO_UNIT);
gume 0:1f82672b8755 6732 } else {
gume 0:1f82672b8755 6733 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6734 }
gume 0:1f82672b8755 6735 }
gume 0:1f82672b8755 6736 return com_rslt;
gume 0:1f82672b8755 6737 }
gume 0:1f82672b8755 6738 /*!
gume 0:1f82672b8755 6739 * @brief This API used to write the gyro unit
gume 0:1f82672b8755 6740 * from register from 0x3B bit 1
gume 0:1f82672b8755 6741 *
gume 0:1f82672b8755 6742 * @param gyro_unit_u8 : The value of accel unit
gume 0:1f82672b8755 6743 *
gume 0:1f82672b8755 6744 * gyro_unit_u8 | result
gume 0:1f82672b8755 6745 * ------------- | -----------
gume 0:1f82672b8755 6746 * 0x00 | BNO055_GYRO_UNIT_DPS
gume 0:1f82672b8755 6747 * 0x01 | BNO055_GYRO_UNIT_RPS
gume 0:1f82672b8755 6748 *
gume 0:1f82672b8755 6749 * @return results of bus communication function
gume 0:1f82672b8755 6750 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 6751 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 6752 *
gume 0:1f82672b8755 6753 *
gume 0:1f82672b8755 6754 */
gume 0:1f82672b8755 6755 BNO055_RETURN_FUNCTION_TYPE bno055_set_gyro_unit(u8 gyro_unit_u8)
gume 0:1f82672b8755 6756 {
gume 0:1f82672b8755 6757 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6758 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 6759 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 6760 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 6761 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 6762 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 6763 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 6764 } else {
gume 0:1f82672b8755 6765 /* The write operation effective only if the operation
gume 0:1f82672b8755 6766 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 6767 current operation mode and set the config mode */
gume 0:1f82672b8755 6768 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 6769 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 6770 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 6771 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 6772 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 6773 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 6774 /* Write the gyro unit */
gume 0:1f82672b8755 6775 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 6776 (p_bno055->dev_addr,
gume 0:1f82672b8755 6777 BNO055_GYRO_UNIT_REG,
gume 0:1f82672b8755 6778 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 6779 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 6780 data_u8r =
gume 0:1f82672b8755 6781 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 6782 BNO055_GYRO_UNIT, gyro_unit_u8);
gume 0:1f82672b8755 6783 com_rslt +=
gume 0:1f82672b8755 6784 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 6785 (p_bno055->dev_addr,
gume 0:1f82672b8755 6786 BNO055_GYRO_UNIT_REG,
gume 0:1f82672b8755 6787 &data_u8r,
gume 0:1f82672b8755 6788 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 6789 }
gume 0:1f82672b8755 6790 } else {
gume 0:1f82672b8755 6791 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6792 }
gume 0:1f82672b8755 6793 } else {
gume 0:1f82672b8755 6794 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6795 }
gume 0:1f82672b8755 6796 }
gume 0:1f82672b8755 6797 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 6798 /* set the operation mode
gume 0:1f82672b8755 6799 of previous operation mode*/
gume 0:1f82672b8755 6800 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 6801 (prev_opmode_u8);
gume 0:1f82672b8755 6802 return com_rslt;
gume 0:1f82672b8755 6803 }
gume 0:1f82672b8755 6804 /*!
gume 0:1f82672b8755 6805 * @brief This API used to read the Euler unit
gume 0:1f82672b8755 6806 * from register from 0x3B bit 2
gume 0:1f82672b8755 6807 *
gume 0:1f82672b8755 6808 * @param euler_unit_u8 : The value of accel unit
gume 0:1f82672b8755 6809 *
gume 0:1f82672b8755 6810 * euler_unit_u8 | result
gume 0:1f82672b8755 6811 * -------------- | -----------
gume 0:1f82672b8755 6812 * 0x00 | BNO055_EULER_UNIT_DEG
gume 0:1f82672b8755 6813 * 0x01 | BNO055_EULER_UNIT_RAD
gume 0:1f82672b8755 6814 *
gume 0:1f82672b8755 6815 * @return results of bus communication function
gume 0:1f82672b8755 6816 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 6817 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 6818 *
gume 0:1f82672b8755 6819 *
gume 0:1f82672b8755 6820 */
gume 0:1f82672b8755 6821 BNO055_RETURN_FUNCTION_TYPE bno055_get_euler_unit(
gume 0:1f82672b8755 6822 u8 *euler_unit_u8)
gume 0:1f82672b8755 6823 {
gume 0:1f82672b8755 6824 /* Variable used to return value of
gume 0:1f82672b8755 6825 communication routine*/
gume 0:1f82672b8755 6826 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6827 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 6828 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 6829 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 6830 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 6831 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 6832 } else {
gume 0:1f82672b8755 6833 /*condition check for page, Euler unit is
gume 0:1f82672b8755 6834 available in the page zero*/
gume 0:1f82672b8755 6835 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 6836 /* Write the page zero*/
gume 0:1f82672b8755 6837 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 6838 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 6839 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 6840 /* Read the Euler unit */
gume 0:1f82672b8755 6841 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 6842 (p_bno055->dev_addr,
gume 0:1f82672b8755 6843 BNO055_EULER_UNIT_REG,
gume 0:1f82672b8755 6844 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 6845 *euler_unit_u8 =
gume 0:1f82672b8755 6846 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 6847 BNO055_EULER_UNIT);
gume 0:1f82672b8755 6848 } else {
gume 0:1f82672b8755 6849 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6850 }
gume 0:1f82672b8755 6851 }
gume 0:1f82672b8755 6852 return com_rslt;
gume 0:1f82672b8755 6853 }
gume 0:1f82672b8755 6854 /*!
gume 0:1f82672b8755 6855 * @brief This API used to write the Euler unit
gume 0:1f82672b8755 6856 * from register from 0x3B bit 2
gume 0:1f82672b8755 6857 *
gume 0:1f82672b8755 6858 * @param euler_unit_u8 : The value of Euler unit
gume 0:1f82672b8755 6859 *
gume 0:1f82672b8755 6860 * euler_unit_u8 | result
gume 0:1f82672b8755 6861 * -------------- | -----------
gume 0:1f82672b8755 6862 * 0x00 | BNO055_EULER_UNIT_DEG
gume 0:1f82672b8755 6863 * 0x01 | BNO055_EULER_UNIT_RAD
gume 0:1f82672b8755 6864 *
gume 0:1f82672b8755 6865 * @return results of bus communication function
gume 0:1f82672b8755 6866 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 6867 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 6868 *
gume 0:1f82672b8755 6869 *
gume 0:1f82672b8755 6870 */
gume 0:1f82672b8755 6871 BNO055_RETURN_FUNCTION_TYPE bno055_set_euler_unit(u8 euler_unit_u8)
gume 0:1f82672b8755 6872 {
gume 0:1f82672b8755 6873 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6874 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 6875 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 6876 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 6877 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 6878 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 6879 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 6880 } else {
gume 0:1f82672b8755 6881 /* The write operation effective only if the operation
gume 0:1f82672b8755 6882 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 6883 current operation mode and set the config mode */
gume 0:1f82672b8755 6884 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 6885 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 6886 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 6887 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 6888 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 6889 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 6890 /* Write the Euler unit*/
gume 0:1f82672b8755 6891 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 6892 (p_bno055->dev_addr,
gume 0:1f82672b8755 6893 BNO055_EULER_UNIT_REG,
gume 0:1f82672b8755 6894 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 6895 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 6896 data_u8r =
gume 0:1f82672b8755 6897 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 6898 BNO055_EULER_UNIT, euler_unit_u8);
gume 0:1f82672b8755 6899 com_rslt +=
gume 0:1f82672b8755 6900 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 6901 (p_bno055->dev_addr,
gume 0:1f82672b8755 6902 BNO055_EULER_UNIT_REG,
gume 0:1f82672b8755 6903 &data_u8r,
gume 0:1f82672b8755 6904 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 6905 }
gume 0:1f82672b8755 6906 } else {
gume 0:1f82672b8755 6907 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6908 }
gume 0:1f82672b8755 6909 } else {
gume 0:1f82672b8755 6910 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6911 }
gume 0:1f82672b8755 6912 }
gume 0:1f82672b8755 6913 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 6914 /* set the operation mode
gume 0:1f82672b8755 6915 of previous operation mode*/
gume 0:1f82672b8755 6916 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 6917 (prev_opmode_u8);
gume 0:1f82672b8755 6918 return com_rslt;
gume 0:1f82672b8755 6919 }
gume 0:1f82672b8755 6920 /*!
gume 0:1f82672b8755 6921 * @brief This API used to write the tilt unit
gume 0:1f82672b8755 6922 * from register from 0x3B bit 3
gume 0:1f82672b8755 6923 *
gume 0:1f82672b8755 6924 * @param tilt_unit_u8 : The value of tilt unit
gume 0:1f82672b8755 6925 *
gume 0:1f82672b8755 6926 * tilt_unit_u8 | result
gume 0:1f82672b8755 6927 * --------------- | ---------
gume 0:1f82672b8755 6928 * 0x00 | degrees
gume 0:1f82672b8755 6929 * 0x01 | radians
gume 0:1f82672b8755 6930 *
gume 0:1f82672b8755 6931 * @return results of bus communication function
gume 0:1f82672b8755 6932 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 6933 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 6934 *
gume 0:1f82672b8755 6935 *
gume 0:1f82672b8755 6936 */
gume 0:1f82672b8755 6937 BNO055_RETURN_FUNCTION_TYPE bno055_get_tilt_unit(
gume 0:1f82672b8755 6938 u8 *tilt_unit_u8)
gume 0:1f82672b8755 6939 {
gume 0:1f82672b8755 6940 /* Variable used to return value of
gume 0:1f82672b8755 6941 communication routine*/
gume 0:1f82672b8755 6942 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6943 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 6944 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 6945 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 6946 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 6947 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 6948 } else {
gume 0:1f82672b8755 6949 /*condition check for page, chip id is
gume 0:1f82672b8755 6950 available in the page zero*/
gume 0:1f82672b8755 6951 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 6952 /* Write the page zero*/
gume 0:1f82672b8755 6953 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 6954 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 6955 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 6956 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 6957 (p_bno055->dev_addr,
gume 0:1f82672b8755 6958 BNO055_TILT_UNIT_REG,
gume 0:1f82672b8755 6959 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 6960 *tilt_unit_u8 =
gume 0:1f82672b8755 6961 BNO055_GET_BITSLICE(data_u8r, BNO055_TILT_UNIT);
gume 0:1f82672b8755 6962 } else {
gume 0:1f82672b8755 6963 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6964 }
gume 0:1f82672b8755 6965 }
gume 0:1f82672b8755 6966 return com_rslt;
gume 0:1f82672b8755 6967 }
gume 0:1f82672b8755 6968 /*!
gume 0:1f82672b8755 6969 * @brief This API used to write the tilt unit
gume 0:1f82672b8755 6970 * from register from 0x3B bit 3
gume 0:1f82672b8755 6971 *
gume 0:1f82672b8755 6972 * @param tilt_unit_u8 : The value of tilt unit
gume 0:1f82672b8755 6973 *
gume 0:1f82672b8755 6974 * tilt_unit_u8 | result
gume 0:1f82672b8755 6975 * --------------- | ---------
gume 0:1f82672b8755 6976 * 0x00 | degrees
gume 0:1f82672b8755 6977 * 0x01 | radians
gume 0:1f82672b8755 6978 *
gume 0:1f82672b8755 6979 * @return results of bus communication function
gume 0:1f82672b8755 6980 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 6981 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 6982 *
gume 0:1f82672b8755 6983 *
gume 0:1f82672b8755 6984 *
gume 0:1f82672b8755 6985 * \return Communication results
gume 0:1f82672b8755 6986 *
gume 0:1f82672b8755 6987 *
gume 0:1f82672b8755 6988 */
gume 0:1f82672b8755 6989 BNO055_RETURN_FUNCTION_TYPE bno055_set_tilt_unit(u8 tilt_unit_u8)
gume 0:1f82672b8755 6990 {
gume 0:1f82672b8755 6991 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 6992 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 6993 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 6994 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 6995 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 6996 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 6997 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 6998 } else {
gume 0:1f82672b8755 6999 /* The write operation effective only if the operation
gume 0:1f82672b8755 7000 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 7001 current operation mode and set the config mode */
gume 0:1f82672b8755 7002 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 7003 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 7004 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 7005 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 7006 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 7007 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 7008 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 7009 (p_bno055->dev_addr,
gume 0:1f82672b8755 7010 BNO055_TILT_UNIT_REG,
gume 0:1f82672b8755 7011 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 7012 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 7013 data_u8r =
gume 0:1f82672b8755 7014 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 7015 BNO055_TILT_UNIT, tilt_unit_u8);
gume 0:1f82672b8755 7016 com_rslt +=
gume 0:1f82672b8755 7017 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 7018 (p_bno055->dev_addr,
gume 0:1f82672b8755 7019 BNO055_TILT_UNIT_REG,
gume 0:1f82672b8755 7020 &data_u8r,
gume 0:1f82672b8755 7021 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 7022 }
gume 0:1f82672b8755 7023 } else {
gume 0:1f82672b8755 7024 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7025 }
gume 0:1f82672b8755 7026 } else {
gume 0:1f82672b8755 7027 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7028 }
gume 0:1f82672b8755 7029 }
gume 0:1f82672b8755 7030 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 7031 /* set the operation mode
gume 0:1f82672b8755 7032 of previous operation mode*/
gume 0:1f82672b8755 7033 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 7034 (prev_opmode_u8);
gume 0:1f82672b8755 7035 return com_rslt;
gume 0:1f82672b8755 7036 }
gume 0:1f82672b8755 7037 /*!
gume 0:1f82672b8755 7038 * @brief This API used to read the temperature unit
gume 0:1f82672b8755 7039 * from register from 0x3B bit 4
gume 0:1f82672b8755 7040 *
gume 0:1f82672b8755 7041 * @param temp_unit_u8 : The value of temperature unit
gume 0:1f82672b8755 7042 *
gume 0:1f82672b8755 7043 * temp_unit_u8 | result
gume 0:1f82672b8755 7044 * ----------- | --------------
gume 0:1f82672b8755 7045 * 0x00 | BNO055_TEMP_UNIT_CELSIUS
gume 0:1f82672b8755 7046 * 0x01 | BNO055_TEMP_UNIT_FAHRENHEIT
gume 0:1f82672b8755 7047 *
gume 0:1f82672b8755 7048 * @return results of bus communication function
gume 0:1f82672b8755 7049 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 7050 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 7051 *
gume 0:1f82672b8755 7052 */
gume 0:1f82672b8755 7053 BNO055_RETURN_FUNCTION_TYPE bno055_get_temp_unit(
gume 0:1f82672b8755 7054 u8 *temp_unit_u8)
gume 0:1f82672b8755 7055 {
gume 0:1f82672b8755 7056 /* Variable used to return value of
gume 0:1f82672b8755 7057 communication routine*/
gume 0:1f82672b8755 7058 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7059 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 7060 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 7061 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 7062 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 7063 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 7064 } else {
gume 0:1f82672b8755 7065 /*condition check for page, temperature unit is
gume 0:1f82672b8755 7066 available in the page zero*/
gume 0:1f82672b8755 7067 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 7068 /* Write the page zero*/
gume 0:1f82672b8755 7069 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 7070 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 7071 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 7072 /* Read the temperature unit */
gume 0:1f82672b8755 7073 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 7074 (p_bno055->dev_addr,
gume 0:1f82672b8755 7075 BNO055_TEMP_UNIT_REG,
gume 0:1f82672b8755 7076 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 7077 *temp_unit_u8 =
gume 0:1f82672b8755 7078 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 7079 BNO055_TEMP_UNIT);
gume 0:1f82672b8755 7080 } else {
gume 0:1f82672b8755 7081 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7082 }
gume 0:1f82672b8755 7083 }
gume 0:1f82672b8755 7084 return com_rslt;
gume 0:1f82672b8755 7085 }
gume 0:1f82672b8755 7086 /*!
gume 0:1f82672b8755 7087 * @brief This API used to write the temperature unit
gume 0:1f82672b8755 7088 * from register from 0x3B bit 4
gume 0:1f82672b8755 7089 *
gume 0:1f82672b8755 7090 * @param temp_unit_u8 : The value of temperature unit
gume 0:1f82672b8755 7091 *
gume 0:1f82672b8755 7092 * temp_unit_u8 | result
gume 0:1f82672b8755 7093 * ----------- | --------------
gume 0:1f82672b8755 7094 * 0x00 | BNO055_TEMP_UNIT_CELSIUS
gume 0:1f82672b8755 7095 * 0x01 | BNO055_TEMP_UNIT_FAHRENHEIT
gume 0:1f82672b8755 7096 *
gume 0:1f82672b8755 7097 * @return results of bus communication function
gume 0:1f82672b8755 7098 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 7099 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 7100 *
gume 0:1f82672b8755 7101 *
gume 0:1f82672b8755 7102 */
gume 0:1f82672b8755 7103 BNO055_RETURN_FUNCTION_TYPE bno055_set_temp_unit(
gume 0:1f82672b8755 7104 u8 temp_unit_u8)
gume 0:1f82672b8755 7105 {
gume 0:1f82672b8755 7106 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7107 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 7108 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 7109 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 7110 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 7111 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 7112 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 7113 } else {
gume 0:1f82672b8755 7114 /* The write operation effective only if the operation
gume 0:1f82672b8755 7115 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 7116 current operation mode and set the config mode */
gume 0:1f82672b8755 7117 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 7118 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 7119 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 7120 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 7121 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 7122 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 7123 /* Write the temperature unit */
gume 0:1f82672b8755 7124 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 7125 (p_bno055->dev_addr,
gume 0:1f82672b8755 7126 BNO055_TEMP_UNIT_REG,
gume 0:1f82672b8755 7127 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 7128 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 7129 data_u8r =
gume 0:1f82672b8755 7130 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 7131 BNO055_TEMP_UNIT,
gume 0:1f82672b8755 7132 temp_unit_u8);
gume 0:1f82672b8755 7133 com_rslt +=
gume 0:1f82672b8755 7134 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 7135 (p_bno055->dev_addr,
gume 0:1f82672b8755 7136 BNO055_TEMP_UNIT_REG,
gume 0:1f82672b8755 7137 &data_u8r,
gume 0:1f82672b8755 7138 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 7139 }
gume 0:1f82672b8755 7140 } else {
gume 0:1f82672b8755 7141 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7142 }
gume 0:1f82672b8755 7143 } else {
gume 0:1f82672b8755 7144 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7145 }
gume 0:1f82672b8755 7146 }
gume 0:1f82672b8755 7147 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 7148 /* set the operation mode
gume 0:1f82672b8755 7149 of previous operation mode*/
gume 0:1f82672b8755 7150 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 7151 (prev_opmode_u8);
gume 0:1f82672b8755 7152 return com_rslt;
gume 0:1f82672b8755 7153 }
gume 0:1f82672b8755 7154 /*!
gume 0:1f82672b8755 7155 * @brief This API used to read the current selected orientation mode
gume 0:1f82672b8755 7156 * from register from 0x3B bit 7
gume 0:1f82672b8755 7157 *
gume 0:1f82672b8755 7158 * @param data_output_format_u8 : The value of data output format
gume 0:1f82672b8755 7159 *
gume 0:1f82672b8755 7160 * data_output_format_u8 | result
gume 0:1f82672b8755 7161 * -------------------- | --------
gume 0:1f82672b8755 7162 * 0x00 | Windows
gume 0:1f82672b8755 7163 * 0x01 | Android
gume 0:1f82672b8755 7164 *
gume 0:1f82672b8755 7165 * @return results of bus communication function
gume 0:1f82672b8755 7166 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 7167 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 7168 *
gume 0:1f82672b8755 7169 */
gume 0:1f82672b8755 7170 BNO055_RETURN_FUNCTION_TYPE bno055_get_data_output_format(
gume 0:1f82672b8755 7171 u8 *data_output_format_u8)
gume 0:1f82672b8755 7172 {
gume 0:1f82672b8755 7173 /* Variable used to return value of
gume 0:1f82672b8755 7174 communication routine*/
gume 0:1f82672b8755 7175 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7176 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 7177 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 7178 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 7179 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 7180 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 7181 } else {
gume 0:1f82672b8755 7182 /*condition check for page, data output format is
gume 0:1f82672b8755 7183 available in the page zero*/
gume 0:1f82672b8755 7184 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 7185 /* Write the page zero*/
gume 0:1f82672b8755 7186 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 7187 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 7188 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 7189 /* Read the data output format */
gume 0:1f82672b8755 7190 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 7191 (p_bno055->dev_addr,
gume 0:1f82672b8755 7192 BNO055_DATA_OUTPUT_FORMAT_REG,
gume 0:1f82672b8755 7193 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 7194 *data_output_format_u8 =
gume 0:1f82672b8755 7195 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 7196 BNO055_DATA_OUTPUT_FORMAT);
gume 0:1f82672b8755 7197 } else {
gume 0:1f82672b8755 7198 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7199 }
gume 0:1f82672b8755 7200 }
gume 0:1f82672b8755 7201 return com_rslt;
gume 0:1f82672b8755 7202 }
gume 0:1f82672b8755 7203 /*!
gume 0:1f82672b8755 7204 * @brief This API used to write the current selected orientation mode
gume 0:1f82672b8755 7205 * from register from 0x3B bit 7
gume 0:1f82672b8755 7206 *
gume 0:1f82672b8755 7207 * @param data_output_format_u8 : The value of data output format
gume 0:1f82672b8755 7208 *
gume 0:1f82672b8755 7209 * data_output_format_u8 | result
gume 0:1f82672b8755 7210 * -------------------- | --------
gume 0:1f82672b8755 7211 * 0x00 | Windows
gume 0:1f82672b8755 7212 * 0x01 | Android
gume 0:1f82672b8755 7213 *
gume 0:1f82672b8755 7214 * @return results of bus communication function
gume 0:1f82672b8755 7215 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 7216 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 7217 *
gume 0:1f82672b8755 7218 *
gume 0:1f82672b8755 7219 */
gume 0:1f82672b8755 7220 BNO055_RETURN_FUNCTION_TYPE bno055_set_data_output_format(
gume 0:1f82672b8755 7221 u8 data_output_format_u8)
gume 0:1f82672b8755 7222 {
gume 0:1f82672b8755 7223 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7224 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 7225 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 7226 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 7227 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 7228 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 7229 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 7230 } else {
gume 0:1f82672b8755 7231 /* The write operation effective only if the operation
gume 0:1f82672b8755 7232 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 7233 current operation mode and set the config mode */
gume 0:1f82672b8755 7234 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 7235 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 7236 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 7237 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 7238 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 7239 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 7240 /* Write the data output format */
gume 0:1f82672b8755 7241 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 7242 (p_bno055->dev_addr,
gume 0:1f82672b8755 7243 BNO055_DATA_OUTPUT_FORMAT_REG,
gume 0:1f82672b8755 7244 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 7245 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 7246 data_u8r =
gume 0:1f82672b8755 7247 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 7248 BNO055_DATA_OUTPUT_FORMAT,
gume 0:1f82672b8755 7249 data_output_format_u8);
gume 0:1f82672b8755 7250 com_rslt +=
gume 0:1f82672b8755 7251 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 7252 (p_bno055->dev_addr,
gume 0:1f82672b8755 7253 BNO055_DATA_OUTPUT_FORMAT_REG,
gume 0:1f82672b8755 7254 &data_u8r,
gume 0:1f82672b8755 7255 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 7256 }
gume 0:1f82672b8755 7257 } else {
gume 0:1f82672b8755 7258 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7259 }
gume 0:1f82672b8755 7260 } else {
gume 0:1f82672b8755 7261 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7262 }
gume 0:1f82672b8755 7263 }
gume 0:1f82672b8755 7264 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 7265 /* set the operation mode
gume 0:1f82672b8755 7266 of previous operation mode*/
gume 0:1f82672b8755 7267 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 7268 (prev_opmode_u8);
gume 0:1f82672b8755 7269 return com_rslt;
gume 0:1f82672b8755 7270 }
gume 0:1f82672b8755 7271 /*! @brief This API used to read the operation mode
gume 0:1f82672b8755 7272 * from register from 0x3D bit 0 to 3
gume 0:1f82672b8755 7273 *
gume 0:1f82672b8755 7274 * @param operation_mode_u8 : The value of operation mode
gume 0:1f82672b8755 7275 *
gume 0:1f82672b8755 7276 * operation_mode_u8 | result | comments
gume 0:1f82672b8755 7277 * ----------|----------------------------|----------------------------
gume 0:1f82672b8755 7278 * 0x00 | BNO055_OPERATION_MODE_CONFIG | Configuration mode
gume 0:1f82672b8755 7279 * 0x01 | BNO055_OPERATION_MODE_ACCONLY | Reads accel data alone
gume 0:1f82672b8755 7280 * 0x02 | BNO055_OPERATION_MODE_MAGONLY | Reads mag data alone
gume 0:1f82672b8755 7281 * 0x03 | BNO055_OPERATION_MODE_GYRONLY | Reads gyro data alone
gume 0:1f82672b8755 7282 * 0x04 | BNO055_OPERATION_MODE_ACCMAG | Reads accel and mag data
gume 0:1f82672b8755 7283 * 0x05 | BNO055_OPERATION_MODE_ACCGYRO | Reads accel and gyro data
gume 0:1f82672b8755 7284 * 0x06 | BNO055_OPERATION_MODE_MAGGYRO | Reads accel and mag data
gume 0:1f82672b8755 7285 * 0x07 | OPERATION_MODE_ANY_MOTION | Reads accel mag and gyro data
gume 0:1f82672b8755 7286 * 0x08 | BNO055_OPERATION_MODE_IMUPLUS | Inertial measurement unit
gume 0:1f82672b8755 7287 * - | - | Reads accel,gyro and fusion data
gume 0:1f82672b8755 7288 * 0x09 | BNO055_OPERATION_MODE_COMPASS | Reads accel, mag data
gume 0:1f82672b8755 7289 * - | - | and fusion data
gume 0:1f82672b8755 7290 * 0x0A | BNO055_OPERATION_MODE_M4G | Reads accel, mag data
gume 0:1f82672b8755 7291 * - | - | and fusion data
gume 0:1f82672b8755 7292 * 0x0B | BNO055_OPERATION_MODE_NDOF_FMC_OFF| Nine degrees of freedom with
gume 0:1f82672b8755 7293 * - | - | fast magnetic calibration
gume 0:1f82672b8755 7294 * - | - | Reads accel,mag, gyro
gume 0:1f82672b8755 7295 * - | - | and fusion data
gume 0:1f82672b8755 7296 * 0x0C | BNO055_OPERATION_MODE_NDOF | Nine degrees of freedom
gume 0:1f82672b8755 7297 * - | - | Reads accel,mag, gyro
gume 0:1f82672b8755 7298 * - | - | and fusion data
gume 0:1f82672b8755 7299 *
gume 0:1f82672b8755 7300 * @return results of bus communication function
gume 0:1f82672b8755 7301 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 7302 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 7303 *
gume 0:1f82672b8755 7304 * @note In the config mode, all sensor and fusion data
gume 0:1f82672b8755 7305 * becomes zero and it is mainly derived
gume 0:1f82672b8755 7306 * to configure the various settings of the BNO
gume 0:1f82672b8755 7307 *
gume 0:1f82672b8755 7308 */
gume 0:1f82672b8755 7309 BNO055_RETURN_FUNCTION_TYPE bno055_get_operation_mode(
gume 0:1f82672b8755 7310 u8 *operation_mode_u8)
gume 0:1f82672b8755 7311 {
gume 0:1f82672b8755 7312 /* Variable used to return value of
gume 0:1f82672b8755 7313 communication routine*/
gume 0:1f82672b8755 7314 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7315 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 7316 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 7317 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 7318 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 7319 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 7320 } else {
gume 0:1f82672b8755 7321 /*condition check for page, operation mode is
gume 0:1f82672b8755 7322 available in the page zero*/
gume 0:1f82672b8755 7323 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 7324 /* Write the page zero*/
gume 0:1f82672b8755 7325 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 7326 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 7327 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 7328 /* Read the value of operation mode*/
gume 0:1f82672b8755 7329 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 7330 (p_bno055->dev_addr,
gume 0:1f82672b8755 7331 BNO055_OPERATION_MODE_REG,
gume 0:1f82672b8755 7332 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 7333 *operation_mode_u8 =
gume 0:1f82672b8755 7334 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 7335 BNO055_OPERATION_MODE);
gume 0:1f82672b8755 7336 } else {
gume 0:1f82672b8755 7337 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7338 }
gume 0:1f82672b8755 7339 }
gume 0:1f82672b8755 7340 return com_rslt;
gume 0:1f82672b8755 7341 }
gume 0:1f82672b8755 7342 /*! @brief This API used to write the operation mode
gume 0:1f82672b8755 7343 * from register from 0x3D bit 0 to 3
gume 0:1f82672b8755 7344 *
gume 0:1f82672b8755 7345 * @param operation_mode_u8 : The value of operation mode
gume 0:1f82672b8755 7346 *
gume 0:1f82672b8755 7347 * operation_mode_u8 | result | comments
gume 0:1f82672b8755 7348 * ---------|-----------------------------------|--------------------------
gume 0:1f82672b8755 7349 * 0x00 | BNO055_OPERATION_MODE_CONFIG | Configuration mode
gume 0:1f82672b8755 7350 * 0x01 | BNO055_OPERATION_MODE_ACCONLY | Reads accel data alone
gume 0:1f82672b8755 7351 * 0x02 | BNO055_OPERATION_MODE_MAGONLY | Reads mag data alone
gume 0:1f82672b8755 7352 * 0x03 | BNO055_OPERATION_MODE_GYRONLY | Reads gyro data alone
gume 0:1f82672b8755 7353 * 0x04 | BNO055_OPERATION_MODE_ACCMAG | Reads accel and mag data
gume 0:1f82672b8755 7354 * 0x05 | BNO055_OPERATION_MODE_ACCGYRO | Reads accel and gyro data
gume 0:1f82672b8755 7355 * 0x06 | BNO055_OPERATION_MODE_MAGGYRO | Reads accel and mag data
gume 0:1f82672b8755 7356 * 0x07 | OPERATION_MODE_ANY_MOTION | Reads accel mag and
gume 0:1f82672b8755 7357 * | - | gyro data
gume 0:1f82672b8755 7358 * 0x08 | BNO055_OPERATION_MODE_IMUPLUS | Inertial measurement unit
gume 0:1f82672b8755 7359 * - | | Reads accel,gyro and
gume 0:1f82672b8755 7360 * | - | fusion data
gume 0:1f82672b8755 7361 * 0x09 | BNO055_OPERATION_MODE_COMPASS | Reads accel, mag data
gume 0:1f82672b8755 7362 * - | - | and fusion data
gume 0:1f82672b8755 7363 * 0x0A | BNO055_OPERATION_MODE_M4G | Reads accel, mag data
gume 0:1f82672b8755 7364 * - | - | and fusion data
gume 0:1f82672b8755 7365 * 0x0B | BNO055_OPERATION_MODE_NDOF_FMC_OFF| Nine degrees of freedom with
gume 0:1f82672b8755 7366 * - | - | fast magnetic calibration
gume 0:1f82672b8755 7367 * - | - | Reads accel,mag, gyro
gume 0:1f82672b8755 7368 * - | - | and fusion data
gume 0:1f82672b8755 7369 * 0x0C | BNO055_OPERATION_MODE_NDOF | Nine degrees of freedom
gume 0:1f82672b8755 7370 * - | - | Reads accel,mag, gyro
gume 0:1f82672b8755 7371 * - | - | and fusion data
gume 0:1f82672b8755 7372 *
gume 0:1f82672b8755 7373 * @return results of bus communication function
gume 0:1f82672b8755 7374 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 7375 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 7376 *
gume 0:1f82672b8755 7377 * @note In the config mode, all sensor and fusion data
gume 0:1f82672b8755 7378 * becomes zero and it is mainly derived
gume 0:1f82672b8755 7379 * to configure the various settings of the BNO
gume 0:1f82672b8755 7380 *
gume 0:1f82672b8755 7381 */
gume 0:1f82672b8755 7382 BNO055_RETURN_FUNCTION_TYPE bno055_set_operation_mode(u8 operation_mode_u8)
gume 0:1f82672b8755 7383 {
gume 0:1f82672b8755 7384 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7385 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 7386 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 7387 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 7388 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 7389 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 7390 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 7391 } else {
gume 0:1f82672b8755 7392 /* The write operation effective only if the operation
gume 0:1f82672b8755 7393 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 7394 current operation mode and set the config mode */
gume 0:1f82672b8755 7395 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 7396 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 7397 /* If the previous operation mode is config it is
gume 0:1f82672b8755 7398 directly write the operation mode */
gume 0:1f82672b8755 7399 if (prev_opmode_u8 == BNO055_OPERATION_MODE_CONFIG) {
gume 0:1f82672b8755 7400 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 7401 (p_bno055->dev_addr,
gume 0:1f82672b8755 7402 BNO055_OPERATION_MODE_REG,
gume 0:1f82672b8755 7403 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 7404 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 7405 data_u8r =
gume 0:1f82672b8755 7406 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 7407 BNO055_OPERATION_MODE,
gume 0:1f82672b8755 7408 operation_mode_u8);
gume 0:1f82672b8755 7409 com_rslt +=
gume 0:1f82672b8755 7410 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 7411 (p_bno055->dev_addr,
gume 0:1f82672b8755 7412 BNO055_OPERATION_MODE_REG,
gume 0:1f82672b8755 7413 &data_u8r,
gume 0:1f82672b8755 7414 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 7415 /* Config mode to other
gume 0:1f82672b8755 7416 operation mode switching
gume 0:1f82672b8755 7417 required delay of 600ms*/
gume 0:1f82672b8755 7418 p_bno055->delay_msec(
gume 0:1f82672b8755 7419 BNO055_MODE_SWITCHING_DELAY);
gume 0:1f82672b8755 7420 }
gume 0:1f82672b8755 7421 } else {
gume 0:1f82672b8755 7422 /* If the previous operation
gume 0:1f82672b8755 7423 mode is not config it is
gume 0:1f82672b8755 7424 write the config mode */
gume 0:1f82672b8755 7425 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 7426 (p_bno055->dev_addr,
gume 0:1f82672b8755 7427 BNO055_OPERATION_MODE_REG,
gume 0:1f82672b8755 7428 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 7429 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 7430 data_u8r =
gume 0:1f82672b8755 7431 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 7432 BNO055_OPERATION_MODE,
gume 0:1f82672b8755 7433 BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 7434 com_rslt += bno055_write_register(
gume 0:1f82672b8755 7435 BNO055_OPERATION_MODE_REG,
gume 0:1f82672b8755 7436 &data_u8r,
gume 0:1f82672b8755 7437 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 7438 /* other mode to config mode switching
gume 0:1f82672b8755 7439 required delay of 20ms*/
gume 0:1f82672b8755 7440 p_bno055->delay_msec(
gume 0:1f82672b8755 7441 BNO055_CONFIG_MODE_SWITCHING_DELAY);
gume 0:1f82672b8755 7442 }
gume 0:1f82672b8755 7443 /* Write the operation mode */
gume 0:1f82672b8755 7444 if (operation_mode_u8 !=
gume 0:1f82672b8755 7445 BNO055_OPERATION_MODE_CONFIG) {
gume 0:1f82672b8755 7446 com_rslt =
gume 0:1f82672b8755 7447 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 7448 (p_bno055->dev_addr,
gume 0:1f82672b8755 7449 BNO055_OPERATION_MODE_REG,
gume 0:1f82672b8755 7450 &data_u8r,
gume 0:1f82672b8755 7451 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 7452 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 7453 data_u8r = BNO055_SET_BITSLICE
gume 0:1f82672b8755 7454 (data_u8r,
gume 0:1f82672b8755 7455 BNO055_OPERATION_MODE,
gume 0:1f82672b8755 7456 operation_mode_u8);
gume 0:1f82672b8755 7457 com_rslt +=
gume 0:1f82672b8755 7458 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 7459 (p_bno055->dev_addr,
gume 0:1f82672b8755 7460 BNO055_OPERATION_MODE_REG,
gume 0:1f82672b8755 7461 &data_u8r,
gume 0:1f82672b8755 7462 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 7463 /* Config mode to other
gume 0:1f82672b8755 7464 operation mode switching
gume 0:1f82672b8755 7465 required delay of 600ms*/
gume 0:1f82672b8755 7466 p_bno055->delay_msec(
gume 0:1f82672b8755 7467 BNO055_MODE_SWITCHING_DELAY);
gume 0:1f82672b8755 7468 }
gume 0:1f82672b8755 7469 }
gume 0:1f82672b8755 7470 }
gume 0:1f82672b8755 7471 } else {
gume 0:1f82672b8755 7472 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7473 }
gume 0:1f82672b8755 7474 }
gume 0:1f82672b8755 7475 return com_rslt;
gume 0:1f82672b8755 7476 }
gume 0:1f82672b8755 7477 /*! @brief This API used to read the power mode
gume 0:1f82672b8755 7478 * from register from 0x3E bit 0 to 1
gume 0:1f82672b8755 7479 *
gume 0:1f82672b8755 7480 * @param power_mode_u8 : The value of power mode
gume 0:1f82672b8755 7481 *
gume 0:1f82672b8755 7482 * power_mode_u8| result | comments
gume 0:1f82672b8755 7483 * ---------|---------------------------|-------------------------------------
gume 0:1f82672b8755 7484 * 0x00 |BNO055_POWER_MODE_NORMAL | In the NORMAL mode the register
gume 0:1f82672b8755 7485 * - | - | map and the internal peripherals
gume 0:1f82672b8755 7486 * - | - | of the MCU are always
gume 0:1f82672b8755 7487 * - | - | operative in this mode
gume 0:1f82672b8755 7488 * 0x01 |BNO055_POWER_MODE_LOWPOWER | This is first level of power
gume 0:1f82672b8755 7489 * | - | saving mode
gume 0:1f82672b8755 7490 * 0x02 |BNO055_POWER_MODE_SUSPEND | In suspend mode the system is
gume 0:1f82672b8755 7491 * - | - | paused and all the sensors and
gume 0:1f82672b8755 7492 * - | - | the micro controller are
gume 0:1f82672b8755 7493 * - | - | put into sleep mode.
gume 0:1f82672b8755 7494 *
gume 0:1f82672b8755 7495 * @return results of bus communication function
gume 0:1f82672b8755 7496 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 7497 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 7498 *
gume 0:1f82672b8755 7499 * @note For detailed about LOWPOWER mode
gume 0:1f82672b8755 7500 * refer data sheet 3.4.2
gume 0:1f82672b8755 7501 *
gume 0:1f82672b8755 7502 */
gume 0:1f82672b8755 7503 BNO055_RETURN_FUNCTION_TYPE bno055_get_power_mode(
gume 0:1f82672b8755 7504 u8 *power_mode_u8)
gume 0:1f82672b8755 7505 {
gume 0:1f82672b8755 7506 /* Variable used to return value of
gume 0:1f82672b8755 7507 communication routine*/
gume 0:1f82672b8755 7508 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7509 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 7510 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 7511 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 7512 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 7513 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 7514 } else {
gume 0:1f82672b8755 7515 /*condition check for page, power mode is
gume 0:1f82672b8755 7516 available in the page zero*/
gume 0:1f82672b8755 7517 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 7518 /* Write the page zero*/
gume 0:1f82672b8755 7519 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 7520 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 7521 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 7522 /* Read the value of power mode */
gume 0:1f82672b8755 7523 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 7524 (p_bno055->dev_addr,
gume 0:1f82672b8755 7525 BNO055_POWER_MODE_REG,
gume 0:1f82672b8755 7526 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 7527 *power_mode_u8 =
gume 0:1f82672b8755 7528 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 7529 BNO055_POWER_MODE);
gume 0:1f82672b8755 7530 } else {
gume 0:1f82672b8755 7531 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7532 }
gume 0:1f82672b8755 7533 }
gume 0:1f82672b8755 7534 return com_rslt;
gume 0:1f82672b8755 7535 }
gume 0:1f82672b8755 7536 /*! @brief This API used to write the power mode
gume 0:1f82672b8755 7537 * from register from 0x3E bit 0 to 1
gume 0:1f82672b8755 7538 *
gume 0:1f82672b8755 7539 * @param power_mode_u8 : The value of power mode
gume 0:1f82672b8755 7540 *
gume 0:1f82672b8755 7541 *
gume 0:1f82672b8755 7542 * power_mode_u8| result | comments
gume 0:1f82672b8755 7543 * -------|----------------------------|---------------------------------
gume 0:1f82672b8755 7544 * 0x00 | BNO055_POWER_MODE_NORMAL | In the NORMAL mode the register
gume 0:1f82672b8755 7545 * - | - | map and the internal peripherals
gume 0:1f82672b8755 7546 * - | - | of the MCU are always
gume 0:1f82672b8755 7547 * - | - | operative in this mode
gume 0:1f82672b8755 7548 * 0x01 | BNO055_POWER_MODE_LOWPOWER | This is first level of power
gume 0:1f82672b8755 7549 * | - | saving mode
gume 0:1f82672b8755 7550 * 0x02 | BNO055_POWER_MODE_SUSPEND | In suspend mode the system is
gume 0:1f82672b8755 7551 * - | - | paused and all the sensors and
gume 0:1f82672b8755 7552 * - | - | the micro controller are
gume 0:1f82672b8755 7553 * - | - | put into sleep mode.
gume 0:1f82672b8755 7554 *
gume 0:1f82672b8755 7555 * @return results of bus communication function
gume 0:1f82672b8755 7556 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 7557 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 7558 *
gume 0:1f82672b8755 7559 * @note For detailed about LOWPOWER mode
gume 0:1f82672b8755 7560 * refer data sheet 3.4.2
gume 0:1f82672b8755 7561 *
gume 0:1f82672b8755 7562 */
gume 0:1f82672b8755 7563 BNO055_RETURN_FUNCTION_TYPE bno055_set_power_mode(u8 power_mode_u8)
gume 0:1f82672b8755 7564 {
gume 0:1f82672b8755 7565 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7566 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 7567 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 7568 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 7569 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 7570 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 7571 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 7572 } else {
gume 0:1f82672b8755 7573 /* The write operation effective only if the operation
gume 0:1f82672b8755 7574 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 7575 current operation mode and set the config mode */
gume 0:1f82672b8755 7576 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 7577 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 7578 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 7579 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 7580 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 7581 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 7582 /* Write the value of power mode */
gume 0:1f82672b8755 7583 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 7584 (p_bno055->dev_addr,
gume 0:1f82672b8755 7585 BNO055_POWER_MODE_REG,
gume 0:1f82672b8755 7586 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 7587 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 7588 data_u8r =
gume 0:1f82672b8755 7589 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 7590 BNO055_POWER_MODE, power_mode_u8);
gume 0:1f82672b8755 7591 com_rslt +=
gume 0:1f82672b8755 7592 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 7593 (p_bno055->dev_addr,
gume 0:1f82672b8755 7594 BNO055_POWER_MODE_REG,
gume 0:1f82672b8755 7595 &data_u8r,
gume 0:1f82672b8755 7596 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 7597 }
gume 0:1f82672b8755 7598 } else {
gume 0:1f82672b8755 7599 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7600 }
gume 0:1f82672b8755 7601 } else {
gume 0:1f82672b8755 7602 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7603 }
gume 0:1f82672b8755 7604 }
gume 0:1f82672b8755 7605 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 7606 /* set the operation mode
gume 0:1f82672b8755 7607 of previous operation mode*/
gume 0:1f82672b8755 7608 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 7609 (prev_opmode_u8);
gume 0:1f82672b8755 7610 return com_rslt;
gume 0:1f82672b8755 7611 }
gume 0:1f82672b8755 7612 /*!
gume 0:1f82672b8755 7613 * @brief This API used to read the reset interrupt
gume 0:1f82672b8755 7614 * from register from 0x3F bit 6
gume 0:1f82672b8755 7615 * It resets all the interrupt bit and interrupt output
gume 0:1f82672b8755 7616 *
gume 0:1f82672b8755 7617 * @param intr_rst_u8 : The value of reset interrupt
gume 0:1f82672b8755 7618 *
gume 0:1f82672b8755 7619 * intr_rst_u8 | result
gume 0:1f82672b8755 7620 * ------------ |----------
gume 0:1f82672b8755 7621 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 7622 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 7623 *
gume 0:1f82672b8755 7624 * @return results of bus communication function
gume 0:1f82672b8755 7625 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 7626 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 7627 *
gume 0:1f82672b8755 7628 */
gume 0:1f82672b8755 7629 BNO055_RETURN_FUNCTION_TYPE bno055_get_intr_rst(
gume 0:1f82672b8755 7630 u8 *intr_rst_u8)
gume 0:1f82672b8755 7631 {
gume 0:1f82672b8755 7632 /* Variable used to return value of
gume 0:1f82672b8755 7633 communication routine*/
gume 0:1f82672b8755 7634 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7635 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 7636 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 7637 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 7638 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 7639 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 7640 } else {
gume 0:1f82672b8755 7641 /*condition check for page, reset interrupt is
gume 0:1f82672b8755 7642 available in the page zero*/
gume 0:1f82672b8755 7643 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 7644 /* Write the page zero*/
gume 0:1f82672b8755 7645 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 7646 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 7647 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 7648 /* Read the value of reset interrupt*/
gume 0:1f82672b8755 7649 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 7650 (p_bno055->dev_addr,
gume 0:1f82672b8755 7651 BNO055_INTR_RST_REG,
gume 0:1f82672b8755 7652 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 7653 *intr_rst_u8 =
gume 0:1f82672b8755 7654 BNO055_GET_BITSLICE(data_u8r, BNO055_INTR_RST);
gume 0:1f82672b8755 7655 } else {
gume 0:1f82672b8755 7656 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7657 }
gume 0:1f82672b8755 7658 }
gume 0:1f82672b8755 7659 return com_rslt;
gume 0:1f82672b8755 7660 }
gume 0:1f82672b8755 7661 /*!
gume 0:1f82672b8755 7662 * @brief This API used to write the reset interrupt
gume 0:1f82672b8755 7663 * from register from 0x3F bit 6
gume 0:1f82672b8755 7664 * It resets all the interrupt bit and interrupt output
gume 0:1f82672b8755 7665 *
gume 0:1f82672b8755 7666 * @param intr_rst_u8 : The value of reset interrupt
gume 0:1f82672b8755 7667 *
gume 0:1f82672b8755 7668 * intr_rst_u8 | result
gume 0:1f82672b8755 7669 * -------------- |----------
gume 0:1f82672b8755 7670 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 7671 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 7672 *
gume 0:1f82672b8755 7673 * @return results of bus communication function
gume 0:1f82672b8755 7674 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 7675 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 7676 *
gume 0:1f82672b8755 7677 */
gume 0:1f82672b8755 7678 BNO055_RETURN_FUNCTION_TYPE bno055_set_intr_rst(u8 intr_rst_u8)
gume 0:1f82672b8755 7679 {
gume 0:1f82672b8755 7680 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7681 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 7682 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 7683 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 7684 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 7685 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 7686 } else {
gume 0:1f82672b8755 7687 /*condition check for page, reset interrupt
gume 0:1f82672b8755 7688 available in the page zero*/
gume 0:1f82672b8755 7689 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 7690 /* Write the page zero*/
gume 0:1f82672b8755 7691 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 7692 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 7693 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 7694 /* Write the value of reset interrupt */
gume 0:1f82672b8755 7695 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 7696 (p_bno055->dev_addr,
gume 0:1f82672b8755 7697 BNO055_INTR_RST_REG,
gume 0:1f82672b8755 7698 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 7699 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 7700 data_u8r =
gume 0:1f82672b8755 7701 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 7702 BNO055_INTR_RST, intr_rst_u8);
gume 0:1f82672b8755 7703 com_rslt +=
gume 0:1f82672b8755 7704 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 7705 (p_bno055->dev_addr,
gume 0:1f82672b8755 7706 BNO055_INTR_RST_REG,
gume 0:1f82672b8755 7707 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 7708 }
gume 0:1f82672b8755 7709 } else {
gume 0:1f82672b8755 7710 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7711 }
gume 0:1f82672b8755 7712 }
gume 0:1f82672b8755 7713 return com_rslt;
gume 0:1f82672b8755 7714 }
gume 0:1f82672b8755 7715 /*!
gume 0:1f82672b8755 7716 * @brief This API used to read the clk source
gume 0:1f82672b8755 7717 * from register from 0x3F bit 7
gume 0:1f82672b8755 7718 *
gume 0:1f82672b8755 7719 * @param clk_src_u8 : The value of clk source
gume 0:1f82672b8755 7720 *
gume 0:1f82672b8755 7721 * clk_src_u8 | result
gume 0:1f82672b8755 7722 * -------------- |----------
gume 0:1f82672b8755 7723 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 7724 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 7725 *
gume 0:1f82672b8755 7726 * @return results of bus communication function
gume 0:1f82672b8755 7727 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 7728 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 7729 *
gume 0:1f82672b8755 7730 */
gume 0:1f82672b8755 7731 BNO055_RETURN_FUNCTION_TYPE bno055_get_clk_src(
gume 0:1f82672b8755 7732 u8 *clk_src_u8)
gume 0:1f82672b8755 7733 {
gume 0:1f82672b8755 7734 /* Variable used to return value of
gume 0:1f82672b8755 7735 communication routine*/
gume 0:1f82672b8755 7736 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7737 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 7738 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 7739 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 7740 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 7741 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 7742 } else {
gume 0:1f82672b8755 7743 /*condition check for page, clk source is
gume 0:1f82672b8755 7744 available in the page zero*/
gume 0:1f82672b8755 7745 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 7746 /* Write the page zero*/
gume 0:1f82672b8755 7747 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 7748 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 7749 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 7750 /* Read the value of clk source */
gume 0:1f82672b8755 7751 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 7752 (p_bno055->dev_addr,
gume 0:1f82672b8755 7753 BNO055_CLK_SRC_REG,
gume 0:1f82672b8755 7754 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 7755 *clk_src_u8 =
gume 0:1f82672b8755 7756 BNO055_GET_BITSLICE(data_u8r, BNO055_CLK_SRC);
gume 0:1f82672b8755 7757 } else {
gume 0:1f82672b8755 7758 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7759 }
gume 0:1f82672b8755 7760 }
gume 0:1f82672b8755 7761 return com_rslt;
gume 0:1f82672b8755 7762 }
gume 0:1f82672b8755 7763 /*!
gume 0:1f82672b8755 7764 * @brief This API used to write the clk source
gume 0:1f82672b8755 7765 * from register from 0x3F bit 7
gume 0:1f82672b8755 7766 *
gume 0:1f82672b8755 7767 * @param clk_src_u8 : The value of clk source
gume 0:1f82672b8755 7768 *
gume 0:1f82672b8755 7769 * clk_src_u8 | result
gume 0:1f82672b8755 7770 * -------------- |----------
gume 0:1f82672b8755 7771 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 7772 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 7773 *
gume 0:1f82672b8755 7774 * @return results of bus communication function
gume 0:1f82672b8755 7775 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 7776 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 7777 *
gume 0:1f82672b8755 7778 */
gume 0:1f82672b8755 7779 BNO055_RETURN_FUNCTION_TYPE bno055_set_clk_src(u8 clk_src_u8)
gume 0:1f82672b8755 7780 {
gume 0:1f82672b8755 7781 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7782 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 7783 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 7784 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 7785 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 7786 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 7787 } else {
gume 0:1f82672b8755 7788 /*condition check for page, clk source is
gume 0:1f82672b8755 7789 available in the page zero*/
gume 0:1f82672b8755 7790 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 7791 /* Write the page zero*/
gume 0:1f82672b8755 7792 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 7793 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 7794 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 7795 /* Write the value of clk source */
gume 0:1f82672b8755 7796 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 7797 (p_bno055->dev_addr,
gume 0:1f82672b8755 7798 BNO055_CLK_SRC_REG,
gume 0:1f82672b8755 7799 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 7800 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 7801 data_u8r =
gume 0:1f82672b8755 7802 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 7803 BNO055_CLK_SRC, clk_src_u8);
gume 0:1f82672b8755 7804 com_rslt +=
gume 0:1f82672b8755 7805 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 7806 (p_bno055->dev_addr,
gume 0:1f82672b8755 7807 BNO055_CLK_SRC_REG,
gume 0:1f82672b8755 7808 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 7809 }
gume 0:1f82672b8755 7810 } else {
gume 0:1f82672b8755 7811 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7812 }
gume 0:1f82672b8755 7813 }
gume 0:1f82672b8755 7814 return com_rslt;
gume 0:1f82672b8755 7815 }
gume 0:1f82672b8755 7816 /*!
gume 0:1f82672b8755 7817 * @brief This API used to read the reset system
gume 0:1f82672b8755 7818 * from register from 0x3F bit 5
gume 0:1f82672b8755 7819 *
gume 0:1f82672b8755 7820 * @param sys_rst_u8 : The value of reset system
gume 0:1f82672b8755 7821 *
gume 0:1f82672b8755 7822 * sys_rst_u8 | result
gume 0:1f82672b8755 7823 * -------------- |----------
gume 0:1f82672b8755 7824 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 7825 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 7826 *
gume 0:1f82672b8755 7827 * @return results of bus communication function
gume 0:1f82672b8755 7828 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 7829 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 7830 *
gume 0:1f82672b8755 7831 * @note It resets the whole system
gume 0:1f82672b8755 7832 */
gume 0:1f82672b8755 7833 BNO055_RETURN_FUNCTION_TYPE bno055_get_sys_rst(
gume 0:1f82672b8755 7834 u8 *sys_rst_u8)
gume 0:1f82672b8755 7835 {
gume 0:1f82672b8755 7836 /* Variable used to return value of
gume 0:1f82672b8755 7837 communication routine*/
gume 0:1f82672b8755 7838 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7839 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 7840 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 7841 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 7842 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 7843 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 7844 } else {
gume 0:1f82672b8755 7845 /*condition check for page, reset system is
gume 0:1f82672b8755 7846 available in the page zero*/
gume 0:1f82672b8755 7847 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 7848 /* Write the page zero*/
gume 0:1f82672b8755 7849 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 7850 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 7851 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 7852 /* Read the value of reset system */
gume 0:1f82672b8755 7853 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 7854 (p_bno055->dev_addr,
gume 0:1f82672b8755 7855 BNO055_SYS_RST_REG,
gume 0:1f82672b8755 7856 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 7857 *sys_rst_u8 =
gume 0:1f82672b8755 7858 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 7859 BNO055_SYS_RST);
gume 0:1f82672b8755 7860 } else {
gume 0:1f82672b8755 7861 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7862 }
gume 0:1f82672b8755 7863 }
gume 0:1f82672b8755 7864 return com_rslt;
gume 0:1f82672b8755 7865 }
gume 0:1f82672b8755 7866 /*!
gume 0:1f82672b8755 7867 * @brief This API used to write the reset system
gume 0:1f82672b8755 7868 * from register from 0x3F bit 5
gume 0:1f82672b8755 7869 *
gume 0:1f82672b8755 7870 * @param sys_rst_u8 : The value of reset system
gume 0:1f82672b8755 7871 *
gume 0:1f82672b8755 7872 * sys_rst_u8 | result
gume 0:1f82672b8755 7873 * -------------- |----------
gume 0:1f82672b8755 7874 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 7875 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 7876 *
gume 0:1f82672b8755 7877 * @return results of bus communication function
gume 0:1f82672b8755 7878 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 7879 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 7880 *
gume 0:1f82672b8755 7881 * @note It resets the whole system
gume 0:1f82672b8755 7882 */
gume 0:1f82672b8755 7883 BNO055_RETURN_FUNCTION_TYPE bno055_set_sys_rst(u8 sys_rst_u8)
gume 0:1f82672b8755 7884 {
gume 0:1f82672b8755 7885 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7886 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 7887 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 7888 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 7889 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 7890 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 7891 } else {
gume 0:1f82672b8755 7892 /*condition check for page, reset system is
gume 0:1f82672b8755 7893 available in the page zero*/
gume 0:1f82672b8755 7894 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 7895 /* Write the page zero*/
gume 0:1f82672b8755 7896 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 7897 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 7898 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 7899 /* Write the value of reset system */
gume 0:1f82672b8755 7900 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 7901 (p_bno055->dev_addr,
gume 0:1f82672b8755 7902 BNO055_SYS_RST_REG,
gume 0:1f82672b8755 7903 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 7904 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 7905 data_u8r =
gume 0:1f82672b8755 7906 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 7907 BNO055_SYS_RST, sys_rst_u8);
gume 0:1f82672b8755 7908 com_rslt =
gume 0:1f82672b8755 7909 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 7910 (p_bno055->dev_addr,
gume 0:1f82672b8755 7911 BNO055_SYS_RST_REG,
gume 0:1f82672b8755 7912 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 7913 }
gume 0:1f82672b8755 7914 } else {
gume 0:1f82672b8755 7915 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7916 }
gume 0:1f82672b8755 7917 }
gume 0:1f82672b8755 7918 return com_rslt;
gume 0:1f82672b8755 7919 }
gume 0:1f82672b8755 7920 /*!
gume 0:1f82672b8755 7921 * @brief This API used to read the self test
gume 0:1f82672b8755 7922 * from register from 0x3F bit 0
gume 0:1f82672b8755 7923 *
gume 0:1f82672b8755 7924 * @param selftest_u8 : The value of self test
gume 0:1f82672b8755 7925 *
gume 0:1f82672b8755 7926 * selftest_u8 | result
gume 0:1f82672b8755 7927 * -------------- |----------
gume 0:1f82672b8755 7928 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 7929 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 7930 *
gume 0:1f82672b8755 7931 * @return results of bus communication function
gume 0:1f82672b8755 7932 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 7933 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 7934 *
gume 0:1f82672b8755 7935 * @note It triggers the self test
gume 0:1f82672b8755 7936 */
gume 0:1f82672b8755 7937 BNO055_RETURN_FUNCTION_TYPE bno055_get_selftest(
gume 0:1f82672b8755 7938 u8 *selftest_u8)
gume 0:1f82672b8755 7939 {
gume 0:1f82672b8755 7940 /* Variable used to return value of
gume 0:1f82672b8755 7941 communication routine*/
gume 0:1f82672b8755 7942 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7943 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 7944 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 7945 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 7946 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 7947 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 7948 } else {
gume 0:1f82672b8755 7949 /*condition check for page, self test is
gume 0:1f82672b8755 7950 available in the page zero*/
gume 0:1f82672b8755 7951 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 7952 /* Write the page zero*/
gume 0:1f82672b8755 7953 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 7954 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 7955 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 7956 /* Read the value of self test */
gume 0:1f82672b8755 7957 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 7958 (p_bno055->dev_addr,
gume 0:1f82672b8755 7959 BNO055_SELFTEST_REG,
gume 0:1f82672b8755 7960 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 7961 *selftest_u8 =
gume 0:1f82672b8755 7962 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 7963 BNO055_SELFTEST);
gume 0:1f82672b8755 7964 } else {
gume 0:1f82672b8755 7965 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7966 }
gume 0:1f82672b8755 7967 }
gume 0:1f82672b8755 7968 return com_rslt;
gume 0:1f82672b8755 7969 }
gume 0:1f82672b8755 7970 /*!
gume 0:1f82672b8755 7971 * @brief This API used to write the self test
gume 0:1f82672b8755 7972 * from register from 0x3F bit 0
gume 0:1f82672b8755 7973 *
gume 0:1f82672b8755 7974 * @param selftest_u8 : The value of self test
gume 0:1f82672b8755 7975 *
gume 0:1f82672b8755 7976 * selftest_u8 | result
gume 0:1f82672b8755 7977 * -------------- |----------
gume 0:1f82672b8755 7978 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 7979 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 7980 *
gume 0:1f82672b8755 7981 * @return results of bus communication function
gume 0:1f82672b8755 7982 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 7983 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 7984 *
gume 0:1f82672b8755 7985 * @note It triggers the self test
gume 0:1f82672b8755 7986 *
gume 0:1f82672b8755 7987 *
gume 0:1f82672b8755 7988 */
gume 0:1f82672b8755 7989 BNO055_RETURN_FUNCTION_TYPE bno055_set_selftest(u8 selftest_u8)
gume 0:1f82672b8755 7990 {
gume 0:1f82672b8755 7991 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 7992 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 7993 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 7994 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 7995 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 7996 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 7997 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 7998 } else {
gume 0:1f82672b8755 7999 /* The write operation effective only if the operation
gume 0:1f82672b8755 8000 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 8001 current operation mode and set the config mode */
gume 0:1f82672b8755 8002 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 8003 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 8004 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 8005 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 8006 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 8007 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 8008 /* Write the value of self test */
gume 0:1f82672b8755 8009 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 8010 (p_bno055->dev_addr,
gume 0:1f82672b8755 8011 BNO055_SELFTEST_REG,
gume 0:1f82672b8755 8012 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 8013 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 8014 data_u8r =
gume 0:1f82672b8755 8015 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 8016 BNO055_SELFTEST,
gume 0:1f82672b8755 8017 selftest_u8);
gume 0:1f82672b8755 8018 com_rslt +=
gume 0:1f82672b8755 8019 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 8020 (p_bno055->dev_addr,
gume 0:1f82672b8755 8021 BNO055_SELFTEST_REG,
gume 0:1f82672b8755 8022 &data_u8r,
gume 0:1f82672b8755 8023 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 8024 }
gume 0:1f82672b8755 8025 } else {
gume 0:1f82672b8755 8026 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8027 }
gume 0:1f82672b8755 8028 } else {
gume 0:1f82672b8755 8029 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8030 }
gume 0:1f82672b8755 8031 }
gume 0:1f82672b8755 8032 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 8033 /* set the operation mode
gume 0:1f82672b8755 8034 of previous operation mode*/
gume 0:1f82672b8755 8035 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 8036 (prev_opmode_u8);
gume 0:1f82672b8755 8037 return com_rslt;
gume 0:1f82672b8755 8038 }
gume 0:1f82672b8755 8039 /*!
gume 0:1f82672b8755 8040 * @brief This API used to read the temperature source
gume 0:1f82672b8755 8041 * from register from 0x40 bit 0 and 1
gume 0:1f82672b8755 8042 *
gume 0:1f82672b8755 8043 * @param temp_source_u8 : The value of selected temperature source
gume 0:1f82672b8755 8044 *
gume 0:1f82672b8755 8045 * temp_source_u8 | result
gume 0:1f82672b8755 8046 * ---------------- |---------------
gume 0:1f82672b8755 8047 * 0x00 | BNO055_ACCEL_TEMP_EN
gume 0:1f82672b8755 8048 * 0X01 | BNO055_GYRO_TEMP_EN
gume 0:1f82672b8755 8049 * 0X03 | BNO055_MCU_TEMP_EN
gume 0:1f82672b8755 8050 *
gume 0:1f82672b8755 8051 * @return results of bus communication function
gume 0:1f82672b8755 8052 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 8053 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 8054 *
gume 0:1f82672b8755 8055 */
gume 0:1f82672b8755 8056 BNO055_RETURN_FUNCTION_TYPE bno055_get_temp_source(
gume 0:1f82672b8755 8057 u8 *temp_source_u8)
gume 0:1f82672b8755 8058 {
gume 0:1f82672b8755 8059 /* Variable used to return value of
gume 0:1f82672b8755 8060 communication routine*/
gume 0:1f82672b8755 8061 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8062 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 8063 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 8064 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 8065 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 8066 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 8067 } else {
gume 0:1f82672b8755 8068 /*condition check for page, temperature source is
gume 0:1f82672b8755 8069 available in the page zero*/
gume 0:1f82672b8755 8070 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 8071 /* Write the page zero*/
gume 0:1f82672b8755 8072 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 8073 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 8074 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 8075 /* Read the value of temperature source */
gume 0:1f82672b8755 8076 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 8077 (p_bno055->dev_addr,
gume 0:1f82672b8755 8078 BNO055_TEMP_SOURCE_REG,
gume 0:1f82672b8755 8079 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 8080 *temp_source_u8 =
gume 0:1f82672b8755 8081 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 8082 BNO055_TEMP_SOURCE);
gume 0:1f82672b8755 8083 } else {
gume 0:1f82672b8755 8084 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8085 }
gume 0:1f82672b8755 8086 }
gume 0:1f82672b8755 8087 return com_rslt;
gume 0:1f82672b8755 8088 }
gume 0:1f82672b8755 8089 /*!
gume 0:1f82672b8755 8090 * @brief This API used to write the temperature source
gume 0:1f82672b8755 8091 * from register from 0x40 bit 0 and 1
gume 0:1f82672b8755 8092 *
gume 0:1f82672b8755 8093 * @param temp_source_u8 : The value of selected temperature source
gume 0:1f82672b8755 8094 *
gume 0:1f82672b8755 8095 * temp_source_u8 | result
gume 0:1f82672b8755 8096 * ---------------- |---------------
gume 0:1f82672b8755 8097 * 0x00 | BNO055_ACCEL_TEMP_EN
gume 0:1f82672b8755 8098 * 0X01 | BNO055_GYRO_TEMP_EN
gume 0:1f82672b8755 8099 * 0X03 | BNO055_MCU_TEMP_EN
gume 0:1f82672b8755 8100 *
gume 0:1f82672b8755 8101 * @return results of bus communication function
gume 0:1f82672b8755 8102 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 8103 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 8104 *
gume 0:1f82672b8755 8105 */
gume 0:1f82672b8755 8106 BNO055_RETURN_FUNCTION_TYPE bno055_set_temp_source(u8 temp_source_u8)
gume 0:1f82672b8755 8107 {
gume 0:1f82672b8755 8108 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8109 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 8110 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 8111 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 8112 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 8113 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 8114 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 8115 } else {
gume 0:1f82672b8755 8116 /* The write operation effective only if the operation
gume 0:1f82672b8755 8117 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 8118 current operation mode and set the config mode */
gume 0:1f82672b8755 8119 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 8120 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 8121 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 8122 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 8123 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 8124 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 8125 /* Write the value of temperature source*/
gume 0:1f82672b8755 8126 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 8127 (p_bno055->dev_addr,
gume 0:1f82672b8755 8128 BNO055_TEMP_SOURCE_REG,
gume 0:1f82672b8755 8129 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 8130 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 8131 data_u8r =
gume 0:1f82672b8755 8132 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 8133 BNO055_TEMP_SOURCE, temp_source_u8);
gume 0:1f82672b8755 8134 com_rslt +=
gume 0:1f82672b8755 8135 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 8136 (p_bno055->dev_addr,
gume 0:1f82672b8755 8137 BNO055_TEMP_SOURCE_REG,
gume 0:1f82672b8755 8138 &data_u8r,
gume 0:1f82672b8755 8139 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 8140 }
gume 0:1f82672b8755 8141 } else {
gume 0:1f82672b8755 8142 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8143 }
gume 0:1f82672b8755 8144 } else {
gume 0:1f82672b8755 8145 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8146 }
gume 0:1f82672b8755 8147 }
gume 0:1f82672b8755 8148 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 8149 /* set the operation mode
gume 0:1f82672b8755 8150 of previous operation mode*/
gume 0:1f82672b8755 8151 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 8152 (prev_opmode_u8);
gume 0:1f82672b8755 8153 return com_rslt;
gume 0:1f82672b8755 8154 }
gume 0:1f82672b8755 8155 /*!
gume 0:1f82672b8755 8156 * @brief This API used to read the axis remap value
gume 0:1f82672b8755 8157 * from register from 0x41 bit 0 and 5
gume 0:1f82672b8755 8158 *
gume 0:1f82672b8755 8159 * @param remap_axis_u8 : The value of axis remapping
gume 0:1f82672b8755 8160 *
gume 0:1f82672b8755 8161 * remap_axis_u8 | result | comments
gume 0:1f82672b8755 8162 * ------------|-------------------|------------
gume 0:1f82672b8755 8163 * 0X21 | BNO055_REMAP_X_Y | Z=Z;X=Y;Y=X
gume 0:1f82672b8755 8164 * 0X18 | BNO055_REMAP_Y_Z | X=X;Y=Z;Z=Y
gume 0:1f82672b8755 8165 * 0X06 | BNO055_REMAP_Z_X | Y=Y;X=Z;Z=X
gume 0:1f82672b8755 8166 * 0X12 | BNO055_REMAP_X_Y_Z_TYPE0 | X=Z;Y=X;Z=Y
gume 0:1f82672b8755 8167 * 0X09 | BNO055_REMAP_X_Y_Z_TYPE1 | X=Y;Y=Z;Z=X
gume 0:1f82672b8755 8168 * 0X24 | BNO055_DEFAULT_AXIS | X=X;Y=Y;Z=Z
gume 0:1f82672b8755 8169 *
gume 0:1f82672b8755 8170 * @return results of bus communication function
gume 0:1f82672b8755 8171 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 8172 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 8173 *
gume 0:1f82672b8755 8174 * @note : For axis sign remap refer the following APIs
gume 0:1f82672b8755 8175 * x-axis :
gume 0:1f82672b8755 8176 *
gume 0:1f82672b8755 8177 * bno055_set_x_remap_sign()
gume 0:1f82672b8755 8178 *
gume 0:1f82672b8755 8179 * y-axis :
gume 0:1f82672b8755 8180 *
gume 0:1f82672b8755 8181 * bno055_set_y_remap_sign()
gume 0:1f82672b8755 8182 *
gume 0:1f82672b8755 8183 * z-axis :
gume 0:1f82672b8755 8184 *
gume 0:1f82672b8755 8185 * bno055_set_z_remap_sign()
gume 0:1f82672b8755 8186 *
gume 0:1f82672b8755 8187 */
gume 0:1f82672b8755 8188 BNO055_RETURN_FUNCTION_TYPE bno055_get_axis_remap_value(
gume 0:1f82672b8755 8189 u8 *remap_axis_u8)
gume 0:1f82672b8755 8190 {
gume 0:1f82672b8755 8191 /* Variable used to return value of
gume 0:1f82672b8755 8192 communication routine*/
gume 0:1f82672b8755 8193 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8194 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 8195 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 8196 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 8197 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 8198 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 8199 } else {
gume 0:1f82672b8755 8200 /*condition check for page, axis remap is
gume 0:1f82672b8755 8201 available in the page zero*/
gume 0:1f82672b8755 8202 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 8203 /* Write the page zero*/
gume 0:1f82672b8755 8204 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 8205 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 8206 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 8207 /* Read the value of axis remap*/
gume 0:1f82672b8755 8208 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 8209 (p_bno055->dev_addr,
gume 0:1f82672b8755 8210 BNO055_REMAP_AXIS_VALUE_REG,
gume 0:1f82672b8755 8211 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 8212 *remap_axis_u8 =
gume 0:1f82672b8755 8213 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 8214 BNO055_REMAP_AXIS_VALUE);
gume 0:1f82672b8755 8215 } else {
gume 0:1f82672b8755 8216 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8217 }
gume 0:1f82672b8755 8218 }
gume 0:1f82672b8755 8219 return com_rslt;
gume 0:1f82672b8755 8220 }
gume 0:1f82672b8755 8221 /*!
gume 0:1f82672b8755 8222 * @brief This API used to write the axis remap value
gume 0:1f82672b8755 8223 * from register from 0x41 bit 0 and 5
gume 0:1f82672b8755 8224 *
gume 0:1f82672b8755 8225 * @param remap_axis_u8 : The value of axis remapping
gume 0:1f82672b8755 8226 *
gume 0:1f82672b8755 8227 * remap_axis_u8 | result | comments
gume 0:1f82672b8755 8228 * ------------|-------------------|------------
gume 0:1f82672b8755 8229 * 0X21 | BNO055_REMAP_X_Y | Z=Z;X=Y;Y=X
gume 0:1f82672b8755 8230 * 0X18 | BNO055_REMAP_Y_Z | X=X;Y=Z;Z=Y
gume 0:1f82672b8755 8231 * 0X06 | BNO055_REMAP_Z_X | Y=Y;X=Z;Z=X
gume 0:1f82672b8755 8232 * 0X12 | BNO055_REMAP_X_Y_Z_TYPE0 | X=Z;Y=X;Z=Y
gume 0:1f82672b8755 8233 * 0X09 | BNO055_REMAP_X_Y_Z_TYPE1 | X=Y;Y=Z;Z=X
gume 0:1f82672b8755 8234 * 0X24 | BNO055_DEFAULT_AXIS | X=X;Y=Y;Z=Z
gume 0:1f82672b8755 8235 *
gume 0:1f82672b8755 8236 * @return results of bus communication function
gume 0:1f82672b8755 8237 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 8238 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 8239 *
gume 0:1f82672b8755 8240 * @note : For axis sign remap refer the following APIs
gume 0:1f82672b8755 8241 * x-axis :
gume 0:1f82672b8755 8242 *
gume 0:1f82672b8755 8243 * bno055_set_x_remap_sign()
gume 0:1f82672b8755 8244 *
gume 0:1f82672b8755 8245 * y-axis :
gume 0:1f82672b8755 8246 *
gume 0:1f82672b8755 8247 * bno055_set_y_remap_sign()
gume 0:1f82672b8755 8248 *
gume 0:1f82672b8755 8249 * z-axis :
gume 0:1f82672b8755 8250 *
gume 0:1f82672b8755 8251 * bno055_set_z_remap_sign()
gume 0:1f82672b8755 8252 *
gume 0:1f82672b8755 8253 */
gume 0:1f82672b8755 8254 BNO055_RETURN_FUNCTION_TYPE bno055_set_axis_remap_value(
gume 0:1f82672b8755 8255 u8 remap_axis_u8)
gume 0:1f82672b8755 8256 {
gume 0:1f82672b8755 8257 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8258 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 8259 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 8260 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 8261 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 8262 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 8263 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 8264 } else {
gume 0:1f82672b8755 8265 /* The write operation effective only if the operation
gume 0:1f82672b8755 8266 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 8267 current operation mode and set the config mode */
gume 0:1f82672b8755 8268 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 8269 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 8270 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 8271 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 8272 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 8273 /* Write the value of axis remap */
gume 0:1f82672b8755 8274 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 8275 switch (remap_axis_u8) {
gume 0:1f82672b8755 8276 case BNO055_REMAP_X_Y:
gume 0:1f82672b8755 8277 case BNO055_REMAP_Y_Z:
gume 0:1f82672b8755 8278 case BNO055_REMAP_Z_X:
gume 0:1f82672b8755 8279 case BNO055_REMAP_X_Y_Z_TYPE0:
gume 0:1f82672b8755 8280 case BNO055_REMAP_X_Y_Z_TYPE1:
gume 0:1f82672b8755 8281 case BNO055_DEFAULT_AXIS:
gume 0:1f82672b8755 8282 com_rslt =
gume 0:1f82672b8755 8283 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 8284 (p_bno055->dev_addr,
gume 0:1f82672b8755 8285 BNO055_REMAP_AXIS_VALUE_REG,
gume 0:1f82672b8755 8286 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 8287 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 8288 data_u8r = BNO055_SET_BITSLICE
gume 0:1f82672b8755 8289 (data_u8r,
gume 0:1f82672b8755 8290 BNO055_REMAP_AXIS_VALUE,
gume 0:1f82672b8755 8291 remap_axis_u8);
gume 0:1f82672b8755 8292 com_rslt +=
gume 0:1f82672b8755 8293 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 8294 (p_bno055->dev_addr,
gume 0:1f82672b8755 8295 BNO055_REMAP_AXIS_VALUE_REG,
gume 0:1f82672b8755 8296 &data_u8r,
gume 0:1f82672b8755 8297 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 8298 }
gume 0:1f82672b8755 8299 break;
gume 0:1f82672b8755 8300 default:
gume 0:1f82672b8755 8301 /* Write the default axis remap value */
gume 0:1f82672b8755 8302 com_rslt =
gume 0:1f82672b8755 8303 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 8304 (p_bno055->dev_addr,
gume 0:1f82672b8755 8305 BNO055_REMAP_AXIS_VALUE_REG,
gume 0:1f82672b8755 8306 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 8307 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 8308 data_u8r = BNO055_SET_BITSLICE
gume 0:1f82672b8755 8309 (data_u8r,
gume 0:1f82672b8755 8310 BNO055_REMAP_AXIS_VALUE,
gume 0:1f82672b8755 8311 BNO055_DEFAULT_AXIS);
gume 0:1f82672b8755 8312 com_rslt +=
gume 0:1f82672b8755 8313 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 8314 (p_bno055->dev_addr,
gume 0:1f82672b8755 8315 BNO055_REMAP_AXIS_VALUE_REG,
gume 0:1f82672b8755 8316 &data_u8r,
gume 0:1f82672b8755 8317 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 8318 }
gume 0:1f82672b8755 8319 break;
gume 0:1f82672b8755 8320 }
gume 0:1f82672b8755 8321 } else {
gume 0:1f82672b8755 8322 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8323 }
gume 0:1f82672b8755 8324 } else {
gume 0:1f82672b8755 8325 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8326 }
gume 0:1f82672b8755 8327 }
gume 0:1f82672b8755 8328 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 8329 /* set the operation mode
gume 0:1f82672b8755 8330 of previous operation mode*/
gume 0:1f82672b8755 8331 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 8332 (prev_opmode_u8);
gume 0:1f82672b8755 8333 return com_rslt;
gume 0:1f82672b8755 8334 }
gume 0:1f82672b8755 8335 /*!
gume 0:1f82672b8755 8336 * @brief This API used to read the x-axis remap
gume 0:1f82672b8755 8337 * sign from register from 0x42 bit 2
gume 0:1f82672b8755 8338 *
gume 0:1f82672b8755 8339 * @param remap_x_sign_u8 : The value of x-axis remap sign
gume 0:1f82672b8755 8340 *
gume 0:1f82672b8755 8341 * remap_x_sign_u8 | result
gume 0:1f82672b8755 8342 * ------------------- |--------------------
gume 0:1f82672b8755 8343 * 0X00 | BNO055_REMAP_AXIS_POSITIVE
gume 0:1f82672b8755 8344 * 0X01 | BNO055_REMAP_AXIS_NEGATIVE
gume 0:1f82672b8755 8345 *
gume 0:1f82672b8755 8346 * @return results of bus communication function
gume 0:1f82672b8755 8347 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 8348 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 8349 *
gume 0:1f82672b8755 8350 */
gume 0:1f82672b8755 8351 BNO055_RETURN_FUNCTION_TYPE bno055_get_remap_x_sign(
gume 0:1f82672b8755 8352 u8 *remap_x_sign_u8)
gume 0:1f82672b8755 8353 {
gume 0:1f82672b8755 8354 /* Variable used to return value of
gume 0:1f82672b8755 8355 communication routine*/
gume 0:1f82672b8755 8356 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8357 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 8358 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 8359 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 8360 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 8361 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 8362 } else {
gume 0:1f82672b8755 8363 /*condition check for page, x-axis remap sign is
gume 0:1f82672b8755 8364 available in the page zero*/
gume 0:1f82672b8755 8365 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 8366 /* Write the page zero*/
gume 0:1f82672b8755 8367 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 8368 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 8369 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 8370 /* Read the value of x-axis remap sign */
gume 0:1f82672b8755 8371 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 8372 (p_bno055->dev_addr,
gume 0:1f82672b8755 8373 BNO055_REMAP_X_SIGN_REG,
gume 0:1f82672b8755 8374 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 8375 *remap_x_sign_u8 =
gume 0:1f82672b8755 8376 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 8377 BNO055_REMAP_X_SIGN);
gume 0:1f82672b8755 8378 } else {
gume 0:1f82672b8755 8379 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8380 }
gume 0:1f82672b8755 8381 }
gume 0:1f82672b8755 8382 return com_rslt;
gume 0:1f82672b8755 8383 }
gume 0:1f82672b8755 8384 /*!
gume 0:1f82672b8755 8385 * @brief This API used to write the x-axis remap
gume 0:1f82672b8755 8386 * sign from register from 0x42 bit 2
gume 0:1f82672b8755 8387 *
gume 0:1f82672b8755 8388 * @param remap_x_sign_u8 : The value of x-axis remap sign
gume 0:1f82672b8755 8389 *
gume 0:1f82672b8755 8390 * remap_x_sign_u8 | result
gume 0:1f82672b8755 8391 * ------------------- |--------------------
gume 0:1f82672b8755 8392 * 0X00 | BNO055_REMAP_AXIS_POSITIVE
gume 0:1f82672b8755 8393 * 0X01 | BNO055_REMAP_AXIS_NEGATIVE
gume 0:1f82672b8755 8394 *
gume 0:1f82672b8755 8395 * @return results of bus communication function
gume 0:1f82672b8755 8396 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 8397 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 8398 *
gume 0:1f82672b8755 8399 */
gume 0:1f82672b8755 8400 BNO055_RETURN_FUNCTION_TYPE bno055_set_remap_x_sign(
gume 0:1f82672b8755 8401 u8 remap_x_sign_u8)
gume 0:1f82672b8755 8402 {
gume 0:1f82672b8755 8403 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8404 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 8405 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 8406 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 8407 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 8408 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 8409 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 8410 } else {
gume 0:1f82672b8755 8411 /* The write operation effective only if the operation
gume 0:1f82672b8755 8412 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 8413 current operation mode and set the config mode */
gume 0:1f82672b8755 8414 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 8415 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 8416 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 8417 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 8418 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 8419 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 8420 /* Write the value of x-axis remap */
gume 0:1f82672b8755 8421 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 8422 (p_bno055->dev_addr,
gume 0:1f82672b8755 8423 BNO055_REMAP_X_SIGN_REG,
gume 0:1f82672b8755 8424 &data_u8r,
gume 0:1f82672b8755 8425 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 8426 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 8427 data_u8r =
gume 0:1f82672b8755 8428 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 8429 BNO055_REMAP_X_SIGN,
gume 0:1f82672b8755 8430 remap_x_sign_u8);
gume 0:1f82672b8755 8431 com_rslt +=
gume 0:1f82672b8755 8432 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 8433 (p_bno055->dev_addr,
gume 0:1f82672b8755 8434 BNO055_REMAP_X_SIGN_REG,
gume 0:1f82672b8755 8435 &data_u8r,
gume 0:1f82672b8755 8436 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 8437 }
gume 0:1f82672b8755 8438 } else {
gume 0:1f82672b8755 8439 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8440 }
gume 0:1f82672b8755 8441 } else {
gume 0:1f82672b8755 8442 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8443 }
gume 0:1f82672b8755 8444 }
gume 0:1f82672b8755 8445 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 8446 /* set the operation mode
gume 0:1f82672b8755 8447 of previous operation mode*/
gume 0:1f82672b8755 8448 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 8449 (prev_opmode_u8);
gume 0:1f82672b8755 8450 return com_rslt;
gume 0:1f82672b8755 8451 }
gume 0:1f82672b8755 8452 /*!
gume 0:1f82672b8755 8453 * @brief This API used to read the y-axis remap
gume 0:1f82672b8755 8454 * sign from register from 0x42 bit 1
gume 0:1f82672b8755 8455 *
gume 0:1f82672b8755 8456 * @param remap_y_sign_u8 : The value of y-axis remap sign
gume 0:1f82672b8755 8457 *
gume 0:1f82672b8755 8458 * remap_y_sign_u8 | result
gume 0:1f82672b8755 8459 * ------------------- |--------------------
gume 0:1f82672b8755 8460 * 0X00 | BNO055_REMAP_AXIS_POSITIVE
gume 0:1f82672b8755 8461 * 0X01 | BNO055_REMAP_AXIS_NEGATIVE
gume 0:1f82672b8755 8462 *
gume 0:1f82672b8755 8463 * @return results of bus communication function
gume 0:1f82672b8755 8464 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 8465 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 8466 *
gume 0:1f82672b8755 8467 */
gume 0:1f82672b8755 8468 BNO055_RETURN_FUNCTION_TYPE bno055_get_remap_y_sign(
gume 0:1f82672b8755 8469 u8 *remap_y_sign_u8)
gume 0:1f82672b8755 8470 {
gume 0:1f82672b8755 8471 /* Variable used to return value of
gume 0:1f82672b8755 8472 communication routine*/
gume 0:1f82672b8755 8473 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8474 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 8475 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 8476 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 8477 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 8478 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 8479 } else {
gume 0:1f82672b8755 8480 /*condition check for page, y-axis remap sign is
gume 0:1f82672b8755 8481 available in the page zero*/
gume 0:1f82672b8755 8482 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 8483 /* Write the page zero*/
gume 0:1f82672b8755 8484 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 8485 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 8486 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 8487 /* Read the value of y-axis remap sign*/
gume 0:1f82672b8755 8488 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 8489 (p_bno055->dev_addr,
gume 0:1f82672b8755 8490 BNO055_REMAP_Y_SIGN_REG,
gume 0:1f82672b8755 8491 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 8492 *remap_y_sign_u8 =
gume 0:1f82672b8755 8493 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 8494 BNO055_REMAP_Y_SIGN);
gume 0:1f82672b8755 8495 } else {
gume 0:1f82672b8755 8496 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8497 }
gume 0:1f82672b8755 8498 }
gume 0:1f82672b8755 8499 return com_rslt;
gume 0:1f82672b8755 8500 }
gume 0:1f82672b8755 8501 /*!
gume 0:1f82672b8755 8502 * @brief This API used to write the y-axis remap
gume 0:1f82672b8755 8503 * sign from register from 0x42 bit 1
gume 0:1f82672b8755 8504 *
gume 0:1f82672b8755 8505 * @param remap_y_sign_u8 : The value of y-axis remap sign
gume 0:1f82672b8755 8506 *
gume 0:1f82672b8755 8507 * remap_y_sign_u8 | result
gume 0:1f82672b8755 8508 * ------------------- |--------------------
gume 0:1f82672b8755 8509 * 0X00 | BNO055_REMAP_AXIS_POSITIVE
gume 0:1f82672b8755 8510 * 0X01 | BNO055_REMAP_AXIS_NEGATIVE
gume 0:1f82672b8755 8511 *
gume 0:1f82672b8755 8512 * @return results of bus communication function
gume 0:1f82672b8755 8513 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 8514 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 8515 *
gume 0:1f82672b8755 8516 */
gume 0:1f82672b8755 8517 BNO055_RETURN_FUNCTION_TYPE bno055_set_remap_y_sign(
gume 0:1f82672b8755 8518 u8 remap_y_sign_u8)
gume 0:1f82672b8755 8519 {
gume 0:1f82672b8755 8520 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8521 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 8522 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 8523 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 8524 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 8525 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 8526 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 8527 } else {
gume 0:1f82672b8755 8528 /* The write operation effective only if the operation
gume 0:1f82672b8755 8529 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 8530 current operation mode and set the config mode */
gume 0:1f82672b8755 8531 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 8532 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 8533 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 8534 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 8535 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 8536 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 8537 /* Write the value of y-axis remap sign*/
gume 0:1f82672b8755 8538 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 8539 (p_bno055->dev_addr,
gume 0:1f82672b8755 8540 BNO055_REMAP_Y_SIGN_REG,
gume 0:1f82672b8755 8541 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 8542 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 8543 data_u8r =
gume 0:1f82672b8755 8544 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 8545 BNO055_REMAP_Y_SIGN,
gume 0:1f82672b8755 8546 remap_y_sign_u8);
gume 0:1f82672b8755 8547 com_rslt +=
gume 0:1f82672b8755 8548 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 8549 (p_bno055->dev_addr,
gume 0:1f82672b8755 8550 BNO055_REMAP_Y_SIGN_REG,
gume 0:1f82672b8755 8551 &data_u8r,
gume 0:1f82672b8755 8552 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 8553 }
gume 0:1f82672b8755 8554 } else {
gume 0:1f82672b8755 8555 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8556 }
gume 0:1f82672b8755 8557 } else {
gume 0:1f82672b8755 8558 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8559 }
gume 0:1f82672b8755 8560 }
gume 0:1f82672b8755 8561 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 8562 /* set the operation mode
gume 0:1f82672b8755 8563 of previous operation mode*/
gume 0:1f82672b8755 8564 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 8565 (prev_opmode_u8);
gume 0:1f82672b8755 8566 return com_rslt;
gume 0:1f82672b8755 8567 }
gume 0:1f82672b8755 8568 /*!
gume 0:1f82672b8755 8569 * @brief This API used to read the z-axis remap
gume 0:1f82672b8755 8570 * sign from register from 0x42 bit 0
gume 0:1f82672b8755 8571 *
gume 0:1f82672b8755 8572 * @param remap_z_sign_u8 : The value of z-axis remap sign
gume 0:1f82672b8755 8573 *
gume 0:1f82672b8755 8574 * remap_z_sign_u8 | result
gume 0:1f82672b8755 8575 * ------------------- |--------------------
gume 0:1f82672b8755 8576 * 0X00 | BNO055_REMAP_AXIS_POSITIVE
gume 0:1f82672b8755 8577 * 0X01 | BNO055_REMAP_AXIS_NEGATIVE
gume 0:1f82672b8755 8578 *
gume 0:1f82672b8755 8579 * @return results of bus communication function
gume 0:1f82672b8755 8580 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 8581 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 8582 *
gume 0:1f82672b8755 8583 */
gume 0:1f82672b8755 8584 BNO055_RETURN_FUNCTION_TYPE bno055_get_remap_z_sign(
gume 0:1f82672b8755 8585 u8 *remap_z_sign_u8)
gume 0:1f82672b8755 8586 {
gume 0:1f82672b8755 8587 /* Variable used to return value of
gume 0:1f82672b8755 8588 communication routine*/
gume 0:1f82672b8755 8589 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8590 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 8591 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 8592 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 8593 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 8594 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 8595 } else {
gume 0:1f82672b8755 8596 /*condition check for page, z-axis remap sign is
gume 0:1f82672b8755 8597 available in the page zero*/
gume 0:1f82672b8755 8598 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 8599 /* Write the page zero*/
gume 0:1f82672b8755 8600 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 8601 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 8602 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 8603 /* Read the value of z-axis remap sign*/
gume 0:1f82672b8755 8604 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 8605 (p_bno055->dev_addr,
gume 0:1f82672b8755 8606 BNO055_REMAP_Z_SIGN_REG,
gume 0:1f82672b8755 8607 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 8608 *remap_z_sign_u8 =
gume 0:1f82672b8755 8609 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 8610 BNO055_REMAP_Z_SIGN);
gume 0:1f82672b8755 8611 } else {
gume 0:1f82672b8755 8612 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8613 }
gume 0:1f82672b8755 8614 }
gume 0:1f82672b8755 8615 return com_rslt;
gume 0:1f82672b8755 8616 }
gume 0:1f82672b8755 8617 /*!
gume 0:1f82672b8755 8618 * @brief This API used to write the z-axis remap
gume 0:1f82672b8755 8619 * sign from register from 0x42 bit 0
gume 0:1f82672b8755 8620 *
gume 0:1f82672b8755 8621 * @param remap_z_sign_u8 : The value of z-axis remap sign
gume 0:1f82672b8755 8622 *
gume 0:1f82672b8755 8623 * remap_z_sign_u8 | result
gume 0:1f82672b8755 8624 * ------------------- |--------------------
gume 0:1f82672b8755 8625 * 0X00 | BNO055_REMAP_AXIS_POSITIVE
gume 0:1f82672b8755 8626 * 0X01 | BNO055_REMAP_AXIS_NEGATIVE
gume 0:1f82672b8755 8627 *
gume 0:1f82672b8755 8628 * @return results of bus communication function
gume 0:1f82672b8755 8629 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 8630 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 8631 *
gume 0:1f82672b8755 8632 */
gume 0:1f82672b8755 8633 BNO055_RETURN_FUNCTION_TYPE bno055_set_remap_z_sign(
gume 0:1f82672b8755 8634 u8 remap_z_sign_u8)
gume 0:1f82672b8755 8635 {
gume 0:1f82672b8755 8636 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8637 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 8638 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 8639 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 8640 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 8641 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 8642 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 8643 } else {
gume 0:1f82672b8755 8644 /* The write operation effective only if the operation
gume 0:1f82672b8755 8645 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 8646 current operation mode and set the config mode */
gume 0:1f82672b8755 8647 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 8648 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 8649 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 8650 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 8651 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 8652 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 8653 /* Write the value of z-axis remap sign*/
gume 0:1f82672b8755 8654 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 8655 (p_bno055->dev_addr,
gume 0:1f82672b8755 8656 BNO055_REMAP_Z_SIGN_REG,
gume 0:1f82672b8755 8657 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 8658 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 8659 data_u8r =
gume 0:1f82672b8755 8660 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 8661 BNO055_REMAP_Z_SIGN,
gume 0:1f82672b8755 8662 remap_z_sign_u8);
gume 0:1f82672b8755 8663 com_rslt +=
gume 0:1f82672b8755 8664 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 8665 (p_bno055->dev_addr,
gume 0:1f82672b8755 8666 BNO055_REMAP_Z_SIGN_REG,
gume 0:1f82672b8755 8667 &data_u8r,
gume 0:1f82672b8755 8668 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 8669 }
gume 0:1f82672b8755 8670 } else {
gume 0:1f82672b8755 8671 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8672 }
gume 0:1f82672b8755 8673 } else {
gume 0:1f82672b8755 8674 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8675 }
gume 0:1f82672b8755 8676 }
gume 0:1f82672b8755 8677 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 8678 /* set the operation mode
gume 0:1f82672b8755 8679 of previous operation mode*/
gume 0:1f82672b8755 8680 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 8681 (prev_opmode_u8);
gume 0:1f82672b8755 8682 return com_rslt;
gume 0:1f82672b8755 8683 }
gume 0:1f82672b8755 8684 /*!
gume 0:1f82672b8755 8685 * @brief This API is used to read soft iron calibration matrix
gume 0:1f82672b8755 8686 * from the register 0x43 to 0x53 it is a 18 bytes of data
gume 0:1f82672b8755 8687 *
gume 0:1f82672b8755 8688 * @param sic_matrix : The value of soft iron calibration matrix
gume 0:1f82672b8755 8689 *
gume 0:1f82672b8755 8690 * sic_matrix | result
gume 0:1f82672b8755 8691 * --------------------|----------------------------------
gume 0:1f82672b8755 8692 * sic_0 | soft iron calibration matrix zero
gume 0:1f82672b8755 8693 * sic_1 | soft iron calibration matrix one
gume 0:1f82672b8755 8694 * sic_2 | soft iron calibration matrix two
gume 0:1f82672b8755 8695 * sic_3 | soft iron calibration matrix three
gume 0:1f82672b8755 8696 * sic_4 | soft iron calibration matrix four
gume 0:1f82672b8755 8697 * sic_5 | soft iron calibration matrix five
gume 0:1f82672b8755 8698 * sic_6 | soft iron calibration matrix six
gume 0:1f82672b8755 8699 * sic_7 | soft iron calibration matrix seven
gume 0:1f82672b8755 8700 * sic_8 | soft iron calibration matrix eight
gume 0:1f82672b8755 8701 *
gume 0:1f82672b8755 8702 *
gume 0:1f82672b8755 8703 * @return results of bus communication function
gume 0:1f82672b8755 8704 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 8705 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 8706 *
gume 0:1f82672b8755 8707 * @note : Each soft iron calibration matrix range from -32768 to +32767
gume 0:1f82672b8755 8708 */
gume 0:1f82672b8755 8709 BNO055_RETURN_FUNCTION_TYPE bno055_read_sic_matrix(
gume 0:1f82672b8755 8710 struct bno055_sic_matrix_t *sic_matrix)
gume 0:1f82672b8755 8711 {
gume 0:1f82672b8755 8712 /* Variable used to return value of
gume 0:1f82672b8755 8713 communication routine*/
gume 0:1f82672b8755 8714 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8715 /* Array holding the soft iron calibration matrix values
gume 0:1f82672b8755 8716 data_u8[BNO055_SOFT_IRON_CALIB_0_LSB] - sic_0->LSB
gume 0:1f82672b8755 8717 data_u8[BNO055_SOFT_IRON_CALIB_0_MSB] - sic_0->MSB
gume 0:1f82672b8755 8718 data_u8[BNO055_SOFT_IRON_CALIB_1_LSB] - sic_1->LSB
gume 0:1f82672b8755 8719 data_u8[BNO055_SOFT_IRON_CALIB_1_MSB] - sic_1->MSB
gume 0:1f82672b8755 8720 data_u8[BNO055_SOFT_IRON_CALIB_2_LSB] - sic_2->LSB
gume 0:1f82672b8755 8721 data_u8[BNO055_SOFT_IRON_CALIB_2_MSB] - sic_2->MSB
gume 0:1f82672b8755 8722 data_u8[BNO055_SOFT_IRON_CALIB_3_LSB] - sic_3->LSB
gume 0:1f82672b8755 8723 data_u8[BNO055_SOFT_IRON_CALIB_3_MSB] - sic_3->MSB
gume 0:1f82672b8755 8724 data_u8[BNO055_SOFT_IRON_CALIB_4_LSB] - sic_4->LSB
gume 0:1f82672b8755 8725 data_u8[BNO055_SOFT_IRON_CALIB_4_MSB] - sic_4->MSB
gume 0:1f82672b8755 8726 data_u8[BNO055_SOFT_IRON_CALIB_5_LSB] - sic_5->LSB
gume 0:1f82672b8755 8727 data_u8[BNO055_SOFT_IRON_CALIB_5_MSB] - sic_5->MSB
gume 0:1f82672b8755 8728 data_u8[BNO055_SOFT_IRON_CALIB_6_LSB] - sic_6->LSB
gume 0:1f82672b8755 8729 data_u8[BNO055_SOFT_IRON_CALIB_6_MSB] - sic_6->MSB
gume 0:1f82672b8755 8730 data_u8[BNO055_SOFT_IRON_CALIB_7_LSB] - sic_7->LSB
gume 0:1f82672b8755 8731 data_u8[BNO055_SOFT_IRON_CALIB_7_MSB] - sic_7->MSB
gume 0:1f82672b8755 8732 data_u8[BNO055_SOFT_IRON_CALIB_8_LSB] - sic_8->LSB
gume 0:1f82672b8755 8733 data_u8[BNO055_SOFT_IRON_CALIB_8_MSB] - sic_8->MSB
gume 0:1f82672b8755 8734 */
gume 0:1f82672b8755 8735 u8 data_u8[BNO055_SOFT_IRON_CALIBRATION_MATRIX_SIZE] = {
gume 0:1f82672b8755 8736 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 8737 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 8738 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 8739 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 8740 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 8741 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 8742 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 8743 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 8744 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 8745 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 8746 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 8747 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 8748 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 8749 } else {
gume 0:1f82672b8755 8750 /*condition check for page, soft iron calibration matrix is
gume 0:1f82672b8755 8751 available in the page zero*/
gume 0:1f82672b8755 8752 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 8753 /* Write the page zero*/
gume 0:1f82672b8755 8754 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 8755 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 8756 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 8757 /* Read soft iron calibration matrix value
gume 0:1f82672b8755 8758 it is eighteen bytes of data */
gume 0:1f82672b8755 8759 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 8760 (p_bno055->dev_addr,
gume 0:1f82672b8755 8761 BNO055_SIC_MATRIX_0_LSB_REG,
gume 0:1f82672b8755 8762 data_u8, BNO055_SOFT_IRON_CALIBRATION_MATRIX_SIZE);
gume 0:1f82672b8755 8763 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 8764 /*soft iron calibration matrix zero*/
gume 0:1f82672b8755 8765 data_u8[BNO055_SOFT_IRON_CALIB_0_LSB] =
gume 0:1f82672b8755 8766 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 8767 data_u8[BNO055_SOFT_IRON_CALIB_0_LSB],
gume 0:1f82672b8755 8768 BNO055_SIC_MATRIX_0_LSB);
gume 0:1f82672b8755 8769 data_u8[BNO055_SOFT_IRON_CALIB_0_MSB] =
gume 0:1f82672b8755 8770 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 8771 data_u8[BNO055_SOFT_IRON_CALIB_0_MSB],
gume 0:1f82672b8755 8772 BNO055_SIC_MATRIX_0_MSB);
gume 0:1f82672b8755 8773 sic_matrix->sic_0 = (s16)((((s32)
gume 0:1f82672b8755 8774 (s8)(data_u8[BNO055_SOFT_IRON_CALIB_0_MSB])) <<
gume 0:1f82672b8755 8775 (BNO055_SHIFT_EIGHT_BITS))
gume 0:1f82672b8755 8776 | (data_u8[BNO055_SOFT_IRON_CALIB_0_LSB]));
gume 0:1f82672b8755 8777
gume 0:1f82672b8755 8778 /*soft iron calibration matrix one*/
gume 0:1f82672b8755 8779 data_u8[BNO055_SOFT_IRON_CALIB_1_LSB] =
gume 0:1f82672b8755 8780 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 8781 data_u8[BNO055_SOFT_IRON_CALIB_1_LSB],
gume 0:1f82672b8755 8782 BNO055_SIC_MATRIX_1_LSB);
gume 0:1f82672b8755 8783 data_u8[BNO055_SOFT_IRON_CALIB_1_MSB] =
gume 0:1f82672b8755 8784 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 8785 data_u8[BNO055_SOFT_IRON_CALIB_1_MSB],
gume 0:1f82672b8755 8786 BNO055_SIC_MATRIX_1_MSB);
gume 0:1f82672b8755 8787 sic_matrix->sic_1 = (s16)((((s32)
gume 0:1f82672b8755 8788 (s8)(data_u8[BNO055_SOFT_IRON_CALIB_1_MSB])) <<
gume 0:1f82672b8755 8789 (BNO055_SHIFT_EIGHT_BITS))
gume 0:1f82672b8755 8790 | (data_u8[BNO055_SOFT_IRON_CALIB_1_LSB]));
gume 0:1f82672b8755 8791
gume 0:1f82672b8755 8792 /*soft iron calibration matrix two*/
gume 0:1f82672b8755 8793 data_u8[BNO055_SOFT_IRON_CALIB_2_LSB] =
gume 0:1f82672b8755 8794 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 8795 data_u8[BNO055_SOFT_IRON_CALIB_2_LSB],
gume 0:1f82672b8755 8796 BNO055_SIC_MATRIX_2_LSB);
gume 0:1f82672b8755 8797 data_u8[BNO055_SOFT_IRON_CALIB_2_MSB] =
gume 0:1f82672b8755 8798 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 8799 data_u8[BNO055_SOFT_IRON_CALIB_2_MSB],
gume 0:1f82672b8755 8800 BNO055_SIC_MATRIX_2_MSB);
gume 0:1f82672b8755 8801 sic_matrix->sic_2 = (s16)((((s32)
gume 0:1f82672b8755 8802 (s8)(data_u8[BNO055_SOFT_IRON_CALIB_2_MSB])) <<
gume 0:1f82672b8755 8803 (BNO055_SHIFT_EIGHT_BITS))
gume 0:1f82672b8755 8804 | (data_u8[BNO055_SOFT_IRON_CALIB_2_LSB]));
gume 0:1f82672b8755 8805
gume 0:1f82672b8755 8806 /*soft iron calibration matrix three*/
gume 0:1f82672b8755 8807 data_u8[BNO055_SOFT_IRON_CALIB_3_LSB] =
gume 0:1f82672b8755 8808 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 8809 data_u8[BNO055_SOFT_IRON_CALIB_3_LSB],
gume 0:1f82672b8755 8810 BNO055_SIC_MATRIX_3_LSB);
gume 0:1f82672b8755 8811 data_u8[BNO055_SOFT_IRON_CALIB_3_MSB] =
gume 0:1f82672b8755 8812 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 8813 data_u8[BNO055_SOFT_IRON_CALIB_3_MSB],
gume 0:1f82672b8755 8814 BNO055_SIC_MATRIX_3_LSB);
gume 0:1f82672b8755 8815 sic_matrix->sic_3 = (s16)((((s32)
gume 0:1f82672b8755 8816 (s8)(data_u8[BNO055_SOFT_IRON_CALIB_3_MSB])) <<
gume 0:1f82672b8755 8817 (BNO055_SHIFT_EIGHT_BITS)) |
gume 0:1f82672b8755 8818 (data_u8[BNO055_SOFT_IRON_CALIB_3_LSB]));
gume 0:1f82672b8755 8819
gume 0:1f82672b8755 8820 /*soft iron calibration matrix four*/
gume 0:1f82672b8755 8821 data_u8[BNO055_SOFT_IRON_CALIB_4_LSB] =
gume 0:1f82672b8755 8822 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 8823 data_u8[BNO055_SOFT_IRON_CALIB_4_LSB],
gume 0:1f82672b8755 8824 BNO055_SIC_MATRIX_4_LSB);
gume 0:1f82672b8755 8825 data_u8[BNO055_SOFT_IRON_CALIB_4_MSB] =
gume 0:1f82672b8755 8826 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 8827 data_u8[BNO055_SOFT_IRON_CALIB_4_MSB],
gume 0:1f82672b8755 8828 BNO055_SIC_MATRIX_4_LSB);
gume 0:1f82672b8755 8829 sic_matrix->sic_4 = (s16)((((s32)
gume 0:1f82672b8755 8830 (s8)(data_u8[BNO055_SOFT_IRON_CALIB_4_MSB])) <<
gume 0:1f82672b8755 8831 (BNO055_SHIFT_EIGHT_BITS)) |
gume 0:1f82672b8755 8832 (data_u8[BNO055_SOFT_IRON_CALIB_4_LSB]));
gume 0:1f82672b8755 8833
gume 0:1f82672b8755 8834 /*soft iron calibration matrix five*/
gume 0:1f82672b8755 8835 data_u8[BNO055_SOFT_IRON_CALIB_5_LSB] =
gume 0:1f82672b8755 8836 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 8837 data_u8[BNO055_SOFT_IRON_CALIB_5_LSB],
gume 0:1f82672b8755 8838 BNO055_SIC_MATRIX_5_LSB);
gume 0:1f82672b8755 8839 data_u8[BNO055_SOFT_IRON_CALIB_5_MSB] =
gume 0:1f82672b8755 8840 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 8841 data_u8[BNO055_SOFT_IRON_CALIB_5_MSB],
gume 0:1f82672b8755 8842 BNO055_SIC_MATRIX_5_LSB);
gume 0:1f82672b8755 8843 sic_matrix->sic_5 = (s16)((((s32)
gume 0:1f82672b8755 8844 (s8)(data_u8[BNO055_SOFT_IRON_CALIB_5_MSB])) <<
gume 0:1f82672b8755 8845 (BNO055_SHIFT_EIGHT_BITS)) |
gume 0:1f82672b8755 8846 (data_u8[BNO055_SOFT_IRON_CALIB_5_LSB]));
gume 0:1f82672b8755 8847
gume 0:1f82672b8755 8848 /*soft iron calibration matrix six*/
gume 0:1f82672b8755 8849 data_u8[BNO055_SOFT_IRON_CALIB_6_LSB] =
gume 0:1f82672b8755 8850 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 8851 data_u8[BNO055_SOFT_IRON_CALIB_6_LSB],
gume 0:1f82672b8755 8852 BNO055_SIC_MATRIX_6_LSB);
gume 0:1f82672b8755 8853 data_u8[BNO055_SOFT_IRON_CALIB_6_MSB] =
gume 0:1f82672b8755 8854 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 8855 data_u8[BNO055_SOFT_IRON_CALIB_6_MSB],
gume 0:1f82672b8755 8856 BNO055_SIC_MATRIX_6_LSB);
gume 0:1f82672b8755 8857 sic_matrix->sic_6 = (s16)((((s32)
gume 0:1f82672b8755 8858 (s8)(data_u8[BNO055_SOFT_IRON_CALIB_6_MSB])) <<
gume 0:1f82672b8755 8859 (BNO055_SHIFT_EIGHT_BITS)) |
gume 0:1f82672b8755 8860 (data_u8[BNO055_SOFT_IRON_CALIB_6_LSB]));
gume 0:1f82672b8755 8861
gume 0:1f82672b8755 8862 /*soft iron calibration matrix seven*/
gume 0:1f82672b8755 8863 data_u8[BNO055_SOFT_IRON_CALIB_7_LSB] =
gume 0:1f82672b8755 8864 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 8865 data_u8[BNO055_SOFT_IRON_CALIB_7_LSB],
gume 0:1f82672b8755 8866 BNO055_SIC_MATRIX_7_LSB);
gume 0:1f82672b8755 8867 data_u8[BNO055_SOFT_IRON_CALIB_7_MSB] =
gume 0:1f82672b8755 8868 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 8869 data_u8[BNO055_SOFT_IRON_CALIB_7_MSB],
gume 0:1f82672b8755 8870 BNO055_SIC_MATRIX_7_LSB);
gume 0:1f82672b8755 8871 sic_matrix->sic_7 = (s16)((((s32)
gume 0:1f82672b8755 8872 (s8)(data_u8[BNO055_SOFT_IRON_CALIB_7_MSB])) <<
gume 0:1f82672b8755 8873 (BNO055_SHIFT_EIGHT_BITS)) |
gume 0:1f82672b8755 8874 (data_u8[BNO055_SOFT_IRON_CALIB_7_LSB]));
gume 0:1f82672b8755 8875
gume 0:1f82672b8755 8876 /*soft iron calibration matrix eight*/
gume 0:1f82672b8755 8877 data_u8[BNO055_SOFT_IRON_CALIB_8_LSB] =
gume 0:1f82672b8755 8878 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 8879 data_u8[BNO055_SOFT_IRON_CALIB_8_LSB],
gume 0:1f82672b8755 8880 BNO055_SIC_MATRIX_8_LSB);
gume 0:1f82672b8755 8881 data_u8[BNO055_SOFT_IRON_CALIB_8_MSB] =
gume 0:1f82672b8755 8882 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 8883 data_u8[BNO055_SOFT_IRON_CALIB_8_MSB],
gume 0:1f82672b8755 8884 BNO055_SIC_MATRIX_8_LSB);
gume 0:1f82672b8755 8885 sic_matrix->sic_8 = (s16)((((s32)
gume 0:1f82672b8755 8886 (s8)(data_u8[BNO055_SOFT_IRON_CALIB_8_MSB])) <<
gume 0:1f82672b8755 8887 (BNO055_SHIFT_EIGHT_BITS)) |
gume 0:1f82672b8755 8888 (data_u8[BNO055_SOFT_IRON_CALIB_8_LSB]));
gume 0:1f82672b8755 8889 } else {
gume 0:1f82672b8755 8890 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8891 }
gume 0:1f82672b8755 8892 } else {
gume 0:1f82672b8755 8893 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8894 }
gume 0:1f82672b8755 8895 }
gume 0:1f82672b8755 8896 return com_rslt;
gume 0:1f82672b8755 8897 }
gume 0:1f82672b8755 8898 /*!
gume 0:1f82672b8755 8899 * @brief This API is used to write soft iron calibration matrix
gume 0:1f82672b8755 8900 * from the register 0x43 to 0x53 it is a 18 bytes of data
gume 0:1f82672b8755 8901 *
gume 0:1f82672b8755 8902 * @param sic_matrix : The value of soft iron calibration matrix
gume 0:1f82672b8755 8903 *
gume 0:1f82672b8755 8904 * sic_matrix | result
gume 0:1f82672b8755 8905 * --------------------|----------------------------------
gume 0:1f82672b8755 8906 * sic_0 | soft iron calibration matrix zero
gume 0:1f82672b8755 8907 * sic_1 | soft iron calibration matrix one
gume 0:1f82672b8755 8908 * sic_2 | soft iron calibration matrix two
gume 0:1f82672b8755 8909 * sic_3 | soft iron calibration matrix three
gume 0:1f82672b8755 8910 * sic_4 | soft iron calibration matrix four
gume 0:1f82672b8755 8911 * sic_5 | soft iron calibration matrix five
gume 0:1f82672b8755 8912 * sic_6 | soft iron calibration matrix six
gume 0:1f82672b8755 8913 * sic_7 | soft iron calibration matrix seven
gume 0:1f82672b8755 8914 * sic_8 | soft iron calibration matrix eight
gume 0:1f82672b8755 8915 *
gume 0:1f82672b8755 8916 *
gume 0:1f82672b8755 8917 * @return results of bus communication function
gume 0:1f82672b8755 8918 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 8919 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 8920 *
gume 0:1f82672b8755 8921 * @note : Each soft iron calibration matrix range from -32768 to +32767
gume 0:1f82672b8755 8922 */
gume 0:1f82672b8755 8923 BNO055_RETURN_FUNCTION_TYPE bno055_write_sic_matrix(
gume 0:1f82672b8755 8924 struct bno055_sic_matrix_t *sic_matrix)
gume 0:1f82672b8755 8925 {
gume 0:1f82672b8755 8926 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 8927 u8 data1_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 8928 u8 data2_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 8929 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 8930 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 8931 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 8932 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 8933 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 8934 } else {
gume 0:1f82672b8755 8935 /* The write operation effective only if the operation
gume 0:1f82672b8755 8936 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 8937 current operation mode and set the config mode */
gume 0:1f82672b8755 8938 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 8939 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 8940 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 8941 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 8942 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 8943 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 8944 /* write soft iron calibration
gume 0:1f82672b8755 8945 matrix zero value*/
gume 0:1f82672b8755 8946 com_rslt =
gume 0:1f82672b8755 8947 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 8948 (p_bno055->dev_addr,
gume 0:1f82672b8755 8949 BNO055_SIC_MATRIX_0_LSB_REG,
gume 0:1f82672b8755 8950 &data2_u8r,
gume 0:1f82672b8755 8951 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 8952 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 8953 data1_u8r = ((s8)
gume 0:1f82672b8755 8954 (sic_matrix->sic_0
gume 0:1f82672b8755 8955 & BNO055_SIC_HEX_0_0_F_F_DATA));
gume 0:1f82672b8755 8956 data2_u8r =
gume 0:1f82672b8755 8957 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 8958 BNO055_SIC_MATRIX_0_LSB,
gume 0:1f82672b8755 8959 data1_u8r);
gume 0:1f82672b8755 8960 com_rslt +=
gume 0:1f82672b8755 8961 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 8962 (p_bno055->dev_addr,
gume 0:1f82672b8755 8963 BNO055_SIC_MATRIX_0_LSB_REG,
gume 0:1f82672b8755 8964 &data2_u8r,
gume 0:1f82672b8755 8965 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 8966 }
gume 0:1f82672b8755 8967
gume 0:1f82672b8755 8968 com_rslt +=
gume 0:1f82672b8755 8969 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 8970 (p_bno055->dev_addr,
gume 0:1f82672b8755 8971 BNO055_SIC_MATRIX_0_MSB_REG,
gume 0:1f82672b8755 8972 &data2_u8r,
gume 0:1f82672b8755 8973 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 8974 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 8975 data1_u8r = ((s8)
gume 0:1f82672b8755 8976 (sic_matrix->sic_0 >>
gume 0:1f82672b8755 8977 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 8978 & BNO055_SIC_HEX_0_0_F_F_DATA);
gume 0:1f82672b8755 8979 data2_u8r =
gume 0:1f82672b8755 8980 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 8981 BNO055_SIC_MATRIX_0_MSB,
gume 0:1f82672b8755 8982 data1_u8r);
gume 0:1f82672b8755 8983 com_rslt +=
gume 0:1f82672b8755 8984 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 8985 (p_bno055->dev_addr,
gume 0:1f82672b8755 8986 BNO055_SIC_MATRIX_0_MSB_REG,
gume 0:1f82672b8755 8987 &data2_u8r,
gume 0:1f82672b8755 8988 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 8989 }
gume 0:1f82672b8755 8990
gume 0:1f82672b8755 8991 /* write soft iron calibration
gume 0:1f82672b8755 8992 matrix one value*/
gume 0:1f82672b8755 8993 com_rslt +=
gume 0:1f82672b8755 8994 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 8995 (p_bno055->dev_addr,
gume 0:1f82672b8755 8996 BNO055_SIC_MATRIX_1_LSB_REG,
gume 0:1f82672b8755 8997 &data2_u8r,
gume 0:1f82672b8755 8998 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 8999 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9000 data1_u8r = ((s8)
gume 0:1f82672b8755 9001 (sic_matrix->sic_1
gume 0:1f82672b8755 9002 & BNO055_SIC_HEX_0_0_F_F_DATA));
gume 0:1f82672b8755 9003 data2_u8r =
gume 0:1f82672b8755 9004 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 9005 BNO055_SIC_MATRIX_1_LSB,
gume 0:1f82672b8755 9006 data1_u8r);
gume 0:1f82672b8755 9007 com_rslt +=
gume 0:1f82672b8755 9008 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 9009 (p_bno055->dev_addr,
gume 0:1f82672b8755 9010 BNO055_SIC_MATRIX_1_LSB_REG,
gume 0:1f82672b8755 9011 &data2_u8r,
gume 0:1f82672b8755 9012 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9013 }
gume 0:1f82672b8755 9014
gume 0:1f82672b8755 9015 com_rslt +=
gume 0:1f82672b8755 9016 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9017 (p_bno055->dev_addr,
gume 0:1f82672b8755 9018 BNO055_SIC_MATRIX_1_MSB_REG,
gume 0:1f82672b8755 9019 &data2_u8r,
gume 0:1f82672b8755 9020 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9021 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9022 data1_u8r = ((s8)
gume 0:1f82672b8755 9023 (sic_matrix->sic_1 >>
gume 0:1f82672b8755 9024 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 9025 & BNO055_SIC_HEX_0_0_F_F_DATA);
gume 0:1f82672b8755 9026 data2_u8r =
gume 0:1f82672b8755 9027 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 9028 BNO055_SIC_MATRIX_1_MSB,
gume 0:1f82672b8755 9029 data1_u8r);
gume 0:1f82672b8755 9030 com_rslt +=
gume 0:1f82672b8755 9031 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 9032 (p_bno055->dev_addr,
gume 0:1f82672b8755 9033 BNO055_SIC_MATRIX_1_MSB_REG,
gume 0:1f82672b8755 9034 &data2_u8r,
gume 0:1f82672b8755 9035 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9036 }
gume 0:1f82672b8755 9037
gume 0:1f82672b8755 9038 /* write soft iron calibration
gume 0:1f82672b8755 9039 matrix two value*/
gume 0:1f82672b8755 9040 com_rslt +=
gume 0:1f82672b8755 9041 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9042 (p_bno055->dev_addr,
gume 0:1f82672b8755 9043 BNO055_SIC_MATRIX_2_LSB_REG,
gume 0:1f82672b8755 9044 &data2_u8r,
gume 0:1f82672b8755 9045 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9046 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9047 data1_u8r = ((s8)
gume 0:1f82672b8755 9048 (sic_matrix->sic_2
gume 0:1f82672b8755 9049 & BNO055_SIC_HEX_0_0_F_F_DATA));
gume 0:1f82672b8755 9050 data2_u8r =
gume 0:1f82672b8755 9051 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 9052 BNO055_SIC_MATRIX_2_LSB,
gume 0:1f82672b8755 9053 data1_u8r);
gume 0:1f82672b8755 9054 com_rslt +=
gume 0:1f82672b8755 9055 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 9056 (p_bno055->dev_addr,
gume 0:1f82672b8755 9057 BNO055_SIC_MATRIX_2_LSB_REG,
gume 0:1f82672b8755 9058 &data2_u8r,
gume 0:1f82672b8755 9059 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9060 }
gume 0:1f82672b8755 9061
gume 0:1f82672b8755 9062 com_rslt +=
gume 0:1f82672b8755 9063 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9064 (p_bno055->dev_addr,
gume 0:1f82672b8755 9065 BNO055_SIC_MATRIX_2_MSB_REG,
gume 0:1f82672b8755 9066 &data2_u8r,
gume 0:1f82672b8755 9067 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9068 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9069 data1_u8r = ((s8)
gume 0:1f82672b8755 9070 (sic_matrix->sic_2 >>
gume 0:1f82672b8755 9071 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 9072 & BNO055_SIC_HEX_0_0_F_F_DATA);
gume 0:1f82672b8755 9073 data2_u8r =
gume 0:1f82672b8755 9074 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 9075 BNO055_SIC_MATRIX_2_MSB,
gume 0:1f82672b8755 9076 data1_u8r);
gume 0:1f82672b8755 9077 com_rslt +=
gume 0:1f82672b8755 9078 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 9079 (p_bno055->dev_addr,
gume 0:1f82672b8755 9080 BNO055_SIC_MATRIX_2_MSB_REG,
gume 0:1f82672b8755 9081 &data2_u8r,
gume 0:1f82672b8755 9082 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9083 }
gume 0:1f82672b8755 9084
gume 0:1f82672b8755 9085 /* write soft iron calibration
gume 0:1f82672b8755 9086 matrix three value*/
gume 0:1f82672b8755 9087 com_rslt +=
gume 0:1f82672b8755 9088 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9089 (p_bno055->dev_addr,
gume 0:1f82672b8755 9090 BNO055_SIC_MATRIX_3_LSB_REG,
gume 0:1f82672b8755 9091 &data2_u8r,
gume 0:1f82672b8755 9092 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9093 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9094 data1_u8r = ((s8)
gume 0:1f82672b8755 9095 (sic_matrix->sic_3
gume 0:1f82672b8755 9096 & BNO055_SIC_HEX_0_0_F_F_DATA));
gume 0:1f82672b8755 9097 data2_u8r =
gume 0:1f82672b8755 9098 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 9099 BNO055_SIC_MATRIX_3_LSB,
gume 0:1f82672b8755 9100 data1_u8r);
gume 0:1f82672b8755 9101 com_rslt +=
gume 0:1f82672b8755 9102 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 9103 (p_bno055->dev_addr,
gume 0:1f82672b8755 9104 BNO055_SIC_MATRIX_3_LSB_REG,
gume 0:1f82672b8755 9105 &data2_u8r,
gume 0:1f82672b8755 9106 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9107 }
gume 0:1f82672b8755 9108
gume 0:1f82672b8755 9109 com_rslt +=
gume 0:1f82672b8755 9110 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9111 (p_bno055->dev_addr,
gume 0:1f82672b8755 9112 BNO055_SIC_MATRIX_3_MSB_REG,
gume 0:1f82672b8755 9113 &data2_u8r,
gume 0:1f82672b8755 9114 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9115 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9116 data1_u8r = ((s8)
gume 0:1f82672b8755 9117 (sic_matrix->sic_3 >>
gume 0:1f82672b8755 9118 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 9119 & BNO055_SIC_HEX_0_0_F_F_DATA);
gume 0:1f82672b8755 9120 data2_u8r =
gume 0:1f82672b8755 9121 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 9122 BNO055_SIC_MATRIX_3_MSB,
gume 0:1f82672b8755 9123 data1_u8r);
gume 0:1f82672b8755 9124 com_rslt +=
gume 0:1f82672b8755 9125 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 9126 (p_bno055->dev_addr,
gume 0:1f82672b8755 9127 BNO055_SIC_MATRIX_3_MSB_REG,
gume 0:1f82672b8755 9128 &data2_u8r,
gume 0:1f82672b8755 9129 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9130 }
gume 0:1f82672b8755 9131
gume 0:1f82672b8755 9132 /* write soft iron calibration
gume 0:1f82672b8755 9133 matrix four value*/
gume 0:1f82672b8755 9134 com_rslt +=
gume 0:1f82672b8755 9135 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9136 (p_bno055->dev_addr,
gume 0:1f82672b8755 9137 BNO055_SIC_MATRIX_4_LSB_REG,
gume 0:1f82672b8755 9138 &data2_u8r,
gume 0:1f82672b8755 9139 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9140 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9141 data1_u8r = ((s8)
gume 0:1f82672b8755 9142 (sic_matrix->sic_4
gume 0:1f82672b8755 9143 & BNO055_SIC_HEX_0_0_F_F_DATA));
gume 0:1f82672b8755 9144 data2_u8r =
gume 0:1f82672b8755 9145 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 9146 BNO055_SIC_MATRIX_4_LSB,
gume 0:1f82672b8755 9147 data1_u8r);
gume 0:1f82672b8755 9148 com_rslt +=
gume 0:1f82672b8755 9149 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 9150 (p_bno055->dev_addr,
gume 0:1f82672b8755 9151 BNO055_SIC_MATRIX_4_LSB_REG,
gume 0:1f82672b8755 9152 &data2_u8r,
gume 0:1f82672b8755 9153 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9154 }
gume 0:1f82672b8755 9155
gume 0:1f82672b8755 9156 com_rslt +=
gume 0:1f82672b8755 9157 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9158 (p_bno055->dev_addr,
gume 0:1f82672b8755 9159 BNO055_SIC_MATRIX_4_MSB_REG,
gume 0:1f82672b8755 9160 &data2_u8r,
gume 0:1f82672b8755 9161 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9162 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9163 data1_u8r = ((s8)
gume 0:1f82672b8755 9164 (sic_matrix->sic_4 >>
gume 0:1f82672b8755 9165 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 9166 & BNO055_SIC_HEX_0_0_F_F_DATA);
gume 0:1f82672b8755 9167 data2_u8r =
gume 0:1f82672b8755 9168 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 9169 BNO055_SIC_MATRIX_4_MSB,
gume 0:1f82672b8755 9170 data1_u8r);
gume 0:1f82672b8755 9171 com_rslt +=
gume 0:1f82672b8755 9172 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 9173 (p_bno055->dev_addr,
gume 0:1f82672b8755 9174 BNO055_SIC_MATRIX_4_MSB_REG,
gume 0:1f82672b8755 9175 &data2_u8r,
gume 0:1f82672b8755 9176 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9177 }
gume 0:1f82672b8755 9178
gume 0:1f82672b8755 9179 /* write soft iron calibration
gume 0:1f82672b8755 9180 matrix five value*/
gume 0:1f82672b8755 9181 com_rslt +=
gume 0:1f82672b8755 9182 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9183 (p_bno055->dev_addr,
gume 0:1f82672b8755 9184 BNO055_SIC_MATRIX_5_LSB_REG,
gume 0:1f82672b8755 9185 &data2_u8r,
gume 0:1f82672b8755 9186 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9187 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9188 data1_u8r = ((s8)
gume 0:1f82672b8755 9189 (sic_matrix->sic_5
gume 0:1f82672b8755 9190 & BNO055_SIC_HEX_0_0_F_F_DATA));
gume 0:1f82672b8755 9191 data2_u8r =
gume 0:1f82672b8755 9192 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 9193 BNO055_SIC_MATRIX_5_LSB,
gume 0:1f82672b8755 9194 data1_u8r);
gume 0:1f82672b8755 9195 com_rslt +=
gume 0:1f82672b8755 9196 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 9197 (p_bno055->dev_addr,
gume 0:1f82672b8755 9198 BNO055_SIC_MATRIX_5_LSB_REG,
gume 0:1f82672b8755 9199 &data2_u8r,
gume 0:1f82672b8755 9200 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9201 }
gume 0:1f82672b8755 9202
gume 0:1f82672b8755 9203 com_rslt +=
gume 0:1f82672b8755 9204 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9205 (p_bno055->dev_addr,
gume 0:1f82672b8755 9206 BNO055_SIC_MATRIX_5_MSB_REG,
gume 0:1f82672b8755 9207 &data2_u8r,
gume 0:1f82672b8755 9208 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9209 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9210 data1_u8r = ((s8)
gume 0:1f82672b8755 9211 (sic_matrix->sic_5 >>
gume 0:1f82672b8755 9212 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 9213 & BNO055_SIC_HEX_0_0_F_F_DATA);
gume 0:1f82672b8755 9214 data2_u8r =
gume 0:1f82672b8755 9215 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 9216 BNO055_SIC_MATRIX_5_MSB,
gume 0:1f82672b8755 9217 data1_u8r);
gume 0:1f82672b8755 9218 com_rslt +=
gume 0:1f82672b8755 9219 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 9220 (p_bno055->dev_addr,
gume 0:1f82672b8755 9221 BNO055_SIC_MATRIX_5_MSB_REG,
gume 0:1f82672b8755 9222 &data2_u8r,
gume 0:1f82672b8755 9223 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9224 }
gume 0:1f82672b8755 9225
gume 0:1f82672b8755 9226 /* write soft iron calibration
gume 0:1f82672b8755 9227 matrix six value*/
gume 0:1f82672b8755 9228 com_rslt +=
gume 0:1f82672b8755 9229 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9230 (p_bno055->dev_addr,
gume 0:1f82672b8755 9231 BNO055_SIC_MATRIX_6_LSB_REG,
gume 0:1f82672b8755 9232 &data2_u8r,
gume 0:1f82672b8755 9233 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9234 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9235 data1_u8r = ((s8)
gume 0:1f82672b8755 9236 (sic_matrix->sic_6
gume 0:1f82672b8755 9237 & BNO055_SIC_HEX_0_0_F_F_DATA));
gume 0:1f82672b8755 9238 data2_u8r =
gume 0:1f82672b8755 9239 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 9240 BNO055_SIC_MATRIX_6_LSB,
gume 0:1f82672b8755 9241 data1_u8r);
gume 0:1f82672b8755 9242 com_rslt +=
gume 0:1f82672b8755 9243 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 9244 (p_bno055->dev_addr,
gume 0:1f82672b8755 9245 BNO055_SIC_MATRIX_6_LSB_REG,
gume 0:1f82672b8755 9246 &data2_u8r,
gume 0:1f82672b8755 9247 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9248 }
gume 0:1f82672b8755 9249
gume 0:1f82672b8755 9250 com_rslt +=
gume 0:1f82672b8755 9251 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9252 (p_bno055->dev_addr,
gume 0:1f82672b8755 9253 BNO055_SIC_MATRIX_6_MSB_REG,
gume 0:1f82672b8755 9254 &data2_u8r,
gume 0:1f82672b8755 9255 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9256 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9257 data1_u8r = ((s8)
gume 0:1f82672b8755 9258 (sic_matrix->sic_6 >>
gume 0:1f82672b8755 9259 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 9260 & BNO055_SIC_HEX_0_0_F_F_DATA);
gume 0:1f82672b8755 9261 data2_u8r =
gume 0:1f82672b8755 9262 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 9263 BNO055_SIC_MATRIX_6_MSB,
gume 0:1f82672b8755 9264 data1_u8r);
gume 0:1f82672b8755 9265 com_rslt +=
gume 0:1f82672b8755 9266 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 9267 (p_bno055->dev_addr,
gume 0:1f82672b8755 9268 BNO055_SIC_MATRIX_6_MSB_REG,
gume 0:1f82672b8755 9269 &data2_u8r,
gume 0:1f82672b8755 9270 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9271 }
gume 0:1f82672b8755 9272
gume 0:1f82672b8755 9273 /* write soft iron calibration
gume 0:1f82672b8755 9274 matrix seven value*/
gume 0:1f82672b8755 9275 com_rslt +=
gume 0:1f82672b8755 9276 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9277 (p_bno055->dev_addr,
gume 0:1f82672b8755 9278 BNO055_SIC_MATRIX_7_LSB_REG,
gume 0:1f82672b8755 9279 &data2_u8r,
gume 0:1f82672b8755 9280 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9281 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9282 data1_u8r = ((s8)
gume 0:1f82672b8755 9283 (sic_matrix->sic_7
gume 0:1f82672b8755 9284 & BNO055_SIC_HEX_0_0_F_F_DATA));
gume 0:1f82672b8755 9285 data2_u8r =
gume 0:1f82672b8755 9286 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 9287 BNO055_SIC_MATRIX_7_LSB,
gume 0:1f82672b8755 9288 data1_u8r);
gume 0:1f82672b8755 9289 com_rslt +=
gume 0:1f82672b8755 9290 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 9291 (p_bno055->dev_addr,
gume 0:1f82672b8755 9292 BNO055_SIC_MATRIX_7_LSB_REG,
gume 0:1f82672b8755 9293 &data2_u8r,
gume 0:1f82672b8755 9294 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9295 }
gume 0:1f82672b8755 9296
gume 0:1f82672b8755 9297 com_rslt +=
gume 0:1f82672b8755 9298 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9299 (p_bno055->dev_addr,
gume 0:1f82672b8755 9300 BNO055_SIC_MATRIX_7_MSB_REG,
gume 0:1f82672b8755 9301 &data2_u8r,
gume 0:1f82672b8755 9302 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9303 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9304 data1_u8r = ((s8)
gume 0:1f82672b8755 9305 (sic_matrix->sic_7 >>
gume 0:1f82672b8755 9306 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 9307 & BNO055_SIC_HEX_0_0_F_F_DATA);
gume 0:1f82672b8755 9308 data2_u8r =
gume 0:1f82672b8755 9309 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 9310 BNO055_SIC_MATRIX_7_MSB,
gume 0:1f82672b8755 9311 data1_u8r);
gume 0:1f82672b8755 9312 com_rslt +=
gume 0:1f82672b8755 9313 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 9314 (p_bno055->dev_addr,
gume 0:1f82672b8755 9315 BNO055_SIC_MATRIX_7_MSB_REG,
gume 0:1f82672b8755 9316 &data2_u8r,
gume 0:1f82672b8755 9317 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9318 }
gume 0:1f82672b8755 9319
gume 0:1f82672b8755 9320 /* write soft iron calibration
gume 0:1f82672b8755 9321 matrix eight value*/
gume 0:1f82672b8755 9322 com_rslt +=
gume 0:1f82672b8755 9323 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9324 (p_bno055->dev_addr,
gume 0:1f82672b8755 9325 BNO055_SIC_MATRIX_8_LSB_REG,
gume 0:1f82672b8755 9326 &data2_u8r,
gume 0:1f82672b8755 9327 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9328 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9329 data1_u8r = ((s8)
gume 0:1f82672b8755 9330 (sic_matrix->sic_8
gume 0:1f82672b8755 9331 & BNO055_SIC_HEX_0_0_F_F_DATA));
gume 0:1f82672b8755 9332 data2_u8r =
gume 0:1f82672b8755 9333 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 9334 BNO055_SIC_MATRIX_8_LSB,
gume 0:1f82672b8755 9335 data1_u8r);
gume 0:1f82672b8755 9336 com_rslt +=
gume 0:1f82672b8755 9337 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 9338 (p_bno055->dev_addr,
gume 0:1f82672b8755 9339 BNO055_SIC_MATRIX_8_LSB_REG,
gume 0:1f82672b8755 9340 &data2_u8r,
gume 0:1f82672b8755 9341 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9342 }
gume 0:1f82672b8755 9343
gume 0:1f82672b8755 9344 com_rslt +=
gume 0:1f82672b8755 9345 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9346 (p_bno055->dev_addr,
gume 0:1f82672b8755 9347 BNO055_SIC_MATRIX_8_MSB_REG,
gume 0:1f82672b8755 9348 &data2_u8r,
gume 0:1f82672b8755 9349 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9350 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9351 data1_u8r = ((s8)
gume 0:1f82672b8755 9352 (sic_matrix->sic_8 >>
gume 0:1f82672b8755 9353 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 9354 & BNO055_SIC_HEX_0_0_F_F_DATA);
gume 0:1f82672b8755 9355 data2_u8r =
gume 0:1f82672b8755 9356 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 9357 BNO055_SIC_MATRIX_8_MSB,
gume 0:1f82672b8755 9358 data1_u8r);
gume 0:1f82672b8755 9359 com_rslt +=
gume 0:1f82672b8755 9360 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 9361 (p_bno055->dev_addr,
gume 0:1f82672b8755 9362 BNO055_SIC_MATRIX_8_MSB_REG,
gume 0:1f82672b8755 9363 &data2_u8r,
gume 0:1f82672b8755 9364 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9365 }
gume 0:1f82672b8755 9366 } else {
gume 0:1f82672b8755 9367 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 9368 }
gume 0:1f82672b8755 9369 } else {
gume 0:1f82672b8755 9370 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 9371 }
gume 0:1f82672b8755 9372 }
gume 0:1f82672b8755 9373 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 9374 /* set the operation mode
gume 0:1f82672b8755 9375 of previous operation mode*/
gume 0:1f82672b8755 9376 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 9377 (prev_opmode_u8);
gume 0:1f82672b8755 9378 return com_rslt;
gume 0:1f82672b8755 9379 }
gume 0:1f82672b8755 9380 /*!
gume 0:1f82672b8755 9381 * @brief This API is used to read accel offset and accel radius
gume 0:1f82672b8755 9382 * offset form register 0x55 to 0x5A and radius form 0x67 and 0x68
gume 0:1f82672b8755 9383 *
gume 0:1f82672b8755 9384 * @param accel_offset : The value of accel offset and radius
gume 0:1f82672b8755 9385 *
gume 0:1f82672b8755 9386 * bno055_accel_offset_t | result
gume 0:1f82672b8755 9387 * ------------------- | ----------------
gume 0:1f82672b8755 9388 * x | accel offset x
gume 0:1f82672b8755 9389 * y | accel offset y
gume 0:1f82672b8755 9390 * z | accel offset z
gume 0:1f82672b8755 9391 * r | accel offset r
gume 0:1f82672b8755 9392 *
gume 0:1f82672b8755 9393 *
gume 0:1f82672b8755 9394 * @return results of bus communication function
gume 0:1f82672b8755 9395 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 9396 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 9397 *
gume 0:1f82672b8755 9398 * @note The range of the accel offset varies based on
gume 0:1f82672b8755 9399 * the G-range of accel sensor.
gume 0:1f82672b8755 9400 *
gume 0:1f82672b8755 9401 * accel G range | offset range
gume 0:1f82672b8755 9402 * --------------- | --------------
gume 0:1f82672b8755 9403 * BNO055_ACCEL_RANGE_2G | +/-2000
gume 0:1f82672b8755 9404 * BNO055_ACCEL_RANGE_4G | +/-4000
gume 0:1f82672b8755 9405 * BNO055_ACCEL_RANGE_8G | +/-8000
gume 0:1f82672b8755 9406 * BNO055_ACCEL_RANGE_16G | +/-16000
gume 0:1f82672b8755 9407 *
gume 0:1f82672b8755 9408 * accel G range can be configured by using the
gume 0:1f82672b8755 9409 * bno055_set_accel_range() API
gume 0:1f82672b8755 9410 */
gume 0:1f82672b8755 9411 BNO055_RETURN_FUNCTION_TYPE bno055_read_accel_offset(
gume 0:1f82672b8755 9412 struct bno055_accel_offset_t *accel_offset)
gume 0:1f82672b8755 9413 {
gume 0:1f82672b8755 9414 /* Variable used to return value of
gume 0:1f82672b8755 9415 communication routine*/
gume 0:1f82672b8755 9416 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 9417 /* Array holding the accel offset values
gume 0:1f82672b8755 9418 data_u8[BNO055_SENSOR_OFFSET_DATA_X_LSB] - offset x->LSB
gume 0:1f82672b8755 9419 data_u8[BNO055_SENSOR_OFFSET_DATA_X_MSB] - offset x->MSB
gume 0:1f82672b8755 9420 data_u8[BNO055_SENSOR_OFFSET_DATA_Y_LSB] - offset y->LSB
gume 0:1f82672b8755 9421 data_u8[BNO055_SENSOR_OFFSET_DATA_Y_MSB] - offset y->MSB
gume 0:1f82672b8755 9422 data_u8[BNO055_SENSOR_OFFSET_DATA_Z_LSB] - offset z->LSB
gume 0:1f82672b8755 9423 data_u8[BNO055_SENSOR_OFFSET_DATA_Z_MSB] - offset z->MSB
gume 0:1f82672b8755 9424 */
gume 0:1f82672b8755 9425 u8 data_u8[BNO055_ACCEL_OFFSET_ARRAY] = {
gume 0:1f82672b8755 9426 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 9427 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 9428 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 9429 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 9430 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 9431 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 9432 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 9433 } else {
gume 0:1f82672b8755 9434 /*condition check for page, accel offset is
gume 0:1f82672b8755 9435 available in the page zero*/
gume 0:1f82672b8755 9436 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 9437 /* Write the page zero*/
gume 0:1f82672b8755 9438 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 9439 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 9440 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 9441 /* Read accel offset value it is six bytes of data*/
gume 0:1f82672b8755 9442 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9443 (p_bno055->dev_addr,
gume 0:1f82672b8755 9444 BNO055_ACCEL_OFFSET_X_LSB_REG,
gume 0:1f82672b8755 9445 data_u8, BNO055_ACCEL_OFFSET_ARRAY);
gume 0:1f82672b8755 9446 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9447 /* Read accel x offset value*/
gume 0:1f82672b8755 9448 data_u8[BNO055_SENSOR_OFFSET_DATA_X_LSB] =
gume 0:1f82672b8755 9449 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 9450 data_u8[BNO055_SENSOR_OFFSET_DATA_X_LSB],
gume 0:1f82672b8755 9451 BNO055_ACCEL_OFFSET_X_LSB);
gume 0:1f82672b8755 9452 data_u8[BNO055_SENSOR_OFFSET_DATA_X_MSB] =
gume 0:1f82672b8755 9453 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 9454 data_u8[BNO055_SENSOR_OFFSET_DATA_X_MSB],
gume 0:1f82672b8755 9455 BNO055_ACCEL_OFFSET_X_MSB);
gume 0:1f82672b8755 9456 accel_offset->x = (s16)((((s32)(s8)
gume 0:1f82672b8755 9457 (data_u8[BNO055_SENSOR_OFFSET_DATA_X_MSB])) <<
gume 0:1f82672b8755 9458 (BNO055_SHIFT_EIGHT_BITS)) |
gume 0:1f82672b8755 9459 (data_u8[BNO055_SENSOR_OFFSET_DATA_X_LSB]));
gume 0:1f82672b8755 9460
gume 0:1f82672b8755 9461 /* Read accel y offset value*/
gume 0:1f82672b8755 9462 data_u8[BNO055_SENSOR_OFFSET_DATA_Y_LSB] =
gume 0:1f82672b8755 9463 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 9464 data_u8[BNO055_SENSOR_OFFSET_DATA_Y_LSB],
gume 0:1f82672b8755 9465 BNO055_ACCEL_OFFSET_Y_LSB);
gume 0:1f82672b8755 9466 data_u8[BNO055_SENSOR_OFFSET_DATA_Y_MSB] =
gume 0:1f82672b8755 9467 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 9468 data_u8[BNO055_SENSOR_OFFSET_DATA_Y_MSB],
gume 0:1f82672b8755 9469 BNO055_ACCEL_OFFSET_Y_MSB);
gume 0:1f82672b8755 9470 accel_offset->y = (s16)((((s32)(s8)
gume 0:1f82672b8755 9471 (data_u8[BNO055_SENSOR_OFFSET_DATA_Y_MSB])) <<
gume 0:1f82672b8755 9472 (BNO055_SHIFT_EIGHT_BITS))
gume 0:1f82672b8755 9473 | (data_u8[BNO055_SENSOR_OFFSET_DATA_Y_LSB]));
gume 0:1f82672b8755 9474
gume 0:1f82672b8755 9475 /* Read accel z offset value*/
gume 0:1f82672b8755 9476 data_u8[BNO055_SENSOR_OFFSET_DATA_Z_LSB] =
gume 0:1f82672b8755 9477 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 9478 data_u8[BNO055_SENSOR_OFFSET_DATA_Z_LSB],
gume 0:1f82672b8755 9479 BNO055_ACCEL_OFFSET_Z_LSB);
gume 0:1f82672b8755 9480 data_u8[BNO055_SENSOR_OFFSET_DATA_Z_MSB] =
gume 0:1f82672b8755 9481 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 9482 data_u8[BNO055_SENSOR_OFFSET_DATA_Z_MSB],
gume 0:1f82672b8755 9483 BNO055_ACCEL_OFFSET_Z_MSB);
gume 0:1f82672b8755 9484 accel_offset->z = (s16)((((s32)(s8)
gume 0:1f82672b8755 9485 (data_u8[BNO055_SENSOR_OFFSET_DATA_Z_MSB])) <<
gume 0:1f82672b8755 9486 (BNO055_SHIFT_EIGHT_BITS)) |
gume 0:1f82672b8755 9487 (data_u8[BNO055_SENSOR_OFFSET_DATA_Z_LSB]));
gume 0:1f82672b8755 9488
gume 0:1f82672b8755 9489 /* Read accel radius value
gume 0:1f82672b8755 9490 it is two bytes of data*/
gume 0:1f82672b8755 9491 com_rslt += p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9492 (p_bno055->dev_addr,
gume 0:1f82672b8755 9493 BNO055_ACCEL_RADIUS_LSB_REG,
gume 0:1f82672b8755 9494 data_u8,
gume 0:1f82672b8755 9495 BNO055_LSB_MSB_READ_LENGTH);
gume 0:1f82672b8755 9496 /* Array holding the accel radius values
gume 0:1f82672b8755 9497 data_u8[BNO055_OFFSET_RADIUS_LSB] - radius->LSB
gume 0:1f82672b8755 9498 data_u8[BNO055_OFFSET_RADIUS_MSB] - radius->MSB
gume 0:1f82672b8755 9499 */
gume 0:1f82672b8755 9500 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9501 data_u8[BNO055_OFFSET_RADIUS_LSB] =
gume 0:1f82672b8755 9502 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 9503 data_u8[BNO055_OFFSET_RADIUS_LSB],
gume 0:1f82672b8755 9504 BNO055_ACCEL_RADIUS_LSB);
gume 0:1f82672b8755 9505 data_u8[BNO055_OFFSET_RADIUS_MSB] =
gume 0:1f82672b8755 9506 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 9507 data_u8[BNO055_OFFSET_RADIUS_MSB],
gume 0:1f82672b8755 9508 BNO055_ACCEL_RADIUS_MSB);
gume 0:1f82672b8755 9509 accel_offset->r = (s16)((((s32)(s8)
gume 0:1f82672b8755 9510 (data_u8[BNO055_OFFSET_RADIUS_MSB])) <<
gume 0:1f82672b8755 9511 (BNO055_SHIFT_EIGHT_BITS)) |
gume 0:1f82672b8755 9512 (data_u8[BNO055_OFFSET_RADIUS_LSB]));
gume 0:1f82672b8755 9513 } else {
gume 0:1f82672b8755 9514 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 9515 }
gume 0:1f82672b8755 9516 } else {
gume 0:1f82672b8755 9517 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 9518 }
gume 0:1f82672b8755 9519 } else {
gume 0:1f82672b8755 9520 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 9521 }
gume 0:1f82672b8755 9522 }
gume 0:1f82672b8755 9523 return com_rslt;
gume 0:1f82672b8755 9524 }
gume 0:1f82672b8755 9525 /*!
gume 0:1f82672b8755 9526 * @brief This API is used to write accel offset and accel radius
gume 0:1f82672b8755 9527 * offset form register 0x55 to 0x5A and radius form 0x67 and 0x68
gume 0:1f82672b8755 9528 *
gume 0:1f82672b8755 9529 * @param accel_offset : The value of accel offset and radius
gume 0:1f82672b8755 9530 *
gume 0:1f82672b8755 9531 * bno055_accel_offset_t | result
gume 0:1f82672b8755 9532 * ------------------- | ----------------
gume 0:1f82672b8755 9533 * x | accel offset x
gume 0:1f82672b8755 9534 * y | accel offset y
gume 0:1f82672b8755 9535 * z | accel offset z
gume 0:1f82672b8755 9536 * r | accel offset r
gume 0:1f82672b8755 9537 *
gume 0:1f82672b8755 9538 *
gume 0:1f82672b8755 9539 * @return results of bus communication function
gume 0:1f82672b8755 9540 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 9541 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 9542 *
gume 0:1f82672b8755 9543 * @note The range of the accel offset varies based on
gume 0:1f82672b8755 9544 * the G-range of accel sensor.
gume 0:1f82672b8755 9545 *
gume 0:1f82672b8755 9546 * accel G range | offset range
gume 0:1f82672b8755 9547 * --------------- | --------------
gume 0:1f82672b8755 9548 * BNO055_ACCEL_RANGE_2G | +/-2000
gume 0:1f82672b8755 9549 * BNO055_ACCEL_RANGE_4G | +/-4000
gume 0:1f82672b8755 9550 * BNO055_ACCEL_RANGE_8G | +/-8000
gume 0:1f82672b8755 9551 * BNO055_ACCEL_RANGE_16G | +/-16000
gume 0:1f82672b8755 9552 *
gume 0:1f82672b8755 9553 * accel G range can be configured by using the
gume 0:1f82672b8755 9554 * bno055_set_accel_range() API
gume 0:1f82672b8755 9555 */
gume 0:1f82672b8755 9556 BNO055_RETURN_FUNCTION_TYPE bno055_write_accel_offset(
gume 0:1f82672b8755 9557 struct bno055_accel_offset_t *accel_offset)
gume 0:1f82672b8755 9558 {
gume 0:1f82672b8755 9559 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 9560 u8 data1_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 9561 u8 data2_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 9562 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 9563 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 9564 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 9565 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 9566 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 9567 } else {
gume 0:1f82672b8755 9568 /* The write operation effective only if the operation
gume 0:1f82672b8755 9569 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 9570 current operation mode and set the config mode */
gume 0:1f82672b8755 9571 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 9572 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 9573 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 9574 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 9575 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 9576 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 9577 /* write accel offset x value*/
gume 0:1f82672b8755 9578 com_rslt =
gume 0:1f82672b8755 9579 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9580 (p_bno055->dev_addr,
gume 0:1f82672b8755 9581 BNO055_ACCEL_OFFSET_X_LSB_REG,
gume 0:1f82672b8755 9582 &data2_u8r,
gume 0:1f82672b8755 9583 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9584 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9585 data1_u8r = ((s8)
gume 0:1f82672b8755 9586 (accel_offset->x
gume 0:1f82672b8755 9587 & BNO055_SIC_HEX_0_0_F_F_DATA));
gume 0:1f82672b8755 9588 data2_u8r =
gume 0:1f82672b8755 9589 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 9590 BNO055_ACCEL_OFFSET_X_LSB,
gume 0:1f82672b8755 9591 data1_u8r);
gume 0:1f82672b8755 9592 com_rslt +=
gume 0:1f82672b8755 9593 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 9594 (p_bno055->dev_addr,
gume 0:1f82672b8755 9595 BNO055_ACCEL_OFFSET_X_LSB_REG,
gume 0:1f82672b8755 9596 &data2_u8r,
gume 0:1f82672b8755 9597 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9598 }
gume 0:1f82672b8755 9599
gume 0:1f82672b8755 9600 com_rslt +=
gume 0:1f82672b8755 9601 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9602 (p_bno055->dev_addr,
gume 0:1f82672b8755 9603 BNO055_ACCEL_OFFSET_X_MSB_REG,
gume 0:1f82672b8755 9604 &data2_u8r,
gume 0:1f82672b8755 9605 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9606 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9607 data1_u8r = ((s8)
gume 0:1f82672b8755 9608 (accel_offset->x >>
gume 0:1f82672b8755 9609 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 9610 & BNO055_SIC_HEX_0_0_F_F_DATA);
gume 0:1f82672b8755 9611 data2_u8r =
gume 0:1f82672b8755 9612 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 9613 BNO055_ACCEL_OFFSET_X_MSB,
gume 0:1f82672b8755 9614 data1_u8r);
gume 0:1f82672b8755 9615 com_rslt +=
gume 0:1f82672b8755 9616 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 9617 (p_bno055->dev_addr,
gume 0:1f82672b8755 9618 BNO055_ACCEL_OFFSET_X_MSB_REG,
gume 0:1f82672b8755 9619 &data2_u8r,
gume 0:1f82672b8755 9620 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9621 }
gume 0:1f82672b8755 9622
gume 0:1f82672b8755 9623 /* write accel offset y value*/
gume 0:1f82672b8755 9624 com_rslt +=
gume 0:1f82672b8755 9625 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9626 (p_bno055->dev_addr,
gume 0:1f82672b8755 9627 BNO055_ACCEL_OFFSET_Y_LSB_REG,
gume 0:1f82672b8755 9628 &data2_u8r,
gume 0:1f82672b8755 9629 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9630 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9631 data1_u8r = ((s8)
gume 0:1f82672b8755 9632 (accel_offset->y
gume 0:1f82672b8755 9633 & BNO055_SIC_HEX_0_0_F_F_DATA));
gume 0:1f82672b8755 9634 data2_u8r =
gume 0:1f82672b8755 9635 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 9636 BNO055_ACCEL_OFFSET_Y_LSB,
gume 0:1f82672b8755 9637 data1_u8r);
gume 0:1f82672b8755 9638 com_rslt +=
gume 0:1f82672b8755 9639 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 9640 (p_bno055->dev_addr,
gume 0:1f82672b8755 9641 BNO055_ACCEL_OFFSET_Y_LSB_REG,
gume 0:1f82672b8755 9642 &data2_u8r,
gume 0:1f82672b8755 9643 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9644 }
gume 0:1f82672b8755 9645
gume 0:1f82672b8755 9646 com_rslt +=
gume 0:1f82672b8755 9647 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9648 (p_bno055->dev_addr,
gume 0:1f82672b8755 9649 BNO055_ACCEL_OFFSET_Y_MSB_REG,
gume 0:1f82672b8755 9650 &data2_u8r,
gume 0:1f82672b8755 9651 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9652 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9653 data1_u8r = ((s8)
gume 0:1f82672b8755 9654 (accel_offset->y >>
gume 0:1f82672b8755 9655 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 9656 & BNO055_SIC_HEX_0_0_F_F_DATA);
gume 0:1f82672b8755 9657 data2_u8r =
gume 0:1f82672b8755 9658 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 9659 BNO055_ACCEL_OFFSET_Y_MSB,
gume 0:1f82672b8755 9660 data1_u8r);
gume 0:1f82672b8755 9661 com_rslt +=
gume 0:1f82672b8755 9662 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 9663 (p_bno055->dev_addr,
gume 0:1f82672b8755 9664 BNO055_ACCEL_OFFSET_Y_MSB_REG,
gume 0:1f82672b8755 9665 &data2_u8r,
gume 0:1f82672b8755 9666 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9667 }
gume 0:1f82672b8755 9668 /* write accel offset z value*/
gume 0:1f82672b8755 9669 com_rslt +=
gume 0:1f82672b8755 9670 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9671 (p_bno055->dev_addr,
gume 0:1f82672b8755 9672 BNO055_ACCEL_OFFSET_Z_LSB_REG,
gume 0:1f82672b8755 9673 &data2_u8r,
gume 0:1f82672b8755 9674 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9675 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9676 data1_u8r = ((s8)
gume 0:1f82672b8755 9677 (accel_offset->z
gume 0:1f82672b8755 9678 & BNO055_SIC_HEX_0_0_F_F_DATA));
gume 0:1f82672b8755 9679 data2_u8r =
gume 0:1f82672b8755 9680 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 9681 BNO055_ACCEL_OFFSET_Z_LSB,
gume 0:1f82672b8755 9682 data1_u8r);
gume 0:1f82672b8755 9683 com_rslt +=
gume 0:1f82672b8755 9684 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 9685 (p_bno055->dev_addr,
gume 0:1f82672b8755 9686 BNO055_ACCEL_OFFSET_Z_LSB_REG,
gume 0:1f82672b8755 9687 &data2_u8r,
gume 0:1f82672b8755 9688 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9689 }
gume 0:1f82672b8755 9690
gume 0:1f82672b8755 9691 com_rslt +=
gume 0:1f82672b8755 9692 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9693 (p_bno055->dev_addr,
gume 0:1f82672b8755 9694 BNO055_ACCEL_OFFSET_Z_MSB_REG,
gume 0:1f82672b8755 9695 &data2_u8r,
gume 0:1f82672b8755 9696 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9697 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9698 data1_u8r = ((s8)
gume 0:1f82672b8755 9699 (accel_offset->z >>
gume 0:1f82672b8755 9700 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 9701 & BNO055_SIC_HEX_0_0_F_F_DATA);
gume 0:1f82672b8755 9702 data2_u8r =
gume 0:1f82672b8755 9703 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 9704 BNO055_ACCEL_OFFSET_Z_MSB,
gume 0:1f82672b8755 9705 data1_u8r);
gume 0:1f82672b8755 9706 com_rslt +=
gume 0:1f82672b8755 9707 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 9708 (p_bno055->dev_addr,
gume 0:1f82672b8755 9709 BNO055_ACCEL_OFFSET_Z_MSB_REG,
gume 0:1f82672b8755 9710 &data2_u8r,
gume 0:1f82672b8755 9711 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9712 }
gume 0:1f82672b8755 9713
gume 0:1f82672b8755 9714 /*write accel radius value*/
gume 0:1f82672b8755 9715 com_rslt +=
gume 0:1f82672b8755 9716 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9717 (p_bno055->dev_addr,
gume 0:1f82672b8755 9718 BNO055_ACCEL_RADIUS_LSB_REG,
gume 0:1f82672b8755 9719 &data2_u8r,
gume 0:1f82672b8755 9720 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9721 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9722 data1_u8r = ((s8)
gume 0:1f82672b8755 9723 (accel_offset->r
gume 0:1f82672b8755 9724 & BNO055_SIC_HEX_0_0_F_F_DATA));
gume 0:1f82672b8755 9725 data2_u8r =
gume 0:1f82672b8755 9726 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 9727 BNO055_ACCEL_RADIUS_LSB,
gume 0:1f82672b8755 9728 data1_u8r);
gume 0:1f82672b8755 9729 com_rslt =
gume 0:1f82672b8755 9730 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 9731 (p_bno055->dev_addr,
gume 0:1f82672b8755 9732 BNO055_ACCEL_RADIUS_LSB_REG,
gume 0:1f82672b8755 9733 &data2_u8r,
gume 0:1f82672b8755 9734 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9735 }
gume 0:1f82672b8755 9736
gume 0:1f82672b8755 9737 com_rslt +=
gume 0:1f82672b8755 9738 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9739 (p_bno055->dev_addr,
gume 0:1f82672b8755 9740 BNO055_ACCEL_RADIUS_MSB_REG,
gume 0:1f82672b8755 9741 &data2_u8r,
gume 0:1f82672b8755 9742 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9743 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9744 data1_u8r = ((s8)
gume 0:1f82672b8755 9745 (accel_offset->r >>
gume 0:1f82672b8755 9746 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 9747 & BNO055_SIC_HEX_0_0_F_F_DATA);
gume 0:1f82672b8755 9748 data2_u8r =
gume 0:1f82672b8755 9749 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 9750 BNO055_ACCEL_RADIUS_MSB,
gume 0:1f82672b8755 9751 data1_u8r);
gume 0:1f82672b8755 9752 com_rslt =
gume 0:1f82672b8755 9753 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 9754 (p_bno055->dev_addr,
gume 0:1f82672b8755 9755 BNO055_ACCEL_RADIUS_MSB_REG,
gume 0:1f82672b8755 9756 &data2_u8r,
gume 0:1f82672b8755 9757 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9758 }
gume 0:1f82672b8755 9759 } else {
gume 0:1f82672b8755 9760 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 9761 }
gume 0:1f82672b8755 9762 } else {
gume 0:1f82672b8755 9763 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 9764 }
gume 0:1f82672b8755 9765 }
gume 0:1f82672b8755 9766 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 9767 /* set the operation mode
gume 0:1f82672b8755 9768 of previous operation mode*/
gume 0:1f82672b8755 9769 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 9770 (prev_opmode_u8);
gume 0:1f82672b8755 9771 return com_rslt;
gume 0:1f82672b8755 9772 }
gume 0:1f82672b8755 9773
gume 0:1f82672b8755 9774 /*!
gume 0:1f82672b8755 9775 * @brief This API is used to read mag offset
gume 0:1f82672b8755 9776 * offset form register 0x69 to 0x6A
gume 0:1f82672b8755 9777 *
gume 0:1f82672b8755 9778 * @param mag_offset : The value of mag offset and radius
gume 0:1f82672b8755 9779 *
gume 0:1f82672b8755 9780 * bno055_mag_offset_t | result
gume 0:1f82672b8755 9781 * ------------------- | ----------------
gume 0:1f82672b8755 9782 * x | mag offset x
gume 0:1f82672b8755 9783 * y | mag offset y
gume 0:1f82672b8755 9784 * z | mag offset z
gume 0:1f82672b8755 9785 * r | mag radius r
gume 0:1f82672b8755 9786 *
gume 0:1f82672b8755 9787 *
gume 0:1f82672b8755 9788 * @return results of bus communication function
gume 0:1f82672b8755 9789 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 9790 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 9791 *
gume 0:1f82672b8755 9792 * @note The range of the magnetometer offset is +/-6400 in LSB
gume 0:1f82672b8755 9793 */
gume 0:1f82672b8755 9794
gume 0:1f82672b8755 9795 BNO055_RETURN_FUNCTION_TYPE bno055_read_mag_offset(
gume 0:1f82672b8755 9796 struct bno055_mag_offset_t *mag_offset)
gume 0:1f82672b8755 9797 {
gume 0:1f82672b8755 9798 /* Variable used to return value of
gume 0:1f82672b8755 9799 communication routine*/
gume 0:1f82672b8755 9800 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 9801 /* Array holding the mag offset values
gume 0:1f82672b8755 9802 data_u8[BNO055_SENSOR_OFFSET_DATA_X_LSB] - offset x->LSB
gume 0:1f82672b8755 9803 data_u8[BNO055_SENSOR_OFFSET_DATA_X_MSB] - offset x->MSB
gume 0:1f82672b8755 9804 data_u8[BNO055_SENSOR_OFFSET_DATA_Y_LSB] - offset y->LSB
gume 0:1f82672b8755 9805 data_u8[BNO055_SENSOR_OFFSET_DATA_Y_MSB] - offset y->MSB
gume 0:1f82672b8755 9806 data_u8[BNO055_SENSOR_OFFSET_DATA_Z_LSB] - offset z->LSB
gume 0:1f82672b8755 9807 data_u8[BNO055_SENSOR_OFFSET_DATA_Z_MSB] - offset z->MSB
gume 0:1f82672b8755 9808 */
gume 0:1f82672b8755 9809 u8 data_u8[BNO055_MAG_OFFSET_ARRAY] = {
gume 0:1f82672b8755 9810 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 9811 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 9812 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 9813 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 9814 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 9815 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 9816 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 9817 } else {
gume 0:1f82672b8755 9818 /*condition check for page, mag offset is
gume 0:1f82672b8755 9819 available in the page zero*/
gume 0:1f82672b8755 9820 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 9821 /* Write the page zero*/
gume 0:1f82672b8755 9822 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 9823 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 9824 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 9825 /* Read mag offset value it the six bytes of data */
gume 0:1f82672b8755 9826 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9827 (p_bno055->dev_addr,
gume 0:1f82672b8755 9828 BNO055_MAG_OFFSET_X_LSB_REG,
gume 0:1f82672b8755 9829 data_u8, BNO055_MAG_OFFSET_ARRAY);
gume 0:1f82672b8755 9830 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9831 /* Read mag x offset value*/
gume 0:1f82672b8755 9832 data_u8[BNO055_SENSOR_OFFSET_DATA_X_LSB] =
gume 0:1f82672b8755 9833 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 9834 data_u8[BNO055_SENSOR_OFFSET_DATA_X_LSB],
gume 0:1f82672b8755 9835 BNO055_MAG_OFFSET_X_LSB);
gume 0:1f82672b8755 9836 data_u8[BNO055_SENSOR_OFFSET_DATA_X_MSB] =
gume 0:1f82672b8755 9837 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 9838 data_u8[BNO055_SENSOR_OFFSET_DATA_X_MSB],
gume 0:1f82672b8755 9839 BNO055_MAG_OFFSET_X_MSB);
gume 0:1f82672b8755 9840 mag_offset->x = (s16)((((s32)(s8)
gume 0:1f82672b8755 9841 (data_u8[BNO055_SENSOR_OFFSET_DATA_X_MSB])) <<
gume 0:1f82672b8755 9842 (BNO055_SHIFT_EIGHT_BITS)) |
gume 0:1f82672b8755 9843 (data_u8[BNO055_SENSOR_OFFSET_DATA_X_LSB]));
gume 0:1f82672b8755 9844
gume 0:1f82672b8755 9845 /* Read mag y offset value*/
gume 0:1f82672b8755 9846 data_u8[BNO055_SENSOR_OFFSET_DATA_Y_LSB] =
gume 0:1f82672b8755 9847 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 9848 data_u8[BNO055_SENSOR_OFFSET_DATA_Y_LSB],
gume 0:1f82672b8755 9849 BNO055_MAG_OFFSET_Y_LSB);
gume 0:1f82672b8755 9850 data_u8[BNO055_SENSOR_OFFSET_DATA_Y_MSB] =
gume 0:1f82672b8755 9851 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 9852 data_u8[BNO055_SENSOR_OFFSET_DATA_Y_MSB],
gume 0:1f82672b8755 9853 BNO055_MAG_OFFSET_Y_MSB);
gume 0:1f82672b8755 9854 mag_offset->y = (s16)((((s32)(s8)
gume 0:1f82672b8755 9855 (data_u8[BNO055_SENSOR_OFFSET_DATA_Y_MSB])) <<
gume 0:1f82672b8755 9856 (BNO055_SHIFT_EIGHT_BITS))
gume 0:1f82672b8755 9857 | (data_u8[BNO055_SENSOR_OFFSET_DATA_Y_LSB]));
gume 0:1f82672b8755 9858
gume 0:1f82672b8755 9859 /* Read mag z offset value*/
gume 0:1f82672b8755 9860 data_u8[BNO055_SENSOR_OFFSET_DATA_Z_LSB] =
gume 0:1f82672b8755 9861 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 9862 data_u8[BNO055_SENSOR_OFFSET_DATA_Z_LSB],
gume 0:1f82672b8755 9863 BNO055_MAG_OFFSET_Z_LSB);
gume 0:1f82672b8755 9864 data_u8[BNO055_SENSOR_OFFSET_DATA_Z_MSB] =
gume 0:1f82672b8755 9865 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 9866 data_u8[BNO055_SENSOR_OFFSET_DATA_Z_MSB],
gume 0:1f82672b8755 9867 BNO055_MAG_OFFSET_Z_MSB);
gume 0:1f82672b8755 9868 mag_offset->z = (s16)((((s32)(s8)
gume 0:1f82672b8755 9869 (data_u8[BNO055_SENSOR_OFFSET_DATA_Z_MSB])) <<
gume 0:1f82672b8755 9870 (BNO055_SHIFT_EIGHT_BITS))
gume 0:1f82672b8755 9871 | (data_u8[BNO055_SENSOR_OFFSET_DATA_Z_LSB]));
gume 0:1f82672b8755 9872
gume 0:1f82672b8755 9873 /* Read mag radius value
gume 0:1f82672b8755 9874 it the two bytes of data */
gume 0:1f82672b8755 9875 com_rslt += p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9876 (p_bno055->dev_addr,
gume 0:1f82672b8755 9877 BNO055_MAG_RADIUS_LSB_REG,
gume 0:1f82672b8755 9878 data_u8,
gume 0:1f82672b8755 9879 BNO055_LSB_MSB_READ_LENGTH);
gume 0:1f82672b8755 9880 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9881 /* Array holding the mag radius values
gume 0:1f82672b8755 9882 data_u8[BNO055_OFFSET_RADIUS_LSB] -
gume 0:1f82672b8755 9883 radius->LSB
gume 0:1f82672b8755 9884 data_u8[BNO055_OFFSET_RADIUS_MSB] -
gume 0:1f82672b8755 9885 radius->MSB
gume 0:1f82672b8755 9886 */
gume 0:1f82672b8755 9887 data_u8[BNO055_OFFSET_RADIUS_LSB] =
gume 0:1f82672b8755 9888 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 9889 data_u8[BNO055_OFFSET_RADIUS_LSB],
gume 0:1f82672b8755 9890 BNO055_MAG_RADIUS_LSB);
gume 0:1f82672b8755 9891 data_u8[BNO055_OFFSET_RADIUS_MSB] =
gume 0:1f82672b8755 9892 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 9893 data_u8[BNO055_OFFSET_RADIUS_MSB],
gume 0:1f82672b8755 9894 BNO055_MAG_RADIUS_MSB);
gume 0:1f82672b8755 9895 mag_offset->r = (s16)((((s32)(s8)
gume 0:1f82672b8755 9896 (data_u8[BNO055_OFFSET_RADIUS_MSB])) <<
gume 0:1f82672b8755 9897 (BNO055_SHIFT_EIGHT_BITS)) |
gume 0:1f82672b8755 9898 (data_u8[BNO055_OFFSET_RADIUS_LSB]));
gume 0:1f82672b8755 9899 } else {
gume 0:1f82672b8755 9900 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 9901 }
gume 0:1f82672b8755 9902 } else {
gume 0:1f82672b8755 9903 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 9904 }
gume 0:1f82672b8755 9905 } else {
gume 0:1f82672b8755 9906 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 9907 }
gume 0:1f82672b8755 9908 }
gume 0:1f82672b8755 9909 return com_rslt;
gume 0:1f82672b8755 9910 }
gume 0:1f82672b8755 9911
gume 0:1f82672b8755 9912 /*!
gume 0:1f82672b8755 9913 * @brief This API is used to read mag offset
gume 0:1f82672b8755 9914 * offset form register 0x69 to 0x6A
gume 0:1f82672b8755 9915 *
gume 0:1f82672b8755 9916 * @param mag_offset : The value of mag offset and radius
gume 0:1f82672b8755 9917 *
gume 0:1f82672b8755 9918 * bno055_mag_offset_t | result
gume 0:1f82672b8755 9919 * ------------------- | ----------------
gume 0:1f82672b8755 9920 * x | mag offset x
gume 0:1f82672b8755 9921 * y | mag offset y
gume 0:1f82672b8755 9922 * z | mag offset z
gume 0:1f82672b8755 9923 * r | mag radius r
gume 0:1f82672b8755 9924 *
gume 0:1f82672b8755 9925 *
gume 0:1f82672b8755 9926 * @return results of bus communication function
gume 0:1f82672b8755 9927 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 9928 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 9929 *
gume 0:1f82672b8755 9930 * @note The range of the magnetometer offset is +/-6400 in LSB
gume 0:1f82672b8755 9931 */
gume 0:1f82672b8755 9932 BNO055_RETURN_FUNCTION_TYPE bno055_write_mag_offset(
gume 0:1f82672b8755 9933 struct bno055_mag_offset_t *mag_offset)
gume 0:1f82672b8755 9934 {
gume 0:1f82672b8755 9935 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 9936 u8 data1_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 9937 u8 data2_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 9938 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 9939 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 9940 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 9941 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 9942 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 9943 } else {
gume 0:1f82672b8755 9944 /* The write operation effective only if the operation
gume 0:1f82672b8755 9945 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 9946 current operation mode and set the config mode */
gume 0:1f82672b8755 9947 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 9948 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 9949 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 9950 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 9951 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 9952 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 9953 /* write Mag offset x value*/
gume 0:1f82672b8755 9954 com_rslt =
gume 0:1f82672b8755 9955 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9956 (p_bno055->dev_addr,
gume 0:1f82672b8755 9957 BNO055_MAG_OFFSET_X_LSB_REG,
gume 0:1f82672b8755 9958 &data2_u8r,
gume 0:1f82672b8755 9959 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9960 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9961 data1_u8r = ((s8)
gume 0:1f82672b8755 9962 (mag_offset->x
gume 0:1f82672b8755 9963 & BNO055_SIC_HEX_0_0_F_F_DATA));
gume 0:1f82672b8755 9964 data2_u8r =
gume 0:1f82672b8755 9965 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 9966 BNO055_MAG_OFFSET_X_LSB,
gume 0:1f82672b8755 9967 data1_u8r);
gume 0:1f82672b8755 9968 com_rslt +=
gume 0:1f82672b8755 9969 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 9970 (p_bno055->dev_addr,
gume 0:1f82672b8755 9971 BNO055_MAG_OFFSET_X_LSB_REG,
gume 0:1f82672b8755 9972 &data2_u8r,
gume 0:1f82672b8755 9973 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9974 }
gume 0:1f82672b8755 9975
gume 0:1f82672b8755 9976 com_rslt +=
gume 0:1f82672b8755 9977 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 9978 (p_bno055->dev_addr,
gume 0:1f82672b8755 9979 BNO055_MAG_OFFSET_X_MSB_REG,
gume 0:1f82672b8755 9980 &data2_u8r,
gume 0:1f82672b8755 9981 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9982 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 9983 data1_u8r = ((s8)
gume 0:1f82672b8755 9984 (mag_offset->x >>
gume 0:1f82672b8755 9985 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 9986 & BNO055_SIC_HEX_0_0_F_F_DATA);
gume 0:1f82672b8755 9987 data2_u8r =
gume 0:1f82672b8755 9988 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 9989 BNO055_MAG_OFFSET_X_MSB,
gume 0:1f82672b8755 9990 data1_u8r);
gume 0:1f82672b8755 9991 com_rslt +=
gume 0:1f82672b8755 9992 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 9993 (p_bno055->dev_addr,
gume 0:1f82672b8755 9994 BNO055_MAG_OFFSET_X_MSB_REG,
gume 0:1f82672b8755 9995 &data2_u8r,
gume 0:1f82672b8755 9996 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 9997 }
gume 0:1f82672b8755 9998
gume 0:1f82672b8755 9999 /* write Mag offset y value*/
gume 0:1f82672b8755 10000 com_rslt +=
gume 0:1f82672b8755 10001 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 10002 (p_bno055->dev_addr,
gume 0:1f82672b8755 10003 BNO055_MAG_OFFSET_Y_LSB_REG,
gume 0:1f82672b8755 10004 &data2_u8r,
gume 0:1f82672b8755 10005 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10006 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 10007 data1_u8r = ((s8)
gume 0:1f82672b8755 10008 (mag_offset->y &
gume 0:1f82672b8755 10009 BNO055_SIC_HEX_0_0_F_F_DATA));
gume 0:1f82672b8755 10010 data2_u8r =
gume 0:1f82672b8755 10011 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 10012 BNO055_MAG_OFFSET_Y_LSB,
gume 0:1f82672b8755 10013 data1_u8r);
gume 0:1f82672b8755 10014 com_rslt +=
gume 0:1f82672b8755 10015 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 10016 (p_bno055->dev_addr,
gume 0:1f82672b8755 10017 BNO055_MAG_OFFSET_Y_LSB_REG,
gume 0:1f82672b8755 10018 &data2_u8r,
gume 0:1f82672b8755 10019 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10020 }
gume 0:1f82672b8755 10021
gume 0:1f82672b8755 10022 com_rslt +=
gume 0:1f82672b8755 10023 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 10024 (p_bno055->dev_addr,
gume 0:1f82672b8755 10025 BNO055_MAG_OFFSET_Y_MSB_REG,
gume 0:1f82672b8755 10026 &data2_u8r,
gume 0:1f82672b8755 10027 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10028 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 10029 data1_u8r = ((s8)
gume 0:1f82672b8755 10030 (mag_offset->y >>
gume 0:1f82672b8755 10031 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 10032 & BNO055_SIC_HEX_0_0_F_F_DATA);
gume 0:1f82672b8755 10033 data2_u8r =
gume 0:1f82672b8755 10034 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 10035 BNO055_MAG_OFFSET_Y_MSB,
gume 0:1f82672b8755 10036 data1_u8r);
gume 0:1f82672b8755 10037 com_rslt +=
gume 0:1f82672b8755 10038 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 10039 (p_bno055->dev_addr,
gume 0:1f82672b8755 10040 BNO055_MAG_OFFSET_Y_MSB_REG,
gume 0:1f82672b8755 10041 &data2_u8r,
gume 0:1f82672b8755 10042 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10043 }
gume 0:1f82672b8755 10044 /* write Mag offset z value*/
gume 0:1f82672b8755 10045 com_rslt +=
gume 0:1f82672b8755 10046 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 10047 (p_bno055->dev_addr,
gume 0:1f82672b8755 10048 BNO055_MAG_OFFSET_Z_LSB_REG,
gume 0:1f82672b8755 10049 &data2_u8r,
gume 0:1f82672b8755 10050 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10051 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 10052 data1_u8r = ((s8)
gume 0:1f82672b8755 10053 (mag_offset->z &
gume 0:1f82672b8755 10054 BNO055_SIC_HEX_0_0_F_F_DATA));
gume 0:1f82672b8755 10055 data2_u8r =
gume 0:1f82672b8755 10056 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 10057 BNO055_MAG_OFFSET_Z_LSB,
gume 0:1f82672b8755 10058 data1_u8r);
gume 0:1f82672b8755 10059 com_rslt +=
gume 0:1f82672b8755 10060 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 10061 (p_bno055->dev_addr,
gume 0:1f82672b8755 10062 BNO055_MAG_OFFSET_Z_LSB_REG,
gume 0:1f82672b8755 10063 &data2_u8r,
gume 0:1f82672b8755 10064 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10065 }
gume 0:1f82672b8755 10066
gume 0:1f82672b8755 10067 com_rslt +=
gume 0:1f82672b8755 10068 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 10069 (p_bno055->dev_addr,
gume 0:1f82672b8755 10070 BNO055_MAG_OFFSET_Z_MSB_REG,
gume 0:1f82672b8755 10071 &data2_u8r,
gume 0:1f82672b8755 10072 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10073 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 10074 data1_u8r = ((s8)
gume 0:1f82672b8755 10075 (mag_offset->z >>
gume 0:1f82672b8755 10076 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 10077 & BNO055_SIC_HEX_0_0_F_F_DATA);
gume 0:1f82672b8755 10078 data2_u8r =
gume 0:1f82672b8755 10079 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 10080 BNO055_MAG_OFFSET_Z_MSB,
gume 0:1f82672b8755 10081 data1_u8r);
gume 0:1f82672b8755 10082 com_rslt +=
gume 0:1f82672b8755 10083 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 10084 (p_bno055->dev_addr,
gume 0:1f82672b8755 10085 BNO055_MAG_OFFSET_Z_MSB_REG,
gume 0:1f82672b8755 10086 &data2_u8r,
gume 0:1f82672b8755 10087 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10088 }
gume 0:1f82672b8755 10089
gume 0:1f82672b8755 10090 /* write Mag radius value*/
gume 0:1f82672b8755 10091 com_rslt +=
gume 0:1f82672b8755 10092 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 10093 (p_bno055->dev_addr,
gume 0:1f82672b8755 10094 BNO055_MAG_RADIUS_LSB_REG,
gume 0:1f82672b8755 10095 &data2_u8r,
gume 0:1f82672b8755 10096 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10097 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 10098 data1_u8r = ((s8)
gume 0:1f82672b8755 10099 (mag_offset->r &
gume 0:1f82672b8755 10100 BNO055_SIC_HEX_0_0_F_F_DATA));
gume 0:1f82672b8755 10101 data2_u8r =
gume 0:1f82672b8755 10102 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 10103 BNO055_MAG_RADIUS_LSB,
gume 0:1f82672b8755 10104 data1_u8r);
gume 0:1f82672b8755 10105 com_rslt +=
gume 0:1f82672b8755 10106 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 10107 (p_bno055->dev_addr,
gume 0:1f82672b8755 10108 BNO055_MAG_RADIUS_LSB_REG,
gume 0:1f82672b8755 10109 &data2_u8r,
gume 0:1f82672b8755 10110 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10111 }
gume 0:1f82672b8755 10112
gume 0:1f82672b8755 10113 com_rslt +=
gume 0:1f82672b8755 10114 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 10115 (p_bno055->dev_addr,
gume 0:1f82672b8755 10116 BNO055_MAG_RADIUS_MSB_REG,
gume 0:1f82672b8755 10117 &data2_u8r,
gume 0:1f82672b8755 10118 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10119 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 10120 data1_u8r = ((s8)
gume 0:1f82672b8755 10121 (mag_offset->r >>
gume 0:1f82672b8755 10122 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 10123 & BNO055_SIC_HEX_0_0_F_F_DATA);
gume 0:1f82672b8755 10124 data2_u8r =
gume 0:1f82672b8755 10125 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 10126 BNO055_MAG_RADIUS_MSB,
gume 0:1f82672b8755 10127 data1_u8r);
gume 0:1f82672b8755 10128 com_rslt +=
gume 0:1f82672b8755 10129 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 10130 (p_bno055->dev_addr,
gume 0:1f82672b8755 10131 BNO055_MAG_RADIUS_MSB_REG,
gume 0:1f82672b8755 10132 &data2_u8r,
gume 0:1f82672b8755 10133 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10134 }
gume 0:1f82672b8755 10135 } else {
gume 0:1f82672b8755 10136 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10137 }
gume 0:1f82672b8755 10138 } else {
gume 0:1f82672b8755 10139 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10140 }
gume 0:1f82672b8755 10141 }
gume 0:1f82672b8755 10142 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 10143 /* set the operation mode
gume 0:1f82672b8755 10144 of previous operation mode*/
gume 0:1f82672b8755 10145 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 10146 (prev_opmode_u8);
gume 0:1f82672b8755 10147 return com_rslt;
gume 0:1f82672b8755 10148 }
gume 0:1f82672b8755 10149 /*!
gume 0:1f82672b8755 10150 * @brief This API is used to read gyro offset
gume 0:1f82672b8755 10151 * offset form register 0x61 to 0x66
gume 0:1f82672b8755 10152 *
gume 0:1f82672b8755 10153 * @param gyro_offset : The value of gyro offset
gume 0:1f82672b8755 10154 *
gume 0:1f82672b8755 10155 * bno055_gyro_offset_t | result
gume 0:1f82672b8755 10156 * ------------------- | ----------------
gume 0:1f82672b8755 10157 * x | gyro offset x
gume 0:1f82672b8755 10158 * y | gyro offset y
gume 0:1f82672b8755 10159 * z | gyro offset z
gume 0:1f82672b8755 10160 *
gume 0:1f82672b8755 10161 *
gume 0:1f82672b8755 10162 * @return results of bus communication function
gume 0:1f82672b8755 10163 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 10164 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 10165 *
gume 0:1f82672b8755 10166 * @note The range of the gyro offset varies based on
gume 0:1f82672b8755 10167 * the range of gyro sensor
gume 0:1f82672b8755 10168 *
gume 0:1f82672b8755 10169 * gyro G range | offset range
gume 0:1f82672b8755 10170 * -------------------- | ------------
gume 0:1f82672b8755 10171 * BNO055_GYRO_RANGE_2000DPS | +/-32000
gume 0:1f82672b8755 10172 * BNO055_GYRO_RANGE_1000DPS | +/-16000
gume 0:1f82672b8755 10173 * BNO055_GYRO_RANGE_500DPS | +/-8000
gume 0:1f82672b8755 10174 * BNO055_GYRO_RANGE_250DPS | +/-4000
gume 0:1f82672b8755 10175 * BNO055_GYRO_RANGE_125DPS | +/-2000
gume 0:1f82672b8755 10176 *
gume 0:1f82672b8755 10177 * Gyro range can be configured by using the
gume 0:1f82672b8755 10178 * bno055_set_gyro_range() API
gume 0:1f82672b8755 10179 */
gume 0:1f82672b8755 10180 BNO055_RETURN_FUNCTION_TYPE bno055_read_gyro_offset(
gume 0:1f82672b8755 10181 struct bno055_gyro_offset_t *gyro_offset)
gume 0:1f82672b8755 10182 {
gume 0:1f82672b8755 10183 /* Variable used to return value of
gume 0:1f82672b8755 10184 communication routine*/
gume 0:1f82672b8755 10185 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10186 /* Array holding the gyro offset values
gume 0:1f82672b8755 10187 data_u8[BNO055_SENSOR_OFFSET_DATA_X_LSB] - offset x->LSB
gume 0:1f82672b8755 10188 data_u8[BNO055_SENSOR_OFFSET_DATA_X_MSB] - offset x->MSB
gume 0:1f82672b8755 10189 data_u8[BNO055_SENSOR_OFFSET_DATA_Y_LSB] - offset y->LSB
gume 0:1f82672b8755 10190 data_u8[BNO055_SENSOR_OFFSET_DATA_Y_MSB] - offset y->MSB
gume 0:1f82672b8755 10191 data_u8[BNO055_SENSOR_OFFSET_DATA_Z_LSB] - offset z->LSB
gume 0:1f82672b8755 10192 data_u8[BNO055_SENSOR_OFFSET_DATA_Z_MSB] - offset z->MSB
gume 0:1f82672b8755 10193 */
gume 0:1f82672b8755 10194 u8 data_u8[BNO055_GYRO_OFFSET_ARRAY] = {
gume 0:1f82672b8755 10195 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 10196 BNO055_INIT_VALUE, BNO055_INIT_VALUE,
gume 0:1f82672b8755 10197 BNO055_INIT_VALUE, BNO055_INIT_VALUE};
gume 0:1f82672b8755 10198 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 10199 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 10200 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 10201 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 10202 } else {
gume 0:1f82672b8755 10203 /*condition check for page, gyro offset is
gume 0:1f82672b8755 10204 available in the page zero*/
gume 0:1f82672b8755 10205 if (p_bno055->page_id != BNO055_PAGE_ZERO)
gume 0:1f82672b8755 10206 /* Write the page zero*/
gume 0:1f82672b8755 10207 stat_s8 = bno055_write_page_id(BNO055_PAGE_ZERO);
gume 0:1f82672b8755 10208 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 10209 (p_bno055->page_id == BNO055_PAGE_ZERO)) {
gume 0:1f82672b8755 10210 /* Read gyro offset value it the six bytes of data*/
gume 0:1f82672b8755 10211 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 10212 (p_bno055->dev_addr,
gume 0:1f82672b8755 10213 BNO055_GYRO_OFFSET_X_LSB_REG,
gume 0:1f82672b8755 10214 data_u8, BNO055_GYRO_OFFSET_ARRAY);
gume 0:1f82672b8755 10215 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 10216 /* Read gyro x offset value*/
gume 0:1f82672b8755 10217 data_u8[BNO055_SENSOR_OFFSET_DATA_X_LSB] =
gume 0:1f82672b8755 10218 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 10219 data_u8[BNO055_SENSOR_OFFSET_DATA_X_LSB],
gume 0:1f82672b8755 10220 BNO055_GYRO_OFFSET_X_LSB);
gume 0:1f82672b8755 10221 data_u8[BNO055_SENSOR_OFFSET_DATA_X_MSB] =
gume 0:1f82672b8755 10222 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 10223 data_u8[BNO055_SENSOR_OFFSET_DATA_X_MSB],
gume 0:1f82672b8755 10224 BNO055_GYRO_OFFSET_X_MSB);
gume 0:1f82672b8755 10225 gyro_offset->x = (s16)((((s32)(s8)
gume 0:1f82672b8755 10226 (data_u8[BNO055_SENSOR_OFFSET_DATA_X_MSB])) <<
gume 0:1f82672b8755 10227 (BNO055_SHIFT_EIGHT_BITS)) |
gume 0:1f82672b8755 10228 (data_u8[BNO055_SENSOR_OFFSET_DATA_X_LSB]));
gume 0:1f82672b8755 10229
gume 0:1f82672b8755 10230 /* Read gyro y offset value*/
gume 0:1f82672b8755 10231 data_u8[BNO055_SENSOR_OFFSET_DATA_Y_LSB] =
gume 0:1f82672b8755 10232 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 10233 data_u8[BNO055_SENSOR_OFFSET_DATA_Y_LSB],
gume 0:1f82672b8755 10234 BNO055_GYRO_OFFSET_Y_LSB);
gume 0:1f82672b8755 10235 data_u8[BNO055_SENSOR_OFFSET_DATA_Y_MSB] =
gume 0:1f82672b8755 10236 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 10237 data_u8[BNO055_SENSOR_OFFSET_DATA_Y_MSB],
gume 0:1f82672b8755 10238 BNO055_GYRO_OFFSET_Y_MSB);
gume 0:1f82672b8755 10239 gyro_offset->y = (s16)((((s32)(s8)
gume 0:1f82672b8755 10240 (data_u8[BNO055_SENSOR_OFFSET_DATA_Y_MSB])) <<
gume 0:1f82672b8755 10241 (BNO055_SHIFT_EIGHT_BITS)) |
gume 0:1f82672b8755 10242 (data_u8[BNO055_SENSOR_OFFSET_DATA_Y_LSB]));
gume 0:1f82672b8755 10243
gume 0:1f82672b8755 10244 /* Read gyro z offset value*/
gume 0:1f82672b8755 10245 data_u8[BNO055_SENSOR_OFFSET_DATA_Z_LSB] =
gume 0:1f82672b8755 10246 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 10247 data_u8[BNO055_SENSOR_OFFSET_DATA_Z_LSB],
gume 0:1f82672b8755 10248 BNO055_GYRO_OFFSET_Z_LSB);
gume 0:1f82672b8755 10249 data_u8[BNO055_SENSOR_OFFSET_DATA_Z_MSB] =
gume 0:1f82672b8755 10250 BNO055_GET_BITSLICE(
gume 0:1f82672b8755 10251 data_u8[BNO055_SENSOR_OFFSET_DATA_Z_MSB],
gume 0:1f82672b8755 10252 BNO055_GYRO_OFFSET_Z_MSB);
gume 0:1f82672b8755 10253 gyro_offset->z = (s16)((((s32)(s8)
gume 0:1f82672b8755 10254 (data_u8[BNO055_SENSOR_OFFSET_DATA_Z_MSB])) <<
gume 0:1f82672b8755 10255 (BNO055_SHIFT_EIGHT_BITS)) |
gume 0:1f82672b8755 10256 (data_u8[BNO055_SENSOR_OFFSET_DATA_Z_LSB]));
gume 0:1f82672b8755 10257 } else {
gume 0:1f82672b8755 10258 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10259 }
gume 0:1f82672b8755 10260 } else {
gume 0:1f82672b8755 10261 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10262 }
gume 0:1f82672b8755 10263 }
gume 0:1f82672b8755 10264 return com_rslt;
gume 0:1f82672b8755 10265 }
gume 0:1f82672b8755 10266 /*!
gume 0:1f82672b8755 10267 * @brief This API is used to read gyro offset
gume 0:1f82672b8755 10268 * offset form register 0x61 to 0x66
gume 0:1f82672b8755 10269 *
gume 0:1f82672b8755 10270 * @param gyro_offset : The value of gyro offset
gume 0:1f82672b8755 10271 *
gume 0:1f82672b8755 10272 * bno055_gyro_offset_t | result
gume 0:1f82672b8755 10273 * ------------------- | ----------------
gume 0:1f82672b8755 10274 * x | gyro offset x
gume 0:1f82672b8755 10275 * y | gyro offset y
gume 0:1f82672b8755 10276 * z | gyro offset z
gume 0:1f82672b8755 10277 *
gume 0:1f82672b8755 10278 *
gume 0:1f82672b8755 10279 * @return results of bus communication function
gume 0:1f82672b8755 10280 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 10281 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 10282 *
gume 0:1f82672b8755 10283 * @note The range of the gyro offset varies based on
gume 0:1f82672b8755 10284 * the range of gyro sensor
gume 0:1f82672b8755 10285 *
gume 0:1f82672b8755 10286 * gyro G range | offset range
gume 0:1f82672b8755 10287 * -------------------- | ------------
gume 0:1f82672b8755 10288 * BNO055_GYRO_RANGE_2000DPS | +/-32000
gume 0:1f82672b8755 10289 * BNO055_GYRO_RANGE_1000DPS | +/-16000
gume 0:1f82672b8755 10290 * BNO055_GYRO_RANGE_500DPS | +/-8000
gume 0:1f82672b8755 10291 * BNO055_GYRO_RANGE_250DPS | +/-4000
gume 0:1f82672b8755 10292 * BNO055_GYRO_RANGE_125DPS | +/-2000
gume 0:1f82672b8755 10293 *
gume 0:1f82672b8755 10294 * Gyro range can be configured by using the
gume 0:1f82672b8755 10295 * bno055_set_gyro_range() API
gume 0:1f82672b8755 10296 */
gume 0:1f82672b8755 10297 BNO055_RETURN_FUNCTION_TYPE bno055_write_gyro_offset(
gume 0:1f82672b8755 10298 struct bno055_gyro_offset_t *gyro_offset)
gume 0:1f82672b8755 10299 {
gume 0:1f82672b8755 10300 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10301 u8 data1_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 10302 u8 data2_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 10303 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 10304 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 10305 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 10306 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 10307 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 10308 } else {
gume 0:1f82672b8755 10309 /* The write operation effective only if the operation
gume 0:1f82672b8755 10310 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 10311 current operation mode and set the config mode */
gume 0:1f82672b8755 10312 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 10313 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 10314 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 10315 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 10316 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 10317 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 10318 /* write gryo offset x value*/
gume 0:1f82672b8755 10319 com_rslt =
gume 0:1f82672b8755 10320 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 10321 (p_bno055->dev_addr,
gume 0:1f82672b8755 10322 BNO055_GYRO_OFFSET_X_LSB_REG,
gume 0:1f82672b8755 10323 &data2_u8r,
gume 0:1f82672b8755 10324 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10325 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 10326 data1_u8r = ((s8)
gume 0:1f82672b8755 10327 (gyro_offset->x
gume 0:1f82672b8755 10328 & BNO055_SIC_HEX_0_0_F_F_DATA));
gume 0:1f82672b8755 10329 data2_u8r =
gume 0:1f82672b8755 10330 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 10331 BNO055_GYRO_OFFSET_X_LSB,
gume 0:1f82672b8755 10332 data1_u8r);
gume 0:1f82672b8755 10333 com_rslt +=
gume 0:1f82672b8755 10334 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 10335 (p_bno055->dev_addr,
gume 0:1f82672b8755 10336 BNO055_GYRO_OFFSET_X_LSB_REG,
gume 0:1f82672b8755 10337 &data2_u8r,
gume 0:1f82672b8755 10338 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10339 }
gume 0:1f82672b8755 10340
gume 0:1f82672b8755 10341 com_rslt +=
gume 0:1f82672b8755 10342 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 10343 (p_bno055->dev_addr,
gume 0:1f82672b8755 10344 BNO055_GYRO_OFFSET_X_MSB_REG,
gume 0:1f82672b8755 10345 &data2_u8r,
gume 0:1f82672b8755 10346 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10347 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 10348 data1_u8r = ((s8)
gume 0:1f82672b8755 10349 (gyro_offset->x >>
gume 0:1f82672b8755 10350 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 10351 & BNO055_SIC_HEX_0_0_F_F_DATA);
gume 0:1f82672b8755 10352 data2_u8r =
gume 0:1f82672b8755 10353 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 10354 BNO055_GYRO_OFFSET_X_MSB,
gume 0:1f82672b8755 10355 data1_u8r);
gume 0:1f82672b8755 10356 com_rslt +=
gume 0:1f82672b8755 10357 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 10358 (p_bno055->dev_addr,
gume 0:1f82672b8755 10359 BNO055_GYRO_OFFSET_X_MSB_REG,
gume 0:1f82672b8755 10360 &data2_u8r,
gume 0:1f82672b8755 10361 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10362 }
gume 0:1f82672b8755 10363
gume 0:1f82672b8755 10364 /* write gryo offset y value*/
gume 0:1f82672b8755 10365 com_rslt +=
gume 0:1f82672b8755 10366 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 10367 (p_bno055->dev_addr,
gume 0:1f82672b8755 10368 BNO055_GYRO_OFFSET_Y_LSB_REG,
gume 0:1f82672b8755 10369 &data2_u8r,
gume 0:1f82672b8755 10370 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10371 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 10372 data1_u8r = ((s8)
gume 0:1f82672b8755 10373 (gyro_offset->y
gume 0:1f82672b8755 10374 & BNO055_SIC_HEX_0_0_F_F_DATA));
gume 0:1f82672b8755 10375 data2_u8r =
gume 0:1f82672b8755 10376 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 10377 BNO055_GYRO_OFFSET_Y_LSB,
gume 0:1f82672b8755 10378 data1_u8r);
gume 0:1f82672b8755 10379 com_rslt +=
gume 0:1f82672b8755 10380 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 10381 (p_bno055->dev_addr,
gume 0:1f82672b8755 10382 BNO055_GYRO_OFFSET_Y_LSB_REG,
gume 0:1f82672b8755 10383 &data2_u8r,
gume 0:1f82672b8755 10384 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10385 }
gume 0:1f82672b8755 10386
gume 0:1f82672b8755 10387 com_rslt +=
gume 0:1f82672b8755 10388 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 10389 (p_bno055->dev_addr,
gume 0:1f82672b8755 10390 BNO055_GYRO_OFFSET_Y_MSB_REG,
gume 0:1f82672b8755 10391 &data2_u8r,
gume 0:1f82672b8755 10392 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10393 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 10394 data1_u8r = ((s8)
gume 0:1f82672b8755 10395 (gyro_offset->y >>
gume 0:1f82672b8755 10396 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 10397 & BNO055_SIC_HEX_0_0_F_F_DATA);
gume 0:1f82672b8755 10398 data2_u8r =
gume 0:1f82672b8755 10399 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 10400 BNO055_GYRO_OFFSET_Y_MSB,
gume 0:1f82672b8755 10401 data1_u8r);
gume 0:1f82672b8755 10402 com_rslt +=
gume 0:1f82672b8755 10403 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 10404 (p_bno055->dev_addr,
gume 0:1f82672b8755 10405 BNO055_GYRO_OFFSET_Y_MSB_REG,
gume 0:1f82672b8755 10406 &data2_u8r,
gume 0:1f82672b8755 10407 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10408 }
gume 0:1f82672b8755 10409 /* write gryo offset z value*/
gume 0:1f82672b8755 10410 com_rslt +=
gume 0:1f82672b8755 10411 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 10412 (p_bno055->dev_addr,
gume 0:1f82672b8755 10413 BNO055_GYRO_OFFSET_Z_LSB_REG,
gume 0:1f82672b8755 10414 &data2_u8r,
gume 0:1f82672b8755 10415 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10416 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 10417 data1_u8r = ((s8)
gume 0:1f82672b8755 10418 (gyro_offset->z
gume 0:1f82672b8755 10419 & BNO055_SIC_HEX_0_0_F_F_DATA));
gume 0:1f82672b8755 10420 data2_u8r =
gume 0:1f82672b8755 10421 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 10422 BNO055_GYRO_OFFSET_Z_LSB,
gume 0:1f82672b8755 10423 data1_u8r);
gume 0:1f82672b8755 10424 com_rslt +=
gume 0:1f82672b8755 10425 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 10426 (p_bno055->dev_addr,
gume 0:1f82672b8755 10427 BNO055_GYRO_OFFSET_Z_LSB_REG,
gume 0:1f82672b8755 10428 &data2_u8r,
gume 0:1f82672b8755 10429 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10430 }
gume 0:1f82672b8755 10431
gume 0:1f82672b8755 10432 com_rslt +=
gume 0:1f82672b8755 10433 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 10434 (p_bno055->dev_addr,
gume 0:1f82672b8755 10435 BNO055_GYRO_OFFSET_Z_MSB_REG,
gume 0:1f82672b8755 10436 &data2_u8r,
gume 0:1f82672b8755 10437 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10438 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 10439 data1_u8r = ((s8)
gume 0:1f82672b8755 10440 (gyro_offset->z >>
gume 0:1f82672b8755 10441 BNO055_SHIFT_EIGHT_BITS)
gume 0:1f82672b8755 10442 & BNO055_SIC_HEX_0_0_F_F_DATA);
gume 0:1f82672b8755 10443 data2_u8r =
gume 0:1f82672b8755 10444 BNO055_SET_BITSLICE(data2_u8r,
gume 0:1f82672b8755 10445 BNO055_GYRO_OFFSET_Z_MSB,
gume 0:1f82672b8755 10446 data1_u8r);
gume 0:1f82672b8755 10447 com_rslt +=
gume 0:1f82672b8755 10448 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 10449 (p_bno055->dev_addr,
gume 0:1f82672b8755 10450 BNO055_GYRO_OFFSET_Z_MSB_REG,
gume 0:1f82672b8755 10451 &data2_u8r,
gume 0:1f82672b8755 10452 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10453 }
gume 0:1f82672b8755 10454 } else {
gume 0:1f82672b8755 10455 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10456 }
gume 0:1f82672b8755 10457 } else {
gume 0:1f82672b8755 10458 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10459 }
gume 0:1f82672b8755 10460 }
gume 0:1f82672b8755 10461 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 10462 /* set the operation mode
gume 0:1f82672b8755 10463 of previous operation mode*/
gume 0:1f82672b8755 10464 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 10465 (prev_opmode_u8);
gume 0:1f82672b8755 10466 return com_rslt;
gume 0:1f82672b8755 10467 }
gume 0:1f82672b8755 10468 /********************************************************/
gume 0:1f82672b8755 10469 /************** PAGE1 Functions *********************/
gume 0:1f82672b8755 10470 /********************************************************/
gume 0:1f82672b8755 10471 /*!
gume 0:1f82672b8755 10472 * @brief This API used to read the accel range
gume 0:1f82672b8755 10473 * from page one register from 0x08 bit 0 and 1
gume 0:1f82672b8755 10474 *
gume 0:1f82672b8755 10475 * @param accel_range_u8 : The value of accel range
gume 0:1f82672b8755 10476 * accel_range_u8 | result
gume 0:1f82672b8755 10477 * ----------------- | --------------
gume 0:1f82672b8755 10478 * 0x00 | BNO055_ACCEL_RANGE_2G
gume 0:1f82672b8755 10479 * 0x01 | BNO055_ACCEL_RANGE_4G
gume 0:1f82672b8755 10480 * 0x02 | BNO055_ACCEL_RANGE_8G
gume 0:1f82672b8755 10481 * 0x03 | BNO055_ACCEL_RANGE_16G
gume 0:1f82672b8755 10482 *
gume 0:1f82672b8755 10483 * @return results of bus communication function
gume 0:1f82672b8755 10484 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 10485 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 10486 *
gume 0:1f82672b8755 10487 *
gume 0:1f82672b8755 10488 */
gume 0:1f82672b8755 10489 BNO055_RETURN_FUNCTION_TYPE bno055_get_accel_range(
gume 0:1f82672b8755 10490 u8 *accel_range_u8)
gume 0:1f82672b8755 10491 {
gume 0:1f82672b8755 10492 /* Variable used to return value of
gume 0:1f82672b8755 10493 communication routine*/
gume 0:1f82672b8755 10494 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10495 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 10496 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 10497 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 10498 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 10499 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 10500 } else {
gume 0:1f82672b8755 10501 /*condition check for page, accel range is
gume 0:1f82672b8755 10502 available in the page one*/
gume 0:1f82672b8755 10503 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 10504 /* Write page as one */
gume 0:1f82672b8755 10505 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 10506 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 10507 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 10508 /* Read the value of accel g range */
gume 0:1f82672b8755 10509 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 10510 (p_bno055->dev_addr,
gume 0:1f82672b8755 10511 BNO055_ACCEL_RANGE_REG,
gume 0:1f82672b8755 10512 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10513 *accel_range_u8 =
gume 0:1f82672b8755 10514 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 10515 BNO055_ACCEL_RANGE);
gume 0:1f82672b8755 10516 } else {
gume 0:1f82672b8755 10517 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10518 }
gume 0:1f82672b8755 10519 }
gume 0:1f82672b8755 10520 return com_rslt;
gume 0:1f82672b8755 10521 }
gume 0:1f82672b8755 10522 /*!
gume 0:1f82672b8755 10523 * @brief This API used to write the accel range
gume 0:1f82672b8755 10524 * from page one register from 0x08 bit 0 and 1
gume 0:1f82672b8755 10525 *
gume 0:1f82672b8755 10526 * @param accel_range_u8 : The value of accel range
gume 0:1f82672b8755 10527 *
gume 0:1f82672b8755 10528 * accel_range_u8 | result
gume 0:1f82672b8755 10529 * ----------------- | --------------
gume 0:1f82672b8755 10530 * 0x00 | BNO055_ACCEL_RANGE_2G
gume 0:1f82672b8755 10531 * 0x01 | BNO055_ACCEL_RANGE_4G
gume 0:1f82672b8755 10532 * 0x02 | BNO055_ACCEL_RANGE_8G
gume 0:1f82672b8755 10533 * 0x03 | BNO055_ACCEL_RANGE_16G
gume 0:1f82672b8755 10534 *
gume 0:1f82672b8755 10535 * @return results of bus communication function
gume 0:1f82672b8755 10536 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 10537 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 10538 *
gume 0:1f82672b8755 10539 *
gume 0:1f82672b8755 10540 */
gume 0:1f82672b8755 10541 BNO055_RETURN_FUNCTION_TYPE bno055_set_accel_range(
gume 0:1f82672b8755 10542 u8 accel_range_u8)
gume 0:1f82672b8755 10543 {
gume 0:1f82672b8755 10544 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10545 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 10546 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 10547 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 10548 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 10549 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 10550 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 10551 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 10552 } else {
gume 0:1f82672b8755 10553 /* The write operation effective only if the operation
gume 0:1f82672b8755 10554 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 10555 current operation mode and set the config mode */
gume 0:1f82672b8755 10556 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 10557 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 10558 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 10559 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 10560 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 10561 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 10562 /* Write page as one */
gume 0:1f82672b8755 10563 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 10564 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 10565 if (accel_range_u8 < BNO055_ACCEL_RANGE) {
gume 0:1f82672b8755 10566 /* Write the value of accel range*/
gume 0:1f82672b8755 10567 com_rslt =
gume 0:1f82672b8755 10568 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 10569 (p_bno055->dev_addr,
gume 0:1f82672b8755 10570 BNO055_ACCEL_RANGE_REG,
gume 0:1f82672b8755 10571 &data_u8r,
gume 0:1f82672b8755 10572 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10573 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 10574 data_u8r = BNO055_SET_BITSLICE
gume 0:1f82672b8755 10575 (data_u8r,
gume 0:1f82672b8755 10576 BNO055_ACCEL_RANGE,
gume 0:1f82672b8755 10577 accel_range_u8);
gume 0:1f82672b8755 10578 com_rslt +=
gume 0:1f82672b8755 10579 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 10580 (p_bno055->dev_addr,
gume 0:1f82672b8755 10581 BNO055_ACCEL_RANGE_REG,
gume 0:1f82672b8755 10582 &data_u8r,
gume 0:1f82672b8755 10583 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10584 }
gume 0:1f82672b8755 10585 } else {
gume 0:1f82672b8755 10586 com_rslt = BNO055_OUT_OF_RANGE;
gume 0:1f82672b8755 10587 }
gume 0:1f82672b8755 10588 } else {
gume 0:1f82672b8755 10589 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10590 }
gume 0:1f82672b8755 10591 } else {
gume 0:1f82672b8755 10592 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10593 }
gume 0:1f82672b8755 10594 } else {
gume 0:1f82672b8755 10595 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10596 }
gume 0:1f82672b8755 10597 }
gume 0:1f82672b8755 10598 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 10599 /* set the operation mode of
gume 0:1f82672b8755 10600 previous operation mode*/
gume 0:1f82672b8755 10601 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 10602 (prev_opmode_u8);
gume 0:1f82672b8755 10603 return com_rslt;
gume 0:1f82672b8755 10604 }
gume 0:1f82672b8755 10605 /*!
gume 0:1f82672b8755 10606 * @brief This API used to read the accel bandwidth
gume 0:1f82672b8755 10607 * from page one register from 0x08 bit 2 to 4
gume 0:1f82672b8755 10608 *
gume 0:1f82672b8755 10609 * @param accel_bw_u8 : The value of accel bandwidth
gume 0:1f82672b8755 10610 *
gume 0:1f82672b8755 10611 * accel_bw_u8 | result
gume 0:1f82672b8755 10612 * ----------------- | ---------------
gume 0:1f82672b8755 10613 * 0x00 | BNO055_ACCEL_BW_7_81HZ
gume 0:1f82672b8755 10614 * 0x01 | BNO055_ACCEL_BW_15_63HZ
gume 0:1f82672b8755 10615 * 0x02 | BNO055_ACCEL_BW_31_25HZ
gume 0:1f82672b8755 10616 * 0x03 | BNO055_ACCEL_BW_62_5HZ
gume 0:1f82672b8755 10617 * 0x04 | BNO055_ACCEL_BW_125HZ
gume 0:1f82672b8755 10618 * 0x05 | BNO055_ACCEL_BW_250HZ
gume 0:1f82672b8755 10619 * 0x06 | BNO055_ACCEL_BW_500HZ
gume 0:1f82672b8755 10620 * 0x07 | BNO055_ACCEL_BW_1000HZ
gume 0:1f82672b8755 10621 *
gume 0:1f82672b8755 10622 * @return results of bus communication function
gume 0:1f82672b8755 10623 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 10624 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 10625 *
gume 0:1f82672b8755 10626 *
gume 0:1f82672b8755 10627 */
gume 0:1f82672b8755 10628 BNO055_RETURN_FUNCTION_TYPE bno055_get_accel_bw(
gume 0:1f82672b8755 10629 u8 *accel_bw_u8)
gume 0:1f82672b8755 10630 {
gume 0:1f82672b8755 10631 /* Variable used to return value of
gume 0:1f82672b8755 10632 communication routine*/
gume 0:1f82672b8755 10633 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10634 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 10635 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 10636 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 10637 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 10638 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 10639 } else {
gume 0:1f82672b8755 10640 /*condition check for page, accel bandwidth is
gume 0:1f82672b8755 10641 available in the page one*/
gume 0:1f82672b8755 10642 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 10643 /* Write page as one */
gume 0:1f82672b8755 10644 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 10645 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 10646 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 10647 /* Read the value of accel bandwidth */
gume 0:1f82672b8755 10648 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 10649 (p_bno055->dev_addr,
gume 0:1f82672b8755 10650 BNO055_ACCEL_BW_REG,
gume 0:1f82672b8755 10651 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10652 *accel_bw_u8 =
gume 0:1f82672b8755 10653 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 10654 BNO055_ACCEL_BW);
gume 0:1f82672b8755 10655 } else {
gume 0:1f82672b8755 10656 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10657 }
gume 0:1f82672b8755 10658 }
gume 0:1f82672b8755 10659 return com_rslt;
gume 0:1f82672b8755 10660 }
gume 0:1f82672b8755 10661 /*!
gume 0:1f82672b8755 10662 * @brief This API used to write the accel bandwidth
gume 0:1f82672b8755 10663 * from page one register from 0x08 bit 2 to 4
gume 0:1f82672b8755 10664 *
gume 0:1f82672b8755 10665 * @param accel_bw_u8 : The value of accel bandwidth
gume 0:1f82672b8755 10666 *
gume 0:1f82672b8755 10667 * accel_bw_u8 | result
gume 0:1f82672b8755 10668 * ----------------- | ---------------
gume 0:1f82672b8755 10669 * 0x00 | BNO055_ACCEL_BW_7_81HZ
gume 0:1f82672b8755 10670 * 0x01 | BNO055_ACCEL_BW_15_63HZ
gume 0:1f82672b8755 10671 * 0x02 | BNO055_ACCEL_BW_31_25HZ
gume 0:1f82672b8755 10672 * 0x03 | BNO055_ACCEL_BW_62_5HZ
gume 0:1f82672b8755 10673 * 0x04 | BNO055_ACCEL_BW_125HZ
gume 0:1f82672b8755 10674 * 0x05 | BNO055_ACCEL_BW_250HZ
gume 0:1f82672b8755 10675 * 0x06 | BNO055_ACCEL_BW_500HZ
gume 0:1f82672b8755 10676 * 0x07 | BNO055_ACCEL_BW_1000HZ
gume 0:1f82672b8755 10677 *
gume 0:1f82672b8755 10678 * @return results of bus communication function
gume 0:1f82672b8755 10679 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 10680 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 10681 *
gume 0:1f82672b8755 10682 *
gume 0:1f82672b8755 10683 */
gume 0:1f82672b8755 10684 BNO055_RETURN_FUNCTION_TYPE bno055_set_accel_bw(
gume 0:1f82672b8755 10685 u8 accel_bw_u8)
gume 0:1f82672b8755 10686 {
gume 0:1f82672b8755 10687 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10688 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 10689 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 10690 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 10691 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 10692 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 10693 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 10694 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 10695 } else {
gume 0:1f82672b8755 10696 /* The write operation effective only if the operation
gume 0:1f82672b8755 10697 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 10698 current operation mode and set the config mode */
gume 0:1f82672b8755 10699 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 10700 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 10701 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 10702 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 10703 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 10704 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 10705 /* Write page as one */
gume 0:1f82672b8755 10706 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 10707 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 10708 if (accel_bw_u8 <
gume 0:1f82672b8755 10709 BNO055_ACCEL_GYRO_BW_RANGE) {
gume 0:1f82672b8755 10710 /* Write the accel */
gume 0:1f82672b8755 10711 com_rslt =
gume 0:1f82672b8755 10712 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 10713 (p_bno055->dev_addr,
gume 0:1f82672b8755 10714 BNO055_ACCEL_BW_REG,
gume 0:1f82672b8755 10715 &data_u8r,
gume 0:1f82672b8755 10716 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10717 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 10718 data_u8r = BNO055_SET_BITSLICE
gume 0:1f82672b8755 10719 (data_u8r, BNO055_ACCEL_BW,
gume 0:1f82672b8755 10720 accel_bw_u8);
gume 0:1f82672b8755 10721 com_rslt +=
gume 0:1f82672b8755 10722 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 10723 (p_bno055->dev_addr,
gume 0:1f82672b8755 10724 BNO055_ACCEL_BW_REG,
gume 0:1f82672b8755 10725 &data_u8r,
gume 0:1f82672b8755 10726 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10727 }
gume 0:1f82672b8755 10728 } else {
gume 0:1f82672b8755 10729 com_rslt = BNO055_OUT_OF_RANGE;
gume 0:1f82672b8755 10730 }
gume 0:1f82672b8755 10731 } else {
gume 0:1f82672b8755 10732 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10733 }
gume 0:1f82672b8755 10734 } else {
gume 0:1f82672b8755 10735 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10736 }
gume 0:1f82672b8755 10737 } else {
gume 0:1f82672b8755 10738 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10739 }
gume 0:1f82672b8755 10740 }
gume 0:1f82672b8755 10741 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 10742 /* set the operation mode of
gume 0:1f82672b8755 10743 previous operation mode*/
gume 0:1f82672b8755 10744 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 10745 (prev_opmode_u8);
gume 0:1f82672b8755 10746 return com_rslt;
gume 0:1f82672b8755 10747 }
gume 0:1f82672b8755 10748 /*!
gume 0:1f82672b8755 10749 * @brief This API used to read the accel power mode
gume 0:1f82672b8755 10750 * from page one register from 0x08 bit 5 to 7
gume 0:1f82672b8755 10751 *
gume 0:1f82672b8755 10752 * @param accel_power_mode_u8 : The value of accel power mode
gume 0:1f82672b8755 10753 * accel_power_mode_u8 | result
gume 0:1f82672b8755 10754 * ----------------- | -------------
gume 0:1f82672b8755 10755 * 0x00 | BNO055_ACCEL_NORMAL
gume 0:1f82672b8755 10756 * 0x01 | BNO055_ACCEL_SUSPEND
gume 0:1f82672b8755 10757 * 0x02 | BNO055_ACCEL_LOWPOWER_1
gume 0:1f82672b8755 10758 * 0x03 | BNO055_ACCEL_STANDBY
gume 0:1f82672b8755 10759 * 0x04 | BNO055_ACCEL_LOWPOWER_2
gume 0:1f82672b8755 10760 * 0x05 | BNO055_ACCEL_DEEPSUSPEND
gume 0:1f82672b8755 10761 *
gume 0:1f82672b8755 10762 * @return results of bus communication function
gume 0:1f82672b8755 10763 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 10764 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 10765 *
gume 0:1f82672b8755 10766 *
gume 0:1f82672b8755 10767 */
gume 0:1f82672b8755 10768 BNO055_RETURN_FUNCTION_TYPE bno055_get_accel_power_mode(
gume 0:1f82672b8755 10769 u8 *accel_power_mode_u8)
gume 0:1f82672b8755 10770 {
gume 0:1f82672b8755 10771 /* Variable used to return value of
gume 0:1f82672b8755 10772 communication routine*/
gume 0:1f82672b8755 10773 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10774 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 10775 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 10776 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 10777 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 10778 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 10779 } else {
gume 0:1f82672b8755 10780 /*condition check for page, accel power mode is
gume 0:1f82672b8755 10781 available in the page one*/
gume 0:1f82672b8755 10782 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 10783 /* Write page as one */
gume 0:1f82672b8755 10784 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 10785 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 10786 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 10787 /* Read the value of accel bandwidth */
gume 0:1f82672b8755 10788 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 10789 (p_bno055->dev_addr,
gume 0:1f82672b8755 10790 BNO055_ACCEL_POWER_MODE_REG,
gume 0:1f82672b8755 10791 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10792 *accel_power_mode_u8 =
gume 0:1f82672b8755 10793 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 10794 BNO055_ACCEL_POWER_MODE);
gume 0:1f82672b8755 10795 } else {
gume 0:1f82672b8755 10796 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10797 }
gume 0:1f82672b8755 10798 }
gume 0:1f82672b8755 10799 return com_rslt;
gume 0:1f82672b8755 10800 }
gume 0:1f82672b8755 10801 /*!
gume 0:1f82672b8755 10802 * @brief This API used to write the accel power mode
gume 0:1f82672b8755 10803 * from page one register from 0x08 bit 5 to 7
gume 0:1f82672b8755 10804 *
gume 0:1f82672b8755 10805 * @param accel_power_mode_u8 : The value of accel power mode
gume 0:1f82672b8755 10806 * accel_power_mode_u8 | result
gume 0:1f82672b8755 10807 * ----------------- | -------------
gume 0:1f82672b8755 10808 * 0x00 | BNO055_ACCEL_NORMAL
gume 0:1f82672b8755 10809 * 0x01 | BNO055_ACCEL_SUSPEND
gume 0:1f82672b8755 10810 * 0x02 | BNO055_ACCEL_LOWPOWER_1
gume 0:1f82672b8755 10811 * 0x03 | BNO055_ACCEL_STANDBY
gume 0:1f82672b8755 10812 * 0x04 | BNO055_ACCEL_LOWPOWER_2
gume 0:1f82672b8755 10813 * 0x05 | BNO055_ACCEL_DEEPSUSPEND
gume 0:1f82672b8755 10814 *
gume 0:1f82672b8755 10815 * @return results of bus communication function
gume 0:1f82672b8755 10816 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 10817 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 10818 *
gume 0:1f82672b8755 10819 *
gume 0:1f82672b8755 10820 */
gume 0:1f82672b8755 10821 BNO055_RETURN_FUNCTION_TYPE bno055_set_accel_power_mode(
gume 0:1f82672b8755 10822 u8 accel_power_mode_u8)
gume 0:1f82672b8755 10823 {
gume 0:1f82672b8755 10824 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10825 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 10826 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 10827 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 10828 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 10829 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 10830 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 10831 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 10832 } else {
gume 0:1f82672b8755 10833 /* The write operation effective only if the operation
gume 0:1f82672b8755 10834 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 10835 current operation mode and set the config mode */
gume 0:1f82672b8755 10836 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 10837 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 10838 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 10839 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 10840 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 10841 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 10842 /* Write page as one */
gume 0:1f82672b8755 10843 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 10844 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 10845 if (accel_power_mode_u8 <
gume 0:1f82672b8755 10846 BNO055_ACCEL_POWER_MODE_RANGE) {
gume 0:1f82672b8755 10847 /* Write the value of accel bandwidth*/
gume 0:1f82672b8755 10848 com_rslt =
gume 0:1f82672b8755 10849 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 10850 (p_bno055->dev_addr,
gume 0:1f82672b8755 10851 BNO055_ACCEL_POWER_MODE_REG,
gume 0:1f82672b8755 10852 &data_u8r,
gume 0:1f82672b8755 10853 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10854 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 10855 data_u8r = BNO055_SET_BITSLICE
gume 0:1f82672b8755 10856 (data_u8r,
gume 0:1f82672b8755 10857 BNO055_ACCEL_POWER_MODE,
gume 0:1f82672b8755 10858 accel_power_mode_u8);
gume 0:1f82672b8755 10859 com_rslt +=
gume 0:1f82672b8755 10860 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 10861 (p_bno055->dev_addr,
gume 0:1f82672b8755 10862 BNO055_ACCEL_POWER_MODE_REG,
gume 0:1f82672b8755 10863 &data_u8r,
gume 0:1f82672b8755 10864 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10865 }
gume 0:1f82672b8755 10866 } else {
gume 0:1f82672b8755 10867 com_rslt = BNO055_OUT_OF_RANGE;
gume 0:1f82672b8755 10868 }
gume 0:1f82672b8755 10869 } else {
gume 0:1f82672b8755 10870 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10871 }
gume 0:1f82672b8755 10872 } else {
gume 0:1f82672b8755 10873 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10874 }
gume 0:1f82672b8755 10875 } else {
gume 0:1f82672b8755 10876 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10877 }
gume 0:1f82672b8755 10878 }
gume 0:1f82672b8755 10879 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 10880 /* set the operation mode of
gume 0:1f82672b8755 10881 previous operation mode*/
gume 0:1f82672b8755 10882 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 10883 (prev_opmode_u8);
gume 0:1f82672b8755 10884 return com_rslt;
gume 0:1f82672b8755 10885 }
gume 0:1f82672b8755 10886 /*!
gume 0:1f82672b8755 10887 * @brief This API used to read the mag output data rate
gume 0:1f82672b8755 10888 * from page one register from 0x09 bit 0 to 2
gume 0:1f82672b8755 10889 *
gume 0:1f82672b8755 10890 * @param mag_data_output_rate_u8 : The value of mag output data rate
gume 0:1f82672b8755 10891 *
gume 0:1f82672b8755 10892 * mag_data_output_rate_u8 | result
gume 0:1f82672b8755 10893 * ---------------------- |----------------------
gume 0:1f82672b8755 10894 * 0x00 | MAG_DATA_OUTPUT_RATE_2HZ
gume 0:1f82672b8755 10895 * 0x01 | MAG_DATA_OUTPUT_RATE_6HZ
gume 0:1f82672b8755 10896 * 0x02 | MAG_DATA_OUTPUT_RATE_8HZ
gume 0:1f82672b8755 10897 * 0x03 | MAG_DATA_OUTPUT_RATE_10HZ
gume 0:1f82672b8755 10898 * 0x04 | MAG_DATA_OUTPUT_RATE_15HZ
gume 0:1f82672b8755 10899 * 0x05 | MAG_DATA_OUTPUT_RATE_20HZ
gume 0:1f82672b8755 10900 * 0x06 | MAG_DATA_OUTPUT_RATE_25HZ
gume 0:1f82672b8755 10901 * 0x07 | MAG_DATA_OUTPUT_RATE_30HZ
gume 0:1f82672b8755 10902 *
gume 0:1f82672b8755 10903 * @return results of bus communication function
gume 0:1f82672b8755 10904 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 10905 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 10906 *
gume 0:1f82672b8755 10907 *
gume 0:1f82672b8755 10908 */
gume 0:1f82672b8755 10909 BNO055_RETURN_FUNCTION_TYPE bno055_get_mag_data_output_rate(
gume 0:1f82672b8755 10910 u8 *mag_data_output_rate_u8)
gume 0:1f82672b8755 10911 {
gume 0:1f82672b8755 10912 /* Variable used to return value of
gume 0:1f82672b8755 10913 communication routine*/
gume 0:1f82672b8755 10914 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10915 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 10916 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 10917 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 10918 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 10919 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 10920 } else {
gume 0:1f82672b8755 10921 /*condition check for page, output data rate
gume 0:1f82672b8755 10922 available in the page one*/
gume 0:1f82672b8755 10923 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 10924 /* Write page as one */
gume 0:1f82672b8755 10925 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 10926 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 10927 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 10928 /* Read the mag output data rate*/
gume 0:1f82672b8755 10929 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 10930 (p_bno055->dev_addr,
gume 0:1f82672b8755 10931 BNO055_MAG_DATA_OUTPUT_RATE_REG,
gume 0:1f82672b8755 10932 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10933 *mag_data_output_rate_u8 =
gume 0:1f82672b8755 10934 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 10935 BNO055_MAG_DATA_OUTPUT_RATE);
gume 0:1f82672b8755 10936 } else {
gume 0:1f82672b8755 10937 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10938 }
gume 0:1f82672b8755 10939 }
gume 0:1f82672b8755 10940 return com_rslt;
gume 0:1f82672b8755 10941 }
gume 0:1f82672b8755 10942 /*!
gume 0:1f82672b8755 10943 * @brief This API used to write the mag output data rate
gume 0:1f82672b8755 10944 * from page one register from 0x09 bit 0 to 2
gume 0:1f82672b8755 10945 *
gume 0:1f82672b8755 10946 * @param mag_data_output_rate_u8 : The value of mag output data rate
gume 0:1f82672b8755 10947 *
gume 0:1f82672b8755 10948 * mag_data_output_rate_u8 | result
gume 0:1f82672b8755 10949 * ---------------------- |----------------------
gume 0:1f82672b8755 10950 * 0x00 | MAG_DATA_OUTPUT_RATE_2HZ
gume 0:1f82672b8755 10951 * 0x01 | MAG_DATA_OUTPUT_RATE_6HZ
gume 0:1f82672b8755 10952 * 0x02 | MAG_DATA_OUTPUT_RATE_8HZ
gume 0:1f82672b8755 10953 * 0x03 | MAG_DATA_OUTPUT_RATE_10HZ
gume 0:1f82672b8755 10954 * 0x04 | MAG_DATA_OUTPUT_RATE_15HZ
gume 0:1f82672b8755 10955 * 0x05 | MAG_DATA_OUTPUT_RATE_20HZ
gume 0:1f82672b8755 10956 * 0x06 | MAG_DATA_OUTPUT_RATE_25HZ
gume 0:1f82672b8755 10957 * 0x07 | MAG_DATA_OUTPUT_RATE_30HZ
gume 0:1f82672b8755 10958 *
gume 0:1f82672b8755 10959 * @return results of bus communication function
gume 0:1f82672b8755 10960 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 10961 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 10962 *
gume 0:1f82672b8755 10963 *
gume 0:1f82672b8755 10964 */
gume 0:1f82672b8755 10965 BNO055_RETURN_FUNCTION_TYPE bno055_set_mag_data_output_rate(
gume 0:1f82672b8755 10966 u8 mag_data_output_rate_u8)
gume 0:1f82672b8755 10967 {
gume 0:1f82672b8755 10968 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 10969 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 10970 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 10971 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 10972 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 10973 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 10974 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 10975 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 10976 } else {
gume 0:1f82672b8755 10977 /* The write operation effective only if the operation
gume 0:1f82672b8755 10978 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 10979 current operation mode and set the config mode */
gume 0:1f82672b8755 10980 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 10981 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 10982 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 10983 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 10984 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 10985 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 10986 /* Write page as one */
gume 0:1f82672b8755 10987 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 10988 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 10989 if (mag_data_output_rate_u8
gume 0:1f82672b8755 10990 < BNO055_MAG_OUTPUT_RANGE) {
gume 0:1f82672b8755 10991 /* Write the value of
gume 0:1f82672b8755 10992 mag output data rate*/
gume 0:1f82672b8755 10993 com_rslt =
gume 0:1f82672b8755 10994 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 10995 (p_bno055->dev_addr,
gume 0:1f82672b8755 10996 BNO055_MAG_DATA_OUTPUT_RATE_REG,
gume 0:1f82672b8755 10997 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 10998 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 10999 data_u8r = BNO055_SET_BITSLICE
gume 0:1f82672b8755 11000 (data_u8r,
gume 0:1f82672b8755 11001 BNO055_MAG_DATA_OUTPUT_RATE,
gume 0:1f82672b8755 11002 mag_data_output_rate_u8);
gume 0:1f82672b8755 11003 com_rslt +=
gume 0:1f82672b8755 11004 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 11005 (p_bno055->dev_addr,
gume 0:1f82672b8755 11006 BNO055_MAG_DATA_OUTPUT_RATE_REG,
gume 0:1f82672b8755 11007 &data_u8r,
gume 0:1f82672b8755 11008 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 11009 }
gume 0:1f82672b8755 11010 } else {
gume 0:1f82672b8755 11011 com_rslt = BNO055_OUT_OF_RANGE;
gume 0:1f82672b8755 11012 }
gume 0:1f82672b8755 11013 } else {
gume 0:1f82672b8755 11014 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11015 }
gume 0:1f82672b8755 11016 } else {
gume 0:1f82672b8755 11017 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11018 }
gume 0:1f82672b8755 11019 } else {
gume 0:1f82672b8755 11020 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11021 }
gume 0:1f82672b8755 11022 }
gume 0:1f82672b8755 11023 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 11024 /* set the operation mode of
gume 0:1f82672b8755 11025 previous operation mode*/
gume 0:1f82672b8755 11026 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 11027 (prev_opmode_u8);
gume 0:1f82672b8755 11028 return com_rslt;
gume 0:1f82672b8755 11029 }
gume 0:1f82672b8755 11030 /*!
gume 0:1f82672b8755 11031 * @brief This API used to read the mag operation mode
gume 0:1f82672b8755 11032 * from page one register from 0x09 bit 3 to 4
gume 0:1f82672b8755 11033 *
gume 0:1f82672b8755 11034 * @param mag_operation_mode_u8 : The value of mag operation mode
gume 0:1f82672b8755 11035 *
gume 0:1f82672b8755 11036 * mag_operation_mode_u8 | result
gume 0:1f82672b8755 11037 * ------------------------- |--------------------------
gume 0:1f82672b8755 11038 * 0x00 | MAG_OPR_MODE_LOWPOWER
gume 0:1f82672b8755 11039 * 0x01 | MAG_OPR_MODE_REGULAR
gume 0:1f82672b8755 11040 * 0x02 | MAG_OPR_MODE_ENHANCED_REGULAR
gume 0:1f82672b8755 11041 * 0x03 | MAG_OPR_MODE_HIGH_ACCURACY
gume 0:1f82672b8755 11042 *
gume 0:1f82672b8755 11043 * @return results of bus communication function
gume 0:1f82672b8755 11044 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 11045 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 11046 *
gume 0:1f82672b8755 11047 *
gume 0:1f82672b8755 11048 */
gume 0:1f82672b8755 11049 BNO055_RETURN_FUNCTION_TYPE bno055_get_mag_operation_mode(
gume 0:1f82672b8755 11050 u8 *mag_operation_mode_u8)
gume 0:1f82672b8755 11051 {
gume 0:1f82672b8755 11052 /* Variable used to return value of
gume 0:1f82672b8755 11053 communication routine*/
gume 0:1f82672b8755 11054 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11055 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 11056 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 11057 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 11058 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 11059 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 11060 } else {
gume 0:1f82672b8755 11061 /*condition check for page, mag operation mode is
gume 0:1f82672b8755 11062 available in the page one*/
gume 0:1f82672b8755 11063 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 11064 /* Write page as one */
gume 0:1f82672b8755 11065 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 11066 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 11067 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 11068 /* Read the value of mag operation mode*/
gume 0:1f82672b8755 11069 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 11070 (p_bno055->dev_addr,
gume 0:1f82672b8755 11071 BNO055_MAG_OPERATION_MODE_REG,
gume 0:1f82672b8755 11072 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 11073 *mag_operation_mode_u8 =
gume 0:1f82672b8755 11074 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 11075 BNO055_MAG_OPERATION_MODE);
gume 0:1f82672b8755 11076 } else {
gume 0:1f82672b8755 11077 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11078 }
gume 0:1f82672b8755 11079 }
gume 0:1f82672b8755 11080 return com_rslt;
gume 0:1f82672b8755 11081 }
gume 0:1f82672b8755 11082 /*!
gume 0:1f82672b8755 11083 * @brief This API used to write the mag operation mode
gume 0:1f82672b8755 11084 * from page one register from 0x09 bit 3 to 4
gume 0:1f82672b8755 11085 *
gume 0:1f82672b8755 11086 * @param mag_operation_mode_u8 : The value of mag operation mode
gume 0:1f82672b8755 11087 *
gume 0:1f82672b8755 11088 * mag_operation_mode_u8 | result
gume 0:1f82672b8755 11089 * ------------------------- |--------------------------
gume 0:1f82672b8755 11090 * 0x00 | MAG_OPR_MODE_LOWPOWER
gume 0:1f82672b8755 11091 * 0x01 | MAG_OPR_MODE_REGULAR
gume 0:1f82672b8755 11092 * 0x02 | MAG_OPR_MODE_ENHANCED_REGULAR
gume 0:1f82672b8755 11093 * 0x03 | MAG_OPR_MODE_HIGH_ACCURACY
gume 0:1f82672b8755 11094 *
gume 0:1f82672b8755 11095 * @return results of bus communication function
gume 0:1f82672b8755 11096 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 11097 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 11098 *
gume 0:1f82672b8755 11099 *
gume 0:1f82672b8755 11100 */
gume 0:1f82672b8755 11101 BNO055_RETURN_FUNCTION_TYPE bno055_set_mag_operation_mode(
gume 0:1f82672b8755 11102 u8 mag_operation_mode_u8)
gume 0:1f82672b8755 11103 {
gume 0:1f82672b8755 11104 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11105 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 11106 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 11107 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 11108 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 11109 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 11110 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 11111 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 11112 } else {
gume 0:1f82672b8755 11113 /* The write operation effective only if the operation
gume 0:1f82672b8755 11114 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 11115 current operation mode and set the config mode */
gume 0:1f82672b8755 11116 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 11117 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 11118 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 11119 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 11120 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 11121 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 11122 /* Write page as one */
gume 0:1f82672b8755 11123 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 11124 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 11125 if (mag_operation_mode_u8
gume 0:1f82672b8755 11126 < BNO055_MAG_OPR_MODE_RANGE) {
gume 0:1f82672b8755 11127 /* Write the value
gume 0:1f82672b8755 11128 of mag operation mode*/
gume 0:1f82672b8755 11129 com_rslt =
gume 0:1f82672b8755 11130 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 11131 (p_bno055->dev_addr,
gume 0:1f82672b8755 11132 BNO055_MAG_OPERATION_MODE_REG,
gume 0:1f82672b8755 11133 &data_u8r,
gume 0:1f82672b8755 11134 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 11135 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 11136 data_u8r = BNO055_SET_BITSLICE
gume 0:1f82672b8755 11137 (data_u8r,
gume 0:1f82672b8755 11138 BNO055_MAG_OPERATION_MODE,
gume 0:1f82672b8755 11139 mag_operation_mode_u8);
gume 0:1f82672b8755 11140 com_rslt +=
gume 0:1f82672b8755 11141 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 11142 (p_bno055->dev_addr,
gume 0:1f82672b8755 11143 BNO055_MAG_OPERATION_MODE_REG,
gume 0:1f82672b8755 11144 &data_u8r,
gume 0:1f82672b8755 11145 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 11146 }
gume 0:1f82672b8755 11147 } else {
gume 0:1f82672b8755 11148 com_rslt = BNO055_OUT_OF_RANGE;
gume 0:1f82672b8755 11149 }
gume 0:1f82672b8755 11150 } else {
gume 0:1f82672b8755 11151 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11152 }
gume 0:1f82672b8755 11153 } else {
gume 0:1f82672b8755 11154 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11155 }
gume 0:1f82672b8755 11156 } else {
gume 0:1f82672b8755 11157 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11158 }
gume 0:1f82672b8755 11159 }
gume 0:1f82672b8755 11160 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 11161 /* set the operation mode of
gume 0:1f82672b8755 11162 previous operation mode*/
gume 0:1f82672b8755 11163 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 11164 (prev_opmode_u8);
gume 0:1f82672b8755 11165 return com_rslt;
gume 0:1f82672b8755 11166 }
gume 0:1f82672b8755 11167 /*!
gume 0:1f82672b8755 11168 * @brief This API used to read the mag power mode
gume 0:1f82672b8755 11169 * from page one register from 0x09 bit 4 to 6
gume 0:1f82672b8755 11170 *
gume 0:1f82672b8755 11171 * @param mag_power_mode_u8 : The value of mag power mode
gume 0:1f82672b8755 11172 *
gume 0:1f82672b8755 11173 * mag_power_mode_u8 | result
gume 0:1f82672b8755 11174 * --------------------|-----------------
gume 0:1f82672b8755 11175 * 0x00 | BNO055_MAG_POWER_MODE_NORMAL
gume 0:1f82672b8755 11176 * 0x01 | BNO055_MAG_POWER_MODE_SLEEP
gume 0:1f82672b8755 11177 * 0x02 | BNO055_MAG_POWER_MODE_SUSPEND
gume 0:1f82672b8755 11178 * 0x03 | BNO055_MAG_POWER_MODE_FORCE_MODE
gume 0:1f82672b8755 11179 *
gume 0:1f82672b8755 11180 * @return results of bus communication function
gume 0:1f82672b8755 11181 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 11182 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 11183 *
gume 0:1f82672b8755 11184 *
gume 0:1f82672b8755 11185 */
gume 0:1f82672b8755 11186 BNO055_RETURN_FUNCTION_TYPE bno055_get_mag_power_mode(
gume 0:1f82672b8755 11187 u8 *mag_power_mode_u8)
gume 0:1f82672b8755 11188 {
gume 0:1f82672b8755 11189 /* Variable used to return value of
gume 0:1f82672b8755 11190 communication routine*/
gume 0:1f82672b8755 11191 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11192 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 11193 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 11194 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 11195 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 11196 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 11197 } else {
gume 0:1f82672b8755 11198 /*condition check for page, mag power mode is
gume 0:1f82672b8755 11199 available in the page one*/
gume 0:1f82672b8755 11200 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 11201 /* Write page as one */
gume 0:1f82672b8755 11202 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 11203 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 11204 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 11205 /* Read the value of mag power mode */
gume 0:1f82672b8755 11206 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 11207 (p_bno055->dev_addr,
gume 0:1f82672b8755 11208 BNO055_MAG_POWER_MODE_REG,
gume 0:1f82672b8755 11209 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 11210 *mag_power_mode_u8 =
gume 0:1f82672b8755 11211 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 11212 BNO055_MAG_POWER_MODE);
gume 0:1f82672b8755 11213 } else {
gume 0:1f82672b8755 11214 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11215 }
gume 0:1f82672b8755 11216 }
gume 0:1f82672b8755 11217 return com_rslt;
gume 0:1f82672b8755 11218 }
gume 0:1f82672b8755 11219 /*!
gume 0:1f82672b8755 11220 * @brief This API used to write the mag power mode
gume 0:1f82672b8755 11221 * from page one register from 0x09 bit 4 to 6
gume 0:1f82672b8755 11222 *
gume 0:1f82672b8755 11223 * @param mag_power_mode_u8 : The value of mag power mode
gume 0:1f82672b8755 11224 *
gume 0:1f82672b8755 11225 * mag_power_mode_u8 | result
gume 0:1f82672b8755 11226 * --------------------|-----------------
gume 0:1f82672b8755 11227 * 0x00 | BNO055_MAG_POWER_MODE_NORMAL
gume 0:1f82672b8755 11228 * 0x01 | BNO055_MAG_POWER_MODE_SLEEP
gume 0:1f82672b8755 11229 * 0x02 | BNO055_MAG_POWER_MODE_SUSPEND
gume 0:1f82672b8755 11230 * 0x03 | BNO055_MAG_POWER_MODE_FORCE_MODE
gume 0:1f82672b8755 11231 *
gume 0:1f82672b8755 11232 * @return results of bus communication function
gume 0:1f82672b8755 11233 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 11234 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 11235 *
gume 0:1f82672b8755 11236 *
gume 0:1f82672b8755 11237 */
gume 0:1f82672b8755 11238 BNO055_RETURN_FUNCTION_TYPE bno055_set_mag_power_mode(
gume 0:1f82672b8755 11239 u8 mag_power_mode_u8)
gume 0:1f82672b8755 11240 {
gume 0:1f82672b8755 11241 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11242 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 11243 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 11244 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 11245 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 11246 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 11247 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 11248 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 11249 } else {
gume 0:1f82672b8755 11250 /* The write operation effective only if the operation
gume 0:1f82672b8755 11251 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 11252 current operation mode and set the config mode */
gume 0:1f82672b8755 11253 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 11254 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 11255 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 11256 stat_s8 += bno055_set_operation_mode(
gume 0:1f82672b8755 11257 BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 11258 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 11259 /* Write page as one */
gume 0:1f82672b8755 11260 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 11261 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 11262 if (mag_power_mode_u8 <
gume 0:1f82672b8755 11263 BNO055_MAG_POWER_MODE_RANGE) {
gume 0:1f82672b8755 11264 /* Write the value of mag power mode*/
gume 0:1f82672b8755 11265 com_rslt =
gume 0:1f82672b8755 11266 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 11267 (p_bno055->dev_addr,
gume 0:1f82672b8755 11268 BNO055_MAG_POWER_MODE_REG,
gume 0:1f82672b8755 11269 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 11270 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 11271 data_u8r = BNO055_SET_BITSLICE
gume 0:1f82672b8755 11272 (data_u8r,
gume 0:1f82672b8755 11273 BNO055_MAG_POWER_MODE,
gume 0:1f82672b8755 11274 mag_power_mode_u8);
gume 0:1f82672b8755 11275 com_rslt +=
gume 0:1f82672b8755 11276 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 11277 (p_bno055->dev_addr,
gume 0:1f82672b8755 11278 BNO055_MAG_POWER_MODE_REG,
gume 0:1f82672b8755 11279 &data_u8r,
gume 0:1f82672b8755 11280 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 11281 }
gume 0:1f82672b8755 11282 } else {
gume 0:1f82672b8755 11283 com_rslt = BNO055_OUT_OF_RANGE;
gume 0:1f82672b8755 11284 }
gume 0:1f82672b8755 11285 } else {
gume 0:1f82672b8755 11286 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11287 }
gume 0:1f82672b8755 11288 } else {
gume 0:1f82672b8755 11289 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11290 }
gume 0:1f82672b8755 11291 } else {
gume 0:1f82672b8755 11292 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11293 }
gume 0:1f82672b8755 11294 }
gume 0:1f82672b8755 11295 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 11296 /* set the operation mode of
gume 0:1f82672b8755 11297 previous operation mode*/
gume 0:1f82672b8755 11298 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 11299 (prev_opmode_u8);
gume 0:1f82672b8755 11300 return com_rslt;
gume 0:1f82672b8755 11301 }
gume 0:1f82672b8755 11302 /*!
gume 0:1f82672b8755 11303 * @brief This API used to read the gyro range
gume 0:1f82672b8755 11304 * from page one register from 0x0A bit 0 to 3
gume 0:1f82672b8755 11305 *
gume 0:1f82672b8755 11306 * @param gyro_range_u8 : The value of gyro range
gume 0:1f82672b8755 11307 *
gume 0:1f82672b8755 11308 * gyro_range_u8 | result
gume 0:1f82672b8755 11309 * --------------------|-----------------
gume 0:1f82672b8755 11310 * 0x00 | BNO055_GYRO_RANGE_2000DPS
gume 0:1f82672b8755 11311 * 0x01 | BNO055_GYRO_RANGE_1000DPS
gume 0:1f82672b8755 11312 * 0x02 | BNO055_GYRO_RANGE_500DPS
gume 0:1f82672b8755 11313 * 0x03 | BNO055_GYRO_RANGE_250DPS
gume 0:1f82672b8755 11314 * 0x04 | BNO055_GYRO_RANGE_125DPS
gume 0:1f82672b8755 11315 *
gume 0:1f82672b8755 11316 * @return results of bus communication function
gume 0:1f82672b8755 11317 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 11318 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 11319 *
gume 0:1f82672b8755 11320 *
gume 0:1f82672b8755 11321 */
gume 0:1f82672b8755 11322 BNO055_RETURN_FUNCTION_TYPE bno055_get_gyro_range(
gume 0:1f82672b8755 11323 u8 *gyro_range_u8)
gume 0:1f82672b8755 11324 {
gume 0:1f82672b8755 11325 /* Variable used to return value of
gume 0:1f82672b8755 11326 communication routine*/
gume 0:1f82672b8755 11327 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11328 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 11329 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 11330 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 11331 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 11332 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 11333 } else {
gume 0:1f82672b8755 11334 /*condition check for page, gyro range is
gume 0:1f82672b8755 11335 available in the page one*/
gume 0:1f82672b8755 11336 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 11337 /* Write page as one */
gume 0:1f82672b8755 11338 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 11339 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 11340 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 11341 /* Read the value of gyro range */
gume 0:1f82672b8755 11342 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 11343 (p_bno055->dev_addr,
gume 0:1f82672b8755 11344 BNO055_GYRO_RANGE_REG,
gume 0:1f82672b8755 11345 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 11346 *gyro_range_u8 =
gume 0:1f82672b8755 11347 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 11348 BNO055_GYRO_RANGE);
gume 0:1f82672b8755 11349 } else {
gume 0:1f82672b8755 11350 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11351 }
gume 0:1f82672b8755 11352 }
gume 0:1f82672b8755 11353 return com_rslt;
gume 0:1f82672b8755 11354 }
gume 0:1f82672b8755 11355 /*!
gume 0:1f82672b8755 11356 * @brief This API used to write the gyro range
gume 0:1f82672b8755 11357 * from page one register from 0x0A bit 0 to 3
gume 0:1f82672b8755 11358 *
gume 0:1f82672b8755 11359 * @param gyro_range_u8 : The value of gyro range
gume 0:1f82672b8755 11360 *
gume 0:1f82672b8755 11361 * gyro_range_u8 | result
gume 0:1f82672b8755 11362 * --------------------|-----------------
gume 0:1f82672b8755 11363 * 0x00 | BNO055_GYRO_RANGE_2000DPS
gume 0:1f82672b8755 11364 * 0x01 | BNO055_GYRO_RANGE_1000DPS
gume 0:1f82672b8755 11365 * 0x02 | BNO055_GYRO_RANGE_500DPS
gume 0:1f82672b8755 11366 * 0x03 | BNO055_GYRO_RANGE_250DPS
gume 0:1f82672b8755 11367 * 0x04 | BNO055_GYRO_RANGE_125DPS
gume 0:1f82672b8755 11368 *
gume 0:1f82672b8755 11369 * @return results of bus communication function
gume 0:1f82672b8755 11370 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 11371 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 11372 *
gume 0:1f82672b8755 11373 *
gume 0:1f82672b8755 11374 */
gume 0:1f82672b8755 11375 BNO055_RETURN_FUNCTION_TYPE bno055_set_gyro_range(
gume 0:1f82672b8755 11376 u8 gyro_range_u8)
gume 0:1f82672b8755 11377 {
gume 0:1f82672b8755 11378 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11379 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 11380 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 11381 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 11382 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 11383 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 11384 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 11385 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 11386 } else {
gume 0:1f82672b8755 11387 /* The write operation effective only if the operation
gume 0:1f82672b8755 11388 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 11389 current operation mode and set the config mode */
gume 0:1f82672b8755 11390 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 11391 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 11392 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 11393 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 11394 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 11395 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 11396 /* Write page as one */
gume 0:1f82672b8755 11397 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 11398 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 11399 if (gyro_range_u8 < BNO055_GYRO_RANGE) {
gume 0:1f82672b8755 11400 /* Write the value of gyro range*/
gume 0:1f82672b8755 11401 com_rslt =
gume 0:1f82672b8755 11402 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 11403 (p_bno055->dev_addr,
gume 0:1f82672b8755 11404 BNO055_GYRO_RANGE_REG,
gume 0:1f82672b8755 11405 &data_u8r,
gume 0:1f82672b8755 11406 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 11407 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 11408 data_u8r = BNO055_SET_BITSLICE
gume 0:1f82672b8755 11409 (data_u8r,
gume 0:1f82672b8755 11410 BNO055_GYRO_RANGE,
gume 0:1f82672b8755 11411 gyro_range_u8);
gume 0:1f82672b8755 11412 com_rslt +=
gume 0:1f82672b8755 11413 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 11414 (p_bno055->dev_addr,
gume 0:1f82672b8755 11415 BNO055_GYRO_RANGE_REG,
gume 0:1f82672b8755 11416 &data_u8r,
gume 0:1f82672b8755 11417 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 11418 }
gume 0:1f82672b8755 11419 } else {
gume 0:1f82672b8755 11420 com_rslt = BNO055_OUT_OF_RANGE;
gume 0:1f82672b8755 11421 }
gume 0:1f82672b8755 11422 } else {
gume 0:1f82672b8755 11423 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11424 }
gume 0:1f82672b8755 11425 } else {
gume 0:1f82672b8755 11426 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11427 }
gume 0:1f82672b8755 11428 } else {
gume 0:1f82672b8755 11429 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11430 }
gume 0:1f82672b8755 11431 }
gume 0:1f82672b8755 11432 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 11433 /* set the operation mode of
gume 0:1f82672b8755 11434 previous operation mode*/
gume 0:1f82672b8755 11435 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 11436 (prev_opmode_u8);
gume 0:1f82672b8755 11437 return com_rslt;
gume 0:1f82672b8755 11438 }
gume 0:1f82672b8755 11439 /*!
gume 0:1f82672b8755 11440 * @brief This API used to read the gyro bandwidth
gume 0:1f82672b8755 11441 * from page one register from 0x0A bit 3 to 5
gume 0:1f82672b8755 11442 *
gume 0:1f82672b8755 11443 * @param gyro_bw_u8 : The value of gyro bandwidth
gume 0:1f82672b8755 11444 *
gume 0:1f82672b8755 11445 * gyro_bw_u8 | result
gume 0:1f82672b8755 11446 * --------------------|-----------------
gume 0:1f82672b8755 11447 * 0x00 | BNO055_GYRO_BW_523HZ
gume 0:1f82672b8755 11448 * 0x01 | BNO055_GYRO_BW_230HZ
gume 0:1f82672b8755 11449 * 0x02 | BNO055_GYRO_BW_116HZ
gume 0:1f82672b8755 11450 * 0x03 | BNO055_GYRO_BW_47HZ
gume 0:1f82672b8755 11451 * 0x04 | BNO055_GYRO_BW_23HZ
gume 0:1f82672b8755 11452 * 0x05 | BNO055_GYRO_BW_12HZ
gume 0:1f82672b8755 11453 * 0x06 | BNO055_GYRO_BW_64HZ
gume 0:1f82672b8755 11454 * 0x07 | BNO055_GYRO_BW_32HZ
gume 0:1f82672b8755 11455 *
gume 0:1f82672b8755 11456 * @return results of bus communication function
gume 0:1f82672b8755 11457 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 11458 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 11459 *
gume 0:1f82672b8755 11460 *
gume 0:1f82672b8755 11461 */
gume 0:1f82672b8755 11462 BNO055_RETURN_FUNCTION_TYPE bno055_get_gyro_bw(
gume 0:1f82672b8755 11463 u8 *gyro_bw_u8)
gume 0:1f82672b8755 11464 {
gume 0:1f82672b8755 11465 /* Variable used to return value of
gume 0:1f82672b8755 11466 communication routine*/
gume 0:1f82672b8755 11467 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11468 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 11469 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 11470 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 11471 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 11472 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 11473 } else {
gume 0:1f82672b8755 11474 /*condition check for page, gyro bandwidth is
gume 0:1f82672b8755 11475 available in the page one*/
gume 0:1f82672b8755 11476 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 11477 /* Write page as one */
gume 0:1f82672b8755 11478 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 11479 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 11480 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 11481 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 11482 (p_bno055->dev_addr,
gume 0:1f82672b8755 11483 BNO055_GYRO_BW_REG,
gume 0:1f82672b8755 11484 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 11485 *gyro_bw_u8 =
gume 0:1f82672b8755 11486 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 11487 BNO055_GYRO_BW);
gume 0:1f82672b8755 11488 } else {
gume 0:1f82672b8755 11489 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11490 }
gume 0:1f82672b8755 11491 }
gume 0:1f82672b8755 11492 return com_rslt;
gume 0:1f82672b8755 11493 }
gume 0:1f82672b8755 11494 /*!
gume 0:1f82672b8755 11495 * @brief This API used to write the gyro bandwidth
gume 0:1f82672b8755 11496 * from page one register from 0x0A bit 3 to 5
gume 0:1f82672b8755 11497 *
gume 0:1f82672b8755 11498 * @param gyro_bw_u8 : The value of gyro bandwidth
gume 0:1f82672b8755 11499 *
gume 0:1f82672b8755 11500 * gyro_bw_u8 | result
gume 0:1f82672b8755 11501 * --------------------|-----------------
gume 0:1f82672b8755 11502 * 0x00 | BNO055_GYRO_BW_523HZ
gume 0:1f82672b8755 11503 * 0x01 | BNO055_GYRO_BW_230HZ
gume 0:1f82672b8755 11504 * 0x02 | BNO055_GYRO_BW_116HZ
gume 0:1f82672b8755 11505 * 0x03 | BNO055_GYRO_BW_47HZ
gume 0:1f82672b8755 11506 * 0x04 | BNO055_GYRO_BW_23HZ
gume 0:1f82672b8755 11507 * 0x05 | BNO055_GYRO_BW_12HZ
gume 0:1f82672b8755 11508 * 0x06 | BNO055_GYRO_BW_64HZ
gume 0:1f82672b8755 11509 * 0x07 | BNO055_GYRO_BW_32HZ
gume 0:1f82672b8755 11510 *
gume 0:1f82672b8755 11511 * @return results of bus communication function
gume 0:1f82672b8755 11512 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 11513 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 11514 *
gume 0:1f82672b8755 11515 *
gume 0:1f82672b8755 11516 */
gume 0:1f82672b8755 11517 BNO055_RETURN_FUNCTION_TYPE bno055_set_gyro_bw(
gume 0:1f82672b8755 11518 u8 gyro_bw_u8)
gume 0:1f82672b8755 11519 {
gume 0:1f82672b8755 11520 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11521 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 11522 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 11523 u8 gyro_opmode = BNO055_INIT_VALUE;
gume 0:1f82672b8755 11524 u8 gyro_auto_sleep_durn = BNO055_INIT_VALUE;
gume 0:1f82672b8755 11525 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 11526 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 11527 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 11528 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 11529 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 11530 } else {
gume 0:1f82672b8755 11531 /* The write operation effective only if the operation
gume 0:1f82672b8755 11532 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 11533 current operation mode and set the config mode */
gume 0:1f82672b8755 11534 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 11535 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 11536 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 11537 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 11538 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 11539 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 11540 /* Write page as one */
gume 0:1f82672b8755 11541 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 11542 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 11543 /* Write the value of gyro bandwidth */
gume 0:1f82672b8755 11544 if ((gyro_bw_u8 == BNO055_INIT_VALUE ||
gume 0:1f82672b8755 11545 gyro_bw_u8 > BNO055_INIT_VALUE) &&
gume 0:1f82672b8755 11546 gyro_bw_u8 < BNO055_ACCEL_GYRO_BW_RANGE) {
gume 0:1f82672b8755 11547 switch (gyro_bw_u8) {
gume 0:1f82672b8755 11548 case BNO055_GYRO_BW_523HZ:
gume 0:1f82672b8755 11549 gyro_bw_u8 = BNO055_GYRO_BW_523HZ;
gume 0:1f82672b8755 11550 break;
gume 0:1f82672b8755 11551 case BNO055_GYRO_BW_230HZ:
gume 0:1f82672b8755 11552 gyro_bw_u8 = BNO055_GYRO_BW_230HZ;
gume 0:1f82672b8755 11553 break;
gume 0:1f82672b8755 11554 case BNO055_GYRO_BW_116HZ:
gume 0:1f82672b8755 11555 gyro_bw_u8 = BNO055_GYRO_BW_116HZ;
gume 0:1f82672b8755 11556 break;
gume 0:1f82672b8755 11557 case BNO055_GYRO_BW_47HZ:
gume 0:1f82672b8755 11558 gyro_bw_u8 = BNO055_GYRO_BW_47HZ;
gume 0:1f82672b8755 11559 break;
gume 0:1f82672b8755 11560 case BNO055_GYRO_BW_23HZ:
gume 0:1f82672b8755 11561 gyro_bw_u8 = BNO055_GYRO_BW_23HZ;
gume 0:1f82672b8755 11562 break;
gume 0:1f82672b8755 11563 case BNO055_GYRO_BW_12HZ:
gume 0:1f82672b8755 11564 gyro_bw_u8 = BNO055_GYRO_BW_12HZ;
gume 0:1f82672b8755 11565 break;
gume 0:1f82672b8755 11566 case BNO055_GYRO_BW_64HZ:
gume 0:1f82672b8755 11567 gyro_bw_u8 = BNO055_GYRO_BW_64HZ;
gume 0:1f82672b8755 11568 break;
gume 0:1f82672b8755 11569 case BNO055_GYRO_BW_32HZ:
gume 0:1f82672b8755 11570 gyro_bw_u8 = BNO055_GYRO_BW_32HZ;
gume 0:1f82672b8755 11571 break;
gume 0:1f82672b8755 11572 default:
gume 0:1f82672b8755 11573 break;
gume 0:1f82672b8755 11574 }
gume 0:1f82672b8755 11575 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 11576 (p_bno055->dev_addr,
gume 0:1f82672b8755 11577 BNO055_GYRO_BW_REG,
gume 0:1f82672b8755 11578 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 11579 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 11580 data_u8r = BNO055_SET_BITSLICE
gume 0:1f82672b8755 11581 (data_u8r,
gume 0:1f82672b8755 11582 BNO055_GYRO_BW,
gume 0:1f82672b8755 11583 gyro_bw_u8);
gume 0:1f82672b8755 11584 com_rslt +=
gume 0:1f82672b8755 11585 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 11586 (p_bno055->dev_addr,
gume 0:1f82672b8755 11587 BNO055_GYRO_BW_REG,
gume 0:1f82672b8755 11588 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 11589 }
gume 0:1f82672b8755 11590 com_rslt = bno055_get_gyro_power_mode
gume 0:1f82672b8755 11591 (&gyro_opmode);
gume 0:1f82672b8755 11592 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 11593 if (gyro_opmode ==
gume 0:1f82672b8755 11594 BNO055_GYRO_POWER_MODE_ADVANCE_POWERSAVE) {
gume 0:1f82672b8755 11595 com_rslt +=
gume 0:1f82672b8755 11596 bno055_get_gyro_auto_sleep_durn
gume 0:1f82672b8755 11597 (&gyro_auto_sleep_durn);
gume 0:1f82672b8755 11598 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 11599 com_rslt +=
gume 0:1f82672b8755 11600 bno055_gyro_set_auto_sleep_durn
gume 0:1f82672b8755 11601 (gyro_auto_sleep_durn,
gume 0:1f82672b8755 11602 gyro_bw_u8);
gume 0:1f82672b8755 11603 }
gume 0:1f82672b8755 11604 }
gume 0:1f82672b8755 11605 }
gume 0:1f82672b8755 11606 } else {
gume 0:1f82672b8755 11607 com_rslt = BNO055_OUT_OF_RANGE;
gume 0:1f82672b8755 11608 }
gume 0:1f82672b8755 11609 } else {
gume 0:1f82672b8755 11610 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11611 }
gume 0:1f82672b8755 11612 } else {
gume 0:1f82672b8755 11613 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11614 }
gume 0:1f82672b8755 11615 } else {
gume 0:1f82672b8755 11616 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11617 }
gume 0:1f82672b8755 11618 }
gume 0:1f82672b8755 11619 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 11620 /* set the operation mode of
gume 0:1f82672b8755 11621 previous operation mode*/
gume 0:1f82672b8755 11622 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 11623 (prev_opmode_u8);
gume 0:1f82672b8755 11624 return com_rslt;
gume 0:1f82672b8755 11625 }
gume 0:1f82672b8755 11626 /*!
gume 0:1f82672b8755 11627 * @brief This API used to read the gyro power mode
gume 0:1f82672b8755 11628 * from page one register from 0x0B bit 0 to 2
gume 0:1f82672b8755 11629 *
gume 0:1f82672b8755 11630 * @param gyro_power_mode_u8 : The value of gyro power mode
gume 0:1f82672b8755 11631 *
gume 0:1f82672b8755 11632 * gyro_power_mode_u8 | result
gume 0:1f82672b8755 11633 * ----------------------|----------------------------
gume 0:1f82672b8755 11634 * 0x00 | GYRO_OPR_MODE_NORMAL
gume 0:1f82672b8755 11635 * 0x01 | GYRO_OPR_MODE_FASTPOWERUP
gume 0:1f82672b8755 11636 * 0x02 | GYRO_OPR_MODE_DEEPSUSPEND
gume 0:1f82672b8755 11637 * 0x03 | GYRO_OPR_MODE_SUSPEND
gume 0:1f82672b8755 11638 * 0x04 | GYRO_OPR_MODE_ADVANCE_POWERSAVE
gume 0:1f82672b8755 11639 *
gume 0:1f82672b8755 11640 * @return results of bus communication function
gume 0:1f82672b8755 11641 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 11642 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 11643 *
gume 0:1f82672b8755 11644 *
gume 0:1f82672b8755 11645 */
gume 0:1f82672b8755 11646 BNO055_RETURN_FUNCTION_TYPE bno055_get_gyro_power_mode(
gume 0:1f82672b8755 11647 u8 *gyro_power_mode_u8)
gume 0:1f82672b8755 11648 {
gume 0:1f82672b8755 11649 /* Variable used to return value of
gume 0:1f82672b8755 11650 communication routine*/
gume 0:1f82672b8755 11651 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11652 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 11653 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 11654 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 11655 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 11656 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 11657 } else {
gume 0:1f82672b8755 11658 /*condition check for page, gyro power mode is
gume 0:1f82672b8755 11659 available in the page one*/
gume 0:1f82672b8755 11660 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 11661 /* Write page as one */
gume 0:1f82672b8755 11662 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 11663 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 11664 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 11665 /* Write the value of gyro power mode*/
gume 0:1f82672b8755 11666 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 11667 (p_bno055->dev_addr,
gume 0:1f82672b8755 11668 BNO055_GYRO_POWER_MODE_REG,
gume 0:1f82672b8755 11669 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 11670 *gyro_power_mode_u8 =
gume 0:1f82672b8755 11671 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 11672 BNO055_GYRO_POWER_MODE);
gume 0:1f82672b8755 11673 } else {
gume 0:1f82672b8755 11674 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11675 }
gume 0:1f82672b8755 11676 }
gume 0:1f82672b8755 11677 return com_rslt;
gume 0:1f82672b8755 11678 }
gume 0:1f82672b8755 11679 /*!
gume 0:1f82672b8755 11680 * @brief This API used to write the gyro power mode
gume 0:1f82672b8755 11681 * from page one register from 0x0B bit 0 to 2
gume 0:1f82672b8755 11682 *
gume 0:1f82672b8755 11683 * @param gyro_power_mode_u8 : The value of gyro power mode
gume 0:1f82672b8755 11684 *
gume 0:1f82672b8755 11685 * gyro_power_mode_u8 | result
gume 0:1f82672b8755 11686 * ----------------------|----------------------------
gume 0:1f82672b8755 11687 * 0x00 | GYRO_OPR_MODE_NORMAL
gume 0:1f82672b8755 11688 * 0x01 | GYRO_OPR_MODE_FASTPOWERUP
gume 0:1f82672b8755 11689 * 0x02 | GYRO_OPR_MODE_DEEPSUSPEND
gume 0:1f82672b8755 11690 * 0x03 | GYRO_OPR_MODE_SUSPEND
gume 0:1f82672b8755 11691 * 0x04 | GYRO_OPR_MODE_ADVANCE_POWERSAVE
gume 0:1f82672b8755 11692 *
gume 0:1f82672b8755 11693 * @return results of bus communication function
gume 0:1f82672b8755 11694 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 11695 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 11696 *
gume 0:1f82672b8755 11697 *
gume 0:1f82672b8755 11698 */
gume 0:1f82672b8755 11699 BNO055_RETURN_FUNCTION_TYPE bno055_set_gyro_power_mode(
gume 0:1f82672b8755 11700 u8 gyro_power_mode_u8)
gume 0:1f82672b8755 11701 {
gume 0:1f82672b8755 11702 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11703 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 11704 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 11705 u8 gyro_auto_sleep_durn = BNO055_INIT_VALUE;
gume 0:1f82672b8755 11706 u8 gyro_bw_u8 = BNO055_INIT_VALUE;
gume 0:1f82672b8755 11707 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 11708 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 11709 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 11710 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 11711 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 11712 } else {
gume 0:1f82672b8755 11713 /* The write operation effective only if the operation
gume 0:1f82672b8755 11714 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 11715 current operation mode and set the config mode */
gume 0:1f82672b8755 11716 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 11717 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 11718 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 11719 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 11720 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 11721 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 11722 /* Write page as one */
gume 0:1f82672b8755 11723 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 11724 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 11725 /* Write the value of power mode*/
gume 0:1f82672b8755 11726 if ((gyro_power_mode_u8 == BNO055_INIT_VALUE ||
gume 0:1f82672b8755 11727 gyro_power_mode_u8 > BNO055_INIT_VALUE) &&
gume 0:1f82672b8755 11728 gyro_power_mode_u8 < BNO055_GYRO_RANGE) {
gume 0:1f82672b8755 11729 switch (gyro_power_mode_u8) {
gume 0:1f82672b8755 11730 case BNO055_GYRO_POWER_MODE_NORMAL:
gume 0:1f82672b8755 11731 gyro_power_mode_u8 =
gume 0:1f82672b8755 11732 BNO055_GYRO_POWER_MODE_NORMAL;
gume 0:1f82672b8755 11733 break;
gume 0:1f82672b8755 11734 case BNO055_GYRO_POWER_MODE_FASTPOWERUP:
gume 0:1f82672b8755 11735 gyro_power_mode_u8 =
gume 0:1f82672b8755 11736 BNO055_GYRO_POWER_MODE_FASTPOWERUP;
gume 0:1f82672b8755 11737 break;
gume 0:1f82672b8755 11738 case BNO055_GYRO_POWER_MODE_DEEPSUSPEND:
gume 0:1f82672b8755 11739 gyro_power_mode_u8 =
gume 0:1f82672b8755 11740 BNO055_GYRO_POWER_MODE_DEEPSUSPEND;
gume 0:1f82672b8755 11741 break;
gume 0:1f82672b8755 11742 case BNO055_GYRO_POWER_MODE_SUSPEND:
gume 0:1f82672b8755 11743 gyro_power_mode_u8 =
gume 0:1f82672b8755 11744 BNO055_GYRO_POWER_MODE_SUSPEND;
gume 0:1f82672b8755 11745 break;
gume 0:1f82672b8755 11746 case BNO055_GYRO_POWER_MODE_ADVANCE_POWERSAVE:
gume 0:1f82672b8755 11747 com_rslt = bno055_get_gyro_bw
gume 0:1f82672b8755 11748 (&gyro_bw_u8);
gume 0:1f82672b8755 11749 com_rslt += bno055_get_gyro_auto_sleep_durn
gume 0:1f82672b8755 11750 (&gyro_auto_sleep_durn);
gume 0:1f82672b8755 11751 if (com_rslt == BNO055_SUCCESS)
gume 0:1f82672b8755 11752 bno055_gyro_set_auto_sleep_durn
gume 0:1f82672b8755 11753 (gyro_auto_sleep_durn,
gume 0:1f82672b8755 11754 gyro_bw_u8);
gume 0:1f82672b8755 11755 com_rslt +=
gume 0:1f82672b8755 11756 bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 11757 gyro_power_mode_u8 =
gume 0:1f82672b8755 11758 BNO055_GYRO_POWER_MODE_ADVANCE_POWERSAVE;
gume 0:1f82672b8755 11759 break;
gume 0:1f82672b8755 11760 default:
gume 0:1f82672b8755 11761 break;
gume 0:1f82672b8755 11762 }
gume 0:1f82672b8755 11763 com_rslt =
gume 0:1f82672b8755 11764 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 11765 (p_bno055->dev_addr,
gume 0:1f82672b8755 11766 BNO055_GYRO_POWER_MODE_REG,
gume 0:1f82672b8755 11767 &data_u8r,
gume 0:1f82672b8755 11768 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 11769 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 11770 data_u8r = BNO055_SET_BITSLICE
gume 0:1f82672b8755 11771 (data_u8r,
gume 0:1f82672b8755 11772 BNO055_GYRO_POWER_MODE,
gume 0:1f82672b8755 11773 gyro_power_mode_u8);
gume 0:1f82672b8755 11774 com_rslt +=
gume 0:1f82672b8755 11775 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 11776 (p_bno055->dev_addr,
gume 0:1f82672b8755 11777 BNO055_GYRO_POWER_MODE_REG,
gume 0:1f82672b8755 11778 &data_u8r,
gume 0:1f82672b8755 11779 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 11780 }
gume 0:1f82672b8755 11781 } else {
gume 0:1f82672b8755 11782 com_rslt = BNO055_OUT_OF_RANGE;
gume 0:1f82672b8755 11783 }
gume 0:1f82672b8755 11784 } else {
gume 0:1f82672b8755 11785 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11786 }
gume 0:1f82672b8755 11787 } else {
gume 0:1f82672b8755 11788 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11789 }
gume 0:1f82672b8755 11790 } else {
gume 0:1f82672b8755 11791 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11792 }
gume 0:1f82672b8755 11793 }
gume 0:1f82672b8755 11794 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 11795 /* set the operation mode of
gume 0:1f82672b8755 11796 previous operation mode*/
gume 0:1f82672b8755 11797 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 11798 (prev_opmode_u8);
gume 0:1f82672b8755 11799 return com_rslt;
gume 0:1f82672b8755 11800 }
gume 0:1f82672b8755 11801 /*!
gume 0:1f82672b8755 11802 * @brief This API used to read the accel sleep mode
gume 0:1f82672b8755 11803 * from page one register from 0x0C bit 0
gume 0:1f82672b8755 11804 *
gume 0:1f82672b8755 11805 * @param sleep_tmr_u8 : The value of accel sleep mode
gume 0:1f82672b8755 11806 *
gume 0:1f82672b8755 11807 * sleep_tmr_u8 | result
gume 0:1f82672b8755 11808 * ----------------- |------------------------------------
gume 0:1f82672b8755 11809 * 0x00 | enable EventDrivenSampling(EDT)
gume 0:1f82672b8755 11810 * 0x01 | enable Equidistant sampling mode(EST)
gume 0:1f82672b8755 11811 *
gume 0:1f82672b8755 11812 * @return results of bus communication function
gume 0:1f82672b8755 11813 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 11814 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 11815 *
gume 0:1f82672b8755 11816 *
gume 0:1f82672b8755 11817 */
gume 0:1f82672b8755 11818 BNO055_RETURN_FUNCTION_TYPE bno055_get_accel_sleep_tmr_mode(
gume 0:1f82672b8755 11819 u8 *sleep_tmr_u8)
gume 0:1f82672b8755 11820 {
gume 0:1f82672b8755 11821 /* Variable used to return value of
gume 0:1f82672b8755 11822 communication routine*/
gume 0:1f82672b8755 11823 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11824 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 11825 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 11826 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 11827 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 11828 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 11829 } else {
gume 0:1f82672b8755 11830 /*condition check for page, accel sleep mode is
gume 0:1f82672b8755 11831 available in the page one*/
gume 0:1f82672b8755 11832 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 11833 /* Write page as one */
gume 0:1f82672b8755 11834 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 11835 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 11836 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 11837 /* read the value of accel sleep mode */
gume 0:1f82672b8755 11838 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 11839 (p_bno055->dev_addr,
gume 0:1f82672b8755 11840 BNO055_ACCEL_SLEEP_MODE_REG,
gume 0:1f82672b8755 11841 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 11842 *sleep_tmr_u8 =
gume 0:1f82672b8755 11843 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 11844 BNO055_ACCEL_SLEEP_MODE);
gume 0:1f82672b8755 11845 } else {
gume 0:1f82672b8755 11846 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11847 }
gume 0:1f82672b8755 11848 }
gume 0:1f82672b8755 11849 return com_rslt;
gume 0:1f82672b8755 11850 }
gume 0:1f82672b8755 11851 /*!
gume 0:1f82672b8755 11852 * @brief This API used to write the accel sleep mode
gume 0:1f82672b8755 11853 * from page one register from 0x0C bit 0
gume 0:1f82672b8755 11854 *
gume 0:1f82672b8755 11855 * @param sleep_tmr_u8 : The value of accel sleep mode
gume 0:1f82672b8755 11856 *
gume 0:1f82672b8755 11857 * sleep_tmr_u8 | result
gume 0:1f82672b8755 11858 * ----------------- |------------------------------------
gume 0:1f82672b8755 11859 * 0x00 | enable EventDrivenSampling(EDT)
gume 0:1f82672b8755 11860 * 0x01 | enable Equidistant sampling mode(EST)
gume 0:1f82672b8755 11861 *
gume 0:1f82672b8755 11862 * @return results of bus communication function
gume 0:1f82672b8755 11863 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 11864 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 11865 *
gume 0:1f82672b8755 11866 *
gume 0:1f82672b8755 11867 */
gume 0:1f82672b8755 11868 BNO055_RETURN_FUNCTION_TYPE bno055_set_accel_sleep_tmr_mode(
gume 0:1f82672b8755 11869 u8 sleep_tmr_u8)
gume 0:1f82672b8755 11870 {
gume 0:1f82672b8755 11871 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11872 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 11873 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 11874 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 11875 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 11876 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 11877 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 11878 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 11879 } else {
gume 0:1f82672b8755 11880 /* The write operation effective only if the operation
gume 0:1f82672b8755 11881 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 11882 current operation mode and set the config mode */
gume 0:1f82672b8755 11883 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 11884 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 11885 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 11886 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 11887 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 11888 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 11889 /* Write page as one */
gume 0:1f82672b8755 11890 pg_stat_s8 = bno055_write_page_id(
gume 0:1f82672b8755 11891 BNO055_PAGE_ONE);
gume 0:1f82672b8755 11892 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 11893 if (sleep_tmr_u8 <
gume 0:1f82672b8755 11894 BNO055_ACCEL_SLEEP_MODE_RANGE) {
gume 0:1f82672b8755 11895 /*Write the value
gume 0:1f82672b8755 11896 of accel sleep mode*/
gume 0:1f82672b8755 11897 com_rslt =
gume 0:1f82672b8755 11898 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 11899 (p_bno055->dev_addr,
gume 0:1f82672b8755 11900 BNO055_ACCEL_SLEEP_MODE_REG,
gume 0:1f82672b8755 11901 &data_u8r,
gume 0:1f82672b8755 11902 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 11903 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 11904 data_u8r = BNO055_SET_BITSLICE
gume 0:1f82672b8755 11905 (data_u8r,
gume 0:1f82672b8755 11906 BNO055_ACCEL_SLEEP_MODE,
gume 0:1f82672b8755 11907 sleep_tmr_u8);
gume 0:1f82672b8755 11908 com_rslt +=
gume 0:1f82672b8755 11909 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 11910 (p_bno055->dev_addr,
gume 0:1f82672b8755 11911 BNO055_ACCEL_SLEEP_MODE_REG,
gume 0:1f82672b8755 11912 &data_u8r,
gume 0:1f82672b8755 11913 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 11914 }
gume 0:1f82672b8755 11915 } else {
gume 0:1f82672b8755 11916 com_rslt = BNO055_OUT_OF_RANGE;
gume 0:1f82672b8755 11917 }
gume 0:1f82672b8755 11918 } else {
gume 0:1f82672b8755 11919 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11920 }
gume 0:1f82672b8755 11921 } else {
gume 0:1f82672b8755 11922 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11923 }
gume 0:1f82672b8755 11924 } else {
gume 0:1f82672b8755 11925 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11926 }
gume 0:1f82672b8755 11927 }
gume 0:1f82672b8755 11928 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 11929 /* set the operation mode of
gume 0:1f82672b8755 11930 previous operation mode*/
gume 0:1f82672b8755 11931 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 11932 (prev_opmode_u8);
gume 0:1f82672b8755 11933 return com_rslt;
gume 0:1f82672b8755 11934 }
gume 0:1f82672b8755 11935 /*!
gume 0:1f82672b8755 11936 * @brief This API used to read the accel sleep duration
gume 0:1f82672b8755 11937 * from page one register from 0x0C bit 1 to 4
gume 0:1f82672b8755 11938 *
gume 0:1f82672b8755 11939 * @param sleep_durn_u8 : The value of accel sleep duration
gume 0:1f82672b8755 11940 *
gume 0:1f82672b8755 11941 * sleep_durn_u8 | result
gume 0:1f82672b8755 11942 * ---------------- |-----------------------------
gume 0:1f82672b8755 11943 * 0x05 | BNO055_ACCEL_SLEEP_DURN_0_5MS
gume 0:1f82672b8755 11944 * 0x06 | BNO055_ACCEL_SLEEP_DURN_1MS
gume 0:1f82672b8755 11945 * 0x07 | BNO055_ACCEL_SLEEP_DURN_2MS
gume 0:1f82672b8755 11946 * 0x08 | BNO055_ACCEL_SLEEP_DURN_4MS
gume 0:1f82672b8755 11947 * 0x09 | BNO055_ACCEL_SLEEP_DURN_6MS
gume 0:1f82672b8755 11948 * 0x0A | BNO055_ACCEL_SLEEP_DURN_10MS
gume 0:1f82672b8755 11949 * 0x0B | BNO055_ACCEL_SLEEP_DURN_25MS
gume 0:1f82672b8755 11950 * 0x0C | BNO055_ACCEL_SLEEP_DURN_50MS
gume 0:1f82672b8755 11951 * 0x0D | BNO055_ACCEL_SLEEP_DURN_100MS
gume 0:1f82672b8755 11952 * 0x0E | BNO055_ACCEL_SLEEP_DURN_500MS
gume 0:1f82672b8755 11953 * 0x0F | BNO055_ACCEL_SLEEP_DURN_1S
gume 0:1f82672b8755 11954 *
gume 0:1f82672b8755 11955 * @return results of bus communication function
gume 0:1f82672b8755 11956 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 11957 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 11958 *
gume 0:1f82672b8755 11959 *
gume 0:1f82672b8755 11960 */
gume 0:1f82672b8755 11961 BNO055_RETURN_FUNCTION_TYPE bno055_get_accel_sleep_durn(
gume 0:1f82672b8755 11962 u8 *sleep_durn_u8)
gume 0:1f82672b8755 11963 {
gume 0:1f82672b8755 11964 /* Variable used to return value of
gume 0:1f82672b8755 11965 communication routine*/
gume 0:1f82672b8755 11966 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11967 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 11968 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 11969 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 11970 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 11971 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 11972 } else {
gume 0:1f82672b8755 11973 /*condition check for page, accel sleep duration
gume 0:1f82672b8755 11974 available in the page one*/
gume 0:1f82672b8755 11975 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 11976 /* Write page as one */
gume 0:1f82672b8755 11977 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 11978 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 11979 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 11980 /* Read the value of accel sleep duration */
gume 0:1f82672b8755 11981 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 11982 (p_bno055->dev_addr,
gume 0:1f82672b8755 11983 BNO055_ACCEL_SLEEP_DURN_REG,
gume 0:1f82672b8755 11984 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 11985 *sleep_durn_u8 =
gume 0:1f82672b8755 11986 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 11987 BNO055_ACCEL_SLEEP_DURN);
gume 0:1f82672b8755 11988 } else {
gume 0:1f82672b8755 11989 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 11990 }
gume 0:1f82672b8755 11991 }
gume 0:1f82672b8755 11992 return com_rslt;
gume 0:1f82672b8755 11993 }
gume 0:1f82672b8755 11994 /*!
gume 0:1f82672b8755 11995 * @brief This API used to write the accel sleep duration
gume 0:1f82672b8755 11996 * from page one register from 0x0C bit 1 to 4
gume 0:1f82672b8755 11997 *
gume 0:1f82672b8755 11998 * @param sleep_durn_u8 : The value of accel sleep duration
gume 0:1f82672b8755 11999 *
gume 0:1f82672b8755 12000 * sleep_durn_u8 | result
gume 0:1f82672b8755 12001 * ---------------|-----------------------------
gume 0:1f82672b8755 12002 * 0x05 | BNO055_ACCEL_SLEEP_DURN_0_5MS
gume 0:1f82672b8755 12003 * 0x06 | BNO055_ACCEL_SLEEP_DURN_1MS
gume 0:1f82672b8755 12004 * 0x07 | BNO055_ACCEL_SLEEP_DURN_2MS
gume 0:1f82672b8755 12005 * 0x08 | BNO055_ACCEL_SLEEP_DURN_4MS
gume 0:1f82672b8755 12006 * 0x09 | BNO055_ACCEL_SLEEP_DURN_6MS
gume 0:1f82672b8755 12007 * 0x0A | BNO055_ACCEL_SLEEP_DURN_10MS
gume 0:1f82672b8755 12008 * 0x0B | BNO055_ACCEL_SLEEP_DURN_25MS
gume 0:1f82672b8755 12009 * 0x0C | BNO055_ACCEL_SLEEP_DURN_50MS
gume 0:1f82672b8755 12010 * 0x0D | BNO055_ACCEL_SLEEP_DURN_100MS
gume 0:1f82672b8755 12011 * 0x0E | BNO055_ACCEL_SLEEP_DURN_500MS
gume 0:1f82672b8755 12012 * 0x0F | BNO055_ACCEL_SLEEP_DURN_1S
gume 0:1f82672b8755 12013 *
gume 0:1f82672b8755 12014 * @return results of bus communication function
gume 0:1f82672b8755 12015 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 12016 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 12017 *
gume 0:1f82672b8755 12018 *
gume 0:1f82672b8755 12019 */
gume 0:1f82672b8755 12020 BNO055_RETURN_FUNCTION_TYPE bno055_set_accel_sleep_durn(
gume 0:1f82672b8755 12021 u8 sleep_durn_u8)
gume 0:1f82672b8755 12022 {
gume 0:1f82672b8755 12023 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12024 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 12025 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 12026 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 12027 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 12028 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 12029 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 12030 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 12031 } else {
gume 0:1f82672b8755 12032 /* The write operation effective only if the operation
gume 0:1f82672b8755 12033 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 12034 current operation mode and set the config mode */
gume 0:1f82672b8755 12035 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 12036 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 12037 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 12038 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 12039 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 12040 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 12041 /* Write page as one */
gume 0:1f82672b8755 12042 pg_stat_s8 = bno055_write_page_id(
gume 0:1f82672b8755 12043 BNO055_PAGE_ONE);
gume 0:1f82672b8755 12044 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 12045 if (sleep_durn_u8 <
gume 0:1f82672b8755 12046 BNO055_ACCEL_SLEEP_DURATION_RANGE) {
gume 0:1f82672b8755 12047 /* Write the accel
gume 0:1f82672b8755 12048 sleep duration*/
gume 0:1f82672b8755 12049 com_rslt =
gume 0:1f82672b8755 12050 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 12051 (p_bno055->dev_addr,
gume 0:1f82672b8755 12052 BNO055_ACCEL_SLEEP_DURN_REG,
gume 0:1f82672b8755 12053 &data_u8r,
gume 0:1f82672b8755 12054 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 12055 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 12056 data_u8r = BNO055_SET_BITSLICE
gume 0:1f82672b8755 12057 (data_u8r,
gume 0:1f82672b8755 12058 BNO055_ACCEL_SLEEP_DURN,
gume 0:1f82672b8755 12059 sleep_durn_u8);
gume 0:1f82672b8755 12060 com_rslt +=
gume 0:1f82672b8755 12061 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 12062 (p_bno055->dev_addr,
gume 0:1f82672b8755 12063 BNO055_ACCEL_SLEEP_DURN_REG,
gume 0:1f82672b8755 12064 &data_u8r,
gume 0:1f82672b8755 12065 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 12066 }
gume 0:1f82672b8755 12067 } else {
gume 0:1f82672b8755 12068 com_rslt = BNO055_OUT_OF_RANGE;
gume 0:1f82672b8755 12069 }
gume 0:1f82672b8755 12070 } else {
gume 0:1f82672b8755 12071 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12072 }
gume 0:1f82672b8755 12073 } else {
gume 0:1f82672b8755 12074 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12075 }
gume 0:1f82672b8755 12076 } else {
gume 0:1f82672b8755 12077 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12078 }
gume 0:1f82672b8755 12079 }
gume 0:1f82672b8755 12080 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 12081 /* set the operation mode of
gume 0:1f82672b8755 12082 previous operation mode*/
gume 0:1f82672b8755 12083 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 12084 (prev_opmode_u8);
gume 0:1f82672b8755 12085 return com_rslt;
gume 0:1f82672b8755 12086 }
gume 0:1f82672b8755 12087 /*!
gume 0:1f82672b8755 12088 * @brief This API used to write the gyro sleep duration
gume 0:1f82672b8755 12089 * from page one register from 0x0D bit 0 to 2
gume 0:1f82672b8755 12090 *
gume 0:1f82672b8755 12091 * @param sleep_durn_u8 : The value of gyro sleep duration
gume 0:1f82672b8755 12092 *
gume 0:1f82672b8755 12093 * @return results of bus communication function
gume 0:1f82672b8755 12094 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 12095 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 12096 *
gume 0:1f82672b8755 12097 *
gume 0:1f82672b8755 12098 */
gume 0:1f82672b8755 12099 BNO055_RETURN_FUNCTION_TYPE bno055_get_gyro_sleep_durn(u8 *sleep_durn_u8)
gume 0:1f82672b8755 12100 {
gume 0:1f82672b8755 12101 /* Variable used to return value of
gume 0:1f82672b8755 12102 communication routine*/
gume 0:1f82672b8755 12103 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12104 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 12105 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 12106 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 12107 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 12108 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 12109 } else {
gume 0:1f82672b8755 12110 /*condition check for page, accel range is
gume 0:1f82672b8755 12111 available in the page one*/
gume 0:1f82672b8755 12112 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 12113 /* Write page as one */
gume 0:1f82672b8755 12114 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 12115 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 12116 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 12117 /* Read the gyro sleep duration */
gume 0:1f82672b8755 12118 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 12119 (p_bno055->dev_addr,
gume 0:1f82672b8755 12120 BNO055_GYRO_SLEEP_DURN_REG,
gume 0:1f82672b8755 12121 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 12122 *sleep_durn_u8 =
gume 0:1f82672b8755 12123 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 12124 BNO055_GYRO_SLEEP_DURN);
gume 0:1f82672b8755 12125 } else {
gume 0:1f82672b8755 12126 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12127 }
gume 0:1f82672b8755 12128 }
gume 0:1f82672b8755 12129 return com_rslt;
gume 0:1f82672b8755 12130 }
gume 0:1f82672b8755 12131 /*!
gume 0:1f82672b8755 12132 * @brief This API used to write the gyro sleep duration
gume 0:1f82672b8755 12133 * from page one register from 0x0D bit 0 to 2
gume 0:1f82672b8755 12134 *
gume 0:1f82672b8755 12135 * @param sleep_durn_u8 : The value of gyro sleep duration
gume 0:1f82672b8755 12136 *
gume 0:1f82672b8755 12137 * @return results of bus communication function
gume 0:1f82672b8755 12138 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 12139 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 12140 *
gume 0:1f82672b8755 12141 *
gume 0:1f82672b8755 12142 */
gume 0:1f82672b8755 12143 BNO055_RETURN_FUNCTION_TYPE bno055_set_gyro_sleep_durn(u8 sleep_durn_u8)
gume 0:1f82672b8755 12144 {
gume 0:1f82672b8755 12145 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12146 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 12147 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 12148 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 12149 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 12150 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 12151 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 12152 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 12153 } else {
gume 0:1f82672b8755 12154 /* The write operation effective only if the operation
gume 0:1f82672b8755 12155 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 12156 current operation mode and set the config mode */
gume 0:1f82672b8755 12157 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 12158 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 12159 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 12160 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 12161 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 12162 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 12163 /* Write page as one */
gume 0:1f82672b8755 12164 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 12165 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 12166 if (sleep_durn_u8 <
gume 0:1f82672b8755 12167 BNO055_GYRO_AUTO_SLEEP_DURATION_RANGE) {
gume 0:1f82672b8755 12168 com_rslt =
gume 0:1f82672b8755 12169 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 12170 (p_bno055->dev_addr,
gume 0:1f82672b8755 12171 BNO055_GYRO_SLEEP_DURN_REG,
gume 0:1f82672b8755 12172 &data_u8r,
gume 0:1f82672b8755 12173 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 12174 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 12175 /* Write the gyro
gume 0:1f82672b8755 12176 sleep duration */
gume 0:1f82672b8755 12177 data_u8r = BNO055_SET_BITSLICE
gume 0:1f82672b8755 12178 (data_u8r,
gume 0:1f82672b8755 12179 BNO055_GYRO_SLEEP_DURN,
gume 0:1f82672b8755 12180 sleep_durn_u8);
gume 0:1f82672b8755 12181 com_rslt +=
gume 0:1f82672b8755 12182 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 12183 (p_bno055->dev_addr,
gume 0:1f82672b8755 12184 BNO055_GYRO_SLEEP_DURN_REG,
gume 0:1f82672b8755 12185 &data_u8r,
gume 0:1f82672b8755 12186 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 12187 }
gume 0:1f82672b8755 12188 } else {
gume 0:1f82672b8755 12189 com_rslt = BNO055_OUT_OF_RANGE;
gume 0:1f82672b8755 12190 }
gume 0:1f82672b8755 12191 } else {
gume 0:1f82672b8755 12192 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12193 }
gume 0:1f82672b8755 12194 } else {
gume 0:1f82672b8755 12195 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12196 }
gume 0:1f82672b8755 12197 } else {
gume 0:1f82672b8755 12198 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12199 }
gume 0:1f82672b8755 12200 }
gume 0:1f82672b8755 12201 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 12202 /* set the operation mode of
gume 0:1f82672b8755 12203 previous operation mode*/
gume 0:1f82672b8755 12204 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 12205 (prev_opmode_u8);
gume 0:1f82672b8755 12206 return com_rslt;
gume 0:1f82672b8755 12207 }
gume 0:1f82672b8755 12208 /*!
gume 0:1f82672b8755 12209 * @brief This API used to read the gyro auto sleep duration
gume 0:1f82672b8755 12210 * from page one register from 0x0D bit 3 to 5
gume 0:1f82672b8755 12211 *
gume 0:1f82672b8755 12212 * @param auto_sleep_durn_u8 : The value of gyro auto sleep duration
gume 0:1f82672b8755 12213 *
gume 0:1f82672b8755 12214 * @return results of bus communication function
gume 0:1f82672b8755 12215 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 12216 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 12217 *
gume 0:1f82672b8755 12218 *
gume 0:1f82672b8755 12219 */
gume 0:1f82672b8755 12220 BNO055_RETURN_FUNCTION_TYPE bno055_get_gyro_auto_sleep_durn(
gume 0:1f82672b8755 12221 u8 *auto_sleep_durn_u8)
gume 0:1f82672b8755 12222 {
gume 0:1f82672b8755 12223 /* Variable used to return value of
gume 0:1f82672b8755 12224 communication routine*/
gume 0:1f82672b8755 12225 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12226 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 12227 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 12228 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 12229 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 12230 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 12231 } else {
gume 0:1f82672b8755 12232 /*condition check for page, accel range is
gume 0:1f82672b8755 12233 available in the page one*/
gume 0:1f82672b8755 12234 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 12235 /* Write page as one */
gume 0:1f82672b8755 12236 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 12237 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 12238 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 12239 /* Read the value of gyro auto sleep duration */
gume 0:1f82672b8755 12240 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 12241 (p_bno055->dev_addr,
gume 0:1f82672b8755 12242 BNO055_GYRO_AUTO_SLEEP_DURN_REG,
gume 0:1f82672b8755 12243 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 12244 *auto_sleep_durn_u8 =
gume 0:1f82672b8755 12245 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 12246 BNO055_GYRO_AUTO_SLEEP_DURN);
gume 0:1f82672b8755 12247 } else {
gume 0:1f82672b8755 12248 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12249 }
gume 0:1f82672b8755 12250 }
gume 0:1f82672b8755 12251 return com_rslt;
gume 0:1f82672b8755 12252 }
gume 0:1f82672b8755 12253 /*!
gume 0:1f82672b8755 12254 * @brief This API used to write the gyro auto sleep duration
gume 0:1f82672b8755 12255 * from page one register from 0x0D bit 3 to 5
gume 0:1f82672b8755 12256 *
gume 0:1f82672b8755 12257 * @param auto_sleep_durn_u8 : The value of gyro auto sleep duration
gume 0:1f82672b8755 12258 * @param bw : The value of gyro bandwidth
gume 0:1f82672b8755 12259 *
gume 0:1f82672b8755 12260 * @return results of bus communication function
gume 0:1f82672b8755 12261 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 12262 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 12263 *
gume 0:1f82672b8755 12264 *
gume 0:1f82672b8755 12265 */
gume 0:1f82672b8755 12266 BNO055_RETURN_FUNCTION_TYPE bno055_gyro_set_auto_sleep_durn(
gume 0:1f82672b8755 12267 u8 auto_sleep_durn_u8, u8 bw)
gume 0:1f82672b8755 12268 {
gume 0:1f82672b8755 12269 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12270 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 12271 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 12272 u8 auto_sleep_durn_u8r;
gume 0:1f82672b8755 12273 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 12274 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 12275 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 12276 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 12277 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 12278 } else {
gume 0:1f82672b8755 12279 /* The write operation effective only if the operation
gume 0:1f82672b8755 12280 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 12281 current operation mode and set the config mode */
gume 0:1f82672b8755 12282 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 12283 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 12284 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 12285 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 12286 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 12287 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 12288 /* Write page as one */
gume 0:1f82672b8755 12289 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 12290 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 12291 /* Write the value of gyro sleep duration */
gume 0:1f82672b8755 12292 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 12293 (p_bno055->dev_addr,
gume 0:1f82672b8755 12294 BNO055_GYRO_AUTO_SLEEP_DURN_REG,
gume 0:1f82672b8755 12295 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 12296 if (auto_sleep_durn_u8 <
gume 0:1f82672b8755 12297 BNO055_GYRO_AUTO_SLEEP_DURATION_RANGE) {
gume 0:1f82672b8755 12298 switch (bw) {
gume 0:1f82672b8755 12299 case BNO055_GYRO_BW_523HZ:
gume 0:1f82672b8755 12300 if (auto_sleep_durn_u8 >
gume 0:1f82672b8755 12301 BNO055_GYRO_4MS_AUTOSLPDUR)
gume 0:1f82672b8755 12302 auto_sleep_durn_u8r =
gume 0:1f82672b8755 12303 auto_sleep_durn_u8;
gume 0:1f82672b8755 12304 else
gume 0:1f82672b8755 12305 auto_sleep_durn_u8r =
gume 0:1f82672b8755 12306 BNO055_GYRO_4MS_AUTOSLPDUR;
gume 0:1f82672b8755 12307 break;
gume 0:1f82672b8755 12308 case BNO055_GYRO_BW_230HZ:
gume 0:1f82672b8755 12309 if (auto_sleep_durn_u8 >
gume 0:1f82672b8755 12310 BNO055_GYRO_4MS_AUTOSLPDUR)
gume 0:1f82672b8755 12311 auto_sleep_durn_u8r =
gume 0:1f82672b8755 12312 auto_sleep_durn_u8;
gume 0:1f82672b8755 12313 else
gume 0:1f82672b8755 12314 auto_sleep_durn_u8r =
gume 0:1f82672b8755 12315 BNO055_GYRO_4MS_AUTOSLPDUR;
gume 0:1f82672b8755 12316 break;
gume 0:1f82672b8755 12317 case BNO055_GYRO_BW_116HZ:
gume 0:1f82672b8755 12318 if (auto_sleep_durn_u8 >
gume 0:1f82672b8755 12319 BNO055_GYRO_4MS_AUTOSLPDUR)
gume 0:1f82672b8755 12320 auto_sleep_durn_u8r =
gume 0:1f82672b8755 12321 auto_sleep_durn_u8;
gume 0:1f82672b8755 12322 else
gume 0:1f82672b8755 12323 auto_sleep_durn_u8r =
gume 0:1f82672b8755 12324 BNO055_GYRO_4MS_AUTOSLPDUR;
gume 0:1f82672b8755 12325 break;
gume 0:1f82672b8755 12326 case BNO055_GYRO_BW_47HZ:
gume 0:1f82672b8755 12327 if (auto_sleep_durn_u8 >
gume 0:1f82672b8755 12328 BNO055_GYRO_5MS_AUTOSLPDUR)
gume 0:1f82672b8755 12329 auto_sleep_durn_u8r =
gume 0:1f82672b8755 12330 auto_sleep_durn_u8;
gume 0:1f82672b8755 12331 else
gume 0:1f82672b8755 12332 auto_sleep_durn_u8r =
gume 0:1f82672b8755 12333 BNO055_GYRO_5MS_AUTOSLPDUR;
gume 0:1f82672b8755 12334 break;
gume 0:1f82672b8755 12335 case BNO055_GYRO_BW_23HZ:
gume 0:1f82672b8755 12336 if (auto_sleep_durn_u8 >
gume 0:1f82672b8755 12337 BNO055_GYRO_10MS_AUTOSLPDUR)
gume 0:1f82672b8755 12338 auto_sleep_durn_u8r =
gume 0:1f82672b8755 12339 auto_sleep_durn_u8;
gume 0:1f82672b8755 12340 else
gume 0:1f82672b8755 12341 auto_sleep_durn_u8r =
gume 0:1f82672b8755 12342 BNO055_GYRO_10MS_AUTOSLPDUR;
gume 0:1f82672b8755 12343 break;
gume 0:1f82672b8755 12344 case BNO055_GYRO_BW_12HZ:
gume 0:1f82672b8755 12345 if (auto_sleep_durn_u8 >
gume 0:1f82672b8755 12346 BNO055_GYRO_20MS_AUTOSLPDUR)
gume 0:1f82672b8755 12347 auto_sleep_durn_u8r =
gume 0:1f82672b8755 12348 auto_sleep_durn_u8;
gume 0:1f82672b8755 12349 else
gume 0:1f82672b8755 12350 auto_sleep_durn_u8r =
gume 0:1f82672b8755 12351 BNO055_GYRO_20MS_AUTOSLPDUR;
gume 0:1f82672b8755 12352 break;
gume 0:1f82672b8755 12353 case BNO055_GYRO_BW_64HZ:
gume 0:1f82672b8755 12354 if (auto_sleep_durn_u8 >
gume 0:1f82672b8755 12355 BNO055_GYRO_10MS_AUTOSLPDUR)
gume 0:1f82672b8755 12356 auto_sleep_durn_u8r =
gume 0:1f82672b8755 12357 auto_sleep_durn_u8;
gume 0:1f82672b8755 12358 else
gume 0:1f82672b8755 12359 auto_sleep_durn_u8r =
gume 0:1f82672b8755 12360 BNO055_GYRO_10MS_AUTOSLPDUR;
gume 0:1f82672b8755 12361 break;
gume 0:1f82672b8755 12362 case BNO055_GYRO_BW_32HZ:
gume 0:1f82672b8755 12363 if (auto_sleep_durn_u8 >
gume 0:1f82672b8755 12364 BNO055_GYRO_20MS_AUTOSLPDUR)
gume 0:1f82672b8755 12365 auto_sleep_durn_u8r =
gume 0:1f82672b8755 12366 auto_sleep_durn_u8;
gume 0:1f82672b8755 12367 else
gume 0:1f82672b8755 12368 auto_sleep_durn_u8r =
gume 0:1f82672b8755 12369 BNO055_GYRO_20MS_AUTOSLPDUR;
gume 0:1f82672b8755 12370 break;
gume 0:1f82672b8755 12371 default:
gume 0:1f82672b8755 12372 if (auto_sleep_durn_u8 >
gume 0:1f82672b8755 12373 BNO055_GYRO_4MS_AUTOSLPDUR)
gume 0:1f82672b8755 12374 auto_sleep_durn_u8r =
gume 0:1f82672b8755 12375 auto_sleep_durn_u8;
gume 0:1f82672b8755 12376 else
gume 0:1f82672b8755 12377 auto_sleep_durn_u8r =
gume 0:1f82672b8755 12378 BNO055_GYRO_4MS_AUTOSLPDUR;
gume 0:1f82672b8755 12379 break;
gume 0:1f82672b8755 12380 }
gume 0:1f82672b8755 12381 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 12382 data_u8r = BNO055_SET_BITSLICE
gume 0:1f82672b8755 12383 (data_u8r,
gume 0:1f82672b8755 12384 BNO055_GYRO_AUTO_SLEEP_DURN,
gume 0:1f82672b8755 12385 auto_sleep_durn_u8r);
gume 0:1f82672b8755 12386 com_rslt +=
gume 0:1f82672b8755 12387 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 12388 (p_bno055->dev_addr,
gume 0:1f82672b8755 12389 BNO055_GYRO_AUTO_SLEEP_DURN_REG,
gume 0:1f82672b8755 12390 &data_u8r,
gume 0:1f82672b8755 12391 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 12392 }
gume 0:1f82672b8755 12393 } else {
gume 0:1f82672b8755 12394 com_rslt = BNO055_OUT_OF_RANGE;
gume 0:1f82672b8755 12395 }
gume 0:1f82672b8755 12396 } else {
gume 0:1f82672b8755 12397 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12398 }
gume 0:1f82672b8755 12399 } else {
gume 0:1f82672b8755 12400 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12401 }
gume 0:1f82672b8755 12402 } else {
gume 0:1f82672b8755 12403 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12404 }
gume 0:1f82672b8755 12405 }
gume 0:1f82672b8755 12406 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 12407 /* set the operation mode of
gume 0:1f82672b8755 12408 previous operation mode*/
gume 0:1f82672b8755 12409 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 12410 (prev_opmode_u8);
gume 0:1f82672b8755 12411 return com_rslt;
gume 0:1f82672b8755 12412 }
gume 0:1f82672b8755 12413 /*!
gume 0:1f82672b8755 12414 * @brief This API used to read the mag sleep mode
gume 0:1f82672b8755 12415 * from page one register from 0x0E bit 0
gume 0:1f82672b8755 12416 *
gume 0:1f82672b8755 12417 * @param sleep_mode_u8 : The value of mag sleep mode
gume 0:1f82672b8755 12418 *
gume 0:1f82672b8755 12419 * @return results of bus communication function
gume 0:1f82672b8755 12420 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 12421 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 12422 *
gume 0:1f82672b8755 12423 *
gume 0:1f82672b8755 12424 */
gume 0:1f82672b8755 12425 BNO055_RETURN_FUNCTION_TYPE bno055_get_mag_sleep_mode(
gume 0:1f82672b8755 12426 u8 *sleep_mode_u8)
gume 0:1f82672b8755 12427 {
gume 0:1f82672b8755 12428 /* Variable used to return value of
gume 0:1f82672b8755 12429 communication routine*/
gume 0:1f82672b8755 12430 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12431 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 12432 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 12433 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 12434 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 12435 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 12436 } else {
gume 0:1f82672b8755 12437 /*condition check for page,mag sleep mode is
gume 0:1f82672b8755 12438 available in the page one*/
gume 0:1f82672b8755 12439 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 12440 /* Write page as one */
gume 0:1f82672b8755 12441 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 12442 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 12443 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 12444 /* Read the value of mag sleep mode*/
gume 0:1f82672b8755 12445 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 12446 (p_bno055->dev_addr,
gume 0:1f82672b8755 12447 BNO055_MAG_SLEEP_MODE_REG,
gume 0:1f82672b8755 12448 &data_u8r,
gume 0:1f82672b8755 12449 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 12450 *sleep_mode_u8 =
gume 0:1f82672b8755 12451 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 12452 BNO055_MAG_SLEEP_MODE);
gume 0:1f82672b8755 12453 } else {
gume 0:1f82672b8755 12454 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12455 }
gume 0:1f82672b8755 12456 }
gume 0:1f82672b8755 12457 return com_rslt;
gume 0:1f82672b8755 12458 }
gume 0:1f82672b8755 12459 /*!
gume 0:1f82672b8755 12460 * @brief This API used to write the mag sleep mode
gume 0:1f82672b8755 12461 * from page one register from 0x0E bit 0
gume 0:1f82672b8755 12462 *
gume 0:1f82672b8755 12463 * @param sleep_mode_u8 : The value of mag sleep mode
gume 0:1f82672b8755 12464 *
gume 0:1f82672b8755 12465 * @return results of bus communication function
gume 0:1f82672b8755 12466 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 12467 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 12468 *
gume 0:1f82672b8755 12469 *
gume 0:1f82672b8755 12470 */
gume 0:1f82672b8755 12471 BNO055_RETURN_FUNCTION_TYPE bno055_set_mag_sleep_mode(
gume 0:1f82672b8755 12472 u8 sleep_mode_u8)
gume 0:1f82672b8755 12473 {
gume 0:1f82672b8755 12474 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12475 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 12476 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 12477 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 12478 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 12479 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 12480 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 12481 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 12482 } else {
gume 0:1f82672b8755 12483 /* The write operation effective only if the operation
gume 0:1f82672b8755 12484 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 12485 current operation mode and set the config mode */
gume 0:1f82672b8755 12486 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 12487 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 12488 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 12489 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 12490 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 12491 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 12492 /* Write page as one */
gume 0:1f82672b8755 12493 pg_stat_s8 = bno055_write_page_id(
gume 0:1f82672b8755 12494 BNO055_PAGE_ONE);
gume 0:1f82672b8755 12495 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 12496 com_rslt =
gume 0:1f82672b8755 12497 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 12498 (p_bno055->dev_addr,
gume 0:1f82672b8755 12499 BNO055_MAG_SLEEP_MODE_REG,
gume 0:1f82672b8755 12500 &data_u8r,
gume 0:1f82672b8755 12501 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 12502 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 12503 /* Write the value
gume 0:1f82672b8755 12504 of mag sleep mode*/
gume 0:1f82672b8755 12505 data_u8r =
gume 0:1f82672b8755 12506 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 12507 BNO055_MAG_SLEEP_MODE,
gume 0:1f82672b8755 12508 sleep_mode_u8);
gume 0:1f82672b8755 12509 com_rslt +=
gume 0:1f82672b8755 12510 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 12511 (p_bno055->dev_addr,
gume 0:1f82672b8755 12512 BNO055_MAG_SLEEP_MODE_REG,
gume 0:1f82672b8755 12513 &data_u8r,
gume 0:1f82672b8755 12514 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 12515 }
gume 0:1f82672b8755 12516 } else {
gume 0:1f82672b8755 12517 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12518 }
gume 0:1f82672b8755 12519 } else {
gume 0:1f82672b8755 12520 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12521 }
gume 0:1f82672b8755 12522 } else {
gume 0:1f82672b8755 12523 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12524 }
gume 0:1f82672b8755 12525 }
gume 0:1f82672b8755 12526 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 12527 /* set the operation mode of
gume 0:1f82672b8755 12528 previous operation mode*/
gume 0:1f82672b8755 12529 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 12530 (prev_opmode_u8);
gume 0:1f82672b8755 12531 return com_rslt;
gume 0:1f82672b8755 12532 }
gume 0:1f82672b8755 12533 /*!
gume 0:1f82672b8755 12534 * @brief This API used to read the mag sleep duration
gume 0:1f82672b8755 12535 * from page one register from 0x0E bit 1 to 4
gume 0:1f82672b8755 12536 *
gume 0:1f82672b8755 12537 * @param sleep_durn_u8 : The value of mag sleep duration
gume 0:1f82672b8755 12538 *
gume 0:1f82672b8755 12539 * @return results of bus communication function
gume 0:1f82672b8755 12540 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 12541 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 12542 *
gume 0:1f82672b8755 12543 *
gume 0:1f82672b8755 12544 */
gume 0:1f82672b8755 12545 BNO055_RETURN_FUNCTION_TYPE bno055_get_mag_sleep_durn(
gume 0:1f82672b8755 12546 u8 *sleep_durn_u8)
gume 0:1f82672b8755 12547 {
gume 0:1f82672b8755 12548 /* Variable used to return value of
gume 0:1f82672b8755 12549 communication routine*/
gume 0:1f82672b8755 12550 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12551 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 12552 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 12553 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 12554 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 12555 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 12556 } else {
gume 0:1f82672b8755 12557 /*condition check for page,mag sleep duration is
gume 0:1f82672b8755 12558 available in the page one*/
gume 0:1f82672b8755 12559 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 12560 /* Write page as one */
gume 0:1f82672b8755 12561 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 12562 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 12563 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 12564 /* Read the value of mag sleep duration*/
gume 0:1f82672b8755 12565 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 12566 (p_bno055->dev_addr,
gume 0:1f82672b8755 12567 BNO055_MAG_SLEEP_DURN_REG,
gume 0:1f82672b8755 12568 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 12569 *sleep_durn_u8 =
gume 0:1f82672b8755 12570 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 12571 BNO055_MAG_SLEEP_DURN);
gume 0:1f82672b8755 12572 } else {
gume 0:1f82672b8755 12573 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12574 }
gume 0:1f82672b8755 12575 }
gume 0:1f82672b8755 12576 return com_rslt;
gume 0:1f82672b8755 12577 }
gume 0:1f82672b8755 12578 /*!
gume 0:1f82672b8755 12579 * @brief This API used to write the mag sleep duration
gume 0:1f82672b8755 12580 * from page one register from 0x0E bit 1 to 4
gume 0:1f82672b8755 12581 *
gume 0:1f82672b8755 12582 * @param sleep_durn_u8 : The value of mag sleep duration
gume 0:1f82672b8755 12583 *
gume 0:1f82672b8755 12584 * @return results of bus communication function
gume 0:1f82672b8755 12585 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 12586 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 12587 *
gume 0:1f82672b8755 12588 *
gume 0:1f82672b8755 12589 */
gume 0:1f82672b8755 12590 BNO055_RETURN_FUNCTION_TYPE bno055_set_mag_sleep_durn(
gume 0:1f82672b8755 12591 u8 sleep_durn_u8)
gume 0:1f82672b8755 12592 {
gume 0:1f82672b8755 12593 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12594 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 12595 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 12596 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 12597 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 12598 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 12599 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 12600 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 12601 } else {
gume 0:1f82672b8755 12602 /* The write operation effective only if the operation
gume 0:1f82672b8755 12603 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 12604 current operation mode and set the config mode */
gume 0:1f82672b8755 12605 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 12606 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 12607 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 12608 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 12609 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 12610 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 12611 /* Write page as one */
gume 0:1f82672b8755 12612 pg_stat_s8 = bno055_write_page_id(
gume 0:1f82672b8755 12613 BNO055_PAGE_ONE);
gume 0:1f82672b8755 12614 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 12615 com_rslt =
gume 0:1f82672b8755 12616 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 12617 (p_bno055->dev_addr,
gume 0:1f82672b8755 12618 BNO055_MAG_SLEEP_DURN_REG,
gume 0:1f82672b8755 12619 &data_u8r,
gume 0:1f82672b8755 12620 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 12621 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 12622 /* Write the value of
gume 0:1f82672b8755 12623 mag sleep duration */
gume 0:1f82672b8755 12624 data_u8r =
gume 0:1f82672b8755 12625 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 12626 BNO055_MAG_SLEEP_DURN,
gume 0:1f82672b8755 12627 sleep_durn_u8);
gume 0:1f82672b8755 12628 com_rslt +=
gume 0:1f82672b8755 12629 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 12630 (p_bno055->dev_addr,
gume 0:1f82672b8755 12631 BNO055_MAG_SLEEP_DURN_REG,
gume 0:1f82672b8755 12632 &data_u8r,
gume 0:1f82672b8755 12633 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 12634 }
gume 0:1f82672b8755 12635 } else {
gume 0:1f82672b8755 12636 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12637 }
gume 0:1f82672b8755 12638 } else {
gume 0:1f82672b8755 12639 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12640 }
gume 0:1f82672b8755 12641 } else {
gume 0:1f82672b8755 12642 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12643 }
gume 0:1f82672b8755 12644 }
gume 0:1f82672b8755 12645 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 12646 /* set the operation mode of
gume 0:1f82672b8755 12647 previous operation mode*/
gume 0:1f82672b8755 12648 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 12649 (prev_opmode_u8);
gume 0:1f82672b8755 12650 return com_rslt;
gume 0:1f82672b8755 12651 }
gume 0:1f82672b8755 12652 /*!
gume 0:1f82672b8755 12653 * @brief This API used to read the gyro anymotion interrupt mask
gume 0:1f82672b8755 12654 * from page one register from 0x0F bit 2
gume 0:1f82672b8755 12655 *
gume 0:1f82672b8755 12656 * @param gyro_any_motion_u8 : The value of gyro anymotion interrupt mask
gume 0:1f82672b8755 12657 * gyro_any_motion_u8 | result
gume 0:1f82672b8755 12658 * -------------------- |------------
gume 0:1f82672b8755 12659 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 12660 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 12661 *
gume 0:1f82672b8755 12662 * @return results of bus communication function
gume 0:1f82672b8755 12663 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 12664 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 12665 *
gume 0:1f82672b8755 12666 * @note While enabling the gyro anymotion interrupt
gume 0:1f82672b8755 12667 * configure the following settings
gume 0:1f82672b8755 12668 *
gume 0:1f82672b8755 12669 * Axis:
gume 0:1f82672b8755 12670 * bno055_set_gyro_any_motion_axis_enable()
gume 0:1f82672b8755 12671 *
gume 0:1f82672b8755 12672 * Filter setting:
gume 0:1f82672b8755 12673 * bno055_set_gyro_any_motion_filter()
gume 0:1f82672b8755 12674 *
gume 0:1f82672b8755 12675 * Threshold :
gume 0:1f82672b8755 12676 *
gume 0:1f82672b8755 12677 * bno055_set_gyro_any_motion_thres()
gume 0:1f82672b8755 12678 *
gume 0:1f82672b8755 12679 * Slope samples :
gume 0:1f82672b8755 12680 *
gume 0:1f82672b8755 12681 * bno055_set_gyro_any_motion_slope_samples()
gume 0:1f82672b8755 12682 *
gume 0:1f82672b8755 12683 * Awake duration :
gume 0:1f82672b8755 12684 *
gume 0:1f82672b8755 12685 * bno055_set_gyro_any_motion_awake_durn()
gume 0:1f82672b8755 12686 *
gume 0:1f82672b8755 12687 */
gume 0:1f82672b8755 12688 BNO055_RETURN_FUNCTION_TYPE bno055_get_intr_mask_gyro_any_motion(
gume 0:1f82672b8755 12689 u8 *gyro_any_motion_u8)
gume 0:1f82672b8755 12690 {
gume 0:1f82672b8755 12691 /* Variable used to return value of
gume 0:1f82672b8755 12692 communication routine*/
gume 0:1f82672b8755 12693 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12694 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 12695 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 12696 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 12697 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 12698 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 12699 } else {
gume 0:1f82672b8755 12700 /*condition check for page, gyro anymotion interrupt mask is
gume 0:1f82672b8755 12701 available in the page one*/
gume 0:1f82672b8755 12702 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 12703 /* Write page as one */
gume 0:1f82672b8755 12704 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 12705 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 12706 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 12707 /* Read the value of gyro anymotion interrupt mask*/
gume 0:1f82672b8755 12708 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 12709 (p_bno055->dev_addr,
gume 0:1f82672b8755 12710 BNO055_GYRO_ANY_MOTION_INTR_MASK_REG,
gume 0:1f82672b8755 12711 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 12712 *gyro_any_motion_u8 =
gume 0:1f82672b8755 12713 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 12714 BNO055_GYRO_ANY_MOTION_INTR_MASK);
gume 0:1f82672b8755 12715 } else {
gume 0:1f82672b8755 12716 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12717 }
gume 0:1f82672b8755 12718 }
gume 0:1f82672b8755 12719 return com_rslt;
gume 0:1f82672b8755 12720 }
gume 0:1f82672b8755 12721 /*!
gume 0:1f82672b8755 12722 * @brief This API used to write the gyro anymotion interrupt mask
gume 0:1f82672b8755 12723 * from page one register from 0x0F bit 2
gume 0:1f82672b8755 12724 *
gume 0:1f82672b8755 12725 * @param gyro_any_motion_u8 : The value of gyro anymotion interrupt mask
gume 0:1f82672b8755 12726 * gyro_any_motion_u8 | result
gume 0:1f82672b8755 12727 * -------------------- |------------
gume 0:1f82672b8755 12728 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 12729 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 12730 *
gume 0:1f82672b8755 12731 * @return results of bus communication function
gume 0:1f82672b8755 12732 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 12733 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 12734 *
gume 0:1f82672b8755 12735 * @note While enabling the gyro anymotion interrupt
gume 0:1f82672b8755 12736 * configure the following settings
gume 0:1f82672b8755 12737 *
gume 0:1f82672b8755 12738 * Axis:
gume 0:1f82672b8755 12739 * bno055_set_gyro_any_motion_axis_enable()
gume 0:1f82672b8755 12740 *
gume 0:1f82672b8755 12741 * Filter setting:
gume 0:1f82672b8755 12742 * bno055_set_gyro_any_motion_filter()
gume 0:1f82672b8755 12743 *
gume 0:1f82672b8755 12744 * Threshold :
gume 0:1f82672b8755 12745 *
gume 0:1f82672b8755 12746 * bno055_set_gyro_any_motion_thres()
gume 0:1f82672b8755 12747 *
gume 0:1f82672b8755 12748 * Slope samples :
gume 0:1f82672b8755 12749 *
gume 0:1f82672b8755 12750 * bno055_set_gyro_any_motion_slope_samples()
gume 0:1f82672b8755 12751 *
gume 0:1f82672b8755 12752 * Awake duration :
gume 0:1f82672b8755 12753 *
gume 0:1f82672b8755 12754 * bno055_set_gyro_any_motion_awake_durn()
gume 0:1f82672b8755 12755 *
gume 0:1f82672b8755 12756 */
gume 0:1f82672b8755 12757 BNO055_RETURN_FUNCTION_TYPE bno055_set_intr_mask_gyro_any_motion(
gume 0:1f82672b8755 12758 u8 gyro_any_motion_u8)
gume 0:1f82672b8755 12759 {
gume 0:1f82672b8755 12760 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12761 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 12762 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 12763 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 12764 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 12765 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 12766 } else {
gume 0:1f82672b8755 12767 /*condition check for page, accel range is
gume 0:1f82672b8755 12768 available in the page one*/
gume 0:1f82672b8755 12769 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 12770 /* Write page as one */
gume 0:1f82672b8755 12771 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 12772 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 12773 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 12774 /* Write the value of gyro anymotion interrupt mask*/
gume 0:1f82672b8755 12775 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 12776 (p_bno055->dev_addr,
gume 0:1f82672b8755 12777 BNO055_GYRO_ANY_MOTION_INTR_MASK_REG,
gume 0:1f82672b8755 12778 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 12779 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 12780 data_u8r =
gume 0:1f82672b8755 12781 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 12782 BNO055_GYRO_ANY_MOTION_INTR_MASK,
gume 0:1f82672b8755 12783 gyro_any_motion_u8);
gume 0:1f82672b8755 12784 com_rslt +=
gume 0:1f82672b8755 12785 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 12786 (p_bno055->dev_addr,
gume 0:1f82672b8755 12787 BNO055_GYRO_ANY_MOTION_INTR_MASK_REG,
gume 0:1f82672b8755 12788 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 12789 }
gume 0:1f82672b8755 12790 } else {
gume 0:1f82672b8755 12791 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12792 }
gume 0:1f82672b8755 12793 }
gume 0:1f82672b8755 12794 return com_rslt;
gume 0:1f82672b8755 12795 }
gume 0:1f82672b8755 12796 /*!
gume 0:1f82672b8755 12797 * @brief This API used to read the gyro highrate interrupt mask
gume 0:1f82672b8755 12798 * from page one register from 0x0F bit 3
gume 0:1f82672b8755 12799 *
gume 0:1f82672b8755 12800 * @param gyro_highrate_u8 : The value of gyro highrate interrupt mask
gume 0:1f82672b8755 12801 * gyro_highrate_u8 | result
gume 0:1f82672b8755 12802 * -------------------- |------------
gume 0:1f82672b8755 12803 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 12804 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 12805 *
gume 0:1f82672b8755 12806 * @return results of bus communication function
gume 0:1f82672b8755 12807 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 12808 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 12809 *
gume 0:1f82672b8755 12810 * @note While enabling the gyro highrate interrupt
gume 0:1f82672b8755 12811 * configure the below settings by using
gume 0:1f82672b8755 12812 * the following API
gume 0:1f82672b8755 12813 *
gume 0:1f82672b8755 12814 * Axis :
gume 0:1f82672b8755 12815 *
gume 0:1f82672b8755 12816 * bno055_set_gyro_highrate_axis_enable()
gume 0:1f82672b8755 12817 *
gume 0:1f82672b8755 12818 * Filter :
gume 0:1f82672b8755 12819 *
gume 0:1f82672b8755 12820 * bno055_set_gyro_highrate_filter()
gume 0:1f82672b8755 12821 *
gume 0:1f82672b8755 12822 * Threshold :
gume 0:1f82672b8755 12823 *
gume 0:1f82672b8755 12824 * bno055_get_gyro_highrate_x_thres()
gume 0:1f82672b8755 12825 *
gume 0:1f82672b8755 12826 * bno055_get_gyro_highrate_y_thres()
gume 0:1f82672b8755 12827 *
gume 0:1f82672b8755 12828 * bno055_get_gyro_highrate_z_thres()
gume 0:1f82672b8755 12829 *
gume 0:1f82672b8755 12830 * Hysteresis :
gume 0:1f82672b8755 12831 *
gume 0:1f82672b8755 12832 * bno055_set_gyro_highrate_x_hyst()
gume 0:1f82672b8755 12833 *
gume 0:1f82672b8755 12834 * bno055_set_gyro_highrate_y_hyst()
gume 0:1f82672b8755 12835 *
gume 0:1f82672b8755 12836 * bno055_set_gyro_highrate_z_hyst()
gume 0:1f82672b8755 12837 *
gume 0:1f82672b8755 12838 * Duration :
gume 0:1f82672b8755 12839 *
gume 0:1f82672b8755 12840 * bno055_set_gyro_highrate_x_durn()
gume 0:1f82672b8755 12841 *
gume 0:1f82672b8755 12842 * bno055_set_gyro_highrate_y_durn()
gume 0:1f82672b8755 12843 *
gume 0:1f82672b8755 12844 * bno055_set_gyro_highrate_z_durn()
gume 0:1f82672b8755 12845 *
gume 0:1f82672b8755 12846 */
gume 0:1f82672b8755 12847 BNO055_RETURN_FUNCTION_TYPE bno055_get_intr_mask_gyro_highrate(
gume 0:1f82672b8755 12848 u8 *gyro_highrate_u8)
gume 0:1f82672b8755 12849 {
gume 0:1f82672b8755 12850 /* Variable used to return value of
gume 0:1f82672b8755 12851 communication routine*/
gume 0:1f82672b8755 12852 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12853 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 12854 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 12855 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 12856 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 12857 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 12858 } else {
gume 0:1f82672b8755 12859 /*condition check for page, gyro highrate interrupt mask is
gume 0:1f82672b8755 12860 available in the page one*/
gume 0:1f82672b8755 12861 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 12862 /* Write page as one */
gume 0:1f82672b8755 12863 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 12864 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 12865 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 12866 /* Read the value of gyro highrate interrupt mask*/
gume 0:1f82672b8755 12867 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 12868 (p_bno055->dev_addr,
gume 0:1f82672b8755 12869 BNO055_GYRO_HIGHRATE_INTR_MASK_REG,
gume 0:1f82672b8755 12870 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 12871 *gyro_highrate_u8 =
gume 0:1f82672b8755 12872 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 12873 BNO055_GYRO_HIGHRATE_INTR_MASK);
gume 0:1f82672b8755 12874 } else {
gume 0:1f82672b8755 12875 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12876 }
gume 0:1f82672b8755 12877 }
gume 0:1f82672b8755 12878 return com_rslt;
gume 0:1f82672b8755 12879 }
gume 0:1f82672b8755 12880 /*!
gume 0:1f82672b8755 12881 * @brief This API used to write the gyro highrate interrupt mask
gume 0:1f82672b8755 12882 * from page one register from 0x0F bit 3
gume 0:1f82672b8755 12883 *
gume 0:1f82672b8755 12884 * @param gyro_highrate_u8 : The value of gyro highrate interrupt mask
gume 0:1f82672b8755 12885 * gyro_highrate_u8 | result
gume 0:1f82672b8755 12886 * -------------------- |------------
gume 0:1f82672b8755 12887 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 12888 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 12889 *
gume 0:1f82672b8755 12890 * @return results of bus communication function
gume 0:1f82672b8755 12891 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 12892 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 12893 *
gume 0:1f82672b8755 12894 * @note While enabling the gyro highrate interrupt
gume 0:1f82672b8755 12895 * configure the below settings by using
gume 0:1f82672b8755 12896 * the following APIs
gume 0:1f82672b8755 12897 *
gume 0:1f82672b8755 12898 * Axis :
gume 0:1f82672b8755 12899 *
gume 0:1f82672b8755 12900 * bno055_set_gyro_highrate_axis_enable()
gume 0:1f82672b8755 12901 *
gume 0:1f82672b8755 12902 * Filter :
gume 0:1f82672b8755 12903 *
gume 0:1f82672b8755 12904 * bno055_set_gyro_highrate_filter()
gume 0:1f82672b8755 12905 *
gume 0:1f82672b8755 12906 * Threshold :
gume 0:1f82672b8755 12907 *
gume 0:1f82672b8755 12908 * bno055_get_gyro_highrate_x_thres()
gume 0:1f82672b8755 12909 *
gume 0:1f82672b8755 12910 * bno055_get_gyro_highrate_y_thres()
gume 0:1f82672b8755 12911 *
gume 0:1f82672b8755 12912 * bno055_get_gyro_highrate_z_thres()
gume 0:1f82672b8755 12913 *
gume 0:1f82672b8755 12914 * Hysteresis :
gume 0:1f82672b8755 12915 *
gume 0:1f82672b8755 12916 * bno055_set_gyro_highrate_x_hyst()
gume 0:1f82672b8755 12917 *
gume 0:1f82672b8755 12918 * bno055_set_gyro_highrate_y_hyst()
gume 0:1f82672b8755 12919 *
gume 0:1f82672b8755 12920 * bno055_set_gyro_highrate_z_hyst()
gume 0:1f82672b8755 12921 *
gume 0:1f82672b8755 12922 * Duration :
gume 0:1f82672b8755 12923 *
gume 0:1f82672b8755 12924 * bno055_set_gyro_highrate_x_durn()
gume 0:1f82672b8755 12925 *
gume 0:1f82672b8755 12926 * bno055_set_gyro_highrate_y_durn()
gume 0:1f82672b8755 12927 *
gume 0:1f82672b8755 12928 * bno055_set_gyro_highrate_z_durn()
gume 0:1f82672b8755 12929 *
gume 0:1f82672b8755 12930 */
gume 0:1f82672b8755 12931 BNO055_RETURN_FUNCTION_TYPE bno055_set_intr_mask_gyro_highrate(
gume 0:1f82672b8755 12932 u8 gyro_highrate_u8)
gume 0:1f82672b8755 12933 {
gume 0:1f82672b8755 12934 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12935 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 12936 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 12937 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 12938 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 12939 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 12940 } else {
gume 0:1f82672b8755 12941 /*condition check for page, gyro highrate interrupt mask is
gume 0:1f82672b8755 12942 available in the page one*/
gume 0:1f82672b8755 12943 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 12944 /* Write page as one */
gume 0:1f82672b8755 12945 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 12946 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 12947 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 12948 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 12949 (p_bno055->dev_addr,
gume 0:1f82672b8755 12950 BNO055_GYRO_HIGHRATE_INTR_MASK_REG,
gume 0:1f82672b8755 12951 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 12952 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 12953 /* Write the value of gyro
gume 0:1f82672b8755 12954 highrate interrupt mask*/
gume 0:1f82672b8755 12955 data_u8r =
gume 0:1f82672b8755 12956 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 12957 BNO055_GYRO_HIGHRATE_INTR_MASK,
gume 0:1f82672b8755 12958 gyro_highrate_u8);
gume 0:1f82672b8755 12959 com_rslt +=
gume 0:1f82672b8755 12960 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 12961 (p_bno055->dev_addr,
gume 0:1f82672b8755 12962 BNO055_GYRO_HIGHRATE_INTR_MASK_REG,
gume 0:1f82672b8755 12963 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 12964 }
gume 0:1f82672b8755 12965 } else {
gume 0:1f82672b8755 12966 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 12967 }
gume 0:1f82672b8755 12968 }
gume 0:1f82672b8755 12969 return com_rslt;
gume 0:1f82672b8755 12970 }
gume 0:1f82672b8755 12971 /*!
gume 0:1f82672b8755 12972 * @brief This API used to read the accel highg interrupt mask
gume 0:1f82672b8755 12973 * from page one register from 0x0F bit 5
gume 0:1f82672b8755 12974 *
gume 0:1f82672b8755 12975 * @param accel_high_g_u8 : The value of accel highg interrupt mask
gume 0:1f82672b8755 12976 * accel_high_g_u8 | result
gume 0:1f82672b8755 12977 * -------------------- |------------
gume 0:1f82672b8755 12978 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 12979 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 12980 *
gume 0:1f82672b8755 12981 * @return results of bus communication function
gume 0:1f82672b8755 12982 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 12983 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 12984 *
gume 0:1f82672b8755 12985 * @note While enabling the accel highg interrupt
gume 0:1f82672b8755 12986 * configure the below settings by using
gume 0:1f82672b8755 12987 * the following APIs
gume 0:1f82672b8755 12988 *
gume 0:1f82672b8755 12989 * Axis :
gume 0:1f82672b8755 12990 *
gume 0:1f82672b8755 12991 * bno055_set_accel_high_g_axis_enable()
gume 0:1f82672b8755 12992 *
gume 0:1f82672b8755 12993 * Threshold :
gume 0:1f82672b8755 12994 *
gume 0:1f82672b8755 12995 * bno055_set_accel_high_g_thres()
gume 0:1f82672b8755 12996 *
gume 0:1f82672b8755 12997 * Duration :
gume 0:1f82672b8755 12998 *
gume 0:1f82672b8755 12999 * bno055_set_accel_high_g_durn()
gume 0:1f82672b8755 13000 *
gume 0:1f82672b8755 13001 */
gume 0:1f82672b8755 13002 BNO055_RETURN_FUNCTION_TYPE bno055_get_intr_mask_accel_high_g(
gume 0:1f82672b8755 13003 u8 *accel_high_g_u8)
gume 0:1f82672b8755 13004 {
gume 0:1f82672b8755 13005 /* Variable used to return value of
gume 0:1f82672b8755 13006 communication routine*/
gume 0:1f82672b8755 13007 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13008 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 13009 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 13010 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 13011 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 13012 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 13013 } else {
gume 0:1f82672b8755 13014 /*condition check for page, accel highg interrupt mask is
gume 0:1f82672b8755 13015 available in the page one*/
gume 0:1f82672b8755 13016 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 13017 /* Write page as one */
gume 0:1f82672b8755 13018 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 13019 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 13020 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 13021 /* Read the value of accel highg interrupt mask*/
gume 0:1f82672b8755 13022 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 13023 (p_bno055->dev_addr,
gume 0:1f82672b8755 13024 BNO055_ACCEL_HIGH_G_INTR_MASK_REG,
gume 0:1f82672b8755 13025 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 13026 *accel_high_g_u8 =
gume 0:1f82672b8755 13027 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 13028 BNO055_ACCEL_HIGH_G_INTR_MASK);
gume 0:1f82672b8755 13029 } else {
gume 0:1f82672b8755 13030 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13031 }
gume 0:1f82672b8755 13032 }
gume 0:1f82672b8755 13033 return com_rslt;
gume 0:1f82672b8755 13034 }
gume 0:1f82672b8755 13035 /*!
gume 0:1f82672b8755 13036 * @brief This API used to write the accel highg interrupt mask
gume 0:1f82672b8755 13037 * from page one register from 0x0F bit 5
gume 0:1f82672b8755 13038 *
gume 0:1f82672b8755 13039 * @param accel_high_g_u8 : The value of accel highg interrupt mask
gume 0:1f82672b8755 13040 * accel_high_g_u8 | result
gume 0:1f82672b8755 13041 * -------------------- |------------
gume 0:1f82672b8755 13042 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 13043 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 13044 *
gume 0:1f82672b8755 13045 * @return results of bus communication function
gume 0:1f82672b8755 13046 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 13047 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 13048 *
gume 0:1f82672b8755 13049 * @note While enabling the accel highg interrupt
gume 0:1f82672b8755 13050 * configure the below settings by using
gume 0:1f82672b8755 13051 * the following APIs
gume 0:1f82672b8755 13052 *
gume 0:1f82672b8755 13053 * Axis :
gume 0:1f82672b8755 13054 *
gume 0:1f82672b8755 13055 * bno055_set_accel_high_g_axis_enable()
gume 0:1f82672b8755 13056 *
gume 0:1f82672b8755 13057 * Threshold :
gume 0:1f82672b8755 13058 *
gume 0:1f82672b8755 13059 * bno055_set_accel_high_g_thres()
gume 0:1f82672b8755 13060 *
gume 0:1f82672b8755 13061 * Duration :
gume 0:1f82672b8755 13062 *
gume 0:1f82672b8755 13063 * bno055_set_accel_high_g_durn()
gume 0:1f82672b8755 13064 *
gume 0:1f82672b8755 13065 */
gume 0:1f82672b8755 13066 BNO055_RETURN_FUNCTION_TYPE bno055_set_intr_mask_accel_high_g(
gume 0:1f82672b8755 13067 u8 accel_high_g_u8)
gume 0:1f82672b8755 13068 {
gume 0:1f82672b8755 13069 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13070 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 13071 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 13072 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 13073 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 13074 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 13075 } else {
gume 0:1f82672b8755 13076 /*condition check for page, accel highg interrupt mask is
gume 0:1f82672b8755 13077 available in the page one*/
gume 0:1f82672b8755 13078 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 13079 /* Write page as one */
gume 0:1f82672b8755 13080 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 13081 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 13082 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 13083 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 13084 (p_bno055->dev_addr,
gume 0:1f82672b8755 13085 BNO055_ACCEL_HIGH_G_INTR_MASK_REG,
gume 0:1f82672b8755 13086 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 13087 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 13088 /* Write the value of accel
gume 0:1f82672b8755 13089 highg interrupt mask*/
gume 0:1f82672b8755 13090 data_u8r =
gume 0:1f82672b8755 13091 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 13092 BNO055_ACCEL_HIGH_G_INTR_MASK,
gume 0:1f82672b8755 13093 accel_high_g_u8);
gume 0:1f82672b8755 13094 com_rslt +=
gume 0:1f82672b8755 13095 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 13096 (p_bno055->dev_addr,
gume 0:1f82672b8755 13097 BNO055_ACCEL_HIGH_G_INTR_MASK_REG,
gume 0:1f82672b8755 13098 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 13099 }
gume 0:1f82672b8755 13100 } else {
gume 0:1f82672b8755 13101 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13102 }
gume 0:1f82672b8755 13103 }
gume 0:1f82672b8755 13104 return com_rslt;
gume 0:1f82672b8755 13105 }
gume 0:1f82672b8755 13106 /*!
gume 0:1f82672b8755 13107 * @brief This API used to read the accel anymotion interrupt mask
gume 0:1f82672b8755 13108 * from page one register from 0x0F bit 6
gume 0:1f82672b8755 13109 *
gume 0:1f82672b8755 13110 * @param accel_any_motion_u8 : The value of accel anymotion interrupt mask
gume 0:1f82672b8755 13111 * accel_any_motion_u8 | result
gume 0:1f82672b8755 13112 * -------------------- |------------
gume 0:1f82672b8755 13113 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 13114 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 13115 *
gume 0:1f82672b8755 13116 * @return results of bus communication function
gume 0:1f82672b8755 13117 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 13118 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 13119 *
gume 0:1f82672b8755 13120 * @note While enabling the accel highg interrupt
gume 0:1f82672b8755 13121 * configure the below settings by using
gume 0:1f82672b8755 13122 * the following APIs
gume 0:1f82672b8755 13123 *
gume 0:1f82672b8755 13124 * Axis :
gume 0:1f82672b8755 13125 *
gume 0:1f82672b8755 13126 * bno055_set_accel_high_g_axis_enable()
gume 0:1f82672b8755 13127 *
gume 0:1f82672b8755 13128 * Threshold :
gume 0:1f82672b8755 13129 *
gume 0:1f82672b8755 13130 * bno055_set_accel_high_g_thres()
gume 0:1f82672b8755 13131 *
gume 0:1f82672b8755 13132 * Duration :
gume 0:1f82672b8755 13133 *
gume 0:1f82672b8755 13134 * bno055_set_accel_high_g_durn()
gume 0:1f82672b8755 13135 *
gume 0:1f82672b8755 13136 */
gume 0:1f82672b8755 13137 BNO055_RETURN_FUNCTION_TYPE bno055_get_intr_mask_accel_any_motion(
gume 0:1f82672b8755 13138 u8 *accel_any_motion_u8)
gume 0:1f82672b8755 13139 {
gume 0:1f82672b8755 13140 /* Variable used to return value of
gume 0:1f82672b8755 13141 communication routine*/
gume 0:1f82672b8755 13142 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13143 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 13144 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 13145 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 13146 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 13147 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 13148 } else {
gume 0:1f82672b8755 13149 /*condition check for page, accel anymotion interrupt mask is
gume 0:1f82672b8755 13150 available in the page one*/
gume 0:1f82672b8755 13151 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 13152 /* Write page as one */
gume 0:1f82672b8755 13153 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 13154 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 13155 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 13156 /* The value of accel anymotion interrupt mask*/
gume 0:1f82672b8755 13157 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 13158 (p_bno055->dev_addr,
gume 0:1f82672b8755 13159 BNO055_ACCEL_ANY_MOTION_INTR_MASK_REG,
gume 0:1f82672b8755 13160 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 13161 *accel_any_motion_u8 =
gume 0:1f82672b8755 13162 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 13163 BNO055_ACCEL_ANY_MOTION_INTR_MASK);
gume 0:1f82672b8755 13164 } else {
gume 0:1f82672b8755 13165 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13166 }
gume 0:1f82672b8755 13167 }
gume 0:1f82672b8755 13168 return com_rslt;
gume 0:1f82672b8755 13169 }
gume 0:1f82672b8755 13170 /*!
gume 0:1f82672b8755 13171 * @brief This API used to write the accel anymotion interrupt mask
gume 0:1f82672b8755 13172 * from page one register from 0x0F bit 6
gume 0:1f82672b8755 13173 *
gume 0:1f82672b8755 13174 * @param accel_any_motion_u8 : The value of accel anymotion interrupt mask
gume 0:1f82672b8755 13175 * accel_any_motion_u8 | result
gume 0:1f82672b8755 13176 * -------------------- |------------
gume 0:1f82672b8755 13177 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 13178 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 13179 *
gume 0:1f82672b8755 13180 * @return results of bus communication function
gume 0:1f82672b8755 13181 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 13182 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 13183 *
gume 0:1f82672b8755 13184 * @note While enabling the accel anymotion interrupt
gume 0:1f82672b8755 13185 * configure the following settings
gume 0:1f82672b8755 13186 *
gume 0:1f82672b8755 13187 * Axis:
gume 0:1f82672b8755 13188 *
gume 0:1f82672b8755 13189 * bno055_set_accel_any_motion_no_motion_axis_enable()
gume 0:1f82672b8755 13190 *
gume 0:1f82672b8755 13191 * Duration:
gume 0:1f82672b8755 13192 *
gume 0:1f82672b8755 13193 * bno055_set_accel_any_motion_durn()
gume 0:1f82672b8755 13194 *
gume 0:1f82672b8755 13195 * Threshold:
gume 0:1f82672b8755 13196 *
gume 0:1f82672b8755 13197 * bno055_set_accel_any_motion_thres()
gume 0:1f82672b8755 13198 *
gume 0:1f82672b8755 13199 */
gume 0:1f82672b8755 13200 BNO055_RETURN_FUNCTION_TYPE bno055_set_intr_mask_accel_any_motion(
gume 0:1f82672b8755 13201 u8 accel_any_motion_u8)
gume 0:1f82672b8755 13202 {
gume 0:1f82672b8755 13203 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13204 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 13205 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 13206 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 13207 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 13208 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 13209 } else {
gume 0:1f82672b8755 13210 /*condition check for page, accel anymotion interrupt mask is
gume 0:1f82672b8755 13211 available in the page one*/
gume 0:1f82672b8755 13212 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 13213 /* Write page as one */
gume 0:1f82672b8755 13214 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 13215 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 13216 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 13217 /* Write the value of accel anymotion interrupt mask*/
gume 0:1f82672b8755 13218 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 13219 (p_bno055->dev_addr,
gume 0:1f82672b8755 13220 BNO055_ACCEL_ANY_MOTION_INTR_MASK_REG,
gume 0:1f82672b8755 13221 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 13222 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 13223 data_u8r =
gume 0:1f82672b8755 13224 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 13225 BNO055_ACCEL_ANY_MOTION_INTR_MASK,
gume 0:1f82672b8755 13226 accel_any_motion_u8);
gume 0:1f82672b8755 13227 com_rslt +=
gume 0:1f82672b8755 13228 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 13229 (p_bno055->dev_addr,
gume 0:1f82672b8755 13230 BNO055_ACCEL_ANY_MOTION_INTR_MASK_REG,
gume 0:1f82672b8755 13231 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 13232 }
gume 0:1f82672b8755 13233 } else {
gume 0:1f82672b8755 13234 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13235 }
gume 0:1f82672b8755 13236 }
gume 0:1f82672b8755 13237 return com_rslt;
gume 0:1f82672b8755 13238 }
gume 0:1f82672b8755 13239 /*!
gume 0:1f82672b8755 13240 * @brief This API used to read the accel nomotion interrupt mask
gume 0:1f82672b8755 13241 * from page one register from 0x0F bit 7
gume 0:1f82672b8755 13242 *
gume 0:1f82672b8755 13243 * @param accel_nomotion_u8 : The value of accel nomotion interrupt mask
gume 0:1f82672b8755 13244 * accel_nomotion_u8 | result
gume 0:1f82672b8755 13245 * -------------------- |------------
gume 0:1f82672b8755 13246 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 13247 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 13248 *
gume 0:1f82672b8755 13249 * @return results of bus communication function
gume 0:1f82672b8755 13250 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 13251 *
gume 0:1f82672b8755 13252 * @note While enabling the accel anymotion interrupt
gume 0:1f82672b8755 13253 * configure the following settings
gume 0:1f82672b8755 13254 *
gume 0:1f82672b8755 13255 * Axis:
gume 0:1f82672b8755 13256 *
gume 0:1f82672b8755 13257 * bno055_set_accel_any_motion_no_motion_axis_enable()
gume 0:1f82672b8755 13258 *
gume 0:1f82672b8755 13259 * Duration:
gume 0:1f82672b8755 13260 *
gume 0:1f82672b8755 13261 * bno055_set_accel_any_motion_durn()
gume 0:1f82672b8755 13262 *
gume 0:1f82672b8755 13263 * Threshold:
gume 0:1f82672b8755 13264 *
gume 0:1f82672b8755 13265 * bno055_set_accel_any_motion_thres())
gume 0:1f82672b8755 13266 *
gume 0:1f82672b8755 13267 */
gume 0:1f82672b8755 13268 BNO055_RETURN_FUNCTION_TYPE bno055_get_intr_mask_accel_no_motion(
gume 0:1f82672b8755 13269 u8 *accel_nomotion_u8)
gume 0:1f82672b8755 13270 {
gume 0:1f82672b8755 13271 /* Variable used to return value of
gume 0:1f82672b8755 13272 communication routine*/
gume 0:1f82672b8755 13273 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13274 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 13275 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 13276 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 13277 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 13278 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 13279 } else {
gume 0:1f82672b8755 13280 /*condition check for page, accel nomotion interrupt mask is
gume 0:1f82672b8755 13281 available in the page one*/
gume 0:1f82672b8755 13282 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 13283 /* Write page as one */
gume 0:1f82672b8755 13284 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 13285 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 13286 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 13287 /* Read the value of accel nomotion interrupt mask*/
gume 0:1f82672b8755 13288 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 13289 (p_bno055->dev_addr,
gume 0:1f82672b8755 13290 BNO055_ACCEL_NO_MOTION_INTR_MASK_REG,
gume 0:1f82672b8755 13291 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 13292 *accel_nomotion_u8 =
gume 0:1f82672b8755 13293 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 13294 BNO055_ACCEL_NO_MOTION_INTR_MASK);
gume 0:1f82672b8755 13295 } else {
gume 0:1f82672b8755 13296 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13297 }
gume 0:1f82672b8755 13298 }
gume 0:1f82672b8755 13299 return com_rslt;
gume 0:1f82672b8755 13300 }
gume 0:1f82672b8755 13301 /*!
gume 0:1f82672b8755 13302 * @brief This API used to write the accel nomotion interrupt mask
gume 0:1f82672b8755 13303 * from page one register from 0x0F bit 7
gume 0:1f82672b8755 13304 *
gume 0:1f82672b8755 13305 * @param accel_nomotion_u8 : The value of accel nomotion interrupt mask
gume 0:1f82672b8755 13306 * accel_nomotion_u8 | result
gume 0:1f82672b8755 13307 * -------------------- |------------
gume 0:1f82672b8755 13308 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 13309 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 13310 *
gume 0:1f82672b8755 13311 * @return results of bus communication function
gume 0:1f82672b8755 13312 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 13313 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 13314 *
gume 0:1f82672b8755 13315 * @note While enabling the accel nomotion interrupt
gume 0:1f82672b8755 13316 * configure the following settings
gume 0:1f82672b8755 13317 *
gume 0:1f82672b8755 13318 * Axis:
gume 0:1f82672b8755 13319 *
gume 0:1f82672b8755 13320 * bno055_set_accel_any_motion_no_motion_axis_enable()
gume 0:1f82672b8755 13321 *
gume 0:1f82672b8755 13322 * Threshold :
gume 0:1f82672b8755 13323 *
gume 0:1f82672b8755 13324 * bno055_set_accel_slow_no_motion_thres()
gume 0:1f82672b8755 13325 *
gume 0:1f82672b8755 13326 * Duration :
gume 0:1f82672b8755 13327 *
gume 0:1f82672b8755 13328 * bno055_set_accel_slow_no_motion_durn()
gume 0:1f82672b8755 13329 *
gume 0:1f82672b8755 13330 * Slow/no motion enable:
gume 0:1f82672b8755 13331 *
gume 0:1f82672b8755 13332 * bno055_set_accel_slow_no_motion_enable()
gume 0:1f82672b8755 13333 *
gume 0:1f82672b8755 13334 */
gume 0:1f82672b8755 13335 BNO055_RETURN_FUNCTION_TYPE bno055_set_intr_mask_accel_no_motion(
gume 0:1f82672b8755 13336 u8 accel_nomotion_u8)
gume 0:1f82672b8755 13337 {
gume 0:1f82672b8755 13338 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13339 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 13340 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 13341 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 13342 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 13343 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 13344 } else {
gume 0:1f82672b8755 13345 /*condition check for page, accel
gume 0:1f82672b8755 13346 nomotion interrupt mask is
gume 0:1f82672b8755 13347 available in the page one*/
gume 0:1f82672b8755 13348 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 13349 /* Write page as one */
gume 0:1f82672b8755 13350 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 13351 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 13352 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 13353 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 13354 (p_bno055->dev_addr,
gume 0:1f82672b8755 13355 BNO055_ACCEL_NO_MOTION_INTR_MASK_REG,
gume 0:1f82672b8755 13356 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 13357 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 13358 /* Write the value of accel
gume 0:1f82672b8755 13359 nomotion interrupt mask*/
gume 0:1f82672b8755 13360 data_u8r =
gume 0:1f82672b8755 13361 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 13362 BNO055_ACCEL_NO_MOTION_INTR_MASK,
gume 0:1f82672b8755 13363 accel_nomotion_u8);
gume 0:1f82672b8755 13364 com_rslt +=
gume 0:1f82672b8755 13365 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 13366 (p_bno055->dev_addr,
gume 0:1f82672b8755 13367 BNO055_ACCEL_NO_MOTION_INTR_MASK_REG,
gume 0:1f82672b8755 13368 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 13369 }
gume 0:1f82672b8755 13370 } else {
gume 0:1f82672b8755 13371 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13372 }
gume 0:1f82672b8755 13373 }
gume 0:1f82672b8755 13374 return com_rslt;
gume 0:1f82672b8755 13375 }
gume 0:1f82672b8755 13376 /*!
gume 0:1f82672b8755 13377 * @brief This API used to read the gyro anymotion interrupt
gume 0:1f82672b8755 13378 * from page one register from 0x10 bit 2
gume 0:1f82672b8755 13379 *
gume 0:1f82672b8755 13380 * @param gyro_any_motion_u8 : The value of gyro anymotion interrupt
gume 0:1f82672b8755 13381 * gyro_any_motion_u8 | result
gume 0:1f82672b8755 13382 * -------------------- |------------
gume 0:1f82672b8755 13383 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 13384 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 13385 *
gume 0:1f82672b8755 13386 * @return results of bus communication function
gume 0:1f82672b8755 13387 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 13388 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 13389 *
gume 0:1f82672b8755 13390 * @note While enabling the gyro anymotion interrupt
gume 0:1f82672b8755 13391 * configure the following settings
gume 0:1f82672b8755 13392 *
gume 0:1f82672b8755 13393 * Axis:
gume 0:1f82672b8755 13394 * bno055_set_gyro_any_motion_axis_enable()
gume 0:1f82672b8755 13395 *
gume 0:1f82672b8755 13396 * Filter setting:
gume 0:1f82672b8755 13397 * bno055_set_gyro_any_motion_filter()
gume 0:1f82672b8755 13398 *
gume 0:1f82672b8755 13399 * Threshold :
gume 0:1f82672b8755 13400 *
gume 0:1f82672b8755 13401 * bno055_set_gyro_any_motion_thres()
gume 0:1f82672b8755 13402 *
gume 0:1f82672b8755 13403 * Slope samples :
gume 0:1f82672b8755 13404 *
gume 0:1f82672b8755 13405 * bno055_set_gyro_any_motion_slope_samples()
gume 0:1f82672b8755 13406 *
gume 0:1f82672b8755 13407 * Awake duration :
gume 0:1f82672b8755 13408 *
gume 0:1f82672b8755 13409 * bno055_set_gyro_any_motion_awake_durn()
gume 0:1f82672b8755 13410 */
gume 0:1f82672b8755 13411 BNO055_RETURN_FUNCTION_TYPE bno055_get_intr_gyro_any_motion(
gume 0:1f82672b8755 13412 u8 *gyro_any_motion_u8)
gume 0:1f82672b8755 13413 {
gume 0:1f82672b8755 13414 /* Variable used to return value of
gume 0:1f82672b8755 13415 communication routine*/
gume 0:1f82672b8755 13416 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13417 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 13418 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 13419 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 13420 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 13421 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 13422 } else {
gume 0:1f82672b8755 13423 /*condition check for page, gyro anymotion interrupt is
gume 0:1f82672b8755 13424 available in the page one*/
gume 0:1f82672b8755 13425 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 13426 /* Write page as one */
gume 0:1f82672b8755 13427 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 13428 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 13429 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 13430 /* Read the value of gyro anymotion interrupt */
gume 0:1f82672b8755 13431 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 13432 (p_bno055->dev_addr,
gume 0:1f82672b8755 13433 BNO055_GYRO_ANY_MOTION_INTR_REG,
gume 0:1f82672b8755 13434 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 13435 *gyro_any_motion_u8 =
gume 0:1f82672b8755 13436 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 13437 BNO055_GYRO_ANY_MOTION_INTR);
gume 0:1f82672b8755 13438 } else {
gume 0:1f82672b8755 13439 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13440 }
gume 0:1f82672b8755 13441 }
gume 0:1f82672b8755 13442 return com_rslt;
gume 0:1f82672b8755 13443 }
gume 0:1f82672b8755 13444 /*!
gume 0:1f82672b8755 13445 * @brief This API used to write the gyro anymotion interrupt
gume 0:1f82672b8755 13446 * from page one register from 0x10 bit 2
gume 0:1f82672b8755 13447 *
gume 0:1f82672b8755 13448 * @param gyro_any_motion_u8 : The value of gyro anymotion interrupt
gume 0:1f82672b8755 13449 * gyro_any_motion_u8 | result
gume 0:1f82672b8755 13450 * -------------------- |------------
gume 0:1f82672b8755 13451 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 13452 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 13453 *
gume 0:1f82672b8755 13454 * @return results of bus communication function
gume 0:1f82672b8755 13455 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 13456 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 13457 *
gume 0:1f82672b8755 13458 * @note While enabling the gyro anymotion interrupt
gume 0:1f82672b8755 13459 * configure the following settings
gume 0:1f82672b8755 13460 *
gume 0:1f82672b8755 13461 * Axis:
gume 0:1f82672b8755 13462 * bno055_set_gyro_any_motion_axis_enable()
gume 0:1f82672b8755 13463 *
gume 0:1f82672b8755 13464 * Filter setting:
gume 0:1f82672b8755 13465 * bno055_set_gyro_any_motion_filter()
gume 0:1f82672b8755 13466 *
gume 0:1f82672b8755 13467 * Threshold :
gume 0:1f82672b8755 13468 *
gume 0:1f82672b8755 13469 * bno055_set_gyro_any_motion_thres()
gume 0:1f82672b8755 13470 *
gume 0:1f82672b8755 13471 * Slope samples :
gume 0:1f82672b8755 13472 *
gume 0:1f82672b8755 13473 * bno055_set_gyro_any_motion_slope_samples()
gume 0:1f82672b8755 13474 *
gume 0:1f82672b8755 13475 * Awake duration :
gume 0:1f82672b8755 13476 *
gume 0:1f82672b8755 13477 * bno055_set_gyro_any_motion_awake_durn()
gume 0:1f82672b8755 13478 */
gume 0:1f82672b8755 13479 BNO055_RETURN_FUNCTION_TYPE bno055_set_intr_gyro_any_motion(
gume 0:1f82672b8755 13480 u8 gyro_any_motion_u8)
gume 0:1f82672b8755 13481 {
gume 0:1f82672b8755 13482 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13483 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 13484 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 13485 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 13486 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 13487 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 13488 } else {
gume 0:1f82672b8755 13489 /*condition check for page, gyro anymotion interrupt is
gume 0:1f82672b8755 13490 available in the page one*/
gume 0:1f82672b8755 13491 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 13492 /* Write page as one */
gume 0:1f82672b8755 13493 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 13494 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 13495 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 13496 /* Write the value of gyro anymotion interrupt */
gume 0:1f82672b8755 13497 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 13498 (p_bno055->dev_addr,
gume 0:1f82672b8755 13499 BNO055_GYRO_ANY_MOTION_INTR_REG,
gume 0:1f82672b8755 13500 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 13501 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 13502 data_u8r =
gume 0:1f82672b8755 13503 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 13504 BNO055_GYRO_ANY_MOTION_INTR,
gume 0:1f82672b8755 13505 gyro_any_motion_u8);
gume 0:1f82672b8755 13506 com_rslt +=
gume 0:1f82672b8755 13507 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 13508 (p_bno055->dev_addr,
gume 0:1f82672b8755 13509 BNO055_GYRO_ANY_MOTION_INTR_REG,
gume 0:1f82672b8755 13510 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 13511 }
gume 0:1f82672b8755 13512 } else {
gume 0:1f82672b8755 13513 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13514 }
gume 0:1f82672b8755 13515 }
gume 0:1f82672b8755 13516 return com_rslt;
gume 0:1f82672b8755 13517 }
gume 0:1f82672b8755 13518 /*!
gume 0:1f82672b8755 13519 * @brief This API used to read the gyro highrate interrupt
gume 0:1f82672b8755 13520 * from page one register from 0x10 bit 3
gume 0:1f82672b8755 13521 *
gume 0:1f82672b8755 13522 * @param gyro_highrate_u8 : The value of gyro highrate interrupt
gume 0:1f82672b8755 13523 * gyro_highrate_u8 | result
gume 0:1f82672b8755 13524 * -------------------- |------------
gume 0:1f82672b8755 13525 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 13526 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 13527 *
gume 0:1f82672b8755 13528 * @return results of bus communication function
gume 0:1f82672b8755 13529 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 13530 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 13531 *
gume 0:1f82672b8755 13532 * @note While enabling the gyro highrate interrupt
gume 0:1f82672b8755 13533 * configure the below settings by using
gume 0:1f82672b8755 13534 * the following APIs
gume 0:1f82672b8755 13535 *
gume 0:1f82672b8755 13536 * Axis :
gume 0:1f82672b8755 13537 *
gume 0:1f82672b8755 13538 * bno055_set_gyro_highrate_axis_enable()
gume 0:1f82672b8755 13539 *
gume 0:1f82672b8755 13540 * Filter :
gume 0:1f82672b8755 13541 *
gume 0:1f82672b8755 13542 * bno055_set_gyro_highrate_filter()
gume 0:1f82672b8755 13543 *
gume 0:1f82672b8755 13544 * Threshold :
gume 0:1f82672b8755 13545 *
gume 0:1f82672b8755 13546 * bno055_get_gyro_highrate_x_thres()
gume 0:1f82672b8755 13547 *
gume 0:1f82672b8755 13548 * bno055_get_gyro_highrate_y_thres()
gume 0:1f82672b8755 13549 *
gume 0:1f82672b8755 13550 * bno055_get_gyro_highrate_z_thres()
gume 0:1f82672b8755 13551 *
gume 0:1f82672b8755 13552 * Hysteresis :
gume 0:1f82672b8755 13553 *
gume 0:1f82672b8755 13554 * bno055_set_gyro_highrate_x_hyst()
gume 0:1f82672b8755 13555 *
gume 0:1f82672b8755 13556 * bno055_set_gyro_highrate_y_hyst()
gume 0:1f82672b8755 13557 *
gume 0:1f82672b8755 13558 * bno055_set_gyro_highrate_z_hyst()
gume 0:1f82672b8755 13559 *
gume 0:1f82672b8755 13560 * Duration :
gume 0:1f82672b8755 13561 *
gume 0:1f82672b8755 13562 * bno055_set_gyro_highrate_x_durn()
gume 0:1f82672b8755 13563 *
gume 0:1f82672b8755 13564 * bno055_set_gyro_highrate_y_durn()
gume 0:1f82672b8755 13565 *
gume 0:1f82672b8755 13566 * bno055_set_gyro_highrate_z_durn()
gume 0:1f82672b8755 13567 *
gume 0:1f82672b8755 13568 */
gume 0:1f82672b8755 13569 BNO055_RETURN_FUNCTION_TYPE bno055_get_intr_gyro_highrate(
gume 0:1f82672b8755 13570 u8 *gyro_highrate_u8)
gume 0:1f82672b8755 13571 {
gume 0:1f82672b8755 13572 /* Variable used to return value of
gume 0:1f82672b8755 13573 communication routine*/
gume 0:1f82672b8755 13574 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13575 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 13576 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 13577 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 13578 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 13579 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 13580 } else {
gume 0:1f82672b8755 13581 /*condition check for page, gyro highrate interrupt is
gume 0:1f82672b8755 13582 available in the page one*/
gume 0:1f82672b8755 13583 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 13584 /* Write page as one */
gume 0:1f82672b8755 13585 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 13586 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 13587 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 13588 /* Read the value of gyro highrate interrupt */
gume 0:1f82672b8755 13589 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 13590 (p_bno055->dev_addr,
gume 0:1f82672b8755 13591 BNO055_GYRO_HIGHRATE_INTR_REG,
gume 0:1f82672b8755 13592 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 13593 *gyro_highrate_u8 =
gume 0:1f82672b8755 13594 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 13595 BNO055_GYRO_HIGHRATE_INTR);
gume 0:1f82672b8755 13596 } else {
gume 0:1f82672b8755 13597 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13598 }
gume 0:1f82672b8755 13599 }
gume 0:1f82672b8755 13600 return com_rslt;
gume 0:1f82672b8755 13601 }
gume 0:1f82672b8755 13602 /*!
gume 0:1f82672b8755 13603 * @brief This API used to write the gyro highrate interrupt
gume 0:1f82672b8755 13604 * from page one register from 0x10 bit 3
gume 0:1f82672b8755 13605 *
gume 0:1f82672b8755 13606 * @param gyro_highrate_u8 : The value of gyro highrate interrupt
gume 0:1f82672b8755 13607 * gyro_highrate_u8 | result
gume 0:1f82672b8755 13608 * -------------------- |------------
gume 0:1f82672b8755 13609 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 13610 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 13611 *
gume 0:1f82672b8755 13612 * @return results of bus communication function
gume 0:1f82672b8755 13613 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 13614 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 13615 *
gume 0:1f82672b8755 13616 * @note While enabling the gyro highrate interrupt
gume 0:1f82672b8755 13617 * configure the below settings by using
gume 0:1f82672b8755 13618 * the following APIs
gume 0:1f82672b8755 13619 *
gume 0:1f82672b8755 13620 * Axis :
gume 0:1f82672b8755 13621 *
gume 0:1f82672b8755 13622 * bno055_set_gyro_highrate_axis_enable()
gume 0:1f82672b8755 13623 *
gume 0:1f82672b8755 13624 * Filter :
gume 0:1f82672b8755 13625 *
gume 0:1f82672b8755 13626 * bno055_set_gyro_highrate_filter()
gume 0:1f82672b8755 13627 *
gume 0:1f82672b8755 13628 * Threshold :
gume 0:1f82672b8755 13629 *
gume 0:1f82672b8755 13630 * bno055_get_gyro_highrate_x_thres()
gume 0:1f82672b8755 13631 *
gume 0:1f82672b8755 13632 * bno055_get_gyro_highrate_y_thres()
gume 0:1f82672b8755 13633 *
gume 0:1f82672b8755 13634 * bno055_get_gyro_highrate_z_thres()
gume 0:1f82672b8755 13635 *
gume 0:1f82672b8755 13636 * Hysteresis :
gume 0:1f82672b8755 13637 *
gume 0:1f82672b8755 13638 * bno055_set_gyro_highrate_x_hyst()
gume 0:1f82672b8755 13639 *
gume 0:1f82672b8755 13640 * bno055_set_gyro_highrate_y_hyst()
gume 0:1f82672b8755 13641 *
gume 0:1f82672b8755 13642 * bno055_set_gyro_highrate_z_hyst()
gume 0:1f82672b8755 13643 *
gume 0:1f82672b8755 13644 * Duration :
gume 0:1f82672b8755 13645 *
gume 0:1f82672b8755 13646 * bno055_set_gyro_highrate_x_durn()
gume 0:1f82672b8755 13647 *
gume 0:1f82672b8755 13648 * bno055_set_gyro_highrate_y_durn()
gume 0:1f82672b8755 13649 *
gume 0:1f82672b8755 13650 * bno055_set_gyro_highrate_z_durn()
gume 0:1f82672b8755 13651 *
gume 0:1f82672b8755 13652 */
gume 0:1f82672b8755 13653 BNO055_RETURN_FUNCTION_TYPE bno055_set_intr_gyro_highrate(
gume 0:1f82672b8755 13654 u8 gyro_highrate_u8)
gume 0:1f82672b8755 13655 {
gume 0:1f82672b8755 13656 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13657 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 13658 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 13659 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 13660 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 13661 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 13662 } else {
gume 0:1f82672b8755 13663 /*condition check for page, gyro highrate interrupt is
gume 0:1f82672b8755 13664 available in the page one*/
gume 0:1f82672b8755 13665 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 13666 /* Write page as one */
gume 0:1f82672b8755 13667 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 13668 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 13669 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 13670 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 13671 (p_bno055->dev_addr,
gume 0:1f82672b8755 13672 BNO055_GYRO_HIGHRATE_INTR_REG,
gume 0:1f82672b8755 13673 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 13674 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 13675 /* Write the value of gyro highrate interrupt */
gume 0:1f82672b8755 13676 data_u8r =
gume 0:1f82672b8755 13677 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 13678 BNO055_GYRO_HIGHRATE_INTR, gyro_highrate_u8);
gume 0:1f82672b8755 13679 com_rslt +=
gume 0:1f82672b8755 13680 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 13681 (p_bno055->dev_addr,
gume 0:1f82672b8755 13682 BNO055_GYRO_HIGHRATE_INTR_REG,
gume 0:1f82672b8755 13683 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 13684 }
gume 0:1f82672b8755 13685 } else {
gume 0:1f82672b8755 13686 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13687 }
gume 0:1f82672b8755 13688 }
gume 0:1f82672b8755 13689 return com_rslt;
gume 0:1f82672b8755 13690 }
gume 0:1f82672b8755 13691 /*!
gume 0:1f82672b8755 13692 * @brief This API used to read the accel highg interrupt
gume 0:1f82672b8755 13693 * from page one register from 0x10 bit 5
gume 0:1f82672b8755 13694 *
gume 0:1f82672b8755 13695 * @param accel_high_g_u8 : The value of accel highg interrupt
gume 0:1f82672b8755 13696 * accel_high_g_u8 | result
gume 0:1f82672b8755 13697 * -------------------- |------------
gume 0:1f82672b8755 13698 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 13699 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 13700 *
gume 0:1f82672b8755 13701 * @return results of bus communication function
gume 0:1f82672b8755 13702 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 13703 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 13704 *
gume 0:1f82672b8755 13705 * @note While enabling the accel highg interrupt
gume 0:1f82672b8755 13706 * configure the below settings by using
gume 0:1f82672b8755 13707 * the following APIs
gume 0:1f82672b8755 13708 *
gume 0:1f82672b8755 13709 * Axis :
gume 0:1f82672b8755 13710 *
gume 0:1f82672b8755 13711 * bno055_set_accel_high_g_axis_enable()
gume 0:1f82672b8755 13712 *
gume 0:1f82672b8755 13713 * Threshold :
gume 0:1f82672b8755 13714 *
gume 0:1f82672b8755 13715 * bno055_set_accel_high_g_thres()
gume 0:1f82672b8755 13716 *
gume 0:1f82672b8755 13717 * Duration :
gume 0:1f82672b8755 13718 *
gume 0:1f82672b8755 13719 * bno055_set_accel_high_g_durn()
gume 0:1f82672b8755 13720 *
gume 0:1f82672b8755 13721 */
gume 0:1f82672b8755 13722 BNO055_RETURN_FUNCTION_TYPE bno055_get_intr_accel_high_g(
gume 0:1f82672b8755 13723 u8 *accel_high_g_u8)
gume 0:1f82672b8755 13724 {
gume 0:1f82672b8755 13725 /* Variable used to return value of
gume 0:1f82672b8755 13726 communication routine*/
gume 0:1f82672b8755 13727 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13728 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 13729 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 13730 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 13731 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 13732 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 13733 } else {
gume 0:1f82672b8755 13734 /*condition check for page, accel highg interrupt is
gume 0:1f82672b8755 13735 available in the page one*/
gume 0:1f82672b8755 13736 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 13737 /* Write page as one */
gume 0:1f82672b8755 13738 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 13739 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 13740 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 13741 /* Read the value of accel highg interrupt*/
gume 0:1f82672b8755 13742 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 13743 (p_bno055->dev_addr,
gume 0:1f82672b8755 13744 BNO055_ACCEL_HIGH_G_INTR_REG,
gume 0:1f82672b8755 13745 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 13746 *accel_high_g_u8 =
gume 0:1f82672b8755 13747 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 13748 BNO055_ACCEL_HIGH_G_INTR);
gume 0:1f82672b8755 13749 } else {
gume 0:1f82672b8755 13750 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13751 }
gume 0:1f82672b8755 13752 }
gume 0:1f82672b8755 13753 return com_rslt;
gume 0:1f82672b8755 13754 }
gume 0:1f82672b8755 13755 /*!
gume 0:1f82672b8755 13756 * @brief This API used to write the accel highg interrupt
gume 0:1f82672b8755 13757 * from page one register from 0x10 bit 5
gume 0:1f82672b8755 13758 *
gume 0:1f82672b8755 13759 * @param accel_high_g_u8 : The value of accel highg interrupt
gume 0:1f82672b8755 13760 * accel_high_g_u8 | result
gume 0:1f82672b8755 13761 * -------------------- |------------
gume 0:1f82672b8755 13762 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 13763 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 13764 *
gume 0:1f82672b8755 13765 * @return results of bus communication function
gume 0:1f82672b8755 13766 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 13767 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 13768 *
gume 0:1f82672b8755 13769 * @note While enabling the accel highg interrupt
gume 0:1f82672b8755 13770 * configure the below settings by using
gume 0:1f82672b8755 13771 * the following APIs
gume 0:1f82672b8755 13772 *
gume 0:1f82672b8755 13773 * Axis :
gume 0:1f82672b8755 13774 *
gume 0:1f82672b8755 13775 * bno055_set_accel_high_g_axis_enable()
gume 0:1f82672b8755 13776 *
gume 0:1f82672b8755 13777 * Threshold :
gume 0:1f82672b8755 13778 *
gume 0:1f82672b8755 13779 * bno055_set_accel_high_g_thres()
gume 0:1f82672b8755 13780 *
gume 0:1f82672b8755 13781 * Duration :
gume 0:1f82672b8755 13782 *
gume 0:1f82672b8755 13783 * bno055_set_accel_high_g_durn()
gume 0:1f82672b8755 13784 *
gume 0:1f82672b8755 13785 */
gume 0:1f82672b8755 13786 BNO055_RETURN_FUNCTION_TYPE bno055_set_intr_accel_high_g(
gume 0:1f82672b8755 13787 u8 accel_high_g_u8)
gume 0:1f82672b8755 13788 {
gume 0:1f82672b8755 13789 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13790 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 13791 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 13792 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 13793 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 13794 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 13795 } else {
gume 0:1f82672b8755 13796 /*condition check for page, accel highg interrupt is
gume 0:1f82672b8755 13797 available in the page one*/
gume 0:1f82672b8755 13798 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 13799 /* Write page as one */
gume 0:1f82672b8755 13800 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 13801 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 13802 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 13803 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 13804 (p_bno055->dev_addr,
gume 0:1f82672b8755 13805 BNO055_ACCEL_HIGH_G_INTR_REG,
gume 0:1f82672b8755 13806 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 13807 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 13808 /* Write the value of accel highg interrupt*/
gume 0:1f82672b8755 13809 data_u8r =
gume 0:1f82672b8755 13810 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 13811 BNO055_ACCEL_HIGH_G_INTR,
gume 0:1f82672b8755 13812 accel_high_g_u8);
gume 0:1f82672b8755 13813 com_rslt +=
gume 0:1f82672b8755 13814 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 13815 (p_bno055->dev_addr,
gume 0:1f82672b8755 13816 BNO055_ACCEL_HIGH_G_INTR_REG,
gume 0:1f82672b8755 13817 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 13818 }
gume 0:1f82672b8755 13819 } else {
gume 0:1f82672b8755 13820 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13821 }
gume 0:1f82672b8755 13822 }
gume 0:1f82672b8755 13823 return com_rslt;
gume 0:1f82672b8755 13824 }
gume 0:1f82672b8755 13825 /*!
gume 0:1f82672b8755 13826 * @brief This API used to read the accel anymotion interrupt
gume 0:1f82672b8755 13827 * from page one register from 0x10 bit 6
gume 0:1f82672b8755 13828 *
gume 0:1f82672b8755 13829 * @param accel_any_motion_u8 : The value of accel anymotion interrupt
gume 0:1f82672b8755 13830 * accel_any_motion_u8 | result
gume 0:1f82672b8755 13831 * -------------------- |------------
gume 0:1f82672b8755 13832 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 13833 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 13834 *
gume 0:1f82672b8755 13835 * @return results of bus communication function
gume 0:1f82672b8755 13836 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 13837 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 13838 *
gume 0:1f82672b8755 13839 * @note While enabling the accel anymotion interrupt
gume 0:1f82672b8755 13840 * configure the following settings
gume 0:1f82672b8755 13841 *
gume 0:1f82672b8755 13842 * Axis:
gume 0:1f82672b8755 13843 *
gume 0:1f82672b8755 13844 * bno055_set_accel_any_motion_no_motion_axis_enable()
gume 0:1f82672b8755 13845 *
gume 0:1f82672b8755 13846 * Duration:
gume 0:1f82672b8755 13847 *
gume 0:1f82672b8755 13848 * bno055_set_accel_any_motion_durn()
gume 0:1f82672b8755 13849 *
gume 0:1f82672b8755 13850 * Threshold:
gume 0:1f82672b8755 13851 *
gume 0:1f82672b8755 13852 * bno055_set_accel_any_motion_thres()
gume 0:1f82672b8755 13853 *
gume 0:1f82672b8755 13854 */
gume 0:1f82672b8755 13855 BNO055_RETURN_FUNCTION_TYPE bno055_get_intr_accel_any_motion(
gume 0:1f82672b8755 13856 u8 *accel_any_motion_u8)
gume 0:1f82672b8755 13857 {
gume 0:1f82672b8755 13858 /* Variable used to return value of
gume 0:1f82672b8755 13859 communication routine*/
gume 0:1f82672b8755 13860 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13861 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 13862 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 13863 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 13864 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 13865 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 13866 } else {
gume 0:1f82672b8755 13867 /*condition check for page, accel anymotion interrupt is
gume 0:1f82672b8755 13868 available in the page one*/
gume 0:1f82672b8755 13869 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 13870 /* Write page as one */
gume 0:1f82672b8755 13871 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 13872 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 13873 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 13874 /* Read the value of accel anymotion interrupt */
gume 0:1f82672b8755 13875 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 13876 (p_bno055->dev_addr,
gume 0:1f82672b8755 13877 BNO055_ACCEL_ANY_MOTION_INTR_REG,
gume 0:1f82672b8755 13878 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 13879 *accel_any_motion_u8 =
gume 0:1f82672b8755 13880 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 13881 BNO055_ACCEL_ANY_MOTION_INTR);
gume 0:1f82672b8755 13882 } else {
gume 0:1f82672b8755 13883 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13884 }
gume 0:1f82672b8755 13885 }
gume 0:1f82672b8755 13886 return com_rslt;
gume 0:1f82672b8755 13887 }
gume 0:1f82672b8755 13888 /*!
gume 0:1f82672b8755 13889 * @brief This API used to write the accel anymotion interrupt
gume 0:1f82672b8755 13890 * from page one register from 0x10 bit 6
gume 0:1f82672b8755 13891 *
gume 0:1f82672b8755 13892 * @param accel_any_motion_u8 : The value of accel anymotion interrupt
gume 0:1f82672b8755 13893 * accel_any_motion_u8 | result
gume 0:1f82672b8755 13894 * -------------------- |------------
gume 0:1f82672b8755 13895 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 13896 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 13897 *
gume 0:1f82672b8755 13898 * @return results of bus communication function
gume 0:1f82672b8755 13899 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 13900 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 13901 *
gume 0:1f82672b8755 13902 * @note While enabling the accel anymotion interrupt
gume 0:1f82672b8755 13903 * configure the following settings
gume 0:1f82672b8755 13904 *
gume 0:1f82672b8755 13905 * Axis:
gume 0:1f82672b8755 13906 *
gume 0:1f82672b8755 13907 * bno055_set_accel_any_motion_no_motion_axis_enable()
gume 0:1f82672b8755 13908 *
gume 0:1f82672b8755 13909 * Duration:
gume 0:1f82672b8755 13910 *
gume 0:1f82672b8755 13911 * bno055_set_accel_any_motion_durn()
gume 0:1f82672b8755 13912 *
gume 0:1f82672b8755 13913 * Threshold:
gume 0:1f82672b8755 13914 *
gume 0:1f82672b8755 13915 * bno055_set_accel_any_motion_thres()
gume 0:1f82672b8755 13916 *
gume 0:1f82672b8755 13917 */
gume 0:1f82672b8755 13918 BNO055_RETURN_FUNCTION_TYPE bno055_set_intr_accel_any_motion(
gume 0:1f82672b8755 13919 u8 accel_any_motion_u8)
gume 0:1f82672b8755 13920 {
gume 0:1f82672b8755 13921 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13922 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 13923 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 13924 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 13925 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 13926 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 13927 } else {
gume 0:1f82672b8755 13928 /*condition check for page, accel range is
gume 0:1f82672b8755 13929 available in the page one*/
gume 0:1f82672b8755 13930 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 13931 /* Write page as one */
gume 0:1f82672b8755 13932 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 13933 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 13934 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 13935 /* Write the value of accel anymotion interrupt */
gume 0:1f82672b8755 13936 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 13937 (p_bno055->dev_addr,
gume 0:1f82672b8755 13938 BNO055_ACCEL_ANY_MOTION_INTR_REG,
gume 0:1f82672b8755 13939 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 13940 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 13941 data_u8r =
gume 0:1f82672b8755 13942 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 13943 BNO055_ACCEL_ANY_MOTION_INTR,
gume 0:1f82672b8755 13944 accel_any_motion_u8);
gume 0:1f82672b8755 13945 com_rslt +=
gume 0:1f82672b8755 13946 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 13947 (p_bno055->dev_addr,
gume 0:1f82672b8755 13948 BNO055_ACCEL_ANY_MOTION_INTR_REG,
gume 0:1f82672b8755 13949 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 13950 }
gume 0:1f82672b8755 13951 } else {
gume 0:1f82672b8755 13952 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13953 }
gume 0:1f82672b8755 13954 }
gume 0:1f82672b8755 13955 return com_rslt;
gume 0:1f82672b8755 13956 }
gume 0:1f82672b8755 13957 /*!
gume 0:1f82672b8755 13958 * @brief This API used to read the accel nomotion interrupt
gume 0:1f82672b8755 13959 * from page one register from 0x10 bit 6
gume 0:1f82672b8755 13960 *
gume 0:1f82672b8755 13961 * @param accel_nomotion_u8 : The value of accel nomotion interrupt
gume 0:1f82672b8755 13962 * accel_nomotion_u8 | result
gume 0:1f82672b8755 13963 * -------------------- |------------
gume 0:1f82672b8755 13964 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 13965 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 13966 *
gume 0:1f82672b8755 13967 * @return results of bus communication function
gume 0:1f82672b8755 13968 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 13969 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 13970 *
gume 0:1f82672b8755 13971 * @note While enabling the accel nomotion interrupt
gume 0:1f82672b8755 13972 * configure the following settings
gume 0:1f82672b8755 13973 *
gume 0:1f82672b8755 13974 * Axis:
gume 0:1f82672b8755 13975 *
gume 0:1f82672b8755 13976 * bno055_set_accel_any_motion_no_motion_axis_enable()
gume 0:1f82672b8755 13977 *
gume 0:1f82672b8755 13978 * Threshold :
gume 0:1f82672b8755 13979 *
gume 0:1f82672b8755 13980 * bno055_set_accel_slow_no_motion_thres()
gume 0:1f82672b8755 13981 *
gume 0:1f82672b8755 13982 * Duration :
gume 0:1f82672b8755 13983 *
gume 0:1f82672b8755 13984 * bno055_set_accel_slow_no_motion_durn()
gume 0:1f82672b8755 13985 *
gume 0:1f82672b8755 13986 * Slow/no motion enable:
gume 0:1f82672b8755 13987 *
gume 0:1f82672b8755 13988 * bno055_set_accel_slow_no_motion_enable()
gume 0:1f82672b8755 13989 *
gume 0:1f82672b8755 13990 */
gume 0:1f82672b8755 13991 BNO055_RETURN_FUNCTION_TYPE bno055_get_intr_accel_no_motion(
gume 0:1f82672b8755 13992 u8 *accel_nomotion_u8)
gume 0:1f82672b8755 13993 {
gume 0:1f82672b8755 13994 /* Variable used to return value of
gume 0:1f82672b8755 13995 communication routine*/
gume 0:1f82672b8755 13996 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 13997 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 13998 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 13999 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 14000 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 14001 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 14002 } else {
gume 0:1f82672b8755 14003 /*condition check for page, accel nomotion interrupt is
gume 0:1f82672b8755 14004 available in the page one*/
gume 0:1f82672b8755 14005 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 14006 /* Write page as one */
gume 0:1f82672b8755 14007 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 14008 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 14009 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 14010 /* Read the value of accel nomotion interrupt*/
gume 0:1f82672b8755 14011 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 14012 (p_bno055->dev_addr,
gume 0:1f82672b8755 14013 BNO055_ACCEL_NO_MOTION_INTR_REG,
gume 0:1f82672b8755 14014 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14015 *accel_nomotion_u8 =
gume 0:1f82672b8755 14016 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 14017 BNO055_ACCEL_NO_MOTION_INTR);
gume 0:1f82672b8755 14018 } else {
gume 0:1f82672b8755 14019 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14020 }
gume 0:1f82672b8755 14021 }
gume 0:1f82672b8755 14022 return com_rslt;
gume 0:1f82672b8755 14023 }
gume 0:1f82672b8755 14024 /*!
gume 0:1f82672b8755 14025 * @brief This API used to write the accel nomotion interrupt
gume 0:1f82672b8755 14026 * from page one register from 0x10 bit 6
gume 0:1f82672b8755 14027 *
gume 0:1f82672b8755 14028 * @param accel_nomotion_u8 : The value of accel nomotion interrupt
gume 0:1f82672b8755 14029 * accel_nomotion_u8 | result
gume 0:1f82672b8755 14030 * -------------------- |------------
gume 0:1f82672b8755 14031 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 14032 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 14033 *
gume 0:1f82672b8755 14034 * @return results of bus communication function
gume 0:1f82672b8755 14035 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 14036 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 14037 *
gume 0:1f82672b8755 14038 * @note While enabling the accel nomotion interrupt
gume 0:1f82672b8755 14039 * configure the following settings
gume 0:1f82672b8755 14040 *
gume 0:1f82672b8755 14041 * Axis:
gume 0:1f82672b8755 14042 *
gume 0:1f82672b8755 14043 * bno055_set_accel_any_motion_no_motion_axis_enable()
gume 0:1f82672b8755 14044 *
gume 0:1f82672b8755 14045 * Threshold :
gume 0:1f82672b8755 14046 *
gume 0:1f82672b8755 14047 * bno055_set_accel_slow_no_motion_thres()
gume 0:1f82672b8755 14048 *
gume 0:1f82672b8755 14049 * Duration :
gume 0:1f82672b8755 14050 *
gume 0:1f82672b8755 14051 * bno055_set_accel_slow_no_motion_durn()
gume 0:1f82672b8755 14052 *
gume 0:1f82672b8755 14053 * Slow/no motion enable:
gume 0:1f82672b8755 14054 *
gume 0:1f82672b8755 14055 * bno055_set_accel_slow_no_motion_enable()
gume 0:1f82672b8755 14056 *
gume 0:1f82672b8755 14057 */
gume 0:1f82672b8755 14058 BNO055_RETURN_FUNCTION_TYPE bno055_set_intr_accel_no_motion(
gume 0:1f82672b8755 14059 u8 accel_nomotion_u8)
gume 0:1f82672b8755 14060 {
gume 0:1f82672b8755 14061 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14062 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 14063 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 14064 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 14065 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 14066 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 14067 } else {
gume 0:1f82672b8755 14068 /*condition check for page,
gume 0:1f82672b8755 14069 accel nomotion interrupt is
gume 0:1f82672b8755 14070 available in the page one*/
gume 0:1f82672b8755 14071 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 14072 /* Write page as one */
gume 0:1f82672b8755 14073 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 14074 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 14075 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 14076 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 14077 (p_bno055->dev_addr,
gume 0:1f82672b8755 14078 BNO055_ACCEL_NO_MOTION_INTR_REG,
gume 0:1f82672b8755 14079 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14080 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 14081 /* Write the value of
gume 0:1f82672b8755 14082 accel nomotion interrupt */
gume 0:1f82672b8755 14083 data_u8r = BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 14084 BNO055_ACCEL_NO_MOTION_INTR,
gume 0:1f82672b8755 14085 accel_nomotion_u8);
gume 0:1f82672b8755 14086 com_rslt += p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 14087 (p_bno055->dev_addr,
gume 0:1f82672b8755 14088 BNO055_ACCEL_NO_MOTION_INTR_REG,
gume 0:1f82672b8755 14089 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14090 }
gume 0:1f82672b8755 14091 } else {
gume 0:1f82672b8755 14092 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14093 }
gume 0:1f82672b8755 14094 }
gume 0:1f82672b8755 14095 return com_rslt;
gume 0:1f82672b8755 14096 }
gume 0:1f82672b8755 14097 /*!
gume 0:1f82672b8755 14098 * @brief This API used to read the accel any motion threshold
gume 0:1f82672b8755 14099 * from page one register from 0x11 bit 0 to 7
gume 0:1f82672b8755 14100 *
gume 0:1f82672b8755 14101 * @param accel_any_motion_thres_u8 : The value of any motion threshold
gume 0:1f82672b8755 14102 * accel_any_motion_thres_u8 | result
gume 0:1f82672b8755 14103 * ------------------------ | -------------
gume 0:1f82672b8755 14104 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 14105 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 14106 *
gume 0:1f82672b8755 14107 * @return results of bus communication function
gume 0:1f82672b8755 14108 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 14109 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 14110 *
gume 0:1f82672b8755 14111 * @note Accel anymotion threshold dependent on the
gume 0:1f82672b8755 14112 * range values
gume 0:1f82672b8755 14113 *
gume 0:1f82672b8755 14114 * accel_range_u8 | threshold | LSB
gume 0:1f82672b8755 14115 * ------------- | ------------- | ---------
gume 0:1f82672b8755 14116 * 2g | 3.19mg | 1LSB
gume 0:1f82672b8755 14117 * 4g | 7.81mg | 1LSB
gume 0:1f82672b8755 14118 * 8g | 15.63mg | 1LSB
gume 0:1f82672b8755 14119 * 16g | 31.25mg | 1LSB
gume 0:1f82672b8755 14120 *
gume 0:1f82672b8755 14121 */
gume 0:1f82672b8755 14122 BNO055_RETURN_FUNCTION_TYPE bno055_get_accel_any_motion_thres(
gume 0:1f82672b8755 14123 u8 *accel_any_motion_thres_u8)
gume 0:1f82672b8755 14124 {
gume 0:1f82672b8755 14125 /* Variable used to return value of
gume 0:1f82672b8755 14126 communication routine*/
gume 0:1f82672b8755 14127 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14128 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 14129 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 14130 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 14131 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 14132 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 14133 } else {
gume 0:1f82672b8755 14134 /*condition check for page, accel any motion threshold is
gume 0:1f82672b8755 14135 available in the page one*/
gume 0:1f82672b8755 14136 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 14137 /* Write page as one */
gume 0:1f82672b8755 14138 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 14139 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 14140 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 14141 /* Read the value of accel any motion threshold */
gume 0:1f82672b8755 14142 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 14143 (p_bno055->dev_addr,
gume 0:1f82672b8755 14144 BNO055_ACCEL_ANY_MOTION_THRES_REG,
gume 0:1f82672b8755 14145 &data_u8r,
gume 0:1f82672b8755 14146 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14147 *accel_any_motion_thres_u8 =
gume 0:1f82672b8755 14148 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 14149 BNO055_ACCEL_ANY_MOTION_THRES);
gume 0:1f82672b8755 14150 } else {
gume 0:1f82672b8755 14151 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14152 }
gume 0:1f82672b8755 14153 }
gume 0:1f82672b8755 14154 return com_rslt;
gume 0:1f82672b8755 14155 }
gume 0:1f82672b8755 14156 /*!
gume 0:1f82672b8755 14157 * @brief This API used to write the accel any motion threshold
gume 0:1f82672b8755 14158 * from page one register from 0x11 bit 0 to 7
gume 0:1f82672b8755 14159 *
gume 0:1f82672b8755 14160 * @param accel_any_motion_thres_u8 : The value of any motion threshold
gume 0:1f82672b8755 14161 * accel_any_motion_thres_u8 | result
gume 0:1f82672b8755 14162 * ------------------------ | -------------
gume 0:1f82672b8755 14163 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 14164 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 14165 *
gume 0:1f82672b8755 14166 * @return results of bus communication function
gume 0:1f82672b8755 14167 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 14168 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 14169 *
gume 0:1f82672b8755 14170 * @note Accel anymotion threshold dependent on the
gume 0:1f82672b8755 14171 * range values
gume 0:1f82672b8755 14172 *
gume 0:1f82672b8755 14173 * accel_range_u8 | threshold | LSB
gume 0:1f82672b8755 14174 * ------------- | ------------- | ---------
gume 0:1f82672b8755 14175 * 2g | 3.19mg | 1LSB
gume 0:1f82672b8755 14176 * 4g | 7.81mg | 1LSB
gume 0:1f82672b8755 14177 * 8g | 15.63mg | 1LSB
gume 0:1f82672b8755 14178 * 16g | 31.25mg | 1LSB
gume 0:1f82672b8755 14179 *
gume 0:1f82672b8755 14180 */
gume 0:1f82672b8755 14181 BNO055_RETURN_FUNCTION_TYPE bno055_set_accel_any_motion_thres(
gume 0:1f82672b8755 14182 u8 accel_any_motion_thres_u8)
gume 0:1f82672b8755 14183 {
gume 0:1f82672b8755 14184 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14185 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 14186 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 14187 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 14188 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 14189 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 14190 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 14191 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 14192 } else {
gume 0:1f82672b8755 14193 /* The write operation effective only if the operation
gume 0:1f82672b8755 14194 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 14195 current operation mode and set the config mode */
gume 0:1f82672b8755 14196 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 14197 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 14198 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 14199 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 14200 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 14201 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 14202 /* Write page as one */
gume 0:1f82672b8755 14203 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 14204 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 14205 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 14206 (p_bno055->dev_addr,
gume 0:1f82672b8755 14207 BNO055_ACCEL_ANY_MOTION_THRES_REG,
gume 0:1f82672b8755 14208 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14209 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 14210 /* Write the value of
gume 0:1f82672b8755 14211 accel any motion threshold*/
gume 0:1f82672b8755 14212 data_u8r =
gume 0:1f82672b8755 14213 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 14214 BNO055_ACCEL_ANY_MOTION_THRES,
gume 0:1f82672b8755 14215 accel_any_motion_thres_u8);
gume 0:1f82672b8755 14216 com_rslt +=
gume 0:1f82672b8755 14217 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 14218 (p_bno055->dev_addr,
gume 0:1f82672b8755 14219 BNO055_ACCEL_ANY_MOTION_THRES_REG,
gume 0:1f82672b8755 14220 &data_u8r,
gume 0:1f82672b8755 14221 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14222 }
gume 0:1f82672b8755 14223 } else {
gume 0:1f82672b8755 14224 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14225 }
gume 0:1f82672b8755 14226 } else {
gume 0:1f82672b8755 14227 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14228 }
gume 0:1f82672b8755 14229 } else {
gume 0:1f82672b8755 14230 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14231 }
gume 0:1f82672b8755 14232 }
gume 0:1f82672b8755 14233 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 14234 /* set the operation mode of
gume 0:1f82672b8755 14235 previous operation mode*/
gume 0:1f82672b8755 14236 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 14237 (prev_opmode_u8);
gume 0:1f82672b8755 14238 return com_rslt;
gume 0:1f82672b8755 14239 }
gume 0:1f82672b8755 14240 /*!
gume 0:1f82672b8755 14241 * @brief This API used to read the accel anymotion duration
gume 0:1f82672b8755 14242 * from page one register from 0x12 bit 0 to 1
gume 0:1f82672b8755 14243 *
gume 0:1f82672b8755 14244 * @param accel_any_motion_durn_u8 : The value of accel anymotion duration
gume 0:1f82672b8755 14245 * accel_any_motion_durn_u8 | result
gume 0:1f82672b8755 14246 * ------------------------- | -------------
gume 0:1f82672b8755 14247 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 14248 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 14249 *
gume 0:1f82672b8755 14250 * @return results of bus communication function
gume 0:1f82672b8755 14251 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 14252 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 14253 *
gume 0:1f82672b8755 14254 *
gume 0:1f82672b8755 14255 */
gume 0:1f82672b8755 14256 BNO055_RETURN_FUNCTION_TYPE bno055_get_accel_any_motion_durn(
gume 0:1f82672b8755 14257 u8 *accel_any_motion_durn_u8)
gume 0:1f82672b8755 14258 {
gume 0:1f82672b8755 14259 /* Variable used to return value of
gume 0:1f82672b8755 14260 communication routine*/
gume 0:1f82672b8755 14261 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14262 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 14263 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 14264 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 14265 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 14266 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 14267 } else {
gume 0:1f82672b8755 14268 /*condition check for page, accel anymotion duration is
gume 0:1f82672b8755 14269 available in the page one*/
gume 0:1f82672b8755 14270 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 14271 /* Write page as one */
gume 0:1f82672b8755 14272 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 14273 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 14274 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 14275 /* Read the value of accel anymotion duration */
gume 0:1f82672b8755 14276 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 14277 (p_bno055->dev_addr,
gume 0:1f82672b8755 14278 BNO055_ACCEL_ANY_MOTION_DURN_SET_REG,
gume 0:1f82672b8755 14279 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14280 *accel_any_motion_durn_u8 =
gume 0:1f82672b8755 14281 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 14282 BNO055_ACCEL_ANY_MOTION_DURN_SET);
gume 0:1f82672b8755 14283 } else {
gume 0:1f82672b8755 14284 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14285 }
gume 0:1f82672b8755 14286 }
gume 0:1f82672b8755 14287 return com_rslt;
gume 0:1f82672b8755 14288 }
gume 0:1f82672b8755 14289 /*!
gume 0:1f82672b8755 14290 * @brief This API used to write the accel anymotion duration
gume 0:1f82672b8755 14291 * from page one register from 0x12 bit 0 to 1
gume 0:1f82672b8755 14292 *
gume 0:1f82672b8755 14293 * @param accel_any_motion_durn_u8 : The value of accel anymotion duration
gume 0:1f82672b8755 14294 *
gume 0:1f82672b8755 14295 * accel_any_motion_durn_u8 | result
gume 0:1f82672b8755 14296 * ------------------------- | -------------
gume 0:1f82672b8755 14297 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 14298 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 14299 *
gume 0:1f82672b8755 14300 * @return results of bus communication function
gume 0:1f82672b8755 14301 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 14302 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 14303 *
gume 0:1f82672b8755 14304 *
gume 0:1f82672b8755 14305 */
gume 0:1f82672b8755 14306 BNO055_RETURN_FUNCTION_TYPE bno055_set_accel_any_motion_durn(
gume 0:1f82672b8755 14307 u8 accel_any_motion_durn_u8)
gume 0:1f82672b8755 14308 {
gume 0:1f82672b8755 14309 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14310 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 14311 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 14312 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 14313 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 14314 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 14315 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 14316 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 14317 } else {
gume 0:1f82672b8755 14318 /* The write operation effective only if the operation
gume 0:1f82672b8755 14319 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 14320 current operation mode and set the config mode */
gume 0:1f82672b8755 14321 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 14322 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 14323 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 14324 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 14325 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 14326 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 14327 /* Write page as one */
gume 0:1f82672b8755 14328 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 14329 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 14330 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 14331 (p_bno055->dev_addr,
gume 0:1f82672b8755 14332 BNO055_ACCEL_ANY_MOTION_DURN_SET_REG,
gume 0:1f82672b8755 14333 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14334 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 14335 /* Write the value of
gume 0:1f82672b8755 14336 accel anymotion duration*/
gume 0:1f82672b8755 14337 data_u8r =
gume 0:1f82672b8755 14338 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 14339 BNO055_ACCEL_ANY_MOTION_DURN_SET,
gume 0:1f82672b8755 14340 accel_any_motion_durn_u8);
gume 0:1f82672b8755 14341 com_rslt +=
gume 0:1f82672b8755 14342 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 14343 (p_bno055->dev_addr,
gume 0:1f82672b8755 14344 BNO055_ACCEL_ANY_MOTION_DURN_SET_REG,
gume 0:1f82672b8755 14345 &data_u8r,
gume 0:1f82672b8755 14346 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14347 }
gume 0:1f82672b8755 14348 } else {
gume 0:1f82672b8755 14349 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14350 }
gume 0:1f82672b8755 14351 } else {
gume 0:1f82672b8755 14352 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14353 }
gume 0:1f82672b8755 14354 } else {
gume 0:1f82672b8755 14355 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14356 }
gume 0:1f82672b8755 14357 }
gume 0:1f82672b8755 14358 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 14359 /* set the operation mode of
gume 0:1f82672b8755 14360 previous operation mode*/
gume 0:1f82672b8755 14361 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 14362 (prev_opmode_u8);
gume 0:1f82672b8755 14363 return com_rslt;
gume 0:1f82672b8755 14364 }
gume 0:1f82672b8755 14365 /*!
gume 0:1f82672b8755 14366 * @brief This API used to read the accel anymotion enable
gume 0:1f82672b8755 14367 * from page one register from 0x12 bit 2 to 4
gume 0:1f82672b8755 14368 *
gume 0:1f82672b8755 14369 * @param data_u8 : The value of accel anymotion enable
gume 0:1f82672b8755 14370 * data_u8 | result
gume 0:1f82672b8755 14371 * ------------ | -------------
gume 0:1f82672b8755 14372 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 14373 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 14374 * @param channel_u8 : The value of accel anymotion axis selection
gume 0:1f82672b8755 14375 * channel_u8 | value
gume 0:1f82672b8755 14376 * -------------------------- | ----------
gume 0:1f82672b8755 14377 * BNO055_ACCEL_ANY_MOTION_NO_MOTION_X_AXIS | 0
gume 0:1f82672b8755 14378 * BNO055_ACCEL_ANY_MOTION_NO_MOTION_Y_AXIS | 1
gume 0:1f82672b8755 14379 * BNO055_ACCEL_ANY_MOTION_NO_MOTION_Y_AXIS | 2
gume 0:1f82672b8755 14380 *
gume 0:1f82672b8755 14381 * @return results of bus communication function
gume 0:1f82672b8755 14382 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 14383 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 14384 *
gume 0:1f82672b8755 14385 *
gume 0:1f82672b8755 14386 */
gume 0:1f82672b8755 14387 BNO055_RETURN_FUNCTION_TYPE bno055_get_accel_any_motion_no_motion_axis_enable(
gume 0:1f82672b8755 14388 u8 channel_u8, u8 *data_u8)
gume 0:1f82672b8755 14389 {
gume 0:1f82672b8755 14390 /* Variable used to return value of
gume 0:1f82672b8755 14391 communication routine*/
gume 0:1f82672b8755 14392 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14393 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 14394 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 14395 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 14396 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 14397 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 14398 } else {
gume 0:1f82672b8755 14399 /*condition check for page, accel anymotion enable is
gume 0:1f82672b8755 14400 available in the page one*/
gume 0:1f82672b8755 14401 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 14402 /* Write page as one */
gume 0:1f82672b8755 14403 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 14404 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 14405 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 14406 switch (channel_u8) {
gume 0:1f82672b8755 14407 case BNO055_ACCEL_ANY_MOTION_NO_MOTION_X_AXIS:
gume 0:1f82672b8755 14408 /* Read the value of accel anymotion x enable*/
gume 0:1f82672b8755 14409 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 14410 (p_bno055->dev_addr,
gume 0:1f82672b8755 14411 BNO055_ACCEL_ANY_MOTION_X_AXIS_REG,
gume 0:1f82672b8755 14412 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14413 *data_u8 =
gume 0:1f82672b8755 14414 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 14415 BNO055_ACCEL_ANY_MOTION_X_AXIS);
gume 0:1f82672b8755 14416 break;
gume 0:1f82672b8755 14417 case BNO055_ACCEL_ANY_MOTION_NO_MOTION_Y_AXIS:
gume 0:1f82672b8755 14418 /* Read the value of accel anymotion y enable*/
gume 0:1f82672b8755 14419 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 14420 (p_bno055->dev_addr,
gume 0:1f82672b8755 14421 BNO055_ACCEL_ANY_MOTION_Y_AXIS_REG,
gume 0:1f82672b8755 14422 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14423 *data_u8 =
gume 0:1f82672b8755 14424 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 14425 BNO055_ACCEL_ANY_MOTION_Y_AXIS);
gume 0:1f82672b8755 14426 break;
gume 0:1f82672b8755 14427 case BNO055_ACCEL_ANY_MOTION_NO_MOTION_Z_AXIS:
gume 0:1f82672b8755 14428 /* Read the value of accel anymotion z enable*/
gume 0:1f82672b8755 14429 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 14430 (p_bno055->dev_addr,
gume 0:1f82672b8755 14431 BNO055_ACCEL_ANY_MOTION_Z_AXIS_REG,
gume 0:1f82672b8755 14432 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14433 *data_u8 =
gume 0:1f82672b8755 14434 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 14435 BNO055_ACCEL_ANY_MOTION_Z_AXIS);
gume 0:1f82672b8755 14436 break;
gume 0:1f82672b8755 14437 default:
gume 0:1f82672b8755 14438 com_rslt = BNO055_OUT_OF_RANGE;
gume 0:1f82672b8755 14439 break;
gume 0:1f82672b8755 14440 }
gume 0:1f82672b8755 14441 } else {
gume 0:1f82672b8755 14442 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14443 }
gume 0:1f82672b8755 14444 }
gume 0:1f82672b8755 14445 return com_rslt;
gume 0:1f82672b8755 14446 }
gume 0:1f82672b8755 14447 /*!
gume 0:1f82672b8755 14448 * @brief This API used to write the accel anymotion enable
gume 0:1f82672b8755 14449 * from page one register from 0x12 bit 2 to 4
gume 0:1f82672b8755 14450 *
gume 0:1f82672b8755 14451 * @param data_u8 : The value of accel anymotion enable
gume 0:1f82672b8755 14452 * data_u8 | result
gume 0:1f82672b8755 14453 * ------------ | -------------
gume 0:1f82672b8755 14454 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 14455 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 14456 * @param channel_u8 : The value of accel anymotion axis selection
gume 0:1f82672b8755 14457 * channel_u8 | value
gume 0:1f82672b8755 14458 * -------------------------- | ----------
gume 0:1f82672b8755 14459 * BNO055_ACCEL_ANY_MOTION_NO_MOTION_X_AXIS | 0
gume 0:1f82672b8755 14460 * BNO055_ACCEL_ANY_MOTION_NO_MOTION_Y_AXIS | 1
gume 0:1f82672b8755 14461 * BNO055_ACCEL_ANY_MOTION_NO_MOTION_Y_AXIS | 2
gume 0:1f82672b8755 14462 *
gume 0:1f82672b8755 14463 * @return results of bus communication function
gume 0:1f82672b8755 14464 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 14465 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 14466 *
gume 0:1f82672b8755 14467 *
gume 0:1f82672b8755 14468 */
gume 0:1f82672b8755 14469 BNO055_RETURN_FUNCTION_TYPE bno055_set_accel_any_motion_no_motion_axis_enable(
gume 0:1f82672b8755 14470 u8 channel_u8, u8 data_u8)
gume 0:1f82672b8755 14471 {
gume 0:1f82672b8755 14472 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14473 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 14474 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 14475 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 14476 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 14477 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 14478 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 14479 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 14480 } else {
gume 0:1f82672b8755 14481 /* The write operation effective only if the operation
gume 0:1f82672b8755 14482 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 14483 current operation mode and set the config mode */
gume 0:1f82672b8755 14484 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 14485 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 14486 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 14487 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 14488 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 14489 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 14490 /* Write page as one */
gume 0:1f82672b8755 14491 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 14492 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 14493 switch (channel_u8) {
gume 0:1f82672b8755 14494 case BNO055_ACCEL_ANY_MOTION_NO_MOTION_X_AXIS:
gume 0:1f82672b8755 14495 /* Write the value of
gume 0:1f82672b8755 14496 accel anymotion x enable*/
gume 0:1f82672b8755 14497 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 14498 (p_bno055->dev_addr,
gume 0:1f82672b8755 14499 BNO055_ACCEL_ANY_MOTION_X_AXIS_REG,
gume 0:1f82672b8755 14500 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14501 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 14502 data_u8r = BNO055_SET_BITSLICE
gume 0:1f82672b8755 14503 (data_u8r,
gume 0:1f82672b8755 14504 BNO055_ACCEL_ANY_MOTION_X_AXIS,
gume 0:1f82672b8755 14505 data_u8);
gume 0:1f82672b8755 14506 com_rslt +=
gume 0:1f82672b8755 14507 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 14508 (p_bno055->dev_addr,
gume 0:1f82672b8755 14509 BNO055_ACCEL_ANY_MOTION_X_AXIS_REG,
gume 0:1f82672b8755 14510 &data_u8r,
gume 0:1f82672b8755 14511 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14512 }
gume 0:1f82672b8755 14513 break;
gume 0:1f82672b8755 14514 case BNO055_ACCEL_ANY_MOTION_NO_MOTION_Y_AXIS:
gume 0:1f82672b8755 14515 /* Write the value of
gume 0:1f82672b8755 14516 accel anymotion y enable*/
gume 0:1f82672b8755 14517 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 14518 (p_bno055->dev_addr,
gume 0:1f82672b8755 14519 BNO055_ACCEL_ANY_MOTION_Y_AXIS_REG,
gume 0:1f82672b8755 14520 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14521 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 14522 data_u8r = BNO055_SET_BITSLICE
gume 0:1f82672b8755 14523 (data_u8r,
gume 0:1f82672b8755 14524 BNO055_ACCEL_ANY_MOTION_Y_AXIS,
gume 0:1f82672b8755 14525 data_u8);
gume 0:1f82672b8755 14526 com_rslt +=
gume 0:1f82672b8755 14527 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 14528 (p_bno055->dev_addr,
gume 0:1f82672b8755 14529 BNO055_ACCEL_ANY_MOTION_Y_AXIS_REG,
gume 0:1f82672b8755 14530 &data_u8r,
gume 0:1f82672b8755 14531 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14532 }
gume 0:1f82672b8755 14533 break;
gume 0:1f82672b8755 14534 case BNO055_ACCEL_ANY_MOTION_NO_MOTION_Z_AXIS:
gume 0:1f82672b8755 14535 /* Write the value of
gume 0:1f82672b8755 14536 accel anymotion z enable*/
gume 0:1f82672b8755 14537 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 14538 (p_bno055->dev_addr,
gume 0:1f82672b8755 14539 BNO055_ACCEL_ANY_MOTION_Z_AXIS_REG,
gume 0:1f82672b8755 14540 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14541 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 14542 data_u8r = BNO055_SET_BITSLICE
gume 0:1f82672b8755 14543 (data_u8r,
gume 0:1f82672b8755 14544 BNO055_ACCEL_ANY_MOTION_Z_AXIS,
gume 0:1f82672b8755 14545 data_u8);
gume 0:1f82672b8755 14546 com_rslt +=
gume 0:1f82672b8755 14547 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 14548 (p_bno055->dev_addr,
gume 0:1f82672b8755 14549 BNO055_ACCEL_ANY_MOTION_Z_AXIS_REG,
gume 0:1f82672b8755 14550 &data_u8r,
gume 0:1f82672b8755 14551 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14552 }
gume 0:1f82672b8755 14553 break;
gume 0:1f82672b8755 14554 default:
gume 0:1f82672b8755 14555 com_rslt = BNO055_OUT_OF_RANGE;
gume 0:1f82672b8755 14556 break;
gume 0:1f82672b8755 14557 }
gume 0:1f82672b8755 14558 } else {
gume 0:1f82672b8755 14559 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14560 }
gume 0:1f82672b8755 14561 } else {
gume 0:1f82672b8755 14562 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14563 }
gume 0:1f82672b8755 14564 } else {
gume 0:1f82672b8755 14565 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14566 }
gume 0:1f82672b8755 14567 }
gume 0:1f82672b8755 14568 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 14569 /* set the operation mode of
gume 0:1f82672b8755 14570 previous operation mode*/
gume 0:1f82672b8755 14571 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 14572 (prev_opmode_u8);
gume 0:1f82672b8755 14573 return com_rslt;
gume 0:1f82672b8755 14574 }
gume 0:1f82672b8755 14575 /*!
gume 0:1f82672b8755 14576 * @brief This API used to read the accel highg enable
gume 0:1f82672b8755 14577 * from page one register from 0x12 bit 5 to 7
gume 0:1f82672b8755 14578 *
gume 0:1f82672b8755 14579 * @param data_u8 : The value of accel highg enable
gume 0:1f82672b8755 14580 * data_u8| result
gume 0:1f82672b8755 14581 * ------------ | -------------
gume 0:1f82672b8755 14582 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 14583 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 14584 * @param channel_u8 : The value of accel highg axis selection
gume 0:1f82672b8755 14585 * channel_u8 | value
gume 0:1f82672b8755 14586 * -------------------------- | ----------
gume 0:1f82672b8755 14587 * BNO055_ACCEL_HIGH_G_X_AXIS | 0
gume 0:1f82672b8755 14588 * BNO055_ACCEL_HIGH_G_Y_AXIS | 1
gume 0:1f82672b8755 14589 * BNO055_ACCEL_HIGH_G_Z_AXIS | 2
gume 0:1f82672b8755 14590 *
gume 0:1f82672b8755 14591 * @return results of bus communication function
gume 0:1f82672b8755 14592 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 14593 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 14594 *
gume 0:1f82672b8755 14595 *
gume 0:1f82672b8755 14596 */
gume 0:1f82672b8755 14597 BNO055_RETURN_FUNCTION_TYPE bno055_get_accel_high_g_axis_enable(
gume 0:1f82672b8755 14598 u8 channel_u8, u8 *data_u8)
gume 0:1f82672b8755 14599 {
gume 0:1f82672b8755 14600 /* Variable used to return value of
gume 0:1f82672b8755 14601 communication routine*/
gume 0:1f82672b8755 14602 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14603 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 14604 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 14605 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 14606 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 14607 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 14608 } else {
gume 0:1f82672b8755 14609 /*condition check for page, accel highg enable is
gume 0:1f82672b8755 14610 available in the page one*/
gume 0:1f82672b8755 14611 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 14612 /* Write page as one */
gume 0:1f82672b8755 14613 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 14614 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 14615 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 14616 switch (channel_u8) {
gume 0:1f82672b8755 14617 case BNO055_ACCEL_HIGH_G_X_AXIS:
gume 0:1f82672b8755 14618 /* Read the value of accel x highg enable*/
gume 0:1f82672b8755 14619 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 14620 (p_bno055->dev_addr,
gume 0:1f82672b8755 14621 BNO055_ACCEL_HIGH_G_X_AXIS_REG,
gume 0:1f82672b8755 14622 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14623 *data_u8 =
gume 0:1f82672b8755 14624 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 14625 BNO055_ACCEL_HIGH_G_X_AXIS);
gume 0:1f82672b8755 14626 break;
gume 0:1f82672b8755 14627 case BNO055_ACCEL_HIGH_G_Y_AXIS:
gume 0:1f82672b8755 14628 /* Read the value of accel y highg enable*/
gume 0:1f82672b8755 14629 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 14630 (p_bno055->dev_addr,
gume 0:1f82672b8755 14631 BNO055_ACCEL_HIGH_G_Y_AXIS_REG,
gume 0:1f82672b8755 14632 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14633 *data_u8 =
gume 0:1f82672b8755 14634 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 14635 BNO055_ACCEL_HIGH_G_Y_AXIS);
gume 0:1f82672b8755 14636 break;
gume 0:1f82672b8755 14637 case BNO055_ACCEL_HIGH_G_Z_AXIS:
gume 0:1f82672b8755 14638 /* Read the value of accel z highg enable*/
gume 0:1f82672b8755 14639 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 14640 (p_bno055->dev_addr,
gume 0:1f82672b8755 14641 BNO055_ACCEL_HIGH_G_Z_AXIS_REG,
gume 0:1f82672b8755 14642 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14643 *data_u8 =
gume 0:1f82672b8755 14644 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 14645 BNO055_ACCEL_HIGH_G_Z_AXIS);
gume 0:1f82672b8755 14646 break;
gume 0:1f82672b8755 14647 default:
gume 0:1f82672b8755 14648 com_rslt = BNO055_OUT_OF_RANGE;
gume 0:1f82672b8755 14649 break;
gume 0:1f82672b8755 14650 }
gume 0:1f82672b8755 14651 } else {
gume 0:1f82672b8755 14652 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14653 }
gume 0:1f82672b8755 14654 }
gume 0:1f82672b8755 14655 return com_rslt;
gume 0:1f82672b8755 14656 }
gume 0:1f82672b8755 14657 /*!
gume 0:1f82672b8755 14658 * @brief This API used to write the accel highg enable
gume 0:1f82672b8755 14659 * from page one register from 0x12 bit 5 to 7
gume 0:1f82672b8755 14660 *
gume 0:1f82672b8755 14661 * @param data_u8 : The value of accel highg enable
gume 0:1f82672b8755 14662 * data_u8| result
gume 0:1f82672b8755 14663 * ------------ | -------------
gume 0:1f82672b8755 14664 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 14665 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 14666 * @param channel_u8 : The value of accel highg axis selection
gume 0:1f82672b8755 14667 * channel_u8 | value
gume 0:1f82672b8755 14668 * -------------------------- | ----------
gume 0:1f82672b8755 14669 * BNO055_ACCEL_HIGH_G_X_AXIS | 0
gume 0:1f82672b8755 14670 * BNO055_ACCEL_HIGH_G_Y_AXIS | 1
gume 0:1f82672b8755 14671 * BNO055_ACCEL_HIGH_G_Z_AXIS | 2
gume 0:1f82672b8755 14672 *
gume 0:1f82672b8755 14673 * @return results of bus communication function
gume 0:1f82672b8755 14674 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 14675 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 14676 *
gume 0:1f82672b8755 14677 *
gume 0:1f82672b8755 14678 */
gume 0:1f82672b8755 14679 BNO055_RETURN_FUNCTION_TYPE bno055_set_accel_high_g_axis_enable(
gume 0:1f82672b8755 14680 u8 channel_u8, u8 data_u8)
gume 0:1f82672b8755 14681 {
gume 0:1f82672b8755 14682 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14683 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 14684 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 14685 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 14686 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 14687 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 14688 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 14689 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 14690 } else {
gume 0:1f82672b8755 14691 /* The write operation effective only if the operation
gume 0:1f82672b8755 14692 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 14693 current operation mode and set the config mode */
gume 0:1f82672b8755 14694 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 14695 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 14696 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 14697 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 14698 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 14699 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 14700 /* Write page as one */
gume 0:1f82672b8755 14701 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 14702 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 14703 switch (channel_u8) {
gume 0:1f82672b8755 14704 case BNO055_ACCEL_HIGH_G_X_AXIS:
gume 0:1f82672b8755 14705 /* Write the value of
gume 0:1f82672b8755 14706 accel x highg enable*/
gume 0:1f82672b8755 14707 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 14708 (p_bno055->dev_addr,
gume 0:1f82672b8755 14709 BNO055_ACCEL_HIGH_G_X_AXIS_REG,
gume 0:1f82672b8755 14710 &data_u8r,
gume 0:1f82672b8755 14711 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14712 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 14713 data_u8r =
gume 0:1f82672b8755 14714 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 14715 BNO055_ACCEL_HIGH_G_X_AXIS, data_u8);
gume 0:1f82672b8755 14716 com_rslt +=
gume 0:1f82672b8755 14717 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 14718 (p_bno055->dev_addr,
gume 0:1f82672b8755 14719 BNO055_ACCEL_HIGH_G_X_AXIS_REG,
gume 0:1f82672b8755 14720 &data_u8r,
gume 0:1f82672b8755 14721 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14722 }
gume 0:1f82672b8755 14723 break;
gume 0:1f82672b8755 14724 case BNO055_ACCEL_HIGH_G_Y_AXIS:
gume 0:1f82672b8755 14725 /* Write the value of
gume 0:1f82672b8755 14726 accel y highg enable*/
gume 0:1f82672b8755 14727 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 14728 (p_bno055->dev_addr,
gume 0:1f82672b8755 14729 BNO055_ACCEL_HIGH_G_Y_AXIS_REG,
gume 0:1f82672b8755 14730 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14731 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 14732 data_u8r =
gume 0:1f82672b8755 14733 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 14734 BNO055_ACCEL_HIGH_G_Y_AXIS,
gume 0:1f82672b8755 14735 data_u8);
gume 0:1f82672b8755 14736 com_rslt +=
gume 0:1f82672b8755 14737 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 14738 (p_bno055->dev_addr,
gume 0:1f82672b8755 14739 BNO055_ACCEL_HIGH_G_Y_AXIS_REG,
gume 0:1f82672b8755 14740 &data_u8r,
gume 0:1f82672b8755 14741 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14742 }
gume 0:1f82672b8755 14743 break;
gume 0:1f82672b8755 14744 case BNO055_ACCEL_HIGH_G_Z_AXIS:
gume 0:1f82672b8755 14745 /* Write the value of
gume 0:1f82672b8755 14746 accel z highg enable*/
gume 0:1f82672b8755 14747 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 14748 (p_bno055->dev_addr,
gume 0:1f82672b8755 14749 BNO055_ACCEL_HIGH_G_Z_AXIS_REG,
gume 0:1f82672b8755 14750 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14751 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 14752 data_u8r =
gume 0:1f82672b8755 14753 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 14754 BNO055_ACCEL_HIGH_G_Z_AXIS, data_u8);
gume 0:1f82672b8755 14755 com_rslt +=
gume 0:1f82672b8755 14756 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 14757 (p_bno055->dev_addr,
gume 0:1f82672b8755 14758 BNO055_ACCEL_HIGH_G_Z_AXIS_REG,
gume 0:1f82672b8755 14759 &data_u8r,
gume 0:1f82672b8755 14760 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14761 }
gume 0:1f82672b8755 14762 break;
gume 0:1f82672b8755 14763 default:
gume 0:1f82672b8755 14764 com_rslt = BNO055_OUT_OF_RANGE;
gume 0:1f82672b8755 14765 break;
gume 0:1f82672b8755 14766 }
gume 0:1f82672b8755 14767 } else {
gume 0:1f82672b8755 14768 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14769 }
gume 0:1f82672b8755 14770 } else {
gume 0:1f82672b8755 14771 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14772 }
gume 0:1f82672b8755 14773 } else {
gume 0:1f82672b8755 14774 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14775 }
gume 0:1f82672b8755 14776 }
gume 0:1f82672b8755 14777 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 14778 /* set the operation mode of
gume 0:1f82672b8755 14779 previous operation mode*/
gume 0:1f82672b8755 14780 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 14781 (prev_opmode_u8);
gume 0:1f82672b8755 14782 return com_rslt;
gume 0:1f82672b8755 14783 }
gume 0:1f82672b8755 14784 /*!
gume 0:1f82672b8755 14785 * @brief This API used to read the accel highg duration
gume 0:1f82672b8755 14786 * from page one register from 0x13 bit 0 to 7
gume 0:1f82672b8755 14787 *
gume 0:1f82672b8755 14788 * @param accel_high_g_durn_u8 : The value of accel highg duration
gume 0:1f82672b8755 14789 *
gume 0:1f82672b8755 14790 * @return results of bus communication function
gume 0:1f82672b8755 14791 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 14792 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 14793 *
gume 0:1f82672b8755 14794 * @note The high-g interrupt trigger delay according
gume 0:1f82672b8755 14795 * to [highg duration + 1] * 2 ms
gume 0:1f82672b8755 14796 *
gume 0:1f82672b8755 14797 * in a range from 2 ms to 512 ms
gume 0:1f82672b8755 14798 *
gume 0:1f82672b8755 14799 */
gume 0:1f82672b8755 14800 BNO055_RETURN_FUNCTION_TYPE bno055_get_accel_high_g_durn(
gume 0:1f82672b8755 14801 u8 *accel_high_g_durn_u8)
gume 0:1f82672b8755 14802 {
gume 0:1f82672b8755 14803 /* Variable used to return value of
gume 0:1f82672b8755 14804 communication routine*/
gume 0:1f82672b8755 14805 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14806 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 14807 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 14808 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 14809 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 14810 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 14811 } else {
gume 0:1f82672b8755 14812 /*condition check for page, accel highg duration is
gume 0:1f82672b8755 14813 available in the page one*/
gume 0:1f82672b8755 14814 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 14815 /* Write page as one */
gume 0:1f82672b8755 14816 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 14817 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 14818 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 14819 /* Read the value of accel highg duration*/
gume 0:1f82672b8755 14820 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 14821 (p_bno055->dev_addr,
gume 0:1f82672b8755 14822 BNO055_ACCEL_HIGH_G_DURN_REG,
gume 0:1f82672b8755 14823 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14824 *accel_high_g_durn_u8 =
gume 0:1f82672b8755 14825 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 14826 BNO055_ACCEL_HIGH_G_DURN);
gume 0:1f82672b8755 14827 } else {
gume 0:1f82672b8755 14828 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14829 }
gume 0:1f82672b8755 14830 }
gume 0:1f82672b8755 14831 return com_rslt;
gume 0:1f82672b8755 14832 }
gume 0:1f82672b8755 14833 /*!
gume 0:1f82672b8755 14834 * @brief This API used to write the accel highg duration
gume 0:1f82672b8755 14835 * from page one register from 0x13 bit 0 to 7
gume 0:1f82672b8755 14836 *
gume 0:1f82672b8755 14837 * @param accel_high_g_durn_u8 : The value of accel highg duration
gume 0:1f82672b8755 14838 *
gume 0:1f82672b8755 14839 * @return results of bus communication function
gume 0:1f82672b8755 14840 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 14841 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 14842 *
gume 0:1f82672b8755 14843 * @note The high-g interrupt trigger delay according
gume 0:1f82672b8755 14844 * to [highg duration + 1] * 2 ms
gume 0:1f82672b8755 14845 *
gume 0:1f82672b8755 14846 * in a range from 2 ms to 512 ms
gume 0:1f82672b8755 14847 *
gume 0:1f82672b8755 14848 */
gume 0:1f82672b8755 14849 BNO055_RETURN_FUNCTION_TYPE bno055_set_accel_high_g_durn(
gume 0:1f82672b8755 14850 u8 accel_high_g_durn_u8)
gume 0:1f82672b8755 14851 {
gume 0:1f82672b8755 14852 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14853 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 14854 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 14855 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 14856 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 14857 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 14858 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 14859 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 14860 } else {
gume 0:1f82672b8755 14861 /* The write operation effective only if the operation
gume 0:1f82672b8755 14862 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 14863 current operation mode and set the config mode */
gume 0:1f82672b8755 14864 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 14865 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 14866 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 14867 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 14868 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 14869
gume 0:1f82672b8755 14870 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 14871 /* Write page as one */
gume 0:1f82672b8755 14872 pg_stat_s8 = bno055_write_page_id(
gume 0:1f82672b8755 14873 BNO055_PAGE_ONE);
gume 0:1f82672b8755 14874 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 14875 com_rslt =
gume 0:1f82672b8755 14876 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 14877 (p_bno055->dev_addr,
gume 0:1f82672b8755 14878 BNO055_ACCEL_HIGH_G_DURN_REG,
gume 0:1f82672b8755 14879 &data_u8r,
gume 0:1f82672b8755 14880 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14881 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 14882 /* Write the value of
gume 0:1f82672b8755 14883 accel highg duration*/
gume 0:1f82672b8755 14884 data_u8r =
gume 0:1f82672b8755 14885 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 14886 BNO055_ACCEL_HIGH_G_DURN,
gume 0:1f82672b8755 14887 accel_high_g_durn_u8);
gume 0:1f82672b8755 14888 com_rslt +=
gume 0:1f82672b8755 14889 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 14890 (p_bno055->dev_addr,
gume 0:1f82672b8755 14891 BNO055_ACCEL_HIGH_G_DURN_REG,
gume 0:1f82672b8755 14892 &data_u8r,
gume 0:1f82672b8755 14893 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14894 }
gume 0:1f82672b8755 14895 } else {
gume 0:1f82672b8755 14896 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14897 }
gume 0:1f82672b8755 14898 } else {
gume 0:1f82672b8755 14899 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14900 }
gume 0:1f82672b8755 14901 } else {
gume 0:1f82672b8755 14902 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14903 }
gume 0:1f82672b8755 14904 }
gume 0:1f82672b8755 14905 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 14906 /* set the operation mode of
gume 0:1f82672b8755 14907 previous operation mode*/
gume 0:1f82672b8755 14908 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 14909 (prev_opmode_u8);
gume 0:1f82672b8755 14910 return com_rslt;
gume 0:1f82672b8755 14911 }
gume 0:1f82672b8755 14912 /*!
gume 0:1f82672b8755 14913 * @brief This API used to read the accel highg threshold
gume 0:1f82672b8755 14914 * from page one register from 0x14 bit 0 to 7
gume 0:1f82672b8755 14915 *
gume 0:1f82672b8755 14916 * @param accel_high_g_thres_u8 : The value of accel highg threshold
gume 0:1f82672b8755 14917 *
gume 0:1f82672b8755 14918 * @return results of bus communication function
gume 0:1f82672b8755 14919 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 14920 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 14921 *
gume 0:1f82672b8755 14922 * @note Accel highg interrupt threshold dependent
gume 0:1f82672b8755 14923 * for accel g range
gume 0:1f82672b8755 14924 *
gume 0:1f82672b8755 14925 * accel_range_u8 | threshold | LSB
gume 0:1f82672b8755 14926 * ------------- | ------------- | ---------
gume 0:1f82672b8755 14927 * 2g | 7.81mg | 1LSB
gume 0:1f82672b8755 14928 * 4g | 15.63mg | 1LSB
gume 0:1f82672b8755 14929 * 8g | 31.25mg | 1LSB
gume 0:1f82672b8755 14930 * 16g | 62.5mg | 1LSB
gume 0:1f82672b8755 14931 *
gume 0:1f82672b8755 14932 */
gume 0:1f82672b8755 14933 BNO055_RETURN_FUNCTION_TYPE bno055_get_accel_high_g_thres(
gume 0:1f82672b8755 14934 u8 *accel_high_g_thres_u8)
gume 0:1f82672b8755 14935 {
gume 0:1f82672b8755 14936 /* Variable used to return value of
gume 0:1f82672b8755 14937 communication routine*/
gume 0:1f82672b8755 14938 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14939 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 14940 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 14941 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 14942 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 14943 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 14944 } else {
gume 0:1f82672b8755 14945 /*condition check for page, highg threshold is
gume 0:1f82672b8755 14946 available in the page one*/
gume 0:1f82672b8755 14947 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 14948 /* Write page as one */
gume 0:1f82672b8755 14949 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 14950 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 14951 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 14952 /* Read the value of highg threshold */
gume 0:1f82672b8755 14953 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 14954 (p_bno055->dev_addr,
gume 0:1f82672b8755 14955 BNO055_ACCEL_HIGH_G_THRES_REG,
gume 0:1f82672b8755 14956 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 14957 *accel_high_g_thres_u8 =
gume 0:1f82672b8755 14958 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 14959 BNO055_ACCEL_HIGH_G_THRES);
gume 0:1f82672b8755 14960 } else {
gume 0:1f82672b8755 14961 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14962 }
gume 0:1f82672b8755 14963 }
gume 0:1f82672b8755 14964 return com_rslt;
gume 0:1f82672b8755 14965 }
gume 0:1f82672b8755 14966 /*!
gume 0:1f82672b8755 14967 * @brief This API used to write the accel highg threshold
gume 0:1f82672b8755 14968 * from page one register from 0x14 bit 0 to 7
gume 0:1f82672b8755 14969 *
gume 0:1f82672b8755 14970 * @param accel_high_g_thres_u8 : The value of accel highg threshold
gume 0:1f82672b8755 14971 *
gume 0:1f82672b8755 14972 * @return results of bus communication function
gume 0:1f82672b8755 14973 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 14974 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 14975 *
gume 0:1f82672b8755 14976 * @note Accel highg interrupt threshold dependent
gume 0:1f82672b8755 14977 * for accel g range
gume 0:1f82672b8755 14978 *
gume 0:1f82672b8755 14979 * accel_range_u8 | threshold | LSB
gume 0:1f82672b8755 14980 * ------------- | ------------- | ---------
gume 0:1f82672b8755 14981 * 2g | 7.81mg | 1LSB
gume 0:1f82672b8755 14982 * 4g | 15.63mg | 1LSB
gume 0:1f82672b8755 14983 * 8g | 31.25mg | 1LSB
gume 0:1f82672b8755 14984 * 16g | 62.5mg | 1LSB
gume 0:1f82672b8755 14985 *
gume 0:1f82672b8755 14986 */
gume 0:1f82672b8755 14987 BNO055_RETURN_FUNCTION_TYPE bno055_set_accel_high_g_thres(
gume 0:1f82672b8755 14988 u8 accel_high_g_thres_u8)
gume 0:1f82672b8755 14989 {
gume 0:1f82672b8755 14990 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 14991 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 14992 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 14993 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 14994 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 14995 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 14996 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 14997 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 14998 } else {
gume 0:1f82672b8755 14999 /* The write operation effective only if the operation
gume 0:1f82672b8755 15000 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 15001 current operation mode and set the config mode */
gume 0:1f82672b8755 15002 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 15003 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 15004 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 15005 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 15006 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 15007 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 15008 /* Write page as one */
gume 0:1f82672b8755 15009 pg_stat_s8 = bno055_write_page_id(
gume 0:1f82672b8755 15010 BNO055_PAGE_ONE);
gume 0:1f82672b8755 15011 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 15012 com_rslt =
gume 0:1f82672b8755 15013 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 15014 (p_bno055->dev_addr,
gume 0:1f82672b8755 15015 BNO055_ACCEL_HIGH_G_THRES_REG,
gume 0:1f82672b8755 15016 &data_u8r,
gume 0:1f82672b8755 15017 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15018 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 15019 /* Write the value of
gume 0:1f82672b8755 15020 accel highg threshold */
gume 0:1f82672b8755 15021 data_u8r =
gume 0:1f82672b8755 15022 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 15023 BNO055_ACCEL_HIGH_G_THRES,
gume 0:1f82672b8755 15024 accel_high_g_thres_u8);
gume 0:1f82672b8755 15025 com_rslt +=
gume 0:1f82672b8755 15026 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 15027 (p_bno055->dev_addr,
gume 0:1f82672b8755 15028 BNO055_ACCEL_HIGH_G_THRES_REG,
gume 0:1f82672b8755 15029 &data_u8r,
gume 0:1f82672b8755 15030 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15031 }
gume 0:1f82672b8755 15032 } else {
gume 0:1f82672b8755 15033 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15034 }
gume 0:1f82672b8755 15035 } else {
gume 0:1f82672b8755 15036 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15037 }
gume 0:1f82672b8755 15038 } else {
gume 0:1f82672b8755 15039 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15040 }
gume 0:1f82672b8755 15041 }
gume 0:1f82672b8755 15042 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 15043 /* set the operation mode of
gume 0:1f82672b8755 15044 previous operation mode*/
gume 0:1f82672b8755 15045 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 15046 (prev_opmode_u8);
gume 0:1f82672b8755 15047 return com_rslt;
gume 0:1f82672b8755 15048 }
gume 0:1f82672b8755 15049 /*!
gume 0:1f82672b8755 15050 * @brief This API used to read the accel slownomotion threshold
gume 0:1f82672b8755 15051 * from page one register from 0x15 bit 0 to 7
gume 0:1f82672b8755 15052 *
gume 0:1f82672b8755 15053 * @param accel_slow_no_motion_thres_u8 :
gume 0:1f82672b8755 15054 * The value of accel slownomotion threshold
gume 0:1f82672b8755 15055 *
gume 0:1f82672b8755 15056 * @return results of bus communication function
gume 0:1f82672b8755 15057 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 15058 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 15059 *
gume 0:1f82672b8755 15060 * @note Accel slow no motion interrupt threshold dependent
gume 0:1f82672b8755 15061 * for accel g range
gume 0:1f82672b8755 15062 *
gume 0:1f82672b8755 15063 * accel_range_u8 | threshold | LSB
gume 0:1f82672b8755 15064 * ------------- | ------------- | ---------
gume 0:1f82672b8755 15065 * 2g | 3.19mg | 1LSB
gume 0:1f82672b8755 15066 * 4g | 7.81mg | 1LSB
gume 0:1f82672b8755 15067 * 8g | 15.63mg | 1LSB
gume 0:1f82672b8755 15068 * 16g | 31.25mg | 1LSB
gume 0:1f82672b8755 15069 */
gume 0:1f82672b8755 15070 BNO055_RETURN_FUNCTION_TYPE bno055_get_accel_slow_no_motion_thres(
gume 0:1f82672b8755 15071 u8 *accel_slow_no_motion_thres_u8)
gume 0:1f82672b8755 15072 {
gume 0:1f82672b8755 15073 /* Variable used to return value of
gume 0:1f82672b8755 15074 communication routine*/
gume 0:1f82672b8755 15075 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15076 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 15077 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 15078 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 15079 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 15080 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 15081 } else {
gume 0:1f82672b8755 15082 /*condition check for page, accel slownomotion threshold is
gume 0:1f82672b8755 15083 available in the page one*/
gume 0:1f82672b8755 15084 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 15085 /* Write page as one */
gume 0:1f82672b8755 15086 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 15087 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 15088 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 15089 /* Read the value of slownomotion threshold */
gume 0:1f82672b8755 15090 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 15091 (p_bno055->dev_addr,
gume 0:1f82672b8755 15092 BNO055_ACCEL_SLOW_NO_MOTION_THRES_REG,
gume 0:1f82672b8755 15093 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15094 *accel_slow_no_motion_thres_u8 =
gume 0:1f82672b8755 15095 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 15096 BNO055_ACCEL_SLOW_NO_MOTION_THRES);
gume 0:1f82672b8755 15097 } else {
gume 0:1f82672b8755 15098 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15099 }
gume 0:1f82672b8755 15100 }
gume 0:1f82672b8755 15101 return com_rslt;
gume 0:1f82672b8755 15102 }
gume 0:1f82672b8755 15103 /*!
gume 0:1f82672b8755 15104 * @brief This API used to write the accel slownomotion threshold
gume 0:1f82672b8755 15105 * from page one register from 0x15 bit 0 to 7
gume 0:1f82672b8755 15106 *
gume 0:1f82672b8755 15107 * @param accel_slow_no_motion_thres_u8 :
gume 0:1f82672b8755 15108 * The value of accel slownomotion threshold
gume 0:1f82672b8755 15109 *
gume 0:1f82672b8755 15110 * @return results of bus communication function
gume 0:1f82672b8755 15111 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 15112 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 15113 *
gume 0:1f82672b8755 15114 * @note Accel slow no motion interrupt threshold dependent
gume 0:1f82672b8755 15115 * for accel g range
gume 0:1f82672b8755 15116 *
gume 0:1f82672b8755 15117 * accel_range_u8 | threshold | LSB
gume 0:1f82672b8755 15118 * ------------- | ------------- | ---------
gume 0:1f82672b8755 15119 * 2g | 3.19mg | 1LSB
gume 0:1f82672b8755 15120 * 4g | 7.81mg | 1LSB
gume 0:1f82672b8755 15121 * 8g | 15.63mg | 1LSB
gume 0:1f82672b8755 15122 * 16g | 31.25mg | 1LSB
gume 0:1f82672b8755 15123 */
gume 0:1f82672b8755 15124 BNO055_RETURN_FUNCTION_TYPE bno055_set_accel_slow_no_motion_thres(
gume 0:1f82672b8755 15125 u8 accel_slow_no_motion_thres_u8)
gume 0:1f82672b8755 15126 {
gume 0:1f82672b8755 15127 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15128 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 15129 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 15130 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 15131 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 15132 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 15133 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 15134 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 15135 } else {
gume 0:1f82672b8755 15136 /* The write operation effective only if the operation
gume 0:1f82672b8755 15137 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 15138 current operation mode and set the config mode */
gume 0:1f82672b8755 15139 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 15140 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 15141 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 15142 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 15143 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 15144 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 15145 /* Write page as one */
gume 0:1f82672b8755 15146 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 15147 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 15148 /* Write the value of
gume 0:1f82672b8755 15149 slownomotion threshold */
gume 0:1f82672b8755 15150 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 15151 (p_bno055->dev_addr,
gume 0:1f82672b8755 15152 BNO055_ACCEL_SLOW_NO_MOTION_THRES_REG,
gume 0:1f82672b8755 15153 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15154 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 15155 data_u8r =
gume 0:1f82672b8755 15156 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 15157 BNO055_ACCEL_SLOW_NO_MOTION_THRES,
gume 0:1f82672b8755 15158 accel_slow_no_motion_thres_u8);
gume 0:1f82672b8755 15159 com_rslt +=
gume 0:1f82672b8755 15160 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 15161 (p_bno055->dev_addr,
gume 0:1f82672b8755 15162 BNO055_ACCEL_SLOW_NO_MOTION_THRES_REG,
gume 0:1f82672b8755 15163 &data_u8r,
gume 0:1f82672b8755 15164 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15165 }
gume 0:1f82672b8755 15166 } else {
gume 0:1f82672b8755 15167 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15168 }
gume 0:1f82672b8755 15169 } else {
gume 0:1f82672b8755 15170 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15171 }
gume 0:1f82672b8755 15172 } else {
gume 0:1f82672b8755 15173 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15174 }
gume 0:1f82672b8755 15175 }
gume 0:1f82672b8755 15176 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 15177 /* set the operation mode of
gume 0:1f82672b8755 15178 previous operation mode*/
gume 0:1f82672b8755 15179 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 15180 (prev_opmode_u8);
gume 0:1f82672b8755 15181 return com_rslt;
gume 0:1f82672b8755 15182 }
gume 0:1f82672b8755 15183 /*!
gume 0:1f82672b8755 15184 * @brief This API used to read accel slownomotion enable
gume 0:1f82672b8755 15185 * from page one register from 0x16 bit 0
gume 0:1f82672b8755 15186 *
gume 0:1f82672b8755 15187 * @param accel_slow_no_motion_en_u8 : The value of accel slownomotion enable
gume 0:1f82672b8755 15188 * accel_slow_no_motion_en_u8 | result
gume 0:1f82672b8755 15189 * ------------------------ | --------
gume 0:1f82672b8755 15190 * 0x01 | Slow motion
gume 0:1f82672b8755 15191 * 0x00 | No motion
gume 0:1f82672b8755 15192 *
gume 0:1f82672b8755 15193 * @return results of bus communication function
gume 0:1f82672b8755 15194 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 15195 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 15196 *
gume 0:1f82672b8755 15197 */
gume 0:1f82672b8755 15198 BNO055_RETURN_FUNCTION_TYPE bno055_get_accel_slow_no_motion_enable(
gume 0:1f82672b8755 15199 u8 *accel_slow_no_motion_en_u8)
gume 0:1f82672b8755 15200 {
gume 0:1f82672b8755 15201 /* Variable used to return value of
gume 0:1f82672b8755 15202 communication routine*/
gume 0:1f82672b8755 15203 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15204 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 15205 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 15206 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 15207 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 15208 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 15209 } else {
gume 0:1f82672b8755 15210 /*condition check for page, accel slownomotion enable is
gume 0:1f82672b8755 15211 available in the page one*/
gume 0:1f82672b8755 15212 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 15213 /* Write page as one */
gume 0:1f82672b8755 15214 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 15215 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 15216 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 15217 /* Read the value of accel slownomotion enable */
gume 0:1f82672b8755 15218 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 15219 (p_bno055->dev_addr,
gume 0:1f82672b8755 15220 BNO055_ACCEL_SLOW_NO_MOTION_ENABLE_REG,
gume 0:1f82672b8755 15221 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15222 *accel_slow_no_motion_en_u8 =
gume 0:1f82672b8755 15223 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 15224 BNO055_ACCEL_SLOW_NO_MOTION_ENABLE);
gume 0:1f82672b8755 15225 } else {
gume 0:1f82672b8755 15226 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15227 }
gume 0:1f82672b8755 15228 }
gume 0:1f82672b8755 15229 return com_rslt;
gume 0:1f82672b8755 15230 }
gume 0:1f82672b8755 15231 /*!
gume 0:1f82672b8755 15232 * @brief This API used to write accel slownomotion enable
gume 0:1f82672b8755 15233 * from page one register from 0x16 bit 0
gume 0:1f82672b8755 15234 *
gume 0:1f82672b8755 15235 * @param accel_slow_no_motion_en_u8 : The value of accel slownomotion enable
gume 0:1f82672b8755 15236 * accel_slow_no_motion_en_u8 | result
gume 0:1f82672b8755 15237 * ------------------------ | --------
gume 0:1f82672b8755 15238 * 0x01 | Slow motion
gume 0:1f82672b8755 15239 * 0x00 | No motion
gume 0:1f82672b8755 15240 *
gume 0:1f82672b8755 15241 * @return results of bus communication function
gume 0:1f82672b8755 15242 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 15243 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 15244 *
gume 0:1f82672b8755 15245 */
gume 0:1f82672b8755 15246 BNO055_RETURN_FUNCTION_TYPE bno055_set_accel_slow_no_motion_enable(
gume 0:1f82672b8755 15247 u8 accel_slow_no_motion_en_u8)
gume 0:1f82672b8755 15248 {
gume 0:1f82672b8755 15249 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15250 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 15251 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 15252 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 15253 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 15254 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 15255 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 15256 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 15257 } else {
gume 0:1f82672b8755 15258 /* The write operation effective only if the operation
gume 0:1f82672b8755 15259 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 15260 current operation mode and set the config mode */
gume 0:1f82672b8755 15261 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 15262 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 15263 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 15264 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 15265 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 15266 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 15267 /* Write page as one */
gume 0:1f82672b8755 15268 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 15269 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 15270 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 15271 (p_bno055->dev_addr,
gume 0:1f82672b8755 15272 BNO055_ACCEL_SLOW_NO_MOTION_ENABLE_REG,
gume 0:1f82672b8755 15273 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15274 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 15275 /* Read the value of
gume 0:1f82672b8755 15276 accel slownomotion enable */
gume 0:1f82672b8755 15277 data_u8r =
gume 0:1f82672b8755 15278 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 15279 BNO055_ACCEL_SLOW_NO_MOTION_ENABLE,
gume 0:1f82672b8755 15280 accel_slow_no_motion_en_u8);
gume 0:1f82672b8755 15281 com_rslt +=
gume 0:1f82672b8755 15282 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 15283 (p_bno055->dev_addr,
gume 0:1f82672b8755 15284 BNO055_ACCEL_SLOW_NO_MOTION_ENABLE_REG,
gume 0:1f82672b8755 15285 &data_u8r,
gume 0:1f82672b8755 15286 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15287 }
gume 0:1f82672b8755 15288 } else {
gume 0:1f82672b8755 15289 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15290 }
gume 0:1f82672b8755 15291 } else {
gume 0:1f82672b8755 15292 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15293 }
gume 0:1f82672b8755 15294 } else {
gume 0:1f82672b8755 15295 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15296 }
gume 0:1f82672b8755 15297 }
gume 0:1f82672b8755 15298 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 15299 /* set the operation mode of
gume 0:1f82672b8755 15300 previous operation mode*/
gume 0:1f82672b8755 15301 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 15302 (prev_opmode_u8);
gume 0:1f82672b8755 15303 return com_rslt;
gume 0:1f82672b8755 15304 }
gume 0:1f82672b8755 15305 /*!
gume 0:1f82672b8755 15306 * @brief This API used to read accel slownomotion duration
gume 0:1f82672b8755 15307 * from page one register from 0x16 bit 1 to 6
gume 0:1f82672b8755 15308 *
gume 0:1f82672b8755 15309 * @param accel_slow_no_motion_durn_u8 :
gume 0:1f82672b8755 15310 * The value of accel slownomotion duration
gume 0:1f82672b8755 15311 *
gume 0:1f82672b8755 15312 * @return results of bus communication function
gume 0:1f82672b8755 15313 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 15314 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 15315 *
gume 0:1f82672b8755 15316 */
gume 0:1f82672b8755 15317 BNO055_RETURN_FUNCTION_TYPE bno055_get_accel_slow_no_motion_durn(
gume 0:1f82672b8755 15318 u8 *accel_slow_no_motion_durn_u8)
gume 0:1f82672b8755 15319 {
gume 0:1f82672b8755 15320 /* Variable used to return value of
gume 0:1f82672b8755 15321 communication routine*/
gume 0:1f82672b8755 15322 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15323 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 15324 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 15325 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 15326 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 15327 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 15328 } else {
gume 0:1f82672b8755 15329 /*condition check for page, accel slownomotion duration is
gume 0:1f82672b8755 15330 available in the page one*/
gume 0:1f82672b8755 15331 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 15332 /* Write page as one */
gume 0:1f82672b8755 15333 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 15334 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 15335 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 15336 /*read value of accel slownomotion duration*/
gume 0:1f82672b8755 15337 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 15338 (p_bno055->dev_addr,
gume 0:1f82672b8755 15339 BNO055_ACCEL_SLOW_NO_MOTION_DURN_REG,
gume 0:1f82672b8755 15340 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15341 *accel_slow_no_motion_durn_u8 =
gume 0:1f82672b8755 15342 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 15343 BNO055_ACCEL_SLOW_NO_MOTION_DURN);
gume 0:1f82672b8755 15344 } else {
gume 0:1f82672b8755 15345 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15346 }
gume 0:1f82672b8755 15347 }
gume 0:1f82672b8755 15348 return com_rslt;
gume 0:1f82672b8755 15349 }
gume 0:1f82672b8755 15350 /*!
gume 0:1f82672b8755 15351 * @brief This API used to write accel slownomotion duration
gume 0:1f82672b8755 15352 * from page one register from 0x16 bit 1 to 6
gume 0:1f82672b8755 15353 *
gume 0:1f82672b8755 15354 * @param accel_slow_no_motion_durn_u8 :
gume 0:1f82672b8755 15355 * The value of accel slownomotion duration
gume 0:1f82672b8755 15356 *
gume 0:1f82672b8755 15357 * @return results of bus communication function
gume 0:1f82672b8755 15358 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 15359 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 15360 *
gume 0:1f82672b8755 15361 */
gume 0:1f82672b8755 15362 BNO055_RETURN_FUNCTION_TYPE bno055_set_accel_slow_no_motion_durn(
gume 0:1f82672b8755 15363 u8 accel_slow_no_motion_durn_u8)
gume 0:1f82672b8755 15364 {
gume 0:1f82672b8755 15365 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15366 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 15367 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 15368 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 15369 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 15370 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 15371 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 15372 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 15373 } else {
gume 0:1f82672b8755 15374 /* The write operation effective only if the operation
gume 0:1f82672b8755 15375 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 15376 current operation mode and set the config mode */
gume 0:1f82672b8755 15377 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 15378 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 15379 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 15380 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 15381 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 15382 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 15383 /* Write page as one */
gume 0:1f82672b8755 15384 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 15385 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 15386 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 15387 (p_bno055->dev_addr,
gume 0:1f82672b8755 15388 BNO055_ACCEL_SLOW_NO_MOTION_DURN_REG,
gume 0:1f82672b8755 15389 &data_u8r,
gume 0:1f82672b8755 15390 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15391 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 15392 /*Write the value of accel
gume 0:1f82672b8755 15393 slownomotion duration*/
gume 0:1f82672b8755 15394 data_u8r =
gume 0:1f82672b8755 15395 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 15396 BNO055_ACCEL_SLOW_NO_MOTION_DURN,
gume 0:1f82672b8755 15397 accel_slow_no_motion_durn_u8);
gume 0:1f82672b8755 15398 com_rslt +=
gume 0:1f82672b8755 15399 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 15400 (p_bno055->dev_addr,
gume 0:1f82672b8755 15401 BNO055_ACCEL_SLOW_NO_MOTION_DURN_REG,
gume 0:1f82672b8755 15402 &data_u8r,
gume 0:1f82672b8755 15403 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15404 }
gume 0:1f82672b8755 15405 } else {
gume 0:1f82672b8755 15406 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15407 }
gume 0:1f82672b8755 15408 } else {
gume 0:1f82672b8755 15409 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15410 }
gume 0:1f82672b8755 15411 } else {
gume 0:1f82672b8755 15412 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15413 }
gume 0:1f82672b8755 15414 }
gume 0:1f82672b8755 15415 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 15416 /* set the operation mode of
gume 0:1f82672b8755 15417 previous operation mode*/
gume 0:1f82672b8755 15418 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 15419 (prev_opmode_u8);
gume 0:1f82672b8755 15420 return com_rslt;
gume 0:1f82672b8755 15421 }
gume 0:1f82672b8755 15422 /*!
gume 0:1f82672b8755 15423 * @brief This API used to read the gyro anymotion enable
gume 0:1f82672b8755 15424 * from page one register from 0x17 bit 0 to 2
gume 0:1f82672b8755 15425 *
gume 0:1f82672b8755 15426 * @param data_u8 : The value of gyro anymotion enable
gume 0:1f82672b8755 15427 * data_u8 | result
gume 0:1f82672b8755 15428 * ----------------- |-------------
gume 0:1f82672b8755 15429 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 15430 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 15431 * @param channel_u8 : The value of gyro anymotion axis selection
gume 0:1f82672b8755 15432 * channel_u8 | value
gume 0:1f82672b8755 15433 * --------------------------- | ----------
gume 0:1f82672b8755 15434 * BNO055_GYRO_ANY_MOTIONX_AXIS | 0
gume 0:1f82672b8755 15435 * BNO055_GYRO_ANY_MOTIONY_AXIS | 1
gume 0:1f82672b8755 15436 * BNO055_GYRO_ANY_MOTIONZ_AXIS | 2
gume 0:1f82672b8755 15437 *
gume 0:1f82672b8755 15438 *
gume 0:1f82672b8755 15439 * @return results of bus communication function
gume 0:1f82672b8755 15440 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 15441 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 15442 *
gume 0:1f82672b8755 15443 *
gume 0:1f82672b8755 15444 */
gume 0:1f82672b8755 15445 BNO055_RETURN_FUNCTION_TYPE bno055_get_gyro_any_motion_axis_enable(
gume 0:1f82672b8755 15446 u8 channel_u8, u8 *data_u8)
gume 0:1f82672b8755 15447 {
gume 0:1f82672b8755 15448 /* Variable used to return value of
gume 0:1f82672b8755 15449 communication routine*/
gume 0:1f82672b8755 15450 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15451 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 15452 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 15453 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 15454 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 15455 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 15456 } else {
gume 0:1f82672b8755 15457 /*condition check for page, gyro anymotion axis is
gume 0:1f82672b8755 15458 available in the page one*/
gume 0:1f82672b8755 15459 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 15460 /* Write page as one */
gume 0:1f82672b8755 15461 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 15462 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 15463 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 15464 switch (channel_u8) {
gume 0:1f82672b8755 15465 case BNO055_GYRO_ANY_MOTION_X_AXIS:
gume 0:1f82672b8755 15466 /* Read the gyro anymotion x enable*/
gume 0:1f82672b8755 15467 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 15468 (p_bno055->dev_addr,
gume 0:1f82672b8755 15469 BNO055_GYRO_ANY_MOTION_X_AXIS_REG,
gume 0:1f82672b8755 15470 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15471 *data_u8 =
gume 0:1f82672b8755 15472 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 15473 BNO055_GYRO_ANY_MOTION_X_AXIS);
gume 0:1f82672b8755 15474 break;
gume 0:1f82672b8755 15475 case BNO055_GYRO_ANY_MOTION_Y_AXIS:
gume 0:1f82672b8755 15476 /* Read the gyro anymotion y enable*/
gume 0:1f82672b8755 15477 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 15478 (p_bno055->dev_addr,
gume 0:1f82672b8755 15479 BNO055_GYRO_ANY_MOTION_Y_AXIS_REG,
gume 0:1f82672b8755 15480 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15481 *data_u8 =
gume 0:1f82672b8755 15482 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 15483 BNO055_GYRO_ANY_MOTION_Y_AXIS);
gume 0:1f82672b8755 15484 break;
gume 0:1f82672b8755 15485 case BNO055_GYRO_ANY_MOTION_Z_AXIS:
gume 0:1f82672b8755 15486 /* Read the gyro anymotion z enable*/
gume 0:1f82672b8755 15487 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 15488 (p_bno055->dev_addr,
gume 0:1f82672b8755 15489 BNO055_GYRO_ANY_MOTION_Z_AXIS_REG,
gume 0:1f82672b8755 15490 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15491 *data_u8 =
gume 0:1f82672b8755 15492 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 15493 BNO055_GYRO_ANY_MOTION_Z_AXIS);
gume 0:1f82672b8755 15494 break;
gume 0:1f82672b8755 15495 default:
gume 0:1f82672b8755 15496 com_rslt = BNO055_OUT_OF_RANGE;
gume 0:1f82672b8755 15497 break;
gume 0:1f82672b8755 15498 }
gume 0:1f82672b8755 15499 } else {
gume 0:1f82672b8755 15500 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15501 }
gume 0:1f82672b8755 15502 }
gume 0:1f82672b8755 15503 return com_rslt;
gume 0:1f82672b8755 15504 }
gume 0:1f82672b8755 15505 /*!
gume 0:1f82672b8755 15506 * @brief This API used to write the gyro anymotion enable
gume 0:1f82672b8755 15507 * from page one register from 0x17 bit 0 to 2
gume 0:1f82672b8755 15508 *
gume 0:1f82672b8755 15509 * @param data_u8 : The value of gyro anymotion enable
gume 0:1f82672b8755 15510 * data_u8 | result
gume 0:1f82672b8755 15511 * ----------------- |-------------
gume 0:1f82672b8755 15512 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 15513 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 15514 * @param channel_u8 : The value of gyro anymotion axis selection
gume 0:1f82672b8755 15515 * channel_u8 | value
gume 0:1f82672b8755 15516 * --------------------------- | ----------
gume 0:1f82672b8755 15517 * BNO055_GYRO_ANY_MOTIONX_AXIS | 0
gume 0:1f82672b8755 15518 * BNO055_GYRO_ANY_MOTIONY_AXIS | 1
gume 0:1f82672b8755 15519 * BNO055_GYRO_ANY_MOTIONZ_AXIS | 2
gume 0:1f82672b8755 15520 *
gume 0:1f82672b8755 15521 * @return results of bus communication function
gume 0:1f82672b8755 15522 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 15523 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 15524 *
gume 0:1f82672b8755 15525 *
gume 0:1f82672b8755 15526 */
gume 0:1f82672b8755 15527 BNO055_RETURN_FUNCTION_TYPE bno055_set_gyro_any_motion_axis_enable(
gume 0:1f82672b8755 15528 u8 channel_u8, u8 data_u8)
gume 0:1f82672b8755 15529 {
gume 0:1f82672b8755 15530 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15531 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 15532 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 15533 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 15534 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 15535 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 15536 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 15537 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 15538 } else {
gume 0:1f82672b8755 15539 /* The write operation effective only if the operation
gume 0:1f82672b8755 15540 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 15541 current operation mode and set the config mode */
gume 0:1f82672b8755 15542 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 15543 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 15544 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 15545 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 15546 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 15547 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 15548 /* Write page as one */
gume 0:1f82672b8755 15549 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 15550 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 15551 switch (channel_u8) {
gume 0:1f82672b8755 15552 case BNO055_GYRO_ANY_MOTION_X_AXIS:
gume 0:1f82672b8755 15553 /* Write the gyro
gume 0:1f82672b8755 15554 anymotion x enable*/
gume 0:1f82672b8755 15555 com_rslt =
gume 0:1f82672b8755 15556 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 15557 (p_bno055->dev_addr,
gume 0:1f82672b8755 15558 BNO055_GYRO_ANY_MOTION_X_AXIS_REG,
gume 0:1f82672b8755 15559 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15560 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 15561 data_u8r = BNO055_SET_BITSLICE
gume 0:1f82672b8755 15562 (data_u8r,
gume 0:1f82672b8755 15563 BNO055_GYRO_ANY_MOTION_X_AXIS,
gume 0:1f82672b8755 15564 data_u8);
gume 0:1f82672b8755 15565 com_rslt +=
gume 0:1f82672b8755 15566 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 15567 (p_bno055->dev_addr,
gume 0:1f82672b8755 15568 BNO055_GYRO_ANY_MOTION_X_AXIS_REG,
gume 0:1f82672b8755 15569 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15570 }
gume 0:1f82672b8755 15571 break;
gume 0:1f82672b8755 15572 case BNO055_GYRO_ANY_MOTION_Y_AXIS:
gume 0:1f82672b8755 15573 /* Write the gyro
gume 0:1f82672b8755 15574 anymotion y enable*/
gume 0:1f82672b8755 15575 com_rslt =
gume 0:1f82672b8755 15576 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 15577 (p_bno055->dev_addr,
gume 0:1f82672b8755 15578 BNO055_GYRO_ANY_MOTION_Y_AXIS_REG,
gume 0:1f82672b8755 15579 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15580 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 15581 data_u8r = BNO055_SET_BITSLICE
gume 0:1f82672b8755 15582 (data_u8r,
gume 0:1f82672b8755 15583 BNO055_GYRO_ANY_MOTION_Y_AXIS, data_u8);
gume 0:1f82672b8755 15584 com_rslt +=
gume 0:1f82672b8755 15585 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 15586 (p_bno055->dev_addr,
gume 0:1f82672b8755 15587 BNO055_GYRO_ANY_MOTION_Y_AXIS_REG,
gume 0:1f82672b8755 15588 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15589 }
gume 0:1f82672b8755 15590 break;
gume 0:1f82672b8755 15591 case BNO055_GYRO_ANY_MOTION_Z_AXIS:
gume 0:1f82672b8755 15592 /* Write the gyro
gume 0:1f82672b8755 15593 anymotion z enable*/
gume 0:1f82672b8755 15594 com_rslt =
gume 0:1f82672b8755 15595 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 15596 (p_bno055->dev_addr,
gume 0:1f82672b8755 15597 BNO055_GYRO_ANY_MOTION_Z_AXIS_REG,
gume 0:1f82672b8755 15598 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15599 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 15600 data_u8r = BNO055_SET_BITSLICE
gume 0:1f82672b8755 15601 (data_u8r,
gume 0:1f82672b8755 15602 BNO055_GYRO_ANY_MOTION_Z_AXIS,
gume 0:1f82672b8755 15603 data_u8);
gume 0:1f82672b8755 15604 com_rslt +=
gume 0:1f82672b8755 15605 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 15606 (p_bno055->dev_addr,
gume 0:1f82672b8755 15607 BNO055_GYRO_ANY_MOTION_Z_AXIS_REG,
gume 0:1f82672b8755 15608 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15609 }
gume 0:1f82672b8755 15610 break;
gume 0:1f82672b8755 15611 default:
gume 0:1f82672b8755 15612 com_rslt = BNO055_OUT_OF_RANGE;
gume 0:1f82672b8755 15613 break;
gume 0:1f82672b8755 15614 }
gume 0:1f82672b8755 15615 } else {
gume 0:1f82672b8755 15616 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15617 }
gume 0:1f82672b8755 15618 } else {
gume 0:1f82672b8755 15619 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15620 }
gume 0:1f82672b8755 15621 } else {
gume 0:1f82672b8755 15622 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15623 }
gume 0:1f82672b8755 15624 }
gume 0:1f82672b8755 15625 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 15626 /* set the operation mode of
gume 0:1f82672b8755 15627 previous operation mode*/
gume 0:1f82672b8755 15628 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 15629 (prev_opmode_u8);
gume 0:1f82672b8755 15630 return com_rslt;
gume 0:1f82672b8755 15631 }
gume 0:1f82672b8755 15632 /*!
gume 0:1f82672b8755 15633 * @brief This API used to read the gyro highrate enable
gume 0:1f82672b8755 15634 * from page one register from 0x17 bit 3 to 5
gume 0:1f82672b8755 15635 *
gume 0:1f82672b8755 15636 * @param data_u8 : The value of gyro highrate enable
gume 0:1f82672b8755 15637 * data_u8 | result
gume 0:1f82672b8755 15638 * ---------------- |-------------
gume 0:1f82672b8755 15639 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 15640 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 15641 * @param channel_u8 : The value of gyro highrate axis selection
gume 0:1f82672b8755 15642 * channel_u8 | value
gume 0:1f82672b8755 15643 * ------------------------ | ----------
gume 0:1f82672b8755 15644 * BNO055_GYRO_HIGHRATE_X_AXIS | 0
gume 0:1f82672b8755 15645 * BNO055_GYRO_HIGHRATE_Y_AXIS | 1
gume 0:1f82672b8755 15646 * BNO055_GYRO_HIGHRATE_Z_AXIS | 2
gume 0:1f82672b8755 15647 *
gume 0:1f82672b8755 15648 *
gume 0:1f82672b8755 15649 * @return results of bus communication function
gume 0:1f82672b8755 15650 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 15651 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 15652 *
gume 0:1f82672b8755 15653 *
gume 0:1f82672b8755 15654 */
gume 0:1f82672b8755 15655 BNO055_RETURN_FUNCTION_TYPE bno055_get_gyro_highrate_axis_enable(
gume 0:1f82672b8755 15656 u8 channel_u8, u8 *data_u8)
gume 0:1f82672b8755 15657 {
gume 0:1f82672b8755 15658 /* Variable used to return value of
gume 0:1f82672b8755 15659 communication routine*/
gume 0:1f82672b8755 15660 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15661 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 15662 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 15663 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 15664 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 15665 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 15666 } else {
gume 0:1f82672b8755 15667 /*condition check for page, gyro highrate enable is
gume 0:1f82672b8755 15668 available in the page one*/
gume 0:1f82672b8755 15669 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 15670 /* Write page as one */
gume 0:1f82672b8755 15671 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 15672 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 15673 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 15674 switch (channel_u8) {
gume 0:1f82672b8755 15675 case BNO055_GYRO_HIGHRATE_X_AXIS:
gume 0:1f82672b8755 15676 /* Read the gyro highrate x enable */
gume 0:1f82672b8755 15677 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 15678 (p_bno055->dev_addr,
gume 0:1f82672b8755 15679 BNO055_GYRO_HIGHRATE_X_AXIS_REG,
gume 0:1f82672b8755 15680 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15681 *data_u8 =
gume 0:1f82672b8755 15682 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 15683 BNO055_GYRO_HIGHRATE_X_AXIS);
gume 0:1f82672b8755 15684 break;
gume 0:1f82672b8755 15685 case BNO055_GYRO_HIGHRATE_Y_AXIS:
gume 0:1f82672b8755 15686 /* Read the gyro highrate y enable */
gume 0:1f82672b8755 15687 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 15688 (p_bno055->dev_addr,
gume 0:1f82672b8755 15689 BNO055_GYRO_HIGHRATE_Y_AXIS_REG,
gume 0:1f82672b8755 15690 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15691 *data_u8 =
gume 0:1f82672b8755 15692 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 15693 BNO055_GYRO_HIGHRATE_Y_AXIS);
gume 0:1f82672b8755 15694 break;
gume 0:1f82672b8755 15695 case BNO055_GYRO_HIGHRATE_Z_AXIS:
gume 0:1f82672b8755 15696 /* Read the gyro highrate z enable */
gume 0:1f82672b8755 15697 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 15698 (p_bno055->dev_addr,
gume 0:1f82672b8755 15699 BNO055_GYRO_HIGHRATE_Z_AXIS_REG,
gume 0:1f82672b8755 15700 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15701 *data_u8 =
gume 0:1f82672b8755 15702 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 15703 BNO055_GYRO_HIGHRATE_Z_AXIS);
gume 0:1f82672b8755 15704 break;
gume 0:1f82672b8755 15705 default:
gume 0:1f82672b8755 15706 com_rslt = BNO055_OUT_OF_RANGE;
gume 0:1f82672b8755 15707 break;
gume 0:1f82672b8755 15708 }
gume 0:1f82672b8755 15709 } else {
gume 0:1f82672b8755 15710 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15711 }
gume 0:1f82672b8755 15712 }
gume 0:1f82672b8755 15713 return com_rslt;
gume 0:1f82672b8755 15714 }
gume 0:1f82672b8755 15715 /*!
gume 0:1f82672b8755 15716 * @brief This API used to write the gyro highrate enable
gume 0:1f82672b8755 15717 * from page one register from 0x17 bit 3 to 5
gume 0:1f82672b8755 15718 *
gume 0:1f82672b8755 15719 * @param data_u8 : The value of gyro highrate enable
gume 0:1f82672b8755 15720 * data_u8 | result
gume 0:1f82672b8755 15721 * ---------------- |-------------
gume 0:1f82672b8755 15722 * 0x01 | BNO055_BIT_ENABLE
gume 0:1f82672b8755 15723 * 0x00 | BNO055_BIT_DISABLE
gume 0:1f82672b8755 15724 * @param channel_u8 : The value of gyro highrate axis selection
gume 0:1f82672b8755 15725 * channel_u8 | value
gume 0:1f82672b8755 15726 * ------------------------ | ----------
gume 0:1f82672b8755 15727 * BNO055_GYRO_HIGHRATE_X_AXIS | 0
gume 0:1f82672b8755 15728 * BNO055_GYRO_HIGHRATE_Y_AXIS | 1
gume 0:1f82672b8755 15729 * BNO055_GYRO_HIGHRATE_Z_AXIS | 2
gume 0:1f82672b8755 15730 *
gume 0:1f82672b8755 15731 * @return results of bus communication function
gume 0:1f82672b8755 15732 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 15733 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 15734 *
gume 0:1f82672b8755 15735 *
gume 0:1f82672b8755 15736 */
gume 0:1f82672b8755 15737 BNO055_RETURN_FUNCTION_TYPE bno055_set_gyro_highrate_axis_enable(
gume 0:1f82672b8755 15738 u8 channel_u8, u8 data_u8)
gume 0:1f82672b8755 15739 {
gume 0:1f82672b8755 15740 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15741 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 15742 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 15743 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 15744 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 15745 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 15746 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 15747 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 15748 } else {
gume 0:1f82672b8755 15749 /* The write operation effective only if the operation
gume 0:1f82672b8755 15750 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 15751 current operation mode and set the config mode */
gume 0:1f82672b8755 15752 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 15753 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 15754 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 15755 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 15756 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 15757 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 15758 /* Write page as one */
gume 0:1f82672b8755 15759 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 15760 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 15761 switch (channel_u8) {
gume 0:1f82672b8755 15762 case BNO055_GYRO_HIGHRATE_X_AXIS:
gume 0:1f82672b8755 15763 /* Write the value of
gume 0:1f82672b8755 15764 gyro highrate x enable*/
gume 0:1f82672b8755 15765 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 15766 (p_bno055->dev_addr,
gume 0:1f82672b8755 15767 BNO055_GYRO_HIGHRATE_X_AXIS_REG,
gume 0:1f82672b8755 15768 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15769 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 15770 data_u8r = BNO055_SET_BITSLICE
gume 0:1f82672b8755 15771 (data_u8r,
gume 0:1f82672b8755 15772 BNO055_GYRO_HIGHRATE_X_AXIS, data_u8);
gume 0:1f82672b8755 15773 com_rslt +=
gume 0:1f82672b8755 15774 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 15775 (p_bno055->dev_addr,
gume 0:1f82672b8755 15776 BNO055_GYRO_HIGHRATE_X_AXIS_REG,
gume 0:1f82672b8755 15777 &data_u8r,
gume 0:1f82672b8755 15778 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15779 }
gume 0:1f82672b8755 15780 break;
gume 0:1f82672b8755 15781 case BNO055_GYRO_HIGHRATE_Y_AXIS:
gume 0:1f82672b8755 15782 /* Write the value of
gume 0:1f82672b8755 15783 gyro highrate y enable*/
gume 0:1f82672b8755 15784 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 15785 (p_bno055->dev_addr,
gume 0:1f82672b8755 15786 BNO055_GYRO_HIGHRATE_Y_AXIS_REG,
gume 0:1f82672b8755 15787 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15788 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 15789 data_u8r =
gume 0:1f82672b8755 15790 BNO055_SET_BITSLICE(
gume 0:1f82672b8755 15791 data_u8r,
gume 0:1f82672b8755 15792 BNO055_GYRO_HIGHRATE_Y_AXIS, data_u8);
gume 0:1f82672b8755 15793 com_rslt +=
gume 0:1f82672b8755 15794 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 15795 (p_bno055->dev_addr,
gume 0:1f82672b8755 15796 BNO055_GYRO_HIGHRATE_Y_AXIS_REG,
gume 0:1f82672b8755 15797 &data_u8r,
gume 0:1f82672b8755 15798 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15799 }
gume 0:1f82672b8755 15800 break;
gume 0:1f82672b8755 15801 case BNO055_GYRO_HIGHRATE_Z_AXIS:
gume 0:1f82672b8755 15802 /* Write the value of
gume 0:1f82672b8755 15803 gyro highrate z enable*/
gume 0:1f82672b8755 15804 com_rslt =
gume 0:1f82672b8755 15805 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 15806 (p_bno055->dev_addr,
gume 0:1f82672b8755 15807 BNO055_GYRO_HIGHRATE_Z_AXIS_REG,
gume 0:1f82672b8755 15808 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15809 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 15810 data_u8r = BNO055_SET_BITSLICE
gume 0:1f82672b8755 15811 (data_u8r,
gume 0:1f82672b8755 15812 BNO055_GYRO_HIGHRATE_Z_AXIS, data_u8);
gume 0:1f82672b8755 15813 com_rslt +=
gume 0:1f82672b8755 15814 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 15815 (p_bno055->dev_addr,
gume 0:1f82672b8755 15816 BNO055_GYRO_HIGHRATE_Z_AXIS_REG,
gume 0:1f82672b8755 15817 &data_u8r,
gume 0:1f82672b8755 15818 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15819 }
gume 0:1f82672b8755 15820 break;
gume 0:1f82672b8755 15821 default:
gume 0:1f82672b8755 15822 com_rslt = BNO055_OUT_OF_RANGE;
gume 0:1f82672b8755 15823 break;
gume 0:1f82672b8755 15824 }
gume 0:1f82672b8755 15825 } else {
gume 0:1f82672b8755 15826 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15827 }
gume 0:1f82672b8755 15828 } else {
gume 0:1f82672b8755 15829 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15830 }
gume 0:1f82672b8755 15831 } else {
gume 0:1f82672b8755 15832 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15833 }
gume 0:1f82672b8755 15834 }
gume 0:1f82672b8755 15835 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 15836 /* set the operation mode of
gume 0:1f82672b8755 15837 previous operation mode*/
gume 0:1f82672b8755 15838 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 15839 (prev_opmode_u8);
gume 0:1f82672b8755 15840 return com_rslt;
gume 0:1f82672b8755 15841 }
gume 0:1f82672b8755 15842 /*!
gume 0:1f82672b8755 15843 * @brief This API used to read gyro anymotion filter
gume 0:1f82672b8755 15844 * from page one register from 0x17 bit 6
gume 0:1f82672b8755 15845 *
gume 0:1f82672b8755 15846 * @param gyro_any_motion_filter_u8 : The value of gyro anymotion filter
gume 0:1f82672b8755 15847 * gyro_any_motion_filter_u8 | result
gume 0:1f82672b8755 15848 * --------------------------- |------------
gume 0:1f82672b8755 15849 * 0x00 | BNO055_GYRO_FILTERED_CONFIG
gume 0:1f82672b8755 15850 * 0x01 | BNO055_GYRO_UNFILTERED_CONFIG
gume 0:1f82672b8755 15851 *
gume 0:1f82672b8755 15852 * @return results of bus communication function
gume 0:1f82672b8755 15853 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 15854 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 15855 *
gume 0:1f82672b8755 15856 */
gume 0:1f82672b8755 15857 BNO055_RETURN_FUNCTION_TYPE bno055_get_gyro_any_motion_filter(
gume 0:1f82672b8755 15858 u8 *gyro_any_motion_filter_u8)
gume 0:1f82672b8755 15859 {
gume 0:1f82672b8755 15860 /* Variable used to return value of
gume 0:1f82672b8755 15861 communication routine*/
gume 0:1f82672b8755 15862 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15863 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 15864 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 15865 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 15866 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 15867 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 15868 } else {
gume 0:1f82672b8755 15869 /*condition check for page, gyro anymotion filter is
gume 0:1f82672b8755 15870 available in the page one*/
gume 0:1f82672b8755 15871 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 15872 /* Write page as one */
gume 0:1f82672b8755 15873 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 15874 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 15875 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 15876 /* Read the value of gyro anymotion filter*/
gume 0:1f82672b8755 15877 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 15878 (p_bno055->dev_addr,
gume 0:1f82672b8755 15879 BNO055_GYRO_ANY_MOTION_FILTER_REG,
gume 0:1f82672b8755 15880 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15881 *gyro_any_motion_filter_u8 =
gume 0:1f82672b8755 15882 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 15883 BNO055_GYRO_ANY_MOTION_FILTER);
gume 0:1f82672b8755 15884 } else {
gume 0:1f82672b8755 15885 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15886 }
gume 0:1f82672b8755 15887 }
gume 0:1f82672b8755 15888 return com_rslt;
gume 0:1f82672b8755 15889 }
gume 0:1f82672b8755 15890 /*!
gume 0:1f82672b8755 15891 * @brief This API used to write gyro anymotion filter
gume 0:1f82672b8755 15892 * from page one register from 0x17 bit 6
gume 0:1f82672b8755 15893 *
gume 0:1f82672b8755 15894 * @param gyro_any_motion_filter_u8 : The value of gyro anymotion filter
gume 0:1f82672b8755 15895 * gyro_any_motion_filter_u8 | result
gume 0:1f82672b8755 15896 * --------------------------- |------------
gume 0:1f82672b8755 15897 * 0x00 | BNO055_GYRO_FILTERED_CONFIG
gume 0:1f82672b8755 15898 * 0x01 | BNO055_GYRO_UNFILTERED_CONFIG
gume 0:1f82672b8755 15899 *
gume 0:1f82672b8755 15900 * @return results of bus communication function
gume 0:1f82672b8755 15901 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 15902 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 15903 *
gume 0:1f82672b8755 15904 */
gume 0:1f82672b8755 15905 BNO055_RETURN_FUNCTION_TYPE bno055_set_gyro_any_motion_filter(
gume 0:1f82672b8755 15906 u8 gyro_any_motion_filter_u8)
gume 0:1f82672b8755 15907 {
gume 0:1f82672b8755 15908 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15909 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 15910 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 15911 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 15912 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 15913 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 15914 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 15915 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 15916 } else {
gume 0:1f82672b8755 15917 /* The write operation effective only if the operation
gume 0:1f82672b8755 15918 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 15919 current operation mode and set the config mode */
gume 0:1f82672b8755 15920 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 15921 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 15922 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 15923 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 15924 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 15925 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 15926 /* Write page as one */
gume 0:1f82672b8755 15927 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 15928 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 15929 /* Write the value of
gume 0:1f82672b8755 15930 gyro anymotion filter*/
gume 0:1f82672b8755 15931 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 15932 (p_bno055->dev_addr,
gume 0:1f82672b8755 15933 BNO055_GYRO_ANY_MOTION_FILTER_REG,
gume 0:1f82672b8755 15934 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15935 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 15936 data_u8r =
gume 0:1f82672b8755 15937 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 15938 BNO055_GYRO_ANY_MOTION_FILTER,
gume 0:1f82672b8755 15939 gyro_any_motion_filter_u8);
gume 0:1f82672b8755 15940 com_rslt +=
gume 0:1f82672b8755 15941 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 15942 (p_bno055->dev_addr,
gume 0:1f82672b8755 15943 BNO055_GYRO_ANY_MOTION_FILTER_REG,
gume 0:1f82672b8755 15944 &data_u8r,
gume 0:1f82672b8755 15945 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 15946 }
gume 0:1f82672b8755 15947 } else {
gume 0:1f82672b8755 15948 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15949 }
gume 0:1f82672b8755 15950 } else {
gume 0:1f82672b8755 15951 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15952 }
gume 0:1f82672b8755 15953 } else {
gume 0:1f82672b8755 15954 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15955 }
gume 0:1f82672b8755 15956 }
gume 0:1f82672b8755 15957 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 15958 /* set the operation mode of
gume 0:1f82672b8755 15959 previous operation mode*/
gume 0:1f82672b8755 15960 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 15961 (prev_opmode_u8);
gume 0:1f82672b8755 15962 return com_rslt;
gume 0:1f82672b8755 15963 }
gume 0:1f82672b8755 15964 /*!
gume 0:1f82672b8755 15965 * @brief This API used to read gyro highrate filter
gume 0:1f82672b8755 15966 * from page one register from 0x17 bit 7
gume 0:1f82672b8755 15967 *
gume 0:1f82672b8755 15968 * @param gyro_highrate_filter_u8 : The value of gyro highrate filter
gume 0:1f82672b8755 15969 * gyro_highrate_filter_u8 | result
gume 0:1f82672b8755 15970 * --------------------------- |------------
gume 0:1f82672b8755 15971 * 0x00 | BNO055_GYRO_FILTERED_CONFIG
gume 0:1f82672b8755 15972 * 0x01 | BNO055_GYRO_UNFILTERED_CONFIG
gume 0:1f82672b8755 15973 *
gume 0:1f82672b8755 15974 * @return results of bus communication function
gume 0:1f82672b8755 15975 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 15976 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 15977 *
gume 0:1f82672b8755 15978 */
gume 0:1f82672b8755 15979 BNO055_RETURN_FUNCTION_TYPE bno055_get_gyro_highrate_filter(
gume 0:1f82672b8755 15980 u8 *gyro_highrate_filter_u8)
gume 0:1f82672b8755 15981 {
gume 0:1f82672b8755 15982 /* Variable used to return value of
gume 0:1f82672b8755 15983 communication routine*/
gume 0:1f82672b8755 15984 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 15985 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 15986 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 15987 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 15988 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 15989 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 15990 } else {
gume 0:1f82672b8755 15991 /*condition check for page, gyro highrate filter is
gume 0:1f82672b8755 15992 available in the page one*/
gume 0:1f82672b8755 15993 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 15994 /* Write page as one */
gume 0:1f82672b8755 15995 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 15996 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 15997 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 15998 /* Read the value of gyro highrate filter */
gume 0:1f82672b8755 15999 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 16000 (p_bno055->dev_addr,
gume 0:1f82672b8755 16001 BNO055_GYRO_HIGHRATE_FILTER_REG,
gume 0:1f82672b8755 16002 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 16003 *gyro_highrate_filter_u8 =
gume 0:1f82672b8755 16004 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 16005 BNO055_GYRO_HIGHRATE_FILTER);
gume 0:1f82672b8755 16006 } else {
gume 0:1f82672b8755 16007 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16008 }
gume 0:1f82672b8755 16009 }
gume 0:1f82672b8755 16010 return com_rslt;
gume 0:1f82672b8755 16011 }
gume 0:1f82672b8755 16012 /*!
gume 0:1f82672b8755 16013 * @brief This API used to write gyro highrate filter
gume 0:1f82672b8755 16014 * from page one register from 0x17 bit 7
gume 0:1f82672b8755 16015 *
gume 0:1f82672b8755 16016 * @param gyro_highrate_filter_u8 : The value of gyro highrate filter
gume 0:1f82672b8755 16017 * gyro_highrate_filter_u8 | result
gume 0:1f82672b8755 16018 * --------------------------- |------------
gume 0:1f82672b8755 16019 * 0x00 | BNO055_GYRO_FILTERED_CONFIG
gume 0:1f82672b8755 16020 * 0x01 | BNO055_GYRO_UNFILTERED_CONFIG
gume 0:1f82672b8755 16021 *
gume 0:1f82672b8755 16022 * @return results of bus communication function
gume 0:1f82672b8755 16023 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 16024 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 16025 *
gume 0:1f82672b8755 16026 */
gume 0:1f82672b8755 16027 BNO055_RETURN_FUNCTION_TYPE bno055_set_gyro_highrate_filter(
gume 0:1f82672b8755 16028 u8 gyro_highrate_filter_u8)
gume 0:1f82672b8755 16029 {
gume 0:1f82672b8755 16030 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16031 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 16032 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 16033 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 16034 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 16035 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 16036 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 16037 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 16038 } else {
gume 0:1f82672b8755 16039 /* The write operation effective only if the operation
gume 0:1f82672b8755 16040 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 16041 current operation mode and set the config mode */
gume 0:1f82672b8755 16042 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 16043 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 16044 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 16045 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 16046 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 16047 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 16048 /* Write page as one */
gume 0:1f82672b8755 16049 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 16050 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 16051 /* Write the value of
gume 0:1f82672b8755 16052 gyro highrate filter*/
gume 0:1f82672b8755 16053 com_rslt =
gume 0:1f82672b8755 16054 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 16055 (p_bno055->dev_addr,
gume 0:1f82672b8755 16056 BNO055_GYRO_HIGHRATE_FILTER_REG,
gume 0:1f82672b8755 16057 &data_u8r,
gume 0:1f82672b8755 16058 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 16059 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 16060 data_u8r =
gume 0:1f82672b8755 16061 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 16062 BNO055_GYRO_HIGHRATE_FILTER,
gume 0:1f82672b8755 16063 gyro_highrate_filter_u8);
gume 0:1f82672b8755 16064 com_rslt +=
gume 0:1f82672b8755 16065 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 16066 (p_bno055->dev_addr,
gume 0:1f82672b8755 16067 BNO055_GYRO_HIGHRATE_FILTER_REG,
gume 0:1f82672b8755 16068 &data_u8r,
gume 0:1f82672b8755 16069 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 16070 }
gume 0:1f82672b8755 16071 } else {
gume 0:1f82672b8755 16072 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16073 }
gume 0:1f82672b8755 16074 } else {
gume 0:1f82672b8755 16075 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16076 }
gume 0:1f82672b8755 16077 } else {
gume 0:1f82672b8755 16078 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16079 }
gume 0:1f82672b8755 16080 }
gume 0:1f82672b8755 16081 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 16082 /* set the operation mode of
gume 0:1f82672b8755 16083 previous operation mode*/
gume 0:1f82672b8755 16084 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 16085 (prev_opmode_u8);
gume 0:1f82672b8755 16086 return com_rslt;
gume 0:1f82672b8755 16087 }
gume 0:1f82672b8755 16088 /*!
gume 0:1f82672b8755 16089 * @brief This API used to read gyro highrate x threshold
gume 0:1f82672b8755 16090 * from page one register from 0x18 bit 0 to 4
gume 0:1f82672b8755 16091 *
gume 0:1f82672b8755 16092 * @param gyro_highrate_x_thres_u8 : The value of gyro x highrate threshold
gume 0:1f82672b8755 16093 *
gume 0:1f82672b8755 16094 * @return results of bus communication function
gume 0:1f82672b8755 16095 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 16096 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 16097 *
gume 0:1f82672b8755 16098 * @note Gyro highrate threshold dependent on the
gume 0:1f82672b8755 16099 * selection of gyro range
gume 0:1f82672b8755 16100 *
gume 0:1f82672b8755 16101 * gyro_range_u8 | threshold | LSB
gume 0:1f82672b8755 16102 * ----------------- | ------------- | ---------
gume 0:1f82672b8755 16103 * 2000 | 62.5dps | 1LSB
gume 0:1f82672b8755 16104 * 1000 | 31.25dps | 1LSB
gume 0:1f82672b8755 16105 * 500 | 15.625dps | 1LSB
gume 0:1f82672b8755 16106 * 125 | 7.8125dps | 1LSB
gume 0:1f82672b8755 16107 *
gume 0:1f82672b8755 16108 */
gume 0:1f82672b8755 16109 BNO055_RETURN_FUNCTION_TYPE bno055_get_gyro_highrate_x_thres(
gume 0:1f82672b8755 16110 u8 *gyro_highrate_x_thres_u8)
gume 0:1f82672b8755 16111 {
gume 0:1f82672b8755 16112 /* Variable used to return value of
gume 0:1f82672b8755 16113 communication routine*/
gume 0:1f82672b8755 16114 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16115 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 16116 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 16117 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 16118 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 16119 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 16120 } else {
gume 0:1f82672b8755 16121 /*condition check for page, gyro highrate x threshold is
gume 0:1f82672b8755 16122 available in the page one*/
gume 0:1f82672b8755 16123 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 16124 /* Write page as one */
gume 0:1f82672b8755 16125 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 16126 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 16127 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 16128 /* Read the value of gyro highrate threshold*/
gume 0:1f82672b8755 16129 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 16130 (p_bno055->dev_addr,
gume 0:1f82672b8755 16131 BNO055_GYRO_HIGHRATE_X_THRES_REG,
gume 0:1f82672b8755 16132 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 16133 *gyro_highrate_x_thres_u8 =
gume 0:1f82672b8755 16134 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 16135 BNO055_GYRO_HIGHRATE_X_THRES);
gume 0:1f82672b8755 16136 } else {
gume 0:1f82672b8755 16137 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16138 }
gume 0:1f82672b8755 16139 }
gume 0:1f82672b8755 16140 return com_rslt;
gume 0:1f82672b8755 16141 }
gume 0:1f82672b8755 16142 /*!
gume 0:1f82672b8755 16143 * @brief This API used to write gyro highrate x threshold
gume 0:1f82672b8755 16144 * from page one register from 0x18 bit 0 to 4
gume 0:1f82672b8755 16145 *
gume 0:1f82672b8755 16146 * @param gyro_highrate_x_thres_u8 : The value of gyro x highrate threshold
gume 0:1f82672b8755 16147 *
gume 0:1f82672b8755 16148 * @return results of bus communication function
gume 0:1f82672b8755 16149 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 16150 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 16151 *
gume 0:1f82672b8755 16152 * @note Gyro highrate threshold dependent on the
gume 0:1f82672b8755 16153 * selection of gyro range
gume 0:1f82672b8755 16154 *
gume 0:1f82672b8755 16155 * gyro_range_u8 | threshold | LSB
gume 0:1f82672b8755 16156 * ----------------- | ------------- | ---------
gume 0:1f82672b8755 16157 * 2000 | 62.5dps | 1LSB
gume 0:1f82672b8755 16158 * 1000 | 31.25dps | 1LSB
gume 0:1f82672b8755 16159 * 500 | 15.625dps | 1LSB
gume 0:1f82672b8755 16160 * 125 | 7.8125dps | 1LSB
gume 0:1f82672b8755 16161 *
gume 0:1f82672b8755 16162 */
gume 0:1f82672b8755 16163 BNO055_RETURN_FUNCTION_TYPE bno055_set_gyro_highrate_x_thres(
gume 0:1f82672b8755 16164 u8 gyro_highrate_x_thres_u8)
gume 0:1f82672b8755 16165 {
gume 0:1f82672b8755 16166 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16167 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 16168 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 16169 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 16170 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 16171 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 16172 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 16173 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 16174 } else {
gume 0:1f82672b8755 16175 /* The write operation effective only if the operation
gume 0:1f82672b8755 16176 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 16177 current operation mode and set the config mode */
gume 0:1f82672b8755 16178 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 16179 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 16180 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 16181 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 16182 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 16183 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 16184 /* Write page as one */
gume 0:1f82672b8755 16185 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 16186 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 16187 /* Write the value of
gume 0:1f82672b8755 16188 gyro highrate x threshold*/
gume 0:1f82672b8755 16189 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 16190 (p_bno055->dev_addr,
gume 0:1f82672b8755 16191 BNO055_GYRO_HIGHRATE_X_THRES_REG,
gume 0:1f82672b8755 16192 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 16193 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 16194 data_u8r =
gume 0:1f82672b8755 16195 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 16196 BNO055_GYRO_HIGHRATE_X_THRES,
gume 0:1f82672b8755 16197 gyro_highrate_x_thres_u8);
gume 0:1f82672b8755 16198 com_rslt +=
gume 0:1f82672b8755 16199 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 16200 (p_bno055->dev_addr,
gume 0:1f82672b8755 16201 BNO055_GYRO_HIGHRATE_X_THRES_REG,
gume 0:1f82672b8755 16202 &data_u8r,
gume 0:1f82672b8755 16203 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 16204 }
gume 0:1f82672b8755 16205 } else {
gume 0:1f82672b8755 16206 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16207 }
gume 0:1f82672b8755 16208 } else {
gume 0:1f82672b8755 16209 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16210 }
gume 0:1f82672b8755 16211 } else {
gume 0:1f82672b8755 16212 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16213 }
gume 0:1f82672b8755 16214 }
gume 0:1f82672b8755 16215 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 16216 /* set the operation mode of
gume 0:1f82672b8755 16217 previous operation mode*/
gume 0:1f82672b8755 16218 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 16219 (prev_opmode_u8);
gume 0:1f82672b8755 16220 return com_rslt;
gume 0:1f82672b8755 16221 }
gume 0:1f82672b8755 16222 /*!
gume 0:1f82672b8755 16223 * @brief This API used to read gyro highrate x hysteresis
gume 0:1f82672b8755 16224 * from page one register from 0x18 bit 5 to 6
gume 0:1f82672b8755 16225 *
gume 0:1f82672b8755 16226 * @param gyro_highrate_x_hyst_u8 : The value of gyro highrate x hysteresis
gume 0:1f82672b8755 16227 *
gume 0:1f82672b8755 16228 * @return results of bus communication function
gume 0:1f82672b8755 16229 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 16230 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 16231 *
gume 0:1f82672b8755 16232 * @note Gyro high rate hysteresis calculated by
gume 0:1f82672b8755 16233 *
gume 0:1f82672b8755 16234 * using this (255 + 256 * gyro_highrate_x_hyst_u8) *4 LSB
gume 0:1f82672b8755 16235 *
gume 0:1f82672b8755 16236 * The high rate value scales with the range setting
gume 0:1f82672b8755 16237 *
gume 0:1f82672b8755 16238 * gyro_range_u8 | hysteresis | LSB
gume 0:1f82672b8755 16239 * ----------------- | ------------- | ---------
gume 0:1f82672b8755 16240 * 2000 | 62.26dps | 1LSB
gume 0:1f82672b8755 16241 * 1000 | 31.13dps | 1LSB
gume 0:1f82672b8755 16242 * 500 | 15.56dps | 1LSB
gume 0:1f82672b8755 16243 *
gume 0:1f82672b8755 16244 */
gume 0:1f82672b8755 16245 BNO055_RETURN_FUNCTION_TYPE bno055_get_gyro_highrate_x_hyst(
gume 0:1f82672b8755 16246 u8 *gyro_highrate_x_hyst_u8)
gume 0:1f82672b8755 16247 {
gume 0:1f82672b8755 16248 /* Variable used to return value of
gume 0:1f82672b8755 16249 communication routine*/
gume 0:1f82672b8755 16250 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16251 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 16252 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 16253 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 16254 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 16255 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 16256 } else {
gume 0:1f82672b8755 16257 /*condition check for page,gyro highrate x hysteresis is
gume 0:1f82672b8755 16258 available in the page one*/
gume 0:1f82672b8755 16259 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 16260 /* Write page as one */
gume 0:1f82672b8755 16261 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 16262 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 16263 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 16264 /* Read the value of gyro highrate x hysteresis*/
gume 0:1f82672b8755 16265 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 16266 (p_bno055->dev_addr,
gume 0:1f82672b8755 16267 BNO055_GYRO_HIGHRATE_X_HYST_REG,
gume 0:1f82672b8755 16268 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 16269 *gyro_highrate_x_hyst_u8 =
gume 0:1f82672b8755 16270 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 16271 BNO055_GYRO_HIGHRATE_X_HYST);
gume 0:1f82672b8755 16272 } else {
gume 0:1f82672b8755 16273 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16274 }
gume 0:1f82672b8755 16275 }
gume 0:1f82672b8755 16276 return com_rslt;
gume 0:1f82672b8755 16277 }
gume 0:1f82672b8755 16278 /*!
gume 0:1f82672b8755 16279 * @brief This API used to write gyro highrate x hysteresis
gume 0:1f82672b8755 16280 * from page one register from 0x18 bit 5 to 6
gume 0:1f82672b8755 16281 *
gume 0:1f82672b8755 16282 * @param gyro_highrate_x_hyst_u8 : The value of gyro highrate x hysteresis
gume 0:1f82672b8755 16283 *
gume 0:1f82672b8755 16284 * @return results of bus communication function
gume 0:1f82672b8755 16285 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 16286 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 16287 *
gume 0:1f82672b8755 16288 * @note Gyro high rate hysteresis calculated by
gume 0:1f82672b8755 16289 *
gume 0:1f82672b8755 16290 * using this (255 + 256 * gyro_highrate_x_hyst_u8) *4 LSB
gume 0:1f82672b8755 16291 *
gume 0:1f82672b8755 16292 * The high rate value scales with the range setting
gume 0:1f82672b8755 16293 *
gume 0:1f82672b8755 16294 * gyro_range_u8 | hysteresis | LSB
gume 0:1f82672b8755 16295 * ----------------- | ------------- | ---------
gume 0:1f82672b8755 16296 * 2000 | 62.26dps | 1LSB
gume 0:1f82672b8755 16297 * 1000 | 31.13dps | 1LSB
gume 0:1f82672b8755 16298 * 500 | 15.56dps | 1LSB
gume 0:1f82672b8755 16299 *
gume 0:1f82672b8755 16300 */
gume 0:1f82672b8755 16301 BNO055_RETURN_FUNCTION_TYPE bno055_set_gyro_highrate_x_hyst(
gume 0:1f82672b8755 16302 u8 gyro_highrate_x_hyst_u8)
gume 0:1f82672b8755 16303 {
gume 0:1f82672b8755 16304 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16305 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 16306 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 16307 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 16308 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 16309 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 16310 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 16311 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 16312 } else {
gume 0:1f82672b8755 16313 /* The write operation effective only if the operation
gume 0:1f82672b8755 16314 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 16315 current operation mode and set the config mode */
gume 0:1f82672b8755 16316 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 16317 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 16318 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 16319 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 16320 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 16321 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 16322 /* Write page as one */
gume 0:1f82672b8755 16323 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 16324 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 16325 /*Write the value of
gume 0:1f82672b8755 16326 gyro highrate x hysteresis*/
gume 0:1f82672b8755 16327 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 16328 (p_bno055->dev_addr,
gume 0:1f82672b8755 16329 BNO055_GYRO_HIGHRATE_X_HYST_REG,
gume 0:1f82672b8755 16330 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 16331 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 16332 data_u8r =
gume 0:1f82672b8755 16333 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 16334 BNO055_GYRO_HIGHRATE_X_HYST,
gume 0:1f82672b8755 16335 gyro_highrate_x_hyst_u8);
gume 0:1f82672b8755 16336 com_rslt +=
gume 0:1f82672b8755 16337 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 16338 (p_bno055->dev_addr,
gume 0:1f82672b8755 16339 BNO055_GYRO_HIGHRATE_X_HYST_REG,
gume 0:1f82672b8755 16340 &data_u8r,
gume 0:1f82672b8755 16341 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 16342 }
gume 0:1f82672b8755 16343 } else {
gume 0:1f82672b8755 16344 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16345 }
gume 0:1f82672b8755 16346 } else {
gume 0:1f82672b8755 16347 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16348 }
gume 0:1f82672b8755 16349 } else {
gume 0:1f82672b8755 16350 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16351 }
gume 0:1f82672b8755 16352 }
gume 0:1f82672b8755 16353 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 16354 /* set the operation mode of
gume 0:1f82672b8755 16355 previous operation mode*/
gume 0:1f82672b8755 16356 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 16357 (prev_opmode_u8);
gume 0:1f82672b8755 16358 return com_rslt;
gume 0:1f82672b8755 16359 }
gume 0:1f82672b8755 16360 /*!
gume 0:1f82672b8755 16361 * @brief This API used to read gyro highrate x duration
gume 0:1f82672b8755 16362 * from page one register from 0x19 bit 0 to 7
gume 0:1f82672b8755 16363 *
gume 0:1f82672b8755 16364 * @param gyro_highrate_x_durn_u8 : The value of gyro highrate x duration
gume 0:1f82672b8755 16365 *
gume 0:1f82672b8755 16366 * @return results of bus communication function
gume 0:1f82672b8755 16367 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 16368 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 16369 *
gume 0:1f82672b8755 16370 * @note Gyro highrate duration calculate by using the formula
gume 0:1f82672b8755 16371 *
gume 0:1f82672b8755 16372 * (1 + gyro_highrate_x_durn_u8)*2.5ms
gume 0:1f82672b8755 16373 *
gume 0:1f82672b8755 16374 */
gume 0:1f82672b8755 16375 BNO055_RETURN_FUNCTION_TYPE bno055_get_gyro_highrate_x_durn(
gume 0:1f82672b8755 16376 u8 *gyro_highrate_x_durn_u8)
gume 0:1f82672b8755 16377 {
gume 0:1f82672b8755 16378 /* Variable used to return value of
gume 0:1f82672b8755 16379 communication routine*/
gume 0:1f82672b8755 16380 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16381 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 16382 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 16383 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 16384 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 16385 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 16386 } else {
gume 0:1f82672b8755 16387 /*condition check for page, gyro highrate x duration is
gume 0:1f82672b8755 16388 available in the page one*/
gume 0:1f82672b8755 16389 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 16390 /* Write page as one */
gume 0:1f82672b8755 16391 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 16392 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 16393 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 16394 /* Read the value of gyro highrate x duration*/
gume 0:1f82672b8755 16395 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 16396 (p_bno055->dev_addr,
gume 0:1f82672b8755 16397 BNO055_GYRO_HIGHRATE_X_DURN_REG,
gume 0:1f82672b8755 16398 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 16399 *gyro_highrate_x_durn_u8 =
gume 0:1f82672b8755 16400 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 16401 BNO055_GYRO_HIGHRATE_X_DURN);
gume 0:1f82672b8755 16402 } else {
gume 0:1f82672b8755 16403 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16404 }
gume 0:1f82672b8755 16405 }
gume 0:1f82672b8755 16406 return com_rslt;
gume 0:1f82672b8755 16407 }
gume 0:1f82672b8755 16408 /*!
gume 0:1f82672b8755 16409 * @brief This API used to write gyro highrate x duration
gume 0:1f82672b8755 16410 * from page one register from 0x19 bit 0 to 7
gume 0:1f82672b8755 16411 *
gume 0:1f82672b8755 16412 * @param gyro_highrate_x_durn_u8 : The value of gyro highrate x duration
gume 0:1f82672b8755 16413 *
gume 0:1f82672b8755 16414 * @return results of bus communication function
gume 0:1f82672b8755 16415 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 16416 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 16417 *
gume 0:1f82672b8755 16418 * @note Gyro highrate duration calculate by using the formula
gume 0:1f82672b8755 16419 *
gume 0:1f82672b8755 16420 * (1 + gyro_highrate_x_durn_u8)*2.5ms
gume 0:1f82672b8755 16421 */
gume 0:1f82672b8755 16422 BNO055_RETURN_FUNCTION_TYPE bno055_set_gyro_highrate_x_durn(
gume 0:1f82672b8755 16423 u8 gyro_highrate_x_durn_u8)
gume 0:1f82672b8755 16424 {
gume 0:1f82672b8755 16425 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16426 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 16427 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 16428 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 16429 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 16430 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 16431 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 16432 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 16433 } else {
gume 0:1f82672b8755 16434 /* The write operation effective only if the operation
gume 0:1f82672b8755 16435 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 16436 current operation mode and set the config mode */
gume 0:1f82672b8755 16437 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 16438 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 16439 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 16440 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 16441 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 16442 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 16443 /* Write page as one */
gume 0:1f82672b8755 16444 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 16445 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 16446 /* Write the value
gume 0:1f82672b8755 16447 of gyro highrate x duration*/
gume 0:1f82672b8755 16448 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 16449 (p_bno055->dev_addr,
gume 0:1f82672b8755 16450 BNO055_GYRO_HIGHRATE_X_DURN_REG,
gume 0:1f82672b8755 16451 &data_u8r,
gume 0:1f82672b8755 16452 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 16453 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 16454 data_u8r =
gume 0:1f82672b8755 16455 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 16456 BNO055_GYRO_HIGHRATE_X_DURN,
gume 0:1f82672b8755 16457 gyro_highrate_x_durn_u8);
gume 0:1f82672b8755 16458 com_rslt +=
gume 0:1f82672b8755 16459 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 16460 (p_bno055->dev_addr,
gume 0:1f82672b8755 16461 BNO055_GYRO_HIGHRATE_X_DURN_REG,
gume 0:1f82672b8755 16462 &data_u8r,
gume 0:1f82672b8755 16463 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 16464 }
gume 0:1f82672b8755 16465 } else {
gume 0:1f82672b8755 16466 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16467 }
gume 0:1f82672b8755 16468 } else {
gume 0:1f82672b8755 16469 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16470 }
gume 0:1f82672b8755 16471 } else {
gume 0:1f82672b8755 16472 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16473 }
gume 0:1f82672b8755 16474 }
gume 0:1f82672b8755 16475 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 16476 /* set the operation mode of
gume 0:1f82672b8755 16477 previous operation mode*/
gume 0:1f82672b8755 16478 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 16479 (prev_opmode_u8);
gume 0:1f82672b8755 16480 return com_rslt;
gume 0:1f82672b8755 16481 }
gume 0:1f82672b8755 16482 /*!
gume 0:1f82672b8755 16483 * @brief This API used to read gyro highrate y threshold
gume 0:1f82672b8755 16484 * from page one register from 0x1A bit 0 to 4
gume 0:1f82672b8755 16485 *
gume 0:1f82672b8755 16486 * @param gyro_highrate_y_thres_u8 : The value of gyro highrate y threshold
gume 0:1f82672b8755 16487 *
gume 0:1f82672b8755 16488 * @return results of bus communication function
gume 0:1f82672b8755 16489 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 16490 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 16491 *
gume 0:1f82672b8755 16492 * @note Gyro highrate threshold dependent on the
gume 0:1f82672b8755 16493 * selection of gyro range
gume 0:1f82672b8755 16494 *
gume 0:1f82672b8755 16495 * gyro_range_u8 | threshold | LSB
gume 0:1f82672b8755 16496 * ----------------- | ------------- | ---------
gume 0:1f82672b8755 16497 * 2000 | 62.5dps | 1LSB
gume 0:1f82672b8755 16498 * 1000 | 31.25dps | 1LSB
gume 0:1f82672b8755 16499 * 500 | 15.625dps | 1LSB
gume 0:1f82672b8755 16500 * 125 | 7.8125dps | 1LSB
gume 0:1f82672b8755 16501 *
gume 0:1f82672b8755 16502 */
gume 0:1f82672b8755 16503 BNO055_RETURN_FUNCTION_TYPE bno055_get_gyro_highrate_y_thres(
gume 0:1f82672b8755 16504 u8 *gyro_highrate_y_thres_u8)
gume 0:1f82672b8755 16505 {
gume 0:1f82672b8755 16506 /* Variable used to return value of
gume 0:1f82672b8755 16507 communication routine*/
gume 0:1f82672b8755 16508 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16509 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 16510 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 16511 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 16512 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 16513 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 16514 } else {
gume 0:1f82672b8755 16515 /*condition check for page, gyro highrate y threshold is
gume 0:1f82672b8755 16516 available in the page one*/
gume 0:1f82672b8755 16517 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 16518 /* Write page as one */
gume 0:1f82672b8755 16519 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 16520 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 16521 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 16522 /* Read the value of gyro highrate y threshold*/
gume 0:1f82672b8755 16523 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 16524 (p_bno055->dev_addr,
gume 0:1f82672b8755 16525 BNO055_GYRO_HIGHRATE_Y_THRES_REG,
gume 0:1f82672b8755 16526 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 16527 *gyro_highrate_y_thres_u8 =
gume 0:1f82672b8755 16528 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 16529 BNO055_GYRO_HIGHRATE_Y_THRES);
gume 0:1f82672b8755 16530 } else {
gume 0:1f82672b8755 16531 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16532 }
gume 0:1f82672b8755 16533 }
gume 0:1f82672b8755 16534 return com_rslt;
gume 0:1f82672b8755 16535 }
gume 0:1f82672b8755 16536 /*!
gume 0:1f82672b8755 16537 * @brief This API used to write gyro highrate y threshold
gume 0:1f82672b8755 16538 * from page one register from 0x1A bit 0 to 4
gume 0:1f82672b8755 16539 *
gume 0:1f82672b8755 16540 * @param gyro_highrate_y_thres_u8 : The value of gyro highrate y threshold
gume 0:1f82672b8755 16541 *
gume 0:1f82672b8755 16542 * @return results of bus communication function
gume 0:1f82672b8755 16543 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 16544 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 16545 *
gume 0:1f82672b8755 16546 * @note Gyro highrate threshold dependent on the
gume 0:1f82672b8755 16547 * selection of gyro range
gume 0:1f82672b8755 16548 *
gume 0:1f82672b8755 16549 * gyro_range_u8 | threshold | LSB
gume 0:1f82672b8755 16550 * ----------------- | ------------- | ---------
gume 0:1f82672b8755 16551 * 2000 | 62.5dps | 1LSB
gume 0:1f82672b8755 16552 * 1000 | 31.25dps | 1LSB
gume 0:1f82672b8755 16553 * 500 | 15.625dps | 1LSB
gume 0:1f82672b8755 16554 * 125 | 7.8125dps | 1LSB
gume 0:1f82672b8755 16555 *
gume 0:1f82672b8755 16556 */
gume 0:1f82672b8755 16557 BNO055_RETURN_FUNCTION_TYPE bno055_set_gyro_highrate_y_thres(
gume 0:1f82672b8755 16558 u8 gyro_highrate_y_thres_u8)
gume 0:1f82672b8755 16559 {
gume 0:1f82672b8755 16560 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16561 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 16562 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 16563 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 16564 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 16565 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 16566 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 16567 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 16568 } else {
gume 0:1f82672b8755 16569 /* The write operation effective only if the operation
gume 0:1f82672b8755 16570 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 16571 current operation mode and set the config mode */
gume 0:1f82672b8755 16572 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 16573 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 16574 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 16575 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 16576 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 16577 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 16578 /* Write page as one */
gume 0:1f82672b8755 16579 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 16580 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 16581 /* Write the value
gume 0:1f82672b8755 16582 of gyro highrate y threshold*/
gume 0:1f82672b8755 16583 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 16584 (p_bno055->dev_addr,
gume 0:1f82672b8755 16585 BNO055_GYRO_HIGHRATE_Y_THRES_REG,
gume 0:1f82672b8755 16586 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 16587 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 16588 data_u8r =
gume 0:1f82672b8755 16589 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 16590 BNO055_GYRO_HIGHRATE_Y_THRES,
gume 0:1f82672b8755 16591 gyro_highrate_y_thres_u8);
gume 0:1f82672b8755 16592 com_rslt +=
gume 0:1f82672b8755 16593 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 16594 (p_bno055->dev_addr,
gume 0:1f82672b8755 16595 BNO055_GYRO_HIGHRATE_Y_THRES_REG,
gume 0:1f82672b8755 16596 &data_u8r,
gume 0:1f82672b8755 16597 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 16598 }
gume 0:1f82672b8755 16599 } else {
gume 0:1f82672b8755 16600 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16601 }
gume 0:1f82672b8755 16602 } else {
gume 0:1f82672b8755 16603 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16604 }
gume 0:1f82672b8755 16605 } else {
gume 0:1f82672b8755 16606 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16607 }
gume 0:1f82672b8755 16608 }
gume 0:1f82672b8755 16609 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 16610 /* set the operation mode of
gume 0:1f82672b8755 16611 previous operation mode*/
gume 0:1f82672b8755 16612 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 16613 (prev_opmode_u8);
gume 0:1f82672b8755 16614 return com_rslt;
gume 0:1f82672b8755 16615 }
gume 0:1f82672b8755 16616 /*!
gume 0:1f82672b8755 16617 * @brief This API used to read gyro highrate y hysteresis
gume 0:1f82672b8755 16618 * from page one register from 0x1A bit 5 to 6
gume 0:1f82672b8755 16619 *
gume 0:1f82672b8755 16620 * @param gyro_highrate_y_hyst_u8 : The value of gyro highrate y hysteresis
gume 0:1f82672b8755 16621 *
gume 0:1f82672b8755 16622 * @return results of bus communication function
gume 0:1f82672b8755 16623 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 16624 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 16625 *
gume 0:1f82672b8755 16626 * @note Gyro high rate hysteresis calculated by
gume 0:1f82672b8755 16627 *
gume 0:1f82672b8755 16628 * using this (255 + 256 * gyro_highrate_y_hyst_u8) *4 LSB
gume 0:1f82672b8755 16629 *
gume 0:1f82672b8755 16630 * The high rate value scales with the range setting
gume 0:1f82672b8755 16631 *
gume 0:1f82672b8755 16632 * gyro_range_u8 | hysteresis | LSB
gume 0:1f82672b8755 16633 * ----------------- | ------------- | ---------
gume 0:1f82672b8755 16634 * 2000 | 62.26dps | 1LSB
gume 0:1f82672b8755 16635 * 1000 | 31.13dps | 1LSB
gume 0:1f82672b8755 16636 * 500 | 15.56dps | 1LSB
gume 0:1f82672b8755 16637 */
gume 0:1f82672b8755 16638 BNO055_RETURN_FUNCTION_TYPE bno055_get_gyro_highrate_y_hyst(
gume 0:1f82672b8755 16639 u8 *gyro_highrate_y_hyst_u8)
gume 0:1f82672b8755 16640 {
gume 0:1f82672b8755 16641 /* Variable used to return value of
gume 0:1f82672b8755 16642 communication routine*/
gume 0:1f82672b8755 16643 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16644 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 16645 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 16646 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 16647 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 16648 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 16649 } else {
gume 0:1f82672b8755 16650 /*condition check for page, gyro highrate y hysteresis is
gume 0:1f82672b8755 16651 available in the page one*/
gume 0:1f82672b8755 16652 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 16653 /* Write page as one */
gume 0:1f82672b8755 16654 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 16655 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 16656 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 16657 /* Read the value of gyro highrate y hysteresis*/
gume 0:1f82672b8755 16658 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 16659 (p_bno055->dev_addr,
gume 0:1f82672b8755 16660 BNO055_GYRO_HIGHRATE_Y_HYST_REG,
gume 0:1f82672b8755 16661 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 16662 *gyro_highrate_y_hyst_u8 =
gume 0:1f82672b8755 16663 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 16664 BNO055_GYRO_HIGHRATE_Y_HYST);
gume 0:1f82672b8755 16665 } else {
gume 0:1f82672b8755 16666 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16667 }
gume 0:1f82672b8755 16668 }
gume 0:1f82672b8755 16669 return com_rslt;
gume 0:1f82672b8755 16670 }
gume 0:1f82672b8755 16671 /*!
gume 0:1f82672b8755 16672 * @brief This API used to write gyro highrate y hysteresis
gume 0:1f82672b8755 16673 * from page one register from 0x1A bit 5 to 6
gume 0:1f82672b8755 16674 *
gume 0:1f82672b8755 16675 * @param gyro_highrate_y_hyst_u8 : The value of gyro highrate y hysteresis
gume 0:1f82672b8755 16676 *
gume 0:1f82672b8755 16677 * @return results of bus communication function
gume 0:1f82672b8755 16678 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 16679 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 16680 *
gume 0:1f82672b8755 16681 * @note Gyro high rate hysteresis calculated by
gume 0:1f82672b8755 16682 *
gume 0:1f82672b8755 16683 * using this (255 + 256 * gyro_highrate_y_hyst_u8) *4 LSB
gume 0:1f82672b8755 16684 *
gume 0:1f82672b8755 16685 * The high rate value scales with the range setting
gume 0:1f82672b8755 16686 *
gume 0:1f82672b8755 16687 * gyro_range_u8 | hysteresis | LSB
gume 0:1f82672b8755 16688 * ----------------- | ------------- | ---------
gume 0:1f82672b8755 16689 * 2000 | 62.26dps | 1LSB
gume 0:1f82672b8755 16690 * 1000 | 31.13dps | 1LSB
gume 0:1f82672b8755 16691 * 500 | 15.56dps | 1LSB
gume 0:1f82672b8755 16692 */
gume 0:1f82672b8755 16693 BNO055_RETURN_FUNCTION_TYPE bno055_set_gyro_highrate_y_hyst(
gume 0:1f82672b8755 16694 u8 gyro_highrate_y_hyst_u8)
gume 0:1f82672b8755 16695 {
gume 0:1f82672b8755 16696 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16697 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 16698 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 16699 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 16700 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 16701 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 16702 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 16703 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 16704 } else {
gume 0:1f82672b8755 16705 /* The write operation effective only if the operation
gume 0:1f82672b8755 16706 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 16707 current operation mode and set the config mode */
gume 0:1f82672b8755 16708 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 16709 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 16710 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 16711 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 16712 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 16713 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 16714 /* Write page as one */
gume 0:1f82672b8755 16715 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 16716 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 16717 /* Write the value of
gume 0:1f82672b8755 16718 gyro highrate y hysteresis*/
gume 0:1f82672b8755 16719 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 16720 (p_bno055->dev_addr,
gume 0:1f82672b8755 16721 BNO055_GYRO_HIGHRATE_Y_HYST_REG,
gume 0:1f82672b8755 16722 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 16723 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 16724 data_u8r =
gume 0:1f82672b8755 16725 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 16726 BNO055_GYRO_HIGHRATE_Y_HYST,
gume 0:1f82672b8755 16727 gyro_highrate_y_hyst_u8);
gume 0:1f82672b8755 16728 com_rslt +=
gume 0:1f82672b8755 16729 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 16730 (p_bno055->dev_addr,
gume 0:1f82672b8755 16731 BNO055_GYRO_HIGHRATE_Y_HYST_REG,
gume 0:1f82672b8755 16732 &data_u8r,
gume 0:1f82672b8755 16733 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 16734 }
gume 0:1f82672b8755 16735 } else {
gume 0:1f82672b8755 16736 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16737 }
gume 0:1f82672b8755 16738 } else {
gume 0:1f82672b8755 16739 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16740 }
gume 0:1f82672b8755 16741 } else {
gume 0:1f82672b8755 16742 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16743 }
gume 0:1f82672b8755 16744 }
gume 0:1f82672b8755 16745 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 16746 /* set the operation mode of
gume 0:1f82672b8755 16747 previous operation mode*/
gume 0:1f82672b8755 16748 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 16749 (prev_opmode_u8);
gume 0:1f82672b8755 16750 return com_rslt;
gume 0:1f82672b8755 16751 }
gume 0:1f82672b8755 16752 /*!
gume 0:1f82672b8755 16753 * @brief This API used to read gyro highrate y duration
gume 0:1f82672b8755 16754 * from page one register from 0x1B bit 0 to 7
gume 0:1f82672b8755 16755 *
gume 0:1f82672b8755 16756 * @param gyro_highrate_y_durn_u8 : The value of gyro highrate y duration
gume 0:1f82672b8755 16757 *
gume 0:1f82672b8755 16758 * @return results of bus communication function
gume 0:1f82672b8755 16759 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 16760 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 16761 *
gume 0:1f82672b8755 16762 * @note Gyro highrate duration calculate by using the formula
gume 0:1f82672b8755 16763 *
gume 0:1f82672b8755 16764 * (1 + gyro_highrate_y_durn_u8)*2.5ms
gume 0:1f82672b8755 16765 */
gume 0:1f82672b8755 16766 BNO055_RETURN_FUNCTION_TYPE bno055_get_gyro_highrate_y_durn(
gume 0:1f82672b8755 16767 u8 *gyro_highrate_y_durn_u8)
gume 0:1f82672b8755 16768 {
gume 0:1f82672b8755 16769 /* Variable used to return value of
gume 0:1f82672b8755 16770 communication routine*/
gume 0:1f82672b8755 16771 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16772 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 16773 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 16774 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 16775 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 16776 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 16777 } else {
gume 0:1f82672b8755 16778 /*condition check for page, gyro highrate y duration is
gume 0:1f82672b8755 16779 available in the page one*/
gume 0:1f82672b8755 16780 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 16781 /* Write page as one */
gume 0:1f82672b8755 16782 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 16783 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 16784 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 16785 /* Read the value of gyro highrate y duration*/
gume 0:1f82672b8755 16786 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 16787 (p_bno055->dev_addr,
gume 0:1f82672b8755 16788 BNO055_GYRO_HIGHRATE_Y_DURN_REG,
gume 0:1f82672b8755 16789 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 16790 *gyro_highrate_y_durn_u8 =
gume 0:1f82672b8755 16791 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 16792 BNO055_GYRO_HIGHRATE_Y_DURN);
gume 0:1f82672b8755 16793 } else {
gume 0:1f82672b8755 16794 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16795 }
gume 0:1f82672b8755 16796 }
gume 0:1f82672b8755 16797 return com_rslt;
gume 0:1f82672b8755 16798 }
gume 0:1f82672b8755 16799 /*!
gume 0:1f82672b8755 16800 * @brief This API used to write gyro highrate y duration
gume 0:1f82672b8755 16801 * from page one register from 0x1B bit 0 to 7
gume 0:1f82672b8755 16802 *
gume 0:1f82672b8755 16803 * @param gyro_highrate_y_durn_u8 : The value of gyro highrate y duration
gume 0:1f82672b8755 16804 *
gume 0:1f82672b8755 16805 * @return results of bus communication function
gume 0:1f82672b8755 16806 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 16807 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 16808 *
gume 0:1f82672b8755 16809 * @note Gyro highrate duration calculate by using the formula
gume 0:1f82672b8755 16810 *
gume 0:1f82672b8755 16811 * (1 + gyro_highrate_y_durn_u8)*2.5ms
gume 0:1f82672b8755 16812 */
gume 0:1f82672b8755 16813 BNO055_RETURN_FUNCTION_TYPE bno055_set_gyro_highrate_y_durn(
gume 0:1f82672b8755 16814 u8 gyro_highrate_y_durn_u8)
gume 0:1f82672b8755 16815 {
gume 0:1f82672b8755 16816 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16817 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 16818 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 16819 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 16820 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 16821 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 16822 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 16823 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 16824 } else {
gume 0:1f82672b8755 16825 /* The write operation effective only if the operation
gume 0:1f82672b8755 16826 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 16827 current operation mode and set the config mode */
gume 0:1f82672b8755 16828 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 16829 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 16830 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 16831 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 16832 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 16833
gume 0:1f82672b8755 16834 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 16835 /* Write page as one */
gume 0:1f82672b8755 16836 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 16837 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 16838 /* Write the value
gume 0:1f82672b8755 16839 of gyro highrate y duration*/
gume 0:1f82672b8755 16840 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 16841 (p_bno055->dev_addr,
gume 0:1f82672b8755 16842 BNO055_GYRO_HIGHRATE_Y_DURN_REG,
gume 0:1f82672b8755 16843 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 16844 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 16845 data_u8r =
gume 0:1f82672b8755 16846 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 16847 BNO055_GYRO_HIGHRATE_Y_DURN,
gume 0:1f82672b8755 16848 gyro_highrate_y_durn_u8);
gume 0:1f82672b8755 16849 com_rslt +=
gume 0:1f82672b8755 16850 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 16851 (p_bno055->dev_addr,
gume 0:1f82672b8755 16852 BNO055_GYRO_HIGHRATE_Y_DURN_REG,
gume 0:1f82672b8755 16853 &data_u8r,
gume 0:1f82672b8755 16854 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 16855 }
gume 0:1f82672b8755 16856 } else {
gume 0:1f82672b8755 16857 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16858 }
gume 0:1f82672b8755 16859 } else {
gume 0:1f82672b8755 16860 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16861 }
gume 0:1f82672b8755 16862 } else {
gume 0:1f82672b8755 16863 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16864 }
gume 0:1f82672b8755 16865 }
gume 0:1f82672b8755 16866 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 16867 /* set the operation mode of
gume 0:1f82672b8755 16868 previous operation mode*/
gume 0:1f82672b8755 16869 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 16870 (prev_opmode_u8);
gume 0:1f82672b8755 16871 return com_rslt;
gume 0:1f82672b8755 16872 }
gume 0:1f82672b8755 16873 /*!
gume 0:1f82672b8755 16874 * @brief This API used to read gyro highrate z threshold
gume 0:1f82672b8755 16875 * from page one register from 0x1C bit 0 to 4
gume 0:1f82672b8755 16876 *
gume 0:1f82672b8755 16877 * @param gyro_highrate_z_thres_u8 : The value of gyro highrate z threshold
gume 0:1f82672b8755 16878 *
gume 0:1f82672b8755 16879 * @return results of bus communication function
gume 0:1f82672b8755 16880 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 16881 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 16882 *
gume 0:1f82672b8755 16883 * @note Gyro highrate threshold dependent on the
gume 0:1f82672b8755 16884 * selection of gyro range
gume 0:1f82672b8755 16885 *
gume 0:1f82672b8755 16886 * gyro_range_u8 | threshold | LSB
gume 0:1f82672b8755 16887 * ----------------- | ------------- | ---------
gume 0:1f82672b8755 16888 * 2000 | 62.5dps | 1LSB
gume 0:1f82672b8755 16889 * 1000 | 31.25dps | 1LSB
gume 0:1f82672b8755 16890 * 500 | 15.625dps | 1LSB
gume 0:1f82672b8755 16891 * 125 | 7.8125dps | 1LSB
gume 0:1f82672b8755 16892 *
gume 0:1f82672b8755 16893 */
gume 0:1f82672b8755 16894 BNO055_RETURN_FUNCTION_TYPE bno055_get_gyro_highrate_z_thres(
gume 0:1f82672b8755 16895 u8 *gyro_highrate_z_thres_u8)
gume 0:1f82672b8755 16896 {
gume 0:1f82672b8755 16897 /* Variable used to return value of
gume 0:1f82672b8755 16898 communication routine*/
gume 0:1f82672b8755 16899 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16900 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 16901 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 16902 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 16903 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 16904 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 16905 } else {
gume 0:1f82672b8755 16906 /*condition check for page, gyro highrate z threshold is
gume 0:1f82672b8755 16907 available in the page one*/
gume 0:1f82672b8755 16908 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 16909 /* Write page as one */
gume 0:1f82672b8755 16910 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 16911 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 16912 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 16913 /* Read the value of gyro highrate z threshold*/
gume 0:1f82672b8755 16914 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 16915 (p_bno055->dev_addr,
gume 0:1f82672b8755 16916 BNO055_GYRO_HIGHRATE_Z_THRES_REG,
gume 0:1f82672b8755 16917 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 16918 *gyro_highrate_z_thres_u8 =
gume 0:1f82672b8755 16919 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 16920 BNO055_GYRO_HIGHRATE_Z_THRES);
gume 0:1f82672b8755 16921 } else {
gume 0:1f82672b8755 16922 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16923 }
gume 0:1f82672b8755 16924 }
gume 0:1f82672b8755 16925 return com_rslt;
gume 0:1f82672b8755 16926 }
gume 0:1f82672b8755 16927 /*!
gume 0:1f82672b8755 16928 * @brief This API used to write gyro highrate z threshold
gume 0:1f82672b8755 16929 * from page one register from 0x1C bit 0 to 4
gume 0:1f82672b8755 16930 *
gume 0:1f82672b8755 16931 * @param gyro_highrate_z_thres_u8 : The value of gyro highrate z threshold
gume 0:1f82672b8755 16932 *
gume 0:1f82672b8755 16933 * @return results of bus communication function
gume 0:1f82672b8755 16934 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 16935 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 16936 *
gume 0:1f82672b8755 16937 * @note Gyro highrate threshold dependent on the
gume 0:1f82672b8755 16938 * selection of gyro range
gume 0:1f82672b8755 16939 *
gume 0:1f82672b8755 16940 * gyro_range_u8 | threshold | LSB
gume 0:1f82672b8755 16941 * ----------------- | ------------- | ---------
gume 0:1f82672b8755 16942 * 2000 | 62.5dps | 1LSB
gume 0:1f82672b8755 16943 * 1000 | 31.25dps | 1LSB
gume 0:1f82672b8755 16944 * 500 | 15.625dps | 1LSB
gume 0:1f82672b8755 16945 * 125 | 7.8125dps | 1LSB
gume 0:1f82672b8755 16946 *
gume 0:1f82672b8755 16947 */
gume 0:1f82672b8755 16948 BNO055_RETURN_FUNCTION_TYPE bno055_set_gyro_highrate_z_thres(
gume 0:1f82672b8755 16949 u8 gyro_highrate_z_thres_u8)
gume 0:1f82672b8755 16950 {
gume 0:1f82672b8755 16951 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16952 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 16953 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 16954 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 16955 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 16956 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 16957 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 16958 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 16959 } else {
gume 0:1f82672b8755 16960 /* The write operation effective only if the operation
gume 0:1f82672b8755 16961 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 16962 current operation mode and set the config mode */
gume 0:1f82672b8755 16963 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 16964 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 16965 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 16966 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 16967 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 16968 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 16969 /* Write page as one */
gume 0:1f82672b8755 16970 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 16971 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 16972 /* Write the value
gume 0:1f82672b8755 16973 of gyro highrate z threshold*/
gume 0:1f82672b8755 16974 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 16975 (p_bno055->dev_addr,
gume 0:1f82672b8755 16976 BNO055_GYRO_HIGHRATE_Z_THRES_REG,
gume 0:1f82672b8755 16977 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 16978 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 16979 data_u8r =
gume 0:1f82672b8755 16980 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 16981 BNO055_GYRO_HIGHRATE_Z_THRES,
gume 0:1f82672b8755 16982 gyro_highrate_z_thres_u8);
gume 0:1f82672b8755 16983 com_rslt +=
gume 0:1f82672b8755 16984 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 16985 (p_bno055->dev_addr,
gume 0:1f82672b8755 16986 BNO055_GYRO_HIGHRATE_Z_THRES_REG,
gume 0:1f82672b8755 16987 &data_u8r,
gume 0:1f82672b8755 16988 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 16989 }
gume 0:1f82672b8755 16990 } else {
gume 0:1f82672b8755 16991 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16992 }
gume 0:1f82672b8755 16993 } else {
gume 0:1f82672b8755 16994 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16995 }
gume 0:1f82672b8755 16996 } else {
gume 0:1f82672b8755 16997 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 16998 }
gume 0:1f82672b8755 16999 }
gume 0:1f82672b8755 17000 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 17001 /* set the operation mode of
gume 0:1f82672b8755 17002 previous operation mode*/
gume 0:1f82672b8755 17003 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 17004 (prev_opmode_u8);
gume 0:1f82672b8755 17005 return com_rslt;
gume 0:1f82672b8755 17006 }
gume 0:1f82672b8755 17007 /*!
gume 0:1f82672b8755 17008 * @brief This API used to read gyro highrate z hysteresis
gume 0:1f82672b8755 17009 * from page one register from 0x1C bit 5 to 6
gume 0:1f82672b8755 17010 *
gume 0:1f82672b8755 17011 * @param gyro_highrate_z_hyst_u8 : The value of gyro highrate z hysteresis
gume 0:1f82672b8755 17012 *
gume 0:1f82672b8755 17013 * @return results of bus communication function
gume 0:1f82672b8755 17014 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 17015 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 17016 *
gume 0:1f82672b8755 17017 * @note Gyro high rate hysteresis calculated by
gume 0:1f82672b8755 17018 *
gume 0:1f82672b8755 17019 * using this (255 + 256 * gyro_highrate_z_hyst_u8) *4 LSB
gume 0:1f82672b8755 17020 *
gume 0:1f82672b8755 17021 * The high rate value scales with the range setting
gume 0:1f82672b8755 17022 *
gume 0:1f82672b8755 17023 * gyro_range_u8 | hysteresis | LSB
gume 0:1f82672b8755 17024 * ----------------- | ------------- | ---------
gume 0:1f82672b8755 17025 * 2000 | 62.26dps | 1LSB
gume 0:1f82672b8755 17026 * 1000 | 31.13dps | 1LSB
gume 0:1f82672b8755 17027 * 500 | 15.56dps | 1LSB
gume 0:1f82672b8755 17028 */
gume 0:1f82672b8755 17029 BNO055_RETURN_FUNCTION_TYPE bno055_get_gyro_highrate_z_hyst(
gume 0:1f82672b8755 17030 u8 *gyro_highrate_z_hyst_u8)
gume 0:1f82672b8755 17031 {
gume 0:1f82672b8755 17032 /* Variable used to return value of
gume 0:1f82672b8755 17033 communication routine*/
gume 0:1f82672b8755 17034 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17035 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 17036 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 17037 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 17038 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 17039 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 17040 } else {
gume 0:1f82672b8755 17041 /*condition check for page, gyro highrate z hysteresis is
gume 0:1f82672b8755 17042 available in the page one*/
gume 0:1f82672b8755 17043 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 17044 /* Write page as one */
gume 0:1f82672b8755 17045 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 17046 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 17047 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 17048 /* Read the value of gyro highrate z hysteresis*/
gume 0:1f82672b8755 17049 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 17050 (p_bno055->dev_addr,
gume 0:1f82672b8755 17051 BNO055_GYRO_HIGHRATE_Z_HYST_REG,
gume 0:1f82672b8755 17052 &data_u8r,
gume 0:1f82672b8755 17053 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 17054 *gyro_highrate_z_hyst_u8 =
gume 0:1f82672b8755 17055 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 17056 BNO055_GYRO_HIGHRATE_Z_HYST);
gume 0:1f82672b8755 17057 } else {
gume 0:1f82672b8755 17058 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17059 }
gume 0:1f82672b8755 17060 }
gume 0:1f82672b8755 17061 return com_rslt;
gume 0:1f82672b8755 17062 }
gume 0:1f82672b8755 17063 /*!
gume 0:1f82672b8755 17064 * @brief This API used to write gyro highrate z hysteresis
gume 0:1f82672b8755 17065 * from page one register from 0x1C bit 5 to 6
gume 0:1f82672b8755 17066 *
gume 0:1f82672b8755 17067 * @param gyro_highrate_z_hyst_u8 : The value of gyro highrate z hysteresis
gume 0:1f82672b8755 17068 *
gume 0:1f82672b8755 17069 * @return results of bus communication function
gume 0:1f82672b8755 17070 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 17071 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 17072 *
gume 0:1f82672b8755 17073 * @note Gyro high rate hysteresis calculated by
gume 0:1f82672b8755 17074 *
gume 0:1f82672b8755 17075 * using this (255 + 256 * gyro_highrate_z_hyst_u8) *4 LSB
gume 0:1f82672b8755 17076 *
gume 0:1f82672b8755 17077 * The high rate value scales with the range setting
gume 0:1f82672b8755 17078 *
gume 0:1f82672b8755 17079 * gyro_range_u8 | hysteresis | LSB
gume 0:1f82672b8755 17080 * ----------------- | ------------- | ---------
gume 0:1f82672b8755 17081 * 2000 | 62.26dps | 1LSB
gume 0:1f82672b8755 17082 * 1000 | 31.13dps | 1LSB
gume 0:1f82672b8755 17083 * 500 | 15.56dps | 1LSB
gume 0:1f82672b8755 17084 */
gume 0:1f82672b8755 17085 BNO055_RETURN_FUNCTION_TYPE bno055_set_gyro_highrate_z_hyst(
gume 0:1f82672b8755 17086 u8 gyro_highrate_z_hyst_u8)
gume 0:1f82672b8755 17087 {
gume 0:1f82672b8755 17088 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17089 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 17090 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 17091 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 17092 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 17093 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 17094 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 17095 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 17096 } else {
gume 0:1f82672b8755 17097 /* The write operation effective only if the operation
gume 0:1f82672b8755 17098 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 17099 current operation mode and set the config mode */
gume 0:1f82672b8755 17100 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 17101 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 17102 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 17103 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 17104 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 17105 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 17106 /* Write page as one */
gume 0:1f82672b8755 17107 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 17108 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 17109 /* Write the value
gume 0:1f82672b8755 17110 of gyro highrate z hysteresis*/
gume 0:1f82672b8755 17111 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 17112 (p_bno055->dev_addr,
gume 0:1f82672b8755 17113 BNO055_GYRO_HIGHRATE_Z_HYST_REG,
gume 0:1f82672b8755 17114 &data_u8r,
gume 0:1f82672b8755 17115 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 17116 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 17117 data_u8r =
gume 0:1f82672b8755 17118 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 17119 BNO055_GYRO_HIGHRATE_Z_HYST,
gume 0:1f82672b8755 17120 gyro_highrate_z_hyst_u8);
gume 0:1f82672b8755 17121 com_rslt +=
gume 0:1f82672b8755 17122 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 17123 (p_bno055->dev_addr,
gume 0:1f82672b8755 17124 BNO055_GYRO_HIGHRATE_Z_HYST_REG,
gume 0:1f82672b8755 17125 &data_u8r,
gume 0:1f82672b8755 17126 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 17127 }
gume 0:1f82672b8755 17128 } else {
gume 0:1f82672b8755 17129 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17130 }
gume 0:1f82672b8755 17131 } else {
gume 0:1f82672b8755 17132 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17133 }
gume 0:1f82672b8755 17134 } else {
gume 0:1f82672b8755 17135 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17136 }
gume 0:1f82672b8755 17137 }
gume 0:1f82672b8755 17138 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 17139 /* set the operation mode of
gume 0:1f82672b8755 17140 previous operation mode*/
gume 0:1f82672b8755 17141 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 17142 (prev_opmode_u8);
gume 0:1f82672b8755 17143 return com_rslt;
gume 0:1f82672b8755 17144 }
gume 0:1f82672b8755 17145 /*!
gume 0:1f82672b8755 17146 * @brief This API used to read gyro highrate z duration
gume 0:1f82672b8755 17147 * from page one register from 0x1D bit 0 to 7
gume 0:1f82672b8755 17148 *
gume 0:1f82672b8755 17149 * @param gyro_highrate_z_durn_u8 : The value of gyro highrate z duration
gume 0:1f82672b8755 17150 *
gume 0:1f82672b8755 17151 * @return results of bus communication function
gume 0:1f82672b8755 17152 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 17153 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 17154 *
gume 0:1f82672b8755 17155 * @note Gyro highrate duration calculate by using the formula
gume 0:1f82672b8755 17156 *
gume 0:1f82672b8755 17157 * (1 + gyro_highrate_z_durn_u8)*2.5ms
gume 0:1f82672b8755 17158 */
gume 0:1f82672b8755 17159 BNO055_RETURN_FUNCTION_TYPE bno055_get_gyro_highrate_z_durn(
gume 0:1f82672b8755 17160 u8 *gyro_highrate_z_durn_u8)
gume 0:1f82672b8755 17161 {
gume 0:1f82672b8755 17162 /* Variable used to return value of
gume 0:1f82672b8755 17163 communication routine*/
gume 0:1f82672b8755 17164 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17165 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 17166 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 17167 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 17168 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 17169 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 17170 } else {
gume 0:1f82672b8755 17171 /*condition check for page, gyro highrate z duration is
gume 0:1f82672b8755 17172 available in the page one*/
gume 0:1f82672b8755 17173 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 17174 /* Write page as one */
gume 0:1f82672b8755 17175 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 17176 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 17177 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 17178 /* Read the value of gyro highrate z duration*/
gume 0:1f82672b8755 17179 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 17180 (p_bno055->dev_addr,
gume 0:1f82672b8755 17181 BNO055_GYRO_HIGHRATE_Z_DURN_REG,
gume 0:1f82672b8755 17182 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 17183 *gyro_highrate_z_durn_u8 =
gume 0:1f82672b8755 17184 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 17185 BNO055_GYRO_HIGHRATE_Z_DURN);
gume 0:1f82672b8755 17186 } else {
gume 0:1f82672b8755 17187 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17188 }
gume 0:1f82672b8755 17189 }
gume 0:1f82672b8755 17190 return com_rslt;
gume 0:1f82672b8755 17191 }
gume 0:1f82672b8755 17192 /*!
gume 0:1f82672b8755 17193 * @brief This API used to write gyro highrate z duration
gume 0:1f82672b8755 17194 * from page one register from 0x1D bit 0 to 7
gume 0:1f82672b8755 17195 *
gume 0:1f82672b8755 17196 * @param gyro_highrate_z_durn_u8 : The value of gyro highrate z duration
gume 0:1f82672b8755 17197 *
gume 0:1f82672b8755 17198 * @return results of bus communication function
gume 0:1f82672b8755 17199 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 17200 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 17201 *
gume 0:1f82672b8755 17202 * @note Gyro highrate duration calculate by using the formula
gume 0:1f82672b8755 17203 *
gume 0:1f82672b8755 17204 * (1 + gyro_highrate_z_durn_u8)*2.5ms
gume 0:1f82672b8755 17205 */
gume 0:1f82672b8755 17206 BNO055_RETURN_FUNCTION_TYPE bno055_set_gyro_highrate_z_durn(
gume 0:1f82672b8755 17207 u8 gyro_highrate_z_durn_u8)
gume 0:1f82672b8755 17208 {
gume 0:1f82672b8755 17209 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17210 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 17211 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 17212 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 17213 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 17214 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 17215 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 17216 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 17217 } else {
gume 0:1f82672b8755 17218 /* The write operation effective only if the operation
gume 0:1f82672b8755 17219 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 17220 current operation mode and set the config mode */
gume 0:1f82672b8755 17221 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 17222 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 17223 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 17224 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 17225 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 17226 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 17227 /* Write page as one */
gume 0:1f82672b8755 17228 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 17229 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 17230 /* Write the value of
gume 0:1f82672b8755 17231 gyro highrate z duration*/
gume 0:1f82672b8755 17232 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 17233 (p_bno055->dev_addr,
gume 0:1f82672b8755 17234 BNO055_GYRO_HIGHRATE_Z_DURN_REG,
gume 0:1f82672b8755 17235 &data_u8r,
gume 0:1f82672b8755 17236 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 17237 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 17238 data_u8r =
gume 0:1f82672b8755 17239 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 17240 BNO055_GYRO_HIGHRATE_Z_DURN,
gume 0:1f82672b8755 17241 gyro_highrate_z_durn_u8);
gume 0:1f82672b8755 17242 com_rslt +=
gume 0:1f82672b8755 17243 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 17244 (p_bno055->dev_addr,
gume 0:1f82672b8755 17245 BNO055_GYRO_HIGHRATE_Z_DURN_REG,
gume 0:1f82672b8755 17246 &data_u8r,
gume 0:1f82672b8755 17247 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 17248 }
gume 0:1f82672b8755 17249 } else {
gume 0:1f82672b8755 17250 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17251 }
gume 0:1f82672b8755 17252 } else {
gume 0:1f82672b8755 17253 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17254 }
gume 0:1f82672b8755 17255 } else {
gume 0:1f82672b8755 17256 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17257 }
gume 0:1f82672b8755 17258 }
gume 0:1f82672b8755 17259 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 17260 /* set the operation mode of
gume 0:1f82672b8755 17261 previous operation mode*/
gume 0:1f82672b8755 17262 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 17263 (prev_opmode_u8);
gume 0:1f82672b8755 17264 return com_rslt;
gume 0:1f82672b8755 17265 }
gume 0:1f82672b8755 17266 /*!
gume 0:1f82672b8755 17267 * @brief This API used to read gyro anymotion threshold
gume 0:1f82672b8755 17268 * from page one register from 0x1E bit 0 to 6
gume 0:1f82672b8755 17269 *
gume 0:1f82672b8755 17270 * @param gyro_any_motion_thres_u8 : The value of gyro anymotion threshold
gume 0:1f82672b8755 17271 *
gume 0:1f82672b8755 17272 * @return results of bus communication function
gume 0:1f82672b8755 17273 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 17274 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 17275 *
gume 0:1f82672b8755 17276 * @note Gyro anymotion interrupt threshold dependent
gume 0:1f82672b8755 17277 * on the selection of gyro range
gume 0:1f82672b8755 17278 *
gume 0:1f82672b8755 17279 * gyro_range_u8 | threshold | LSB
gume 0:1f82672b8755 17280 * ----------------- | ------------- | ---------
gume 0:1f82672b8755 17281 * 2000 | 1dps | 1LSB
gume 0:1f82672b8755 17282 * 1000 | 0.5dps | 1LSB
gume 0:1f82672b8755 17283 * 500 | 0.25dps | 1LSB
gume 0:1f82672b8755 17284 *
gume 0:1f82672b8755 17285 */
gume 0:1f82672b8755 17286 BNO055_RETURN_FUNCTION_TYPE bno055_get_gyro_any_motion_thres(
gume 0:1f82672b8755 17287 u8 *gyro_any_motion_thres_u8)
gume 0:1f82672b8755 17288 {
gume 0:1f82672b8755 17289 /* Variable used to return value of
gume 0:1f82672b8755 17290 communication routine*/
gume 0:1f82672b8755 17291 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17292 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 17293 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 17294 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 17295 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 17296 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 17297 } else {
gume 0:1f82672b8755 17298 /*condition check for page,gyro anymotion threshold is
gume 0:1f82672b8755 17299 available in the page one*/
gume 0:1f82672b8755 17300 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 17301 /* Write page as one */
gume 0:1f82672b8755 17302 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 17303 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 17304 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 17305 /* Read the value of gyro anymotion threshold*/
gume 0:1f82672b8755 17306 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 17307 (p_bno055->dev_addr,
gume 0:1f82672b8755 17308 BNO055_GYRO_ANY_MOTION_THRES_REG,
gume 0:1f82672b8755 17309 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 17310 *gyro_any_motion_thres_u8 =
gume 0:1f82672b8755 17311 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 17312 BNO055_GYRO_ANY_MOTION_THRES);
gume 0:1f82672b8755 17313 } else {
gume 0:1f82672b8755 17314 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17315 }
gume 0:1f82672b8755 17316 }
gume 0:1f82672b8755 17317 return com_rslt;
gume 0:1f82672b8755 17318 }
gume 0:1f82672b8755 17319 /*!
gume 0:1f82672b8755 17320 * @brief This API used to write gyro anymotion threshold
gume 0:1f82672b8755 17321 * from page one register from 0x1E bit 0 to 6
gume 0:1f82672b8755 17322 *
gume 0:1f82672b8755 17323 * @param gyro_any_motion_thres_u8 : The value of gyro anymotion threshold
gume 0:1f82672b8755 17324 *
gume 0:1f82672b8755 17325 * @return results of bus communication function
gume 0:1f82672b8755 17326 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 17327 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 17328 *
gume 0:1f82672b8755 17329 * @note Gyro anymotion interrupt threshold dependent
gume 0:1f82672b8755 17330 * on the selection of gyro range
gume 0:1f82672b8755 17331 *
gume 0:1f82672b8755 17332 * gyro_range_u8 | threshold | LSB
gume 0:1f82672b8755 17333 * ----------------- | ------------- | ---------
gume 0:1f82672b8755 17334 * 2000 | 1dps | 1LSB
gume 0:1f82672b8755 17335 * 1000 | 0.5dps | 1LSB
gume 0:1f82672b8755 17336 * 500 | 0.25dps | 1LSB
gume 0:1f82672b8755 17337 *
gume 0:1f82672b8755 17338 */
gume 0:1f82672b8755 17339 BNO055_RETURN_FUNCTION_TYPE bno055_set_gyro_any_motion_thres(
gume 0:1f82672b8755 17340 u8 gyro_any_motion_thres_u8)
gume 0:1f82672b8755 17341 {
gume 0:1f82672b8755 17342 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17343 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 17344 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 17345 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 17346 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 17347 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 17348 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 17349 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 17350 } else {
gume 0:1f82672b8755 17351 /* The write operation effective only if the operation
gume 0:1f82672b8755 17352 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 17353 current operation mode and set the config mode */
gume 0:1f82672b8755 17354 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 17355 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 17356 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 17357 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 17358 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 17359 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 17360 /* Write page as one */
gume 0:1f82672b8755 17361 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 17362 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 17363 /* Write the value
gume 0:1f82672b8755 17364 of gyro anymotion threshold*/
gume 0:1f82672b8755 17365 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 17366 (p_bno055->dev_addr,
gume 0:1f82672b8755 17367 BNO055_GYRO_ANY_MOTION_THRES_REG,
gume 0:1f82672b8755 17368 &data_u8r,
gume 0:1f82672b8755 17369 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 17370 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 17371 data_u8r =
gume 0:1f82672b8755 17372 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 17373 BNO055_GYRO_ANY_MOTION_THRES,
gume 0:1f82672b8755 17374 gyro_any_motion_thres_u8);
gume 0:1f82672b8755 17375 com_rslt +=
gume 0:1f82672b8755 17376 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 17377 (p_bno055->dev_addr,
gume 0:1f82672b8755 17378 BNO055_GYRO_ANY_MOTION_THRES_REG,
gume 0:1f82672b8755 17379 &data_u8r,
gume 0:1f82672b8755 17380 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 17381 }
gume 0:1f82672b8755 17382 } else {
gume 0:1f82672b8755 17383 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17384 }
gume 0:1f82672b8755 17385 } else {
gume 0:1f82672b8755 17386 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17387 }
gume 0:1f82672b8755 17388 } else {
gume 0:1f82672b8755 17389 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17390 }
gume 0:1f82672b8755 17391 }
gume 0:1f82672b8755 17392 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 17393 /* set the operation mode of
gume 0:1f82672b8755 17394 previous operation mode*/
gume 0:1f82672b8755 17395 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 17396 (prev_opmode_u8);
gume 0:1f82672b8755 17397 return com_rslt;
gume 0:1f82672b8755 17398 }
gume 0:1f82672b8755 17399 /*!
gume 0:1f82672b8755 17400 * @brief This API used to read gyro anymotion slope samples
gume 0:1f82672b8755 17401 * from page one register from 0x1F bit 0 to 1
gume 0:1f82672b8755 17402 *
gume 0:1f82672b8755 17403 * @param gyro_any_motion_slope_samples_u8 :
gume 0:1f82672b8755 17404 * The value of gyro anymotion slope samples
gume 0:1f82672b8755 17405 * gyro_any_motion_slope_samples_u8 | result
gume 0:1f82672b8755 17406 * ---------------------------------- | -----------
gume 0:1f82672b8755 17407 * 0 | 8 samples
gume 0:1f82672b8755 17408 * 1 | 16 samples
gume 0:1f82672b8755 17409 * 2 | 32 samples
gume 0:1f82672b8755 17410 * 3 | 64 samples
gume 0:1f82672b8755 17411 *
gume 0:1f82672b8755 17412 * @return results of bus communication function
gume 0:1f82672b8755 17413 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 17414 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 17415 *
gume 0:1f82672b8755 17416 */
gume 0:1f82672b8755 17417 BNO055_RETURN_FUNCTION_TYPE bno055_get_gyro_any_motion_slope_samples(
gume 0:1f82672b8755 17418 u8 *gyro_any_motion_slope_samples_u8)
gume 0:1f82672b8755 17419 {
gume 0:1f82672b8755 17420 /* Variable used to return value of
gume 0:1f82672b8755 17421 communication routine*/
gume 0:1f82672b8755 17422 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17423 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 17424 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 17425 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 17426 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 17427 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 17428 } else {
gume 0:1f82672b8755 17429 /*condition check for page, gyro anymotion slope samples is
gume 0:1f82672b8755 17430 available in the page one*/
gume 0:1f82672b8755 17431 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 17432 /* Write page as one */
gume 0:1f82672b8755 17433 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 17434 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 17435 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 17436 /*Read the value of gyro anymotion slope samples*/
gume 0:1f82672b8755 17437 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 17438 (p_bno055->dev_addr,
gume 0:1f82672b8755 17439 BNO055_GYRO_SLOPE_SAMPLES_REG,
gume 0:1f82672b8755 17440 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 17441 *gyro_any_motion_slope_samples_u8 =
gume 0:1f82672b8755 17442 BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 17443 BNO055_GYRO_SLOPE_SAMPLES);
gume 0:1f82672b8755 17444 } else {
gume 0:1f82672b8755 17445 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17446 }
gume 0:1f82672b8755 17447 }
gume 0:1f82672b8755 17448 return com_rslt;
gume 0:1f82672b8755 17449 }
gume 0:1f82672b8755 17450 /*!
gume 0:1f82672b8755 17451 * @brief This API used to write gyro anymotion slope samples
gume 0:1f82672b8755 17452 * from page one register from 0x1F bit 0 to 1
gume 0:1f82672b8755 17453 *
gume 0:1f82672b8755 17454 * @param gyro_any_motion_slope_samples_u8 :
gume 0:1f82672b8755 17455 * The value of gyro anymotion slope samples
gume 0:1f82672b8755 17456 * gyro_any_motion_slope_samples_u8 | result
gume 0:1f82672b8755 17457 * ---------------------------------- | -----------
gume 0:1f82672b8755 17458 * 0 | 8 samples
gume 0:1f82672b8755 17459 * 1 | 16 samples
gume 0:1f82672b8755 17460 * 2 | 32 samples
gume 0:1f82672b8755 17461 * 3 | 64 samples
gume 0:1f82672b8755 17462 *
gume 0:1f82672b8755 17463 * @return results of bus communication function
gume 0:1f82672b8755 17464 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 17465 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 17466 *
gume 0:1f82672b8755 17467 */
gume 0:1f82672b8755 17468 BNO055_RETURN_FUNCTION_TYPE bno055_set_gyro_any_motion_slope_samples(
gume 0:1f82672b8755 17469 u8 gyro_any_motion_slope_samples_u8)
gume 0:1f82672b8755 17470 {
gume 0:1f82672b8755 17471 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17472 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 17473 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 17474 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 17475 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 17476 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 17477 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 17478 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 17479 } else {
gume 0:1f82672b8755 17480 /* The write operation effective only if the operation
gume 0:1f82672b8755 17481 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 17482 current operation mode and set the config mode */
gume 0:1f82672b8755 17483 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 17484 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 17485 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 17486 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 17487 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 17488 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 17489 /* Write page as one */
gume 0:1f82672b8755 17490 pg_stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 17491 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 17492 /* Write the value of
gume 0:1f82672b8755 17493 gyro anymotion slope samples*/
gume 0:1f82672b8755 17494 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 17495 (p_bno055->dev_addr,
gume 0:1f82672b8755 17496 BNO055_GYRO_SLOPE_SAMPLES_REG,
gume 0:1f82672b8755 17497 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 17498 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 17499 data_u8r =
gume 0:1f82672b8755 17500 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 17501 BNO055_GYRO_SLOPE_SAMPLES,
gume 0:1f82672b8755 17502 gyro_any_motion_slope_samples_u8);
gume 0:1f82672b8755 17503 com_rslt +=
gume 0:1f82672b8755 17504 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 17505 (p_bno055->dev_addr,
gume 0:1f82672b8755 17506 BNO055_GYRO_SLOPE_SAMPLES_REG,
gume 0:1f82672b8755 17507 &data_u8r,
gume 0:1f82672b8755 17508 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 17509 }
gume 0:1f82672b8755 17510 } else {
gume 0:1f82672b8755 17511 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17512 }
gume 0:1f82672b8755 17513 } else {
gume 0:1f82672b8755 17514 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17515 }
gume 0:1f82672b8755 17516 } else {
gume 0:1f82672b8755 17517 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17518 }
gume 0:1f82672b8755 17519 }
gume 0:1f82672b8755 17520 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 17521 /* set the operation mode of
gume 0:1f82672b8755 17522 previous operation mode*/
gume 0:1f82672b8755 17523 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 17524 (prev_opmode_u8);
gume 0:1f82672b8755 17525 return com_rslt;
gume 0:1f82672b8755 17526 }
gume 0:1f82672b8755 17527 /*!
gume 0:1f82672b8755 17528 * @brief This API used to read gyro anymotion awake duration
gume 0:1f82672b8755 17529 * from page one register from 0x1F bit 2 to 3
gume 0:1f82672b8755 17530 *
gume 0:1f82672b8755 17531 * @param gyro_awake_durn_u8 : The value of gyro anymotion awake duration
gume 0:1f82672b8755 17532 *
gume 0:1f82672b8755 17533 * @return results of bus communication function
gume 0:1f82672b8755 17534 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 17535 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 17536 *
gume 0:1f82672b8755 17537 */
gume 0:1f82672b8755 17538 BNO055_RETURN_FUNCTION_TYPE bno055_get_gyro_any_motion_awake_durn(
gume 0:1f82672b8755 17539 u8 *gyro_awake_durn_u8)
gume 0:1f82672b8755 17540 {
gume 0:1f82672b8755 17541 /* Variable used to return value of
gume 0:1f82672b8755 17542 communication routine*/
gume 0:1f82672b8755 17543 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17544 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 17545 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 17546 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 17547 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 17548 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 17549 } else {
gume 0:1f82672b8755 17550 /*condition check for page, gyro anymotion awake duration is
gume 0:1f82672b8755 17551 available in the page one*/
gume 0:1f82672b8755 17552 if (p_bno055->page_id != BNO055_PAGE_ONE)
gume 0:1f82672b8755 17553 /* Write page as one */
gume 0:1f82672b8755 17554 stat_s8 = bno055_write_page_id(BNO055_PAGE_ONE);
gume 0:1f82672b8755 17555 if ((stat_s8 == BNO055_SUCCESS) ||
gume 0:1f82672b8755 17556 (p_bno055->page_id == BNO055_PAGE_ONE)) {
gume 0:1f82672b8755 17557 /* Read the value of gyro anymotion awake duration*/
gume 0:1f82672b8755 17558 com_rslt = p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 17559 (p_bno055->dev_addr,
gume 0:1f82672b8755 17560 BNO055_GYRO_AWAKE_DURN_REG,
gume 0:1f82672b8755 17561 &data_u8r, BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 17562 *gyro_awake_durn_u8 = BNO055_GET_BITSLICE(data_u8r,
gume 0:1f82672b8755 17563 BNO055_GYRO_AWAKE_DURN);
gume 0:1f82672b8755 17564 } else {
gume 0:1f82672b8755 17565 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17566 }
gume 0:1f82672b8755 17567 }
gume 0:1f82672b8755 17568 return com_rslt;
gume 0:1f82672b8755 17569 }
gume 0:1f82672b8755 17570 /*!
gume 0:1f82672b8755 17571 * @brief This API used to write gyro anymotion awake duration
gume 0:1f82672b8755 17572 * from page one register from 0x1F bit 2 to 3
gume 0:1f82672b8755 17573 *
gume 0:1f82672b8755 17574 * @param gyro_awake_durn_u8 : The value of gyro anymotion awake duration
gume 0:1f82672b8755 17575 *
gume 0:1f82672b8755 17576 * @return results of bus communication function
gume 0:1f82672b8755 17577 * @retval 0 -> BNO055_SUCCESS
gume 0:1f82672b8755 17578 * @retval 1 -> BNO055_ERROR
gume 0:1f82672b8755 17579 *
gume 0:1f82672b8755 17580 */
gume 0:1f82672b8755 17581 BNO055_RETURN_FUNCTION_TYPE bno055_set_gyro_any_motion_awake_durn(
gume 0:1f82672b8755 17582 u8 gyro_awake_durn_u8)
gume 0:1f82672b8755 17583 {
gume 0:1f82672b8755 17584 BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17585 u8 data_u8r = BNO055_INIT_VALUE;
gume 0:1f82672b8755 17586 s8 stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 17587 s8 pg_stat_s8 = BNO055_ERROR;
gume 0:1f82672b8755 17588 u8 prev_opmode_u8 = BNO055_OPERATION_MODE_CONFIG;
gume 0:1f82672b8755 17589 /* Check the struct p_bno055 is empty */
gume 0:1f82672b8755 17590 if (p_bno055 == BNO055_INIT_VALUE) {
gume 0:1f82672b8755 17591 return BNO055_E_NULL_PTR;
gume 0:1f82672b8755 17592 } else {
gume 0:1f82672b8755 17593 /* The write operation effective only if the operation
gume 0:1f82672b8755 17594 mode is in config mode, this part of code is checking the
gume 0:1f82672b8755 17595 current operation mode and set the config mode */
gume 0:1f82672b8755 17596 stat_s8 = bno055_get_operation_mode(&prev_opmode_u8);
gume 0:1f82672b8755 17597 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 17598 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 17599 stat_s8 += bno055_set_operation_mode
gume 0:1f82672b8755 17600 (BNO055_OPERATION_MODE_CONFIG);
gume 0:1f82672b8755 17601 if (stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 17602 /* Write page as one */
gume 0:1f82672b8755 17603 pg_stat_s8 = bno055_write_page_id(
gume 0:1f82672b8755 17604 BNO055_PAGE_ONE);
gume 0:1f82672b8755 17605 if (pg_stat_s8 == BNO055_SUCCESS) {
gume 0:1f82672b8755 17606 /* Write the value of gyro
gume 0:1f82672b8755 17607 anymotion awake duration*/
gume 0:1f82672b8755 17608 com_rslt =
gume 0:1f82672b8755 17609 p_bno055->BNO055_BUS_READ_FUNC
gume 0:1f82672b8755 17610 (p_bno055->dev_addr,
gume 0:1f82672b8755 17611 BNO055_GYRO_AWAKE_DURN_REG,
gume 0:1f82672b8755 17612 &data_u8r,
gume 0:1f82672b8755 17613 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 17614 if (com_rslt == BNO055_SUCCESS) {
gume 0:1f82672b8755 17615 data_u8r =
gume 0:1f82672b8755 17616 BNO055_SET_BITSLICE(data_u8r,
gume 0:1f82672b8755 17617 BNO055_GYRO_AWAKE_DURN,
gume 0:1f82672b8755 17618 gyro_awake_durn_u8);
gume 0:1f82672b8755 17619 com_rslt +=
gume 0:1f82672b8755 17620 p_bno055->BNO055_BUS_WRITE_FUNC
gume 0:1f82672b8755 17621 (p_bno055->dev_addr,
gume 0:1f82672b8755 17622 BNO055_GYRO_AWAKE_DURN_REG,
gume 0:1f82672b8755 17623 &data_u8r,
gume 0:1f82672b8755 17624 BNO055_GEN_READ_WRITE_LENGTH);
gume 0:1f82672b8755 17625 }
gume 0:1f82672b8755 17626 } else {
gume 0:1f82672b8755 17627 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17628 }
gume 0:1f82672b8755 17629 } else {
gume 0:1f82672b8755 17630 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17631 }
gume 0:1f82672b8755 17632 } else {
gume 0:1f82672b8755 17633 com_rslt = BNO055_ERROR;
gume 0:1f82672b8755 17634 }
gume 0:1f82672b8755 17635 }
gume 0:1f82672b8755 17636 if (prev_opmode_u8 != BNO055_OPERATION_MODE_CONFIG)
gume 0:1f82672b8755 17637 /* set the operation mode
gume 0:1f82672b8755 17638 of previous operation mode*/
gume 0:1f82672b8755 17639 com_rslt += bno055_set_operation_mode
gume 0:1f82672b8755 17640 (prev_opmode_u8);
gume 0:1f82672b8755 17641 return com_rslt;
gume 0:1f82672b8755 17642 }