Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 89-apps-should-be-able-to-specify-if-they-want-wifi-to-be-disabled-when-entering-them
  • 9Rmain
  • allow-reloading-sunmenu
  • always-have-a-wifi-instance
  • anon/gpndemo
  • anon/update-sim
  • anon/webflasher
  • app_text_viewer
  • audio_input
  • audio_io
  • blm_dev_chan
  • ch3/bl00mbox_docs
  • ci-1690580595
  • dev_p4
  • dev_p4-iggy
  • dev_p4-iggy-rebased
  • dx/dldldld
  • dx/fb-save-restore
  • dx/hint-hint
  • dx/jacksense-headset-mic-only
  • events
  • fil3s-limit-filesize
  • fil3s-media
  • fpletz/flake
  • gr33nhouse-improvements
  • history-rewrite
  • icon-flower
  • iggy/stemming
  • iggy/stemming_merge
  • led_fix_fix
  • main
  • main+schneider
  • media_has_video_has_audio
  • micropython_api
  • mixer2
  • moon2_demo_temp
  • moon2_migrate_apps
  • more-accurate-battery
  • pippin/ctx_sprite_sheet_support
  • pippin/display-python-errors-on-display
  • pippin/make_empty_drawlists_skip_render_and_blit
  • pippin/more-accurate-battery
  • pippin/tcp_redirect_hack
  • pippin/tune_ctx_config_update_from_upstream
  • pippin/uhm_flash_access_bust
  • pressable_bugfix
  • py_only_update_fps_overlay_when_changing
  • q3k/doom-poc
  • q3k/render-to-texture
  • rahix/flow3rseeds
  • raw_captouch_new
  • raw_captouch_old
  • release/1.0.0
  • release/1.1.0
  • release/1.1.1
  • release/1.2.0
  • release/1.3.0
  • release/1.4.0
  • restore_blit
  • return_of_melodic_demo
  • rev4_micropython
  • schneider/application-remove-name
  • schneider/bhi581
  • schneider/factory_test
  • schneider/recovery
  • scope_hack
  • sdkconfig-spiram-tinyusb
  • sec/auto-nick
  • sec/blinky
  • sector_size_512
  • shoegaze-fps
  • smaller_gradient_lut
  • store_delta_ms_and_ins_as_class_members
  • task_cleanup
  • uctx-wip
  • w1f1-in-sim
  • widgets_draw
  • wifi-json-error-handling
  • wip-docs
  • wip-tinyusb
  • v1.0.0
  • v1.0.0+rc1
  • v1.0.0+rc2
  • v1.0.0+rc3
  • v1.0.0+rc4
  • v1.0.0+rc5
  • v1.0.0+rc6
  • v1.1.0
  • v1.1.0+rc1
  • v1.1.1
  • v1.2.0
  • v1.2.0+rc1
  • v1.3.0
  • v1.4.0
94 results

Target

Select target project
  • flow3r/flow3r-firmware
  • Vespasian/flow3r-firmware
  • alxndr42/flow3r-firmware
  • pl/flow3r-firmware
  • Kari/flow3r-firmware
  • raimue/flow3r-firmware
  • grandchild/flow3r-firmware
  • mu5tach3/flow3r-firmware
  • Nervengift/flow3r-firmware
  • arachnist/flow3r-firmware
  • TheNewCivilian/flow3r-firmware
  • alibi/flow3r-firmware
  • manuel_v/flow3r-firmware
  • xeniter/flow3r-firmware
  • maxbachmann/flow3r-firmware
  • yGifoom/flow3r-firmware
  • istobic/flow3r-firmware
  • EiNSTeiN_/flow3r-firmware
  • gnudalf/flow3r-firmware
  • 999eagle/flow3r-firmware
  • toerb/flow3r-firmware
  • pandark/flow3r-firmware
  • teal/flow3r-firmware
  • x42/flow3r-firmware
  • alufers/flow3r-firmware
  • dos/flow3r-firmware
  • yrlf/flow3r-firmware
  • LuKaRo/flow3r-firmware
  • ThomasElRubio/flow3r-firmware
  • ai/flow3r-firmware
  • T_X/flow3r-firmware
  • highTower/flow3r-firmware
  • beanieboi/flow3r-firmware
  • Woazboat/flow3r-firmware
  • gooniesbro/flow3r-firmware
  • marvino/flow3r-firmware
  • kressnerd/flow3r-firmware
  • quazgar/flow3r-firmware
  • aoid/flow3r-firmware
  • jkj/flow3r-firmware
  • naomi/flow3r-firmware
41 results
Select Git revision
  • 9Rmain
  • anon/gpndemo
  • anon/update-sim
  • anon/webflasher
  • audio_input
  • audio_io
  • bl00mbox
  • bl00mbox_old
  • captouch-threshold
  • ch3/bl00mbox_docs
  • ci-1690580595
  • compressor
  • dev_p4
  • dev_p4-iggy
  • dev_p4-iggy-rebased
  • dos
  • dos-main-patch-50543
  • events
  • fm_fix
  • fm_fix2
  • fpletz/flake
  • history-rewrite
  • icon-flower
  • iggy/stemming
  • iggy/stemming_merge
  • json-error
  • main
  • main+schneider
  • media-buf
  • micropython_api
  • moon2_applications
  • moon2_demo_temp
  • moon2_gay_drums
  • passthrough
  • phhw
  • pippin/display-python-errors-on-display
  • pippin/make_empty_drawlists_skip_render_and_blit
  • pippin/media_framework
  • pippin/uhm_flash_access_bust
  • pressable_bugfix
  • q3k/doom-poc
  • rahix/big-flow3r
  • rahix/flow3rseeds
  • raw_captouch_new
  • raw_captouch_old
  • release/1.0.0
  • release/1.1.0
  • release/1.1.1
  • rev4_micropython
  • schneider/application-remove-name
  • schneider/bhi581
  • schneider/factory_test
  • schneider/recovery
  • scope
  • scope_hack
  • sdkconfig-spiram-tinyusb
  • sec/auto-nick
  • sec/blinky
  • simtest
  • slewtest
  • t
  • test
  • test2
  • uctx-wip
  • view-think
  • vm-pending
  • vsync
  • wave
  • wip-docs
  • wip-tinyusb
  • v1.0.0
  • v1.0.0+rc1
  • v1.0.0+rc2
  • v1.0.0+rc3
  • v1.0.0+rc4
  • v1.0.0+rc5
  • v1.0.0+rc6
  • v1.1.0
  • v1.1.0+rc1
  • v1.1.1
  • v1.2.0
  • v1.2.0+rc1
  • v1.3.0
83 results
Show changes
Showing
with 11699 additions and 0 deletions
/**
* Copyright (c) 2023 Bosch Sensortec GmbH. All rights reserved.
*
* BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @file bmi270_context.c
* @date 2023-05-03
* @version v2.86.1
*
*/
/***************************************************************************/
/*! Header files
****************************************************************************/
#include "bmi270_context.h"
/***************************************************************************/
/*! Global Variable
****************************************************************************/
/*! @name Global array that stores the configuration file of BMI270_CONTEXT */
const uint8_t bmi270_context_config_file[] = {
0xc8, 0x2e, 0x00, 0x2e, 0x80, 0x2e, 0x00, 0xb0, 0xc8, 0x2e, 0x00, 0x2e, 0xc8, 0x2e, 0x00, 0x2e, 0x80, 0x2e, 0xc9,
0x01, 0x80, 0x2e, 0xe2, 0x00, 0xc8, 0x2e, 0x00, 0x2e, 0x80, 0x2e, 0x77, 0xb0, 0x50, 0x30, 0x21, 0x2e, 0x59, 0xf5,
0x10, 0x30, 0x21, 0x2e, 0x6a, 0xf5, 0x80, 0x2e, 0xaf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x09, 0x01, 0x00, 0x22,
0x00, 0x76, 0x00, 0x00, 0x10, 0x00, 0x10, 0xd1, 0x00, 0xcb, 0xa7, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1,
0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00,
0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e,
0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80,
0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1,
0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00,
0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e,
0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80,
0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1,
0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0xfd, 0x2d, 0x2c, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x02, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x24, 0x22, 0x00, 0x80, 0x2e, 0x48, 0x02, 0x01, 0x2e, 0x49,
0xf1, 0x0b, 0xbc, 0x10, 0x50, 0x0f, 0xb8, 0x00, 0x90, 0xfb, 0x7f, 0x07, 0x2f, 0x03, 0x2e, 0x21, 0xf2, 0x02, 0x31,
0x4a, 0x0a, 0x23, 0x2e, 0x21, 0xf2, 0x09, 0x2c, 0x00, 0x30, 0x98, 0x2e, 0x0e, 0xc7, 0x03, 0x2e, 0x21, 0xf2, 0xf2,
0x3e, 0x4a, 0x08, 0x23, 0x2e, 0x21, 0xf2, 0xfb, 0x6f, 0xf0, 0x5f, 0xb8, 0x2e, 0x13, 0x52, 0x00, 0x2e, 0x60, 0x40,
0x41, 0x40, 0x0d, 0xbc, 0x98, 0xbc, 0xc0, 0x2e, 0x01, 0x0a, 0x0f, 0xb8, 0x43, 0x86, 0x25, 0x40, 0x04, 0x40, 0xd8,
0xbe, 0x2c, 0x0b, 0x22, 0x11, 0x54, 0x42, 0x03, 0x80, 0x4b, 0x0e, 0xf6, 0x2f, 0xb8, 0x2e, 0x20, 0x50, 0xe7, 0x7f,
0xf6, 0x7f, 0x46, 0x30, 0x0f, 0x2e, 0xa4, 0xf1, 0xbe, 0x09, 0x80, 0xb3, 0x06, 0x2f, 0x0d, 0x2e, 0x84, 0x00, 0x84,
0xaf, 0x02, 0x2f, 0x16, 0x30, 0x2d, 0x2e, 0x7b, 0x00, 0x86, 0x30, 0x2d, 0x2e, 0x60, 0xf5, 0xf6, 0x6f, 0xe7, 0x6f,
0xe0, 0x5f, 0xc8, 0x2e, 0x80, 0x2e, 0xfb, 0x00, 0x00, 0x30, 0xc0, 0x2e, 0x21, 0x2e, 0x8d, 0x00, 0x44, 0x47, 0x99,
0x00, 0xff, 0x3f, 0x00, 0x0c, 0xff, 0x0f, 0x00, 0x04, 0xc0, 0x00, 0x5b, 0xf5, 0x90, 0x00, 0x1e, 0xf2, 0xfd, 0xf5,
0x8e, 0x00, 0x96, 0x00, 0x96, 0x00, 0xe0, 0x00, 0x19, 0xf4, 0x66, 0xf5, 0x00, 0x18, 0x64, 0xf5, 0x9d, 0x00, 0x7f,
0x00, 0x81, 0x00, 0xae, 0x00, 0xff, 0xfb, 0x21, 0x02, 0x00, 0x10, 0x00, 0x40, 0xff, 0x00, 0x00, 0x80, 0xff, 0x7f,
0x54, 0x0f, 0xeb, 0x00, 0x7f, 0xff, 0xc2, 0xf5, 0x68, 0xf7, 0xb3, 0xf1, 0x4e, 0x0f, 0x42, 0x0f, 0x48, 0x0f, 0x80,
0x00, 0x67, 0x0f, 0x58, 0xf7, 0x5b, 0xf7, 0x6a, 0x0f, 0x86, 0x00, 0x59, 0x0f, 0x6c, 0x0f, 0xc6, 0xf1, 0x66, 0x0f,
0x6c, 0xf7, 0x00, 0xe0, 0x00, 0xff, 0xd1, 0xf5, 0x6e, 0x0f, 0x71, 0x0f, 0xff, 0x03, 0x00, 0xfc, 0xf0, 0x3f, 0xb9,
0x00, 0x2d, 0xf5, 0xca, 0xf5, 0x8a, 0x00, 0x00, 0x08, 0x71, 0x7d, 0xfe, 0xc0, 0x03, 0x3f, 0x05, 0x3e, 0x49, 0x01,
0x92, 0x02, 0xf5, 0xd6, 0xe8, 0x63, 0xd3, 0xf8, 0x2e, 0x07, 0x5c, 0xce, 0xa5, 0x67, 0x28, 0x02, 0x4e, 0x01, 0x00,
0xf0, 0x33, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x50, 0x10,
0x50, 0x17, 0x52, 0x05, 0x2e, 0x7d, 0x00, 0xfb, 0x7f, 0x00, 0x2e, 0x13, 0x40, 0x93, 0x42, 0x41, 0x0e, 0xfb, 0x2f,
0x98, 0x2e, 0x91, 0x03, 0x98, 0x2e, 0x87, 0xcf, 0x01, 0x2e, 0x89, 0x00, 0x00, 0xb2, 0x08, 0x2f, 0x01, 0x2e, 0x69,
0xf7, 0xb1, 0x3f, 0x01, 0x08, 0x01, 0x30, 0x23, 0x2e, 0x89, 0x00, 0x21, 0x2e, 0x69, 0xf7, 0xfb, 0x6f, 0xf0, 0x5f,
0xb8, 0x2e, 0xa0, 0x50, 0x80, 0x7f, 0xe7, 0x7f, 0xd5, 0x7f, 0xc4, 0x7f, 0xb3, 0x7f, 0xa2, 0x7f, 0x91, 0x7f, 0xf6,
0x7f, 0x7b, 0x7f, 0x00, 0x2e, 0x01, 0x2e, 0x60, 0xf5, 0x60, 0x7f, 0x98, 0x2e, 0xce, 0x00, 0x62, 0x6f, 0x01, 0x32,
0x91, 0x08, 0x80, 0xb2, 0x11, 0x2f, 0x00, 0xb2, 0x03, 0x2f, 0x05, 0x2e, 0x18, 0x00, 0x80, 0x90, 0x09, 0x2f, 0x60,
0x7f, 0x98, 0x2e, 0xf9, 0x00, 0x23, 0x50, 0x01, 0x32, 0x01, 0x42, 0x02, 0x86, 0x60, 0x6f, 0x02, 0x30, 0xc2, 0x42,
0x23, 0x2e, 0x60, 0xf5, 0x00, 0x90, 0x00, 0x30, 0x01, 0x2f, 0x21, 0x2e, 0x7a, 0x00, 0xf6, 0x6f, 0x91, 0x6f, 0xa2,
0x6f, 0xb3, 0x6f, 0xc4, 0x6f, 0xd5, 0x6f, 0xe7, 0x6f, 0x7b, 0x6f, 0x80, 0x6f, 0x60, 0x5f, 0xc8, 0x2e, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x01, 0xd4, 0x7b, 0x3b,
0x01, 0xdb, 0x7a, 0x04, 0x00, 0x3f, 0x7b, 0xcd, 0x6c, 0xc3, 0x04, 0x85, 0x09, 0xc3, 0x04, 0xec, 0xe6, 0x0c, 0x46,
0x01, 0x00, 0x27, 0x00, 0x19, 0x00, 0x96, 0x00, 0xa0, 0x00, 0x01, 0x00, 0x0c, 0x00, 0xf0, 0x3c, 0x00, 0x01, 0x01,
0x00, 0x03, 0x00, 0x01, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x07, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x00, 0xe1, 0x06, 0x66, 0x0a, 0x0a, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x50, 0x98, 0x2e, 0xd7, 0x0e, 0x50, 0x32, 0x98, 0x2e,
0x48, 0x03, 0x10, 0x30, 0x21, 0x2e, 0x21, 0xf2, 0x00, 0x30, 0x00, 0x2e, 0x00, 0x2e, 0xd0, 0x2e, 0x00, 0x2e, 0x01,
0x80, 0x06, 0xa2, 0xfb, 0x2f, 0x01, 0x2e, 0x9c, 0x00, 0x00, 0xb2, 0x10, 0x2f, 0x01, 0x2e, 0x18, 0x00, 0x00, 0xb2,
0x0c, 0x2f, 0x01, 0x54, 0x03, 0x52, 0x01, 0x50, 0x98, 0x2e, 0xc2, 0xc0, 0x98, 0x2e, 0xf5, 0xb0, 0x01, 0x50, 0x98,
0x2e, 0xd5, 0xb6, 0x10, 0x30, 0x21, 0x2e, 0x19, 0x00, 0x01, 0x2e, 0x84, 0x00, 0x04, 0xae, 0x0b, 0x2f, 0x01, 0x2e,
0x9c, 0x00, 0x00, 0xb2, 0x07, 0x2f, 0x01, 0x52, 0x98, 0x2e, 0x8e, 0x0e, 0x00, 0xb2, 0x02, 0x2f, 0x10, 0x30, 0x21,
0x2e, 0x79, 0x00, 0x01, 0x2e, 0x79, 0x00, 0x00, 0x90, 0x90, 0x2e, 0x14, 0x03, 0x01, 0x2e, 0x87, 0x00, 0x00, 0xb2,
0x04, 0x2f, 0x98, 0x2e, 0x2f, 0x0e, 0x00, 0x30, 0x21, 0x2e, 0x7b, 0x00, 0x01, 0x2e, 0x7b, 0x00, 0x00, 0xb2, 0x12,
0x2f, 0x01, 0x2e, 0x84, 0x00, 0x00, 0x90, 0x02, 0x2f, 0x98, 0x2e, 0x1f, 0x0e, 0x09, 0x2d, 0x98, 0x2e, 0x81, 0x0d,
0x01, 0x2e, 0x84, 0x00, 0x04, 0x90, 0x02, 0x2f, 0x50, 0x32, 0x98, 0x2e, 0x48, 0x03, 0x00, 0x30, 0x21, 0x2e, 0x7b,
0x00, 0x01, 0x2e, 0x78, 0x00, 0x00, 0xb2, 0x90, 0x2e, 0x2c, 0x03, 0x01, 0x2e, 0x78, 0x00, 0x81, 0x30, 0x01, 0x08,
0x00, 0xb2, 0x61, 0x2f, 0x03, 0x2e, 0x24, 0x02, 0x01, 0x2e, 0x84, 0x00, 0x98, 0xbc, 0x98, 0xb8, 0x05, 0xb2, 0x0d,
0x58, 0x23, 0x2f, 0x07, 0x90, 0x07, 0x54, 0x00, 0x30, 0x37, 0x2f, 0x15, 0x41, 0x04, 0x41, 0xdc, 0xbe, 0x44, 0xbe,
0xdc, 0xba, 0x2c, 0x01, 0x61, 0x00, 0x0d, 0x56, 0x4a, 0x0f, 0x0c, 0x2f, 0xd1, 0x42, 0x94, 0xb8, 0xc1, 0x42, 0x11,
0x30, 0x05, 0x2e, 0x6a, 0xf7, 0x2c, 0xbd, 0x2f, 0xb9, 0x80, 0xb2, 0x08, 0x22, 0x98, 0x2e, 0xaf, 0x03, 0x21, 0x2d,
0x61, 0x30, 0x23, 0x2e, 0x84, 0x00, 0x98, 0x2e, 0xaf, 0x03, 0x00, 0x30, 0x21, 0x2e, 0x5a, 0xf5, 0x18, 0x2d, 0xf1,
0x7f, 0x50, 0x30, 0x98, 0x2e, 0x48, 0x03, 0x0d, 0x52, 0x05, 0x50, 0x50, 0x42, 0x70, 0x30, 0x0b, 0x54, 0x42, 0x42,
0x7e, 0x82, 0xf2, 0x6f, 0x80, 0xb2, 0x42, 0x42, 0x05, 0x2f, 0x21, 0x2e, 0x84, 0x00, 0x10, 0x30, 0x98, 0x2e, 0xaf,
0x03, 0x03, 0x2d, 0x60, 0x30, 0x21, 0x2e, 0x84, 0x00, 0x01, 0x2e, 0x84, 0x00, 0x06, 0x90, 0x18, 0x2f, 0x01, 0x2e,
0x77, 0x00, 0x09, 0x54, 0x05, 0x52, 0xf0, 0x7f, 0x98, 0x2e, 0x7a, 0xc1, 0xf1, 0x6f, 0x08, 0x1a, 0x40, 0x30, 0x08,
0x2f, 0x21, 0x2e, 0x84, 0x00, 0x20, 0x30, 0x98, 0x2e, 0x9b, 0x03, 0x50, 0x32, 0x98, 0x2e, 0x48, 0x03, 0x05, 0x2d,
0x98, 0x2e, 0x38, 0x0e, 0x00, 0x30, 0x21, 0x2e, 0x84, 0x00, 0x00, 0x30, 0x21, 0x2e, 0x78, 0x00, 0x18, 0x2d, 0x01,
0x2e, 0x84, 0x00, 0x03, 0xaa, 0x01, 0x2f, 0x98, 0x2e, 0x45, 0x0e, 0x01, 0x2e, 0x84, 0x00, 0x3f, 0x80, 0x03, 0xa2,
0x01, 0x2f, 0x00, 0x2e, 0x02, 0x2d, 0x98, 0x2e, 0x5b, 0x0e, 0x30, 0x30, 0x98, 0x2e, 0xba, 0x03, 0x00, 0x30, 0x21,
0x2e, 0x79, 0x00, 0x50, 0x32, 0x98, 0x2e, 0x48, 0x03, 0x01, 0x2e, 0x19, 0x00, 0x00, 0xb2, 0x10, 0x2f, 0x01, 0x2e,
0x85, 0x00, 0x21, 0x2e, 0x90, 0x00, 0x0f, 0x52, 0x7e, 0x82, 0x11, 0x50, 0x41, 0x40, 0x18, 0xb9, 0x11, 0x42, 0x02,
0x42, 0x02, 0x80, 0x00, 0x2e, 0x01, 0x40, 0x01, 0x42, 0x98, 0x2e, 0xaa, 0x01, 0x00, 0x30, 0x21, 0x2e, 0x19, 0x00,
0x21, 0x2e, 0x9c, 0x00, 0x80, 0x2e, 0x52, 0x02, 0x21, 0x2e, 0x59, 0xf5, 0x10, 0x30, 0xc0, 0x2e, 0x21, 0x2e, 0x4a,
0xf1, 0x80, 0x2e, 0x00, 0xc1, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9a, 0x01,
0x34, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x03, 0x2e, 0x7d, 0x00, 0x16, 0xb8, 0x02, 0x34, 0x4a, 0x0c, 0x21, 0x2e, 0x2d, 0xf5, 0xc0, 0x2e, 0x23,
0x2e, 0x7d, 0x00, 0x03, 0xbc, 0x21, 0x2e, 0x85, 0x00, 0x03, 0x2e, 0x85, 0x00, 0x40, 0xb2, 0x10, 0x30, 0x21, 0x2e,
0x19, 0x00, 0x01, 0x30, 0x05, 0x2f, 0x05, 0x2e, 0x88, 0x00, 0x80, 0x90, 0x01, 0x2f, 0x23, 0x2e, 0x6f, 0xf5, 0xc0,
0x2e, 0x21, 0x2e, 0x89, 0x00, 0x11, 0x30, 0x81, 0x08, 0x01, 0x2e, 0x6a, 0xf7, 0x71, 0x3f, 0x23, 0xbd, 0x01, 0x08,
0x02, 0x0a, 0xc0, 0x2e, 0x21, 0x2e, 0x6a, 0xf7, 0x30, 0x25, 0x00, 0x30, 0x21, 0x2e, 0x5a, 0xf5, 0x10, 0x50, 0x21,
0x2e, 0x7b, 0x00, 0x21, 0x2e, 0x78, 0x00, 0xfb, 0x7f, 0x98, 0x2e, 0xaf, 0x03, 0x40, 0x30, 0x21, 0x2e, 0x84, 0x00,
0xfb, 0x6f, 0xf0, 0x5f, 0x03, 0x25, 0x80, 0x2e, 0x9b, 0x03, 0x0b, 0x00, 0x94, 0x02, 0x14, 0x24, 0x80, 0x00, 0x04,
0x00, 0x04, 0x30, 0x08, 0xb8, 0x94, 0x02, 0xc0, 0x2e, 0x28, 0xbd, 0x02, 0x0a, 0x0d, 0x82, 0x02, 0x30, 0x12, 0x42,
0x41, 0x0e, 0xfc, 0x2f, 0xb8, 0x2e, 0x95, 0x50, 0xc0, 0x2e, 0x21, 0x2e, 0xa9, 0x01, 0x02, 0x30, 0x02, 0x2c, 0x41,
0x00, 0x12, 0x42, 0x41, 0x0e, 0xfc, 0x2f, 0xb8, 0x2e, 0x13, 0x82, 0x02, 0x30, 0x12, 0x42, 0x41, 0x0e, 0xfc, 0x2f,
0x3f, 0x80, 0xa1, 0x30, 0xc0, 0x2e, 0x01, 0x42, 0x00, 0x2e, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80,
0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0xc0, 0x50, 0xe7, 0x7f,
0xf6, 0x7f, 0x26, 0x30, 0x0f, 0x2e, 0x61, 0xf5, 0x2f, 0x2e, 0x78, 0x00, 0x0f, 0x2e, 0x78, 0x00, 0xbe, 0x09, 0xa2,
0x7f, 0x80, 0x7f, 0x80, 0xb3, 0xd5, 0x7f, 0xc4, 0x7f, 0xb3, 0x7f, 0x91, 0x7f, 0x7b, 0x7f, 0x0b, 0x2f, 0x19, 0x50,
0x1a, 0x25, 0x12, 0x40, 0x42, 0x7f, 0x74, 0x82, 0x12, 0x40, 0x52, 0x7f, 0x00, 0x2e, 0x00, 0x40, 0x60, 0x7f, 0x98,
0x2e, 0x6a, 0xd6, 0x81, 0x30, 0x01, 0x2e, 0x78, 0x00, 0x01, 0x08, 0x00, 0xb2, 0x42, 0x2f, 0x03, 0x2e, 0x24, 0x02,
0x01, 0x2e, 0x24, 0x02, 0x97, 0xbc, 0x06, 0xbc, 0x9f, 0xb8, 0x0f, 0xb8, 0x00, 0x90, 0x23, 0x2e, 0x88, 0x00, 0x10,
0x30, 0x01, 0x30, 0x2a, 0x2f, 0x03, 0x2e, 0x84, 0x00, 0x44, 0xb2, 0x05, 0x2f, 0x47, 0xb2, 0x00, 0x30, 0x2d, 0x2f,
0x21, 0x2e, 0x78, 0x00, 0x2b, 0x2d, 0x03, 0x2e, 0xfd, 0xf5, 0x9e, 0xbc, 0x9f, 0xb8, 0x40, 0x90, 0x14, 0x2f, 0x03,
0x2e, 0xfc, 0xf5, 0x99, 0xbc, 0x9f, 0xb8, 0x40, 0x90, 0x0e, 0x2f, 0x03, 0x2e, 0x49, 0xf1, 0x1b, 0x54, 0x4a, 0x08,
0x40, 0x90, 0x08, 0x2f, 0x98, 0x2e, 0xce, 0x00, 0x00, 0xb2, 0x10, 0x30, 0x03, 0x2f, 0x50, 0x30, 0x21, 0x2e, 0x84,
0x00, 0x10, 0x2d, 0x98, 0x2e, 0x9b, 0x03, 0x00, 0x30, 0x21, 0x2e, 0x78, 0x00, 0x0a, 0x2d, 0x05, 0x2e, 0x69, 0xf7,
0x2d, 0xbd, 0x2f, 0xb9, 0x80, 0xb2, 0x01, 0x2f, 0x21, 0x2e, 0x79, 0x00, 0x23, 0x2e, 0x78, 0x00, 0xe0, 0x31, 0x21,
0x2e, 0x61, 0xf5, 0xf6, 0x6f, 0xe7, 0x6f, 0x80, 0x6f, 0xa2, 0x6f, 0xb3, 0x6f, 0xc4, 0x6f, 0xd5, 0x6f, 0x7b, 0x6f,
0x91, 0x6f, 0x40, 0x5f, 0xc8, 0x2e, 0x90, 0x50, 0xf7, 0x7f, 0xe6, 0x7f, 0xd5, 0x7f, 0xc4, 0x7f, 0xb3, 0x7f, 0xa1,
0x7f, 0x90, 0x7f, 0x82, 0x7f, 0x7b, 0x7f, 0x98, 0x2e, 0xce, 0x00, 0x00, 0xb2, 0x10, 0x30, 0x49, 0x2f, 0x05, 0x2e,
0x21, 0x02, 0x03, 0x2e, 0x2d, 0x02, 0x21, 0x56, 0x08, 0x08, 0x93, 0x08, 0x90, 0x0a, 0x25, 0x2e, 0x18, 0x00, 0x05,
0x2e, 0xc1, 0xf5, 0x2e, 0xbc, 0x05, 0x2e, 0x84, 0x00, 0x84, 0xa2, 0x0e, 0xb8, 0x31, 0x30, 0x88, 0x04, 0x03, 0x2f,
0x01, 0x2e, 0x18, 0x00, 0x00, 0xb2, 0x0c, 0x2f, 0x1d, 0x50, 0x01, 0x52, 0x98, 0x2e, 0xd7, 0x00, 0x05, 0x2e, 0x7a,
0x00, 0x80, 0x90, 0x02, 0x2f, 0x10, 0x30, 0x21, 0x2e, 0x7a, 0x00, 0x25, 0x2e, 0x9c, 0x00, 0x05, 0x2e, 0x18, 0x00,
0x80, 0xb2, 0x20, 0x2f, 0x01, 0x2e, 0xc0, 0xf5, 0xf2, 0x30, 0x02, 0x08, 0x07, 0xaa, 0x73, 0x30, 0x03, 0x2e, 0x7c,
0x00, 0x18, 0x22, 0x41, 0x1a, 0x05, 0x2f, 0x03, 0x2e, 0x66, 0xf5, 0x9f, 0xbc, 0x9f, 0xb8, 0x40, 0x90, 0x0c, 0x2f,
0x1f, 0x52, 0x03, 0x30, 0x53, 0x42, 0x2b, 0x30, 0x90, 0x04, 0x5b, 0x42, 0x21, 0x2e, 0x7c, 0x00, 0x24, 0xbd, 0x7e,
0x80, 0x81, 0x84, 0x43, 0x42, 0x02, 0x42, 0x02, 0x32, 0x25, 0x2e, 0x62, 0xf5, 0x05, 0x2e, 0x86, 0x00, 0x81, 0x84,
0x25, 0x2e, 0x86, 0x00, 0x02, 0x31, 0x25, 0x2e, 0x60, 0xf5, 0x05, 0x2e, 0x25, 0x02, 0x10, 0x30, 0x90, 0x08, 0x80,
0xb2, 0x0b, 0x2f, 0x05, 0x2e, 0xca, 0xf5, 0xf0, 0x3e, 0x90, 0x08, 0x25, 0x2e, 0xca, 0xf5, 0x05, 0x2e, 0x59, 0xf5,
0xe0, 0x3f, 0x90, 0x08, 0x25, 0x2e, 0x59, 0xf5, 0x90, 0x6f, 0xa1, 0x6f, 0xb3, 0x6f, 0xc4, 0x6f, 0xd5, 0x6f, 0xe6,
0x6f, 0xf7, 0x6f, 0x7b, 0x6f, 0x82, 0x6f, 0x70, 0x5f, 0xc8, 0x2e, 0x2f, 0x52, 0x90, 0x50, 0x53, 0x40, 0x4a, 0x25,
0x40, 0x40, 0x39, 0x8b, 0xfb, 0x7f, 0x0c, 0xbc, 0x21, 0x52, 0x37, 0x89, 0x0b, 0x30, 0x59, 0x08, 0x0c, 0xb8, 0xe0,
0x7f, 0x8b, 0x7f, 0x4b, 0x43, 0x0b, 0x43, 0x40, 0xb2, 0xd1, 0x7f, 0x6e, 0x2f, 0x01, 0x2e, 0x83, 0x00, 0x00, 0xb2,
0x0e, 0x2f, 0x25, 0x52, 0x01, 0x2e, 0x7e, 0x00, 0xc3, 0x7f, 0xb4, 0x7f, 0xa5, 0x7f, 0x98, 0x2e, 0xbb, 0xcc, 0x05,
0x30, 0x2b, 0x2e, 0x83, 0x00, 0xc3, 0x6f, 0xd1, 0x6f, 0xb4, 0x6f, 0xa5, 0x6f, 0x36, 0xbc, 0x06, 0xb9, 0x35, 0xbc,
0x0f, 0xb8, 0x94, 0xb0, 0xc6, 0x7f, 0x00, 0xb2, 0x0c, 0x2f, 0x27, 0x50, 0x29, 0x56, 0x0b, 0x30, 0x05, 0x2e, 0x21,
0x02, 0x2d, 0x5c, 0x1b, 0x42, 0xdb, 0x42, 0x96, 0x08, 0x25, 0x2e, 0x21, 0x02, 0x0b, 0x42, 0xcb, 0x42, 0x00, 0x2e,
0x31, 0x56, 0xcb, 0x08, 0x25, 0x52, 0x01, 0x2e, 0x7e, 0x00, 0x01, 0x54, 0x2b, 0x5c, 0x98, 0x2e, 0x06, 0xcd, 0xd2,
0x6f, 0x27, 0x5a, 0x94, 0x6f, 0xa4, 0xbc, 0x53, 0x41, 0x00, 0xb3, 0x1f, 0xb8, 0x44, 0x41, 0x01, 0x30, 0xd5, 0x7f,
0x05, 0x2f, 0x00, 0xb2, 0x03, 0x2f, 0x29, 0x5c, 0x11, 0x30, 0x93, 0x43, 0x84, 0x43, 0x23, 0xbd, 0x2f, 0xb9, 0x80,
0xb2, 0x1c, 0x2f, 0x72, 0x6f, 0xda, 0x00, 0x82, 0x6f, 0x22, 0x03, 0x44, 0x43, 0x00, 0x90, 0x27, 0x2e, 0x7f, 0x00,
0x29, 0x5a, 0x12, 0x2f, 0x29, 0x54, 0x00, 0x2e, 0x90, 0x40, 0x82, 0x40, 0x18, 0x04, 0xa2, 0x06, 0x80, 0xaa, 0x04,
0x2f, 0x80, 0x90, 0x08, 0x2f, 0xc2, 0x6f, 0x50, 0x0f, 0x05, 0x2f, 0xc0, 0x6f, 0x00, 0xb2, 0x02, 0x2f, 0x53, 0x43,
0x44, 0x43, 0x11, 0x30, 0xe0, 0x6f, 0x98, 0x2e, 0x95, 0xcf, 0xd1, 0x6f, 0x15, 0x5a, 0x09, 0x2e, 0x7f, 0x00, 0x41,
0x40, 0x54, 0x43, 0x08, 0x2c, 0x41, 0x43, 0x15, 0x30, 0x2b, 0x2e, 0x83, 0x00, 0x01, 0x30, 0xe0, 0x6f, 0x98, 0x2e,
0x95, 0xcf, 0x00, 0x2e, 0xfb, 0x6f, 0x70, 0x5f, 0xb8, 0x2e, 0x50, 0x86, 0xcd, 0x88, 0x34, 0x85, 0xc5, 0x40, 0x91,
0x40, 0x8c, 0x80, 0x06, 0x41, 0x13, 0x40, 0x50, 0x50, 0x6e, 0x01, 0x82, 0x40, 0x04, 0x40, 0x34, 0x8c, 0xfb, 0x7f,
0x98, 0x2e, 0xce, 0x03, 0xe0, 0x7f, 0x00, 0x2e, 0x91, 0x41, 0x8c, 0x81, 0x82, 0x41, 0x13, 0x40, 0x04, 0x40, 0x34,
0x8e, 0x98, 0x2e, 0xce, 0x03, 0xc0, 0x7f, 0xd5, 0x7f, 0x13, 0x24, 0xff, 0x00, 0xd6, 0x41, 0xcc, 0x83, 0xc2, 0x41,
0x57, 0x40, 0x74, 0x80, 0x44, 0x40, 0x11, 0x40, 0x0c, 0x8a, 0xf7, 0x01, 0x94, 0x03, 0x12, 0x24, 0x80, 0x00, 0x3a,
0x01, 0x02, 0x30, 0xb2, 0x03, 0xce, 0x17, 0xfb, 0x08, 0x23, 0x01, 0xb2, 0x02, 0x48, 0xbb, 0x28, 0xbd, 0xf2, 0x0b,
0x53, 0x41, 0x02, 0x40, 0x44, 0x41, 0x74, 0x8d, 0xb7, 0x7f, 0x98, 0x2e, 0xce, 0x03, 0x50, 0x25, 0x91, 0x41, 0x8c,
0x81, 0x82, 0x41, 0x13, 0x40, 0x04, 0x40, 0x34, 0x8e, 0x98, 0x2e, 0xce, 0x03, 0x60, 0x25, 0xd1, 0x41, 0xcc, 0x81,
0xc2, 0x41, 0x13, 0x40, 0x04, 0x40, 0x98, 0x2e, 0xce, 0x03, 0x11, 0x24, 0xb3, 0x00, 0x71, 0x0e, 0xd3, 0x6f, 0xe1,
0x6f, 0x33, 0x2f, 0x12, 0x24, 0xdd, 0x00, 0xda, 0x0f, 0x2b, 0x2f, 0x12, 0x24, 0x8c, 0x00, 0x5a, 0x0e, 0x09, 0x2f,
0x10, 0x24, 0x83, 0x05, 0x48, 0x0e, 0x11, 0x24, 0x7f, 0x22, 0x10, 0x24, 0x18, 0x32, 0x08, 0x22, 0x80, 0x2e, 0xd7,
0xb4, 0x13, 0x24, 0xf4, 0x00, 0x73, 0x0e, 0x0f, 0x2f, 0x10, 0x24, 0x11, 0x10, 0x68, 0x0e, 0x10, 0x24, 0xa2, 0x30,
0x13, 0x24, 0x97, 0x23, 0x03, 0x22, 0x13, 0x24, 0x3b, 0x04, 0x4b, 0x0e, 0x11, 0x24, 0x0f, 0x30, 0x01, 0x22, 0x80,
0x2e, 0xd7, 0xb4, 0x11, 0x24, 0x53, 0x02, 0x41, 0x0e, 0x11, 0x24, 0xe7, 0x31, 0x10, 0x24, 0xfc, 0x25, 0x08, 0x22,
0x80, 0x2e, 0xd7, 0xb4, 0x10, 0x24, 0xe8, 0x40, 0x80, 0x2e, 0xd7, 0xb4, 0xf2, 0x37, 0x5a, 0x0e, 0x90, 0x2e, 0x50,
0xb3, 0x12, 0x24, 0xea, 0x00, 0x4a, 0x0e, 0x90, 0x2e, 0xc7, 0xb2, 0xc2, 0x6f, 0x14, 0x24, 0x4c, 0x0b, 0x54, 0x0e,
0x90, 0x2e, 0xab, 0xb2, 0x14, 0x24, 0x9b, 0x00, 0x5c, 0x0e, 0x90, 0x2e, 0xa1, 0xb2, 0x14, 0x24, 0x22, 0x01, 0x4c,
0x0e, 0x70, 0x2f, 0x82, 0xa3, 0x5e, 0x2f, 0x11, 0x24, 0xba, 0x0b, 0x51, 0x0e, 0x35, 0x2f, 0x11, 0x24, 0x03, 0x08,
0x69, 0x0e, 0x2d, 0x2f, 0xb1, 0x6f, 0x14, 0x24, 0x90, 0x00, 0x0c, 0x0e, 0x24, 0x2f, 0x11, 0x24, 0x31, 0x08, 0x69,
0x0e, 0x16, 0x2f, 0x11, 0x24, 0x7d, 0x01, 0x59, 0x0e, 0x0e, 0x2f, 0x11, 0x24, 0xd7, 0x0c, 0x51, 0x0e, 0x11, 0x24,
0x9f, 0x44, 0x13, 0x24, 0x41, 0x57, 0x4b, 0x22, 0x93, 0x35, 0x43, 0x0e, 0x10, 0x24, 0xbd, 0x42, 0x08, 0x22, 0x80,
0x2e, 0xd7, 0xb4, 0x10, 0x24, 0x1c, 0x42, 0x80, 0x2e, 0xd7, 0xb4, 0x11, 0x24, 0x47, 0x01, 0x59, 0x0e, 0x11, 0x24,
0xa2, 0x45, 0x10, 0x24, 0x31, 0x51, 0x08, 0x22, 0x80, 0x2e, 0xd7, 0xb4, 0x10, 0x24, 0x80, 0x41, 0x80, 0x2e, 0xd7,
0xb4, 0x10, 0x24, 0x67, 0x54, 0x80, 0x2e, 0xd7, 0xb4, 0x11, 0x24, 0x8c, 0x08, 0xe9, 0x0f, 0x10, 0x24, 0x0a, 0x48,
0x90, 0x2e, 0xd7, 0xb4, 0xb1, 0x6f, 0x13, 0x24, 0xe8, 0x03, 0x8b, 0x0f, 0x10, 0x24, 0xcd, 0x57, 0x90, 0x2e, 0xd7,
0xb4, 0x73, 0x35, 0x8b, 0x0f, 0x10, 0x24, 0x6f, 0x42, 0x90, 0x2e, 0xd7, 0xb4, 0x10, 0x24, 0xa0, 0xfe, 0x08, 0x0e,
0x10, 0x24, 0x38, 0x54, 0x13, 0x24, 0xa3, 0x46, 0x03, 0x22, 0x13, 0x24, 0x45, 0xfd, 0x0b, 0x0e, 0x11, 0x24, 0x04,
0x43, 0x08, 0x22, 0x80, 0x2e, 0xd7, 0xb4, 0xb1, 0x6f, 0x00, 0x3a, 0x08, 0x0e, 0x11, 0x24, 0x3d, 0x45, 0x10, 0x24,
0x52, 0x54, 0x48, 0x22, 0x10, 0x24, 0x8f, 0x01, 0x58, 0x0e, 0x10, 0x24, 0x48, 0x44, 0x01, 0x22, 0x80, 0x2e, 0xd7,
0xb4, 0xb1, 0x6f, 0x13, 0x24, 0xfa, 0x03, 0x0b, 0x0e, 0x11, 0x24, 0x85, 0x43, 0x13, 0x24, 0x35, 0x55, 0x4b, 0x22,
0x11, 0xa2, 0x10, 0x24, 0xf6, 0x57, 0x08, 0x22, 0x80, 0x2e, 0xd7, 0xb4, 0x11, 0x24, 0xa4, 0x0a, 0x69, 0x0e, 0x11,
0x24, 0x7b, 0x5a, 0x10, 0x24, 0x5e, 0x20, 0x08, 0x22, 0x80, 0x2e, 0xd7, 0xb4, 0x11, 0x24, 0x0f, 0x01, 0x59, 0x0e,
0x0d, 0x2f, 0x18, 0xa2, 0x11, 0x24, 0x2b, 0x47, 0x10, 0x24, 0xf4, 0x55, 0x48, 0x22, 0x10, 0x24, 0x16, 0x0b, 0x50,
0x0e, 0x10, 0x24, 0xc7, 0x51, 0x01, 0x22, 0x80, 0x2e, 0xd7, 0xb4, 0x11, 0x24, 0x72, 0x0a, 0x51, 0x0e, 0x11, 0x24,
0x85, 0x55, 0x10, 0x24, 0xb2, 0x47, 0x08, 0x22, 0x80, 0x2e, 0xd7, 0xb4, 0x10, 0x24, 0x83, 0x00, 0x48, 0x0e, 0x53,
0x2f, 0x11, 0x24, 0xe1, 0x07, 0x69, 0x0e, 0x2d, 0x2f, 0x95, 0xaf, 0x27, 0x2f, 0x82, 0xaf, 0x21, 0x2f, 0x11, 0x24,
0xd7, 0x00, 0x59, 0x0e, 0x19, 0x2f, 0xb1, 0x6f, 0x10, 0x24, 0xcc, 0x03, 0x88, 0x0f, 0x10, 0x2f, 0x10, 0x24, 0xe8,
0xfe, 0x08, 0x0e, 0x11, 0x24, 0x7e, 0x56, 0x10, 0x24, 0x94, 0x45, 0x48, 0x22, 0xc0, 0x6f, 0x13, 0x24, 0x06, 0x0b,
0x43, 0x0e, 0x10, 0x24, 0x2f, 0x51, 0x01, 0x22, 0x80, 0x2e, 0xd7, 0xb4, 0x10, 0x24, 0xde, 0x51, 0x80, 0x2e, 0xd7,
0xb4, 0x10, 0x24, 0xe8, 0x54, 0x80, 0x2e, 0xd7, 0xb4, 0x10, 0x24, 0xa4, 0x52, 0x80, 0x2e, 0xd7, 0xb4, 0x10, 0x24,
0xd0, 0x44, 0x80, 0x2e, 0xd7, 0xb4, 0x11, 0x24, 0xb8, 0x00, 0xd9, 0x0f, 0x19, 0x2f, 0xc1, 0x6f, 0x10, 0x24, 0xe7,
0x0c, 0xc8, 0x0f, 0x10, 0x2f, 0x11, 0x24, 0xc7, 0x07, 0x69, 0x0e, 0x11, 0x24, 0xf6, 0x52, 0x10, 0x24, 0x7a, 0x12,
0x48, 0x22, 0xb0, 0x6f, 0x13, 0x24, 0x5d, 0x02, 0x03, 0x0e, 0x10, 0x24, 0x7c, 0x54, 0x01, 0x22, 0x80, 0x2e, 0xd7,
0xb4, 0x10, 0x24, 0x8d, 0x51, 0x80, 0x2e, 0xd7, 0xb4, 0x10, 0x24, 0x28, 0x52, 0x80, 0x2e, 0xd7, 0xb4, 0x10, 0x24,
0xd2, 0x07, 0xe8, 0x0f, 0x28, 0x2f, 0x10, 0x24, 0xb0, 0x00, 0xd8, 0x0f, 0x20, 0x2f, 0x10, 0x24, 0xc6, 0x07, 0x68,
0x0e, 0x18, 0x2f, 0x50, 0x35, 0x48, 0x0e, 0x11, 0x2f, 0xb1, 0x6f, 0x10, 0x24, 0xf4, 0x01, 0x08, 0x0e, 0x11, 0x24,
0x35, 0x51, 0x10, 0x24, 0x22, 0x12, 0x48, 0x22, 0xc0, 0x6f, 0x13, 0x24, 0xe0, 0x0c, 0x43, 0x0e, 0x10, 0x24, 0x7b,
0x50, 0x08, 0x22, 0x80, 0x2e, 0xd7, 0xb4, 0x10, 0x24, 0x81, 0x52, 0x80, 0x2e, 0xd7, 0xb4, 0x10, 0x24, 0x3b, 0x53,
0x80, 0x2e, 0xd7, 0xb4, 0x10, 0x24, 0x63, 0x51, 0x80, 0x2e, 0xd7, 0xb4, 0x10, 0x24, 0x27, 0x51, 0x80, 0x2e, 0xd7,
0xb4, 0x18, 0xa2, 0x90, 0x2e, 0xdb, 0xb3, 0x12, 0x24, 0x08, 0x02, 0x4a, 0x0e, 0x37, 0x2f, 0x12, 0x24, 0x2a, 0x09,
0x6a, 0x0e, 0x1d, 0x2f, 0x13, 0x24, 0x8e, 0x00, 0x73, 0x0e, 0x09, 0x2f, 0x11, 0x24, 0xa5, 0x01, 0x41, 0x0e, 0x11,
0x24, 0x76, 0x32, 0x10, 0x24, 0x12, 0x25, 0x08, 0x22, 0x80, 0x2e, 0xd7, 0xb4, 0x10, 0x24, 0xa9, 0x0d, 0x68, 0x0e,
0x10, 0x24, 0x04, 0x27, 0x13, 0x24, 0x73, 0x20, 0x03, 0x22, 0x13, 0x24, 0x14, 0x04, 0x4b, 0x0e, 0x11, 0x24, 0x15,
0x2c, 0x01, 0x22, 0x80, 0x2e, 0xd7, 0xb4, 0x11, 0x24, 0xae, 0x08, 0x69, 0x0e, 0x08, 0x2f, 0xa1, 0x35, 0x71, 0x0e,
0x11, 0x24, 0x8b, 0x2b, 0x10, 0x24, 0x07, 0x35, 0x08, 0x22, 0x80, 0x2e, 0xd7, 0xb4, 0x91, 0x34, 0x59, 0x0e, 0x11,
0x24, 0x7b, 0x19, 0x10, 0x24, 0x50, 0x59, 0x08, 0x22, 0x80, 0x2e, 0xd7, 0xb4, 0x62, 0x32, 0x42, 0x0e, 0x22, 0x2f,
0xa2, 0x32, 0x5a, 0x0e, 0x1b, 0x2f, 0x12, 0x24, 0x0b, 0x08, 0x6a, 0x0e, 0x0e, 0x2f, 0xa3, 0x34, 0x43, 0x0e, 0x10,
0x24, 0x28, 0x2b, 0x13, 0x24, 0x20, 0x23, 0x03, 0x22, 0x13, 0x24, 0x8d, 0x01, 0x4b, 0x0e, 0x11, 0x24, 0x5c, 0x21,
0x08, 0x22, 0x80, 0x2e, 0xd7, 0xb4, 0x31, 0x36, 0x59, 0x0e, 0x11, 0x24, 0x43, 0x25, 0x10, 0x24, 0xfa, 0x49, 0x08,
0x22, 0x80, 0x2e, 0xd7, 0xb4, 0x10, 0x24, 0xc7, 0x2a, 0x80, 0x2e, 0xd7, 0xb4, 0x40, 0x36, 0x58, 0x0e, 0x09, 0x2f,
0x11, 0x24, 0x9e, 0x08, 0x69, 0x0e, 0x11, 0x24, 0xe3, 0x54, 0x10, 0x24, 0x73, 0x22, 0x08, 0x22, 0x80, 0x2e, 0xd7,
0xb4, 0x10, 0x24, 0x38, 0x01, 0xc8, 0x0f, 0x10, 0x2f, 0x11, 0x24, 0x11, 0x08, 0x69, 0x0e, 0x11, 0x24, 0x6e, 0x48,
0x10, 0x24, 0x2b, 0x28, 0x48, 0x22, 0xc0, 0x6f, 0x13, 0x24, 0xc1, 0x0a, 0x43, 0x0e, 0x10, 0x24, 0x0f, 0x23, 0x08,
0x22, 0x80, 0x2e, 0xd7, 0xb4, 0x10, 0x24, 0xd0, 0x1a, 0x80, 0x2e, 0xd7, 0xb4, 0xe2, 0x33, 0x5a, 0x0e, 0x77, 0x2f,
0x12, 0x24, 0x0c, 0x08, 0x6a, 0x0e, 0x2a, 0x2f, 0x12, 0x24, 0xc5, 0x00, 0x4a, 0x0e, 0x08, 0x2f, 0x11, 0x36, 0x59,
0x0e, 0x11, 0x24, 0xfd, 0x18, 0x10, 0x24, 0x75, 0x58, 0x08, 0x22, 0x80, 0x2e, 0xd7, 0xb4, 0xc2, 0x34, 0x5a, 0x0e,
0x0d, 0x2f, 0x11, 0x24, 0x36, 0x08, 0x69, 0x0e, 0x11, 0x24, 0x08, 0x58, 0x13, 0x24, 0x3b, 0x54, 0x4b, 0x22, 0x01,
0xa2, 0x10, 0x24, 0xc6, 0x52, 0x08, 0x22, 0x80, 0x2e, 0xd7, 0xb4, 0xb3, 0x36, 0x4b, 0x0e, 0x11, 0x24, 0x0e, 0x24,
0x13, 0x24, 0x7b, 0x50, 0x59, 0x22, 0x0e, 0xa2, 0x10, 0x24, 0xf7, 0x56, 0x01, 0x22, 0x80, 0x2e, 0xd7, 0xb4, 0xc2,
0x35, 0x5a, 0x0e, 0x12, 0x2f, 0x01, 0xa2, 0x0c, 0x2f, 0x84, 0xa3, 0x10, 0x24, 0xd4, 0x58, 0x13, 0x24, 0x76, 0x56,
0x03, 0x22, 0x73, 0x36, 0x4b, 0x0e, 0x11, 0x24, 0xeb, 0x52, 0x08, 0x22, 0x80, 0x2e, 0xd7, 0xb4, 0x10, 0x24, 0x87,
0x16, 0x80, 0x2e, 0xd7, 0xb4, 0xb0, 0x6f, 0x13, 0x24, 0x02, 0xfd, 0x03, 0x0e, 0x29, 0x2f, 0x84, 0xa3, 0xc0, 0x6f,
0x09, 0x2f, 0x11, 0x24, 0xe4, 0x0a, 0x41, 0x0e, 0x11, 0x24, 0x5d, 0x44, 0x10, 0x24, 0x2f, 0x5a, 0x08, 0x22, 0x80,
0x2e, 0xd7, 0xb4, 0x13, 0x24, 0x96, 0x0c, 0x43, 0x0e, 0x0e, 0x2f, 0x40, 0x33, 0x48, 0x0e, 0x10, 0x24, 0xf2, 0x18,
0x13, 0x24, 0x31, 0x49, 0x03, 0x22, 0x13, 0x24, 0x99, 0x00, 0x4b, 0x0e, 0x11, 0x24, 0xab, 0x18, 0x01, 0x22, 0x80,
0x2e, 0xd7, 0xb4, 0x11, 0x24, 0xc6, 0x07, 0x69, 0x0e, 0x11, 0x24, 0xb0, 0x49, 0x10, 0x24, 0xbf, 0x17, 0x08, 0x22,
0x80, 0x2e, 0xd7, 0xb4, 0x10, 0x24, 0x03, 0x15, 0x80, 0x2e, 0xd7, 0xb4, 0xb0, 0x32, 0x48, 0x0e, 0x57, 0x2f, 0xa0,
0x37, 0x48, 0x0e, 0x13, 0x2f, 0x83, 0xa3, 0x08, 0x2f, 0x10, 0x24, 0xe0, 0x00, 0x48, 0x0e, 0x11, 0x24, 0xf6, 0x25,
0x10, 0x24, 0x75, 0x17, 0x71, 0x2c, 0x08, 0x22, 0x10, 0x24, 0xa0, 0x00, 0x48, 0x0e, 0x11, 0x24, 0x7f, 0x18, 0x10,
0x24, 0xa6, 0x13, 0x68, 0x2c, 0x08, 0x22, 0x11, 0x24, 0xf9, 0x07, 0x69, 0x0e, 0x0d, 0x2f, 0x11, 0x24, 0x10, 0x08,
0x69, 0x0e, 0x11, 0x24, 0xb1, 0x14, 0x10, 0x24, 0x8e, 0x58, 0x48, 0x22, 0x90, 0x32, 0x58, 0x0e, 0x10, 0x24, 0x6d,
0x14, 0x56, 0x2c, 0x01, 0x22, 0xc1, 0x6f, 0x10, 0x24, 0x68, 0x0c, 0x48, 0x0e, 0xb1, 0x6f, 0x0c, 0x2f, 0xcd, 0xa2,
0x10, 0x24, 0x23, 0x14, 0x13, 0x24, 0x8d, 0x42, 0x03, 0x22, 0x13, 0x24, 0x2a, 0xfd, 0x0b, 0x0e, 0x11, 0x24, 0x53,
0x12, 0x43, 0x2c, 0x08, 0x22, 0x10, 0x24, 0xcc, 0x07, 0x68, 0x0e, 0x0e, 0x2f, 0x10, 0x24, 0x08, 0xfd, 0x08, 0x0e,
0x10, 0x24, 0x08, 0x16, 0x13, 0x24, 0x83, 0x45, 0x03, 0x22, 0x13, 0x24, 0xa1, 0xfd, 0x0b, 0x0e, 0x11, 0x24, 0xa6,
0x14, 0x30, 0x2c, 0x01, 0x22, 0x10, 0x24, 0x5b, 0x01, 0x08, 0x0e, 0x11, 0x24, 0x2f, 0x12, 0x10, 0x24, 0xdd, 0x44,
0x27, 0x2c, 0x08, 0x22, 0xdb, 0xa2, 0x0f, 0x2f, 0xc1, 0x6f, 0x10, 0x24, 0xb2, 0x0b, 0x48, 0x0e, 0x11, 0x24, 0x21,
0x55, 0x10, 0x24, 0xc8, 0x14, 0x48, 0x22, 0x10, 0x24, 0x4c, 0x08, 0x68, 0x0e, 0x10, 0x24, 0xe4, 0x57, 0x15, 0x2c,
0x01, 0x22, 0x44, 0xa2, 0x0f, 0x2f, 0xc1, 0x6f, 0x10, 0x24, 0xcb, 0x0b, 0x48, 0x0e, 0x11, 0x24, 0x09, 0x58, 0x10,
0x24, 0xe4, 0x10, 0x48, 0x22, 0x10, 0x24, 0x4d, 0x08, 0x68, 0x0e, 0x10, 0x24, 0x1a, 0x12, 0x03, 0x2c, 0x01, 0x22,
0x10, 0x24, 0x0c, 0x10, 0xfb, 0x6f, 0xb0, 0x5f, 0xb8, 0x2e, 0xa3, 0x32, 0xc3, 0x00, 0x60, 0x51, 0xc2, 0x40, 0x81,
0x84, 0xd3, 0x7f, 0xd2, 0x42, 0xe0, 0x7f, 0x00, 0x30, 0xc4, 0x40, 0x20, 0x02, 0xc3, 0x7f, 0xd0, 0x42, 0x42, 0x3d,
0xc0, 0x40, 0x01, 0x80, 0xc0, 0x42, 0xda, 0x00, 0x93, 0x7f, 0xb1, 0x7f, 0xab, 0x7f, 0x98, 0x2e, 0xb3, 0xc0, 0x91,
0x6f, 0xf3, 0x32, 0x40, 0x42, 0x00, 0xac, 0x8b, 0x00, 0x02, 0x2f, 0xe1, 0x6f, 0x39, 0x56, 0x43, 0x42, 0xa1, 0x82,
0x91, 0x7f, 0x33, 0x33, 0x4b, 0x00, 0x81, 0x7f, 0x13, 0x3c, 0x4b, 0x00, 0x80, 0x40, 0x53, 0x34, 0xb5, 0x6f, 0x8b,
0x00, 0x0d, 0xb0, 0x43, 0x87, 0x76, 0x7f, 0xb2, 0x7f, 0x63, 0x7f, 0x65, 0x25, 0xb5, 0x6f, 0x92, 0x41, 0x63, 0x41,
0x64, 0x41, 0x44, 0x81, 0x56, 0x7f, 0x41, 0x7f, 0x00, 0x2e, 0x26, 0x40, 0x27, 0x40, 0x45, 0x41, 0xf7, 0x7f, 0xb0,
0x7f, 0x98, 0x2e, 0x67, 0xcc, 0x81, 0x6f, 0x0f, 0xa4, 0x43, 0x40, 0x72, 0x6f, 0x94, 0x6f, 0x05, 0x30, 0x01, 0x2f,
0xc0, 0xa0, 0x03, 0x2f, 0x31, 0xac, 0x07, 0x2f, 0xc0, 0xa4, 0x05, 0x2f, 0xa2, 0x00, 0xeb, 0x04, 0x80, 0x40, 0x01,
0x80, 0x43, 0x42, 0x80, 0x42, 0x41, 0x86, 0x56, 0x6f, 0x62, 0x6f, 0x41, 0x6f, 0x42, 0x82, 0x72, 0x0e, 0x83, 0x7f,
0xd5, 0x2f, 0x53, 0x32, 0x8b, 0x00, 0xa1, 0x86, 0x56, 0x25, 0xf0, 0x82, 0x82, 0x40, 0x8d, 0xb0, 0x52, 0x40, 0xde,
0x00, 0x91, 0x7f, 0xb3, 0x7f, 0x85, 0x7f, 0xb3, 0x30, 0x7b, 0x52, 0x98, 0x2e, 0x5a, 0xca, 0x1a, 0x25, 0x83, 0x6f,
0x6d, 0x82, 0xfd, 0x88, 0x50, 0x7f, 0x71, 0x7f, 0x81, 0x7f, 0x05, 0x30, 0x83, 0x30, 0x00, 0x30, 0x11, 0x41, 0x52,
0x6f, 0x25, 0x7f, 0x30, 0x7f, 0x44, 0x7f, 0x98, 0x2e, 0x0f, 0xca, 0x73, 0x6f, 0x20, 0x25, 0x90, 0x6f, 0x7d, 0x52,
0xd2, 0x42, 0x73, 0x7f, 0x12, 0x7f, 0x98, 0x2e, 0x86, 0xb7, 0x93, 0x6f, 0x11, 0x6f, 0xd2, 0x40, 0x0a, 0x18, 0x31,
0x6f, 0x0e, 0x00, 0x93, 0x7f, 0x83, 0x30, 0x44, 0x6f, 0x21, 0x6f, 0x62, 0x6f, 0x62, 0x0e, 0x4f, 0x03, 0xe1, 0x2f,
0x33, 0x52, 0x01, 0x00, 0x01, 0x30, 0x69, 0x03, 0x3a, 0x25, 0xea, 0x82, 0x92, 0x6f, 0xf0, 0x86, 0xd1, 0xbe, 0x0f,
0xb8, 0xbd, 0x84, 0x94, 0x7f, 0x05, 0x0a, 0x23, 0x7f, 0x52, 0x7f, 0x40, 0x7f, 0x31, 0x7f, 0x71, 0x7f, 0xd3, 0x30,
0x84, 0x6f, 0x55, 0x6f, 0x10, 0x41, 0x52, 0x41, 0x41, 0x6f, 0x55, 0x7f, 0x10, 0x7f, 0x04, 0x7f, 0x98, 0x2e, 0x0f,
0xca, 0x11, 0x6f, 0x20, 0x25, 0x98, 0x2e, 0xfe, 0xc9, 0x31, 0x6f, 0x04, 0x6f, 0x50, 0x42, 0x31, 0x7f, 0xd3, 0x30,
0x21, 0x6f, 0x61, 0x0e, 0xea, 0x2f, 0xb1, 0x6f, 0x41, 0x84, 0x32, 0x25, 0x90, 0x40, 0x84, 0x40, 0x71, 0x6f, 0xb4,
0x7f, 0x72, 0x7f, 0x40, 0x7f, 0x33, 0x7f, 0x98, 0x2e, 0xb3, 0xc0, 0x53, 0x6f, 0xb1, 0x32, 0x99, 0x00, 0x83, 0xb9,
0x41, 0x6f, 0x4b, 0x00, 0xb0, 0x6f, 0x03, 0x30, 0xc3, 0x02, 0x84, 0x40, 0xb2, 0x7f, 0xa1, 0x84, 0x0d, 0xb1, 0x52,
0x7f, 0x56, 0x01, 0x74, 0x6f, 0x30, 0x6f, 0x92, 0x6f, 0x43, 0x8b, 0x03, 0x43, 0x01, 0x42, 0x95, 0x7f, 0xbd, 0x86,
0x51, 0x41, 0x41, 0x7f, 0x75, 0x7f, 0x00, 0x2e, 0xd1, 0x40, 0x42, 0x41, 0x32, 0x7f, 0x23, 0x7f, 0x98, 0x2e, 0x74,
0xc0, 0x41, 0x6f, 0xc8, 0x00, 0x90, 0x6f, 0x01, 0x30, 0x75, 0x6f, 0x32, 0x6f, 0x03, 0x42, 0x91, 0x02, 0x23, 0x6f,
0x61, 0x6f, 0x59, 0x0e, 0x62, 0x43, 0x95, 0x7f, 0xe7, 0x2f, 0xb2, 0x6f, 0x51, 0x6f, 0x82, 0x40, 0x8d, 0xb0, 0x8e,
0x00, 0xfd, 0x8a, 0xb2, 0x7f, 0x02, 0x30, 0x79, 0x52, 0x05, 0x25, 0x03, 0x30, 0x54, 0x40, 0xec, 0x01, 0x16, 0x40,
0x43, 0x89, 0xc7, 0x41, 0x37, 0x18, 0x3d, 0x8b, 0x96, 0x00, 0x44, 0x0e, 0xdf, 0x02, 0xf4, 0x2f, 0x09, 0x52, 0x51,
0x00, 0x02, 0x30, 0x9a, 0x02, 0xb5, 0x6f, 0x45, 0x87, 0x1b, 0xba, 0x25, 0xbc, 0x51, 0x6f, 0x4d, 0x8b, 0x7a, 0x82,
0xc6, 0x40, 0x20, 0x0a, 0x30, 0x00, 0xd0, 0x42, 0x2b, 0xb5, 0xc0, 0x40, 0x82, 0x02, 0x40, 0x34, 0x08, 0x00, 0xd2,
0x42, 0xb0, 0x7f, 0x75, 0x7f, 0x93, 0x7f, 0x00, 0x2e, 0xb5, 0x6f, 0xe2, 0x6f, 0x63, 0x41, 0x64, 0x41, 0x44, 0x8f,
0x82, 0x40, 0xe6, 0x41, 0xc0, 0x41, 0xc4, 0x8f, 0x45, 0x41, 0xf0, 0x7f, 0xb7, 0x7f, 0x61, 0x7f, 0x98, 0x2e, 0x67,
0xcc, 0x00, 0x18, 0x09, 0x52, 0x71, 0x00, 0x03, 0x30, 0xbb, 0x02, 0x1b, 0xba, 0x93, 0x6f, 0x25, 0xbc, 0x61, 0x6f,
0xc5, 0x40, 0x42, 0x82, 0x20, 0x0a, 0x28, 0x00, 0xd0, 0x42, 0x2b, 0xb9, 0xc0, 0x40, 0x82, 0x02, 0xd2, 0x42, 0x93,
0x7f, 0x00, 0x2e, 0x72, 0x6f, 0x5a, 0x0e, 0xd9, 0x2f, 0xb1, 0x6f, 0xf3, 0x3c, 0xcb, 0x00, 0xda, 0x82, 0xc3, 0x40,
0x41, 0x40, 0x59, 0x0e, 0x50, 0x2f, 0xe1, 0x6f, 0xe3, 0x32, 0xcb, 0x00, 0xb3, 0x7f, 0x22, 0x30, 0xc0, 0x40, 0x01,
0x80, 0xc0, 0x42, 0x02, 0xa2, 0x30, 0x2f, 0xc2, 0x42, 0x98, 0x2e, 0x83, 0xb1, 0xe1, 0x6f, 0xb3, 0x35, 0xcb, 0x00,
0x24, 0x3d, 0xc2, 0x40, 0xdc, 0x00, 0x84, 0x40, 0x00, 0x91, 0x93, 0x7f, 0x02, 0x2f, 0x00, 0x2e, 0x06, 0x2c, 0x0c,
0xb8, 0x30, 0x25, 0x00, 0x33, 0x48, 0x00, 0x98, 0x2e, 0xf6, 0xb6, 0x91, 0x6f, 0x90, 0x7f, 0x00, 0x2e, 0x44, 0x40,
0x20, 0x1a, 0x15, 0x2f, 0xd3, 0x6f, 0xc1, 0x6f, 0xc3, 0x40, 0x35, 0x5a, 0x42, 0x40, 0xd3, 0x7e, 0x08, 0xbc, 0x25,
0x09, 0xe2, 0x7e, 0xc4, 0x0a, 0x42, 0x82, 0xf3, 0x7e, 0xd1, 0x7f, 0x34, 0x30, 0x83, 0x6f, 0x82, 0x30, 0x31, 0x30,
0x98, 0x2e, 0xb3, 0x00, 0xd1, 0x6f, 0x93, 0x6f, 0x43, 0x42, 0xf0, 0x32, 0xb1, 0x6f, 0x41, 0x82, 0xe2, 0x6f, 0x43,
0x40, 0xc1, 0x86, 0xc2, 0xa2, 0x43, 0x42, 0x03, 0x30, 0x02, 0x2f, 0x90, 0x00, 0x00, 0x2e, 0x83, 0x42, 0x61, 0x88,
0x42, 0x40, 0x8d, 0xb0, 0x26, 0x00, 0x98, 0x2e, 0xd9, 0x03, 0x1c, 0x83, 0x00, 0x2e, 0x43, 0x42, 0x00, 0x2e, 0xab,
0x6f, 0xa0, 0x5e, 0xb8, 0x2e, 0xb1, 0x35, 0x40, 0x51, 0x41, 0x01, 0x02, 0x30, 0x1a, 0x25, 0x13, 0x30, 0x40, 0x25,
0x12, 0x42, 0x45, 0x0e, 0xfc, 0x2f, 0x65, 0x34, 0x28, 0x80, 0x25, 0x01, 0x13, 0x42, 0x44, 0x0e, 0xfc, 0x2f, 0x27,
0x80, 0x65, 0x56, 0x03, 0x42, 0x15, 0x80, 0xa3, 0x30, 0x03, 0x42, 0x04, 0x80, 0x4d, 0x56, 0x7f, 0x58, 0x13, 0x42,
0xd4, 0x7e, 0xc2, 0x7e, 0xf2, 0x7e, 0x6c, 0x8c, 0x81, 0x56, 0x83, 0x58, 0xe3, 0x7e, 0x04, 0x7f, 0x71, 0x8a, 0x97,
0x41, 0x17, 0x42, 0x75, 0x0e, 0xfb, 0x2f, 0x85, 0x5c, 0x87, 0x5e, 0x16, 0x7f, 0x36, 0x7f, 0x27, 0x7f, 0x00, 0x2e,
0x89, 0x5c, 0x8b, 0x5e, 0x46, 0x7f, 0x57, 0x7f, 0x76, 0x8c, 0x57, 0x41, 0x17, 0x42, 0x6e, 0x0e, 0xfb, 0x2f, 0x8d,
0x5a, 0x8f, 0x5e, 0x65, 0x7f, 0x87, 0x7f, 0x72, 0x7f, 0x00, 0x2e, 0x91, 0x5a, 0x93, 0x5e, 0x95, 0x7f, 0xa7, 0x7f,
0x7b, 0x8a, 0x97, 0x41, 0x17, 0x42, 0x75, 0x0e, 0xfb, 0x2f, 0x7f, 0x5c, 0xb2, 0x7f, 0xc6, 0x7f, 0xd3, 0x7f, 0xe2,
0x7f, 0xf4, 0x7f, 0x40, 0x82, 0x52, 0x41, 0x12, 0x42, 0x69, 0x0e, 0xfb, 0x2f, 0xc0, 0x5e, 0xb8, 0x2e, 0x03, 0x2e,
0x2d, 0x02, 0x9f, 0xbc, 0x9f, 0xb8, 0x20, 0x50, 0x40, 0xb2, 0x14, 0x2f, 0x10, 0x25, 0x01, 0x2e, 0x8d, 0x00, 0x00,
0x90, 0x0b, 0x2f, 0x97, 0x50, 0xf1, 0x7f, 0xeb, 0x7f, 0x98, 0x2e, 0x83, 0xb6, 0x01, 0x2e, 0x8d, 0x00, 0x01, 0x80,
0x21, 0x2e, 0x8d, 0x00, 0xf1, 0x6f, 0xeb, 0x6f, 0xe0, 0x5f, 0x97, 0x50, 0x80, 0x2e, 0xda, 0xb4, 0x00, 0x30, 0x21,
0x2e, 0x8d, 0x00, 0xe0, 0x5f, 0xb8, 0x2e, 0x41, 0x25, 0x42, 0x8a, 0x50, 0x50, 0x99, 0x52, 0x81, 0x80, 0x99, 0x09,
0xf5, 0x7f, 0x52, 0x25, 0x07, 0x52, 0x03, 0x8e, 0xd9, 0x08, 0x02, 0x40, 0x03, 0x81, 0x44, 0x83, 0x6c, 0xbb, 0xda,
0x0e, 0xe7, 0x7f, 0xdb, 0x7f, 0x20, 0x2f, 0x02, 0x41, 0x32, 0x1a, 0x1d, 0x2f, 0x42, 0x85, 0x00, 0x2e, 0x82, 0x40,
0xda, 0x0e, 0x03, 0x30, 0x05, 0x2f, 0xf1, 0x6f, 0x06, 0x30, 0x42, 0x40, 0x81, 0x84, 0x18, 0x2c, 0x42, 0x42, 0xbf,
0x85, 0x82, 0x00, 0x41, 0x40, 0x86, 0x40, 0x81, 0x8d, 0x86, 0x42, 0x20, 0x25, 0x13, 0x30, 0x06, 0x30, 0x97, 0x40,
0x81, 0x8d, 0xf9, 0x0f, 0x09, 0x2f, 0x85, 0xa3, 0xf9, 0x2f, 0x03, 0x30, 0x06, 0x2c, 0x06, 0x30, 0x9b, 0x52, 0xd9,
0x0e, 0x13, 0x30, 0x01, 0x30, 0xd9, 0x22, 0xc0, 0xb2, 0x12, 0x83, 0xc1, 0x7f, 0x03, 0x30, 0xb4, 0x7f, 0x06, 0x2f,
0x51, 0x30, 0x70, 0x25, 0x98, 0x2e, 0xe3, 0x03, 0xff, 0x81, 0x00, 0x2e, 0x03, 0x42, 0x43, 0x8b, 0xe0, 0x6f, 0xf1,
0x6f, 0x00, 0x40, 0x41, 0x40, 0xc8, 0x0f, 0x37, 0x2f, 0x00, 0x41, 0x80, 0xa7, 0x3c, 0x2f, 0x01, 0x83, 0x47, 0x8e,
0x42, 0x40, 0xfa, 0x01, 0x81, 0x84, 0x08, 0x89, 0x45, 0x41, 0x55, 0x0e, 0xc6, 0x43, 0x42, 0x42, 0xf4, 0x7f, 0x00,
0x2f, 0x43, 0x42, 0x51, 0x82, 0x70, 0x1a, 0x41, 0x40, 0x06, 0x2f, 0xc3, 0x6f, 0x41, 0x82, 0xc1, 0x42, 0xcd, 0x0e,
0x26, 0x2f, 0xc5, 0x42, 0x25, 0x2d, 0x7f, 0x82, 0x51, 0xbb, 0xa5, 0x00, 0xce, 0x0f, 0x12, 0x2f, 0x14, 0x30, 0x05,
0x30, 0xf7, 0x6f, 0x06, 0x30, 0x05, 0x2c, 0xe0, 0x7f, 0xd0, 0x41, 0x05, 0x1a, 0x23, 0x22, 0xb0, 0x01, 0x7a, 0x0e,
0xf9, 0x2f, 0x71, 0x0f, 0xe0, 0x6f, 0x28, 0x22, 0x41, 0x8b, 0x71, 0x22, 0x45, 0xa7, 0xee, 0x2f, 0xb3, 0x6f, 0xc2,
0x6f, 0xc0, 0x42, 0x81, 0x42, 0x08, 0x2d, 0x04, 0x25, 0xc4, 0x6f, 0x98, 0x2e, 0xea, 0x03, 0x00, 0x2e, 0x40, 0x41,
0x00, 0x43, 0x00, 0x30, 0xdb, 0x6f, 0xb0, 0x5f, 0xb8, 0x2e, 0x10, 0x50, 0x03, 0x40, 0x19, 0x18, 0x37, 0x56, 0x19,
0x05, 0x36, 0x25, 0xf7, 0x7f, 0x4a, 0x17, 0x54, 0x18, 0xec, 0x18, 0x09, 0x17, 0x01, 0x30, 0x0c, 0x07, 0xe2, 0x18,
0xde, 0x00, 0xf2, 0x6f, 0x97, 0x02, 0x33, 0x58, 0xdc, 0x00, 0x91, 0x02, 0xbf, 0xb8, 0x21, 0xbd, 0x8a, 0x0a, 0xc0,
0x2e, 0x02, 0x42, 0xf0, 0x5f, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e,
0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80,
0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1,
0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00,
0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e,
0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80,
0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1,
0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00,
0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e,
0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80,
0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x01, 0x2e, 0x5d, 0xf7, 0x08, 0xbc, 0x80, 0xac, 0x0e, 0xbb, 0x02, 0x2f,
0x00, 0x30, 0x41, 0x04, 0x82, 0x06, 0xc0, 0xa4, 0x00, 0x30, 0x11, 0x2f, 0x40, 0xa9, 0x03, 0x2f, 0x40, 0x91, 0x0d,
0x2f, 0x00, 0xa7, 0x0b, 0x2f, 0x80, 0xb3, 0x33, 0x58, 0x02, 0x2f, 0x90, 0xa1, 0x26, 0x13, 0x20, 0x23, 0x80, 0x90,
0x10, 0x30, 0x01, 0x2f, 0xcc, 0x0e, 0x00, 0x2f, 0x00, 0x30, 0xb8, 0x2e, 0x35, 0x50, 0x18, 0x08, 0x08, 0xbc, 0x88,
0xb6, 0x0d, 0x17, 0xc6, 0xbd, 0x56, 0xbc, 0x37, 0x58, 0xda, 0xba, 0x04, 0x01, 0x1d, 0x0a, 0x10, 0x50, 0x05, 0x30,
0x32, 0x25, 0x45, 0x03, 0xfb, 0x7f, 0xf6, 0x30, 0x21, 0x25, 0x98, 0x2e, 0x37, 0xca, 0x16, 0xb5, 0x9a, 0xbc, 0x06,
0xb8, 0x80, 0xa8, 0x41, 0x0a, 0x0e, 0x2f, 0x80, 0x90, 0x02, 0x2f, 0x39, 0x50, 0x48, 0x0f, 0x09, 0x2f, 0xbf, 0xa0,
0x04, 0x2f, 0xbf, 0x90, 0x06, 0x2f, 0x37, 0x54, 0xca, 0x0f, 0x03, 0x2f, 0x00, 0x2e, 0x02, 0x2c, 0x37, 0x52, 0x39,
0x52, 0xf2, 0x33, 0x98, 0x2e, 0xd9, 0xc0, 0xfb, 0x6f, 0xf1, 0x37, 0xc0, 0x2e, 0x01, 0x08, 0xf0, 0x5f, 0x41, 0x56,
0x3b, 0x54, 0xd0, 0x40, 0xc4, 0x40, 0x0b, 0x2e, 0xfd, 0xf3, 0x41, 0x52, 0x90, 0x42, 0x94, 0x42, 0x95, 0x42, 0x05,
0x30, 0x43, 0x50, 0x0f, 0x88, 0x06, 0x40, 0x04, 0x41, 0x96, 0x42, 0xc5, 0x42, 0x48, 0xbe, 0x73, 0x30, 0x0d, 0x2e,
0x88, 0x00, 0x4f, 0xba, 0x84, 0x42, 0x03, 0x42, 0x81, 0xb3, 0x02, 0x2f, 0x2b, 0x2e, 0x6f, 0xf5, 0x06, 0x2d, 0x05,
0x2e, 0x77, 0xf7, 0x3f, 0x56, 0x93, 0x08, 0x25, 0x2e, 0x77, 0xf7, 0x3d, 0x54, 0x25, 0x2e, 0xc2, 0xf5, 0x07, 0x2e,
0xfd, 0xf3, 0x42, 0x30, 0xb4, 0x33, 0xda, 0x0a, 0x4c, 0x00, 0x27, 0x2e, 0xfd, 0xf3, 0x43, 0x40, 0xd4, 0x3f, 0xdc,
0x08, 0x43, 0x42, 0x00, 0x2e, 0x00, 0x2e, 0x43, 0x40, 0x24, 0x30, 0xdc, 0x0a, 0x43, 0x42, 0x04, 0x80, 0x03, 0x2e,
0xfd, 0xf3, 0x4a, 0x0a, 0x23, 0x2e, 0xfd, 0xf3, 0x61, 0x34, 0xc0, 0x2e, 0x01, 0x42, 0x00, 0x2e, 0x60, 0x50, 0x1a,
0x25, 0x7a, 0x86, 0xe0, 0x7f, 0xf3, 0x7f, 0x03, 0x25, 0x45, 0x52, 0x41, 0x84, 0xdb, 0x7f, 0x33, 0x30, 0x98, 0x2e,
0x16, 0xc2, 0x1a, 0x25, 0x7d, 0x82, 0xf0, 0x6f, 0xe2, 0x6f, 0x32, 0x25, 0x16, 0x40, 0x94, 0x40, 0x26, 0x01, 0x85,
0x40, 0x8e, 0x17, 0xc4, 0x42, 0x6e, 0x03, 0x95, 0x42, 0x41, 0x0e, 0xf4, 0x2f, 0xdb, 0x6f, 0xa0, 0x5f, 0xb8, 0x2e,
0xb0, 0x51, 0xfb, 0x7f, 0x98, 0x2e, 0xe8, 0x0d, 0x5a, 0x25, 0x98, 0x2e, 0x0f, 0x0e, 0x4f, 0x58, 0x32, 0x87, 0xc4,
0x7f, 0x65, 0x89, 0x6b, 0x8d, 0x47, 0x5a, 0x65, 0x7f, 0xe1, 0x7f, 0x83, 0x7f, 0xa6, 0x7f, 0x74, 0x7f, 0xd0, 0x7f,
0xb6, 0x7f, 0x94, 0x7f, 0x17, 0x30, 0x49, 0x52, 0x4b, 0x54, 0x51, 0x7f, 0x00, 0x2e, 0x85, 0x6f, 0x42, 0x7f, 0x00,
0x2e, 0x51, 0x41, 0x45, 0x81, 0x42, 0x41, 0x13, 0x40, 0x3b, 0x8a, 0x00, 0x40, 0x4b, 0x04, 0xd0, 0x06, 0xc0, 0xac,
0x85, 0x7f, 0x02, 0x2f, 0x02, 0x30, 0x51, 0x04, 0xd3, 0x06, 0x41, 0x84, 0x05, 0x30, 0x5d, 0x02, 0xc9, 0x16, 0xdf,
0x08, 0xd3, 0x00, 0x8d, 0x02, 0xaf, 0xbc, 0xb1, 0xb9, 0x59, 0x0a, 0x65, 0x6f, 0x11, 0x43, 0xa1, 0xb4, 0x52, 0x41,
0x53, 0x41, 0x01, 0x43, 0x34, 0x7f, 0x65, 0x7f, 0x26, 0x31, 0xe5, 0x6f, 0xd4, 0x6f, 0x98, 0x2e, 0x37, 0xca, 0x32,
0x6f, 0x75, 0x6f, 0x83, 0x40, 0x42, 0x41, 0x23, 0x7f, 0x12, 0x7f, 0xf6, 0x30, 0x40, 0x25, 0x51, 0x25, 0x98, 0x2e,
0x37, 0xca, 0x14, 0x6f, 0x20, 0x05, 0x70, 0x6f, 0x25, 0x6f, 0x69, 0x07, 0xa2, 0x6f, 0x31, 0x6f, 0x0b, 0x30, 0x04,
0x42, 0x9b, 0x42, 0x8b, 0x42, 0x55, 0x42, 0x32, 0x7f, 0x40, 0xa9, 0xc3, 0x6f, 0x71, 0x7f, 0x02, 0x30, 0xd0, 0x40,
0xc3, 0x7f, 0x03, 0x2f, 0x40, 0x91, 0x15, 0x2f, 0x00, 0xa7, 0x13, 0x2f, 0x00, 0xa4, 0x11, 0x2f, 0x84, 0xbd, 0x98,
0x2e, 0x79, 0xca, 0x55, 0x6f, 0x37, 0x54, 0x54, 0x41, 0x82, 0x00, 0xf3, 0x3f, 0x45, 0x41, 0xcb, 0x02, 0xf6, 0x30,
0x98, 0x2e, 0x37, 0xca, 0x35, 0x6f, 0xa4, 0x6f, 0x41, 0x43, 0x03, 0x2c, 0x00, 0x43, 0xa4, 0x6f, 0x35, 0x6f, 0x17,
0x30, 0x42, 0x6f, 0x51, 0x6f, 0x93, 0x40, 0x42, 0x82, 0x00, 0x41, 0xc3, 0x00, 0x03, 0x43, 0x51, 0x7f, 0x00, 0x2e,
0x94, 0x40, 0x41, 0x41, 0x4c, 0x02, 0xc4, 0x6f, 0x55, 0x56, 0x63, 0x0e, 0x74, 0x6f, 0x51, 0x43, 0xa5, 0x7f, 0x8a,
0x2f, 0x09, 0x2e, 0x88, 0x00, 0x01, 0xb3, 0x21, 0x2f, 0x4f, 0x58, 0x90, 0x6f, 0x13, 0x41, 0xb6, 0x6f, 0xe4, 0x7f,
0x00, 0x2e, 0x91, 0x41, 0x14, 0x40, 0x92, 0x41, 0x15, 0x40, 0x17, 0x2e, 0x6f, 0xf5, 0xb6, 0x7f, 0xd0, 0x7f, 0xcb,
0x7f, 0x98, 0x2e, 0x00, 0x0c, 0x07, 0x15, 0xc2, 0x6f, 0x14, 0x0b, 0x29, 0x2e, 0x6f, 0xf5, 0xc3, 0xa3, 0xc1, 0x8f,
0xe4, 0x6f, 0xd0, 0x6f, 0xe6, 0x2f, 0x14, 0x30, 0x05, 0x2e, 0x6f, 0xf5, 0x14, 0x0b, 0x29, 0x2e, 0x6f, 0xf5, 0x18,
0x2d, 0x51, 0x56, 0x04, 0x32, 0xb5, 0x6f, 0x1c, 0x01, 0x51, 0x41, 0x52, 0x41, 0xc3, 0x40, 0xb5, 0x7f, 0xe4, 0x7f,
0x98, 0x2e, 0x1f, 0x0c, 0xe4, 0x6f, 0x21, 0x87, 0x00, 0x43, 0x04, 0x32, 0x53, 0x54, 0x5a, 0x0e, 0xef, 0x2f, 0x4d,
0x54, 0x09, 0x2e, 0x77, 0xf7, 0x22, 0x0b, 0x29, 0x2e, 0x77, 0xf7, 0xfb, 0x6f, 0x50, 0x5e, 0xb8, 0x2e, 0x10, 0x50,
0x01, 0x2e, 0x84, 0x00, 0x00, 0xb2, 0xfb, 0x7f, 0x51, 0x2f, 0x01, 0xb2, 0x48, 0x2f, 0x02, 0xb2, 0x42, 0x2f, 0x03,
0x90, 0x56, 0x2f, 0x5b, 0x52, 0x79, 0x80, 0x42, 0x40, 0x81, 0x84, 0x00, 0x40, 0x42, 0x42, 0x98, 0x2e, 0x93, 0x0c,
0x5d, 0x54, 0x5b, 0x50, 0xa1, 0x40, 0x98, 0xbd, 0x82, 0x40, 0x3e, 0x82, 0xda, 0x0a, 0x44, 0x40, 0x8b, 0x16, 0xe3,
0x00, 0x53, 0x42, 0x00, 0x2e, 0x43, 0x40, 0x9a, 0x02, 0x52, 0x42, 0x00, 0x2e, 0x41, 0x40, 0x4d, 0x54, 0x4a, 0x0e,
0x3a, 0x2f, 0x3a, 0x82, 0x00, 0x30, 0x41, 0x40, 0x21, 0x2e, 0x6c, 0x0f, 0x40, 0xb2, 0x0a, 0x2f, 0x98, 0x2e, 0xb1,
0x0c, 0x98, 0x2e, 0x45, 0x0e, 0x98, 0x2e, 0x5b, 0x0e, 0xfb, 0x6f, 0xf0, 0x5f, 0x00, 0x30, 0x80, 0x2e, 0xba, 0x03,
0x61, 0x52, 0x57, 0x54, 0x42, 0x42, 0x4f, 0x84, 0x73, 0x30, 0x5f, 0x52, 0x83, 0x42, 0x1b, 0x30, 0x6b, 0x42, 0x23,
0x30, 0x27, 0x2e, 0x87, 0x00, 0x37, 0x2e, 0x84, 0x00, 0x21, 0x2e, 0x86, 0x00, 0x7a, 0x84, 0x17, 0x2c, 0x42, 0x42,
0x30, 0x30, 0x21, 0x2e, 0x84, 0x00, 0x12, 0x2d, 0x21, 0x30, 0x00, 0x30, 0x23, 0x2e, 0x84, 0x00, 0x21, 0x2e, 0x7b,
0xf7, 0x0b, 0x2d, 0x17, 0x30, 0x98, 0x2e, 0x51, 0x0c, 0x59, 0x50, 0x0c, 0x82, 0x72, 0x30, 0x2f, 0x2e, 0x84, 0x00,
0x25, 0x2e, 0x7b, 0xf7, 0x40, 0x42, 0x00, 0x2e, 0xfb, 0x6f, 0xf0, 0x5f, 0xb8, 0x2e, 0x70, 0x50, 0x0a, 0x25, 0x39,
0x86, 0xfb, 0x7f, 0xe1, 0x32, 0x62, 0x30, 0x98, 0x2e, 0xc2, 0xc4, 0x35, 0x56, 0xa5, 0x6f, 0xab, 0x08, 0x91, 0x6f,
0x4b, 0x08, 0x63, 0x56, 0xc4, 0x6f, 0x23, 0x09, 0x4d, 0xba, 0x93, 0xbc, 0x8c, 0x0b, 0xd1, 0x6f, 0x0b, 0x09, 0x4f,
0x52, 0x65, 0x5e, 0x56, 0x42, 0xaf, 0x09, 0x4d, 0xba, 0x23, 0xbd, 0x94, 0x0a, 0xe5, 0x6f, 0x68, 0xbb, 0xeb, 0x08,
0xbd, 0xb9, 0x63, 0xbe, 0xfb, 0x6f, 0x52, 0x42, 0xe3, 0x0a, 0xc0, 0x2e, 0x43, 0x42, 0x90, 0x5f, 0x55, 0x50, 0x03,
0x2e, 0x25, 0xf3, 0x13, 0x40, 0x00, 0x40, 0x9b, 0xbc, 0x9b, 0xb4, 0x08, 0xbd, 0xb8, 0xb9, 0x98, 0xbc, 0xda, 0x0a,
0x08, 0xb6, 0x89, 0x16, 0xc0, 0x2e, 0x19, 0x00, 0x62, 0x02, 0x10, 0x50, 0xfb, 0x7f, 0x98, 0x2e, 0x81, 0x0d, 0x01,
0x2e, 0x84, 0x00, 0x31, 0x30, 0x08, 0x04, 0xfb, 0x6f, 0x01, 0x30, 0xf0, 0x5f, 0x23, 0x2e, 0x86, 0x00, 0x21, 0x2e,
0x87, 0x00, 0xb8, 0x2e, 0x01, 0x2e, 0x87, 0x00, 0x03, 0x2e, 0x86, 0x00, 0x48, 0x0e, 0x01, 0x2f, 0x80, 0x2e, 0x1f,
0x0e, 0xb8, 0x2e, 0x67, 0x50, 0x21, 0x34, 0x01, 0x42, 0x82, 0x30, 0xc1, 0x32, 0x25, 0x2e, 0x62, 0xf5, 0x01, 0x00,
0x22, 0x30, 0x01, 0x40, 0x4a, 0x0a, 0x01, 0x42, 0xb8, 0x2e, 0x67, 0x54, 0xf0, 0x3b, 0x83, 0x40, 0xd8, 0x08, 0x69,
0x52, 0x83, 0x42, 0x00, 0x30, 0x83, 0x30, 0x50, 0x42, 0xc4, 0x32, 0x27, 0x2e, 0x64, 0xf5, 0x94, 0x00, 0x50, 0x42,
0x40, 0x42, 0xd3, 0x3f, 0x84, 0x40, 0x7d, 0x82, 0xe3, 0x08, 0x40, 0x42, 0x83, 0x42, 0xb8, 0x2e, 0x61, 0x52, 0x00,
0x30, 0x40, 0x42, 0x7c, 0x86, 0x3b, 0x52, 0x09, 0x2e, 0x57, 0x0f, 0x41, 0x54, 0xc4, 0x42, 0xd3, 0x86, 0x54, 0x40,
0x55, 0x40, 0x94, 0x42, 0x85, 0x42, 0x21, 0x2e, 0x87, 0x00, 0x42, 0x40, 0x25, 0x2e, 0xfd, 0xf3, 0xc0, 0x42, 0x7e,
0x82, 0x05, 0x2e, 0x79, 0x00, 0x80, 0xb2, 0x14, 0x2f, 0x05, 0x2e, 0x24, 0x02, 0x27, 0xbd, 0x2f, 0xb9, 0x80, 0x90,
0x02, 0x2f, 0x21, 0x2e, 0x6f, 0xf5, 0x0c, 0x2d, 0x07, 0x2e, 0x58, 0x0f, 0x14, 0x30, 0x1c, 0x09, 0x05, 0x2e, 0x77,
0xf7, 0x3f, 0x56, 0x47, 0xbe, 0x93, 0x08, 0x94, 0x0a, 0x25, 0x2e, 0x77, 0xf7, 0x6b, 0x54, 0x50, 0x42, 0x4a, 0x0e,
0xfc, 0x2f, 0xb8, 0x2e, 0x50, 0x50, 0x02, 0x30, 0x43, 0x86, 0x69, 0x50, 0xfb, 0x7f, 0xe3, 0x7f, 0xd2, 0x7f, 0xc0,
0x7f, 0xb1, 0x7f, 0x00, 0x2e, 0x41, 0x40, 0x00, 0x40, 0x48, 0x04, 0x98, 0x2e, 0x74, 0xc0, 0x1e, 0xaa, 0xd3, 0x6f,
0x14, 0x30, 0xb1, 0x6f, 0xe3, 0x22, 0xc0, 0x6f, 0x52, 0x40, 0xe4, 0x6f, 0x4c, 0x0e, 0x12, 0x42, 0xd3, 0x7f, 0xeb,
0x2f, 0x03, 0x2e, 0x6d, 0x0f, 0x40, 0x90, 0x11, 0x30, 0x03, 0x2f, 0x23, 0x2e, 0x6d, 0x0f, 0x02, 0x2c, 0x00, 0x30,
0xd0, 0x6f, 0xfb, 0x6f, 0xb0, 0x5f, 0xb8, 0x2e, 0x40, 0x50, 0xf1, 0x7f, 0x0a, 0x25, 0x3c, 0x86, 0xeb, 0x7f, 0x41,
0x33, 0x22, 0x30, 0x98, 0x2e, 0xc2, 0xc4, 0xd3, 0x6f, 0xf4, 0x30, 0xdc, 0x09, 0x6f, 0x58, 0xc2, 0x6f, 0x94, 0x09,
0x71, 0x58, 0x6a, 0xbb, 0xdc, 0x08, 0xb4, 0xb9, 0xb1, 0xbd, 0x6d, 0x5a, 0x95, 0x08, 0x21, 0xbd, 0xf6, 0xbf, 0x77,
0x0b, 0x51, 0xbe, 0xf1, 0x6f, 0xeb, 0x6f, 0x52, 0x42, 0x54, 0x42, 0xc0, 0x2e, 0x43, 0x42, 0xc0, 0x5f, 0x50, 0x50,
0x75, 0x52, 0x93, 0x30, 0x53, 0x42, 0xfb, 0x7f, 0x7b, 0x30, 0x4b, 0x42, 0x13, 0x30, 0x42, 0x82, 0x20, 0x33, 0x43,
0x42, 0xc8, 0x00, 0x01, 0x2e, 0x80, 0x03, 0x05, 0x2e, 0x7d, 0x00, 0x19, 0x52, 0xe2, 0x7f, 0xd0, 0x7f, 0xc3, 0x7f,
0x98, 0x2e, 0xb6, 0x0e, 0xd1, 0x6f, 0x48, 0x0a, 0xd1, 0x7f, 0x3a, 0x25, 0xfb, 0x86, 0x01, 0x33, 0x12, 0x30, 0x98,
0x2e, 0xc2, 0xc4, 0xd1, 0x6f, 0x48, 0x0a, 0x40, 0xb2, 0x0d, 0x2f, 0xe0, 0x6f, 0x03, 0x2e, 0x80, 0x03, 0x53, 0x30,
0x07, 0x80, 0x27, 0x2e, 0x21, 0xf2, 0x98, 0xbc, 0x01, 0x42, 0x98, 0x2e, 0x91, 0x03, 0x00, 0x2e, 0x00, 0x2e, 0xd0,
0x2e, 0xb1, 0x6f, 0x9b, 0xb8, 0x07, 0x2e, 0x1b, 0x00, 0x19, 0x1a, 0xb1, 0x7f, 0x71, 0x30, 0x04, 0x2f, 0x23, 0x2e,
0x21, 0xf2, 0x00, 0x2e, 0x00, 0x2e, 0xd0, 0x2e, 0x98, 0x2e, 0x6d, 0xc0, 0x98, 0x2e, 0x5d, 0xc0, 0x98, 0x2e, 0xdf,
0x03, 0x20, 0x26, 0xc1, 0x6f, 0x02, 0x31, 0x52, 0x42, 0xab, 0x30, 0x4b, 0x42, 0x20, 0x33, 0x77, 0x56, 0xf1, 0x37,
0xc4, 0x40, 0xa2, 0x0a, 0xc2, 0x42, 0xd8, 0x00, 0x01, 0x2e, 0x5e, 0xf7, 0x41, 0x08, 0x23, 0x2e, 0x94, 0x00, 0xe3,
0x7f, 0x98, 0x2e, 0xaa, 0x01, 0xe1, 0x6f, 0x83, 0x30, 0x43, 0x42, 0x03, 0x30, 0xfb, 0x6f, 0x73, 0x50, 0x02, 0x30,
0x00, 0x2e, 0x00, 0x2e, 0x81, 0x84, 0x50, 0x0e, 0xfa, 0x2f, 0x43, 0x42, 0x11, 0x30, 0xb0, 0x5f, 0x23, 0x2e, 0x21,
0xf2, 0xb8, 0x2e, 0xc1, 0x4a, 0x00, 0x00, 0x6d, 0x57, 0x00, 0x00, 0x77, 0x8e, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff,
0xd3, 0xff, 0xff, 0xff, 0xe5, 0xff, 0xff, 0xff, 0xee, 0xe1, 0xff, 0xff, 0x7c, 0x13, 0x00, 0x00, 0x46, 0xe6, 0xff,
0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80,
0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1,
0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00,
0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e,
0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80,
0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1,
0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00,
0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e,
0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80,
0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1,
0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00,
0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e,
0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80,
0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1,
0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00,
0xc1, 0xfd, 0x2d
};
/*! @name Global array that stores the feature input configuration of
* BMI270_CONTEXT
*/
const struct bmi2_feature_config bmi270_context_feat_in[BMI270_CONTEXT_MAX_FEAT_IN] = {
{ .type = BMI2_CONFIG_ID, .page = BMI2_PAGE_4, .start_addr = BMI270_CONTEXT_CONFIG_ID_STRT_ADDR },
{ .type = BMI2_STEP_COUNTER_PARAMS, .page = BMI2_PAGE_1, .start_addr = BMI270_CONTEXT_STEP_CNT_1_STRT_ADDR },
{ .type = BMI2_STEP_DETECTOR, .page = BMI2_PAGE_4, .start_addr = BMI270_CONTEXT_STEP_CNT_4_STRT_ADDR },
{ .type = BMI2_STEP_COUNTER, .page = BMI2_PAGE_4, .start_addr = BMI270_CONTEXT_STEP_CNT_4_STRT_ADDR },
{ .type = BMI2_NVM_PROG_PREP, .page = BMI2_PAGE_4, .start_addr = BMI270_CONTEXT_NVM_PROG_PREP_STRT_ADDR },
{ .type = BMI2_MAX_BURST_LEN, .page = BMI2_PAGE_4, .start_addr = BMI270_CONTEXT_MAX_BURST_LEN_STRT_ADDR },
{ .type = BMI2_CRT_GYRO_SELF_TEST, .page = BMI2_PAGE_4, .start_addr = BMI270_CONTEXT_CRT_GYRO_SELF_TEST_STRT_ADDR },
{ .type = BMI2_ABORT_CRT_GYRO_SELF_TEST, .page = BMI2_PAGE_4, .start_addr = BMI270_CONTEXT_ABORT_STRT_ADDR },
{ .type = BMI2_ACTIVITY_RECOGNITION_SETTINGS, .page = BMI2_PAGE_5,
.start_addr = BMI270_CONTEXT_ACT_RGN_SETT_STRT_ADDR },
{ .type = BMI2_ACTIVITY_RECOGNITION, .page = BMI2_PAGE_5, .start_addr = BMI270_CONTEXT_ACT_RGN_STRT_ADDR },
};
/*! @name Global array that stores the feature output configuration */
const struct bmi2_feature_config bmi270_context_feat_out[BMI270_CONTEXT_MAX_FEAT_OUT] = {
{ .type = BMI2_STEP_COUNTER, .page = BMI2_PAGE_0, .start_addr = BMI270_CONTEXT_STEP_CNT_OUT_STRT_ADDR },
{ .type = BMI2_GYRO_CROSS_SENSE, .page = BMI2_PAGE_0, .start_addr = BMI270_CONTEXT_GYRO_CROSS_SENSE_STRT_ADDR },
{ .type = BMI2_GYRO_GAIN_UPDATE, .page = BMI2_PAGE_0, .start_addr = BMI270_CONTEXT_GYR_USER_GAIN_OUT_STRT_ADDR },
{ .type = BMI2_NVM_STATUS, .page = BMI2_PAGE_0, .start_addr = BMI270_CONTEXT_NVM_VFRM_OUT_STRT_ADDR },
{ .type = BMI2_VFRM_STATUS, .page = BMI2_PAGE_0, .start_addr = BMI270_CONTEXT_NVM_VFRM_OUT_STRT_ADDR }
};
/*! @name Global array that stores the feature interrupts of BMI270_CONTEXT */
struct bmi2_map_int bmi270_c_map_int[BMI270_C_MAX_INT_MAP] = {
{ .type = BMI2_STEP_COUNTER, .sens_map_int = BMI270_C_INT_STEP_COUNTER_MASK },
{ .type = BMI2_STEP_DETECTOR, .sens_map_int = BMI270_C_INT_STEP_DETECTOR_MASK },
};
/******************************************************************************/
/*! Local Function Prototypes
******************************************************************************/
/*!
* @brief This internal API is used to validate the device pointer for
* null conditions.
*
* @param[in] dev : Structure instance of bmi2_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
static int8_t null_ptr_check(const struct bmi2_dev *dev);
/*!
* @brief This internal API enables the selected sensor/features.
*
* @param[in] sensor_sel : Selects the desired sensor.
* @param[in, out] dev : Structure instance of bmi2_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
static int8_t sensor_enable(uint64_t sensor_sel, struct bmi2_dev *dev);
/*!
* @brief This internal API disables the selected sensor/features.
*
* @param[in] sensor_sel : Selects the desired sensor.
* @param[in, out] dev : Structure instance of bmi2_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
static int8_t sensor_disable(uint64_t sensor_sel, struct bmi2_dev *dev);
/*!
* @brief This internal API selects the sensors/features to be enabled or
* disabled.
*
* @param[in] sens_list : Pointer to select the sensor.
* @param[in] n_sens : Number of sensors selected.
* @param[out] sensor_sel : Gets the selected sensor.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
static int8_t select_sensor(const uint8_t *sens_list, uint8_t n_sens, uint64_t *sensor_sel);
/*!
* @brief This internal API is used to enable/disable step detector feature.
*
* @param[in] dev : Structure instance of bmi2_dev.
* @param[in] enable : Enables/Disables step-detector.
*
* Enable | Description
* -------------|---------------
* BMI2_DISABLE | Disables step detector
* BMI2_ENABLE | Enables step detector
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
static int8_t set_step_detector(uint8_t enable, struct bmi2_dev *dev);
/*!
* @brief This internal API is used to enable/disable step counter feature.
*
* @param[in] dev : Structure instance of bmi2_dev.
* @param[in] enable : Enables/Disables step counter.
*
* Enable | Description
* -------------|---------------
* BMI2_DISABLE | Disables step counter
* BMI2_ENABLE | Enables step counter
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
static int8_t set_step_counter(uint8_t enable, struct bmi2_dev *dev);
/*!
* @brief This internal API enables/disables the activity recognition feature.
*
* @param[in] enable : Enables/Disables activity recognition.
* @param[in] dev : Structure instance of bmi2_dev.
*
* enable | Description
* -------------|---------------
* BMI2_ENABLE | Enables activity recognition.
* BMI2_DISABLE | Disables activity recognition.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
static int8_t set_act_recog(uint8_t enable, struct bmi2_dev *dev);
/*!
* @brief This internal API sets step counter parameter configurations.
*
* @param[in] step_count_params : Array that stores parameters 1 to 25.
* @param[in] dev : Structure instance of bmi2_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
static int8_t set_step_count_params_config(const uint16_t *step_count_params, struct bmi2_dev *dev);
/*!
* @brief This internal API sets step counter/detector/activity configurations.
*
* @param[in] config : Structure instance of bmi2_step_config.
* @param[in] dev : Structure instance of bmi2_dev.
*
*---------------------------------------------------------------------------
* bmi2_step_config |
* Structure parameters | Description
*--------------------------|--------------------------------------------------
* | The Step-counter will trigger output every time
* | the number of steps are counted. Holds implicitly
* water-mark level | a 20x factor, so the range is 0 to 20460,
* | with resolution of 20 steps.
* -------------------------|---------------------------------------------------
* reset counter | Flag to reset the counted steps.
* -------------------------|---------------------------------------------------
* @endverbatim
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
static int8_t set_step_config(const struct bmi2_step_config *config, struct bmi2_dev *dev);
/*!
* @brief This internal API gets step counter parameter configurations.
*
* @param[in] step_count_params : Array that stores parameters 1 to 25.
* @param[in] dev : Structure instance of bmi2_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
static int8_t get_step_count_params_config(uint16_t *step_count_params, struct bmi2_dev *dev);
/*!
* @brief This internal API gets step counter/detector/activity configurations.
*
* @param[out] config : Structure instance of bmi2_step_config.
* @param[in] dev : Structure instance of bmi2_dev.
*
* @verbatim
*----------------------------------------------------------------------------
* bmi2_step_config |
* Structure parameters | Description
*--------------------------|--------------------------------------------------
* | The Step-counter will trigger output every time
* | the number of steps are counted. Holds implicitly
* water-mark level | a 20x factor, so the range is 0 to 20460,
* | with resolution of 20 steps.
* -------------------------|---------------------------------------------------
* reset counter | Flag to reset the counted steps.
* -------------------------|---------------------------------------------------
* @endverbatim
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
static int8_t get_step_config(struct bmi2_step_config *config, struct bmi2_dev *dev);
/*!
* @brief This internal API is used to parse and store the activity recognition
* output from the FIFO data.
*
* @param[out] act_recog : Structure to retrieve output of activity
* recognition frame.
* @param[in] data_index : Index of the FIFO data which contains
* activity recognition frame.
* @param[out] fifo : Structure instance of bmi2_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
static int8_t unpack_act_recog_output(struct bmi2_act_recog_output *act_recog,
uint16_t *data_index,
const struct bmi2_fifo_frame *fifo);
/*!
* @brief This internal API gets the output values of step counter.
*
* @param[out] step_count : Pointer to the stored step counter data.
* @param[in] dev : Structure instance of bmi2_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
static int8_t get_step_counter_output(uint32_t *step_count, struct bmi2_dev *dev);
/*!
* @brief This internal API gets the error status related to NVM.
*
* @param[out] nvm_err_stat : Stores the NVM error status.
* @param[in] dev : Structure instance of bmi2_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
static int8_t get_nvm_error_status(struct bmi2_nvm_err_status *nvm_err_stat, struct bmi2_dev *dev);
/*!
* @brief This internal API gets the error status related to virtual frames.
*
* @param[out] vfrm_err_stat : Stores the VFRM related error status.
* @param[in] dev : Structure instance of bmi2_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
static int8_t get_vfrm_error_status(struct bmi2_vfrm_err_status *vfrm_err_stat, struct bmi2_dev *dev);
/*!
* @brief This internal API skips S4S frame in the FIFO data while getting
* activity recognition output.
*
* @param[in, out] frame_header : FIFO frame header.
* @param[in, out] data_index : Index value of the FIFO data bytes
* from which S4S frame header is to be
* skipped.
* @param[in] fifo : Structure instance of bmi2_fifo_frame.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
static int8_t move_if_s4s_frame(const uint8_t *frame_header, uint16_t *data_index, const struct bmi2_fifo_frame *fifo);
/*!
* @brief This internal API is used to extract the output feature configuration
* details like page and start address from the look-up table.
*
* @param[out] feat_output : Structure that stores output feature
* configurations.
* @param[in] type : Type of feature or sensor.
* @param[in] dev : Structure instance of bmi2_dev.
*
* @return Returns the feature found flag.
*
* @retval BMI2_FALSE : Feature not found
* BMI2_TRUE : Feature found
*/
static uint8_t extract_output_feat_config(struct bmi2_feature_config *feat_output,
uint8_t type,
const struct bmi2_dev *dev);
/*!
* @brief This internal API is used to move the data index ahead of the
* current frame length parameter when unnecessary FIFO data appears while
* extracting the user specified data.
*
* @param[in,out] data_index : Index of the FIFO data which is to be
* moved ahead of the current frame length
* @param[in] current_frame_length : Number of bytes in the current frame.
* @param[in] fifo : Structure instance of bmi2_fifo_frame.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
static int8_t move_next_frame(uint16_t *data_index, uint8_t current_frame_length, const struct bmi2_fifo_frame *fifo);
/*!
* @brief This internal API is used to select the header byte frame
*
* @param[in, out] frame_to_read : Variable to indicate activity frames read.
* @param[in, out] act_frm_len : Number of activity frames parsed.
* @param[in] act_recog : Structure instance of bmi2_act_recog_output.
* @param[in] fifo : Structure instance of bmi2_fifo_frame.
* @param[in] dev : Structure instance of bmi2_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
static int8_t fifo_header_frame(uint16_t frame_to_read,
uint16_t *act_frm_len,
struct bmi2_act_recog_output *act_recog,
struct bmi2_fifo_frame *fifo,
const struct bmi2_dev *dev);
/*!
* @brief This internal API is used to enable main sensors like accel, gyro, aux and temperature.
*
* @param[in] sensor_sel : Enables the selected sensor.
* @param[in, out] dev : Structure instance of bmi2_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
static int8_t enable_main_sensors(uint64_t sensor_sel, struct bmi2_dev *dev);
/*!
* @brief This internal API is used to enable sensor features.
*
* @param[in] sensor_sel : Enables features of selected sensor.
* @param[in, out] dev : Structure instance of bmi2_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
static int8_t enable_sensor_features(uint64_t sensor_sel, struct bmi2_dev *dev);
/*!
* @brief This internal API is used to disable main sensors like accel, gyro, aux and temperature.
*
* @param[in] sensor_sel : Disables the selected sensor.
* @param[in, out] dev : Structure instance of bmi2_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
static int8_t disable_main_sensors(uint64_t sensor_sel, struct bmi2_dev *dev);
/*!
* @brief This internal API is used to disable sensor features.
*
* @param[in] sensor_sel : Disables features of selected sensor.
* @param[in, out] dev : Structure instance of bmi2_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
static int8_t disable_sensor_features(uint64_t sensor_sel, struct bmi2_dev *dev);
/***************************************************************************/
/*! User Interface Definitions
****************************************************************************/
/*!
* @brief This API:
* 1) Updates the device structure with address of the configuration file.
* 2) Initializes BMI270_CONTEXT sensor.
* 3) Writes the configuration file.
* 4) Updates the feature offset parameters in the device structure.
* 5) Updates the maximum number of pages, in the device structure.
*/
int8_t bmi270_context_init(struct bmi2_dev *dev)
{
/* Variable to define error */
int8_t rslt;
/* Null-pointer check */
rslt = null_ptr_check(dev);
if (rslt == BMI2_OK)
{
/* Assign chip id of BMI270_CONTEXT */
dev->chip_id = BMI270_CONTEXT_CHIP_ID;
/* Get the size of config array */
dev->config_size = sizeof(bmi270_context_config_file);
/* Enable the variant specific features if any */
dev->variant_feature = BMI2_CRT_RTOSK_ENABLE | BMI2_GYRO_CROSS_SENS_ENABLE;
/* An extra dummy byte is read during SPI read */
if (dev->intf == BMI2_SPI_INTF)
{
dev->dummy_byte = 1;
}
else
{
dev->dummy_byte = 0;
}
/* If configuration file pointer is not assigned any address */
if (!dev->config_file_ptr)
{
/* Give the address of the configuration file array to
* the device pointer
*/
dev->config_file_ptr = bmi270_context_config_file;
}
/* Initialize BMI2 sensor */
rslt = bmi2_sec_init(dev);
if (rslt == BMI2_OK)
{
/* Assign the offsets of the feature input
* configuration to the device structure
*/
dev->feat_config = bmi270_context_feat_in;
/* Assign the offsets of the feature output to
* the device structure
*/
dev->feat_output = bmi270_context_feat_out;
/* Assign the maximum number of pages to the
* device structure
*/
dev->page_max = BMI270_CONTEXT_MAX_PAGE_NUM;
/* Assign maximum number of input sensors/
* features to device structure
*/
dev->input_sens = BMI270_CONTEXT_MAX_FEAT_IN;
/* Assign maximum number of output sensors/
* features to device structure
*/
dev->out_sens = BMI270_CONTEXT_MAX_FEAT_OUT;
/* Assign the offsets of the feature interrupt
* to the device structure
*/
dev->map_int = bmi270_c_map_int;
/* Assign maximum number of feature interrupts
* to device structure
*/
dev->sens_int_map = BMI270_C_MAX_INT_MAP;
}
}
return rslt;
}
/*!
* @brief This API selects the sensors/features to be enabled.
*/
int8_t bmi270_context_sensor_enable(const uint8_t *sens_list, uint8_t n_sens, struct bmi2_dev *dev)
{
/* Variable to define error */
int8_t rslt;
/* Variable to select sensor */
uint64_t sensor_sel = 0;
/* Null-pointer check */
rslt = null_ptr_check(dev);
if ((rslt == BMI2_OK) && (sens_list != NULL))
{
/* Get the selected sensors */
rslt = select_sensor(sens_list, n_sens, &sensor_sel);
if (rslt == BMI2_OK)
{
/* Enable the selected sensors */
rslt = sensor_enable(sensor_sel, dev);
}
}
else
{
rslt = BMI2_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This API selects the sensors/features to be disabled.
*/
int8_t bmi270_context_sensor_disable(const uint8_t *sens_list, uint8_t n_sens, struct bmi2_dev *dev)
{
/* Variable to define error */
int8_t rslt;
/* Variable to select sensor */
uint64_t sensor_sel = 0;
/* Null-pointer check */
rslt = null_ptr_check(dev);
if ((rslt == BMI2_OK) && (sens_list != NULL))
{
/* Get the selected sensors */
rslt = select_sensor(sens_list, n_sens, &sensor_sel);
if (rslt == BMI2_OK)
{
/* Disable the selected sensors */
rslt = sensor_disable(sensor_sel, dev);
}
}
else
{
rslt = BMI2_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This API sets the sensor/feature configuration.
*/
int8_t bmi270_context_set_sensor_config(struct bmi2_sens_config *sens_cfg, uint8_t n_sens, struct bmi2_dev *dev)
{
/* Variable to define error */
int8_t rslt;
/* Variable to define loop */
uint8_t loop;
/* Variable to get the status of advance power save */
uint8_t aps_stat = 0;
/* Null-pointer check */
rslt = null_ptr_check(dev);
if ((rslt == BMI2_OK) && (sens_cfg != NULL))
{
/* Get status of advance power save mode */
aps_stat = dev->aps_status;
for (loop = 0; loop < n_sens; loop++)
{
if ((sens_cfg[loop].type == BMI2_ACCEL) || (sens_cfg[loop].type == BMI2_GYRO) ||
(sens_cfg[loop].type == BMI2_AUX) || (sens_cfg[loop].type == BMI2_GYRO_GAIN_UPDATE))
{
rslt = bmi2_set_sensor_config(&sens_cfg[loop], 1, dev);
}
else
{
/* Disable Advance power save if enabled for auxiliary
* and feature configurations
*/
if (aps_stat == BMI2_ENABLE)
{
/* Disable advance power save if
* enabled
*/
rslt = bmi2_set_adv_power_save(BMI2_DISABLE, dev);
}
if (rslt == BMI2_OK)
{
switch (sens_cfg[loop].type)
{
/* Set the step counter parameters */
case BMI2_STEP_COUNTER_PARAMS:
rslt = set_step_count_params_config(sens_cfg[loop].cfg.step_counter_params, dev);
break;
/* Set step counter/detector/activity configuration */
case BMI2_STEP_DETECTOR:
case BMI2_STEP_COUNTER:
rslt = set_step_config(&sens_cfg[loop].cfg.step_counter, dev);
break;
default:
rslt = BMI2_E_INVALID_SENSOR;
break;
}
}
/* Return error if any of the set configurations fail */
if (rslt != BMI2_OK)
{
break;
}
}
}
/* Enable Advance power save if disabled while configuring and
* not when already disabled
*/
if ((aps_stat == BMI2_ENABLE) && (rslt == BMI2_OK))
{
rslt = bmi2_set_adv_power_save(BMI2_ENABLE, dev);
}
}
else
{
rslt = BMI2_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This API gets the sensor/feature configuration.
*/
int8_t bmi270_context_get_sensor_config(struct bmi2_sens_config *sens_cfg, uint8_t n_sens, struct bmi2_dev *dev)
{
/* Variable to define error */
int8_t rslt;
/* Variable to define loop */
uint8_t loop;
/* Variable to get the status of advance power save */
uint8_t aps_stat = 0;
/* Null-pointer check */
rslt = null_ptr_check(dev);
if ((rslt == BMI2_OK) && (sens_cfg != NULL))
{
/* Get status of advance power save mode */
aps_stat = dev->aps_status;
for (loop = 0; loop < n_sens; loop++)
{
if ((sens_cfg[loop].type == BMI2_ACCEL) || (sens_cfg[loop].type == BMI2_GYRO) ||
(sens_cfg[loop].type == BMI2_AUX) || (sens_cfg[loop].type == BMI2_GYRO_GAIN_UPDATE))
{
rslt = bmi2_get_sensor_config(&sens_cfg[loop], 1, dev);
}
else
{
/* Disable Advance power save if enabled for auxiliary
* and feature configurations
*/
if ((sens_cfg[loop].type >= BMI2_MAIN_SENS_MAX_NUM) || (sens_cfg[loop].type == BMI2_AUX))
{
if (aps_stat == BMI2_ENABLE)
{
/* Disable advance power save if
* enabled
*/
rslt = bmi2_set_adv_power_save(BMI2_DISABLE, dev);
}
}
if (rslt == BMI2_OK)
{
switch (sens_cfg[loop].type)
{
/* Set the step counter parameters */
case BMI2_STEP_COUNTER_PARAMS:
rslt = get_step_count_params_config(sens_cfg[loop].cfg.step_counter_params, dev);
break;
/* Get step counter/detector/activity configuration */
case BMI2_STEP_DETECTOR:
case BMI2_STEP_COUNTER:
rslt = get_step_config(&sens_cfg[loop].cfg.step_counter, dev);
break;
default:
rslt = BMI2_E_INVALID_SENSOR;
break;
}
}
/* Return error if any of the get configurations fail */
if (rslt != BMI2_OK)
{
break;
}
}
}
/* Enable Advance power save if disabled while configuring and
* not when already disabled
*/
if ((aps_stat == BMI2_ENABLE) && (rslt == BMI2_OK))
{
rslt = bmi2_set_adv_power_save(BMI2_ENABLE, dev);
}
}
else
{
rslt = BMI2_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This API gets the feature data.
*/
int8_t bmi270_context_get_feature_data(struct bmi2_feat_sensor_data *feature_data, uint8_t n_sens, struct bmi2_dev *dev)
{
/* Variable to define error */
int8_t rslt;
/* Variable to define loop */
uint8_t loop;
/* Variable to get the status of advance power save */
uint8_t aps_stat = 0;
/* Null-pointer check */
rslt = null_ptr_check(dev);
if ((rslt == BMI2_OK) && (feature_data != NULL))
{
/* Get status of advance power save mode */
aps_stat = dev->aps_status;
for (loop = 0; loop < n_sens; loop++)
{
if ((feature_data[loop].type == BMI2_GYRO_GAIN_UPDATE) ||
(feature_data[loop].type == BMI2_GYRO_CROSS_SENSE))
{
rslt = bmi2_get_feature_data(&feature_data[loop], 1, dev);
}
else
{
/* Disable Advance power save if enabled for feature
* configurations
*/
if (feature_data[loop].type >= BMI2_MAIN_SENS_MAX_NUM)
{
if (aps_stat == BMI2_ENABLE)
{
/* Disable advance power save if
* enabled
*/
rslt = bmi2_set_adv_power_save(BMI2_DISABLE, dev);
}
}
if (rslt == BMI2_OK)
{
switch (feature_data[loop].type)
{
case BMI2_STEP_COUNTER:
/* Get step counter output */
rslt = get_step_counter_output(&feature_data[loop].sens_data.step_counter_output, dev);
break;
case BMI2_NVM_STATUS:
/* Get NVM error status */
rslt = get_nvm_error_status(&feature_data[loop].sens_data.nvm_status, dev);
break;
case BMI2_VFRM_STATUS:
/* Get VFRM error status */
rslt = get_vfrm_error_status(&feature_data[loop].sens_data.vfrm_status, dev);
break;
default:
rslt = BMI2_E_INVALID_SENSOR;
break;
}
/* Return error if any of the get sensor data fails */
if (rslt != BMI2_OK)
{
break;
}
}
}
/* Enable Advance power save if disabled while
* configuring and not when already disabled
*/
if ((aps_stat == BMI2_ENABLE) && (rslt == BMI2_OK))
{
rslt = bmi2_set_adv_power_save(BMI2_ENABLE, dev);
}
}
}
else
{
rslt = BMI2_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This api is used for retrieving the activity recognition settings currently set.
*/
int8_t bmi270_context_get_act_recg_sett(struct bmi2_act_recg_sett *sett, struct bmi2_dev *dev)
{
/* Variable to define error */
int8_t rslt;
/* Array to define the feature configuration */
uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
/* Variable to define the array offset */
uint8_t idx = 0;
/* Variable to get the status of advance power save */
uint8_t aps_stat;
/* Variable to set flag */
uint8_t feat_found;
uint16_t msb_lsb;
uint8_t lsb;
uint8_t msb;
/* Initialize feature configuration for activity recognition */
struct bmi2_feature_config bmi2_act_recg_sett = { 0, 0, 0 };
/* Null-pointer check */
rslt = null_ptr_check(dev);
if (rslt == BMI2_OK)
{
/* Search for bmi2 Abort feature and extract its configuration details */
feat_found = bmi2_extract_input_feat_config(&bmi2_act_recg_sett, BMI2_ACTIVITY_RECOGNITION_SETTINGS, dev);
if (feat_found)
{
aps_stat = dev->aps_status;
if (aps_stat == BMI2_ENABLE)
{
/* Disable advance power save if enabled */
rslt = bmi2_set_adv_power_save(BMI2_DISABLE, dev);
}
/* Get the configuration from the page where activity recognition setting feature resides */
if (rslt == BMI2_OK)
{
rslt = bmi2_get_feat_config(bmi2_act_recg_sett.page, feat_config, dev);
}
if (rslt == BMI2_OK)
{
/* Define the offset in bytes */
idx = bmi2_act_recg_sett.start_addr;
/* get the status of enable/disable post processing */
sett->pp_en = BMI2_GET_BIT_POS0(feat_config[idx], BMI2_ACT_RECG_POST_PROS_EN_DIS);
/* increment idx by 2 to point min gdi thres addres */
idx = idx + 2;
lsb = feat_config[idx];
idx++;
msb = feat_config[idx];
msb_lsb = (uint16_t)(lsb | msb << 8);
sett->min_gdi_thres = msb_lsb;
/* increment idx by 1 to point max gdi thres addres */
idx++;
lsb = feat_config[idx];
idx++;
msb = feat_config[idx];
msb_lsb = (uint16_t)(lsb | msb << 8);
sett->max_gdi_thres = msb_lsb;
/* increment idx by 1 to point buffer size */
idx++;
sett->buf_size = BMI2_GET_BIT_POS0(feat_config[idx], BMI2_ACT_RECG_BUFF_SIZE);
/* increment idx by 2 to to point to min segment confidence */
idx = idx + 2;
sett->min_seg_conf = BMI2_GET_BIT_POS0(feat_config[idx], BMI2_ACT_RECG_MIN_SEG_CONF);
}
/* Enable Advance power save if disabled while
* configuring and not when already disabled
*/
if ((aps_stat == BMI2_ENABLE) && (rslt == BMI2_OK))
{
rslt = bmi2_set_adv_power_save(BMI2_ENABLE, dev);
}
}
else
{
rslt = BMI2_E_INVALID_SENSOR;
}
}
return rslt;
}
/*!
* @brief This api is used for setting the activity recognition settings.
*/
int8_t bmi270_context_set_act_recg_sett(const struct bmi2_act_recg_sett *sett, struct bmi2_dev *dev)
{
/* Variable to define error */
int8_t rslt;
/* Array to define the feature configuration */
uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
/* Variable to define the array offset */
uint8_t idx = 0;
/* Variable to get the status of advance power save */
uint8_t aps_stat;
/* Variable to set flag */
uint8_t feat_found;
/* Initialize feature configuration for activity recognition */
struct bmi2_feature_config bmi2_act_recg_sett = { 0, 0, 0 };
/* Null-pointer check */
rslt = null_ptr_check(dev);
if (rslt == BMI2_OK)
{
/* Search for bmi2 Abort feature and extract its configuration details */
feat_found = bmi2_extract_input_feat_config(&bmi2_act_recg_sett, BMI2_ACTIVITY_RECOGNITION_SETTINGS, dev);
if (feat_found)
{
aps_stat = dev->aps_status;
if (aps_stat == BMI2_ENABLE)
{
/* Disable advance power save if enabled */
rslt = bmi2_set_adv_power_save(BMI2_DISABLE, dev);
}
/* Get the configuration from the page where activity recognition setting feature resides */
if (rslt == BMI2_OK)
{
rslt = bmi2_get_feat_config(bmi2_act_recg_sett.page, feat_config, dev);
}
if (rslt == BMI2_OK)
{
/* Define the offset in bytes */
idx = bmi2_act_recg_sett.start_addr;
if ((sett->buf_size > 10) || (sett->min_seg_conf > 10))
{
rslt = BMI2_E_INVALID_INPUT;
}
if (rslt == BMI2_OK)
{
feat_config[idx] = BMI2_SET_BIT_POS0(feat_config[idx], BMI2_ACT_RECG_POST_PROS_EN_DIS, sett->pp_en);
/* Increment idx by 2 to point min gdi thres addres */
idx = idx + 2;
feat_config[idx] = BMI2_GET_LSB(sett->min_gdi_thres);
idx++;
feat_config[idx] = BMI2_GET_MSB(sett->min_gdi_thres);
/* Increment idx by 1 to point max gdi thres addres */
idx++;
feat_config[idx] = BMI2_GET_LSB(sett->max_gdi_thres);
idx++;
feat_config[idx] = BMI2_GET_MSB(sett->max_gdi_thres);
/* Increment idx by 1 to point buffer size */
idx++;
feat_config[idx] = BMI2_SET_BIT_POS0(feat_config[idx], BMI2_ACT_RECG_BUFF_SIZE, sett->buf_size);
/* Increment idx by 2 to to point to min segment confidence */
idx = idx + 2;
feat_config[idx] = BMI2_SET_BIT_POS0(feat_config[idx],
BMI2_ACT_RECG_MIN_SEG_CONF,
sett->min_seg_conf);
rslt = bmi2_set_regs(BMI2_FEATURES_REG_ADDR, feat_config, BMI2_FEAT_SIZE_IN_BYTES, dev);
}
}
/* Enable Advance power save if disabled while
* configuring and not when already disabled
*/
if ((aps_stat == BMI2_ENABLE) && (rslt == BMI2_OK))
{
rslt = bmi2_set_adv_power_save(BMI2_ENABLE, dev);
}
}
else
{
rslt = BMI2_E_INVALID_SENSOR;
}
}
return rslt;
}
/*!
* @brief This internal API is used to parse the activity output from the
* FIFO in header mode.
*/
int8_t bmi270_context_get_act_recog_output(struct bmi2_act_recog_output *act_recog,
uint16_t *act_frm_len,
struct bmi2_fifo_frame *fifo,
const struct bmi2_dev *dev)
{
/* Variable to define error */
int8_t rslt;
/* Variable to indicate activity frames read */
uint16_t frame_to_read = 0;
/* Null-pointer check */
rslt = null_ptr_check(dev);
if ((rslt == BMI2_OK) && (act_recog != NULL) && (act_frm_len != NULL) && (fifo != NULL))
{
/* Store the number of frames to be read */
frame_to_read = *act_frm_len;
rslt = fifo_header_frame(frame_to_read, act_frm_len, act_recog, fifo, dev);
}
else
{
rslt = BMI2_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This API maps/unmaps feature interrupts to that of interrupt pins.
*/
int8_t bmi270_context_map_feat_int(const struct bmi2_sens_int_config *sens_int, uint8_t n_sens, struct bmi2_dev *dev)
{
/* Variable to define error */
int8_t rslt;
/* Variable to define loop */
uint8_t loop;
/* Null-pointer check */
rslt = null_ptr_check(dev);
if ((rslt == BMI2_OK) && (sens_int != NULL))
{
for (loop = 0; loop < n_sens; loop++)
{
switch (sens_int[loop].type)
{
case BMI2_STEP_COUNTER:
case BMI2_STEP_DETECTOR:
rslt = bmi2_map_feat_int(sens_int[loop].type, sens_int[loop].hw_int_pin, dev);
break;
default:
rslt = BMI2_E_INVALID_SENSOR;
break;
}
/* Return error if interrupt mapping fails */
if (rslt != BMI2_OK)
{
break;
}
}
}
else
{
rslt = BMI2_E_NULL_PTR;
}
return rslt;
}
/***************************************************************************/
/*! Local Function Definitions
****************************************************************************/
/*!
* @brief This internal API is used to validate the device structure pointer for
* null conditions.
*/
static int8_t null_ptr_check(const struct bmi2_dev *dev)
{
/* Variable to define error */
int8_t rslt = BMI2_OK;
if ((dev == NULL) || (dev->read == NULL) || (dev->write == NULL) || (dev->delay_us == NULL))
{
/* Device structure pointer is not valid */
rslt = BMI2_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This internal API selects the sensor/features to be enabled or
* disabled.
*/
static int8_t select_sensor(const uint8_t *sens_list, uint8_t n_sens, uint64_t *sensor_sel)
{
/* Variable to define error */
int8_t rslt = BMI2_OK;
/* Variable to define loop */
uint8_t count;
for (count = 0; count < n_sens; count++)
{
switch (sens_list[count])
{
case BMI2_ACCEL:
*sensor_sel |= BMI2_ACCEL_SENS_SEL;
break;
case BMI2_GYRO:
*sensor_sel |= BMI2_GYRO_SENS_SEL;
break;
case BMI2_AUX:
*sensor_sel |= BMI2_AUX_SENS_SEL;
break;
case BMI2_TEMP:
*sensor_sel |= BMI2_TEMP_SENS_SEL;
break;
case BMI2_STEP_DETECTOR:
*sensor_sel |= BMI2_STEP_DETECT_SEL;
break;
case BMI2_STEP_COUNTER:
*sensor_sel |= BMI2_STEP_COUNT_SEL;
break;
case BMI2_GYRO_GAIN_UPDATE:
*sensor_sel |= BMI2_GYRO_GAIN_UPDATE_SEL;
break;
case BMI2_ACTIVITY_RECOGNITION:
*sensor_sel |= BMI2_ACTIVITY_RECOGNITION_SEL;
break;
default:
rslt = BMI2_E_INVALID_SENSOR;
break;
}
}
return rslt;
}
/*!
* @brief This internal API enables the selected sensor/features.
*/
static int8_t sensor_enable(uint64_t sensor_sel, struct bmi2_dev *dev)
{
/* Variable to define error */
int8_t rslt;
/* Variable to get the status of advance power save */
uint8_t aps_stat = 0;
rslt = enable_main_sensors(sensor_sel, dev);
if ((rslt == BMI2_OK) && (sensor_sel & ~(BMI2_MAIN_SENSORS)))
{
/* Get status of advance power save mode */
aps_stat = dev->aps_status;
if (aps_stat == BMI2_ENABLE)
{
/* Disable advance power save if enabled */
rslt = bmi2_set_adv_power_save(BMI2_DISABLE, dev);
}
if (rslt == BMI2_OK)
{
rslt = enable_sensor_features(sensor_sel, dev);
/* Enable Advance power save if disabled while
* configuring and not when already disabled
*/
if ((aps_stat == BMI2_ENABLE) && (rslt == BMI2_OK))
{
rslt = bmi2_set_adv_power_save(BMI2_ENABLE, dev);
}
}
}
return rslt;
}
/*!
* @brief This internal API disables the selected sensors/features.
*/
static int8_t sensor_disable(uint64_t sensor_sel, struct bmi2_dev *dev)
{
/* Variable to define error */
int8_t rslt;
/* Variable to get the status of advance power save */
uint8_t aps_stat = 0;
rslt = disable_main_sensors(sensor_sel, dev);
if ((rslt == BMI2_OK) && (sensor_sel & ~(BMI2_MAIN_SENSORS)))
{
/* Get status of advance power save mode */
aps_stat = dev->aps_status;
if (aps_stat == BMI2_ENABLE)
{
/* Disable advance power save if enabled */
rslt = bmi2_set_adv_power_save(BMI2_DISABLE, dev);
}
if (rslt == BMI2_OK)
{
rslt = disable_sensor_features(sensor_sel, dev);
/* Enable Advance power save if disabled while
* configuring and not when already disabled
*/
if ((aps_stat == BMI2_ENABLE) && (rslt == BMI2_OK))
{
rslt = bmi2_set_adv_power_save(BMI2_ENABLE, dev);
}
}
}
return rslt;
}
/*!
* @brief This internal API is used to enable/disable step detector feature.
*/
static int8_t set_step_detector(uint8_t enable, struct bmi2_dev *dev)
{
/* Variable to define error */
int8_t rslt;
/* Array to define the feature configuration */
uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
/* Variable to define the array offset */
uint8_t idx = 0;
/* Variable to set flag */
uint8_t feat_found;
/* Initialize feature configuration for step detector */
struct bmi2_feature_config step_det_config = { 0, 0, 0 };
/* Search for step detector feature and extract its configuration details */
feat_found = bmi2_extract_input_feat_config(&step_det_config, BMI2_STEP_DETECTOR, dev);
if (feat_found)
{
/* Get the configuration from the page where step detector feature resides */
rslt = bmi2_get_feat_config(step_det_config.page, feat_config, dev);
if (rslt == BMI2_OK)
{
/* Define the offset for enable/disable of step detector */
idx = step_det_config.start_addr + BMI2_STEP_COUNT_FEAT_EN_OFFSET;
/* Set the feature enable bit */
feat_config[idx] = BMI2_SET_BITS(feat_config[idx], BMI2_STEP_DET_FEAT_EN, enable);
/* Set the configuration back to the page */
rslt = bmi2_set_regs(BMI2_FEATURES_REG_ADDR, feat_config, BMI2_FEAT_SIZE_IN_BYTES, dev);
if ((rslt == BMI2_OK) && (enable == BMI2_ENABLE))
{
dev->sens_en_stat |= BMI2_STEP_DETECT_SEL;
}
else
{
dev->sens_en_stat &= ~BMI2_STEP_DETECT_SEL;
}
}
}
else
{
rslt = BMI2_E_INVALID_SENSOR;
}
return rslt;
}
/*!
* @brief This internal API is used to enable/disable step counter feature.
*/
static int8_t set_step_counter(uint8_t enable, struct bmi2_dev *dev)
{
/* Variable to define error */
int8_t rslt;
/* Array to define the feature configuration */
uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
/* Variable to define the array offset */
uint8_t idx = 0;
/* Variable to set flag */
uint8_t feat_found;
/* Initialize feature configuration for step counter */
struct bmi2_feature_config step_count_config = { 0, 0, 0 };
/* Search for step counter feature and extract its configuration details */
feat_found = bmi2_extract_input_feat_config(&step_count_config, BMI2_STEP_COUNTER, dev);
if (feat_found)
{
/* Get the configuration from the page where step-counter feature resides */
rslt = bmi2_get_feat_config(step_count_config.page, feat_config, dev);
if (rslt == BMI2_OK)
{
/* Define the offset for enable/disable of step counter */
idx = step_count_config.start_addr + BMI2_STEP_COUNT_FEAT_EN_OFFSET;
/* Set the feature enable bit */
feat_config[idx] = BMI2_SET_BITS(feat_config[idx], BMI2_STEP_COUNT_FEAT_EN, enable);
/* Set the configuration back to the page */
rslt = bmi2_set_regs(BMI2_FEATURES_REG_ADDR, feat_config, BMI2_FEAT_SIZE_IN_BYTES, dev);
if ((rslt == BMI2_OK) && (enable == BMI2_ENABLE))
{
dev->sens_en_stat |= BMI2_STEP_COUNT_SEL;
}
else
{
dev->sens_en_stat &= ~BMI2_STEP_COUNT_SEL;
}
}
}
else
{
rslt = BMI2_E_INVALID_SENSOR;
}
return rslt;
}
/*!
* @brief This internal API enables/disables the activity recognition feature.
*/
static int8_t set_act_recog(uint8_t enable, struct bmi2_dev *dev)
{
/* Variable to define error */
int8_t rslt;
/* Array to define the feature configuration */
uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
/* Variable to define the array offset */
uint8_t idx = 0;
/* Variable to set flag */
uint8_t feat_found;
/* Initialize feature configuration for activity recognition */
struct bmi2_feature_config act_recog_cfg = { 0, 0, 0 };
/* Search for activity recognition and extract its configuration details */
feat_found = bmi2_extract_input_feat_config(&act_recog_cfg, BMI2_ACTIVITY_RECOGNITION, dev);
if (feat_found)
{
/* Get the configuration from the page where activity
* recognition feature resides
*/
rslt = bmi2_get_feat_config(act_recog_cfg.page, feat_config, dev);
if (rslt == BMI2_OK)
{
/* Define the offset for enable/disable of activity recognition */
idx = act_recog_cfg.start_addr;
/* Set the feature enable bit */
feat_config[idx] = BMI2_SET_BIT_POS0(feat_config[idx], BMI2_ACTIVITY_RECOG_EN, enable);
/* Set the configuration back to the page */
rslt = bmi2_set_regs(BMI2_FEATURES_REG_ADDR, feat_config, BMI2_FEAT_SIZE_IN_BYTES, dev);
if ((rslt == BMI2_OK) && (enable == BMI2_ENABLE))
{
dev->sens_en_stat |= BMI2_STEP_ACT_SEL;
}
else
{
dev->sens_en_stat &= ~BMI2_STEP_ACT_SEL;
}
}
}
else
{
rslt = BMI2_E_INVALID_SENSOR;
}
return rslt;
}
/*!
* @brief This internal API sets step counter parameter configurations.
*/
static int8_t set_step_count_params_config(const uint16_t *step_count_params, struct bmi2_dev *dev)
{
/* Variable to define error */
int8_t rslt = BMI2_OK;
/* Array to define the feature configuration */
uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
/* Variable to define index */
uint8_t index = 0;
/* Variable to set flag */
uint8_t feat_found;
/* Initialize feature configuration for step counter parameters */
struct bmi2_feature_config step_params_config = { 0, 0, 0 };
/* Variable to index the page number */
uint8_t page_idx;
/* Variable to define the start page */
uint8_t start_page;
/* Variable to define start address of the parameters */
uint8_t start_addr;
/* Variable to define number of bytes */
uint8_t n_bytes = (BMI2_STEP_CNT_N_PARAMS * 2);
/* Variable to store number of pages */
uint8_t n_pages = (n_bytes / 16);
/* Variable to define the end page */
uint8_t end_page;
/* Variable to define the remaining bytes to be read */
uint8_t remain_len;
/* Variable to define the maximum words(16 bytes or 8 words) to be read in a page */
uint8_t max_len = 8;
/* Variable index bytes in a page */
uint8_t page_byte_idx;
/* Variable to index the parameters */
uint8_t param_idx = 0;
/* Copy the feature configuration address to a local pointer */
uint16_t *data_p = (uint16_t *) (void *)feat_config;
/* Search for step counter parameter feature and extract its configuration details */
feat_found = bmi2_extract_input_feat_config(&step_params_config, BMI2_STEP_COUNTER_PARAMS, dev);
if (feat_found)
{
/* Get the start page for the step counter parameters */
start_page = step_params_config.page;
/* Get the end page for the step counter parameters */
end_page = start_page + n_pages;
/* Get the start address for the step counter parameters */
start_addr = step_params_config.start_addr;
/* Get the remaining length of bytes to be read */
remain_len = (uint8_t)((n_bytes - (n_pages * 16)) + start_addr);
for (page_idx = start_page; page_idx <= end_page; page_idx++)
{
/* Get the configuration from the respective page */
rslt = bmi2_get_feat_config(page_idx, feat_config, dev);
if (rslt == BMI2_OK)
{
/* Start from address 0x00 when switched to next page */
if (page_idx > start_page)
{
start_addr = 0;
}
/* Remaining number of words to be read in the page */
if (page_idx == end_page)
{
max_len = (remain_len / 2);
}
/* Get offset in words since all the features are set in words length */
page_byte_idx = start_addr / 2;
for (; page_byte_idx < max_len;)
{
/* Set parameters 1 to 25 */
*(data_p + page_byte_idx) = BMI2_SET_BIT_POS0(*(data_p + page_byte_idx),
BMI2_STEP_COUNT_PARAMS,
step_count_params[param_idx]);
/* Increment offset by 1 word to set to the next parameter */
page_byte_idx++;
/* Increment to next parameter */
param_idx++;
}
/* Get total length in bytes to copy from local pointer to the array */
page_byte_idx = (uint8_t)(page_byte_idx * 2) - step_params_config.start_addr;
/* Copy the bytes to be set back to the array */
for (index = 0; index < page_byte_idx; index++)
{
feat_config[step_params_config.start_addr +
index] = *((uint8_t *) data_p + step_params_config.start_addr + index);
}
/* Set the configuration back to the page */
rslt = bmi2_set_regs(BMI2_FEATURES_REG_ADDR, feat_config, BMI2_FEAT_SIZE_IN_BYTES, dev);
}
}
}
else
{
rslt = BMI2_E_INVALID_SENSOR;
}
return rslt;
}
/* @brief This internal API sets step counter configurations like water-mark
* level, reset-counter and output-configuration step detector and activity.
*/
static int8_t set_step_config(const struct bmi2_step_config *config, struct bmi2_dev *dev)
{
/* Variable to define error */
int8_t rslt;
/* Array to define the feature configuration */
uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
/* Variable to define the array offset */
uint8_t idx = 0;
/* Variable to define index */
uint8_t index = 0;
/* Variable to set flag */
uint8_t feat_found;
/* Initialize feature configuration for step counter 4 */
struct bmi2_feature_config step_count_config = { 0, 0, 0 };
/* Copy the feature configuration address to a local pointer */
uint16_t *data_p = (uint16_t *) (void *)feat_config;
/* Search for step counter feature and extract its configuration details */
feat_found = bmi2_extract_input_feat_config(&step_count_config, BMI2_STEP_COUNTER, dev);
if (feat_found)
{
/* Get the configuration from the page where step counter resides */
rslt = bmi2_get_feat_config(step_count_config.page, feat_config, dev);
if (rslt == BMI2_OK)
{
/* Define the offset in bytes */
idx = step_count_config.start_addr;
/* Get offset in words since all the features are set in words length */
idx = idx / 2;
/* Set water-mark level */
*(data_p + idx) = BMI2_SET_BIT_POS0(*(data_p + idx), BMI2_STEP_COUNT_WM_LEVEL, config->watermark_level);
/* Set reset-counter */
*(data_p + idx) = BMI2_SET_BITS(*(data_p + idx), BMI2_STEP_COUNT_RST_CNT, config->reset_counter);
/* Increment offset by 1 more word to get the total length in words */
idx++;
/* Get total length in bytes to copy from local pointer to the array */
idx = (uint8_t)(idx * 2) - step_count_config.start_addr;
/* Copy the bytes to be set back to the array */
for (index = 0; index < idx; index++)
{
feat_config[step_count_config.start_addr +
index] = *((uint8_t *) data_p + step_count_config.start_addr + index);
}
/* Set the configuration back to the page */
rslt = bmi2_set_regs(BMI2_FEATURES_REG_ADDR, feat_config, BMI2_FEAT_SIZE_IN_BYTES, dev);
}
}
else
{
rslt = BMI2_E_INVALID_SENSOR;
}
return rslt;
}
/*!
* @brief This internal API gets step counter parameter configurations.
*/
static int8_t get_step_count_params_config(uint16_t *step_count_params, struct bmi2_dev *dev)
{
/* Variable to define error */
int8_t rslt = BMI2_OK;
/* Array to define the feature configuration */
uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
/* Variable to set flag */
uint8_t feat_found;
/* Variable to define LSB */
uint16_t lsb = 0;
/* Variable to define MSB */
uint16_t msb = 0;
/* Variable to define a word */
uint16_t lsb_msb = 0;
/* Initialize feature configuration for step counter 1 */
struct bmi2_feature_config step_params_config = { 0, 0, 0 };
/* Variable to index the page number */
uint8_t page_idx;
/* Variable to define the start page */
uint8_t start_page;
/* Variable to define start address of the parameters */
uint8_t start_addr;
/* Variable to define number of bytes */
uint8_t n_bytes = (BMI2_STEP_CNT_N_PARAMS * 2);
/* Variable to store number of pages */
uint8_t n_pages = (n_bytes / 16);
/* Variable to define the end page */
uint8_t end_page;
/* Variable to define the remaining bytes to be read */
uint8_t remain_len;
/* Variable to define the maximum words to be read in a page */
uint8_t max_len = BMI2_FEAT_SIZE_IN_BYTES;
/* Variable index bytes in a page */
uint8_t page_byte_idx;
/* Variable to index the parameters */
uint8_t param_idx = 0;
/* Search for step counter parameter feature and extract its configuration details */
feat_found = bmi2_extract_input_feat_config(&step_params_config, BMI2_STEP_COUNTER_PARAMS, dev);
if (feat_found)
{
/* Get the start page for the step counter parameters */
start_page = step_params_config.page;
/* Get the end page for the step counter parameters */
end_page = start_page + n_pages;
/* Get the start address for the step counter parameters */
start_addr = step_params_config.start_addr;
/* Get the remaining length of bytes to be read */
remain_len = (uint8_t)((n_bytes - (n_pages * 16)) + start_addr);
for (page_idx = start_page; page_idx <= end_page; page_idx++)
{
/* Get the configuration from the respective page */
rslt = bmi2_get_feat_config(page_idx, feat_config, dev);
if (rslt == BMI2_OK)
{
/* Start from address 0x00 when switched to next page */
if (page_idx > start_page)
{
start_addr = 0;
}
/* Remaining number of bytes to be read in the page */
if (page_idx == end_page)
{
max_len = remain_len;
}
/* Get the offset */
page_byte_idx = start_addr;
while (page_byte_idx < max_len)
{
/* Get word to calculate the parameter*/
lsb = (uint16_t) feat_config[page_byte_idx++];
if (page_byte_idx < max_len)
{
msb = ((uint16_t) feat_config[page_byte_idx++] << 8);
}
lsb_msb = lsb | msb;
/* Get parameters 1 to 25 */
step_count_params[param_idx] = lsb_msb & BMI2_STEP_COUNT_PARAMS_MASK;
/* Increment to next parameter */
param_idx++;
}
}
}
}
else
{
rslt = BMI2_E_INVALID_SENSOR;
}
return rslt;
}
/*!
* @brief This internal API gets step counter/detector/activity configurations.
*/
static int8_t get_step_config(struct bmi2_step_config *config, struct bmi2_dev *dev)
{
/* Variable to define error */
int8_t rslt;
/* Array to define the feature configuration */
uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
/* Variable to define the array offset */
uint8_t idx = 0;
/* Variable to define LSB */
uint16_t lsb = 0;
/* Variable to define MSB */
uint16_t msb = 0;
/* Variable to define a word */
uint16_t lsb_msb = 0;
/* Variable to set flag */
uint8_t feat_found;
/* Initialize feature configuration for step counter */
struct bmi2_feature_config step_count_config = { 0, 0, 0 };
/* Search for step counter 4 feature and extract its configuration details */
feat_found = bmi2_extract_input_feat_config(&step_count_config, BMI2_STEP_COUNTER, dev);
if (feat_found)
{
/* Get the configuration from the page where step counter 4 parameter resides */
rslt = bmi2_get_feat_config(step_count_config.page, feat_config, dev);
if (rslt == BMI2_OK)
{
/* Define the offset for feature enable for step counter/detector/activity */
idx = step_count_config.start_addr;
/* Get word to calculate water-mark level and reset counter */
lsb = (uint16_t) feat_config[idx++];
msb = ((uint16_t) feat_config[idx++] << 8);
lsb_msb = lsb | msb;
/* Get water-mark level */
config->watermark_level = lsb_msb & BMI2_STEP_COUNT_WM_LEVEL_MASK;
/* Get reset counter */
config->reset_counter = (lsb_msb & BMI2_STEP_COUNT_RST_CNT_MASK) >> BMI2_STEP_COUNT_RST_CNT_POS;
}
}
else
{
rslt = BMI2_E_INVALID_SENSOR;
}
return rslt;
}
/*!
* @brief This internal API gets the output values of step counter.
*/
static int8_t get_step_counter_output(uint32_t *step_count, struct bmi2_dev *dev)
{
/* Variable to define error */
int8_t rslt;
/* Array to define the feature configuration */
uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
/* Variables to define index */
uint8_t idx = 0;
/* Variable to set flag */
uint8_t feat_found;
/* Initialize feature output for step counter */
struct bmi2_feature_config step_cnt_out_config = { 0, 0, 0 };
/* Search for step counter output feature and extract its configuration details */
feat_found = extract_output_feat_config(&step_cnt_out_config, BMI2_STEP_COUNTER, dev);
if (feat_found)
{
/* Get the feature output configuration for step-counter */
rslt = bmi2_get_feat_config(step_cnt_out_config.page, feat_config, dev);
if (rslt == BMI2_OK)
{
/* Define the offset in bytes for step counter output */
idx = step_cnt_out_config.start_addr;
/* Get the step counter output in 4 bytes */
*step_count = (uint32_t) feat_config[idx++];
*step_count |= ((uint32_t) feat_config[idx++] << 8);
*step_count |= ((uint32_t) feat_config[idx++] << 16);
*step_count |= ((uint32_t) feat_config[idx++] << 24);
}
}
else
{
rslt = BMI2_E_INVALID_SENSOR;
}
return rslt;
}
/*!
* @brief This internal API gets the error status related to NVM.
*/
static int8_t get_nvm_error_status(struct bmi2_nvm_err_status *nvm_err_stat, struct bmi2_dev *dev)
{
/* Variable to define error */
int8_t rslt;
/* Array to define the feature configuration */
uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
/* Variables to define index */
uint8_t idx = 0;
/* Variable to set flag */
uint8_t feat_found;
/* Initialize feature output for NVM error status */
struct bmi2_feature_config nvm_err_cfg = { 0, 0, 0 };
/* Search for NVM error status feature and extract its configuration details */
feat_found = extract_output_feat_config(&nvm_err_cfg, BMI2_NVM_STATUS, dev);
if (feat_found)
{
/* Get the feature output configuration for NVM error status */
rslt = bmi2_get_feat_config(nvm_err_cfg.page, feat_config, dev);
if (rslt == BMI2_OK)
{
/* Define the offset in bytes for NVM error status */
idx = nvm_err_cfg.start_addr;
/* Increment index to get the error status */
idx++;
/* Error when NVM load action fails */
nvm_err_stat->load_error = BMI2_GET_BIT_POS0(feat_config[idx], BMI2_NVM_LOAD_ERR_STATUS);
/* Error when NVM program action fails */
nvm_err_stat->prog_error = BMI2_GET_BITS(feat_config[idx], BMI2_NVM_PROG_ERR_STATUS);
/* Error when NVM erase action fails */
nvm_err_stat->erase_error = BMI2_GET_BITS(feat_config[idx], BMI2_NVM_ERASE_ERR_STATUS);
/* Error when NVM program limit is exceeded */
nvm_err_stat->exceed_error = BMI2_GET_BITS(feat_config[idx], BMI2_NVM_END_EXCEED_STATUS);
/* Error when NVM privilege mode is not acquired */
nvm_err_stat->privil_error = BMI2_GET_BITS(feat_config[idx], BMI2_NVM_PRIV_ERR_STATUS);
}
}
else
{
rslt = BMI2_E_INVALID_SENSOR;
}
return rslt;
}
/*!
* @brief This internal API is used to parse and store the activity recognition
* output from the FIFO data.
*/
static int8_t unpack_act_recog_output(struct bmi2_act_recog_output *act_recog,
uint16_t *data_index,
const struct bmi2_fifo_frame *fifo)
{
/* Variable to define error */
int8_t rslt = BMI2_OK;
/* Variables to define 4 bytes of sensor time */
uint32_t time_stamp_byte4 = 0;
uint32_t time_stamp_byte3 = 0;
uint32_t time_stamp_byte2 = 0;
uint32_t time_stamp_byte1 = 0;
/* Validate data index */
if ((*data_index + BMI2_FIFO_VIRT_ACT_DATA_LENGTH) >= fifo->length)
{
/* Update the data index to the last byte */
(*data_index) = fifo->length;
/* FIFO is empty */
rslt = BMI2_W_FIFO_EMPTY;
}
else
{
/* Get time-stamp from the activity recognition frame */
time_stamp_byte4 = ((uint32_t)(fifo->data[(*data_index) + 3]) << 24);
time_stamp_byte3 = ((uint32_t)(fifo->data[(*data_index) + 2]) << 16);
time_stamp_byte2 = fifo->data[(*data_index) + 1] << 8;
time_stamp_byte1 = fifo->data[(*data_index)];
/* Update time-stamp from the virtual frame */
act_recog->time_stamp = (time_stamp_byte4 | time_stamp_byte3 | time_stamp_byte2 | time_stamp_byte1);
/* Move the data index by 4 bytes */
(*data_index) = (*data_index) + BMI2_FIFO_VIRT_ACT_TIME_LENGTH;
/* Update the previous activity from the virtual frame */
act_recog->prev_act = fifo->data[(*data_index)];
/* Move the data index by 1 byte */
(*data_index) = (*data_index) + BMI2_FIFO_VIRT_ACT_TYPE_LENGTH;
/* Update the current activity from the virtual frame */
act_recog->curr_act = fifo->data[(*data_index)];
/* Move the data index by 1 byte */
(*data_index) = (*data_index) + BMI2_FIFO_VIRT_ACT_STAT_LENGTH;
/* More frames could be read */
rslt = BMI2_W_PARTIAL_READ;
}
return rslt;
}
/*!
* @brief This internal API gets the error status related to virtual frames.
*/
static int8_t get_vfrm_error_status(struct bmi2_vfrm_err_status *vfrm_err_stat, struct bmi2_dev *dev)
{
/* Variable to define error */
int8_t rslt;
/* Array to define the feature configuration */
uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
/* Variables to define index */
uint8_t idx = 0;
/* Variable to set flag */
uint8_t feat_found;
/* Initialize feature output for VFRM error status */
struct bmi2_feature_config vfrm_err_cfg = { 0, 0, 0 };
/* Search for VFRM error status feature and extract its configuration details */
feat_found = extract_output_feat_config(&vfrm_err_cfg, BMI2_VFRM_STATUS, dev);
if (feat_found)
{
/* Get the feature output configuration for VFRM error status */
rslt = bmi2_get_feat_config(vfrm_err_cfg.page, feat_config, dev);
if (rslt == BMI2_OK)
{
/* Define the offset in bytes for VFRM error status */
idx = vfrm_err_cfg.start_addr;
/* Increment index to get the error status */
idx++;
/* Internal error while acquiring lock for FIFO */
vfrm_err_stat->lock_error = BMI2_GET_BITS(feat_config[idx], BMI2_VFRM_LOCK_ERR_STATUS);
/* Internal error while writing byte into FIFO */
vfrm_err_stat->write_error = BMI2_GET_BITS(feat_config[idx], BMI2_VFRM_WRITE_ERR_STATUS);
/* Internal error while writing into FIFO */
vfrm_err_stat->fatal_error = BMI2_GET_BITS(feat_config[idx], BMI2_VFRM_FATAL_ERR_STATUS);
}
}
else
{
rslt = BMI2_E_INVALID_SENSOR;
}
return rslt;
}
/*!
* @brief This internal API skips S4S frame in the FIFO data while getting
* step activity output.
*/
static int8_t move_if_s4s_frame(const uint8_t *frame_header, uint16_t *data_index, const struct bmi2_fifo_frame *fifo)
{
/* Variable to define error */
int8_t rslt = BMI2_OK;
/* Variable to extract virtual header byte */
uint8_t virtual_header_mode;
/* Variable to define pay-load in words */
uint8_t payload_word = 0;
/* Variable to define pay-load in bytes */
uint8_t payload_bytes = 0;
/* Extract virtual header mode from the frame header */
virtual_header_mode = BMI2_GET_BITS(*frame_header, BMI2_FIFO_VIRT_FRM_MODE);
/* If the extracted header byte is a virtual header */
if (virtual_header_mode == BMI2_FIFO_VIRT_FRM_MODE)
{
/* If frame header is not activity recognition header */
if (*frame_header != 0xC8)
{
/* Extract pay-load in words from the header byte */
payload_word = BMI2_GET_BITS(*frame_header, BMI2_FIFO_VIRT_PAYLOAD) + 1;
/* Convert to bytes */
payload_bytes = (uint8_t)(payload_word * 2);
/* Move the data index by those pay-load bytes */
rslt = move_next_frame(data_index, payload_bytes, fifo);
}
}
return rslt;
}
/*!
* @brief This internal API is used to extract the output feature configuration
* details from the look-up table.
*/
static uint8_t extract_output_feat_config(struct bmi2_feature_config *feat_output,
uint8_t type,
const struct bmi2_dev *dev)
{
/* Variable to define loop */
uint8_t loop = 0;
/* Variable to set flag */
uint8_t feat_found = BMI2_FALSE;
/* Search for the output feature from the output configuration array */
while (loop < dev->out_sens)
{
if (dev->feat_output[loop].type == type)
{
*feat_output = dev->feat_output[loop];
feat_found = BMI2_TRUE;
break;
}
loop++;
}
/* Return flag */
return feat_found;
}
/*!
* @brief This internal API is used to move the data index ahead of the
* current_frame_length parameter when unnecessary FIFO data appears while
* extracting the user specified data.
*/
static int8_t move_next_frame(uint16_t *data_index, uint8_t current_frame_length, const struct bmi2_fifo_frame *fifo)
{
/* Variables to define error */
int8_t rslt = BMI2_OK;
/* Validate data index */
if (((*data_index) + current_frame_length) > fifo->length)
{
/* Move the data index to the last byte */
(*data_index) = fifo->length;
/* FIFO is empty */
rslt = BMI2_W_FIFO_EMPTY;
}
else
{
/* Move the data index to next frame */
(*data_index) = (*data_index) + current_frame_length;
/* More frames could be read */
rslt = BMI2_W_PARTIAL_READ;
}
return rslt;
}
/*!
* @brief This internal API is used to select the header byte frame
*/
static int8_t fifo_header_frame(uint16_t frame_to_read,
uint16_t *act_frm_len,
struct bmi2_act_recog_output *act_recog,
struct bmi2_fifo_frame *fifo,
const struct bmi2_dev *dev)
{
/* Variables to define error */
int8_t rslt = BMI2_OK;
/* Variable to index the data bytes */
uint16_t data_index;
/* Variable to define header frame */
uint8_t frame_header = 0;
/* Variable to index activity frames */
uint16_t act_idx = 0;
/* Check if this is the first iteration of data unpacking
* if yes, then consider dummy byte on SPI
*/
if (fifo->act_recog_byte_start_idx == 0)
{
/* Dummy byte included */
fifo->act_recog_byte_start_idx = dev->dummy_byte;
}
for (data_index = fifo->act_recog_byte_start_idx; data_index < fifo->length;)
{
/* Get frame header byte */
frame_header = fifo->data[data_index] & BMI2_FIFO_TAG_INTR_MASK;
/* Skip S4S frames if S4S is enabled */
rslt = move_if_s4s_frame(&frame_header, &data_index, fifo);
/* Break if FIFO is empty */
if (rslt == BMI2_W_FIFO_EMPTY)
{
break;
}
/* Index shifted to next byte where data starts */
data_index++;
if (rslt == BMI2_OK)
{
switch (frame_header)
{
/* If header defines accelerometer frame */
case BMI2_FIFO_HEADER_ACC_FRM:
rslt = move_next_frame(&data_index, fifo->acc_frm_len, fifo);
break;
/* If header defines accelerometer and auxiliary frames */
case BMI2_FIFO_HEADER_AUX_ACC_FRM:
rslt = move_next_frame(&data_index, fifo->acc_aux_frm_len, fifo);
break;
/* If header defines accelerometer and gyroscope frames */
case BMI2_FIFO_HEADER_GYR_ACC_FRM:
rslt = move_next_frame(&data_index, fifo->acc_gyr_frm_len, fifo);
break;
/* If header defines accelerometer, auxiliary and gyroscope frames */
case BMI2_FIFO_HEADER_ALL_FRM:
rslt = move_next_frame(&data_index, fifo->all_frm_len, fifo);
break;
/* If header defines only gyroscope frame */
case BMI2_FIFO_HEADER_GYR_FRM:
rslt = move_next_frame(&data_index, fifo->gyr_frm_len, fifo);
break;
/* If header defines only auxiliary frame */
case BMI2_FIFO_HEADER_AUX_FRM:
rslt = move_next_frame(&data_index, fifo->aux_frm_len, fifo);
break;
/* If header defines auxiliary and gyroscope frame */
case BMI2_FIFO_HEADER_AUX_GYR_FRM:
rslt = move_next_frame(&data_index, fifo->aux_gyr_frm_len, fifo);
break;
/* If header defines sensor time frame */
case BMI2_FIFO_HEADER_SENS_TIME_FRM:
rslt = move_next_frame(&data_index, BMI2_SENSOR_TIME_LENGTH, fifo);
break;
/* If header defines skip frame */
case BMI2_FIFO_HEADER_SKIP_FRM:
rslt = move_next_frame(&data_index, BMI2_FIFO_SKIP_FRM_LENGTH, fifo);
break;
/* If header defines Input configuration frame */
case BMI2_FIFO_HEADER_INPUT_CFG_FRM:
rslt = move_next_frame(&data_index, BMI2_FIFO_INPUT_CFG_LENGTH, fifo);
break;
/* If header defines invalid frame or end of valid data */
case BMI2_FIFO_HEAD_OVER_READ_MSB:
/* Move the data index to the last byte to mark completion */
data_index = fifo->length;
/* FIFO is empty */
rslt = BMI2_W_FIFO_EMPTY;
break;
/* If header defines activity recognition frame */
case BMI2_FIFO_VIRT_ACT_RECOG_FRM:
/* Get the activity output */
rslt = unpack_act_recog_output(&act_recog[(act_idx)], &data_index, fifo);
/* Update activity frame index */
(act_idx)++;
break;
default:
/* Move the data index to the last byte in case of invalid values */
data_index = fifo->length;
/* FIFO is empty */
rslt = BMI2_W_FIFO_EMPTY;
break;
}
/* Number of frames to be read is complete or FIFO is empty */
if ((frame_to_read == act_idx) || (rslt == BMI2_W_FIFO_EMPTY))
{
break;
}
}
}
/* Update the activity frame index */
(*act_frm_len) = act_idx;
/* Update the activity byte index */
fifo->act_recog_byte_start_idx = data_index;
return rslt;
}
/*!
* @brief This internal API is used to enable main sensors like accel, gyro, aux and temperature.
*/
static int8_t enable_main_sensors(uint64_t sensor_sel, struct bmi2_dev *dev)
{
/* Variable to define error */
int8_t rslt;
/* Variable to store register values */
uint8_t reg_data;
rslt = bmi2_get_regs(BMI2_PWR_CTRL_ADDR, &reg_data, 1, dev);
if (rslt == BMI2_OK)
{
/* Enable accelerometer */
if (sensor_sel & BMI2_ACCEL_SENS_SEL)
{
reg_data = BMI2_SET_BITS(reg_data, BMI2_ACC_EN, BMI2_ENABLE);
}
/* Enable gyroscope */
if (sensor_sel & BMI2_GYRO_SENS_SEL)
{
reg_data = BMI2_SET_BITS(reg_data, BMI2_GYR_EN, BMI2_ENABLE);
}
/* Enable auxiliary sensor */
if (sensor_sel & BMI2_AUX_SENS_SEL)
{
reg_data = BMI2_SET_BIT_POS0(reg_data, BMI2_AUX_EN, BMI2_ENABLE);
}
/* Enable temperature sensor */
if (sensor_sel & BMI2_TEMP_SENS_SEL)
{
reg_data = BMI2_SET_BITS(reg_data, BMI2_TEMP_EN, BMI2_ENABLE);
}
/* Enable the sensors that are set in the power control register */
if (sensor_sel & BMI2_MAIN_SENSORS)
{
rslt = bmi2_set_regs(BMI2_PWR_CTRL_ADDR, &reg_data, 1, dev);
}
}
return rslt;
}
/*!
* @brief This internal API is used to enable sensor features.
*/
static int8_t enable_sensor_features(uint64_t sensor_sel, struct bmi2_dev *dev)
{
/* Variable to define error */
int8_t rslt = BMI2_OK;
/* Enable step detector feature */
if (sensor_sel & BMI2_STEP_DETECT_SEL)
{
rslt = set_step_detector(BMI2_ENABLE, dev);
}
/* Enable step counter feature */
if (sensor_sel & BMI2_STEP_COUNT_SEL)
{
rslt = set_step_counter(BMI2_ENABLE, dev);
}
/* Enable activity recognition feature */
if (sensor_sel & BMI2_ACTIVITY_RECOGNITION_SEL)
{
rslt = set_act_recog(BMI2_ENABLE, dev);
}
return rslt;
}
/*!
* @brief This internal API is used to disable main sensors like accel, gyro, aux and temperature.
*/
static int8_t disable_main_sensors(uint64_t sensor_sel, struct bmi2_dev *dev)
{
/* Variable to define error */
int8_t rslt;
/* Variable to store register values */
uint8_t reg_data;
rslt = bmi2_get_regs(BMI2_PWR_CTRL_ADDR, &reg_data, 1, dev);
if (rslt == BMI2_OK)
{
/* Disable accelerometer */
if (sensor_sel & BMI2_ACCEL_SENS_SEL)
{
reg_data = BMI2_SET_BIT_VAL0(reg_data, BMI2_ACC_EN);
}
/* Disable gyroscope */
if (sensor_sel & BMI2_GYRO_SENS_SEL)
{
reg_data = BMI2_SET_BIT_VAL0(reg_data, BMI2_GYR_EN);
}
/* Disable auxiliary sensor */
if (sensor_sel & BMI2_AUX_SENS_SEL)
{
reg_data = BMI2_SET_BIT_VAL0(reg_data, BMI2_AUX_EN);
}
/* Disable the sensors that are set in the power control register */
if (sensor_sel & BMI2_MAIN_SENSORS)
{
rslt = bmi2_set_regs(BMI2_PWR_CTRL_ADDR, &reg_data, 1, dev);
}
}
return rslt;
}
/*!
* @brief This internal API is used to disable sensor features.
*/
static int8_t disable_sensor_features(uint64_t sensor_sel, struct bmi2_dev *dev)
{
/* Variable to define error */
int8_t rslt = BMI2_OK;
/* Enable step detector feature */
if (sensor_sel & BMI2_STEP_DETECT_SEL)
{
rslt = set_step_detector(BMI2_DISABLE, dev);
}
/* Enable step counter feature */
if (sensor_sel & BMI2_STEP_COUNT_SEL)
{
rslt = set_step_counter(BMI2_DISABLE, dev);
}
/* Enable activity recognition feature */
if (sensor_sel & BMI2_ACTIVITY_RECOGNITION_SEL)
{
rslt = set_act_recog(BMI2_DISABLE, dev);
}
return rslt;
}
/**
* Copyright (c) 2023 Bosch Sensortec GmbH. All rights reserved.
*
* BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @file bmi270_context.h
* @date 2023-05-03
* @version v2.86.1
*
*/
/**
* \ingroup bmi2xy
* \defgroup bmi270_context BMI270_CONTEXT
* @brief Sensor driver for BMI270_CONTEXT sensor
*/
#ifndef BMI270_CONTEXT_H_
#define BMI270_CONTEXT_H_
/*! CPP guard */
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************************/
/*! Header files
****************************************************************************/
#include "bmi2.h"
/***************************************************************************/
/*! Macro definitions
****************************************************************************/
/*! @name BMI270_CONTEXT Chip identifier */
#define BMI270_CONTEXT_CHIP_ID UINT8_C(0x24)
/*! @name BMI270_CONTEXT feature input start addresses */
#define BMI270_CONTEXT_CONFIG_ID_STRT_ADDR UINT8_C(0x06)
#define BMI270_CONTEXT_STEP_CNT_1_STRT_ADDR UINT8_C(0x00)
#define BMI270_CONTEXT_STEP_CNT_4_STRT_ADDR UINT8_C(0x02)
#define BMI270_CONTEXT_MAX_BURST_LEN_STRT_ADDR UINT8_C(0x08)
#define BMI270_CONTEXT_CRT_GYRO_SELF_TEST_STRT_ADDR UINT8_C(0x09)
#define BMI270_CONTEXT_ABORT_STRT_ADDR UINT8_C(0x09)
#define BMI270_CONTEXT_NVM_PROG_PREP_STRT_ADDR UINT8_C(0x0A)
#define BMI270_CONTEXT_ACT_RGN_SETT_STRT_ADDR UINT8_C(0x00)
#define BMI270_CONTEXT_ACT_RGN_STRT_ADDR UINT8_C(0x0A)
/*! @name BMI270_CONTEXT feature output start addresses */
#define BMI270_CONTEXT_STEP_CNT_OUT_STRT_ADDR UINT8_C(0x00)
#define BMI270_CONTEXT_GYR_USER_GAIN_OUT_STRT_ADDR UINT8_C(0x04)
#define BMI270_CONTEXT_GYRO_CROSS_SENSE_STRT_ADDR UINT8_C(0x0C)
#define BMI270_CONTEXT_NVM_VFRM_OUT_STRT_ADDR UINT8_C(0x0E)
/*! @name Defines maximum number of pages */
#define BMI270_CONTEXT_MAX_PAGE_NUM UINT8_C(8)
/*! @name Defines maximum number of feature input configurations */
#define BMI270_CONTEXT_MAX_FEAT_IN UINT8_C(10)
/*! @name Defines maximum number of feature outputs */
#define BMI270_CONTEXT_MAX_FEAT_OUT UINT8_C(5)
/*! @name Mask definitions for feature interrupt status bits */
#define BMI270_CONTEXT_STEP_CNT_STATUS_MASK UINT8_C(0x01)
/*! @name Mask definitions for feature interrupt mapping bits */
#define BMI270_C_INT_STEP_COUNTER_MASK UINT8_C(0x01)
#define BMI270_C_INT_STEP_DETECTOR_MASK UINT8_C(0x01)
/*! @name Defines maximum number of feature interrupts */
#define BMI270_C_MAX_INT_MAP UINT8_C(2)
/***************************************************************************/
/*! BMI270_CONTEXT User Interface function prototypes
****************************************************************************/
/**
* \ingroup bmi270_context
* \defgroup bmi270_contextApiInit Initialization
* @brief Initialize the sensor and device structure
*/
/*!
* \ingroup bmi270_contextApiInit
* \page bmi270_context_api_bmi270_context_init bmi270_context_init
* \code
* int8_t bmi270_context_init(struct bmi2_dev *dev);
* \endcode
* @details This API:
* 1) updates the device structure with address of the configuration file.
* 2) Initializes BMI270_CONTEXT sensor.
* 3) Writes the configuration file.
* 4) Updates the feature offset parameters in the device structure.
* 5) Updates the maximum number of pages, in the device structure.
*
* @param[in, out] dev : Structure instance of bmi2_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bmi270_context_init(struct bmi2_dev *dev);
/**
* \ingroup bmi270_context
* \defgroup bmi270_contextApiSensor Feature Set
* @brief Enable / Disable features of the sensor
*/
/*!
* \ingroup bmi270_contextApiSensor
* \page bmi270_context_api_bmi270_context_sensor_enable bmi270_context_sensor_enable
* \code
* int8_t bmi270_context_sensor_enable(const uint8_t *sens_list, uint8_t n_sens, struct bmi2_dev *dev);
* \endcode
* @details This API selects the sensors/features to be enabled.
*
* @param[in] sens_list : Pointer to select the sensor/feature.
* @param[in] n_sens : Number of sensors selected.
* @param[in, out] dev : Structure instance of bmi2_dev.
*
* @note Sensors/features that can be enabled.
*
*@verbatim
* sens_list | Values
* ----------------------------|-----------
* BMI2_ACCEL | 0
* BMI2_GYRO | 1
* BMI2_AUX | 2
* BMI2_STEP_DETECTOR | 6
* BMI2_STEP_COUNTER | 7
* BMI2_GYRO_GAIN_UPDATE | 9
* BMI2_ACTIVITY_RECOGNITION | 34
*@endverbatim
*
* @note :
* example uint8_t sens_list[2] = {BMI2_ACCEL, BMI2_GYRO};
* uint8_t n_sens = 2;
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bmi270_context_sensor_enable(const uint8_t *sens_list, uint8_t n_sens, struct bmi2_dev *dev);
/*!
* \ingroup bmi270_contextApiSensor
* \page bmi270_context_api_bmi270_context_sensor_disable bmi270_context_sensor_disable
* \code
* int8_t bmi270_context_sensor_disable(const uint8_t *sens_list, uint8_t n_sens, struct bmi2_dev *dev);
* \endcode
* @details This API selects the sensors/features to be disabled.
*
* @param[in] sens_list : Pointer to select the sensor/feature.
* @param[in] n_sens : Number of sensors selected.
* @param[in, out] dev : Structure instance of bmi2_dev.
*
* @note Sensors/features that can be disabled.
*
*@verbatim
* sens_list | Values
* ----------------------------|-----------
* BMI2_ACCEL | 0
* BMI2_GYRO | 1
* BMI2_AUX | 2
* BMI2_STEP_DETECTOR | 6
* BMI2_STEP_COUNTER | 7
* BMI2_GYRO_GAIN_UPDATE | 9
* BMI2_ACTIVITY_RECOGNITION | 34
*@endverbatim
*
* @note :
* example uint8_t sens_list[2] = {BMI2_ACCEL, BMI2_GYRO};
* uint8_t n_sens = 2;
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bmi270_context_sensor_disable(const uint8_t *sens_list, uint8_t n_sens, struct bmi2_dev *dev);
/**
* \ingroup bmi270_context
* \defgroup bmi270_contextApiSensorC Sensor Configuration
* @brief Enable / Disable feature configuration of the sensor
*/
/*!
* \ingroup bmi270_contextApiSensorC
* \page bmi270_context_api_bmi270_context_set_sensor_config bmi270_context_set_sensor_config
* \code
* int8_t bmi270_context_set_sensor_config(struct bmi2_sens_config *sens_cfg, uint8_t n_sens, struct bmi2_dev *dev);
* \endcode
* @details This API sets the sensor/feature configuration.
*
* @param[in] sens_cfg : Structure instance of bmi2_sens_config.
* @param[in] n_sens : Number of sensors selected.
* @param[in, out] dev : Structure instance of bmi2_dev.
*
* @note Sensors/features that can be configured
*
*@verbatim
* sens_list | Values
* ----------------------------|-----------
* BMI2_STEP_DETECTOR | 6
* BMI2_STEP_COUNTER | 7
* BMI2_STEP_COUNTER_PARAMS | 28
*@endverbatim
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bmi270_context_set_sensor_config(struct bmi2_sens_config *sens_cfg, uint8_t n_sens, struct bmi2_dev *dev);
/*!
* \ingroup bmi270_contextApiSensorC
* \page bmi270_context_api_bmi270_context_get_sensor_config bmi270_context_get_sensor_config
* \code
* int8_t bmi270_context_get_sensor_config(struct bmi2_sens_config *sens_cfg, uint8_t n_sens, struct bmi2_dev *dev);
* \endcode
* @details This API gets the sensor/feature configuration.
*
* @param[in] sens_cfg : Structure instance of bmi2_sens_config.
* @param[in] n_sens : Number of sensors selected.
* @param[in, out] dev : Structure instance of bmi2_dev.
*
* @note Sensors/features whose configurations can be read.
*
*@verbatim
* sens_list | Values
* ----------------------------|-----------
* BMI2_STEP_DETECTOR | 6
* BMI2_STEP_COUNTER | 7
* BMI2_STEP_COUNTER_PARAMS | 28
*@endverbatim
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bmi270_context_get_sensor_config(struct bmi2_sens_config *sens_cfg, uint8_t n_sens, struct bmi2_dev *dev);
/**
* \ingroup bmi270_context
* \defgroup bmi270_contextApiSensorD Feature Sensor Data
* @brief Get feature sensor data
*/
/*!
* \ingroup bmi270_contextApiSensorD
* \page bmi270_context_api_bmi270_context_get_feature_data bmi270_context_get_feature_data
* \code
* int8_t bmi270_context_get_feature_data(struct bmi2_feat_sensor_data *feature_data, uint8_t n_sens, struct bmi2_dev *dev);
* \endcode
* @details This API gets the feature data.
*
* @param[out] feature_data : Structure instance of bmi2_feat_sensor_data.
* @param[in] n_sens : Number of sensors selected.
* @param[in] dev : Structure instance of bmi2_dev.
*
* @note Sensors/features whose data can be read
*
*@verbatim
* sens_list | Values
* ---------------------|-----------
* BMI2_STEP_COUNTER | 7
* BMI2_NVM_STATUS | 38
* BMI2_VFRM_STATUS | 39
*@endverbatim
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bmi270_context_get_feature_data(struct bmi2_feat_sensor_data *feature_data, uint8_t n_sens,
struct bmi2_dev *dev);
/**
* \ingroup bmi270_context
* \defgroup bmi270_contextApiARecog Activity recognition settings
* @brief Set / Get activity recognition settings of the sensor
*/
/*!
* \ingroup bmi270_contextApiARecog
* \page bmi270_context_api_bmi270_context_get_act_recg_sett bmi270_context_get_act_recg_sett
* \code
* int8_t bmi270_context_get_act_recg_sett(struct bmi2_act_recg_sett *sett, struct bmi2_dev *dev);
* \endcode
* @details This api is used for retrieving the following activity recognition settings currently set.
* enable/disable post processing(0/1) by default -> 1(enable),
* Setting the min & max Gini's diversity index (GDI) threshold. min_GDI_tres(0-0XFFFF) by default ->(0x06e1)
* max_GDI_tres(0-0xFFFF) by default ->(0x0A66)
* buffer size for post processing. range (1-0x0A) default -> (0x0A)
* min segment confidence. range (1-0x0A) default -> (0x0A)
*
* @param[in] sett : Structure instance of bmi2_act_recg_sett.
* @param[in] dev : Structure instance of bmi2_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bmi270_context_get_act_recg_sett(struct bmi2_act_recg_sett *sett, struct bmi2_dev *dev);
/*!
* \ingroup bmi270_contextApiARecog
* \page bmi270_context_api_bmi270_context_set_act_recg_sett bmi270_context_set_act_recg_sett
* \code
* int8_t bmi270_context_set_act_recg_sett(const struct bmi2_act_recg_sett *sett, struct bmi2_dev *dev);
* \endcode
* @details This api is used for setting the following activity recognition settings
* enable/disable post processing(0/1) by default -> 1(enable),
* Setting the min & max Gini's diversity index (GDI) threshold. min_GDI_tres(0-0XFFFF) by default ->(0x06e1)
* max_GDI_tres(0-0xFFFF) by default ->(0x0A66)
* buffer size for post processing. range (1-0x0A) default -> (0x0A)
* min segment confidence. range (1-0x0A) default -> (0x0A)
*
* @param[in] sett : Structure instance of bmi2_act_recg_sett.
* @param[in] dev : Structure instance of bmi2_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bmi270_context_set_act_recg_sett(const struct bmi2_act_recg_sett *sett, struct bmi2_dev *dev);
/**
* \ingroup bmi270_contex
* \defgroup bmi270_contextApiactOut Activity Output
* @brief Activity output operations of the sensor
*/
/*!
* \ingroup bmi270_contextApiactOut
* \page bmi270_context_api_bmi270_context_get_act_recog_output bmi270_context_get_act_recog_output
* \code
* int8_t bmi270_context_get_act_recog_output(struct bmi2_act_recog_output *act_recog,
* uint16_t *act_frm_len,
* struct bmi2_fifo_frame *fifo,
* const struct bmi2_dev *dev);
*
* \endcode
* @details This internal API is used to parse the activity output from the
* FIFO in header mode.
*
* @param[out] act_recog : Pointer to buffer where the parsed activity data
* bytes are stored.
* @param[in] act_frm_len : Number of activity frames parsed.
* @param[in] fifo : Structure instance of bmi2_fifo_frame.
* @param[in] dev : Structure instance of bmi2_dev.
*
* @verbatim
* ----------------------------------------------------------------------------
* bmi2_act_rec_output |
* Structure parameters | Description
*--------------------------|--------------------------------------------------
* time_stamp | time-stamp (expressed in 50Hz ticks)
* -------------------------|---------------------------------------------------
* type | Type of activity
* -------------------------|---------------------------------------------------
* stat | Activity status
* -------------------------|---------------------------------------------------
* @endverbatim
*
*@verbatim
* type | Activities
*----------|---------------------
* 0 | UNKNOWN
* 1 | STILL
* 2 | WALK
* 3 | RUN
* 4 | BIKE
* 5 | VEHICLE
* 6 | TILTED
*@endverbatim
*
*
*@verbatim
* stat | Activity status
*----------|---------------------
* 1 | START
* 2 | END
*@endverbatim
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bmi270_context_get_act_recog_output(struct bmi2_act_recog_output *act_recog,
uint16_t *act_frm_len,
struct bmi2_fifo_frame *fifo,
const struct bmi2_dev *dev);
/*!
* \ingroup bmi270_contextApiInt
* \page bmi270_context_api_bmi270_context_map_feat_int bmi270_context_map_feat_int
* \code
* int8_t bmi270_context_map_feat_int(const struct bmi2_sens_int_config *sens_int, uint8_t n_sens, struct bmi2_dev *dev)
* \endcode
* @details This API maps/unmaps feature interrupts to that of interrupt pins.
*
* @param[in] sens_int : Structure instance of bmi2_sens_int_config.
* @param[in] n_sens : Number of interrupts to be mapped.
* @param[in] dev : Structure instance of bmi2_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bmi270_context_map_feat_int(const struct bmi2_sens_int_config *sens_int, uint8_t n_sens, struct bmi2_dev *dev);
/******************************************************************************/
/*! @name C++ Guard Macros */
/******************************************************************************/
#ifdef __cplusplus
}
#endif /* End of CPP guard */
#endif /* BMI270_CONTEXT_H_ */
Source diff could not be displayed: it is too large. Options to address this: view the blob.
/**
* Copyright (c) 2023 Bosch Sensortec GmbH. All rights reserved.
*
* BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @file bmi270_legacy.h
* @date 2023-05-03
* @version v2.86.1
*
*/
/* BMI270_legacy offers same low-power features as in BMI160 */
/**
* \ingroup bmi2xy
* \defgroup bmi270_legacy BMI270_LEGACY
* @brief Sensor driver for BMI270_LEGACY sensor
*/
#ifndef BMI270_LEGACY_H_
#define BMI270_LEGACY_H_
/*! CPP guard */
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************************/
/*! Header files
****************************************************************************/
#include "bmi2.h"
/***************************************************************************/
/*! Macro definitions
****************************************************************************/
/*! @name BMI270_LEGACY chip identifier */
#define BMI270_LEGACY_CHIP_ID UINT8_C(0x24)
/*! @name BMI270_LEGACY feature input start addresses */
#define BMI270_LEGACY_CONFIG_ID_STRT_ADDR UINT8_C(0x00)
#define BMI270_LEGACY_MAX_BURST_LEN_STRT_ADDR UINT8_C(0x02)
#define BMI270_LEGACY_CRT_GYRO_SELF_TEST_STRT_ADDR UINT8_C(0x03)
#define BMI270_LEGACY_ABORT_STRT_ADDR UINT8_C(0x03)
#define BMI270_LEGACY_AXIS_MAP_STRT_ADDR UINT8_C(0x04)
#define BMI270_LEGACY_GYRO_SELF_OFF_STRT_ADDR UINT8_C(0x05)
#define BMI270_LEGACY_NVM_PROG_PREP_STRT_ADDR UINT8_C(0x05)
#define BMI270_LEGACY_ANY_MOT_STRT_ADDR UINT8_C(0x06)
#define BMI270_LEGACY_NO_MOT_STRT_ADDR UINT8_C(0x0A)
#define BMI270_LEGACY_ORIENT_STRT_ADDR UINT8_C(0x00)
#define BMI270_LEGACY_HIGH_G_STRT_ADDR UINT8_C(0x04)
#define BMI270_LEGACY_LOW_G_STRT_ADDR UINT8_C(0x0A)
#define BMI270_LEGACY_FLAT_STRT_ADDR UINT8_C(0x00)
#define BMI270_LEGACY_SIG_MOT_STRT_ADDR UINT8_C(0x04)
#define BMI270_LEGACY_STEP_COUNT_STRT_ADDR UINT8_C(0x00)
#define BMI270_LEGACY_GYRO_USERGAIN_UPDATE_STRT_ADDR UINT8_C(0x04)
#define BMI270_LEGACY_TAP_DETECT_1_STRT_ADDR UINT8_C(0x00)
#define BMI270_LEGACY_TAP_DETECT_2_STRT_ADDR UINT8_C(0x00)
/*! @name BMI270_LEGACY feature output start addresses */
#define BMI270_LEGACY_STEP_CNT_OUT_STRT_ADDR UINT8_C(0x00)
#define BMI270_LEGACY_STEP_ACT_OUT_STRT_ADDR UINT8_C(0x04)
#define BMI270_LEGACY_ORIENT_HIGH_G_OUT_STRT_ADDR UINT8_C(0x06)
#define BMI270_LEGACY_GYR_USER_GAIN_OUT_STRT_ADDR UINT8_C(0x08)
#define BMI270_LEGACY_GYRO_CROSS_SENSE_STRT_ADDR UINT8_C(0x0C)
#define BMI270_LEGACY_NVM_VFRM_OUT_STRT_ADDR UINT8_C(0x0E)
/*! @name Defines maximum number of pages */
#define BMI270_LEGACY_MAX_PAGE_NUM UINT8_C(8)
/*! @name Defines maximum number of feature input configurations */
#define BMI270_LEGACY_MAX_FEAT_IN UINT8_C(23)
/*! @name Defines maximum number of feature outputs */
#define BMI270_LEGACY_MAX_FEAT_OUT UINT8_C(8)
/*! @name Mask definitions for feature interrupt status bits */
#define BMI270_LEGACY_SIG_MOT_STATUS_MASK UINT8_C(0x01)
#define BMI270_LEGACY_STEP_CNT_STATUS_MASK UINT8_C(0x02)
#define BMI270_LEGACY_HIGH_G_STATUS_MASK UINT8_C(0x04)
#define BMI270_LEGACY_LOW_G_STATUS_MASK UINT8_C(0x04)
#define BMI270_LEGACY_TAP_STATUS_MASK UINT8_C(0x08)
#define BMI270_LEGACY_FLAT_STATUS_MASK UINT8_C(0x10)
#define BMI270_LEGACY_NO_MOT_STATUS_MASK UINT8_C(0x20)
#define BMI270_LEGACY_ANY_MOT_STATUS_MASK UINT8_C(0x40)
#define BMI270_LEGACY_ORIENT_STATUS_MASK UINT8_C(0x80)
#define BMI270_LEGACY_SINGLE_TAP_MASK UINT8_C(0x20)
#define BMI270_LEGACY_DOUBLE_TAP_MASK UINT8_C(0x40)
#define BMI270_LEGACY_TRIPLE_TAP_MASK UINT8_C(0x80)
/*! @name Status register for tap */
#define BMI270_LEGACY_TAP_STATUS_REG UINT8_C(0x20)
/*! @name Macros for high-g interrupt axis/sign */
#define BMI270_LEGACY_HIGH_G_DETECT_X UINT8_C(0x08)
#define BMI270_LEGACY_HIGH_G_DETECT_Y UINT8_C(0x10)
#define BMI270_LEGACY_HIGH_G_DETECT_Z UINT8_C(0x20)
#define BMI270_LEGACY_HIGH_G_DETECT_SIGN UINT8_C(0x40)
/*! @name Mask definitions for feature interrupt mapping bits */
#define BMI270_LEGACY_INT_SIG_MOT_MASK UINT8_C(0x01)
#define BMI270_LEGACY_INT_STEP_COUNTER_MASK UINT8_C(0x02)
#define BMI270_LEGACY_INT_STEP_DETECTOR_MASK UINT8_C(0x02)
#define BMI270_LEGACY_INT_STEP_ACTIVITY_MASK UINT8_C(0x02)
#define BMI270_LEGACY_INT_HIGH_G_MASK UINT8_C(0x04)
#define BMI270_LEGACY_INT_LOW_G_MASK UINT8_C(0x04)
#define BMI270_LEGACY_INT_TAP_MASK UINT8_C(0x08)
#define BMI270_LEGACY_INT_FLAT_MASK UINT8_C(0x10)
#define BMI270_LEGACY_INT_NO_MOT_MASK UINT8_C(0x20)
#define BMI270_LEGACY_INT_ANY_MOT_MASK UINT8_C(0x40)
#define BMI270_LEGACY_INT_ORIENT_MASK UINT8_C(0x80)
#define BMI270_LEGACY_INT_SINGLE_TAP_MASK UINT8_C(0x20)
#define BMI270_LEGACY_INT_DOUBLE_TAP_MASK UINT8_C(0x40)
#define BMI270_LEGACY_INT_TRIPLE_TAP_MASK UINT8_C(0x80)
/*! @name Defines maximum number of feature interrupts */
#define BMI270_LEGACY_MAX_INT_MAP UINT8_C(14)
/***************************************************************************/
/*! BMI270_LEGACY User Interface function prototypes
****************************************************************************/
/**
* \ingroup bmi270_legacy
* \defgroup bmi270_legacyApiInit Initialization
* @brief Initialize the sensor and device structure
*/
/*!
* \ingroup bmi270_legacyApiInit
* \page bmi270_legacy_api_bmi270_legacy_init bmi270_legacy_init
* \code
* int8_t bmi270_legacy_init(struct bmi2_dev *dev);
* \endcode
* @details This API:
* 1) updates the device structure with address of the configuration file.
* 2) Initializes BMI270_LEGACY sensor.
* 3) Writes the configuration file.
* 4) Updates the feature offset parameters in the device structure.
* 5) Updates the maximum number of pages, in the device structure.
*
* @param[in, out] dev : Structure instance of bmi2_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bmi270_legacy_init(struct bmi2_dev *dev);
/**
* \ingroup bmi270_legacy
* \defgroup bmi270_legacyApiSensor Feature Set
* @brief Enable / Disable features of the sensor
*/
/*!
* \ingroup bmi270_legacyApiSensor
* \page bmi270_legacy_api_bmi270_legacy_sensor_enable bmi270_legacy_sensor_enable
* \code
* int8_t bmi270_legacy_sensor_enable(const uint8_t *sens_list, uint8_t n_sens, struct bmi2_dev *dev);
* \endcode
* @details This API selects the sensors/features to be enabled.
*
* @param[in] sens_list : Pointer to select the sensor/feature.
* @param[in] n_sens : Number of sensors selected.
* @param[in, out] dev : Structure instance of bmi2_dev.
*
* @note Sensors/features that can be enabled.
*
*@verbatim
* sens_list | Values
* ----------------------------|-----------
* BMI2_ACCEL | 0
* BMI2_GYRO | 1
* BMI2_AUX | 2
* BMI2_SIG_MOTION | 3
* BMI2_ANY_MOTION | 4
* BMI2_NO_MOTION | 5
* BMI2_STEP_DETECTOR | 6
* BMI2_STEP_COUNTER | 7
* BMI2_STEP_ACTIVITY | 8
* BMI2_GYRO_GAIN_UPDATE | 9
* BMI2_ORIENTATION | 14
* BMI2_HIGH_G | 15
* BMI2_LOW_G | 16
* BMI2_FLAT | 17
* BMI2_SINGLE_TAP | 25
* BMI2_DOUBLE_TAP | 26
* BMI2_TRIPLE_TAP | 27
* BMI2_TEMP | 31
*@endverbatim
*
* @note :
* example uint8_t sens_list[2] = {BMI2_ACCEL, BMI2_GYRO};
* uint8_t n_sens = 2;
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bmi270_legacy_sensor_enable(const uint8_t *sens_list, uint8_t n_sens, struct bmi2_dev *dev);
/*!
* \ingroup bmi270_legacyApiSensor
* \page bmi270_legacy_api_bmi270_legacy_sensor_disable bmi270_legacy_sensor_disable
* \code
* int8_t bmi270_legacy_sensor_disable(const uint8_t *sens_list, uint8_t n_sens, struct bmi2_dev *dev);
* \endcode
* @details This API selects the sensors/features to be disabled.
*
* @param[in] sens_list : Pointer to select the sensor/feature.
* @param[in] n_sens : Number of sensors selected.
* @param[in, out] dev : Structure instance of bmi2_dev.
*
* @note Sensors/features that can be disabled.
*
*@verbatim
* sens_list | Values
* ----------------------------|-----------
* BMI2_ACCEL | 0
* BMI2_GYRO | 1
* BMI2_AUX | 2
* BMI2_SIG_MOTION | 3
* BMI2_ANY_MOTION | 4
* BMI2_NO_MOTION | 5
* BMI2_STEP_DETECTOR | 6
* BMI2_STEP_COUNTER | 7
* BMI2_STEP_ACTIVITY | 8
* BMI2_GYRO_GAIN_UPDATE | 9
* BMI2_ORIENTATION | 14
* BMI2_HIGH_G | 15
* BMI2_LOW_G | 16
* BMI2_FLAT | 17
* BMI2_SINGLE_TAP | 25
* BMI2_DOUBLE_TAP | 26
* BMI2_TRIPLE_TAP | 27
* BMI2_TEMP | 31
*@endverbatim
*
* @note :
* example uint8_t sens_list[2] = {BMI2_ACCEL, BMI2_GYRO};
* uint8_t n_sens = 2;
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bmi270_legacy_sensor_disable(const uint8_t *sens_list, uint8_t n_sens, struct bmi2_dev *dev);
/**
* \ingroup bmi270_legacy
* \defgroup bmi270_legacyApiSensorC Sensor Configuration
* @brief Enable / Disable feature configuration of the sensor
*/
/*!
* \ingroup bmi270_legacyApiSensorC
* \page bmi270_legacy_api_bmi270_legacy_set_sensor_config bmi270_legacy_set_sensor_config
* \code
* int8_t bmi270_legacy_set_sensor_config(struct bmi2_sens_config *sens_cfg, uint8_t n_sens, struct bmi2_dev *dev);
* \endcode
* @details This API sets the sensor/feature configuration.
*
* @param[in] sens_cfg : Structure instance of bmi2_sens_config.
* @param[in] n_sens : Number of sensors selected.
* @param[in, out] dev : Structure instance of bmi2_dev.
*
* @note Sensors/features that can be configured
*
*@verbatim
* sens_list | Values
* ----------------------------|-----------
* BMI2_SIG_MOTION | 3
* BMI2_ANY_MOTION | 4
* BMI2_NO_MOTION | 5
* BMI2_STEP_DETECTOR | 6
* BMI2_STEP_COUNTER | 7
* BMI2_STEP_ACTIVITY | 8
* BMI2_ORIENTATION | 14
* BMI2_HIGH_G | 15
* BMI2_LOW_G | 16
* BMI2_FLAT | 17
* BMI2_TAP | 28
*@endverbatim
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bmi270_legacy_set_sensor_config(struct bmi2_sens_config *sens_cfg, uint8_t n_sens, struct bmi2_dev *dev);
/*!
* \ingroup bmi270_legacyApiSensorC
* \page bmi270_legacy_api_bmi270_legacy_get_sensor_config bmi270_legacy_get_sensor_config
* \code
* int8_t bmi270_legacy_get_sensor_config(struct bmi2_sens_config *sens_cfg, uint8_t n_sens, struct bmi2_dev *dev);
* \endcode
* @details This API gets the sensor/feature configuration.
*
* @param[in] sens_cfg : Structure instance of bmi2_sens_config.
* @param[in] n_sens : Number of sensors selected.
* @param[in, out] dev : Structure instance of bmi2_dev.
*
* @note Sensors/features whose configurations can be read.
*
*@verbatim
* sens_list | Values
* ----------------------------|-----------
* BMI2_SIG_MOTION | 3
* BMI2_ANY_MOTION | 4
* BMI2_NO_MOTION | 5
* BMI2_STEP_DETECTOR | 6
* BMI2_STEP_COUNTER | 7
* BMI2_STEP_ACTIVITY | 8
* BMI2_ORIENTATION | 14
* BMI2_HIGH_G | 15
* BMI2_LOW_G | 16
* BMI2_FLAT | 17
* BMI2_TAP | 28
*@endverbatim
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bmi270_legacy_get_sensor_config(struct bmi2_sens_config *sens_cfg, uint8_t n_sens, struct bmi2_dev *dev);
/**
* \ingroup bmi270_legacy
* \defgroup bmi270_legacyApiSensorD Feature Sensor Data
* @brief Get feature sensor data
*/
/*!
* \ingroup bmi270_legacyApiSensorD
* \page bmi270_legacy_api_bmi270_legacy_get_feature_data bmi270_legacy_get_feature_data
* \code
* int8_t bmi270_legacy_get_feature_data(struct bmi2_feat_sensor_data *feature_data, uint8_t n_sens, struct bmi2_dev *dev);
* \endcode
* @details This API gets the feature data.
*
* @param[out] feature_data : Structure instance of bmi2_feat_sensor_data.
* @param[in] n_sens : Number of sensors selected.
* @param[in] dev : Structure instance of bmi2_dev.
*
* @note Sensors/features whose data can be read
*
*@verbatim
* sens_list | Values
* ---------------------|-----------
* BMI2_STEP_COUNTER | 7
* BMI2_STEP_ACTIVITY | 8
* BMI2_ORIENTATION | 14
* BMI2_HIGH_G | 15
* BMI2_NVM_STATUS | 38
* BMI2_VFRM_STATUS | 39
*@endverbatim
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bmi270_legacy_get_feature_data(struct bmi2_feat_sensor_data *feature_data, uint8_t n_sens, struct bmi2_dev *dev);
/**
* \ingroup bmi270_legacy
* \defgroup bmi270_legacyApiGyroUG Gyro User Gain
* @brief Set / Get Gyro User Gain of the sensor
*/
/*!
* \ingroup bmi270_legacyApiGyroUG
* \page bmi270_legacy_api_bmi270_legacy_update_gyro_user_gain bmi270_legacy_update_gyro_user_gain
* \code
* int8_t bmi270_legacy_update_gyro_user_gain(const struct bmi2_gyro_user_gain_config *user_gain, struct bmi2_dev *dev);
* \endcode
* @details This API updates the gyroscope user-gain.
*
* @param[in] user_gain : Structure that stores user-gain configurations.
* @param[in] dev : Structure instance of bmi2_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bmi270_legacy_update_gyro_user_gain(const struct bmi2_gyro_user_gain_config *user_gain, struct bmi2_dev *dev);
/*!
* \ingroup bmi270_legacyApiGyroUG
* \page bmi270_legacy_api_bmi270_legacy_read_gyro_user_gain bmi270_legacy_read_gyro_user_gain
* \code
* int8_t bmi270_legacy_read_gyro_user_gain(struct bmi2_gyro_user_gain_data *gyr_usr_gain, const struct bmi2_dev *dev);
* \endcode
* @details This API reads the compensated gyroscope user-gain values.
*
* @param[out] gyr_usr_gain : Structure that stores gain values.
* @param[in] dev : Structure instance of bmi2_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bmi270_legacy_read_gyro_user_gain(struct bmi2_gyro_user_gain_data *gyr_usr_gain, struct bmi2_dev *dev);
/*!
* \ingroup bmi270_legacyApiInt
* \page bmi270_legacy_api_bmi270_legacy_map_feat_int bmi270_legacy_map_feat_int
* \code
* int8_t bmi270_legacy_map_feat_int(const struct bmi2_sens_int_config *sens_int, uint8_t n_sens, struct bmi2_dev *dev)
* \endcode
* @details This API maps/unmaps feature interrupts to that of interrupt pins.
*
* @param[in] sens_int : Structure instance of bmi2_sens_int_config.
* @param[in] n_sens : Number of interrupts to be mapped.
* @param[in] dev : Structure instance of bmi2_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bmi270_legacy_map_feat_int(const struct bmi2_sens_int_config *sens_int, uint8_t n_sens, struct bmi2_dev *dev);
/******************************************************************************/
/*! @name C++ Guard Macros */
/******************************************************************************/
#ifdef __cplusplus
}
#endif /* End of CPP guard */
#endif /* _BMI270_LEGACY_H_ */
/**
* Copyright (c) 2023 Bosch Sensortec GmbH. All rights reserved.
*
* BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @file bmi270_maximum_fifo.c
* @date 2023-05-03
* @version v2.86.1
*
*/
/***************************************************************************/
/*! Header files
****************************************************************************/
#include "bmi270_maximum_fifo.h"
/***************************************************************************/
/*! Global Variable
****************************************************************************/
/*! @name Global array that stores the configuration file of BMI270 */
const uint8_t bmi270_maximum_fifo_config_file[] = {
0xc8, 0x2e, 0x00, 0x2e, 0x80, 0x2e, 0x1a, 0x00, 0xc8, 0x2e, 0x00, 0x2e, 0xc8, 0x2e, 0x00, 0x2e, 0xc8, 0x2e, 0x00,
0x2e, 0xc8, 0x2e, 0x00, 0x2e, 0xc8, 0x2e, 0x00, 0x2e, 0xc8, 0x2e, 0x00, 0x2e, 0x90, 0x32, 0x21, 0x2e, 0x59, 0xf5,
0x10, 0x30, 0x21, 0x2e, 0x6a, 0xf5, 0x1a, 0x24, 0x22, 0x00, 0x80, 0x2e, 0x3b, 0x00, 0xc8, 0x2e, 0x44, 0x47, 0x22,
0x00, 0x37, 0x00, 0xa4, 0x00, 0xff, 0x0f, 0xd1, 0x00, 0x07, 0xad, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1,
0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00,
0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x11, 0x24, 0xfc, 0xf5, 0x80, 0x30, 0x40, 0x42, 0x50, 0x50, 0x00, 0x30, 0x12, 0x24, 0xeb,
0x00, 0x03, 0x30, 0x00, 0x2e, 0xc1, 0x86, 0x5a, 0x0e, 0xfb, 0x2f, 0x21, 0x2e, 0xfc, 0xf5, 0x13, 0x24, 0x63, 0xf5,
0xe0, 0x3c, 0x48, 0x00, 0x22, 0x30, 0xf7, 0x80, 0xc2, 0x42, 0xe1, 0x7f, 0x3a, 0x25, 0xfc, 0x86, 0xf0, 0x7f, 0x41,
0x33, 0x98, 0x2e, 0xc2, 0xc4, 0xd6, 0x6f, 0xf1, 0x30, 0xf1, 0x08, 0xc4, 0x6f, 0x11, 0x24, 0xff, 0x03, 0x12, 0x24,
0x00, 0xfc, 0x61, 0x09, 0xa2, 0x08, 0x36, 0xbe, 0x2a, 0xb9, 0x13, 0x24, 0x38, 0x00, 0x64, 0xbb, 0xd1, 0xbe, 0x94,
0x0a, 0x71, 0x08, 0xd5, 0x42, 0x21, 0xbd, 0x91, 0xbc, 0xd2, 0x42, 0xc1, 0x42, 0x00, 0xb2, 0xfe, 0x82, 0x05, 0x2f,
0x50, 0x30, 0x21, 0x2e, 0x21, 0xf2, 0x00, 0x2e, 0x00, 0x2e, 0xd0, 0x2e, 0xf0, 0x6f, 0x02, 0x30, 0x02, 0x42, 0x20,
0x26, 0xe0, 0x6f, 0x02, 0x31, 0x03, 0x40, 0x9a, 0x0a, 0x02, 0x42, 0xf0, 0x37, 0x05, 0x2e, 0x5e, 0xf7, 0x10, 0x08,
0x12, 0x24, 0x1e, 0xf2, 0x80, 0x42, 0x83, 0x84, 0xf1, 0x7f, 0x0a, 0x25, 0x13, 0x30, 0x83, 0x42, 0x3b, 0x82, 0xf0,
0x6f, 0x00, 0x2e, 0x00, 0x2e, 0xd0, 0x2e, 0x12, 0x40, 0x52, 0x42, 0x00, 0x2e, 0x12, 0x40, 0x52, 0x42, 0x3e, 0x84,
0x00, 0x40, 0x40, 0x42, 0x7e, 0x82, 0xe1, 0x7f, 0xf2, 0x7f, 0x98, 0x2e, 0x6a, 0xd6, 0x21, 0x30, 0x23, 0x2e, 0x61,
0xf5, 0xeb, 0x2c, 0xe1, 0x6f
};
/*! @name Global array that stores the feature input configuration of BMI270 */
const struct bmi2_feature_config bmi270_maximum_fifo_feat_in[BMI270_MAXIMUM_FIFO_MAX_FEAT_IN] = {
};
/*! @name Global array that stores the feature output configuration */
const struct bmi2_feature_config bmi270_maximum_fifo_feat_out[BMI270_MAXIMUM_FIFO_MAX_FEAT_OUT] = {
};
/******************************************************************************/
/*! Local Function Prototypes
******************************************************************************/
/*!
* @brief This internal API is used to validate the device pointer for
* null conditions.
*
* @param[in] dev : Structure instance of bmi2_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
static int8_t null_ptr_check(const struct bmi2_dev *dev);
/***************************************************************************/
/*! User Interface Definitions
****************************************************************************/
/*!
* @brief This API:
* 1) updates the device structure with address of the configuration file.
* 2) Initializes BMI270 sensor.
* 3) Writes the configuration file.
* 4) Updates the feature offset parameters in the device structure.
* 5) Updates the maximum number of pages, in the device structure.
*/
int8_t bmi270_maximum_fifo_init(struct bmi2_dev *dev)
{
/* Variable to define result */
int8_t rslt;
/* Null-pointer check */
rslt = null_ptr_check(dev);
if (rslt == BMI2_OK)
{
/* Assign chip id of BMI270 */
dev->chip_id = BMI270_MAXIMUM_FIFO_CHIP_ID;
dev->config_size = sizeof(bmi270_maximum_fifo_config_file);
/* Enable the variant specific features if any */
dev->variant_feature = BMI2_GYRO_CROSS_SENS_ENABLE | BMI2_MAXIMUM_FIFO_VARIANT;
/* An extra dummy byte is read during SPI read */
if (dev->intf == BMI2_SPI_INTF)
{
dev->dummy_byte = 1;
}
else
{
dev->dummy_byte = 0;
}
/* If configuration file pointer is not assigned any address */
if (!dev->config_file_ptr)
{
/* Give the address of the configuration file array to
* the device pointer
*/
dev->config_file_ptr = bmi270_maximum_fifo_config_file;
}
/* Initialize BMI2 sensor */
rslt = bmi2_sec_init(dev);
if (rslt == BMI2_OK)
{
/* Assign the offsets of the feature input
* configuration to the device structure
*/
dev->feat_config = bmi270_maximum_fifo_feat_in;
/* Assign the offsets of the feature output to
* the device structure
*/
dev->feat_output = bmi270_maximum_fifo_feat_out;
/* Assign the maximum number of pages to the
* device structure
*/
dev->page_max = BMI270_MAXIMUM_FIFO_MAX_PAGE_NUM;
/* Assign maximum number of input sensors/
* features to device structure
*/
dev->input_sens = BMI270_MAXIMUM_FIFO_MAX_FEAT_IN;
/* Assign maximum number of output sensors/
* features to device structure
*/
dev->out_sens = BMI270_MAXIMUM_FIFO_MAX_FEAT_OUT;
/* Get the gyroscope cross axis sensitivity */
rslt = bmi2_get_gyro_cross_sense(dev);
}
}
return rslt;
}
/***************************************************************************/
/*! Local Function Definitions
****************************************************************************/
/*!
* @brief This internal API is used to validate the device structure pointer for
* null conditions.
*/
static int8_t null_ptr_check(const struct bmi2_dev *dev)
{
/* Variable to define result */
int8_t rslt = BMI2_OK;
if ((dev == NULL) || (dev->read == NULL) || (dev->write == NULL) || (dev->delay_us == NULL))
{
/* Device structure pointer is not valid */
rslt = BMI2_E_NULL_PTR;
}
return rslt;
}
/**
* Copyright (c) 2023 Bosch Sensortec GmbH. All rights reserved.
*
* BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @file bmi270_maximum_fifo.h
* @date 2023-05-03
* @version v2.86.1
*
*/
/**
* \ingroup bmi2xy
* \defgroup bmi270_maximum_fifo BMI270_MAXIMUM_FIFO
* @brief Sensor driver for BMI270_MAXIMUM_FIFO sensor
*/
#ifndef BMI270_MAXIMUM_FIFO_H_
#define BMI270_MAXIMUM_FIFO_H_
/*! CPP guard */
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************************/
/*! Header files
****************************************************************************/
#include "bmi2.h"
/***************************************************************************/
/*! Macro definitions
****************************************************************************/
/*! @name BMI270 Chip identifier */
#define BMI270_MAXIMUM_FIFO_CHIP_ID UINT8_C(0x24)
/*! @name Defines maximum number of pages */
#define BMI270_MAXIMUM_FIFO_MAX_PAGE_NUM UINT8_C(0)
/*! @name Defines maximum number of feature input configurations */
#define BMI270_MAXIMUM_FIFO_MAX_FEAT_IN UINT8_C(0)
/*! @name Defines maximum number of feature outputs */
#define BMI270_MAXIMUM_FIFO_MAX_FEAT_OUT UINT8_C(0)
/*! @name Mask definitions for feature interrupt status bits */
/***************************************************************************/
/*! BMI270 User Interface function prototypes
****************************************************************************/
/**
* \ingroup bmi270_maximum_fifo
* \defgroup bmi270_maximum_fifoApiInit Initialization
* @brief Initialize the sensor and device structure
*/
/*!
* \ingroup bmi270_maximum_fifoApiInit
* \page bmi270_maximum_fifo_api_bmi270_maximum_fifo_init bmi270_maximum_fifo_init
* \code
* int8_t bmi270_maximum_fifo_init(struct bmi2_dev *dev);
* \endcode
* @details This API:
* 1) updates the device structure with address of the configuration file.
* 2) Initializes BMI270 sensor.
* 3) Writes the configuration file.
* 4) Updates the feature offset parameters in the device structure.
* 5) Updates the maximum number of pages, in the device structure.
*
* @param[in, out] dev : Structure instance of bmi2_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bmi270_maximum_fifo_init(struct bmi2_dev *dev);
/******************************************************************************/
/*! @name C++ Guard Macros */
/******************************************************************************/
#ifdef __cplusplus
}
#endif /* End of CPP guard */
#endif /* BMI270_MAXIMUM_FIFO_H_ */
/**
* Copyright (c) 2023 Bosch Sensortec GmbH. All rights reserved.
*
* BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @file bmi2_defs.h
* @date 2023-05-03
* @version v2.86.1
*
*/
#ifndef BMI2_DEFS_H_
#define BMI2_DEFS_H_
/******************************************************************************/
/*! @name Header includes */
/******************************************************************************/
#ifdef __KERNEL__
#include <linux/types.h>
#include <linux/kernel.h>
#else
#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
#endif
/******************************************************************************/
/*! @name Common macros */
/******************************************************************************/
#ifdef __KERNEL__
#if !defined(UINT8_C) && !defined(INT8_C)
#define INT8_C(x) S8_C(x)
#define UINT8_C(x) U8_C(x)
#endif
#if !defined(UINT16_C) && !defined(INT16_C)
#define INT16_C(x) S16_C(x)
#define UINT16_C(x) U16_C(x)
#endif
#if !defined(INT32_C) && !defined(UINT32_C)
#define INT32_C(x) S32_C(x)
#define UINT32_C(x) U32_C(x)
#endif
#if !defined(INT64_C) && !defined(UINT64_C)
#define INT64_C(x) S64_C(x)
#define UINT64_C(x) U64_C(x)
#endif
#endif
/*! @name C standard macros */
#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *) 0)
#endif
#endif
/******************************************************************************/
/*! @name General Macro Definitions */
/******************************************************************************/
/*! @name Utility macros */
#define BMI2_SET_BITS(reg_data, bitname, data) \
((reg_data & ~(bitname##_MASK)) | \
((data << bitname##_POS) & bitname##_MASK))
#define BMI2_GET_BITS(reg_data, bitname) \
((reg_data & (bitname##_MASK)) >> \
(bitname##_POS))
#define BMI2_SET_BIT_POS0(reg_data, bitname, data) \
((reg_data & ~(bitname##_MASK)) | \
(data & bitname##_MASK))
#define BMI2_GET_BIT_POS0(reg_data, bitname) (reg_data & (bitname##_MASK))
#define BMI2_SET_BIT_VAL0(reg_data, bitname) (reg_data & ~(bitname##_MASK))
/*! @name For getting LSB and MSB */
#define BMI2_GET_LSB(var) (uint8_t)(var & BMI2_SET_LOW_BYTE)
#define BMI2_GET_MSB(var) (uint8_t)((var & BMI2_SET_HIGH_BYTE) >> 8)
#ifndef BMI2_INTF_RETURN_TYPE
#define BMI2_INTF_RETURN_TYPE int8_t
#endif
/*! @name For defining absolute values */
#define BMI2_ABS(a) ((a) > 0 ? (a) : -(a))
#define BMI2_MAX_BUFFER_SIZE UINT8_C(128)
/*! @name LSB and MSB mask definitions */
#define BMI2_SET_LOW_BYTE UINT16_C(0x00FF)
#define BMI2_SET_HIGH_BYTE UINT16_C(0xFF00)
#define BMI2_SET_LOW_NIBBLE UINT8_C(0x0F)
/*! @name For enable and disable */
#define BMI2_ENABLE UINT8_C(1)
#define BMI2_DISABLE UINT8_C(0)
/*! @name To define TRUE or FALSE */
#define BMI2_TRUE UINT8_C(1)
#define BMI2_FALSE UINT8_C(0)
/*! @name Macro to define maximum length of read */
#define BMI2_MAX_LEN UINT8_C(128)
/*! @name To define sensor interface success code */
#define BMI2_INTF_RET_SUCCESS INT8_C(0)
/*! @name To define success code */
#define BMI2_OK INT8_C(0)
/* @name To define delay */
#define BMI2_POWER_SAVE_MODE_DELAY_IN_US UINT16_C(450)
#define BMI2_NORMAL_MODE_DELAY_IN_US UINT8_C(2)
/*! @name To define error codes */
#define BMI2_E_NULL_PTR INT8_C(-1)
#define BMI2_E_COM_FAIL INT8_C(-2)
#define BMI2_E_DEV_NOT_FOUND INT8_C(-3)
#define BMI2_E_OUT_OF_RANGE INT8_C(-4)
#define BMI2_E_ACC_INVALID_CFG INT8_C(-5)
#define BMI2_E_GYRO_INVALID_CFG INT8_C(-6)
#define BMI2_E_ACC_GYR_INVALID_CFG INT8_C(-7)
#define BMI2_E_INVALID_SENSOR INT8_C(-8)
#define BMI2_E_CONFIG_LOAD INT8_C(-9)
#define BMI2_E_INVALID_PAGE INT8_C(-10)
#define BMI2_E_INVALID_FEAT_BIT INT8_C(-11)
#define BMI2_E_INVALID_INT_PIN INT8_C(-12)
#define BMI2_E_SET_APS_FAIL INT8_C(-13)
#define BMI2_E_AUX_INVALID_CFG INT8_C(-14)
#define BMI2_E_AUX_BUSY INT8_C(-15)
#define BMI2_E_SELF_TEST_FAIL INT8_C(-16)
#define BMI2_E_REMAP_ERROR INT8_C(-17)
#define BMI2_E_GYR_USER_GAIN_UPD_FAIL INT8_C(-18)
#define BMI2_E_SELF_TEST_NOT_DONE INT8_C(-19)
#define BMI2_E_INVALID_INPUT INT8_C(-20)
#define BMI2_E_INVALID_STATUS INT8_C(-21)
#define BMI2_E_CRT_ERROR INT8_C(-22)
#define BMI2_E_ST_ALREADY_RUNNING INT8_C(-23)
#define BMI2_E_CRT_READY_FOR_DL_FAIL_ABORT INT8_C(-24)
#define BMI2_E_DL_ERROR INT8_C(-25)
#define BMI2_E_PRECON_ERROR INT8_C(-26)
#define BMI2_E_ABORT_ERROR INT8_C(-27)
#define BMI2_E_GYRO_SELF_TEST_ERROR INT8_C(-28)
#define BMI2_E_GYRO_SELF_TEST_TIMEOUT INT8_C(-29)
#define BMI2_E_WRITE_CYCLE_ONGOING INT8_C(-30)
#define BMI2_E_WRITE_CYCLE_TIMEOUT INT8_C(-31)
#define BMI2_E_ST_NOT_RUNING INT8_C(-32)
#define BMI2_E_DATA_RDY_INT_FAILED INT8_C(-33)
#define BMI2_E_INVALID_FOC_POSITION INT8_C(-34)
/*! @name To define warnings for FIFO activity */
#define BMI2_W_FIFO_EMPTY INT8_C(1)
#define BMI2_W_PARTIAL_READ INT8_C(2)
#define BMI2_W_DUMMY_BYTE INT8_C(3)
/*! @name Macros to define dummy frame header FIFO headerless mode */
#define BMI2_FIFO_HEADERLESS_DUMMY_ACC UINT8_C(0x01)
#define BMI2_FIFO_HEADERLESS_DUMMY_GYR UINT8_C(0x02)
#define BMI2_FIFO_HEADERLESS_DUMMY_AUX UINT8_C(0x03)
#define BMI2_FIFO_HEADERLESS_DUMMY_BYTE_1 UINT8_C(0x7F)
#define BMI2_FIFO_HEADERLESS_DUMMY_BYTE_2 UINT8_C(0x00)
#define BMI2_FIFO_HEADERLESS_DUMMY_BYTE_3 UINT8_C(0x80)
/*! @name Bit wise to define information */
#define BMI2_I_MIN_VALUE UINT8_C(1)
#define BMI2_I_MAX_VALUE UINT8_C(2)
/*! @name BMI2 register addresses */
#define BMI2_CHIP_ID_ADDR UINT8_C(0x00)
#define BMI2_STATUS_ADDR UINT8_C(0x03)
#define BMI2_AUX_X_LSB_ADDR UINT8_C(0x04)
#define BMI2_ACC_X_LSB_ADDR UINT8_C(0x0C)
#define BMI2_GYR_X_LSB_ADDR UINT8_C(0x12)
#define BMI2_SENSORTIME_ADDR UINT8_C(0x18)
#define BMI2_EVENT_ADDR UINT8_C(0x1B)
#define BMI2_INT_STATUS_0_ADDR UINT8_C(0x1C)
#define BMI2_INT_STATUS_1_ADDR UINT8_C(0x1D)
#define BMI2_SC_OUT_0_ADDR UINT8_C(0x1E)
#define BMI2_SYNC_COMMAND_ADDR UINT8_C(0x1E)
#define BMI2_GYR_CAS_GPIO0_ADDR UINT8_C(0x1E)
#define BMI2_INTERNAL_STATUS_ADDR UINT8_C(0x21)
#define BMI2_TEMPERATURE_0_ADDR UINT8_C(0x22)
#define BMI2_TEMPERATURE_1_ADDR UINT8_C(0x23)
#define BMI2_FIFO_LENGTH_0_ADDR UINT8_C(0x24)
#define BMI2_FIFO_DATA_ADDR UINT8_C(0x26)
#define BMI2_FEAT_PAGE_ADDR UINT8_C(0x2F)
#define BMI2_FEATURES_REG_ADDR UINT8_C(0x30)
#define BMI2_ACC_CONF_ADDR UINT8_C(0x40)
#define BMI2_GYR_CONF_ADDR UINT8_C(0x42)
#define BMI2_AUX_CONF_ADDR UINT8_C(0x44)
#define BMI2_FIFO_DOWNS_ADDR UINT8_C(0x45)
#define BMI2_FIFO_WTM_0_ADDR UINT8_C(0x46)
#define BMI2_FIFO_WTM_1_ADDR UINT8_C(0x47)
#define BMI2_FIFO_CONFIG_0_ADDR UINT8_C(0x48)
#define BMI2_FIFO_CONFIG_1_ADDR UINT8_C(0x49)
#define BMI2_SATURATION_ADDR UINT8_C(0x4A)
#define BMI2_AUX_DEV_ID_ADDR UINT8_C(0x4B)
#define BMI2_AUX_IF_CONF_ADDR UINT8_C(0x4C)
#define BMI2_AUX_RD_ADDR UINT8_C(0x4D)
#define BMI2_AUX_WR_ADDR UINT8_C(0x4E)
#define BMI2_AUX_WR_DATA_ADDR UINT8_C(0x4F)
#define BMI2_ERR_REG_MSK_ADDR UINT8_C(0x52)
#define BMI2_INT1_IO_CTRL_ADDR UINT8_C(0x53)
#define BMI2_INT2_IO_CTRL_ADDR UINT8_C(0x54)
#define BMI2_INT_LATCH_ADDR UINT8_C(0x55)
#define BMI2_INT1_MAP_FEAT_ADDR UINT8_C(0x56)
#define BMI2_INT2_MAP_FEAT_ADDR UINT8_C(0x57)
#define BMI2_INT_MAP_DATA_ADDR UINT8_C(0x58)
#define BMI2_INIT_CTRL_ADDR UINT8_C(0x59)
#define BMI2_INIT_ADDR_0 UINT8_C(0x5B)
#define BMI2_INIT_ADDR_1 UINT8_C(0x5C)
#define BMI2_INIT_DATA_ADDR UINT8_C(0x5E)
#define BMI2_INTERNAL_ERR_ADDR UINT8_C(0x5F)
#define BMI2_AUX_IF_TRIM UINT8_C(0x68)
#define BMI2_GYR_CRT_CONF_ADDR UINT8_C(0x69)
#define BMI2_NVM_CONF_ADDR UINT8_C(0x6A)
#define BMI2_IF_CONF_ADDR UINT8_C(0x6B)
#define BMI2_DRV_STR_ADDR UINT8_C(0x6C)
#define BMI2_ACC_SELF_TEST_ADDR UINT8_C(0x6D)
#define BMI2_GYR_SELF_TEST_AXES_ADDR UINT8_C(0x6E)
#define BMI2_SELF_TEST_MEMS_ADDR UINT8_C(0x6F)
#define BMI2_NV_CONF_ADDR UINT8_C(0x70)
#define BMI2_ACC_OFF_COMP_0_ADDR UINT8_C(0x71)
#define BMI2_GYR_OFF_COMP_3_ADDR UINT8_C(0x74)
#define BMI2_GYR_OFF_COMP_6_ADDR UINT8_C(0x77)
#define BMI2_GYR_USR_GAIN_0_ADDR UINT8_C(0x78)
#define BMI2_PWR_CONF_ADDR UINT8_C(0x7C)
#define BMI2_PWR_CTRL_ADDR UINT8_C(0x7D)
#define BMI2_CMD_REG_ADDR UINT8_C(0x7E)
/*! @name BMI2 I2C address */
#define BMI2_I2C_PRIM_ADDR UINT8_C(0x68)
#define BMI2_I2C_SEC_ADDR UINT8_C(0x69)
/*! @name BMI2 Commands */
#define BMI2_G_TRIGGER_CMD UINT8_C(0x02)
#define BMI2_USR_GAIN_CMD UINT8_C(0x03)
#define BMI2_NVM_PROG_CMD UINT8_C(0xA0)
#define BMI2_SOFT_RESET_CMD UINT8_C(0xB6)
#define BMI2_FIFO_FLUSH_CMD UINT8_C(0xB0)
/*! @name BMI2 sensor data bytes */
#define BMI2_AUX_NUM_BYTES UINT8_C(8)
#define BMI2_ACC_NUM_BYTES UINT8_C(6)
#define BMI2_GYR_NUM_BYTES UINT8_C(6)
#define BMI2_STATUS_INDEX UINT8_C(0)
#define BMI2_AUX_START_INDEX UINT8_C(1)
#define BMI2_ACC_START_INDEX UINT8_C(9)
#define BMI2_GYR_START_INDEX UINT8_C(15)
#define BMI2_ACC_GYR_AUX_SENSORTIME_NUM_BYTES UINT8_C(24)
#define BMI2_CRT_CONFIG_FILE_SIZE UINT16_C(2048)
#define BMI2_FEAT_SIZE_IN_BYTES UINT8_C(16)
#define BMI2_ACC_CONFIG_LENGTH UINT8_C(2)
/*! @name BMI2 configuration load status */
#define BMI2_CONFIG_LOAD_SUCCESS UINT8_C(1)
#define BMI2_CONFIG_LOAD_STATUS_MASK UINT8_C(0x0F)
/*! @name To define BMI2 pages */
#define BMI2_PAGE_0 UINT8_C(0)
#define BMI2_PAGE_1 UINT8_C(1)
#define BMI2_PAGE_2 UINT8_C(2)
#define BMI2_PAGE_3 UINT8_C(3)
#define BMI2_PAGE_4 UINT8_C(4)
#define BMI2_PAGE_5 UINT8_C(5)
#define BMI2_PAGE_6 UINT8_C(6)
#define BMI2_PAGE_7 UINT8_C(7)
/*! @name Array Parameter Definitions */
#define BMI2_PARSE_SENSOR_TIME_LSB_BYTE UINT8_C(21)
#define BMI2_PARSE_SENSOR_TIME_XLSB_BYTE UINT8_C(22)
#define BMI2_PARSE_SENSOR_TIME_MSB_BYTE UINT8_C(23)
#define BMI2_SENSOR_TIME_XLSB_BYTE UINT8_C(1)
#define BMI2_SENSOR_TIME_MSB_BYTE UINT8_C(2)
/*! @name Mask definitions for Gyro CRT */
#define BMI2_GYR_RDY_FOR_DL_MASK UINT8_C(0x08)
#define BMI2_GYR_CRT_RUNNING_MASK UINT8_C(0x04)
/*! @name mask definition for status register */
#define BMI2_AUX_BUSY_MASK UINT8_C(0x04)
#define BMI2_CMD_RDY_MASK UINT8_C(0x10)
#define BMI2_DRDY_AUX_MASK UINT8_C(0x20)
#define BMI2_DRDY_GYR_MASK UINT8_C(0x40)
#define BMI2_DRDY_ACC_MASK UINT8_C(0x80)
/*! @name Mask definitions for SPI read/write address */
#define BMI2_SPI_RD_MASK UINT8_C(0x80)
#define BMI2_SPI_WR_MASK UINT8_C(0x7F)
/*! @name Mask definitions for power configuration register */
#define BMI2_ADV_POW_EN_MASK UINT8_C(0x01)
#define BMI2_FUP_EN_POS UINT8_C(0x02)
#define BMI2_FUP_EN_MASK UINT8_C(0x04)
/*! @name Mask definitions for initialization control register */
#define BMI2_CONF_LOAD_EN_MASK UINT8_C(0x01)
/*! @name Mask definitions for power control register */
#define BMI2_AUX_EN_MASK UINT8_C(0x01)
#define BMI2_GYR_EN_MASK UINT8_C(0x02)
#define BMI2_ACC_EN_MASK UINT8_C(0x04)
#define BMI2_TEMP_EN_MASK UINT8_C(0x08)
/*! @name Mask definitions for sensor event flags */
#define BMI2_EVENT_FLAG_MASK UINT8_C(0x1C)
/*! @name Mask definitions to switch page */
#define BMI2_SWITCH_PAGE_EN_MASK UINT8_C(0x07)
/*! @name Mask definitions of NVM register */
#define BMI2_NV_SPI_EN_MASK UINT8_C(0x01)
#define BMI2_NV_I2C_WD_SEL_MASK UINT8_C(0x02)
#define BMI2_NV_I2C_WD_EN_MASK UINT8_C(0x04)
#define BMI2_NV_ACC_OFFSET_MASK UINT8_C(0x08)
/*! @name Mask definitions of DRV register */
#define BMI2_DRV_STR_MASK UINT8_C(0xFF)
/*! @name Mask definition for config version */
#define BMI2_CONFIG_MAJOR_MASK UINT16_C(0x3C0)
#define BMI2_CONFIG_MINOR_MASK UINT8_C(0x3F)
/*! @name mask and bit position for activity recognition settings */
#define BMI2_ACT_RECG_POST_PROS_EN_DIS_MASK UINT8_C(0x01)
#define BMI2_ACT_RECG_BUFF_SIZE_MASK UINT8_C(0x0F)
#define BMI2_ACT_RECG_MIN_SEG_CONF_MASK UINT8_C(0x0F)
/*! @name mask and bit position for activity recognition hc settings */
#define BMI2_HC_ACT_RECG_SEGMENT_SIZE_MASK UINT8_C(0x03)
#define BMI2_HC_ACT_RECG_PP_EN_MASK UINT8_C(0x01)
#define BMI2_HC_ACT_RECG_MIN_GDI_THRES_MASK UINT16_C(0xFFFF)
#define BMI2_HC_ACT_RECG_MAX_GDI_THRES_MASK UINT16_C(0xFFFF)
#define BMI2_HC_ACT_RECG_BUF_SIZE_MASK UINT16_C(0xFFFF)
#define BMI2_HC_ACT_RECG_MIN_SEG_CONF_MASK UINT16_C(0xFFFF)
#define BMI2_GYRO_CROSS_AXES_SENSE_MASK UINT8_C(0x7F)
#define BMI2_GYRO_CROSS_AXES_SENSE_SIGN_BIT_MASK UINT8_C(0x40)
/*! @name Bit position definitions for Gyro CRT */
#define BMI2_GYR_RDY_FOR_DL_POS UINT8_C(0x03)
#define BMI2_GYR_CRT_RUNNING_POS UINT8_C(0x02)
/*! @name Bit position for status register*/
#define BMI2_AUX_BUSY_POS UINT8_C(0x02)
#define BMI2_CMD_RDY_POS UINT8_C(0x04)
#define BMI2_DRDY_AUX_POS UINT8_C(0x05)
#define BMI2_DRDY_GYR_POS UINT8_C(0x06)
#define BMI2_DRDY_ACC_POS UINT8_C(0x07)
/*! @name Bit position definition for internal error register */
#define BMI2_INTERNAL_ERROR_REG_POS UINT8_C(0x00)
/*! @name Bit position definitions for power control register */
#define BMI2_GYR_EN_POS UINT8_C(0x01)
#define BMI2_ACC_EN_POS UINT8_C(0x02)
#define BMI2_TEMP_EN_POS UINT8_C(0x03)
/*! @name Bit position definitions for sensor event flags */
#define BMI2_EVENT_FLAG_POS UINT8_C(0x02)
/*! @name Bit position definitions of NVM register */
#define BMI2_NV_SPI_EN_POS UINT8_C(0x00)
#define BMI2_NV_I2C_WD_SEL_POS UINT8_C(0x01)
#define BMI2_NV_I2C_WD_EN_POS UINT8_C(0x02)
#define BMI2_NV_ACC_OFFSET_POS UINT8_C(0x03)
/*! @name Mask definitions of DRV register */
#define BMI2_DRV_STR_POS UINT8_C(0x00)
/*! @name Bit position for major version from config */
#define BMI2_CONFIG_MAJOR_POS UINT8_C(0x06)
/*! @name Accelerometer and Gyroscope Filter/Noise performance modes */
/* Power optimized mode */
#define BMI2_POWER_OPT_MODE UINT8_C(0)
/* Performance optimized */
#define BMI2_PERF_OPT_MODE UINT8_C(1)
/*! @name index for config major minor information */
#define BMI2_CONFIG_INFO_LOWER UINT8_C(52)
#define BMI2_CONFIG_INFO_HIGHER UINT8_C(53)
/*! @name Sensor status */
#define BMI2_DRDY_ACC UINT8_C(0x80)
#define BMI2_DRDY_GYR UINT8_C(0x40)
#define BMI2_DRDY_AUX UINT8_C(0x20)
#define BMI2_CMD_RDY UINT8_C(0x10)
#define BMI2_AUX_BUSY UINT8_C(0x04)
/*! @name Macro to define accelerometer configuration value for FOC */
#define BMI2_FOC_ACC_CONF_VAL UINT8_C(0xB7)
/*! @name Macro to define gyroscope configuration value for FOC */
#define BMI2_FOC_GYR_CONF_VAL UINT8_C(0xB6)
/*! @name Macro to define X Y and Z axis for an array */
#define BMI2_X_AXIS UINT8_C(0)
#define BMI2_Y_AXIS UINT8_C(1)
#define BMI2_Z_AXIS UINT8_C(2)
#define BMI2_FOC_INVERT_VALUE INT8_C(-1)
/*! @name Macro for delay to read internal status */
#define BMI2_INTERNAL_STATUS_READ_DELAY_MS UINT32_C(20000)
/******************************************************************************/
/*! @name Sensor Macro Definitions */
/******************************************************************************/
/*! @name Macros to define BMI2 sensor/feature types */
#define BMI2_ACCEL UINT8_C(0)
#define BMI2_GYRO UINT8_C(1)
#define BMI2_AUX UINT8_C(2)
#define BMI2_SIG_MOTION UINT8_C(3)
#define BMI2_ANY_MOTION UINT8_C(4)
#define BMI2_NO_MOTION UINT8_C(5)
#define BMI2_STEP_DETECTOR UINT8_C(6)
#define BMI2_STEP_COUNTER UINT8_C(7)
#define BMI2_STEP_ACTIVITY UINT8_C(8)
#define BMI2_GYRO_GAIN_UPDATE UINT8_C(9)
#define BMI2_TILT UINT8_C(10)
#define BMI2_UP_HOLD_TO_WAKE UINT8_C(11)
#define BMI2_GLANCE_DETECTOR UINT8_C(12)
#define BMI2_WAKE_UP UINT8_C(13)
#define BMI2_ORIENTATION UINT8_C(14)
#define BMI2_HIGH_G UINT8_C(15)
#define BMI2_LOW_G UINT8_C(16)
#define BMI2_FLAT UINT8_C(17)
#define BMI2_EXT_SENS_SYNC UINT8_C(18)
#define BMI2_WRIST_GESTURE UINT8_C(19)
#define BMI2_WRIST_WEAR_WAKE_UP UINT8_C(20)
#define BMI2_WRIST_WEAR_WAKE_UP_WH UINT8_C(21)
#define BMI2_WRIST_GESTURE_WH UINT8_C(22)
#define BMI2_PRIMARY_OIS UINT8_C(23)
#define BMI2_FREE_FALL_DET UINT8_C(24)
#define BMI2_SINGLE_TAP UINT8_C(25)
#define BMI2_DOUBLE_TAP UINT8_C(26)
#define BMI2_TRIPLE_TAP UINT8_C(27)
#define BMI2_TAP UINT8_C(28)
/* Non virtual sensor features */
#define BMI2_STEP_COUNTER_PARAMS UINT8_C(29)
#define BMI2_TAP_DETECTOR_1 UINT8_C(30)
#define BMI2_TAP_DETECTOR_2 UINT8_C(31)
#define BMI2_TEMP UINT8_C(32)
#define BMI2_ACCEL_SELF_TEST UINT8_C(33)
#define BMI2_GYRO_SELF_OFF UINT8_C(34)
#define BMI2_ACTIVITY_RECOGNITION UINT8_C(35)
#define BMI2_MAX_BURST_LEN UINT8_C(36)
#define BMI2_SENS_MAX_NUM UINT8_C(37)
#define BMI2_AXIS_MAP UINT8_C(38)
#define BMI2_NVM_STATUS UINT8_C(39)
#define BMI2_VFRM_STATUS UINT8_C(40)
#define BMI2_GYRO_CROSS_SENSE UINT8_C(41)
#define BMI2_CRT_GYRO_SELF_TEST UINT8_C(42)
#define BMI2_ABORT_CRT_GYRO_SELF_TEST UINT8_C(43)
#define BMI2_NVM_PROG_PREP UINT8_C(44)
#define BMI2_ACTIVITY_RECOGNITION_SETTINGS UINT8_C(45)
#define BMI2_OIS_OUTPUT UINT8_C(46)
#define BMI2_CONFIG_ID UINT8_C(47)
#define BMI2_EXT_TCO UINT8_C(48)
#define BMI2_LPD UINT8_C(49)
#define BMI2_LAPTOP_POSITION_DETECTOR_1 UINT8_C(50)
#define BMI2_LAPTOP_POSITION_DETECTOR_2 UINT8_C(51)
#define BMI2_LAPTOP_POSITION_DETECTOR_3 UINT8_C(52)
#define BMI2_LAPTOP_POSITION_DETECTOR_4 UINT8_C(53)
#define BMI2_WRIST_GESTURE_WH_1 UINT8_C(54)
#define BMI2_WRIST_GESTURE_WH_2 UINT8_C(55)
#define BMI2_WRIST_WEAR_DROP_WH UINT8_C(56)
#define BMI2_DOOR_STATE_DETECTOR UINT8_C(57)
/*! @name Bit wise for selecting BMI2 sensors/features */
#define BMI2_ACCEL_SENS_SEL (1)
#define BMI2_GYRO_SENS_SEL (1 << BMI2_GYRO)
#define BMI2_AUX_SENS_SEL (1 << BMI2_AUX)
#define BMI2_TEMP_SENS_SEL ((uint64_t)1 << BMI2_TEMP)
#define BMI2_ANY_MOT_SEL (1 << BMI2_ANY_MOTION)
#define BMI2_NO_MOT_SEL (1 << BMI2_NO_MOTION)
#define BMI2_TILT_SEL (1 << BMI2_TILT)
#define BMI2_ORIENT_SEL (1 << BMI2_ORIENTATION)
#define BMI2_SIG_MOTION_SEL (1 << BMI2_SIG_MOTION)
#define BMI2_STEP_DETECT_SEL (1 << BMI2_STEP_DETECTOR)
#define BMI2_STEP_COUNT_SEL (1 << BMI2_STEP_COUNTER)
#define BMI2_STEP_ACT_SEL (1 << BMI2_STEP_ACTIVITY)
#define BMI2_GYRO_GAIN_UPDATE_SEL (1 << BMI2_GYRO_GAIN_UPDATE)
#define BMI2_UP_HOLD_TO_WAKE_SEL (1 << BMI2_UP_HOLD_TO_WAKE)
#define BMI2_GLANCE_DET_SEL (1 << BMI2_GLANCE_DETECTOR)
#define BMI2_WAKE_UP_SEL (1 << BMI2_WAKE_UP)
#define BMI2_TAP_SEL (1 << BMI2_TAP)
#define BMI2_HIGH_G_SEL (1 << BMI2_HIGH_G)
#define BMI2_LOW_G_SEL (1 << BMI2_LOW_G)
#define BMI2_FLAT_SEL (1 << BMI2_FLAT)
#define BMI2_EXT_SENS_SEL (1 << BMI2_EXT_SENS_SYNC)
#define BMI2_SINGLE_TAP_SEL (1 << BMI2_SINGLE_TAP)
#define BMI2_DOUBLE_TAP_SEL (1 << BMI2_DOUBLE_TAP)
#define BMI2_TRIPLE_TAP_SEL (1 << BMI2_TRIPLE_TAP)
#define BMI2_GYRO_SELF_OFF_SEL ((uint64_t)1 << BMI2_GYRO_SELF_OFF)
#define BMI2_WRIST_GEST_SEL (1 << BMI2_WRIST_GESTURE)
#define BMI2_WRIST_WEAR_WAKE_UP_SEL (1 << BMI2_WRIST_WEAR_WAKE_UP)
#define BMI2_ACTIVITY_RECOGNITION_SEL ((uint64_t)1 << BMI2_ACTIVITY_RECOGNITION)
#define BMI2_ACCEL_SELF_TEST_SEL ((uint64_t)1 << BMI2_ACCEL_SELF_TEST)
#define BMI2_WRIST_GEST_W_SEL (1 << BMI2_WRIST_GESTURE_WH)
#define BMI2_WRIST_WEAR_WAKE_UP_WH_SEL (1 << BMI2_WRIST_WEAR_WAKE_UP_WH)
#define BMI2_PRIMARY_OIS_SEL (1 << BMI2_PRIMARY_OIS)
#define BMI2_FREE_FALL_DET_SEL (1 << BMI2_FREE_FALL_DET)
#define BMI2_EXT_TCO_SEL ((uint64_t)1 << BMI2_EXT_TCO)
#define BMI2_LPD_SEL ((uint64_t)1 << BMI2_LPD)
#define BMI2_WRIST_WEAR_DROP_WH_SEL ((uint64_t)1 << BMI2_WRIST_WEAR_DROP_WH)
#define BMI2_DOOR_STATE_DETECTOR_SEL ((uint64_t)1 << BMI2_DOOR_STATE_DETECTOR)
/*! @name Macro definitions for Internal error */
#define BMI2_INTERNAL_ERROR_REG_MASK UINT8_C(0xFF)
#define BMI2_INTERNAL_ERROR_1_MASK UINT8_C(0x02)
#define BMI2_INTERNAL_ERROR_2_MASK UINT8_C(0x04)
#define BMI2_FEAT_ENG_DIS_MASK UINT8_C(0x10)
/*! @name Mask definitions for saturation register */
#define BMI2_SATURATION_REG_MASK UINT8_C(0x3F)
#define BMI2_SATURATION_ACC_X_MASK UINT8_C(0x01)
#define BMI2_SATURATION_ACC_Y_MASK UINT8_C(0x02)
#define BMI2_SATURATION_ACC_Z_MASK UINT8_C(0x04)
#define BMI2_SATURATION_GYR_X_MASK UINT8_C(0x08)
#define BMI2_SATURATION_GYR_Y_MASK UINT8_C(0x10)
#define BMI2_SATURATION_GYR_Z_MASK UINT8_C(0x20)
/*! @name Mask definitions for BMI2 wake-up feature configuration for bmi260 */
#define BMI2_WAKEUP_SENSITIVITY_MASK UINT8_C(0x0E)
#define BMI2_WAKEUP_SINGLE_TAP_EN_MASK UINT8_C(0x01)
#define BMI2_WAKEUP_DOUBLE_TAP_EN_MASK UINT8_C(0x02)
#define BMI2_WAKEUP_TRIPLE_TAP_EN_MASK UINT8_C(0x04)
#define BMI2_WAKEUP_DATA_REG_EN_MASK UINT8_C(0x08)
#define BMI2_WAKEUP_AXIS_SEL_MASK UINT8_C(0x03)
/*! @name Bit position definitions for BMI2 wake-up feature configuration for bmi260 */
#define BMI2_WAKEUP_SENSITIVITY_POS UINT8_C(0x01)
#define BMI2_WAKEUP_DOUBLE_TAP_EN_POS UINT8_C(0x01)
#define BMI2_WAKEUP_TRIPLE_TAP_EN_POS UINT8_C(0x02)
#define BMI2_WAKEUP_DATA_REG_EN_POS UINT8_C(0x03)
/*! @name Mask definitions for BMI2 tap feature configuration for bmi260t */
#define BMI2_TAP_SENSITIVITY_MASK UINT8_C(0x0E)
#define BMI2_TAP_SINGLE_TAP_EN_MASK UINT8_C(0x01)
#define BMI2_TAP_DOUBLE_TAP_EN_MASK UINT8_C(0x02)
#define BMI2_TAP_TRIPLE_TAP_EN_MASK UINT8_C(0x04)
#define BMI2_TAP_DATA_REG_EN_MASK UINT8_C(0x08)
#define BMI2_TAP_AXIS_SEL_MASK UINT8_C(0x03)
/*! @name Bit position definitions for BMI2 tap feature configuration for bmi260t */
#define BMI2_TAP_SENSITIVITY_POS UINT8_C(0x01)
#define BMI2_TAP_DOUBLE_TAP_EN_POS UINT8_C(0x01)
#define BMI2_TAP_TRIPLE_TAP_EN_POS UINT8_C(0x02)
#define BMI2_TAP_DATA_REG_EN_POS UINT8_C(0x03)
/*! @name Mask definitions for BMI2 wake-up feature configuration for other than bmi261 */
#define BMI2_WAKE_UP_SENSITIVITY_MASK UINT16_C(0x000E)
#define BMI2_WAKE_UP_SINGLE_TAP_EN_MASK UINT16_C(0x0010)
/*! @name Bit position definitions for BMI2 wake-up feature configuration for other than bmi261 */
#define BMI2_WAKE_UP_SENSITIVITY_POS UINT8_C(0x01)
#define BMI2_WAKE_UP_SINGLE_TAP_EN_POS UINT8_C(0x04)
/*! @name Offsets from feature start address for BMI2 feature enable/disable */
#define BMI2_ANY_MOT_FEAT_EN_OFFSET UINT8_C(0x03)
#define BMI2_NO_MOT_FEAT_EN_OFFSET UINT8_C(0x03)
#define BMI2_SIG_MOT_FEAT_EN_OFFSET UINT8_C(0x0A)
#define BMI2_STEP_COUNT_FEAT_EN_OFFSET UINT8_C(0x01)
#define BMI2_GYR_USER_GAIN_FEAT_EN_OFFSET UINT8_C(0x05)
#define BMI2_HIGH_G_FEAT_EN_OFFSET UINT8_C(0x03)
#define BMI2_LOW_G_FEAT_EN_OFFSET UINT8_C(0x03)
#define BMI2_TILT_FEAT_EN_OFFSET UINT8_C(0x00)
/*! @name Mask definitions for BMI2 feature enable/disable */
#define BMI2_ANY_NO_MOT_EN_MASK UINT8_C(0x80)
#define BMI2_TILT_FEAT_EN_MASK UINT8_C(0x01)
#define BMI2_ORIENT_FEAT_EN_MASK UINT8_C(0x01)
#define BMI2_SIG_MOT_FEAT_EN_MASK UINT8_C(0x01)
#define BMI2_STEP_DET_FEAT_EN_MASK UINT8_C(0x08)
#define BMI2_STEP_COUNT_FEAT_EN_MASK UINT8_C(0x10)
#define BMI2_STEP_ACT_FEAT_EN_MASK UINT8_C(0x20)
#define BMI2_GYR_USER_GAIN_FEAT_EN_MASK UINT8_C(0x08)
#define BMI2_UP_HOLD_TO_WAKE_FEAT_EN_MASK UINT8_C(0x01)
#define BMI2_GLANCE_FEAT_EN_MASK UINT8_C(0x01)
#define BMI2_WAKE_UP_FEAT_EN_MASK UINT8_C(0x01)
#define BMI2_TAP_FEAT_EN_MASK UINT8_C(0x01)
#define BMI2_HIGH_G_FEAT_EN_MASK UINT8_C(0x80)
#define BMI2_LOW_G_FEAT_EN_MASK UINT8_C(0x10)
#define BMI2_FLAT_FEAT_EN_MASK UINT8_C(0x01)
#define BMI2_EXT_SENS_SYNC_FEAT_EN_MASK UINT8_C(0x01)
#define BMI2_GYR_SELF_OFF_CORR_FEAT_EN_MASK UINT8_C(0x02)
#define BMI2_WRIST_GEST_FEAT_EN_MASK UINT8_C(0x20)
#define BMI2_WRIST_WEAR_WAKE_UP_FEAT_EN_MASK UINT8_C(0x10)
#define BMI2_WRIST_WEAR_DROP_FEAT_EN_MASK UINT8_C(0x20)
#define BMI2_ACTIVITY_RECOG_EN_MASK UINT8_C(0x01)
#define BMI2_ACC_SELF_TEST_FEAT_EN_MASK UINT8_C(0x02)
#define BMI2_GYRO_SELF_TEST_CRT_EN_MASK UINT8_C(0x01)
#define BMI2_ABORT_FEATURE_EN_MASK UINT8_C(0x02)
#define BMI2_NVM_PREP_FEATURE_EN_MASK UINT8_C(0x04)
#define BMI2_FREE_FALL_DET_FEAT_EN_MASK UINT8_C(0x01)
#define BMI2_WRIST_GEST_WH_FEAT_EN_MASK UINT8_C(0x02)
#define BMI2_DOOR_STATE_DETECTOR_FEAT_EN_MASK UINT8_C(0x01)
/*! @name Bit position definitions for BMI2 feature enable/disable */
#define BMI2_ANY_NO_MOT_EN_POS UINT8_C(0x07)
#define BMI2_STEP_DET_FEAT_EN_POS UINT8_C(0x03)
#define BMI2_STEP_COUNT_FEAT_EN_POS UINT8_C(0x04)
#define BMI2_STEP_ACT_FEAT_EN_POS UINT8_C(0x05)
#define BMI2_GYR_USER_GAIN_FEAT_EN_POS UINT8_C(0x03)
#define BMI2_HIGH_G_FEAT_EN_POS UINT8_C(0x07)
#define BMI2_LOW_G_FEAT_EN_POS UINT8_C(0x04)
#define BMI2_GYR_SELF_OFF_CORR_FEAT_EN_POS UINT8_C(0x01)
#define BMI2_WRIST_GEST_FEAT_EN_POS UINT8_C(0x05)
#define BMI2_WRIST_WEAR_WAKE_UP_FEAT_EN_POS UINT8_C(0x04)
#define BMI2_WRIST_WEAR_DROP_FEAT_EN_POS UINT8_C(0x05)
#define BMI2_ACC_SELF_TEST_FEAT_EN_POS UINT8_C(0x01)
#define BMI2_ABORT_FEATURE_EN_POS UINT8_C(0x1)
#define BMI2_NVM_PREP_FEATURE_EN_POS UINT8_C(0x02)
#define BMI2_WRIST_GEST_WH_FEAT_EN_POS UINT8_C(0x01)
/*! @name Bit position and mask definitions for BMI2 Error register */
#define BMI2_ERR_REG_READ_MASK UINT8_C(0xFF)
#define BMI2_ERR_REG_READ_POS UINT8_C(0x00)
#define BMI2_FATAL_ERR_MASK UINT8_C(0x01)
#define BMI2_FATAL_ERR_POS UINT8_C(0x00)
#define BMI2_INTERNAL_ERR_MASK UINT8_C(0x1E)
#define BMI2_INTERNAL_ERR_POS UINT8_C(0x02)
#define BMI2_FIFO_ERR_MASK UINT8_C(0x40)
#define BMI2_FIFO_ERR_POS UINT8_C(0x06)
#define BMI2_AUX_ERR_MASK UINT8_C(0x80)
#define BMI2_AUX_ERR_POS UINT8_C(0x07)
/*! Primary OIS low pass filter configuration position and mask */
#define BMI2_LP_FILTER_EN_MASK UINT8_C(0x01)
#define BMI2_LP_FILTER_CONFIG_POS UINT8_C(0x01)
#define BMI2_LP_FILTER_CONFIG_MASK UINT8_C(0x06)
#define BMI2_PRIMARY_OIS_GYR_EN_POS UINT8_C(0x06)
#define BMI2_PRIMARY_OIS_GYR_EN_MASK UINT8_C(0x40)
#define BMI2_PRIMARY_OIS_ACC_EN_POS UINT8_C(0x07)
#define BMI2_PRIMARY_OIS_ACC_EN_MASK UINT8_C(0x80)
/*! @name Mask definitions for BMI2 any and no-motion feature configuration */
#define BMI2_ANY_NO_MOT_DUR_MASK UINT16_C(0x1FFF)
#define BMI2_ANY_NO_MOT_X_SEL_MASK UINT16_C(0x2000)
#define BMI2_ANY_NO_MOT_Y_SEL_MASK UINT16_C(0x4000)
#define BMI2_ANY_NO_MOT_Z_SEL_MASK UINT16_C(0x8000)
#define BMI2_ANY_NO_MOT_THRES_MASK UINT16_C(0x07FF)
#define BMI2_ANY_MOT_INT_MASK UINT8_C(0x40)
/*! @name Mask definitions for BMI2 no-motion interrupt mapping */
#define BMI2_NO_MOT_INT_MASK UINT8_C(0x20)
/*! @name Bit position definitions for BMI2 any and no-motion feature
* configuration
*/
#define BMI2_ANY_NO_MOT_X_SEL_POS UINT8_C(0x0D)
#define BMI2_ANY_NO_MOT_Y_SEL_POS UINT8_C(0x0E)
#define BMI2_ANY_NO_MOT_Z_SEL_POS UINT8_C(0x0F)
/*! @name Mask definitions for BMI2 orientation feature configuration */
#define BMI2_ORIENT_UP_DOWN_MASK UINT16_C(0x0002)
#define BMI2_ORIENT_SYMM_MODE_MASK UINT16_C(0x000C)
#define BMI2_ORIENT_BLOCK_MODE_MASK UINT16_C(0x0030)
#define BMI2_ORIENT_THETA_MASK UINT16_C(0x0FC0)
#define BMI2_ORIENT_HYST_MASK UINT16_C(0x07FF)
/*! @name Bit position definitions for BMI2 orientation feature configuration */
#define BMI2_ORIENT_UP_DOWN_POS UINT8_C(0x01)
#define BMI2_ORIENT_SYMM_MODE_POS UINT8_C(0x02)
#define BMI2_ORIENT_BLOCK_MODE_POS UINT8_C(0x04)
#define BMI2_ORIENT_THETA_POS UINT8_C(0x06)
/*! @name Mask definitions for BMI2 sig-motion feature configuration */
#define BMI2_SIG_MOT_PARAM_1_MASK UINT16_C(0xFFFF)
#define BMI2_SIG_MOT_PARAM_2_MASK UINT16_C(0xFFFF)
#define BMI2_SIG_MOT_PARAM_3_MASK UINT16_C(0xFFFF)
#define BMI2_SIG_MOT_PARAM_4_MASK UINT16_C(0xFFFF)
#define BMI2_SIG_MOT_PARAM_5_MASK UINT16_C(0xFFFF)
/*! @name Mask definitions for BMI2 parameter configurations */
#define BMI2_STEP_COUNT_PARAMS_MASK UINT16_C(0xFFFF)
/*! @name Mask definitions for BMI2 step-counter/detector feature configuration */
#define BMI2_STEP_COUNT_WM_LEVEL_MASK UINT16_C(0x03FF)
#define BMI2_STEP_COUNT_RST_CNT_MASK UINT16_C(0x0400)
#define BMI2_STEP_BUFFER_SIZE_MASK UINT16_C(0xFF00)
#define BMI2_STEP_COUNT_INT_MASK UINT8_C(0x02)
#define BMI2_STEP_ACT_INT_MASK UINT8_C(0x04)
/*! @name Bit position definitions for BMI2 step-counter/detector feature
* configuration
*/
#define BMI2_STEP_COUNT_RST_CNT_POS UINT8_C(0x0A)
#define BMI2_STEP_BUFFER_SIZE_POS UINT8_C(0x08)
/*! @name Mask definitions for BMI2 gyroscope user gain feature
* configuration
*/
#define BMI2_GYR_USER_GAIN_RATIO_X_MASK UINT16_C(0x07FF)
#define BMI2_GYR_USER_GAIN_RATIO_Y_MASK UINT16_C(0x07FF)
#define BMI2_GYR_USER_GAIN_RATIO_Z_MASK UINT16_C(0x07FF)
/*! @name Mask definitions for BMI2 gyroscope user gain saturation status */
#define BMI2_GYR_USER_GAIN_SAT_STAT_X_MASK UINT8_C(0x01)
#define BMI2_GYR_USER_GAIN_SAT_STAT_Y_MASK UINT8_C(0x02)
#define BMI2_GYR_USER_GAIN_SAT_STAT_Z_MASK UINT8_C(0x04)
#define BMI2_G_TRIGGER_STAT_MASK UINT8_C(0x38)
/*! @name Bit position definitions for BMI2 gyroscope user gain saturation status */
#define BMI2_GYR_USER_GAIN_SAT_STAT_Y_POS UINT8_C(0x01)
#define BMI2_GYR_USER_GAIN_SAT_STAT_Z_POS UINT8_C(0x02)
#define BMI2_G_TRIGGER_STAT_POS UINT8_C(0x03)
/*! @name Mask definitions for MSB values of BMI2 gyroscope compensation */
#define BMI2_GYR_OFF_COMP_MSB_X_MASK UINT8_C(0x03)
#define BMI2_GYR_OFF_COMP_MSB_Y_MASK UINT8_C(0x0C)
#define BMI2_GYR_OFF_COMP_MSB_Z_MASK UINT8_C(0x30)
/*! @name Bit positions for MSB values of BMI2 gyroscope compensation */
#define BMI2_GYR_OFF_COMP_MSB_Y_POS UINT8_C(0x02)
#define BMI2_GYR_OFF_COMP_MSB_Z_POS UINT8_C(0x04)
/*! @name Mask definitions for MSB values of BMI2 gyroscope compensation from user input */
#define BMI2_GYR_OFF_COMP_MSB_MASK UINT16_C(0x0300)
#define BMI2_GYR_OFF_COMP_LSB_MASK UINT16_C(0x00FF)
/*! @name Mask definitions for BMI2 orientation status */
#define BMI2_ORIENT_DETECT_MASK UINT8_C(0x03)
#define BMI2_ORIENT_FACE_UP_DWN_MASK UINT8_C(0x04)
/*! @name Bit position definitions for BMI2 orientation status */
#define BMI2_ORIENT_FACE_UP_DWN_POS UINT8_C(0x02)
/*! @name Mask definitions for NVM-VFRM error status */
#define BMI2_NVM_LOAD_ERR_STATUS_MASK UINT8_C(0x01)
#define BMI2_NVM_PROG_ERR_STATUS_MASK UINT8_C(0x02)
#define BMI2_NVM_ERASE_ERR_STATUS_MASK UINT8_C(0x04)
#define BMI2_NVM_END_EXCEED_STATUS_MASK UINT8_C(0x08)
#define BMI2_NVM_PRIV_ERR_STATUS_MASK UINT8_C(0x10)
#define BMI2_VFRM_LOCK_ERR_STATUS_MASK UINT8_C(0x20)
#define BMI2_VFRM_WRITE_ERR_STATUS_MASK UINT8_C(0x40)
#define BMI2_VFRM_FATAL_ERR_STATUS_MASK UINT8_C(0x80)
/*! @name Bit positions for NVM-VFRM error status */
#define BMI2_NVM_PROG_ERR_STATUS_POS UINT8_C(0x01)
#define BMI2_NVM_ERASE_ERR_STATUS_POS UINT8_C(0x02)
#define BMI2_NVM_END_EXCEED_STATUS_POS UINT8_C(0x03)
#define BMI2_NVM_PRIV_ERR_STATUS_POS UINT8_C(0x04)
#define BMI2_VFRM_LOCK_ERR_STATUS_POS UINT8_C(0x05)
#define BMI2_VFRM_WRITE_ERR_STATUS_POS UINT8_C(0x06)
#define BMI2_VFRM_FATAL_ERR_STATUS_POS UINT8_C(0x07)
/*! @name Mask definitions for accelerometer self-test status */
#define BMI2_ACC_SELF_TEST_DONE_MASK UINT8_C(0x01)
#define BMI2_ACC_X_OK_MASK UINT8_C(0x02)
#define BMI2_ACC_Y_OK_MASK UINT8_C(0x04)
#define BMI2_ACC_Z_OK_MASK UINT8_C(0x08)
/*! @name Bit Positions for accelerometer self-test status */
#define BMI2_ACC_X_OK_POS UINT8_C(0x01)
#define BMI2_ACC_Y_OK_POS UINT8_C(0x02)
#define BMI2_ACC_Z_OK_POS UINT8_C(0x03)
/*! @name Mask definitions for BMI2 high-g feature configuration */
#define BMI2_HIGH_G_THRES_MASK UINT16_C(0x7FFF)
#define BMI2_HIGH_G_HYST_MASK UINT16_C(0x0FFF)
#define BMI2_HIGH_G_X_SEL_MASK UINT16_C(0x1000)
#define BMI2_HIGH_G_Y_SEL_MASK UINT16_C(0x2000)
#define BMI2_HIGH_G_Z_SEL_MASK UINT16_C(0x4000)
#define BMI2_HIGH_G_DUR_MASK UINT16_C(0x0FFF)
/*! @name Bit position definitions for BMI2 high-g feature configuration */
#define BMI2_HIGH_G_X_SEL_POS UINT8_C(0x0C)
#define BMI2_HIGH_G_Y_SEL_POS UINT8_C(0x0D)
#define BMI2_HIGH_G_Z_SEL_POS UINT8_C(0x0E)
/*! @name Mask definitions for BMI2 low-g feature configuration */
#define BMI2_LOW_G_THRES_MASK UINT16_C(0x7FFF)
#define BMI2_LOW_G_HYST_MASK UINT16_C(0x0FFF)
#define BMI2_LOW_G_DUR_MASK UINT16_C(0x0FFF)
/*! @name Mask definitions for BMI2 free-fall detection feature configuration */
#define BMI2_FREE_FALL_ACCEL_SETT_MASK UINT16_C(0xFFFF)
/*! @name Mask definitions for BMI2 flat feature configuration */
#define BMI2_FLAT_THETA_MASK UINT16_C(0x007E)
#define BMI2_FLAT_BLOCK_MASK UINT16_C(0x0180)
#define BMI2_FLAT_HYST_MASK UINT16_C(0x003F)
#define BMI2_FLAT_HOLD_TIME_MASK UINT16_C(0x3FC0)
/*! @name Bit position definitions for BMI2 flat feature configuration */
#define BMI2_FLAT_THETA_POS UINT8_C(0x01)
#define BMI2_FLAT_BLOCK_POS UINT8_C(0x07)
#define BMI2_FLAT_HOLD_TIME_POS UINT8_C(0x06)
/*! @name Mask definitions for BMI2 wrist gesture configuration */
#define BMI2_WRIST_GEST_WEAR_ARM_MASK UINT16_C(0x0010)
/*! @name Bit position definitions for wrist gesture configuration */
#define BMI2_WRIST_GEST_WEAR_ARM_POS UINT8_C(0x04)
/*! @name Mask definitions for BMI2 wrist gesture wh configuration */
#define BMI2_WRIST_GEST_WH_DEVICE_POS_MASK UINT16_C(0x0001)
#define BMI2_WRIST_GEST_WH_INT UINT8_C(0x10)
#define BMI2_WRIST_GEST_WH_START_ADD UINT8_C(0x08)
/*! @name Mask definitions for BMI2 wrist wear wake-up configuration */
#define BMI2_WRIST_WAKE_UP_WH_INT_MASK UINT8_C(0x08)
/*! @name Mask definition for BMI2 wrist wear wake-up configuration for wearable variant */
#define BMI2_WRIST_WAKE_UP_ANGLE_LR_MASK UINT16_C(0x00FF)
#define BMI2_WRIST_WAKE_UP_ANGLE_LL_MASK UINT16_C(0xFF00)
#define BMI2_WRIST_WAKE_UP_ANGLE_PD_MASK UINT16_C(0x00FF)
#define BMI2_WRIST_WAKE_UP_ANGLE_PU_MASK UINT16_C(0xFF00)
#define BMI2_WRIST_WAKE_UP_MIN_DUR_MOVED_MASK UINT16_C(0x00FF)
#define BMI2_WRIST_WAKE_UP_MIN_DUR_QUITE_MASK UINT16_C(0xFF00)
#define BMI2_WRIST_WAKE_UP_MIN_DROP_POS_DUR_MASK UINT16_C(0x00FF)
#define BMI2_WRIST_WAKE_UP_MIN_DROP_POS_DUR_LOC_MASK UINT16_C(0xFF00)
/*! @name Bit position definition for BMI2 wrist wear wake-up configuration for wearable variant */
#define BMI2_WRIST_WAKE_UP_ANGLE_LL_POS UINT16_C(0x0008)
#define BMI2_WRIST_WAKE_UP_ANGLE_PU_POS UINT16_C(0x0008)
#define BMI2_WRIST_WAKE_UP_MIN_DUR_QUITE_POS UINT16_C(0x0008)
#define BMI2_WRIST_WAKE_UP_MIN_DROP_POS_DUR_LOC_POS UINT16_C(0x0008)
/*! @name Mask definition for BMI2 EXT TCO configuration */
#define BMI2_EXT_TCO_MASK UINT8_C(0x01)
/*! @name Macros to define values of BMI2 axis and its sign for re-map
* settings
*/
#define BMI2_MAP_X_AXIS UINT8_C(0x00)
#define BMI2_MAP_Y_AXIS UINT8_C(0x01)
#define BMI2_MAP_Z_AXIS UINT8_C(0x02)
#define BMI2_MAP_POSITIVE UINT8_C(0x00)
#define BMI2_MAP_NEGATIVE UINT8_C(0x01)
/*! @name Mask definitions of BMI2 axis re-mapping */
#define BMI2_X_AXIS_MASK UINT8_C(0x03)
#define BMI2_X_AXIS_SIGN_MASK UINT8_C(0x04)
#define BMI2_Y_AXIS_MASK UINT8_C(0x18)
#define BMI2_Y_AXIS_SIGN_MASK UINT8_C(0x20)
#define BMI2_Z_AXIS_MASK UINT8_C(0xC0)
#define BMI2_Z_AXIS_SIGN_MASK UINT8_C(0x01)
/*! @name Bit position definitions of BMI2 axis re-mapping */
#define BMI2_X_AXIS_SIGN_POS UINT8_C(0x02)
#define BMI2_Y_AXIS_POS UINT8_C(0x03)
#define BMI2_Y_AXIS_SIGN_POS UINT8_C(0x05)
#define BMI2_Z_AXIS_POS UINT8_C(0x06)
/*! @name Mask definitions of BMI2 virtual frame */
#define BMI2_EIS_VFRM_DATA_MASK UINT8_C(0x08)
/*! @name Bit position definitions of BMI2 virtual frame */
#define BMI2_EIS_VFRM_DATA_POS UINT8_C(3)
/*! @name Macro to define virtual frame length */
#define BMI2_VIRTUAL_FRAME_LEN UINT8_C(19)
/*! @name Macros to define polarity */
#define BMI2_NEG_SIGN UINT8_C(1)
#define BMI2_POS_SIGN UINT8_C(0)
/*! @name Macro to define related to CRT */
#define BMI2_CRT_READY_FOR_DOWNLOAD_US UINT16_C(2000)
#define BMI2_CRT_READY_FOR_DOWNLOAD_RETRY UINT8_C(100)
#define BMI2_CRT_WAIT_RUNNING_US UINT16_C(10000)
#define BMI2_CRT_WAIT_RUNNING_RETRY_EXECUTION UINT8_C(200)
#define BMI2_CRT_MIN_BURST_WORD_LENGTH UINT8_C(2)
#define BMI2_CRT_MAX_BURST_WORD_LENGTH UINT16_C(255)
/* Reference value with positive and negative noise range in lsb */
/*
* For Gyro FOC, axes values after FOC must be 0 +/- 1 dps
*
* In 2000 dps, 1 dps is 16.384 (~16)
* In 1000 dps, 1 dps is 32.768 (~33)
* In 500 dps, 1 dps is 65.536 (~66)
* In 250 dps, 1 dps is 131.072 (~131)
* In 125 dps, 1 dps is 262.144 (~262)
*/
#define BMI2_GYRO_FOC_2000_DPS_REF UINT16_C(16)
#define BMI2_GYRO_FOC_1000_DPS_REF UINT16_C(33)
#define BMI2_GYRO_FOC_500_DPS_REF UINT16_C(66)
#define BMI2_GYRO_FOC_250_DPS_REF UINT16_C(131)
#define BMI2_GYRO_FOC_125_DPS_REF UINT16_C(262)
/* Reference value with positive and negative noise range in lsb */
/*
* As per datasheet, Zero-g offset : +/- 20mg
*
* In range 2G, 1G is 16384. so, 16384 x 20 x (10 ^ -3) = 328
* In range 4G, 1G is 8192. so, 8192 x 20 x (10 ^ -3) = 164
* In range 8G, 1G is 4096. so, 4096 x 20 x (10 ^ -3) = 82
* In range 16G, 1G is 2048. so, 2048 x 20 x (10 ^ -3) = 41
*/
#define BMI2_ACC_FOC_2G_REF UINT16_C(16384)
#define BMI2_ACC_FOC_4G_REF UINT16_C(8192)
#define BMI2_ACC_FOC_8G_REF UINT16_C(4096)
#define BMI2_ACC_FOC_16G_REF UINT16_C(2048)
#define BMI2_ACC_FOC_2G_OFFSET UINT16_C(328)
#define BMI2_ACC_FOC_4G_OFFSET UINT16_C(164)
#define BMI2_ACC_FOC_8G_OFFSET UINT16_C(82)
#define BMI2_ACC_FOC_16G_OFFSET UINT16_C(41)
#define BMI2_FOC_SAMPLE_LIMIT UINT8_C(128)
#define BMI2_ACC_2G_MAX_NOISE_LIMIT (BMI2_ACC_FOC_2G_REF + BMI2_ACC_FOC_2G_OFFSET)
#define BMI2_ACC_2G_MIN_NOISE_LIMIT (BMI2_ACC_FOC_2G_REF - BMI2_ACC_FOC_2G_OFFSET)
#define BMI2_ACC_4G_MAX_NOISE_LIMIT (BMI2_ACC_FOC_4G_REF + BMI2_ACC_FOC_4G_OFFSET)
#define BMI2_ACC_4G_MIN_NOISE_LIMIT (BMI2_ACC_FOC_4G_REF - BMI2_ACC_FOC_4G_OFFSET)
#define BMI2_ACC_8G_MAX_NOISE_LIMIT (BMI2_ACC_FOC_8G_REF + BMI2_ACC_FOC_8G_OFFSET)
#define BMI2_ACC_8G_MIN_NOISE_LIMIT (BMI2_ACC_FOC_8G_REF - BMI2_ACC_FOC_8G_OFFSET)
#define BMI2_ACC_16G_MAX_NOISE_LIMIT (BMI2_ACC_FOC_16G_REF + BMI2_ACC_FOC_16G_OFFSET)
#define BMI2_ACC_16G_MIN_NOISE_LIMIT (BMI2_ACC_FOC_16G_REF - BMI2_ACC_FOC_16G_OFFSET)
/*! @name Bit wise selection of BMI2 sensors */
#define BMI2_MAIN_SENSORS \
(BMI2_ACCEL_SENS_SEL | BMI2_GYRO_SENS_SEL \
| BMI2_AUX_SENS_SEL | BMI2_TEMP_SENS_SEL)
/*! @name Maximum number of BMI2 main sensors */
#define BMI2_MAIN_SENS_MAX_NUM UINT8_C(4)
/*! @name Macro to specify the number of step counter parameters */
#define BMI2_STEP_CNT_N_PARAMS UINT8_C(25)
/*! @name Macro to specify the number of free-fall accel setting parameters */
#define BMI2_FREE_FALL_ACCEL_SET_PARAMS UINT8_C(7)
#define BMI2_SELECT_GYRO_SELF_TEST UINT8_C(0)
#define BMI2_SELECT_CRT UINT8_C(1)
/*! @name Macro for NVM enable */
#define BMI2_NVM_UNLOCK_ENABLE UINT8_C(0x02)
#define BMI2_NVM_UNLOCK_DISABLE UINT8_C(0x00)
/*! @name macro to select between gyro self test and CRT */
#define BMI2_GYRO_SELF_TEST_SEL UINT8_C(0)
#define BMI2_CRT_SEL UINT8_C(1)
/******************************************************************************/
/*! @name Accelerometer Macro Definitions */
/******************************************************************************/
/*! @name Accelerometer Bandwidth parameters */
#define BMI2_ACC_OSR4_AVG1 UINT8_C(0x00)
#define BMI2_ACC_OSR2_AVG2 UINT8_C(0x01)
#define BMI2_ACC_NORMAL_AVG4 UINT8_C(0x02)
#define BMI2_ACC_CIC_AVG8 UINT8_C(0x03)
#define BMI2_ACC_RES_AVG16 UINT8_C(0x04)
#define BMI2_ACC_RES_AVG32 UINT8_C(0x05)
#define BMI2_ACC_RES_AVG64 UINT8_C(0x06)
#define BMI2_ACC_RES_AVG128 UINT8_C(0x07)
/*! @name Accelerometer Output Data Rate */
#define BMI2_ACC_ODR_0_78HZ UINT8_C(0x01)
#define BMI2_ACC_ODR_1_56HZ UINT8_C(0x02)
#define BMI2_ACC_ODR_3_12HZ UINT8_C(0x03)
#define BMI2_ACC_ODR_6_25HZ UINT8_C(0x04)
#define BMI2_ACC_ODR_12_5HZ UINT8_C(0x05)
#define BMI2_ACC_ODR_25HZ UINT8_C(0x06)
#define BMI2_ACC_ODR_50HZ UINT8_C(0x07)
#define BMI2_ACC_ODR_100HZ UINT8_C(0x08)
#define BMI2_ACC_ODR_200HZ UINT8_C(0x09)
#define BMI2_ACC_ODR_400HZ UINT8_C(0x0A)
#define BMI2_ACC_ODR_800HZ UINT8_C(0x0B)
#define BMI2_ACC_ODR_1600HZ UINT8_C(0x0C)
/*! @name Accelerometer G Range */
#define BMI2_ACC_RANGE_2G UINT8_C(0x00)
#define BMI2_ACC_RANGE_4G UINT8_C(0x01)
#define BMI2_ACC_RANGE_8G UINT8_C(0x02)
#define BMI2_ACC_RANGE_16G UINT8_C(0x03)
/*! @name Mask definitions for accelerometer configuration register */
#define BMI2_ACC_RANGE_MASK UINT8_C(0x03)
#define BMI2_ACC_ODR_MASK UINT8_C(0x0F)
#define BMI2_ACC_BW_PARAM_MASK UINT8_C(0x70)
#define BMI2_ACC_FILTER_PERF_MODE_MASK UINT8_C(0x80)
/*! @name Bit position definitions for accelerometer configuration register */
#define BMI2_ACC_BW_PARAM_POS UINT8_C(0x04)
#define BMI2_ACC_FILTER_PERF_MODE_POS UINT8_C(0x07)
/*! @name Self test macro to define range */
#define BMI2_ACC_SELF_TEST_RANGE UINT8_C(16)
/*! @name Self test macro to show resulting minimum and maximum difference
* signal of the axes in mg
*/
#define BMI2_ST_ACC_X_SIG_MIN_DIFF INT16_C(16000)
#define BMI2_ST_ACC_Y_SIG_MIN_DIFF INT16_C(-15000)
#define BMI2_ST_ACC_Z_SIG_MIN_DIFF INT16_C(10000)
/*! @name Mask definitions for accelerometer self-test */
#define BMI2_ACC_SELF_TEST_EN_MASK UINT8_C(0x01)
#define BMI2_ACC_SELF_TEST_SIGN_MASK UINT8_C(0x04)
#define BMI2_ACC_SELF_TEST_AMP_MASK UINT8_C(0x08)
/*! @name Bit Positions for accelerometer self-test */
#define BMI2_ACC_SELF_TEST_SIGN_POS UINT8_C(0x02)
#define BMI2_ACC_SELF_TEST_AMP_POS UINT8_C(0x03)
/*! @name MASK definition for gyro self test status */
#define BMI2_GYR_ST_AXES_DONE_MASK UINT8_C(0x01)
#define BMI2_GYR_AXIS_X_OK_MASK UINT8_C(0x02)
#define BMI2_GYR_AXIS_Y_OK_MASK UINT8_C(0x04)
#define BMI2_GYR_AXIS_Z_OK_MASK UINT8_C(0x08)
/*! @name Bit position for gyro self test status */
#define BMI2_GYR_AXIS_X_OK_POS UINT8_C(0x01)
#define BMI2_GYR_AXIS_Y_OK_POS UINT8_C(0x02)
#define BMI2_GYR_AXIS_Z_OK_POS UINT8_C(0x03)
/******************************************************************************/
/*! @name Gyroscope Macro Definitions */
/******************************************************************************/
/*! @name Gyroscope Bandwidth parameters */
#define BMI2_GYR_OSR4_MODE UINT8_C(0x00)
#define BMI2_GYR_OSR2_MODE UINT8_C(0x01)
#define BMI2_GYR_NORMAL_MODE UINT8_C(0x02)
#define BMI2_GYR_CIC_MODE UINT8_C(0x03)
/*! @name Gyroscope Output Data Rate */
#define BMI2_GYR_ODR_25HZ UINT8_C(0x06)
#define BMI2_GYR_ODR_50HZ UINT8_C(0x07)
#define BMI2_GYR_ODR_100HZ UINT8_C(0x08)
#define BMI2_GYR_ODR_200HZ UINT8_C(0x09)
#define BMI2_GYR_ODR_400HZ UINT8_C(0x0A)
#define BMI2_GYR_ODR_800HZ UINT8_C(0x0B)
#define BMI2_GYR_ODR_1600HZ UINT8_C(0x0C)
#define BMI2_GYR_ODR_3200HZ UINT8_C(0x0D)
/*! @name Gyroscope OIS Range */
#define BMI2_GYR_OIS_250 UINT8_C(0x00)
#define BMI2_GYR_OIS_2000 UINT8_C(0x01)
/*! @name Gyroscope Angular Rate Measurement Range */
#define BMI2_GYR_RANGE_2000 UINT8_C(0x00)
#define BMI2_GYR_RANGE_1000 UINT8_C(0x01)
#define BMI2_GYR_RANGE_500 UINT8_C(0x02)
#define BMI2_GYR_RANGE_250 UINT8_C(0x03)
#define BMI2_GYR_RANGE_125 UINT8_C(0x04)
/*! @name Mask definitions for gyroscope configuration register */
#define BMI2_GYR_RANGE_MASK UINT8_C(0x07)
#define BMI2_GYR_OIS_RANGE_MASK UINT8_C(0x08)
#define BMI2_GYR_ODR_MASK UINT8_C(0x0F)
#define BMI2_GYR_BW_PARAM_MASK UINT8_C(0x30)
#define BMI2_GYR_NOISE_PERF_MODE_MASK UINT8_C(0x40)
#define BMI2_GYR_FILTER_PERF_MODE_MASK UINT8_C(0x80)
/*! @name Bit position definitions for gyroscope configuration register */
#define BMI2_GYR_OIS_RANGE_POS UINT8_C(0x03)
#define BMI2_GYR_BW_PARAM_POS UINT8_C(0x04)
#define BMI2_GYR_NOISE_PERF_MODE_POS UINT8_C(0x06)
#define BMI2_GYR_FILTER_PERF_MODE_POS UINT8_C(0x07)
/******************************************************************************/
/*! @name Auxiliary Macro Definitions */
/******************************************************************************/
/*! @name Auxiliary Output Data Rate */
#define BMI2_AUX_ODR_RESERVED UINT8_C(0x00)
#define BMI2_AUX_ODR_0_78HZ UINT8_C(0x01)
#define BMI2_AUX_ODR_1_56HZ UINT8_C(0x02)
#define BMI2_AUX_ODR_3_12HZ UINT8_C(0x03)
#define BMI2_AUX_ODR_6_25HZ UINT8_C(0x04)
#define BMI2_AUX_ODR_12_5HZ UINT8_C(0x05)
#define BMI2_AUX_ODR_25HZ UINT8_C(0x06)
#define BMI2_AUX_ODR_50HZ UINT8_C(0x07)
#define BMI2_AUX_ODR_100HZ UINT8_C(0x08)
#define BMI2_AUX_ODR_200HZ UINT8_C(0x09)
#define BMI2_AUX_ODR_400HZ UINT8_C(0x0A)
#define BMI2_AUX_ODR_800HZ UINT8_C(0x0B)
/*! @name Macro to define burst read lengths for both manual and auto modes */
#define BMI2_AUX_READ_LEN_0 UINT8_C(0x00)
#define BMI2_AUX_READ_LEN_1 UINT8_C(0x01)
#define BMI2_AUX_READ_LEN_2 UINT8_C(0x02)
#define BMI2_AUX_READ_LEN_3 UINT8_C(0x03)
#define BMI2_AUX_RD_BURST_FRM_LEN_1 UINT8_C(1)
#define BMI2_AUX_RD_BURST_FRM_LEN_2 UINT8_C(2)
#define BMI2_AUX_RD_BURST_FRM_LEN_6 UINT8_C(6)
#define BMI2_AUX_RD_BURST_FRM_LEN_8 UINT8_C(8)
/*! @name Mask definitions for auxiliary interface configuration register */
#define BMI2_AUX_SET_I2C_ADDR_MASK UINT8_C(0xFE)
#define BMI2_AUX_MAN_MODE_EN_MASK UINT8_C(0x80)
#define BMI2_AUX_FCU_WR_EN_MASK UINT8_C(0x40)
#define BMI2_AUX_MAN_READ_BURST_MASK UINT8_C(0x0C)
#define BMI2_AUX_READ_BURST_MASK UINT8_C(0x03)
#define BMI2_AUX_ODR_EN_MASK UINT8_C(0x0F)
#define BMI2_AUX_OFFSET_READ_OUT_MASK UINT8_C(0xF0)
/*! @name Bit positions for auxiliary interface configuration register */
#define BMI2_AUX_SET_I2C_ADDR_POS UINT8_C(0x01)
#define BMI2_AUX_MAN_MODE_EN_POS UINT8_C(0x07)
#define BMI2_AUX_FCU_WR_EN_POS UINT8_C(0x06)
#define BMI2_AUX_MAN_READ_BURST_POS UINT8_C(0x02)
#define BMI2_AUX_OFFSET_READ_OUT_POS UINT8_C(0x04)
/******************************************************************************/
/*! @name FIFO Macro Definitions */
/******************************************************************************/
/*! @name Macros to define virtual FIFO frame mode */
#define BMI2_FIFO_VIRT_FRM_MODE UINT8_C(0x03)
/*! @name FIFO Header Mask definitions */
#define BMI2_FIFO_HEADER_ACC_FRM UINT8_C(0x84)
#define BMI2_FIFO_HEADER_AUX_FRM UINT8_C(0x90)
#define BMI2_FIFO_HEADER_GYR_FRM UINT8_C(0x88)
#define BMI2_FIFO_HEADER_GYR_ACC_FRM UINT8_C(0x8C)
#define BMI2_FIFO_HEADER_AUX_ACC_FRM UINT8_C(0x94)
#define BMI2_FIFO_HEADER_AUX_GYR_FRM UINT8_C(0x98)
#define BMI2_FIFO_HEADER_ALL_FRM UINT8_C(0x9C)
#define BMI2_FIFO_HEADER_SENS_TIME_FRM UINT8_C(0x44)
#define BMI2_FIFO_HEADER_SKIP_FRM UINT8_C(0x40)
#define BMI2_FIFO_HEADER_INPUT_CFG_FRM UINT8_C(0x48)
#define BMI2_FIFO_HEAD_OVER_READ_MSB UINT8_C(0x80)
#define BMI2_FIFO_VIRT_ACT_RECOG_FRM UINT8_C(0xC8)
/*! @name BMI2 sensor selection for header-less frames */
#define BMI2_FIFO_HEAD_LESS_ACC_FRM UINT8_C(0x40)
#define BMI2_FIFO_HEAD_LESS_AUX_FRM UINT8_C(0x20)
#define BMI2_FIFO_HEAD_LESS_GYR_FRM UINT8_C(0x80)
#define BMI2_FIFO_HEAD_LESS_GYR_AUX_FRM UINT8_C(0xA0)
#define BMI2_FIFO_HEAD_LESS_GYR_ACC_FRM UINT8_C(0xC0)
#define BMI2_FIFO_HEAD_LESS_AUX_ACC_FRM UINT8_C(0x60)
#define BMI2_FIFO_HEAD_LESS_ALL_FRM UINT8_C(0xE0)
/*! @name Mask definitions for FIFO frame content configuration */
#define BMI2_FIFO_STOP_ON_FULL UINT16_C(0x0001)
#define BMI2_FIFO_TIME_EN UINT16_C(0x0002)
#define BMI2_FIFO_TAG_INT1 UINT16_C(0x0300)
#define BMI2_FIFO_TAG_INT2 UINT16_C(0x0C00)
#define BMI2_FIFO_HEADER_EN UINT16_C(0x1000)
#define BMI2_FIFO_AUX_EN UINT16_C(0x2000)
#define BMI2_FIFO_ACC_EN UINT16_C(0x4000)
#define BMI2_FIFO_GYR_EN UINT16_C(0x8000)
#define BMI2_FIFO_ALL_EN UINT16_C(0xE000)
/*! @name Sensortime resolution in seconds */
#define BMI2_SENSORTIME_RESOLUTION 0.0000390625f
/*! @name FIFO sensor data lengths */
#define BMI2_FIFO_ACC_LENGTH UINT8_C(6)
#define BMI2_FIFO_GYR_LENGTH UINT8_C(6)
#define BMI2_FIFO_ACC_GYR_LENGTH UINT8_C(12)
#define BMI2_SENSOR_TIME_LENGTH UINT8_C(3)
#define BMI2_FIFO_CONFIG_LENGTH UINT8_C(2)
#define BMI2_FIFO_WM_LENGTH UINT8_C(2)
#define BMI2_MAX_VALUE_FIFO_FILTER UINT8_C(1)
#define BMI2_FIFO_DATA_LENGTH UINT8_C(2)
#define BMI2_FIFO_LENGTH_MSB_BYTE UINT8_C(1)
#define BMI2_FIFO_INPUT_CFG_LENGTH UINT8_C(4)
#define BMI2_FIFO_SKIP_FRM_LENGTH UINT8_C(1)
/*! @name FIFO sensor virtual data lengths: sensor data plus sensor time */
#define BMI2_FIFO_VIRT_ACC_LENGTH UINT8_C(9)
#define BMI2_FIFO_VIRT_GYR_LENGTH UINT8_C(9)
#define BMI2_FIFO_VIRT_AUX_LENGTH UINT8_C(11)
#define BMI2_FIFO_VIRT_ACC_AUX_LENGTH UINT8_C(17)
#define BMI2_FIFO_VIRT_GYR_AUX_LENGTH UINT8_C(17)
#define BMI2_FIFO_VIRT_ACC_GYR_LENGTH UINT8_C(15)
#define BMI2_FIFO_VIRT_ALL_LENGTH UINT8_C(23)
/*! @name FIFO sensor virtual data lengths: activity recognition */
#define BMI2_FIFO_VIRT_ACT_DATA_LENGTH UINT8_C(6)
#define BMI2_FIFO_VIRT_ACT_TIME_LENGTH UINT8_C(4)
#define BMI2_FIFO_VIRT_ACT_TYPE_LENGTH UINT8_C(1)
#define BMI2_FIFO_VIRT_ACT_STAT_LENGTH UINT8_C(1)
/*! @name BMI2 FIFO data filter modes */
#define BMI2_FIFO_UNFILTERED_DATA UINT8_C(0)
#define BMI2_FIFO_FILTERED_DATA UINT8_C(1)
/*! @name FIFO frame masks */
#define BMI2_FIFO_LSB_CONFIG_CHECK UINT8_C(0x00)
#define BMI2_FIFO_MSB_CONFIG_CHECK UINT8_C(0x80)
#define BMI2_FIFO_TAG_INTR_MASK UINT8_C(0xFF)
/*! @name BMI2 Mask definitions of FIFO configuration registers */
#define BMI2_FIFO_CONFIG_0_MASK UINT16_C(0x0003)
#define BMI2_FIFO_CONFIG_1_MASK UINT16_C(0xFF00)
/*! @name FIFO self wake-up mask definition */
#define BMI2_FIFO_SELF_WAKE_UP_MASK UINT8_C(0x02)
/*! @name FIFO down sampling mask definition */
#define BMI2_ACC_FIFO_DOWNS_MASK UINT8_C(0x70)
#define BMI2_GYR_FIFO_DOWNS_MASK UINT8_C(0x07)
/*! @name FIFO down sampling bit positions */
#define BMI2_ACC_FIFO_DOWNS_POS UINT8_C(0x04)
/*! @name FIFO filter mask definition */
#define BMI2_ACC_FIFO_FILT_DATA_MASK UINT8_C(0x80)
#define BMI2_GYR_FIFO_FILT_DATA_MASK UINT8_C(0x08)
/*! @name FIFO filter bit positions */
#define BMI2_ACC_FIFO_FILT_DATA_POS UINT8_C(0x07)
#define BMI2_GYR_FIFO_FILT_DATA_POS UINT8_C(0x03)
/*! @name FIFO byte counter mask definition */
#define BMI2_FIFO_BYTE_COUNTER_MSB_MASK UINT8_C(0x3F)
/*! @name FIFO self wake-up bit positions */
#define BMI2_FIFO_SELF_WAKE_UP_POS UINT8_C(0x01)
/*! @name Mask Definitions for Virtual FIFO frames */
#define BMI2_FIFO_VIRT_FRM_MODE_MASK UINT8_C(0xC0)
#define BMI2_FIFO_VIRT_PAYLOAD_MASK UINT8_C(0x3C)
/*! @name Bit Positions for Virtual FIFO frames */
#define BMI2_FIFO_VIRT_FRM_MODE_POS UINT8_C(0x06)
#define BMI2_FIFO_VIRT_PAYLOAD_POS UINT8_C(0x02)
/******************************************************************************/
/*! @name Interrupt Macro Definitions */
/******************************************************************************/
/*! @name BMI2 Interrupt Modes */
/* Non latched */
#define BMI2_INT_NON_LATCH UINT8_C(0)
/* Permanently latched */
#define BMI2_INT_LATCH UINT8_C(1)
/*! @name BMI2 Interrupt Pin Behavior */
#define BMI2_INT_PUSH_PULL UINT8_C(0)
#define BMI2_INT_OPEN_DRAIN UINT8_C(1)
/*! @name BMI2 Interrupt Pin Level */
#define BMI2_INT_ACTIVE_LOW UINT8_C(0)
#define BMI2_INT_ACTIVE_HIGH UINT8_C(1)
/*! @name BMI2 Interrupt Output Enable */
#define BMI2_INT_OUTPUT_DISABLE UINT8_C(0)
#define BMI2_INT_OUTPUT_ENABLE UINT8_C(1)
/*! @name BMI2 Interrupt Input Enable */
#define BMI2_INT_INPUT_DISABLE UINT8_C(0)
#define BMI2_INT_INPUT_ENABLE UINT8_C(1)
/*! @name Mask definitions for interrupt pin configuration */
#define BMI2_INT_LATCH_MASK UINT8_C(0x01)
#define BMI2_INT_LEVEL_MASK UINT8_C(0x02)
#define BMI2_INT_OPEN_DRAIN_MASK UINT8_C(0x04)
#define BMI2_INT_OUTPUT_EN_MASK UINT8_C(0x08)
#define BMI2_INT_INPUT_EN_MASK UINT8_C(0x10)
/*! @name Bit position definitions for interrupt pin configuration */
#define BMI2_INT_LEVEL_POS UINT8_C(0x01)
#define BMI2_INT_OPEN_DRAIN_POS UINT8_C(0x02)
#define BMI2_INT_OUTPUT_EN_POS UINT8_C(0x03)
#define BMI2_INT_INPUT_EN_POS UINT8_C(0x04)
/*! @name Mask definitions for data interrupt mapping */
#define BMI2_FFULL_INT UINT8_C(0x01)
#define BMI2_FWM_INT UINT8_C(0x02)
#define BMI2_DRDY_INT UINT8_C(0x04)
#define BMI2_ERR_INT UINT8_C(0x08)
/*! @name Mask definitions for data interrupt status bits */
#define BMI2_FFULL_INT_STATUS_MASK UINT16_C(0x0100)
#define BMI2_FWM_INT_STATUS_MASK UINT16_C(0x0200)
#define BMI2_ERR_INT_STATUS_MASK UINT16_C(0x0400)
#define BMI2_AUX_DRDY_INT_MASK UINT16_C(0x2000)
#define BMI2_GYR_DRDY_INT_MASK UINT16_C(0x4000)
#define BMI2_ACC_DRDY_INT_MASK UINT16_C(0x8000)
/*! @name Maximum number of interrupt pins */
#define BMI2_INT_PIN_MAX_NUM UINT8_C(2)
/*! @name Macro for mapping feature interrupts */
#define BMI2_FEAT_BIT_DISABLE UINT8_C(0)
#define BMI2_FEAT_BIT0 UINT8_C(1)
#define BMI2_FEAT_BIT1 UINT8_C(2)
#define BMI2_FEAT_BIT2 UINT8_C(3)
#define BMI2_FEAT_BIT3 UINT8_C(4)
#define BMI2_FEAT_BIT4 UINT8_C(5)
#define BMI2_FEAT_BIT5 UINT8_C(6)
#define BMI2_FEAT_BIT6 UINT8_C(7)
#define BMI2_FEAT_BIT7 UINT8_C(8)
#define BMI2_FEAT_BIT_MAX UINT8_C(9)
/******************************************************************************/
/*! @name OIS Interface Macro Definitions */
/******************************************************************************/
/*! @name Mask definitions for interface configuration register */
#define BMI2_SPI3_MODE_MASK UINT8_C(0x01)
#define BMI2_SPI3_OIS_MASK UINT8_C(0x02)
#define BMI2_OIS_IF_EN_MASK UINT8_C(0x10)
#define BMI2_AUX_IF_EN_MASK UINT8_C(0x20)
/*! @name Bit positions for OIS interface enable */
#define BMI2_SPI3_MODE_POS UINT8_C(0x00)
#define BMI2_SPI3_OIS_POS UINT8_C(0x01)
#define BMI2_OIS_IF_EN_POS UINT8_C(0x04)
#define BMI2_AUX_IF_EN_POS UINT8_C(0x05)
/******************************************************************************/
/*! @name Macro Definitions for Axes re-mapping */
/******************************************************************************/
/*! @name Macros for the user-defined values of axes and their polarities */
#define BMI2_X UINT8_C(0x01)
#define BMI2_NEG_X UINT8_C(0x09)
#define BMI2_Y UINT8_C(0x02)
#define BMI2_NEG_Y UINT8_C(0x0A)
#define BMI2_Z UINT8_C(0x04)
#define BMI2_NEG_Z UINT8_C(0x0C)
#define BMI2_AXIS_MASK UINT8_C(0x07)
#define BMI2_AXIS_SIGN UINT8_C(0x08)
/******************************************************************************/
/*! @name Macro Definitions for offset and gain compensation */
/******************************************************************************/
/*! @name Mask definitions of gyroscope offset compensation registers */
#define BMI2_GYR_GAIN_EN_MASK UINT8_C(0x80)
#define BMI2_GYR_OFF_COMP_EN_MASK UINT8_C(0x40)
/*! @name Bit positions of gyroscope offset compensation registers */
#define BMI2_GYR_OFF_COMP_EN_POS UINT8_C(0x06)
/*! @name Mask definitions of gyroscope user-gain registers */
#define BMI2_GYR_USR_GAIN_X_MASK UINT8_C(0x7F)
#define BMI2_GYR_USR_GAIN_Y_MASK UINT8_C(0x7F)
#define BMI2_GYR_USR_GAIN_Z_MASK UINT8_C(0x7F)
/*! @name Bit positions of gyroscope offset compensation registers */
#define BMI2_GYR_GAIN_EN_POS UINT8_C(0x07)
/******************************************************************************/
/*! @name Macro Definitions for internal status */
/******************************************************************************/
#define BMI2_NOT_INIT UINT8_C(0x00)
#define BMI2_INIT_OK UINT8_C(0x01)
#define BMI2_INIT_ERR UINT8_C(0x02)
#define BMI2_DRV_ERR UINT8_C(0x03)
#define BMI2_SNS_STOP UINT8_C(0x04)
#define BMI2_NVM_ERROR UINT8_C(0x05)
#define BMI2_START_UP_ERROR UINT8_C(0x06)
#define BMI2_COMPAT_ERROR UINT8_C(0x07)
#define BMI2_VFM_SKIPPED UINT8_C(0x10)
#define BMI2_AXES_MAP_ERROR UINT8_C(0x20)
#define BMI2_ODR_50_HZ_ERROR UINT8_C(0x40)
#define BMI2_ODR_HIGH_ERROR UINT8_C(0x80)
/******************************************************************************/
/*! @name error status form gyro gain update status. */
/******************************************************************************/
#define BMI2_G_TRIGGER_NO_ERROR UINT8_C(0x00)
#define BMI2_G_TRIGGER_PRECON_ERROR UINT8_C(0x01)
#define BMI2_G_TRIGGER_DL_ERROR UINT8_C(0x02)
#define BMI2_G_TRIGGER_ABORT_ERROR UINT8_C(0x03)
/******************************************************************************/
/*! @name Variant specific features selection macros */
/******************************************************************************/
#define BMI2_CRT_RTOSK_ENABLE UINT8_C(0x01)
#define BMI2_GYRO_CROSS_SENS_ENABLE UINT8_C(0x02)
#define BMI2_GYRO_USER_GAIN_ENABLE UINT8_C(0x08)
#define BMI2_NO_FEATURE_ENABLE UINT8_C(0x00)
#define BMI2_CRT_IN_FIFO_NOT_REQ UINT8_C(0x10)
#define BMI2_MAXIMUM_FIFO_VARIANT UINT8_C(0x20)
/*! Pull-up configuration for ASDA */
#define BMI2_ASDA_PUPSEL_OFF UINT8_C(0x00)
#define BMI2_ASDA_PUPSEL_40K UINT8_C(0x01)
#define BMI2_ASDA_PUPSEL_10K UINT8_C(0x02)
#define BMI2_ASDA_PUPSEL_2K UINT8_C(0x03)
/******************************************************************************/
/*! @name Function Pointers */
/******************************************************************************/
/*!
* @brief Bus communication function pointer which should be mapped to
* the platform specific read functions of the user
*
* @param[in] reg_addr : Register address from which data is read.
* @param[out] reg_data : Pointer to data buffer where read data is stored.
* @param[in] len : Number of bytes of data to be read.
* @param[in, out] intf_ptr : Void pointer that can enable the linking of descriptors
* for interface related call backs.
*
* retval = BMA4_INTF_RET_SUCCESS -> Success
* retval != BMA4_INTF_RET_SUCCESS -> Failure
*
*/
typedef BMI2_INTF_RETURN_TYPE (*bmi2_read_fptr_t)(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, void *intf_ptr);
/*!
* @brief Bus communication function pointer which should be mapped to
* the platform specific write functions of the user
*
* @param[in] reg_addr : Register address to which the data is written.
* @param[in] reg_data : Pointer to data buffer in which data to be written
* is stored.
* @param[in] len : Number of bytes of data to be written.
* @param[in, out] intf_ptr : Void pointer that can enable the linking of descriptors
* for interface related call backs
*
* retval = BMA4_INTF_RET_SUCCESS -> Success
* retval != BMA4_INTF_RET_SUCCESS -> Failure
*
*/
typedef BMI2_INTF_RETURN_TYPE (*bmi2_write_fptr_t)(uint8_t reg_addr, const uint8_t *reg_data, uint32_t len,
void *intf_ptr);
/*!
* @brief Delay function pointer which should be mapped to
* delay function of the user
*
* @param[in] period : Delay in microseconds.
* @param[in, out] intf_ptr : Void pointer that can enable the linking of descriptors
* for interface related call backs
*
*/
typedef void (*bmi2_delay_fptr_t)(uint32_t period, void *intf_ptr);
/*!
* @brief To get the configurations for wake_up feature, since wakeup feature is different for bmi260 and bmi261.
*
* @param[out] wake_up : Void pointer to store bmi2_wake_up_config structure.
* @param[in, out] bmi2_dev : Void pointer to store bmi2_dev structure.
*
* @return Result of API execution status
*
* @retval BMI2_OK - Success.
* @retval BMI2_E_COM_FAIL - Error: Communication fail
* @retval BMI2_E_NULL_PTR - Error: Null pointer error
* @retval BMI2_E_INVALID_PAGE - Error: Invalid Page
*
*/
typedef int8_t (*bmi2_wake_up_fptr_t)(void *wake_up, void *bmi2_dev);
/*!
* @brief To get the configurations for tap feature.
*
* @param[out] tap : Void pointer to store bmi2_tap_config structure.
* @param[in, out] bmi2_dev : Void pointer to store bmi2_dev structure.
*
* @return Result of API execution status
*
* @retval BMI2_OK - Success.
* @retval BMI2_E_COM_FAIL - Error: Communication fail
* @retval BMI2_E_NULL_PTR - Error: Null pointer error
* @retval BMI2_E_INVALID_PAGE - Error: Invalid Page
*
*/
typedef int8_t (*bmi2_tap_fptr_t)(void *tap, void *bmi2_dev);
/******************************************************************************/
/*! @name Enum Declarations */
/******************************************************************************/
/*! @name Enum to define BMI2 sensor interfaces */
enum bmi2_intf {
BMI2_SPI_INTF = 0,
BMI2_I2C_INTF,
BMI2_I3C_INTF
};
/*! @name Enum to define BMI2 sensor configuration errors for accelerometer
* and gyroscope
*/
enum bmi2_sensor_config_error {
BMI2_NO_ERROR,
BMI2_ACC_ERROR,
BMI2_GYR_ERROR,
BMI2_ACC_GYR_ERROR
};
/*! @name Enum to define interrupt lines */
enum bmi2_hw_int_pin {
BMI2_INT_NONE,
BMI2_INT1,
BMI2_INT2,
BMI2_INT_BOTH,
BMI2_INT_PIN_MAX
};
/*! @name Enum for the position of the wearable device */
enum bmi2_wear_arm_pos {
BMI2_ARM_LEFT,
BMI2_ARM_RIGHT
};
/*! @name Enum to display type of activity recognition */
enum bmi2_act_recog_type {
BMI2_ACT_UNKNOWN,
BMI2_ACT_STILL,
BMI2_ACT_WALK,
BMI2_ACT_RUN,
BMI2_ACT_BIKE,
BMI2_ACT_VEHICLE,
BMI2_ACT_TILTED
};
/*! @name Enum to display activity recognition status */
enum bmi2_act_recog_stat {
BMI2_ACT_START = 1,
BMI2_ACT_END
};
/******************************************************************************/
/*! @name Structure Declarations */
/******************************************************************************/
/*! @name Structure to store the compensated user-gain data of gyroscope */
struct bmi2_gyro_user_gain_data
{
/*! x-axis */
int8_t x;
/*! y-axis */
int8_t y;
/*! z-axis */
int8_t z;
};
/*! @name Structure to store the re-mapped axis */
struct bmi2_remap
{
/*! Re-mapped x-axis */
uint8_t x;
/*! Re-mapped y-axis */
uint8_t y;
/*! Re-mapped z-axis */
uint8_t z;
};
/*! @name Structure to store the value of re-mapped axis and its sign */
struct bmi2_axes_remap
{
/*! Re-mapped x-axis */
uint8_t x_axis;
/*! Re-mapped y-axis */
uint8_t y_axis;
/*! Re-mapped z-axis */
uint8_t z_axis;
/*! Re-mapped x-axis sign */
uint8_t x_axis_sign;
/*! Re-mapped y-axis sign */
uint8_t y_axis_sign;
/*! Re-mapped z-axis sign */
uint8_t z_axis_sign;
};
/*! @name Structure to define the type of sensor and its interrupt pin */
struct bmi2_sens_int_config
{
/*! Defines the type of sensor */
uint8_t type;
/*! Type of interrupt pin */
enum bmi2_hw_int_pin hw_int_pin;
};
/*! @name Structure to define output for activity recognition */
struct bmi2_act_recog_output
{
/*! Time stamp */
uint32_t time_stamp;
/*! current activity */
uint8_t curr_act;
/*! previous activity */
uint8_t prev_act;
};
/*! @name Structure to define FIFO frame configuration */
struct bmi2_fifo_frame
{
/*! Pointer to FIFO data */
uint8_t *data;
/*! Number of user defined bytes of FIFO to be read */
uint16_t length;
/*! Defines header/header-less mode */
uint8_t header_enable;
/*! Enables type of data to be streamed - accelerometer, auxiliary or
* gyroscope
*/
uint16_t data_enable;
/*! To index accelerometer bytes */
uint16_t acc_byte_start_idx;
/*! To index activity output bytes */
uint16_t act_recog_byte_start_idx;
/*! To index auxiliary bytes */
uint16_t aux_byte_start_idx;
/*! To index gyroscope bytes */
uint16_t gyr_byte_start_idx;
/*! FIFO sensor time */
uint32_t sensor_time;
/*! Skipped frame count */
uint8_t skipped_frame_count;
/*! Type of data interrupt to be mapped */
uint8_t data_int_map;
/*! Water-mark level for water-mark interrupt */
uint16_t wm_lvl;
/*! Accelerometer frame length */
uint8_t acc_frm_len;
/*! Gyroscope frame length */
uint8_t gyr_frm_len;
/*! Auxiliary frame length */
uint8_t aux_frm_len;
/*! Accelerometer and gyroscope frame length */
uint8_t acc_gyr_frm_len;
/*! Accelerometer and auxiliary frame length */
uint8_t acc_aux_frm_len;
/*! Gyroscope and auxiliary frame length */
uint8_t aux_gyr_frm_len;
/*! Accelerometer, Gyroscope and auxiliary frame length */
uint8_t all_frm_len;
};
/*! @name Structure to define Interrupt pin configuration */
struct bmi2_int_pin_cfg
{
/*! Configure level of interrupt pin */
uint8_t lvl;
/*! Configure behavior of interrupt pin */
uint8_t od;
/*! Output enable for interrupt pin */
uint8_t output_en;
/*! Input enable for interrupt pin */
uint8_t input_en;
};
/*! @name Structure to define interrupt pin type, mode and configurations */
struct bmi2_int_pin_config
{
/*! Interrupt pin type: INT1 or INT2 or BOTH */
uint8_t pin_type;
/*! Latched or non-latched mode*/
uint8_t int_latch;
/*! Structure to define Interrupt pin configuration */
struct bmi2_int_pin_cfg pin_cfg[BMI2_INT_PIN_MAX_NUM];
};
/*! @name Structure to define an array of 8 auxiliary data bytes */
struct bmi2_aux_fifo_data
{
/*! Auxiliary data */
uint8_t data[8];
/*! Sensor time for virtual frames */
uint32_t virt_sens_time;
};
/*! @name Structure to define accelerometer and gyroscope sensor axes and
* sensor time for virtual frames
*/
struct bmi2_sens_axes_data
{
/*! Data in x-axis */
int16_t x;
/*! Data in y-axis */
int16_t y;
/*! Data in z-axis */
int16_t z;
/*! Sensor time for virtual frames */
uint32_t virt_sens_time;
};
/*! @name Structure to define gyroscope saturation status of user gain */
struct bmi2_gyr_user_gain_status
{
/*! Status in x-axis */
uint8_t sat_x;
/*! Status in y-axis */
uint8_t sat_y;
/*! Status in z-axis */
uint8_t sat_z;
/*! G trigger status */
uint8_t g_trigger_status;
};
/*! @name Structure to store the status of gyro self test result */
struct bmi2_gyro_self_test_status
{
/*! gyro self test axes done */
uint8_t gyr_st_axes_done : 1;
/*! status of gyro X-axis self test */
uint8_t gyr_axis_x_ok : 1;
/*! status of gyro Y-axis self test */
uint8_t gyr_axis_y_ok : 1;
/*! status of gyro Z-axis self test */
uint8_t gyr_axis_z_ok : 1;
};
/*! @name Structure to define NVM error status */
struct bmi2_nvm_err_status
{
/*! NVM load action error */
uint8_t load_error;
/*! NVM program action error */
uint8_t prog_error;
/*! NVM erase action error */
uint8_t erase_error;
/*! NVM program limit exceeded */
uint8_t exceed_error;
/*! NVM privilege error */
uint8_t privil_error;
};
/*! @name Structure to define VFRM error status */
struct bmi2_vfrm_err_status
{
/*! VFRM lock acquire error */
uint8_t lock_error;
/*! VFRM write error */
uint8_t write_error;
/*! VFRM fatal err */
uint8_t fatal_error;
};
/*! @name Structure to define accelerometer self test feature status */
struct bmi2_acc_self_test_status
{
/*! Accelerometer test completed */
uint8_t acc_self_test_done;
/*! Bit is set to 1 when accelerometer X-axis test passed */
uint8_t acc_x_ok;
/*! Bit is set to 1 when accelerometer y-axis test passed */
uint8_t acc_y_ok;
/*! Bit is set to 1 when accelerometer z-axis test passed */
uint8_t acc_z_ok;
};
/*! @name Structure to define orientation output */
struct bmi2_orientation_output
{
/*! Orientation portrait landscape */
uint8_t portrait_landscape;
/*! Orientation face-up down */
uint8_t faceup_down;
};
/*! @name Structure to define OIS output */
struct bmi2_ois_output
{
/*! OIS accel x axis */
int16_t ois_acc_x;
/*! OIS accel y axis */
int16_t ois_acc_y;
/*! OIS accel z axis */
int16_t ois_acc_z;
/*! ois gyro x axis */
int16_t ois_gyro_x;
/*! OIS gyro y axis */
int16_t ois_gyro_y;
/*! OIS gyro z axis */
int16_t ois_gyro_z;
};
/*! @name Structure to define BMI2 sensor data */
struct bmi2_sens_data
{
/*! Accelerometer axes data */
struct bmi2_sens_axes_data acc;
/*! Gyroscope axes data */
struct bmi2_sens_axes_data gyr;
/*! Auxiliary sensor data */
uint8_t aux_data[BMI2_AUX_NUM_BYTES];
/*! Sensor time */
uint32_t sens_time;
/*! Status register data */
uint8_t status;
};
/*! @name Structure to define BMI2 DSD data */
struct bmi2_door_state_detector_output
{
/*! Door event output */
uint8_t door_event_output;
/*! Heading output */
int16_t heading_output;
};
/*! @name Union to define BMI2 feature data */
union bmi2_feature_data
{
/*! Step counter output */
uint32_t step_counter_output;
/*! Step activity output */
uint8_t activity_output;
/*! Orientation output */
struct bmi2_orientation_output orient_output;
/*! High-g output */
uint8_t high_g_output;
/*! Gyroscope user gain saturation status */
struct bmi2_gyr_user_gain_status gyro_user_gain_status;
/*! NVM error status */
struct bmi2_nvm_err_status nvm_status;
/*! Virtual frame error status */
struct bmi2_vfrm_err_status vfrm_status;
/*! Wrist gesture output */
uint8_t wrist_gesture_output;
/*! Wrist wear wakeup output */
uint8_t wrist_wear_wakeup_output;
/*! Gyroscope cross sense value of z axis */
int16_t correction_factor_zx;
/*! Accelerometer self test feature status */
struct bmi2_acc_self_test_status accel_self_test_output;
/*! OIS output */
struct bmi2_ois_output ois_output;
/*! DSD output */
struct bmi2_door_state_detector_output door_state_detector_output;
};
/*! @name Structure to define type of sensor and their respective data */
struct bmi2_feat_sensor_data
{
/*! Defines the type of sensor */
uint8_t type;
/*! Defines various sensor data */
union bmi2_feature_data sens_data;
};
/*!
* @brief Structure to define type of sensor and their respective data
*/
struct bmi2_sensor_data
{
/*! Defines the type of sensor */
uint8_t type;
/*! Defines various sensor data */
struct bmi2_sens_data sens_data;
};
/*! @name Structure to define accelerometer configuration */
struct bmi2_accel_config
{
/*! Output data rate in Hz */
uint8_t odr;
/*! Bandwidth parameter */
uint8_t bwp;
/*! Filter performance mode */
uint8_t filter_perf;
/*! g-range */
uint8_t range;
};
/*! @name Structure to define gyroscope configuration */
struct bmi2_gyro_config
{
/*! Output data rate in Hz */
uint8_t odr;
/*! Bandwidth parameter */
uint8_t bwp;
/*! Filter performance mode */
uint8_t filter_perf;
/*! OIS Range */
uint8_t ois_range;
/*! Gyroscope Range */
uint8_t range;
/*! Selects noise performance */
uint8_t noise_perf;
};
/*! @name Structure to define auxiliary sensor configuration */
struct bmi2_aux_config
{
/*! Enable/Disable auxiliary interface */
uint8_t aux_en;
/*! Manual or Auto mode*/
uint8_t manual_en;
/*! Enables FCU write command on auxiliary interface */
uint8_t fcu_write_en;
/*! Read burst length for manual mode */
uint8_t man_rd_burst;
/*! Read burst length for data mode */
uint8_t aux_rd_burst;
/*! Output data rate */
uint8_t odr;
/*! Read-out offset */
uint8_t offset;
/*! I2c address of auxiliary sensor */
uint8_t i2c_device_addr;
/*! Read address of auxiliary sensor */
uint8_t read_addr;
};
/*! @name Structure to define any-motion configuration */
struct bmi2_any_motion_config
{
/*! Duration */
uint16_t duration;
/*! Acceleration slope threshold */
uint16_t threshold;
/*! To select per x-axis */
uint16_t select_x;
/*! To select per y-axis */
uint16_t select_y;
/*! To select per z-axis */
uint16_t select_z;
};
/*! @name Structure to define no-motion configuration */
struct bmi2_no_motion_config
{
/*! Duration */
uint16_t duration;
/*! Acceleration slope threshold */
uint16_t threshold;
/*! To select per x-axis */
uint16_t select_x;
/*! To select per y-axis */
uint16_t select_y;
/*! To select per z-axis */
uint16_t select_z;
};
/*! @name Structure to define sig-motion configuration */
struct bmi2_sig_motion_config
{
/*! Block size */
uint16_t block_size;
};
/*! @name Structure to define EXT TCO configuration */
struct bmi2_ext_tco
{
/*! Enable(1) / Disable(0) hardware compensation. */
uint8_t hw_comp_enable;
};
/*! @name Structure to define step counter/detector/activity configuration */
struct bmi2_step_config
{
/*! Water-mark level */
uint16_t watermark_level;
/*! Reset counter */
uint16_t reset_counter;
/*! Step buffer size */
uint8_t step_buffer_size;
};
/*! @name Structure to define gyroscope user gain configuration */
struct bmi2_gyro_user_gain_config
{
/*! Gain update value for x-axis */
uint16_t ratio_x;
/*! Gain update value for y-axis */
uint16_t ratio_y;
/*! Gain update value for z-axis */
uint16_t ratio_z;
};
/*! @name Structure to define wake-up configuration */
struct bmi2_wake_up_config
{
/*! Wake-up sensitivity */
uint16_t sensitivity;
/*!
* For Single tap, single_tap_en = 1
* For Double tap, single_tap_en = 0
*/
uint16_t single_tap_en;
};
/*! @name Structure to define tap configuration */
struct bmi2_tap_config
{
/*! Enable -> Filtered tap data, Disable -> Unfiltered data */
uint16_t data_reg_en;
/*! Scaling factor of threshold */
uint16_t tap_sens_thres;
/*! Maximum duration between each taps */
uint16_t max_gest_dur;
/*! Minimum quite time between the two gesture detection */
uint16_t quite_time_after_gest;
/*! Wait time */
uint16_t wait_for_timeout;
/*! Axis selection */
uint16_t axis_sel;
};
/*! @name Structure to define orientation configuration */
struct bmi2_orient_config
{
/*! Upside/down detection */
uint16_t ud_en;
/*! Symmetrical, high or low Symmetrical */
uint16_t mode;
/*! Blocking mode */
uint16_t blocking;
/*! Threshold angle */
uint16_t theta;
/*! Acceleration hysteresis for orientation detection */
uint16_t hysteresis;
};
/*! @name Structure to define high-g configuration */
struct bmi2_high_g_config
{
/*! Acceleration threshold */
uint16_t threshold;
/*! Hysteresis */
uint16_t hysteresis;
/*! To select per x-axis */
uint16_t select_x;
/*! To select per y-axis */
uint16_t select_y;
/*! To select per z-axis */
uint16_t select_z;
/*! Duration interval */
uint16_t duration;
};
/*! @name Structure to define low-g configuration */
struct bmi2_low_g_config
{
/*! Acceleration threshold */
uint16_t threshold;
/*! Hysteresis */
uint16_t hysteresis;
/*! Duration interval */
uint16_t duration;
};
/*! @name Structure to define flat configuration */
struct bmi2_flat_config
{
/*! Theta angle for flat detection */
uint16_t theta;
/*! Blocking mode */
uint16_t blocking;
/*! Hysteresis for theta flat detection */
uint16_t hysteresis;
/*! Holds the duration */
uint16_t hold_time;
};
/*! @name Structure to define wrist gesture configuration */
struct bmi2_wrist_gest_config
{
/*! Wearable arm (left or right) */
uint16_t wearable_arm;
/*! Sine of the minimum tilt angle in portrait down direction of the device when wrist is rolled
* away from user. The configuration parameter is scaled by 2048 i.e. 2048 * sin(angle).
* Range is 1448 to 1774. Default value is 1774. */
uint16_t min_flick_peak;
/*! Value of minimum time difference between wrist roll-out and roll-in movement during flick gesture.
* Range is 3 to 5 samples at 50Hz. Default value is 4 (i.e. 0.08 seconds). */
uint16_t min_flick_samples;
/*! Maximum time within which gesture movement has to be completed. Range is 150 to 250 samples at 50Hz.
* Default value is 200 (i.e. 4 seconds). */
uint16_t max_duration;
};
/*! @name Structure to define wrist wear wake-up configuration */
struct bmi2_wrist_wear_wake_up_config
{
/*! Cosine of minimum expected attitude change of the device
* within 1 second time window when moving within focus position.
* The parameter is scaled by 2048 i.e. 2048 * cos(angle).
* Range is 1024 to 1774. Default is 1448.
*/
uint16_t min_angle_focus;
/*! Cosine of minimum expected attitude change of the device
* within 1 second time window when moving from non-focus to focus position.
* The parameter is scaled by 2048 i.e. 2048 * cos(angle).
* Range is 1448 to 1856. Default value is 1774.
*/
uint16_t min_angle_nonfocus;
/*! Sine of the maximum allowed downward tilt angle in
* landscape right direction of the device, when it is in focus position
* (i.e. user is able to comfortably look at the dial of wear device).
* The configuration parameter is scaled by 2048 i.e. 2048 * sin(angle).
* Range is 700 to 1024. Default value is 1024.
*/
uint16_t max_tilt_lr;
/*! Sine of the maximum allowed downward tilt angle in
* landscape left direction of the device, when it is in focus position
* (i.e. user is able to comfortably look at the dial of wear device).
* The configuration parameter is scaled by 2048 i.e. 2048 * sin(angle).
* Range is 700 to 1024. Default value is 700.
*/
uint16_t max_tilt_ll;
/*! Sine of the maximum allowed backward tilt angle in
* portrait down direction of the device, when it is in focus position
* (i.e. user is able to comfortably look at the dial of wear device).
* The configuration parameter is scaled by 2048 i.e. 2048 * sin(angle).
* Range is 0 to179. Default value is 179.
*/
uint16_t max_tilt_pd;
/*! Sine of the maximum allowed forward tilt angle in
* portrait up direction of the device, when it is in focus position
* (i.e. user is able to comfortably look at the dial of wear device).
* The configuration parameter is scaled by 2048 i.e. 2048 * sin(angle).
* Range is 1774 to 1978. Default value is 1925.
*/
uint16_t max_tilt_pu;
};
/*! @name Structure to define wrist wear wake-up configuration for wearable configuration */
struct bmi2_wrist_wear_wake_up_wh_config
{
/*! Cosine of minimum expected attitude change of the device
* within 1 second time window when moving within focus position.
* The parameter is scaled by 2048 i.e. 2048 * cos(angle).
* Range is 1024 to 1774. Default is 1774.
*/
uint16_t min_angle_focus;
/*! Cosine of minimum expected attitude change of the device
* within 1 second time window when moving from non-focus to focus position.
* The parameter is scaled by 2048 i.e. 2048 * cos(angle).
* Range is 1448 to 1856. Default value is 1522.
*/
uint16_t min_angle_nonfocus;
/*! Sine of the maximum allowed tilt angle in
* landscape right direction of the device, when it is in focus position
* (i.e. user is able to comfortably look at the dial of wear device).
* The configuration parameter is scaled by 256 i.e. 256 * sin(angle).
* Range is 88 to 128. Default value is 128.
*/
uint8_t angle_landscape_right;
/*! Sine of the maximum allowed tilt angle in
* landscape left direction of the device, when it is in focus position
* (i.e. user is able to comfortably look at the dial of wear device).
* The configuration parameter is scaled by 256 i.e. 256 * sin(angle).
* Range is 88 to 128. Default value is 128.
*/
uint8_t angle_landscape_left;
/*! Sine of the maximum allowed backward tilt angle in
* portrait down direction of the device, when it is in focus position
* (i.e. user is able to comfortably look at the dial of wear device).
* The configuration parameter is scaled by 256 i.e. 256 * sin(angle).
* Range is 0 to179. Default value is 22.
*/
uint8_t angle_portrait_down;
/*! Sine of the maximum allowed forward tilt angle in
* portrait up direction of the device, when it is in focus position
* (i.e. user is able to comfortably look at the dial of wear device).
* The configuration parameter is scaled by 256 i.e. 256 * sin(angle).
* Range is 222 to 247. Default value is 241.
*/
uint8_t angle_portrait_up;
/*! Minimum duration the arm should be moved while performing gesture.
* Range: 1 to 10, resolution = 20 ms
*/
uint8_t min_dur_moved;
/*! Minimum duration the arm should be static between two consecutive gestures.
* Range: 1 to 10, resolution = 20 ms
*/
uint8_t min_dur_quite;
};
/*! @name Structure to define primary OIS configuration */
struct bmi2_primary_ois_config
{
/*! Low pass filter control */
uint8_t lp_filter_enabled;
/*! Lp filter cut-off frequency */
uint8_t lp_filter_config;
/*! Enable gyroscope on OIS interface in registers
* OIS_DATA_6 till OIS_DATA_11 with minimum group delay at 6.4KHz ODR
*/
uint8_t gyr_en;
/*! Enable accelerometer on OIS interface in registers
* OIS_DATA_0 till OIS_DATA_5 with minimum group delay at 1.6KHz ODR
*/
uint8_t acc_en;
};
/*! @name Structure to configure free-fall detection settings */
struct bmi2_free_fall_det_config
{
/*! free-fall accel settings */
uint16_t freefall_accel_settings[BMI2_FREE_FALL_ACCEL_SET_PARAMS];
};
/*! @name Structure to define wrist gesture configuration for wearable variant */
struct bmi2_wrist_gest_w_config
{
/*! Device in left (0) or right (1) arm.
* By default, the wearable device is assumed to be in left arm
* i.e. default value is 0.
*/
uint8_t device_position;
/*! Minimum threshold for flick peak on y-axis */
uint16_t min_flick_peak_y_threshold;
/*! Minimum threshold for flick peak on z-axis */
uint16_t min_flick_peak_z_threshold;
/*! Maximum expected value of positive gravitational acceleration on x-axis
* when arm is in focus pose */
uint16_t gravity_bounds_x_pos;
/*! Maximum expected value of negative gravitational acceleration on x-axis
* when arm is in focus pose */
uint16_t gravity_bounds_x_neg;
/*! Maximum expected value of negative gravitational acceleration on y-axis
* when arm is in focus pose */
uint16_t gravity_bounds_y_neg;
/*! Maximum expected value of negative gravitational acceleration on z-axis
* when arm is in focus pose */
uint16_t gravity_bounds_z_neg;
/*! Exponential smoothing coefficient for adaptive peak threshold decay */
uint16_t flick_peak_decay_coeff;
/*! Exponential smoothing coefficient for acceleration mean estimation */
uint16_t lp_mean_filter_coeff;
/*! Maximum duration between 2 peaks of jiggle in samples @50Hz */
uint16_t max_duration_jiggle_peaks;
};
/*! @name Structure to configure Laptop position recognition settings for bmi260lpd */
struct bmi2_lpd_config
{
/*! Sets the bit for filtered data enable */
uint8_t flit_data_en;
/*! lpd enable bit */
uint8_t lpd_enable;
/*! Sets angle for portrait oriented in bag cases */
uint8_t portrait_theta;
/*! Sets Hysteresis for portrait oriented in bag theta detection */
uint8_t portrait_hysteresis;
/*! Sets angle for landscape oriented in bag cases */
uint8_t landscape_theta;
/*! Sets Hysteresis for landscape oriented in bag theta detection */
uint8_t landscape_hysteresis;
/*! Sets angle for flat oriented in bag cases */
uint8_t flat_posture_theta;
/*! Sets Hysteresis for landscape oriented in bag theta detection */
uint8_t flat_posture_hysteresis;
/*! Sets blocking mode, if blocking mode is set no interrupt will be triggered */
uint8_t blocking_mode;
/*! Sets the hold time for which the condition has to be respected */
uint8_t hold_time;
/*! Sets threshold slope for block mode conditions */
uint8_t blockingslope_thres;
/*! Segment size for which the predictors are computed on */
uint16_t segment_size;
/* Post processing enable for the lap status detected */
uint8_t post_processing_enable;
/* Minimum threshold of the Gini's diversity index for accepting position */
uint16_t mingdithreshold;
/* Maximum threshold of the Gini's diversity index for rejecting position */
uint16_t maxgdithreshold;
/* Buffer size for the post processing of the position detected */
uint8_t output_buffersize;
/* Minimum segments classified with moderate confidence as belonging to certain position */
uint16_t minseg_moderateconf;
};
/*! @name Structure to configure wrist gesture configuration */
struct bmi2_wrist_gesture_config
{
/* Minimum threshold for flick peak on y-axis */
uint16_t min_flick_peak_y_threshold;
/* Minimum threshold for flick peak on z-axis */
uint16_t min_flick_peak_z_threshold;
/* Maximum expected value of positive gravitational acceleration on x-axis when arm is in focus pose */
uint16_t gravity_bounds_x_pos;
/* Maximum expected value of negative gravitational acceleration on x-axis when arm is in focus pose */
uint16_t gravity_bounds_x_neg;
/* Maximum expected value of negaitive gravitational acceleration on y-axis when arm is in focus pose */
uint16_t gravity_bounds_y_neg;
/* Maximum expected value of negaitive gravitational acceleration on z-axis when arm is in focus pose */
uint16_t gravity_bounds_z_neg;
/* Exponential smoothing coefficient for adaptive peak threshold decay */
uint16_t flick_peak_decay_coeff;
/* Exponential smoothing coefficient for acceleration mean estimation */
uint16_t lp_mean_filter_coeff;
/* Maximum duration between 2 peaks of jiggle in samples */
uint16_t max_duration_jiggle_peaks;
/* Device in left (0) or right (1) arm. By default, the wearable device is assumed to be in left arm i.e. default
* value is 0. */
uint16_t device_position;
};
/*! @name Structure to define door state detector configuration */
struct bmi2_door_state_detector_config
{
/*! DSD feature enable/disable */
uint8_t dsd_enable;
/*! Axis remap status */
uint8_t remap_flag;
/*! Map the desired axis sign to z axis */
uint8_t z_sign;
/*! Map the desired axis to z axis */
uint8_t z_axis;
/*! Initial calibration threshold */
uint8_t init_calib_thr;
/*! Manual reset enable */
uint8_t reset_enable_flag;
/*! Value of lower word of bias_x */
int32_t bias_x_low_word;
/*! Value of higher word of bias_x */
int32_t bias_x_high_word;
/*! Value of lower word of bias_y */
int32_t bias_y_low_word;
/*! Value of higher word of bias_y */
int32_t bias_y_high_word;
/* Value of lower word of bias_z */
int32_t bias_z_low_word;
/*! Value of higher word of bias_z */
int32_t bias_z_high_word;
};
/*! @name Union to define the sensor configurations */
union bmi2_sens_config_types
{
/*! Accelerometer configuration */
struct bmi2_accel_config acc;
/*! Gyroscope configuration */
struct bmi2_gyro_config gyr;
/*! Auxiliary configuration */
struct bmi2_aux_config aux;
/*! Any-motion configuration */
struct bmi2_any_motion_config any_motion;
/*! No-motion configuration */
struct bmi2_no_motion_config no_motion;
/*! Sig_motion configuration */
struct bmi2_sig_motion_config sig_motion;
/*! EXT TCO configuration */
struct bmi2_ext_tco ext_tco;
/*! Step counter parameter configuration */
uint16_t step_counter_params[BMI2_STEP_CNT_N_PARAMS];
/*! Step counter/detector/activity configuration */
struct bmi2_step_config step_counter;
/*! Gyroscope user gain configuration */
struct bmi2_gyro_user_gain_config gyro_gain_update;
/*! Wake-up configuration */
struct bmi2_wake_up_config wake_up_conf;
/*! Tap configuration */
struct bmi2_tap_config tap_conf;
/*! Orientation configuration */
struct bmi2_orient_config orientation;
/*! High-g configuration */
struct bmi2_high_g_config high_g;
/*! Low-g configuration */
struct bmi2_low_g_config low_g;
/*! Flat configuration */
struct bmi2_flat_config flat;
/*! Wrist gesture configuration */
struct bmi2_wrist_gest_config wrist_gest;
/*! Wrist wear wake-up configuration */
struct bmi2_wrist_wear_wake_up_config wrist_wear_wake_up;
/*! Wrist gesture configuration for wearable variant */
struct bmi2_wrist_gest_w_config wrist_gest_w;
/*! Wrist wear wake-up configuration for wearable variant */
struct bmi2_wrist_wear_wake_up_wh_config wrist_wear_wake_up_wh;
/*! Primary OIS configuration */
struct bmi2_primary_ois_config primary_ois;
/*! Free-fall detection configurations */
struct bmi2_free_fall_det_config free_fall_det;
/*! Laptop position detection configurations */
struct bmi2_lpd_config lap_pos_det;
/*! Structure to configure wrist gesture configurations */
struct bmi2_wrist_gesture_config wrist_g_config;
/*! Structure to configure door state detector */
struct bmi2_door_state_detector_config door_state_detector;
};
/*! @name Structure to define the type of the sensor and its configurations */
struct bmi2_sens_config
{
/*! Defines the type of sensor */
uint8_t type;
/*! Defines various sensor configurations */
union bmi2_sens_config_types cfg;
};
/*! @name Structure to define the feature configuration */
struct bmi2_feature_config
{
/*! Defines the type of sensor */
uint8_t type;
/*! Page to where the feature is mapped */
uint8_t page;
/*! Address of the feature */
uint8_t start_addr;
};
/*! @name Structure to define the feature interrupt configurations */
struct bmi2_map_int
{
/*! Defines the type of sensor */
uint8_t type;
/*! Defines the feature interrupt */
uint8_t sens_map_int;
};
/*! @name Structure to define BMI2 sensor configurations */
struct bmi2_dev
{
/*! Chip id of BMI2 */
uint8_t chip_id;
/*! The interface pointer is used to enable the user
* to link their interface descriptors for reference during the
* implementation of the read and write interfaces to the
* hardware.
*/
void *intf_ptr;
/*! To store warnings */
uint8_t info;
/*! Type of Interface */
enum bmi2_intf intf;
/*! To store interface pointer error */
BMI2_INTF_RETURN_TYPE intf_rslt;
/*! For switching from I2C to SPI */
uint8_t dummy_byte;
/*! Resolution for FOC */
uint8_t resolution;
/*! User set read/write length */
uint16_t read_write_len;
/*! Store load status value */
uint8_t load_status;
/*! Pointer to the configuration data buffer address */
const uint8_t *config_file_ptr;
/*! To define maximum page number */
uint8_t page_max;
/*! To define maximum number of input sensors/features */
uint8_t input_sens;
/*! To define maximum number of output sensors/features */
uint8_t out_sens;
/*! Indicate manual enable for auxiliary communication */
uint8_t aux_man_en;
/*! Defines manual read burst length for auxiliary communication */
uint8_t aux_man_rd_burst_len;
/*! Array of feature input configuration structure */
const struct bmi2_feature_config *feat_config;
/*! Array of feature output configuration structure */
const struct bmi2_feature_config *feat_output;
/*! Structure to maintain a copy of the re-mapped axis */
struct bmi2_axes_remap remap;
/*! Flag to hold enable status of sensors */
uint64_t sens_en_stat;
/*! Read function pointer */
bmi2_read_fptr_t read;
/*! Write function pointer */
bmi2_write_fptr_t write;
/*! Delay function pointer */
bmi2_delay_fptr_t delay_us;
/*! To store the gyroscope cross sensitivity value */
int16_t gyr_cross_sens_zx;
/* gyro enable status, used as a flag in CRT enabling and aborting */
uint8_t gyro_en : 1;
/* advance power saving mode status, used as a flag in CRT enabling and aborting */
uint8_t aps_status;
/* used as a flag to enable variant specific features like crt */
uint16_t variant_feature;
/* To store hold the size of config file */
uint16_t config_size;
/*! Function pointer to get wakeup configurations */
bmi2_wake_up_fptr_t get_wakeup_config;
/*! Function pointer to set wakeup configurations */
bmi2_wake_up_fptr_t set_wakeup_config;
/*! Function pointer to get tap configurations */
bmi2_tap_fptr_t get_tap_config;
/*! Function pointer to set tap configurations */
bmi2_tap_fptr_t set_tap_config;
/*! Array of feature interrupts configuration structure */
struct bmi2_map_int *map_int;
/*! To define maximum number of interrupts */
uint8_t sens_int_map;
};
/*! @name Structure to enable an accel axis for foc */
struct bmi2_accel_foc_g_value
{
/*! '0' to disable x axis and '1' to enable x axis */
uint8_t x;
/*! '0' to disable y axis and '1' to enable y axis */
uint8_t y;
/*! '0' to disable z axis and '1' to enable z axis */
uint8_t z;
/*! '0' for positive input and '1' for negative input */
uint8_t sign;
};
/*! @name Structure to configure activity recognition settings */
struct bmi2_act_recg_sett
{
/*! Enable/Disable post processing of the activity detected by the classifier */
uint8_t pp_en;
/*! Minimum threshold of the Gini's diversity index (GDI) for
* accepting and adding activity detected by the classifier to activity buffer
*/
uint16_t min_gdi_thres;
/*! Maximum threshold of the Gini's diversity index (GDI) for
* rejecting the activity detected by the classifier
*/
uint16_t max_gdi_thres;
/*! Buffer size for post processing of the activity detected by the classifier */
uint8_t buf_size;
/*! Minimum segments classified with moderate confidence as belonging
* to a certain activity type to be added to activity buffer.
*/
uint8_t min_seg_conf;
};
/*! @name Structure to configure activity recognition settings for bmi270hc */
struct bmi2_hc_act_recg_sett
{
/*! Static segment size for activity classification. */
uint8_t segment_size;
/*! Enable/Disable post processing of the activity detected */
uint8_t pp_en;
/*! Minimum threshold of the Gini's diversity index (GDI) */
uint16_t min_gdi_thres;
/*! Maximum threshold of the Gini's diversity index (GDI) */
uint16_t max_gdi_thres;
/*! Buffer size for post processing of the activity detected */
uint16_t buf_size;
/*! Minimum segments belonging to a certain activity type */
uint16_t min_seg_conf;
};
#endif /* BMI2_DEFS_H_ */
/**
* Copyright (c) 2023 Bosch Sensortec GmbH. All rights reserved.
*
* BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @file bmi2_ois.c
* @date 2023-05-03
* @version v2.86.1
*
*/
/******************************************************************************/
/*! @name Header Files */
/******************************************************************************/
#include "bmi2_ois.h"
/******************************************************************************/
/*! Local Function Prototypes
******************************************************************************/
/*!
* @brief This internal API gets the OIS accelerometer and the gyroscope data.
*
* @param[out] ois_data : Structure instance of bmi2_sens_axes_data.
* @param[in] reg_addr : Register address where data is stored.
* @param[in] ois_dev : Structure instance of bmi2_ois_dev.
* @param[in] ois_gyr_cross_sens_zx :"gyroscope cross sensitivity value which was calculated during
* bmi2xy_init(), refer the example ois_accel_gyro.c for more info"
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
static int8_t get_ois_acc_gyr_data(struct bmi2_ois_sens_axes_data *ois_data,
uint8_t reg_addr,
struct bmi2_ois_dev *ois_dev,
int16_t ois_gyr_cross_sens_zx);
/*!
* @brief This internal API is used to validate the OIS device pointer for null
* conditions.
*
* @param[in] ois_dev : Structure instance of bmi2_ois_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
static int8_t null_ptr_check(const struct bmi2_ois_dev *ois_dev);
/*!
* @brief This internal API corrects the gyroscope cross-axis sensitivity
* between the z and the x axis.
*
* @param[in] ois_dev : Structure instance of bmi2_ois_dev.
* @param[in] ois_gyr_cross_sens_zx : "gyroscope cross sensitivity value which was calculated during bmi2xy_init(),
* refer the example ois_accel_gyro.c for more info"
*
*/
static void comp_gyro_cross_axis_sensitivity(struct bmi2_ois_sens_axes_data *ois_data, int16_t ois_gyr_cross_sens_zx);
/******************************************************************************/
/*! @name User Interface Definitions */
/******************************************************************************/
/*!
* @brief This API reads the data from the given OIS register address of bmi2
* sensor.
*/
int8_t bmi2_ois_get_regs(uint8_t ois_reg_addr, uint8_t *ois_reg_data, uint16_t data_len, struct bmi2_ois_dev *ois_dev)
{
/* Variable to define error */
int8_t rslt;
/* Variable to define dummy byte for SPI read */
uint8_t dummy_byte = 1;
/* Variable to define temporary length */
uint16_t temp_len = data_len + dummy_byte;
/* Variable to define temporary buffer */
uint8_t temp_buf[temp_len];
/* Variable to index bytes read */
uint16_t index = 0;
/* Null-pointer check */
rslt = null_ptr_check(ois_dev);
if ((rslt == BMI2_OIS_OK) && (ois_reg_data != NULL))
{
/* Configuring reg_addr for SPI Interface */
ois_reg_addr = (ois_reg_addr | BMI2_OIS_SPI_RD_MASK);
/* Read from OIS register through OIS interface */
ois_dev->intf_rslt = ois_dev->ois_read(ois_reg_addr, temp_buf, temp_len, ois_dev->intf_ptr);
if (ois_dev->intf_rslt == BMI2_INTF_RET_SUCCESS)
{
/* Read the data from the position next to dummy byte */
while (index < data_len)
{
ois_reg_data[index] = temp_buf[index + dummy_byte];
index++;
}
}
else
{
rslt = BMI2_OIS_E_COM_FAIL;
}
}
else
{
rslt = BMI2_OIS_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This API writes data to the given OIS register address of bmi2 sensor.
*/
int8_t bmi2_ois_set_regs(uint8_t ois_reg_addr,
const uint8_t *ois_reg_data,
uint16_t data_len,
struct bmi2_ois_dev *ois_dev)
{
/* Variable to define error */
int8_t rslt;
/* Null-pointer check */
rslt = null_ptr_check(ois_dev);
if ((rslt == BMI2_OIS_OK) && (ois_reg_data != NULL))
{
/* Configuring reg_addr for SPI Interface */
ois_reg_addr = (ois_reg_addr & BMI2_OIS_SPI_WR_MASK);
/* Burst write to OIS register through OIS interface */
ois_dev->intf_rslt = ois_dev->ois_write(ois_reg_addr, ois_reg_data, data_len, ois_dev->intf_ptr);
if (ois_dev->intf_rslt != BMI2_INTF_RET_SUCCESS)
{
rslt = BMI2_OIS_E_COM_FAIL;
}
}
else
{
rslt = BMI2_OIS_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This API enables/disables accelerometer/gyroscope data read through
* OIS interface.
*/
int8_t bmi2_ois_set_config(struct bmi2_ois_dev *ois_dev)
{
/* Variable to define error */
int8_t rslt;
/* Variable to store data */
uint8_t reg_data = 0;
/* Null-pointer check */
rslt = null_ptr_check(ois_dev);
if (rslt == BMI2_OIS_OK)
{
rslt = bmi2_ois_get_regs(BMI2_OIS_CONFIG_ADDR, &reg_data, 1, ois_dev);
if (rslt == BMI2_OIS_OK)
{
/* Enable/Disable Low pass filter */
reg_data = BMI2_SET_BIT_POS0(reg_data, BMI2_OIS_LP_FILTER_EN, ois_dev->lp_filter_en);
/* Configures Low pass filter cut-off frequency */
reg_data = BMI2_OIS_SET_BITS(reg_data, BMI2_OIS_LP_FILTER_CONFIG, ois_dev->lp_filter_config);
/* Low pass filter - mute on secondary interface */
reg_data = BMI2_OIS_SET_BITS(reg_data, BMI2_OIS_LP_FILTER_MUTE, ois_dev->lp_filter_mute);
/* Enable/Disable ois on accelerometer */
reg_data = BMI2_OIS_SET_BITS(reg_data, BMI2_OIS_ACC_EN, ois_dev->acc_en);
/* Enable/Disable ois on gyroscope */
reg_data = BMI2_OIS_SET_BITS(reg_data, BMI2_OIS_GYR_EN, ois_dev->gyr_en);
/* Set the OIS configurations */
rslt = bmi2_ois_set_regs(BMI2_OIS_CONFIG_ADDR, &reg_data, 1, ois_dev);
}
}
return rslt;
}
/*!
* @brief This API gets the status of accelerometer/gyroscope enable for data
* read through OIS interface.
*/
int8_t bmi2_ois_get_config(struct bmi2_ois_dev *ois_dev)
{
/* Variable to define error */
int8_t rslt;
/* Variable to store data */
uint8_t reg_data = 0;
/* Null-pointer check */
rslt = null_ptr_check(ois_dev);
if (rslt == BMI2_OIS_OK)
{
rslt = bmi2_ois_get_regs(BMI2_OIS_CONFIG_ADDR, &reg_data, 1, ois_dev);
if (rslt == BMI2_OIS_OK)
{
/* Get the status of Low pass filter enable */
ois_dev->lp_filter_en = BMI2_GET_BIT_POS0(reg_data, BMI2_OIS_LP_FILTER_EN);
/* Get the status of Low pass filter cut-off frequency */
ois_dev->lp_filter_config = BMI2_OIS_GET_BITS(reg_data, BMI2_OIS_LP_FILTER_CONFIG);
/* Get the status of Low pass filter mute */
ois_dev->lp_filter_mute = BMI2_OIS_GET_BITS(reg_data, BMI2_OIS_LP_FILTER_MUTE);
/* Get the status of accelerometer enable */
ois_dev->acc_en = BMI2_OIS_GET_BITS(reg_data, BMI2_OIS_ACC_EN);
/* Get the status of gyroscope enable */
ois_dev->gyr_en = BMI2_OIS_GET_BITS(reg_data, BMI2_OIS_GYR_EN);
}
}
return rslt;
}
/*!
* @brief This API reads accelerometer/gyroscope data through OIS interface.
*/
int8_t bmi2_ois_read_data(const uint8_t *sens_sel,
uint8_t n_sens,
struct bmi2_ois_dev *ois_dev,
int16_t gyr_cross_sens_zx)
{
/* Variable to define error */
int8_t rslt;
/* Variable to define loop */
uint8_t loop = 0;
/* Variable to update register address */
uint8_t reg_addr = 0;
/* Null-pointer check */
rslt = null_ptr_check(ois_dev);
if ((rslt == BMI2_OIS_OK) && (sens_sel != NULL))
{
for (loop = 0; loop < n_sens; loop++)
{
switch (sens_sel[loop])
{
case BMI2_OIS_ACCEL:
/* Update OIS accelerometer address */
reg_addr = BMI2_OIS_ACC_X_LSB_ADDR;
/* Get OIS accelerometer data */
rslt = get_ois_acc_gyr_data(&ois_dev->acc_data, reg_addr, ois_dev, 0);
break;
case BMI2_OIS_GYRO:
/* Update OIS gyroscope address */
reg_addr = BMI2_OIS_GYR_X_LSB_ADDR;
/* Get OIS gyroscope data */
rslt = get_ois_acc_gyr_data(&ois_dev->gyr_data, reg_addr, ois_dev, gyr_cross_sens_zx);
break;
default:
rslt = BMI2_OIS_E_INVALID_SENSOR;
break;
}
/* Return error if any of the get sensor data fails */
if (rslt != BMI2_OIS_OK)
{
break;
}
}
}
else
{
rslt = BMI2_OIS_E_NULL_PTR;
}
return rslt;
}
/***************************************************************************/
/*! Local Function Definitions
****************************************************************************/
/*! @cond DOXYGEN_SUPRESS */
/* Suppressing doxygen warnings triggered for same static function names present across various sensor variant
* directories */
/*!
* @brief This internal API gets the accelerometer and the gyroscope data.
*/
static int8_t get_ois_acc_gyr_data(struct bmi2_ois_sens_axes_data *ois_data,
uint8_t reg_addr,
struct bmi2_ois_dev *ois_dev,
int16_t ois_gyr_cross_sens_zx)
{
/* Variable to define error */
int8_t rslt;
/* Variables to store MSB value */
uint8_t msb;
/* Variables to store LSB value */
uint8_t lsb;
/* Variables to store both MSB and LSB value */
uint16_t msb_lsb;
/* Variables to define index */
uint8_t index = 0;
/* Array to define data stored in register */
uint8_t reg_data[BMI2_OIS_ACC_GYR_NUM_BYTES] = { 0 };
/* Read the sensor data */
rslt = bmi2_ois_get_regs(reg_addr, reg_data, BMI2_OIS_ACC_GYR_NUM_BYTES, ois_dev);
if (rslt == BMI2_OIS_OK)
{
/* Read x-axis data */
lsb = reg_data[index++];
msb = reg_data[index++];
msb_lsb = ((uint16_t)msb << 8) | (uint16_t)lsb;
ois_data->x = (int16_t)msb_lsb;
/* Read y-axis data */
lsb = reg_data[index++];
msb = reg_data[index++];
msb_lsb = ((uint16_t)msb << 8) | (uint16_t)lsb;
ois_data->y = (int16_t)msb_lsb;
/* Read z-axis data */
lsb = reg_data[index++];
msb = reg_data[index++];
msb_lsb = ((uint16_t)msb << 8) | (uint16_t)lsb;
ois_data->z = (int16_t)msb_lsb;
comp_gyro_cross_axis_sensitivity(ois_data, ois_gyr_cross_sens_zx);
}
return rslt;
}
/*!
* @brief This internal API is used to validate the device structure pointer for
* null conditions.
*/
static int8_t null_ptr_check(const struct bmi2_ois_dev *ois_dev)
{
/* Variable to define error */
int8_t rslt = BMI2_OIS_OK;
if ((ois_dev == NULL) || (ois_dev->ois_read == NULL) || (ois_dev->ois_write == NULL) ||
(ois_dev->ois_delay_us == NULL))
{
/* Device structure pointer is NULL */
rslt = BMI2_OIS_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This internal API corrects the gyroscope cross-axis sensitivity
* between the z and the x axis.
*/
static void comp_gyro_cross_axis_sensitivity(struct bmi2_ois_sens_axes_data *ois_data, int16_t ois_gyr_cross_sens_zx)
{
/* Get the compensated gyroscope x-axis */
ois_data->x = ois_data->x - (int16_t)(((int32_t)ois_gyr_cross_sens_zx * (int32_t)ois_data->z) / 512);
}
/*! @endcond */
/**
* Copyright (c) 2023 Bosch Sensortec GmbH. All rights reserved.
*
* BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @file bmi2_ois.h
* @date 2023-05-03
* @version v2.86.1
*
*/
/**
* \ingroup bmi2xy
* \defgroup bmi2_ois BMI2_OIS
* @brief Sensor driver for BMI2_OIS sensor
*/
#ifndef _BMI2_OIS_H
#define _BMI2_OIS_H
/*! CPP guard */
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************************/
/*! Header files
****************************************************************************/
#ifdef __KERNEL__
#include <linux/types.h>
#include <linux/kernel.h>
#else
#include <stdint.h>
#include <stddef.h>
#endif
#include "bmi2_defs.h"
/******************************************************************************/
/*! @name Macros */
/******************************************************************************/
#ifndef BMI2_INTF_RETURN_TYPE
#define BMI2_INTF_RETURN_TYPE int8_t
#endif
/*! @name Utility macros */
#define BMI2_OIS_SET_BITS(reg_data, bitname, data) \
((reg_data & ~(bitname##_MASK)) | \
((data << bitname##_POS) & bitname##_MASK))
#define BMI2_OIS_GET_BITS(reg_data, bitname) \
((reg_data & (bitname##_MASK)) >> \
(bitname##_POS))
/*! @name For enable and disable */
#define BMI2_OIS_ENABLE UINT8_C(1)
#define BMI2_OIS_DISABLE UINT8_C(0)
/*! @name To define success code */
#define BMI2_OIS_OK UINT8_C(0)
/*! @name To define error codes */
#define BMI2_OIS_E_NULL_PTR INT8_C(-1)
#define BMI2_OIS_E_COM_FAIL INT8_C(-2)
#define BMI2_OIS_E_INVALID_SENSOR INT8_C(-8)
/*! @name Mask definitions for SPI read/write address for OIS */
#define BMI2_OIS_SPI_RD_MASK UINT8_C(0x80)
#define BMI2_OIS_SPI_WR_MASK UINT8_C(0x7F)
/*! @name BMI2 OIS data bytes */
#define BMI2_OIS_ACC_GYR_NUM_BYTES UINT8_C(6)
/*! @name Macros to select sensor for OIS data read */
#define BMI2_OIS_ACCEL UINT8_C(0x01)
#define BMI2_OIS_GYRO UINT8_C(0x02)
/*! @name Macros to define OIS register addresses */
#define BMI2_OIS_CONFIG_ADDR UINT8_C(0x40)
#define BMI2_OIS_ACC_X_LSB_ADDR UINT8_C(0x0C)
#define BMI2_OIS_GYR_X_LSB_ADDR UINT8_C(0x12)
/*! @name Mask definitions for OIS configurations */
#define BMI2_OIS_GYR_EN_MASK UINT8_C(0x40)
#define BMI2_OIS_ACC_EN_MASK UINT8_C(0x80)
/*! @name Bit Positions for OIS configurations */
#define BMI2_OIS_GYR_EN_POS UINT8_C(0x06)
#define BMI2_OIS_ACC_EN_POS UINT8_C(0x07)
/*! Low pass filter configuration position and mask */
#define BMI2_OIS_LP_FILTER_EN_POS UINT8_C(0x00)
#define BMI2_OIS_LP_FILTER_EN_MASK UINT8_C(0x01)
#define BMI2_OIS_LP_FILTER_CONFIG_POS UINT8_C(0x01)
#define BMI2_OIS_LP_FILTER_CONFIG_MASK UINT8_C(0x06)
#define BMI2_OIS_LP_FILTER_MUTE_POS UINT8_C(0x05)
#define BMI2_OIS_LP_FILTER_MUTE_MASK UINT8_C(0x20)
/******************************************************************************/
/*! @name Function Pointers */
/******************************************************************************/
/*!
* @brief Bus communication function pointer which should be mapped to
* the platform specific read functions of the user
*
* @param[in] reg_addr : Register address from which data is read.
* @param[out] reg_data : Pointer to data buffer where read data is stored.
* @param[in] len : Number of bytes of data to be read.
* @param[in, out] intf_ptr : Void pointer that can enable the linking of descriptors
* for interface related call backs.
*
* retval = BMI2_INTF_RET_SUCCESS -> Success
* retval != BMI2_INTF_RET_SUCCESS -> Failure
*
*/
typedef BMI2_INTF_RETURN_TYPE (*bmi2_ois_read_fptr_t)(uint8_t reg_addr, uint8_t *data, uint32_t len, void *intf_ptr);
/*!
* @brief Bus communication function pointer which should be mapped to
* the platform specific write functions of the user
*
* @param[in] reg_addr : Register address to which the data is written.
* @param[in] reg_data : Pointer to data buffer in which data to be written
* is stored.
* @param[in] len : Number of bytes of data to be written.
* @param[in, out] intf_ptr : Void pointer that can enable the linking of descriptors
* for interface related call backs
*
* retval = BMI2_INTF_RET_SUCCESS -> Success
* retval != BMI2_INTF_RET_SUCCESS -> Failure
*
*/
typedef BMI2_INTF_RETURN_TYPE (*bmi2_ois_write_fptr_t)(uint8_t reg_addr, const uint8_t *data, uint32_t len,
void *intf_ptr);
/*!
* @brief Delay function pointer which should be mapped to
* delay function of the user
*
* @param[in] period : Delay in microseconds.
* @param[in, out] intf_ptr : Void pointer that can enable the linking of descriptors
* for interface related call backs
*
*/
typedef void (*bmi2_ois_delay_fptr_t)(uint32_t period, void *intf_ptr);
/******************************************************************************/
/*! @name Structure Declarations */
/******************************************************************************/
/*! @name Structure to define accelerometer and gyroscope sensor axes for OIS */
struct bmi2_ois_sens_axes_data
{
/*! Data in x-axis */
int16_t x;
/*! Data in y-axis */
int16_t y;
/*! Data in z-axis */
int16_t z;
};
/*! @name Structure to define bmi2 OIS sensor configurations */
struct bmi2_ois_dev
{
/*! Read function pointer */
bmi2_ois_read_fptr_t ois_read;
/*! Write function pointer */
bmi2_ois_write_fptr_t ois_write;
/*! Delay function pointer */
bmi2_ois_delay_fptr_t ois_delay_us;
/*! Low pass filter en/dis */
uint8_t lp_filter_en;
/*! Void interface pointer */
void *intf_ptr;
/*! To store interface pointer error */
int8_t intf_rslt;
/*! Low pass filter cut-off frequency */
uint8_t lp_filter_config;
/*! Low pass filter mute */
uint8_t lp_filter_mute;
/*! Accelerometer enable for OIS */
uint8_t acc_en;
/*! Gyroscope enable for OIS */
uint8_t gyr_en;
/*! Accelerometer data axes */
struct bmi2_ois_sens_axes_data acc_data;
/*! Gyroscope data axes */
struct bmi2_ois_sens_axes_data gyr_data;
};
/***************************************************************************/
/*! BMI2 OIS User Interface function prototypes
****************************************************************************/
/**
* \ingroup bmi2_ois
* \defgroup bmi2_oisApiRegs Registers
* @brief Read data from the given OIS register address of bmi2
*/
/*!
* \ingroup bmi2_oisApiRegs
* \page bmi2_ois_api_bmi2_ois_get_regs bmi2_ois_get_regs
* \code
* int8_t bmi2_ois_get_regs(uint8_t ois_reg_addr,
* uint8_t *ois_reg_data,
* uint16_t data_len,
* const struct bmi2_ois_dev *ois_dev);
* \endcode
* @details This API reads the data from the given OIS register address of bmi2
* sensor.
*
* @param[in] ois_reg_addr : OIS register address from which data is read.
* @param[out] ois_reg_data : Pointer to data buffer where read data is stored.
* @param[in] data_len : No. of bytes of data to be read.
* @param[in] ois_dev : Structure instance of bmi2_ois_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bmi2_ois_get_regs(uint8_t ois_reg_addr, uint8_t *ois_reg_data, uint16_t data_len, struct bmi2_ois_dev *ois_dev);
/*!
* \ingroup bmi2_oisApiRegs
* \page bmi2_ois_api_bmi2_ois_set_regs bmi2_ois_set_regs
* \code
* int8_t bmi2_ois_set_regs(uint8_t ois_reg_addr,
* uint8_t *ois_reg_data,
* uint16_t data_len,
* const struct bmi2_ois_dev *ois_dev);
* \endcode
* @details This API writes data to the given OIS register address of bmi2 sensor.
*
* @param[in] ois_reg_addr : OIS register address to which the data is written.
* @param[in] ois_reg_data : Pointer to data buffer in which data to be written
* is stored.
* @param[in] data_len : No. of bytes of data to be written.
* @param[in] ois_dev : Structure instance of bmi2_ois_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bmi2_ois_set_regs(uint8_t ois_reg_addr,
const uint8_t *ois_reg_data,
uint16_t data_len,
struct bmi2_ois_dev *ois_dev);
/**
* \ingroup bmi2_ois
* \defgroup bmi2_oisApiConfig Status update
* @brief Get / Set the status of Enable / Disable accelerometer / gyroscope data read through OIS interface
*/
/*!
* \ingroup bmi2_oisApiConfig
* \page bmi2_ois_api_bmi2_ois_set_config bmi2_ois_set_config
* \code
* int8_t bmi2_ois_set_config(const struct bmi2_ois_dev *ois_dev);
* \endcode
* @details This API sets the status of enable/disable accelerometer/gyroscope data read through
* OIS interface.
*
* @param[in] ois_dev : Structure instance of bmi2_ois_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bmi2_ois_set_config(struct bmi2_ois_dev *ois_dev);
/*!
* \ingroup bmi2_oisApiConfig
* \page bmi2_ois_api_bmi2_ois_get_config bmi2_ois_get_config
* \code
* int8_t bmi2_ois_get_config(struct bmi2_ois_dev *ois_dev);
* \endcode
* @details This API gets the status of accelerometer/gyroscope enable for data
* read through OIS interface.
*
* @param[in, out] ois_dev : Structure instance of bmi2_ois_dev.
*
* @note Enabling and disabling is done during OIS structure initialization.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bmi2_ois_get_config(struct bmi2_ois_dev *ois_dev);
/**
* \ingroup bmi2_ois
* \defgroup bmi2_oisApiRead Data read
* @brief Read accelerometer / gyroscope data through OIS interface
*/
/*!
* \ingroup bmi2_oisApiRead
* \page bmi2_ois_api_bmi2_ois_read_data bmi2_ois_read_data
* \code
* int8_t bmi2_ois_read_data(const uint8_t *sens_sel,
* uint8_t n_sens,
* struct bmi2_ois_dev *ois_dev,
* int16_t gyr_cross_sens_zx);
* \endcode
* @details This API reads accelerometer/gyroscope data through OIS interface.
*
* @param[in] sens_sel : Select sensor whose data is to be read.
* @param[in] n_sens : Number of sensors selected.
* @param[in, out] ois_dev : Structure instance of bmi2_ois_dev.
* @param[in] gyr_cross_sens_zx : Store the gyroscope cross sensitivity values taken from the bmi2xy
* (refer bmi2_ois example).
*
*@verbatim
* sens_sel | Value
* ---------------|---------------
* BMI2_OIS_ACCEL | 0x01
* BMI2_OIS_GYRO | 0x02
*@endverbatim
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval < 0 -> Fail
*/
int8_t bmi2_ois_read_data(const uint8_t *sens_sel,
uint8_t n_sens,
struct bmi2_ois_dev *ois_dev,
int16_t gyr_cross_sens_zx);
#ifdef __cplusplus
}
#endif /* End of CPP guard */
#endif /* End of _BMI2_OIS_H */
idf_component_register(
SRCS
bmp5.c
INCLUDE_DIRS
.
)
Copyright (c) 2022 Bosch Sensortec GmbH. All rights reserved.
BSD-3-Clause
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
# BMP5 Sensor API
### Sensor overview
The BMP580/BMP581/BMP585 is an absolute barometric pressure sensor.
Its small dimensions, its low power consumption and the highend performance allow the implementation in a wide range of
applications.
### Target Application
- Enhancement of GPS navigation (e.g. dead-reckoning, slope detection)
- Indoor navigation (floor detection, elevator detection)
- Outdoor navigation
- Sports applications like calorie counting, fitness activity identification
- Emergency caller location
- Weather forecast
- Vertical velocity indication (e.g. rise/sink speed)
- Altitude control of drones and flying toys
### Feature
- Pressure data
- Temperature data
### Important links
- [Community support page](https://community.bosch-sensortec.com)
---
/**
* Copyright (c) 2022 Bosch Sensortec GmbH. All rights reserved.
*
* BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @file bmp5.c
* @date 2022-08-11
* @version v1.1.1
*
*/
/***************************************************************************/
/*! Header files
****************************************************************************/
#include "bmp5.h"
/***************************************************************************/
/*! Global Variable
****************************************************************************/
/******************************************************************************/
/*! Local Function Prototypes
******************************************************************************/
/*!
* @brief This internal API is used to validate the device pointer for
* null conditions.
*
* @param[in] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval <0 -> Fail
*/
static int8_t null_ptr_check(const struct bmp5_dev *dev);
/*!
* @brief This internal API is used to validate the chip id of the sensor.
*
* @param[in] chip_id : Variable that hold the chip id from register.
* @param[in,out] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval <0 -> Fail
*/
static int8_t validate_chip_id(uint8_t chip_id, struct bmp5_dev *dev);
/*!
* @brief This internal API is used to validate the post power-up procedure.
*
* @param[in] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval <0 -> Fail
*/
static int8_t power_up_check(struct bmp5_dev *dev);
/*!
* @brief This internal API is used to check if sensor is in deepstandby mode.
*
* @param[out] powermode : To store whether sensor is in deepstanby mode.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval <0 -> Fail
*/
static int8_t check_deepstandby_mode(enum bmp5_powermode *powermode, struct bmp5_dev *dev);
/*!
* @brief This internal API is used to set sensor in deep standby powermode.
*
* @param[in] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval <0 -> Fail
*/
static int8_t set_deep_standby_mode(struct bmp5_dev *dev);
/*!
* @brief This internal API is used to set sensor in standby or
* normal or forced or continous powermode.
*
* @param[in] powermode : Select desired powermode.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval <0 -> Fail
*/
static int8_t set_power_mode(enum bmp5_powermode powermode, struct bmp5_dev *dev);
/*!
* @brief This internal API is used to set sensor in standby powermode when powermode is deepstandby mode.
*
* @param[in] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval <0 -> Fail
*/
static int8_t set_standby_mode(struct bmp5_dev *dev);
#ifdef BMP5_USE_FIXED_POINT
/*!
* @brief This internal API is used to calculate the power of a value.
*
* @param[in] base : Base for power calculation.
* @param[in] resolution : Exponent for power calculation.
*
* @return the calculated power
* @retval the power value
*/
static uint32_t power(uint8_t base, uint8_t resolution);
#endif
/*!
* @brief This internal API is used to set the IIR for temperature and pressure.
*
* @param[in] iir_cfg : Structure instance of bmp5_iir_config.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval <0 -> Fail
*/
static int8_t set_iir_config(const struct bmp5_iir_config *iir_cfg, struct bmp5_dev *dev);
/*!
* @brief This internal API is used to set fifo threshold based on the frame type selected.
*
* @param[in,out] reg_data : Stores the register data.
* @param[in] fifo : Structure instance of bmp5_fifo.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval <0 -> Fail
*/
static int8_t set_fifo_threshold(uint8_t *reg_data, const struct bmp5_fifo *fifo);
/*!
* @brief This internal API sets the configuration for IIR of fifo.
*
* @param[in] set_fifo_iir_t : Variable to store the fifo IIR value for temperature.
* @param[in] set_fifo_iir_p : Variable to store the fifo IIR value for pressure.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval <0 -> Fail
*/
static int8_t set_fifo_iir_config(uint8_t set_fifo_iir_t, uint8_t set_fifo_iir_p, struct bmp5_dev *dev);
/*!
* @brief This internal API is used to unpack the fifo data and store it in the bmp5_sensor_data structure.
*
* @param[out] sensor_data : Stores the pressure and temperature data in bmp5_sensor_data structure.
* @param[in,out] data_index : Contains the beginning of set of bytes parsed to unpack.
* @param[in] fifo : Structure instance of bmp5_fifo.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval <0 -> Fail
*/
static int8_t unpack_sensor_data(struct bmp5_sensor_data *sensor_data,
uint16_t *data_index,
const struct bmp5_fifo *fifo);
/*!
* @brief This internal API sets the IIR configuration and count limit of OOR pressure.
*
* @param[in] set_oor_iir_p : Variable to store the OOR IIR value for pressure.
* @param[in] set_count_limit : Variable to store the OOR count limit value for pressure.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval <0 -> Fail
*/
static int8_t set_oor_iir_count_limit(uint8_t set_oor_iir_p, uint8_t set_count_limit, struct bmp5_dev *dev);
/*!
* @brief This internal API is used to read the nvm data.
*
* @param[out] nvm_data : Variable to store nvm data.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval <0 -> Fail
*/
static int8_t get_nvm_data(uint16_t *nvm_data, struct bmp5_dev *dev);
/*!
* @brief This internal API is used to get the nvm status (NVM ready interrupt, NVM error interrupt
* and NVM command error interrupt).
*
* @param[out] nvm_status : Variable to store nvm status.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @note : Below are values of nvm_status possible.
*
* nvm_status | Functionality
* ---------------------|----------------------------
* BMP5_INT_NVM_RDY | NVM ready status
* BMP5_INT_NVM_ERR | NVM error status
* BMP5_NVM_CMD_ERR | NVM command error status
*
* @return Result of API execution status.
* @return 0 -> Success
* @return < 0 -> Fail
*/
static int8_t get_nvm_status(uint8_t *nvm_status, struct bmp5_dev *dev);
/*!
* @brief This internal API is used to write the nvm address and prog_en.
*
* @param[out] nvm_addr : Variable that holds the nvm address.
* @param[in] prog_en : Variable that holds the prog_en value.
* @param[in,out] curr_pwrmode : Stores current powermode.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval <0 -> Fail
*/
static int8_t nvm_write_addr(uint8_t nvm_addr, uint8_t prog_en, enum bmp5_powermode *curr_pwrmode,
struct bmp5_dev *dev);
/*!
* @brief This internal API is used to set the nvm address and prog_enable based on NVM read/write selected.
*
* @param[out] nvm_addr : Variable that holds the nvm address.
* @param[in] prog_en : Variable that holds the prog_en value.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval <0 -> Fail
*/
static int8_t set_nvm_addr(uint8_t nvm_addr, uint8_t prog_en, struct bmp5_dev *dev);
/***************************************************************************/
/*! Local Function Definitions
****************************************************************************/
/*!
* @brief This API is the entry point.
* It performs the selection of I2C/I3C/SPI read mechanism according to the
* selected interface and reads the chip-id of the sensor.
*/
int8_t bmp5_init(struct bmp5_dev *dev)
{
int8_t rslt;
uint8_t reg_data;
uint8_t chip_id;
/* Check for null pointer in the device structure */
rslt = null_ptr_check(dev);
if (rslt == BMP5_OK)
{
dev->chip_id = 0;
if (dev->intf == BMP5_SPI_INTF)
{
/* Performing a single read via SPI of registers,
* e.g. registers CHIP_ID, before the actual
* SPI communication with the device.
*/
rslt = bmp5_get_regs(BMP5_REG_CHIP_ID, &reg_data, 1, dev);
}
if (rslt == BMP5_OK)
{
/* Read chip_id */
rslt = bmp5_get_regs(BMP5_REG_CHIP_ID, &chip_id, 1, dev);
if (rslt == BMP5_OK)
{
if (chip_id != 0)
{
/* Validate post power-up procedure */
rslt = power_up_check(dev);
}
else
{
rslt = BMP5_E_INVALID_CHIP_ID;
}
if (rslt == BMP5_OK)
{
rslt = validate_chip_id(chip_id, dev);
}
}
}
}
return rslt;
}
/*!
* @brief This API reads the data from the given register address of the sensor.
*/
int8_t bmp5_get_regs(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, struct bmp5_dev *dev)
{
int8_t rslt;
/* Check for null pointer in the device structure */
rslt = null_ptr_check(dev);
/* Proceed if null check is fine */
if ((rslt == BMP5_OK) && (reg_data != NULL))
{
if (dev->intf == BMP5_SPI_INTF)
{
/* If interface selected is SPI */
reg_addr = reg_addr | BMP5_SPI_RD_MASK;
}
/* Read the data from the reg_addr */
dev->intf_rslt = dev->read(reg_addr, reg_data, len, dev->intf_ptr);
if (dev->intf_rslt != BMP5_INTF_RET_SUCCESS)
{
/* Failure case */
rslt = BMP5_E_COM_FAIL;
}
}
else
{
rslt = BMP5_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This API writes the given data to the register address
* of the sensor.
*/
int8_t bmp5_set_regs(uint8_t reg_addr, const uint8_t *reg_data, uint32_t len, struct bmp5_dev *dev)
{
int8_t rslt;
uint8_t idx = 0;
/* Check for null pointer in the device structure */
rslt = null_ptr_check(dev);
/* Proceed if null check is fine */
if ((rslt == BMP5_OK) && (reg_data != NULL))
{
if (dev->intf == BMP5_SPI_INTF)
{
/* Write the data to the reg_addr */
do
{
dev->intf_rslt = dev->write((reg_addr + idx), &reg_data[idx], 1, dev->intf_ptr);
idx++;
} while ((idx < len) && (dev->intf_rslt == BMP5_INTF_RET_SUCCESS));
}
else if ((dev->intf == BMP5_I2C_INTF) || (dev->intf == BMP5_I3C_INTF))
{
/* Write the data to the reg_addr */
dev->intf_rslt = dev->write(reg_addr, reg_data, len, dev->intf_ptr);
}
if (dev->intf_rslt != BMP5_INTF_RET_SUCCESS)
{
/* Failure case */
rslt = BMP5_E_COM_FAIL;
}
}
else
{
rslt = BMP5_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This API performs the soft reset of the sensor.
*/
int8_t bmp5_soft_reset(struct bmp5_dev *dev)
{
int8_t rslt;
uint8_t reg_data;
uint8_t por_status;
uint8_t data = BMP5_SOFT_RESET_CMD;
/* Reset the device */
rslt = bmp5_set_regs(BMP5_REG_CMD, &data, 1, dev);
if (rslt == BMP5_OK)
{
/* Soft-reset execution takes 2 ms */
dev->delay_us(BMP5_DELAY_US_SOFT_RESET, dev->intf_ptr);
if (dev->intf == BMP5_SPI_INTF)
{
/* Performing a single read via SPI of registers,
* e.g. registers CHIP_ID, before the actual
* SPI communication with the device.
*/
rslt = bmp5_get_regs(BMP5_REG_CHIP_ID, &reg_data, 1, dev);
}
if (rslt == BMP5_OK)
{
rslt = bmp5_get_interrupt_status(&por_status, dev);
if (rslt == BMP5_OK)
{
if (por_status & BMP5_INT_ASSERTED_POR_SOFTRESET_COMPLETE)
{
rslt = BMP5_OK;
}
else
{
rslt = BMP5_E_POR_SOFTRESET;
}
}
}
}
return rslt;
}
/*!
* @brief This API is used to get interrupt status.
*/
int8_t bmp5_get_interrupt_status(uint8_t *int_status, struct bmp5_dev *dev)
{
int8_t rslt;
if (int_status != NULL)
{
rslt = bmp5_get_regs(BMP5_REG_INT_STATUS, int_status, 1, dev);
}
else
{
rslt = BMP5_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This API is used to get powermode of the sensor.
*/
int8_t bmp5_get_power_mode(enum bmp5_powermode *powermode, struct bmp5_dev *dev)
{
int8_t rslt;
uint8_t deep_dis;
uint8_t reg_data;
uint8_t pwrmode;
if (powermode != NULL)
{
/* Read the power mode register */
rslt = bmp5_get_regs(BMP5_REG_ODR_CONFIG, &reg_data, 1, dev);
if (rslt == BMP5_OK)
{
pwrmode = BMP5_GET_BITS_POS_0(reg_data, BMP5_POWERMODE);
switch (pwrmode)
{
case BMP5_POWERMODE_STANDBY:
/* Getting deep disable status */
deep_dis = BMP5_GET_BITSLICE(reg_data, BMP5_DEEP_DISABLE);
/* Checking deepstandby status only when powermode is in standby mode */
/* If deep_dis = 0(BMP5_DEEP_ENABLED) then deepstandby mode is enabled.
* If deep_dis = 1(BMP5_DEEP_DISABLED) then deepstandby mode is disabled
*/
*powermode = BMP5_POWERMODE_STANDBY;
if (deep_dis == BMP5_DEEP_ENABLED)
{
rslt = check_deepstandby_mode(powermode, dev);
}
break;
case BMP5_POWERMODE_NORMAL:
*powermode = BMP5_POWERMODE_NORMAL;
break;
case BMP5_POWERMODE_FORCED:
*powermode = BMP5_POWERMODE_FORCED;
break;
case BMP5_POWERMODE_CONTINOUS:
*powermode = BMP5_POWERMODE_CONTINOUS;
break;
default:
rslt = BMP5_E_INVALID_POWERMODE;
break;
}
}
}
else
{
rslt = BMP5_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This API is used to set powermode of the sensor.
*/
int8_t bmp5_set_power_mode(enum bmp5_powermode powermode, struct bmp5_dev *dev)
{
int8_t rslt;
enum bmp5_powermode lst_pwrmode;
/* Existing power mode of the device is received in lst_pwrmode */
rslt = bmp5_get_power_mode(&lst_pwrmode, dev);
if (rslt == BMP5_OK)
{
/* If the sensor is not in standby mode set the device to
* standby mode.
*/
if (lst_pwrmode != BMP5_POWERMODE_STANDBY)
{
/* Device should be set to standby before transiting to
* forced mode or normal mode or continous mode.
*/
rslt = set_power_mode(BMP5_POWERMODE_STANDBY, dev);
if (rslt == BMP5_OK)
{
/* Give t_standby(as per data sheet) time for device to go into standby mode */
dev->delay_us(BMP5_DELAY_US_STANDBY, dev->intf_ptr);
}
}
/* Set the desired power mode */
if (rslt == BMP5_OK)
{
switch (powermode)
{
case BMP5_POWERMODE_DEEP_STANDBY:
rslt = set_deep_standby_mode(dev);
break;
case BMP5_POWERMODE_STANDBY:
/* Since switching between powermodes require sensor to be in standby mode
* it is performed above. So it is not explicitly performed here.
*/
break;
case BMP5_POWERMODE_NORMAL:
case BMP5_POWERMODE_FORCED:
case BMP5_POWERMODE_CONTINOUS:
rslt = set_power_mode(powermode, dev);
break;
default:
rslt = BMP5_E_INVALID_POWERMODE;
break;
}
}
}
return rslt;
}
/*!
* @brief This API reads the temperature(deg C) or both pressure(Pa) and temperature(deg C) data from the
* sensor and store it in the bmp5_sensor_data structure instance passed by the user.
*/
int8_t bmp5_get_sensor_data(struct bmp5_sensor_data *sensor_data,
const struct bmp5_osr_odr_press_config *osr_odr_press_cfg,
struct bmp5_dev *dev)
{
int8_t rslt;
uint8_t reg_data[6] = { 0 };
int32_t raw_data_t;
uint32_t raw_data_p;
rslt = bmp5_get_regs(BMP5_REG_TEMP_DATA_XLSB, reg_data, 6, dev);
if (rslt == BMP5_OK)
{
raw_data_t = (int32_t) ((int32_t) ((uint32_t)(((uint32_t)reg_data[2] << 16) | ((uint16_t)reg_data[1] << 8) | reg_data[0]) << 8) >> 8);
#ifdef BMP5_USE_FIXED_POINT
/* Division by 2^16(whose equivalent value is 65536) is performed to get temperature data and followed by fixed point digit
* precision in deg C
*/
sensor_data->temperature =
(int64_t)((raw_data_t / (float)65536.0) * (power(10, BMP5_FIXED_POINT_DIGIT_PRECISION)));
#else
/* Division by 2^16(whose equivalent value is 65536) is performed to get temperature data in deg C */
sensor_data->temperature = (float)(raw_data_t / 65536.0);
#endif
if (osr_odr_press_cfg->press_en == BMP5_ENABLE)
{
raw_data_p = (uint32_t)((uint32_t)(reg_data[5] << 16) | (uint16_t)(reg_data[4] << 8) | reg_data[3]);
#ifdef BMP5_USE_FIXED_POINT
/* Division by 2^6(whose equivalent value is 64) is performed to get pressure data and followed by fixed point digit
* precision in Pa
*/
sensor_data->pressure =
(uint64_t)((raw_data_p / (float)64.0) * (power(10, BMP5_FIXED_POINT_DIGIT_PRECISION)));
#else
/* Division by 2^6(whose equivalent value is 64) is performed to get pressure data in Pa */
sensor_data->pressure = (float)(raw_data_p / 64.0);
#endif
}
else
{
sensor_data->pressure = 0.0;
}
}
return rslt;
}
/*!
* @brief This API is used to enable the interrupts(drdy interrupt, fifo full interrupt,
* fifo threshold enable and pressure data out of range interrupt).
*/
int8_t bmp5_int_source_select(const struct bmp5_int_source_select *int_source_select, struct bmp5_dev *dev)
{
int8_t rslt;
uint8_t reg_data;
if (int_source_select != NULL)
{
rslt = bmp5_get_regs(BMP5_REG_INT_SOURCE, &reg_data, 1, dev);
if (rslt == BMP5_OK)
{
reg_data = BMP5_SET_BITS_POS_0(reg_data, BMP5_INT_DRDY_EN, int_source_select->drdy_en);
reg_data = BMP5_SET_BITSLICE(reg_data, BMP5_INT_FIFO_FULL_EN, int_source_select->fifo_full_en);
reg_data = BMP5_SET_BITSLICE(reg_data, BMP5_INT_FIFO_THRES_EN, int_source_select->fifo_thres_en);
reg_data = BMP5_SET_BITSLICE(reg_data, BMP5_INT_OOR_PRESS_EN, int_source_select->oor_press_en);
rslt = bmp5_set_regs(BMP5_REG_INT_SOURCE, &reg_data, 1, dev);
}
}
else
{
rslt = BMP5_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This API is used to configure the interrupt settings.
*/
int8_t bmp5_configure_interrupt(enum bmp5_intr_mode int_mode,
enum bmp5_intr_polarity int_pol,
enum bmp5_intr_drive int_od,
enum bmp5_intr_en_dis int_en,
struct bmp5_dev *dev)
{
/* Variable to store the function result */
int8_t rslt;
/* Variable to get interrupt configuration */
uint8_t reg_data = 0;
/* Variable to set interrupt source */
uint8_t int_source = 0;
/* Variable to get interrupt status */
uint8_t int_status = 0;
/* Get interrupt configuration */
rslt = bmp5_get_regs(BMP5_REG_INT_CONFIG, &reg_data, 1, dev);
if (rslt == BMP5_OK)
{
/* Any change between latched/pulsed mode has to be applied while interrupt is disabled */
/* Step 1 : Turn off all INT sources (INT_SOURCE -> 0x00) */
rslt = bmp5_set_regs(BMP5_REG_INT_SOURCE, &int_source, 1, dev);
if (rslt == BMP5_OK)
{
/* Step 2 : Read the INT_STATUS register to clear the status */
rslt = bmp5_get_regs(BMP5_REG_INT_STATUS, &int_status, 1, dev);
if (rslt == BMP5_OK)
{
/* Step 3 : Set the desired mode in INT_CONFIG.int_mode */
reg_data = BMP5_SET_BITS_POS_0(reg_data, BMP5_INT_MODE, int_mode);
reg_data = BMP5_SET_BITSLICE(reg_data, BMP5_INT_POL, int_pol);
reg_data = BMP5_SET_BITSLICE(reg_data, BMP5_INT_OD, int_od);
reg_data = BMP5_SET_BITSLICE(reg_data, BMP5_INT_EN, int_en);
/* Finally transfer the interrupt configurations */
rslt = bmp5_set_regs(BMP5_REG_INT_CONFIG, &reg_data, 1, dev);
}
}
}
return rslt;
}
/*!
* @brief This API gets the configuration for oversampling of temperature, oversampling of
* pressure and ODR configuration along with pressure enable.
*/
int8_t bmp5_get_osr_odr_press_config(struct bmp5_osr_odr_press_config *osr_odr_press_cfg, struct bmp5_dev *dev)
{
/* Variable to store the function result */
int8_t rslt;
/* Variable to store OSR and ODR config */
uint8_t reg_data[2];
if (osr_odr_press_cfg != NULL)
{
/* Get OSR and ODR configuration in burst read */
rslt = bmp5_get_regs(BMP5_REG_OSR_CONFIG, reg_data, 2, dev);
if (rslt == BMP5_OK)
{
osr_odr_press_cfg->osr_t = BMP5_GET_BITS_POS_0(reg_data[0], BMP5_TEMP_OS);
osr_odr_press_cfg->osr_p = BMP5_GET_BITSLICE(reg_data[0], BMP5_PRESS_OS);
osr_odr_press_cfg->press_en = BMP5_GET_BITSLICE(reg_data[0], BMP5_PRESS_EN);
osr_odr_press_cfg->odr = BMP5_GET_BITSLICE(reg_data[1], BMP5_ODR);
}
}
else
{
rslt = BMP5_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This API sets the configuration for oversampling temperature, oversampling of
* pressure and ODR configuration along with pressure enable.
*
* @note If ODR is set to a value higher than 5Hz then powermode is set as standby mode, as ODR value greater than 5HZ
* without disabling deep-standby mode makes powermode invalid.
*/
int8_t bmp5_set_osr_odr_press_config(const struct bmp5_osr_odr_press_config *osr_odr_press_cfg, struct bmp5_dev *dev)
{
/* Variable to store the function result */
int8_t rslt = 0;
/* Variable to set ODR and OSR config */
uint8_t reg_data[2] = { 0 };
if (osr_odr_press_cfg != NULL)
{
/* If ODR is set to a value higher than 5Hz then powermode is set as standby mode, as ODR value greater than 5HZ
* without disabling deep-standby mode makes powermode invalid.
* NOTE: Register value for 5Hz is greater compared to ODRs higher than it. Thus in this below condition odr
* is checked whether less than 5Hz macro.
*/
if (osr_odr_press_cfg->odr < BMP5_ODR_05_HZ)
{
rslt = set_standby_mode(dev);
}
if (rslt == BMP5_OK)
{
rslt = bmp5_get_regs(BMP5_REG_OSR_CONFIG, reg_data, 2, dev);
if (rslt == BMP5_OK)
{
reg_data[0] = BMP5_SET_BITS_POS_0(reg_data[0], BMP5_TEMP_OS, osr_odr_press_cfg->osr_t);
reg_data[0] = BMP5_SET_BITSLICE(reg_data[0], BMP5_PRESS_OS, osr_odr_press_cfg->osr_p);
reg_data[0] = BMP5_SET_BITSLICE(reg_data[0], BMP5_PRESS_EN, osr_odr_press_cfg->press_en);
reg_data[1] = BMP5_SET_BITSLICE(reg_data[1], BMP5_ODR, osr_odr_press_cfg->odr);
/* Set ODR and OSR configuration */
rslt = bmp5_set_regs(BMP5_REG_OSR_CONFIG, reg_data, 2, dev);
}
}
}
else
{
rslt = BMP5_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This API gets the configuration for IIR of temperature and pressure.
*/
int8_t bmp5_get_iir_config(struct bmp5_iir_config *iir_cfg, struct bmp5_dev *dev)
{
/* Variable to store the function result */
int8_t rslt;
/* Variable to get IIR config */
uint8_t reg_data[2];
if (iir_cfg != NULL)
{
/* Get IIR configuration */
rslt = bmp5_get_regs(BMP5_REG_DSP_CONFIG, reg_data, 2, dev);
iir_cfg->shdw_set_iir_t = BMP5_GET_BITSLICE(reg_data[0], BMP5_SHDW_SET_IIR_TEMP);
iir_cfg->shdw_set_iir_p = BMP5_GET_BITSLICE(reg_data[0], BMP5_SHDW_SET_IIR_PRESS);
iir_cfg->iir_flush_forced_en = BMP5_GET_BITSLICE(reg_data[0], BMP5_IIR_FLUSH_FORCED_EN);
iir_cfg->set_iir_t = BMP5_GET_BITS_POS_0(reg_data[1], BMP5_SET_IIR_TEMP);
iir_cfg->set_iir_p = BMP5_GET_BITSLICE(reg_data[1], BMP5_SET_IIR_PRESS);
}
else
{
rslt = BMP5_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This API sets the configuration for IIR of temperature and pressure.
*
* @note If IIR value for both temperature and pressure is set a value other than bypass then powermode is set
* as standby mode, as IIR with value other than bypass without disabling deep-standby mode makes powermode invalid.
*/
int8_t bmp5_set_iir_config(const struct bmp5_iir_config *iir_cfg, struct bmp5_dev *dev)
{
/* Variable to store the function result */
int8_t rslt = 0;
/* Variable to store existing powermode */
enum bmp5_powermode curr_pwrmode;
if (iir_cfg != NULL)
{
/* If IIR value for both temperature and pressure is set a value other than bypass then powermode is set
* as standby mode, as IIR with value other than bypass without disabling deep-standby mode makes powermode
* invalid.
*/
if ((iir_cfg->set_iir_t != BMP5_IIR_FILTER_BYPASS) || (iir_cfg->set_iir_p != BMP5_IIR_FILTER_BYPASS))
{
rslt = set_standby_mode(dev);
}
if (rslt == BMP5_OK)
{
rslt = bmp5_get_power_mode(&curr_pwrmode, dev);
if (rslt == BMP5_OK)
{
/* IIR configuration is writable only during STANDBY mode(as per datasheet) */
if (curr_pwrmode != BMP5_POWERMODE_STANDBY)
{
/* If sensor is not in standby mode, set sensor in standby mode */
rslt = bmp5_set_power_mode(BMP5_POWERMODE_STANDBY, dev);
}
if (rslt == BMP5_OK)
{
rslt = set_iir_config(iir_cfg, dev);
}
/* If previous mode is not standbymode return sensor to that previous mode
* after setting iir configuration
*/
if (rslt == BMP5_OK)
{
/* Since IIR works only in standby mode we are not re-writing to deepstandby mode
* as deep standby mode resets the IIR settings to default
*/
if ((curr_pwrmode != BMP5_POWERMODE_STANDBY) && (curr_pwrmode != BMP5_POWERMODE_DEEP_STANDBY))
{
rslt = bmp5_set_power_mode(curr_pwrmode, dev);
}
}
}
}
}
else
{
rslt = BMP5_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This API gets the configuration for effective OSR of temperature,
* effective OSR of pressure and ODR valid status.
*/
int8_t bmp5_get_osr_odr_eff(struct bmp5_osr_odr_eff *osr_odr_eff, struct bmp5_dev *dev)
{
/* Variable to store the function result */
int8_t rslt;
/* Variable to store effective OSR */
uint8_t reg_data;
if (osr_odr_eff != NULL)
{
/* Get effective OSR configuration and ODR valid status */
rslt = bmp5_get_regs(BMP5_REG_OSR_EFF, &reg_data, 1, dev);
if (rslt == BMP5_OK)
{
osr_odr_eff->osr_t_eff = BMP5_GET_BITS_POS_0(reg_data, BMP5_OSR_TEMP_EFF);
osr_odr_eff->osr_p_eff = BMP5_GET_BITSLICE(reg_data, BMP5_OSR_PRESS_EFF);
osr_odr_eff->odr_is_valid = BMP5_GET_BITSLICE(reg_data, BMP5_ODR_IS_VALID);
}
}
else
{
rslt = BMP5_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This API used to get the configurations of fifo from the sensor.
*/
int8_t bmp5_get_fifo_configuration(struct bmp5_fifo *fifo, struct bmp5_dev *dev)
{
int8_t rslt = 0;
uint8_t reg_data;
if (fifo != NULL)
{
/* Get the fifo congifurations */
rslt = bmp5_get_regs(BMP5_REG_FIFO_CONFIG, &reg_data, 1, dev);
if (rslt == BMP5_OK)
{
fifo->threshold = BMP5_GET_BITS_POS_0(reg_data, BMP5_FIFO_THRESHOLD);
fifo->mode = BMP5_GET_BITSLICE(reg_data, BMP5_FIFO_MODE);
rslt = bmp5_get_regs(BMP5_REG_FIFO_SEL, &reg_data, 1, dev);
if (rslt == BMP5_OK)
{
fifo->frame_sel = BMP5_GET_BITS_POS_0(reg_data, BMP5_FIFO_FRAME_SEL);
fifo->dec_sel = BMP5_GET_BITSLICE(reg_data, BMP5_FIFO_DEC_SEL);
}
}
if (rslt == BMP5_OK)
{
rslt = bmp5_get_regs(BMP5_REG_DSP_CONFIG, &reg_data, 1, dev);
if (rslt == BMP5_OK)
{
fifo->set_fifo_iir_t = BMP5_GET_BITSLICE(reg_data, BMP5_SET_FIFO_IIR_TEMP);
fifo->set_fifo_iir_p = BMP5_GET_BITSLICE(reg_data, BMP5_SET_FIFO_IIR_PRESS);
}
}
}
else
{
rslt = BMP5_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This API used to set the configurations of fifo in the sensor.
*
* @note If Fifo frame selection is enabled then powermode is set as standby mode, as fifo frame selection
* enabled without disabling deep-standby mode makes powermode invalid.
*/
int8_t bmp5_set_fifo_configuration(const struct bmp5_fifo *fifo, struct bmp5_dev *dev)
{
int8_t rslt = 0;
uint8_t reg_data;
uint8_t set_fifo_iir_t, set_fifo_iit_p;
if (fifo != NULL)
{
/* If Fifo frame selection is enabled then powermode is set as standby mode, as fifo frame selection
* enabled without disabling deep-standby mode makes powermode invalid.
*/
if (fifo->frame_sel != BMP5_DISABLE)
{
rslt = set_standby_mode(dev);
}
if (rslt == BMP5_OK)
{
set_fifo_iir_t = fifo->set_fifo_iir_t;
set_fifo_iit_p = fifo->set_fifo_iir_p;
rslt = set_fifo_iir_config(set_fifo_iir_t, set_fifo_iit_p, dev);
if (rslt == BMP5_OK)
{
/* Get the fifo congifurations */
rslt = bmp5_get_regs(BMP5_REG_FIFO_CONFIG, &reg_data, 1, dev);
if (rslt == BMP5_OK)
{
reg_data = BMP5_SET_BITSLICE(reg_data, BMP5_FIFO_MODE, fifo->mode);
rslt = set_fifo_threshold(&reg_data, fifo);
}
if (rslt == BMP5_OK)
{
/* Set the fifo congifurations */
rslt = bmp5_set_regs(BMP5_REG_FIFO_CONFIG, &reg_data, 1, dev);
}
if (rslt == BMP5_OK)
{
rslt = bmp5_get_regs(BMP5_REG_FIFO_SEL, &reg_data, 1, dev);
}
if (rslt == BMP5_OK)
{
reg_data = BMP5_SET_BITS_POS_0(reg_data, BMP5_FIFO_FRAME_SEL, fifo->frame_sel);
reg_data = BMP5_SET_BITSLICE(reg_data, BMP5_FIFO_DEC_SEL, fifo->dec_sel);
}
if (rslt == BMP5_OK)
{
/* Set the fifo congifurations */
rslt = bmp5_set_regs(BMP5_REG_FIFO_SEL, &reg_data, 1, dev);
}
}
}
}
else
{
rslt = BMP5_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This API is used to get the length of fifo from the sensor.
*/
int8_t bmp5_get_fifo_len(uint16_t *fifo_len, struct bmp5_fifo *fifo, struct bmp5_dev *dev)
{
int8_t rslt;
uint8_t reg_data;
if ((fifo != NULL) && (fifo_len != NULL))
{
/* Get the fifo frame count */
rslt = bmp5_get_regs(BMP5_REG_FIFO_COUNT, &reg_data, 1, dev);
if (rslt == BMP5_OK)
{
fifo->fifo_count = BMP5_GET_BITS_POS_0(reg_data, BMP5_FIFO_COUNT);
if ((fifo->frame_sel == BMP5_FIFO_TEMPERATURE_DATA) || (fifo->frame_sel == BMP5_FIFO_PRESSURE_DATA))
{
/* Maximum of 32 frames if either one of temperature or pressure is selected
* and each frame comprises of 3 bytes of data
*/
*fifo_len = fifo->fifo_count * 3;
}
else if (fifo->frame_sel == BMP5_FIFO_PRESS_TEMP_DATA)
{
/* Maximum of 16 frames if both temperature and pressure is selected
* and each frame comprises of 6 bytes of data
*/
*fifo_len = fifo->fifo_count * 6;
}
else
{
return BMP5_E_FIFO_FRAME_EMPTY;
}
}
}
else
{
rslt = BMP5_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This API is used to get the fifo data from the sensor.
*/
int8_t bmp5_get_fifo_data(struct bmp5_fifo *fifo, struct bmp5_dev *dev)
{
int8_t rslt;
uint16_t fifo_len;
if (fifo != NULL)
{
/* Get the fifo length */
rslt = bmp5_get_fifo_len(&fifo_len, fifo, dev);
if (rslt == BMP5_OK)
{
if (fifo->length > fifo_len)
{
fifo->length = fifo_len;
}
/* Read the fifo data */
rslt = bmp5_get_regs(BMP5_REG_FIFO_DATA, fifo->data, fifo->length, dev);
}
}
else
{
rslt = BMP5_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This API extract the temperature and/or pressure data from the fifo data which is
* already read from the fifo.
*/
int8_t bmp5_extract_fifo_data(const struct bmp5_fifo *fifo, struct bmp5_sensor_data *sensor_data)
{
int8_t rslt = 0;
uint8_t idx = 0;
uint16_t data_indx;
/* Proceed if null check is fine */
if ((fifo != NULL) && (sensor_data != NULL))
{
for (data_indx = 0; (data_indx < fifo->length) && (rslt != BMP5_E_FIFO_FRAME_EMPTY);)
{
/* Inside unpack_sensor_data function, data_index is incremented */
rslt = unpack_sensor_data(&sensor_data[idx], &data_indx, fifo);
idx++;
}
}
else
{
rslt = BMP5_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This API gets the configuration for out-of-range pressure threshold, range
* count limit and IIR.
*/
int8_t bmp5_get_oor_configuration(struct bmp5_oor_press_configuration *oor_press_config, struct bmp5_dev *dev)
{
int8_t rslt;
uint8_t reg_data[4];
if (oor_press_config != NULL)
{
rslt = bmp5_get_regs(BMP5_REG_DSP_CONFIG, &reg_data[0], 1, dev);
if (rslt == BMP5_OK)
{
oor_press_config->oor_sel_iir_p = BMP5_GET_BITSLICE(reg_data[0], BMP5_OOR_SEL_IIR_PRESS);
rslt = bmp5_get_regs(BMP5_REG_OOR_THR_P_LSB, reg_data, 4, dev);
if (rslt == BMP5_OK)
{
oor_press_config->oor_thr_p = reg_data[0] | (reg_data[1] << 8) |
((reg_data[3] & BMP5_OOR_THR_P_XMSB_REG_MSK) << 16);
oor_press_config->oor_range_p = reg_data[2];
oor_press_config->cnt_lim = BMP5_GET_BITSLICE(reg_data[3], BMP5_OOR_COUNT_LIMIT);
}
}
}
else
{
rslt = BMP5_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This API sets the configuration for out-of-range pressure threshold, range
* count limit and IIR.
*/
int8_t bmp5_set_oor_configuration(const struct bmp5_oor_press_configuration *oor_press_config, struct bmp5_dev *dev)
{
int8_t rslt;
uint8_t reg_data[4];
uint8_t thres_xmsb;
uint8_t set_oor_iir_p, set_count_limit;
if (oor_press_config != NULL)
{
set_oor_iir_p = oor_press_config->oor_sel_iir_p;
set_count_limit = oor_press_config->cnt_lim;
rslt = set_oor_iir_count_limit(set_oor_iir_p, set_count_limit, dev);
if (rslt == BMP5_OK)
{
/* Get the OOR configurations */
rslt = bmp5_get_regs(BMP5_REG_OOR_THR_P_LSB, reg_data, 4, dev);
if (rslt == BMP5_OK)
{
reg_data[0] = BMP5_SET_BITS_POS_0(reg_data[0], BMP5_OOR_THR_P_LSB, oor_press_config->oor_thr_p);
reg_data[1] =
(uint8_t)(BMP5_SET_BITS_POS_0(reg_data[1], BMP5_OOR_THR_P_MSB, oor_press_config->oor_thr_p) >> 8);
reg_data[2] = oor_press_config->oor_range_p;
thres_xmsb = BMP5_GET_BITSLICE(oor_press_config->oor_thr_p, BMP5_OOR_THR_P_XMSB);
reg_data[3] = BMP5_SET_BITS_POS_0(reg_data[3], BMP5_OOR_THR_P_XMSB_REG, thres_xmsb);
/* Set the OOR congifurations */
rslt = bmp5_set_regs(BMP5_REG_OOR_THR_P_LSB, reg_data, 4, dev);
}
}
}
else
{
rslt = BMP5_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This API is used to perform NVM read.
*/
int8_t bmp5_nvm_read(uint8_t nvm_addr, uint16_t *nvm_data, struct bmp5_dev *dev)
{
int8_t rslt;
uint8_t reg_data;
/* Variable to store existing powermode */
enum bmp5_powermode curr_pwrmode;
/* Check for null pointer in the device structure */
rslt = null_ptr_check(dev);
/* Proceed if null check is fine */
if ((rslt == BMP5_OK) && (nvm_data != NULL))
{
rslt = nvm_write_addr(nvm_addr, BMP5_DISABLE, &curr_pwrmode, dev);
if (rslt == BMP5_OK)
{
/* First NVM command for user read sequence */
reg_data = BMP5_NVM_FIRST_CMND;
rslt = bmp5_set_regs(BMP5_REG_CMD, &reg_data, 1, dev);
}
if (rslt == BMP5_OK)
{
/* Read enable NVM command for user read sequence */
reg_data = BMP5_NVM_READ_ENABLE_CMND;
rslt = bmp5_set_regs(BMP5_REG_CMD, &reg_data, 1, dev);
/* Delay required for NVM ready status to change to 1 before NVM read */
dev->delay_us(BMP5_DELAY_US_NVM_READY_READ, dev->intf_ptr);
}
if (rslt == BMP5_OK)
{
rslt = get_nvm_data(nvm_data, dev);
}
if (rslt == BMP5_OK)
{
/* If previous mode is not standbymode return sensor to that previous mode
* after performing NVM
*/
if (curr_pwrmode != BMP5_POWERMODE_STANDBY)
{
rslt = bmp5_set_power_mode(curr_pwrmode, dev);
}
}
}
else
{
rslt = BMP5_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This API is used to perform NVM write.
*/
int8_t bmp5_nvm_write(uint8_t nvm_addr, const uint16_t *nvm_data, struct bmp5_dev *dev)
{
int8_t rslt;
uint8_t nvm_status = 0;
uint8_t reg_data = 0;
uint8_t nvmdata[2];
/* Variable to store existing powermode */
enum bmp5_powermode curr_pwrmode;
/* Check for null pointer in the device structure */
rslt = null_ptr_check(dev);
/* Proceed if null check is fine */
if ((rslt == BMP5_OK) && (nvm_data != NULL))
{
rslt = nvm_write_addr(nvm_addr, BMP5_ENABLE, &curr_pwrmode, dev);
if (rslt == BMP5_OK)
{
/* Write data to be written to NVM address */
rslt = bmp5_get_regs(BMP5_REG_NVM_DATA_LSB, nvmdata, 2, dev);
if (rslt == BMP5_OK)
{
nvmdata[0] = (uint8_t)(*nvm_data & BMP5_NVM_DATA_LSB_MSK);
nvmdata[1] = (uint8_t)((*nvm_data & BMP5_NVM_DATA_MSB_MSK) >> 8);
rslt = bmp5_set_regs(BMP5_REG_NVM_DATA_LSB, nvmdata, 2, dev);
}
}
if (rslt == BMP5_OK)
{
/* First NVM command for user write sequence */
reg_data = BMP5_NVM_FIRST_CMND;
rslt = bmp5_set_regs(BMP5_REG_CMD, &reg_data, 1, dev);
}
if (rslt == BMP5_OK)
{
/* Write enable NVM command for user write sequence */
reg_data = BMP5_NVM_WRITE_ENABLE_CMND;
rslt = bmp5_set_regs(BMP5_REG_CMD, &reg_data, 1, dev);
/* Delay required for NVM ready status to change to 1 */
dev->delay_us(BMP5_DELAY_US_NVM_READY_WRITE, dev->intf_ptr);
}
if (rslt == BMP5_OK)
{
/* Check if NVM ready status = 1, NVM error status = 0 and NVM command error status = 0 */
rslt = get_nvm_status(&nvm_status, dev);
if (rslt == BMP5_OK)
{
if ((nvm_status & BMP5_INT_NVM_RDY) && (!(nvm_status & BMP5_INT_NVM_ERR)) &&
(!(nvm_status & BMP5_INT_NVM_CMD_ERR)))
{
/* Reset NVM prog_en */
reg_data = BMP5_SET_BIT_VAL_0(reg_data, BMP5_NVM_PROG_EN);
rslt = bmp5_set_regs(BMP5_REG_NVM_ADDR, &reg_data, 1, dev);
}
else
{
rslt = BMP5_E_NVM_NOT_READY;
}
}
}
if (rslt == BMP5_OK)
{
/* If previous mode is not standbymode return sensor to that previous mode
* after performing NVM
*/
if (curr_pwrmode != BMP5_POWERMODE_STANDBY)
{
rslt = bmp5_set_power_mode(curr_pwrmode, dev);
}
}
}
else
{
rslt = BMP5_E_NULL_PTR;
}
return rslt;
}
/****************** Static Function Definitions *******************************/
/*!
* @brief This internal API is used to validate the device structure pointer for
* null conditions.
*/
static int8_t null_ptr_check(const struct bmp5_dev *dev)
{
int8_t rslt;
if ((dev == NULL) || (dev->read == NULL) || (dev->write == NULL) || (dev->delay_us == NULL))
{
/* Device structure pointer is not valid */
rslt = BMP5_E_NULL_PTR;
}
else
{
/* Device structure is fine */
rslt = BMP5_OK;
}
return rslt;
}
/*!
* @brief This internal API is used to validate the chip id of the sensor.
*/
static int8_t validate_chip_id(uint8_t chip_id, struct bmp5_dev *dev)
{
int8_t rslt;
if ((chip_id == BMP5_CHIP_ID_PRIM) || (chip_id == BMP5_CHIP_ID_SEC))
{
/* Updating chip_id in device structure */
dev->chip_id = chip_id;
rslt = BMP5_OK;
}
else
{
rslt = BMP5_E_DEV_NOT_FOUND;
}
return rslt;
}
/*!
* @brief This internal API is used to validate the post power-up procedure.
*/
static int8_t power_up_check(struct bmp5_dev *dev)
{
int8_t rslt;
uint8_t nvm_status;
uint8_t por_status;
rslt = get_nvm_status(&nvm_status, dev);
if (rslt == BMP5_OK)
{
/* Check if nvm_rdy status = 1 and nvm_err status = 0 to proceed */
if ((nvm_status & BMP5_INT_NVM_RDY) && (!(nvm_status & BMP5_INT_NVM_ERR)))
{
rslt = bmp5_get_interrupt_status(&por_status, dev);
if (rslt == BMP5_OK)
{
/* Check if por/soft-reset complete status = 1 to proceed */
if (por_status & BMP5_INT_ASSERTED_POR_SOFTRESET_COMPLETE)
{
rslt = BMP5_OK;
}
else
{
rslt = BMP5_E_POWER_UP;
}
}
}
else
{
rslt = BMP5_E_POWER_UP;
}
}
return rslt;
}
/*!
* @brief This internal API is used to check if sensor is in deepstandby mode.
*/
static int8_t check_deepstandby_mode(enum bmp5_powermode *powermode, struct bmp5_dev *dev)
{
int8_t rslt;
uint8_t fifo_frame_sel;
struct bmp5_iir_config iir_cfg = { 0 };
struct bmp5_osr_odr_press_config osr_odr_press_cfg = { 0 };
rslt = bmp5_get_regs(BMP5_REG_FIFO_SEL, &fifo_frame_sel, 1, dev);
if (rslt == BMP5_OK)
{
fifo_frame_sel = BMP5_GET_BITS_POS_0(fifo_frame_sel, BMP5_FIFO_FRAME_SEL);
rslt = bmp5_get_osr_odr_press_config(&osr_odr_press_cfg, dev);
if (rslt == BMP5_OK)
{
rslt = bmp5_get_iir_config(&iir_cfg, dev);
/* As per datasheet odr should be less than 5Hz. But register value for 5Hz is less than 4Hz and so,
* thus in this below condition odr is checked whether greater than 5Hz macro.
*/
if ((osr_odr_press_cfg.odr > BMP5_ODR_05_HZ) && (fifo_frame_sel == BMP5_DISABLE) &&
(iir_cfg.set_iir_t == BMP5_IIR_FILTER_BYPASS) && (iir_cfg.set_iir_p == BMP5_IIR_FILTER_BYPASS))
{
*powermode = BMP5_POWERMODE_DEEP_STANDBY;
}
}
}
return rslt;
}
/*!
* @brief This internal API is used to set sensor in deep standby mode.
*/
static int8_t set_deep_standby_mode(struct bmp5_dev *dev)
{
int8_t rslt;
uint8_t reg_data;
rslt = bmp5_get_regs(BMP5_REG_ODR_CONFIG, &reg_data, 1, dev);
if (rslt == BMP5_OK)
{
/* Setting deep_dis = 0(BMP5_DEEP_ENABLED) enables the deep standby mode */
reg_data = BMP5_SET_BIT_VAL_0(reg_data, BMP5_DEEP_DISABLE);
/* Set ODR less then 5Hz - ODR used is 1Hz */
reg_data = BMP5_SET_BITSLICE(reg_data, BMP5_ODR, BMP5_ODR_01_HZ);
/* Write the value to the odr config register(0x37) */
rslt = bmp5_set_regs(BMP5_REG_ODR_CONFIG, &reg_data, 1, dev);
if (rslt == BMP5_OK)
{
rslt = bmp5_get_regs(BMP5_REG_DSP_IIR, &reg_data, 1, dev);
if (rslt == BMP5_OK)
{
/* Set iir_t and iir_p as Bypass(0x00) */
/* The register holds only iir_t and iir_p and the last 2 bits are reserved.
* Thus using the macro BMP5_IIR_BYPASS(0xC0) the register value is set as zero.
*/
reg_data = reg_data & BMP5_IIR_BYPASS;
/* Write the value to the IIR register(0x31) */
rslt = bmp5_set_regs(BMP5_REG_DSP_IIR, &reg_data, 1, dev);
}
}
if (rslt == BMP5_OK)
{
rslt = bmp5_get_regs(BMP5_REG_FIFO_SEL, &reg_data, 1, dev);
if (rslt == BMP5_OK)
{
/* Disable fifo frame selct */
reg_data = BMP5_SET_BIT_VAL_0(reg_data, BMP5_FIFO_FRAME_SEL);
/* Write the value to the fifo select register(0x18) */
rslt = bmp5_set_regs(BMP5_REG_FIFO_SEL, &reg_data, 1, dev);
}
}
}
return rslt;
}
/*!
* @brief This internal API is used to set sensor in standby or normal or forced or continous powermode.
*/
static int8_t set_power_mode(enum bmp5_powermode powermode, struct bmp5_dev *dev)
{
int8_t rslt;
uint8_t reg_data;
rslt = bmp5_get_regs(BMP5_REG_ODR_CONFIG, &reg_data, 1, dev);
if (rslt == BMP5_OK)
{
/* Setting deep_dis = 1(BMP5_DEEP_DISABLED) disables the deep standby mode */
reg_data = BMP5_SET_BITSLICE(reg_data, BMP5_DEEP_DISABLE, BMP5_DEEP_DISABLED);
reg_data = BMP5_SET_BITS_POS_0(reg_data, BMP5_POWERMODE, powermode);
rslt = bmp5_set_regs(BMP5_REG_ODR_CONFIG, &reg_data, 1, dev);
}
return rslt;
}
/*!
* @brief This internal API is used to set sensor in standby powermode when powermode is deepstandby mode.
*/
static int8_t set_standby_mode(struct bmp5_dev *dev)
{
int8_t rslt;
enum bmp5_powermode pwrmode;
rslt = bmp5_get_power_mode(&pwrmode, dev);
if (rslt == BMP5_OK)
{
if (pwrmode == BMP5_POWERMODE_DEEP_STANDBY)
{
rslt = bmp5_set_power_mode(BMP5_POWERMODE_STANDBY, dev);
}
}
return rslt;
}
#ifdef BMP5_USE_FIXED_POINT
/*!
* @brief This internal API is used to calculate the power of a value.
*/
static uint32_t power(uint8_t base, uint8_t resolution)
{
/* Initialize loop */
uint8_t loop = 1;
/* Initialize variable to store the power of 2 value */
uint32_t value = 1;
for (; loop <= resolution; loop++)
{
value = (uint32_t)(value * base);
}
return value;
}
#endif
/*!
* @brief This internal API is used to set the IIR for temperature and pressure.
*/
static int8_t set_iir_config(const struct bmp5_iir_config *iir_cfg, struct bmp5_dev *dev)
{
int8_t rslt;
/* Variable to set IIR config */
uint8_t reg_data[2];
rslt = bmp5_get_regs(BMP5_REG_DSP_CONFIG, reg_data, 2, dev);
if (rslt == BMP5_OK)
{
reg_data[0] = BMP5_SET_BITSLICE(reg_data[0], BMP5_SHDW_SET_IIR_TEMP, iir_cfg->shdw_set_iir_t);
reg_data[0] = BMP5_SET_BITSLICE(reg_data[0], BMP5_SHDW_SET_IIR_PRESS, iir_cfg->shdw_set_iir_p);
reg_data[0] = BMP5_SET_BITSLICE(reg_data[0], BMP5_IIR_FLUSH_FORCED_EN, iir_cfg->iir_flush_forced_en);
reg_data[1] = iir_cfg->set_iir_t;
reg_data[1] = BMP5_SET_BITSLICE(reg_data[1], BMP5_SET_IIR_PRESS, iir_cfg->set_iir_p);
/* Set IIR configuration */
rslt = bmp5_set_regs(BMP5_REG_DSP_CONFIG, reg_data, 2, dev);
}
return rslt;
}
/*!
* @brief This internal API sets the configuration for IIR of fifo.
*/
static int8_t set_fifo_iir_config(uint8_t set_fifo_iir_t, uint8_t set_fifo_iir_p, struct bmp5_dev *dev)
{
/* Variable to store the function result */
int8_t rslt;
/* Variable to set fifo IIR config */
uint8_t reg_data = 0;
/* Variable to store existing powermode */
enum bmp5_powermode curr_pwrmode;
rslt = bmp5_get_power_mode(&curr_pwrmode, dev);
if (rslt == BMP5_OK)
{
/* Fifo IIR configuration is writable only during STANDBY mode(as per datasheet) */
if (curr_pwrmode != BMP5_POWERMODE_STANDBY)
{
/* If sensor is not in standby mode, set sensor in standby mode */
rslt = bmp5_set_power_mode(BMP5_POWERMODE_STANDBY, dev);
}
if (rslt == BMP5_OK)
{
/* Get fifo IIR configuration */
rslt = bmp5_get_regs(BMP5_REG_DSP_CONFIG, &reg_data, 1, dev);
if (rslt == BMP5_OK)
{
reg_data = BMP5_SET_BITSLICE(reg_data, BMP5_SET_FIFO_IIR_TEMP, set_fifo_iir_t);
reg_data = BMP5_SET_BITSLICE(reg_data, BMP5_SET_FIFO_IIR_PRESS, set_fifo_iir_p);
/* Set fifo IIR configuration */
rslt = bmp5_set_regs(BMP5_REG_DSP_CONFIG, &reg_data, 1, dev);
}
}
/* If previous mode is not standbymode return sensor to that previous mode
* after setting fifo iir configuration
*/
if (rslt == BMP5_OK)
{
/* Since fifo IIR works only in standby mode we are not re-writing to deepstandby mode
* as deep standby mode resets the fifo IIR settings to default
*/
if ((curr_pwrmode != BMP5_POWERMODE_STANDBY) && (curr_pwrmode != BMP5_POWERMODE_DEEP_STANDBY))
{
rslt = bmp5_set_power_mode(curr_pwrmode, dev);
}
}
}
return rslt;
}
/*!
* @brief This internal API is used to set fifo threshold based on the frame type selected.
*/
static int8_t set_fifo_threshold(uint8_t *reg_data, const struct bmp5_fifo *fifo)
{
int8_t rslt = 0;
if ((fifo->frame_sel == BMP5_FIFO_TEMPERATURE_DATA) || (fifo->frame_sel == BMP5_FIFO_PRESSURE_DATA))
{
/* If Pressure or Temperature is selected, maximum 31 frames can be set as threshold */
if (fifo->threshold <= BMP5_FIFO_MAX_THRESHOLD_P_MODE)
{
reg_data[0] = BMP5_SET_BITS_POS_0(reg_data[0], BMP5_FIFO_THRESHOLD, fifo->threshold);
}
else
{
rslt = BMP5_E_INVALID_THRESHOLD;
}
}
else if (fifo->frame_sel == BMP5_FIFO_PRESS_TEMP_DATA)
{
/* If both pressure and temperature is selected, maximum 15 frames can be set as threshold */
if (fifo->threshold <= BMP5_FIFO_MAX_THRESHOLD_P_T_MODE)
{
reg_data[0] = BMP5_SET_BITS_POS_0(reg_data[0], BMP5_FIFO_THRESHOLD, fifo->threshold);
}
else
{
rslt = BMP5_E_INVALID_THRESHOLD;
}
}
return rslt;
}
/*!
* @brief This internal API is used to unpack the fifo data and store it in the bmp5_sensor_data structure.
*/
static int8_t unpack_sensor_data(struct bmp5_sensor_data *sensor_data,
uint16_t *data_index,
const struct bmp5_fifo *fifo)
{
int8_t rslt = 0;
int32_t raw_data_t;
uint32_t raw_data_p;
switch (fifo->frame_sel)
{
case BMP5_FIFO_TEMPERATURE_DATA:
/* Check if fifo frame is empty */
if (!((fifo->data[*data_index] == BMP5_FIFO_EMPTY) && (fifo->data[*data_index + 1] == BMP5_FIFO_EMPTY) &&
(fifo->data[*data_index + 2] == BMP5_FIFO_EMPTY)))
{
raw_data_t =
(int32_t)((uint32_t)fifo->data[*data_index + 2] << 16 | (uint16_t)fifo->data[*data_index + 1] << 8 |
fifo->data[*data_index]);
#ifdef BMP5_USE_FIXED_POINT
/* Division by 2^16(whose equivalent value is 65536) is performed to get temperature data and followed by fixed point digit
* precision in deg C
*/
sensor_data->temperature =
(int64_t)((raw_data_t / (float)65536.0) * (power(10, BMP5_FIXED_POINT_DIGIT_PRECISION)));
#else
/* Division by 2^16(whose equivalent value is 65536) is performed to get temperature data in deg C */
sensor_data->temperature = (float)(raw_data_t / 65536.0);
#endif
sensor_data->pressure = 0.0;
*data_index += 3;
}
else
{
rslt = BMP5_E_FIFO_FRAME_EMPTY;
/* Move the data index to the last byte to mark completion */
*data_index = fifo->length;
}
break;
case BMP5_FIFO_PRESSURE_DATA:
/* Check if fifo frame is empty */
if (!((fifo->data[*data_index] == BMP5_FIFO_EMPTY) && (fifo->data[*data_index + 1] == BMP5_FIFO_EMPTY) &&
(fifo->data[*data_index + 2] == BMP5_FIFO_EMPTY)))
{
raw_data_p =
(uint32_t)((uint32_t)fifo->data[(*data_index) + 2] << 16 |
(uint16_t)fifo->data[(*data_index) + 1] << 8 |
fifo->data[*data_index]);
#ifdef BMP5_USE_FIXED_POINT
/* Division by 2^6(whose equivalent value is 64) is performed to get pressure data and followed by fixed point digit
* precision in Pa
*/
sensor_data->pressure =
(uint64_t)((raw_data_p / (float)64.0) * (power(10, BMP5_FIXED_POINT_DIGIT_PRECISION)));
#else
/* Division by 2^6(whose equivalent value is 64) is performed to get pressure data in Pa */
sensor_data->pressure = (float)(raw_data_p / 64.0);
#endif
sensor_data->temperature = 0.0;
*data_index += 3;
}
else
{
rslt = BMP5_E_FIFO_FRAME_EMPTY;
/* Move the data index to the last byte to mark completion */
*data_index = fifo->length;
}
break;
case BMP5_FIFO_PRESS_TEMP_DATA:
if (!((fifo->data[*data_index] == BMP5_FIFO_EMPTY) && (fifo->data[*data_index + 1] == BMP5_FIFO_EMPTY) &&
(fifo->data[*data_index + 2] == BMP5_FIFO_EMPTY) &&
(fifo->data[*data_index + 3] == BMP5_FIFO_EMPTY) &&
(fifo->data[*data_index + 4] == BMP5_FIFO_EMPTY) && (fifo->data[*data_index + 5] == BMP5_FIFO_EMPTY)))
{
raw_data_t =
(int32_t)((uint32_t)fifo->data[*data_index + 2] << 16 | (uint16_t)fifo->data[*data_index + 1] << 8 |
fifo->data[*data_index]);
raw_data_p =
(uint32_t)((uint32_t)fifo->data[(*data_index) + 5] << 16 |
(uint16_t)fifo->data[(*data_index) + 4] << 8 |
fifo->data[*data_index + 3]);
#ifdef BMP5_USE_FIXED_POINT
/* Division by 2^16(whose equivalent value is 65536) is performed to get temperature data and followed by fixed point digit
* precision in deg C
*/
sensor_data->temperature =
(int64_t)((raw_data_t / (float)(float)64.0) * (power(10, BMP5_FIXED_POINT_DIGIT_PRECISION)));
/* Division by 2^6(whose equivalent value is 64) is performed to get pressure data and followed by fixed point digit
* precision in Pa
*/
sensor_data->pressure =
(uint64_t)((raw_data_p / (float)64.0) * (power(10, BMP5_FIXED_POINT_DIGIT_PRECISION)));
#else
/* Division by 2^16(whose equivalent value is 65536) is performed to get temperature data in deg C */
sensor_data->temperature = (float)(raw_data_t / 65536.0);
/* Division by 2^6(whose equivalent value is 64) is performed to get pressure data in Pa */
sensor_data->pressure = (float)(raw_data_p / 64.0);
#endif
*data_index += 6;
}
else
{
rslt = BMP5_E_FIFO_FRAME_EMPTY;
/* Move the data index to the last byte to mark completion */
*data_index = fifo->length;
}
break;
default:
sensor_data->pressure = 0.0;
sensor_data->temperature = 0.0;
break;
}
return rslt;
}
/*!
* @brief This internal API sets the IIR configuration and count limit of OOR pressure.
*/
static int8_t set_oor_iir_count_limit(uint8_t set_oor_iir_p, uint8_t set_count_limit, struct bmp5_dev *dev)
{
int8_t rslt;
uint8_t reg_data = 0;
/* Variable to store existing powermode */
enum bmp5_powermode curr_pwrmode;
rslt = bmp5_get_power_mode(&curr_pwrmode, dev);
if (rslt == BMP5_OK)
{
/* OOR IIR configuration and count limit is writable only during STANDBY mode(as per datasheet) */
if (curr_pwrmode != BMP5_POWERMODE_STANDBY)
{
/* If sensor is not in standby mode, set sensor in standby mode */
rslt = bmp5_set_power_mode(BMP5_POWERMODE_STANDBY, dev);
}
if (rslt == BMP5_OK)
{
/* Get OOR pressure IIR configuration */
rslt = bmp5_get_regs(BMP5_REG_DSP_CONFIG, &reg_data, 1, dev);
if (rslt == BMP5_OK)
{
reg_data = BMP5_SET_BITSLICE(reg_data, BMP5_OOR_SEL_IIR_PRESS, set_oor_iir_p);
/* Set OOR pressure IIR configuration */
rslt = bmp5_set_regs(BMP5_REG_DSP_CONFIG, &reg_data, 1, dev);
}
if (rslt == BMP5_OK)
{
/* Get OOR pressure count limit */
rslt = bmp5_get_regs(BMP5_REG_OOR_CONFIG, &reg_data, 1, dev);
}
if (rslt == BMP5_OK)
{
reg_data = BMP5_SET_BITSLICE(reg_data, BMP5_OOR_COUNT_LIMIT, set_count_limit);
}
if (rslt == BMP5_OK)
{
/* Set OOR pressure count limit */
rslt = bmp5_set_regs(BMP5_REG_OOR_CONFIG, &reg_data, 1, dev);
}
}
/* If previous mode is not standbymode return sensor to that previous mode
* after setting oor iir configuration and count limit
*/
if (rslt == BMP5_OK)
{
/* Since oor IIR and count limit works only in standby mode we are not re-writing to deepstandby mode
* as deep standby mode resets the oor iir configuration and count limit to default
*/
if ((curr_pwrmode != BMP5_POWERMODE_STANDBY) && (curr_pwrmode != BMP5_POWERMODE_DEEP_STANDBY))
{
rslt = bmp5_set_power_mode(curr_pwrmode, dev);
}
}
}
return rslt;
}
/*!
* @brief This internal API is used to write the nvm address and prog_en.
*/
static int8_t nvm_write_addr(uint8_t nvm_addr, uint8_t prog_en, enum bmp5_powermode *curr_pwrmode, struct bmp5_dev *dev)
{
int8_t rslt;
if ((nvm_addr >= BMP5_NVM_START_ADDR) && (nvm_addr <= BMP5_NVM_END_ADDR))
{
/* Get current powermode */
rslt = bmp5_get_power_mode(curr_pwrmode, dev);
if (rslt == BMP5_OK)
{
/* NVM write can be performed only during STANDBY mode */
if (*curr_pwrmode != BMP5_POWERMODE_STANDBY)
{
/* If sensor is not in standby mode, set sensor in standby mode */
rslt = bmp5_set_power_mode(BMP5_POWERMODE_STANDBY, dev);
}
if (rslt == BMP5_OK)
{
/* Write the NVM address and set NVM prog_en with respect to NVM read/write selected. */
rslt = set_nvm_addr(nvm_addr, prog_en, dev);
}
}
}
else
{
rslt = BMP5_E_NVM_INVALID_ADDR;
}
return rslt;
}
/*!
* @brief This internal API is used to set the nvm address and prog_enable based on NVM read/write selected.
*/
static int8_t set_nvm_addr(uint8_t nvm_addr, uint8_t prog_en, struct bmp5_dev *dev)
{
int8_t rslt;
uint8_t nvm_status;
uint8_t reg_data;
/* Check if NVM ready status = 1 */
rslt = get_nvm_status(&nvm_status, dev);
if (rslt == BMP5_OK)
{
if (nvm_status & BMP5_INT_NVM_RDY)
{
rslt = bmp5_get_regs(BMP5_REG_NVM_ADDR, &reg_data, 1, dev);
if (rslt == BMP5_OK)
{
/* Write the NVM address */
reg_data = BMP5_SET_BITS_POS_0(reg_data, BMP5_NVM_ADDR, nvm_addr);
if (prog_en == BMP5_ENABLE)
{
/* Set bit nvm_prog_en as 1 if NVM write is selected */
reg_data = BMP5_SET_BITSLICE(reg_data, BMP5_NVM_PROG_EN, prog_en);
}
else
{
/* Set bit nvm_prog_en as 0 if NVM read is selected */
reg_data = BMP5_SET_BIT_VAL_0(reg_data, BMP5_NVM_PROG_EN);
}
rslt = bmp5_set_regs(BMP5_REG_NVM_ADDR, &reg_data, 1, dev);
}
}
else
{
rslt = BMP5_E_NVM_NOT_READY;
}
}
return rslt;
}
/*!
* @brief This internal API is used to read the nvm data.
*/
static int8_t get_nvm_data(uint16_t *nvm_data, struct bmp5_dev *dev)
{
int8_t rslt;
uint8_t nvm_status;
uint8_t nvmdata[2];
if (nvm_data != NULL)
{
rslt = get_nvm_status(&nvm_status, dev);
if (rslt == BMP5_OK)
{
/* Check if NVM ready status = 1, NVM error status = 0 and NVM command error status = 0 */
if ((nvm_status & BMP5_INT_NVM_RDY) && (!(nvm_status & BMP5_INT_NVM_ERR)) &&
(!(nvm_status & BMP5_INT_NVM_CMD_ERR)))
{
/* Read the NVM data from the register address */
rslt = bmp5_get_regs(BMP5_REG_NVM_DATA_LSB, nvmdata, 2, dev);
if (rslt == BMP5_OK)
{
(*nvm_data) = (uint16_t)((nvmdata[1] << 8) | nvmdata[0]);
}
}
else
{
rslt = BMP5_E_NVM_NOT_READY;
}
}
}
else
{
rslt = BMP5_E_NULL_PTR;
}
return rslt;
}
/*!
* @brief This API is used to get nvm status.
*/
static int8_t get_nvm_status(uint8_t *nvm_status, struct bmp5_dev *dev)
{
int8_t rslt;
if (nvm_status != NULL)
{
rslt = bmp5_get_regs(BMP5_REG_STATUS, nvm_status, 1, dev);
}
else
{
rslt = BMP5_E_NULL_PTR;
}
return rslt;
}
/**
* Copyright (c) 2022 Bosch Sensortec GmbH. All rights reserved.
*
* BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @file bmp5.h
* @date 2022-08-11
* @version v1.1.1
*
*/
/*!
* @defgroup bmp5 BMP5
* @brief Sensor driver for BMP5 sensor
*/
#ifndef BMP5_H_
#define BMP5_H_
/*! CPP guard */
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************************/
/*! Header files
****************************************************************************/
#include "bmp5_defs.h"
/***************************************************************************/
/*! BMP5 User Interface function prototypes
****************************************************************************/
/**
* \ingroup bmp5
* \defgroup bmp5ApiInit Initialization
* @brief Initialize the sensor and device structure
*/
/*!
* \ingroup bmp5ApiInit
* \page bmp5_api_bmp5_init bmp5_init
* \code
* int8_t bmp5_init(struct bmp5_dev *dev);
* \endcode
* @details This API is the entry point. Call this API before using all other APIs.
* This API reads the chip-id of the sensor and sets the resolution, feature
* length and the type of variant.
*
* @param[in,out] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status.
* @return 0 -> Success
* @return < 0 -> Fail
*
*/
int8_t bmp5_init(struct bmp5_dev *dev);
/**
* \ingroup bmp5
* \defgroup bmp5ApiRegister Registers
* @brief Generic API for accessing sensor registers
*/
/*!
* \ingroup bmp5ApiRegister
* \page bmp5_api_bmp5_get_regs bmp5_get_regs
* \code
* int8_t bmp5_get_regs(uint8_t reg_addr, uint8_t *data, uint32_t len, struct bmp5_dev *dev);
* \endcode
* @details This API reads the data from the given register address of sensor.
*
* @param[in] reg_addr : Register address from where the data to be read.
* @param[out] data : Pointer to data buffer to store the read data.
* @param[in] len : No of bytes of data to be read.
* @param[in,out] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_get_regs(uint8_t reg_addr, uint8_t *data, uint32_t len, struct bmp5_dev *dev);
/*!
* \ingroup bmp5ApiRegister
* \page bmp5_api_bmp5_set_regs bmp5_set_regs
* \code
* int8_t bmp5_set_regs(uint8_t reg_addr, const uint8_t *data, uint32_t len, struct bmp5_dev *dev);
* \endcode
* @details This API writes the given data to the register address of sensor.
*
* @param[in] reg_addr : Register address where the data is to be written.
* @param[in] data : Pointer to data buffer, whose data is to be written
* in the sensor.
* @param[in] len : No of bytes of data to be writen.
* @param[in,out] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_set_regs(uint8_t reg_addr, const uint8_t *data, uint32_t len, struct bmp5_dev *dev);
/**
* \ingroup bmp5
* \defgroup bmp5ApiSystem System
* @brief API that performs system-level operations
*/
/*!
* \ingroup bmp5ApiSystem
* \page bmp5_api_bmp5_soft_reset bmp5_soft_reset
* \code
* int8_t bmp5_soft_reset(struct bmp5_dev *dev);
* \endcode
* @details This API is used to soft-reset the sensor where all the registers are reset to their default values.
*
* @note If this register is set using I2C, an ACK will NOT be transmitted to
* the host.
*
* @param[in] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status.
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_soft_reset(struct bmp5_dev *dev);
/**
* \ingroup bmp5
* \defgroup bmp5ApiStatus NVM and Interrupt status
* @brief NVM and Interrupt status API
*/
/*!
* \ingroup bmp5ApiStatus
* \page bmp5_api_bmp5_get_interrupt_status bmp5_get_interrupt_status
* \code
* int8_t bmp5_get_interrupt_status(uint8_t *int_status, struct bmp5_dev *dev);
* \endcode
* @details This API is used to get the interrupt status (data ready interrupt, fifo full interrupt,
* fifo threshold interrupt, pressure out of range interrupt and power-on reset/software reset complete interrupt).
*
* @param[out] int_status : Variable to store interrupt status.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @note : Below are values of int_status possible.
*
*@verbatim
* Macros | Functionality
* -----------------------------------------|----------------------------
* BMP5_INT_ASSERTED_DRDY | Data ready interrupt asserted
* BMP5_INT_ASSERTED_FIFO_FULL | Fifo full interrupt asserted
* BMP5_INT_ASSERTED_FIFO_THRES | Fifo threshold interrupt asserted
* BMP5_INT_ASSERTED_PRESSURE_OOR | Pressure out of range interrupt asserted
* BMP5_INT_ASSERTED_POR_SOFTRESET_COMPLETE | Power-on reset/Software reset complete interrupt asserted
*@endverbatim
*
* @return Result of API execution status.
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_get_interrupt_status(uint8_t *int_status, struct bmp5_dev *dev);
/**
* \ingroup bmp5
* \defgroup bmp5ApiPowermode Powermode
* @brief Powermode of the sensor API
*/
/*!
* \ingroup bmp5ApiPowermode
* \page bmp5_api_bmp5_set_power_mode bmp5_set_power_mode
* \code
* int8_t bmp5_set_power_mode(enum bmp5_powermode powermode, struct bmp5_dev *dev);
* \endcode
* @details This API sets the power mode of the sensor.
*
* @param[in] powermode : Select powermode.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @note Below mentioned are the possible powermode that can be set by the user.
*
*@verbatim
* powermode | Macros
* -----------------|-------------------
* 0 | BMP5_POWERMODE_STANBY
* 1 | BMP5_POWERMODE_NORMAL
* 2 | BMP5_POWERMODE_FORCED
* 3 | BMP5_POWERMODE_CONTINOUS
* 4 | BMP5_POWERMODE_DEEP_STANBY
*@endverbatim
*
* @return Result of API execution status.
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_set_power_mode(enum bmp5_powermode powermode, struct bmp5_dev *dev);
/*!
* \ingroup bmp5ApiPowermode
* \page bmp5_api_bmp5_get_power_mode bmp5_get_power_mode
* \code
* int8_t bmp5_get_power_mode(enum bmp5_powermode *powermode, struct bmp5_dev *dev);
* \endcode
* @details This API gets the power mode of the sensor.
*
* @param[out] powermode : To store the power mode.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @note Below mentioned are the possible powermode from the sensor
*
*@verbatim
* powermode | Macros
* -----------------|-------------------
* 0 | BMP5_POWERMODE_STANBY
* 1 | BMP5_POWERMODE_NORMAL
* 2 | BMP5_POWERMODE_FORCED
* 3 | BMP5_POWERMODE_CONTINOUS
* 4 | BMP5_POWERMODE_DEEP_STANBY
*@endverbatim
*
* @return Result of API execution status.
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_get_power_mode(enum bmp5_powermode *powermode, struct bmp5_dev *dev);
/**
* \ingroup bmp5
* \defgroup bmp5ApiData Sensor Data
* @brief Get Sensor data
*/
/*!
* \ingroup bmp5ApiData
* \page bmp5_api_bmp5_get_sensor_data bmp5_get_sensor_data
* \code
* int8_t bmp5_get_sensor_data(struct bmp5_sensor_data *sensor_data,
* const struct bmp5_osr_odr_press_config *osr_odr_press_cfg, struct bmp5_dev *dev);
* \endcode
* @details This API reads the temperature(deg C) or both pressure(Pa) and temperature(deg C) data from the
* sensor and store it in the bmp5_sensor_data structure instance passed by the user.
*
* @param[out] sensor_data : Structure instance of bmp5_sensor_data.
* @param[in] osr_odr_press_cfg : Structure instance of bmp5_osr_odr_press_config.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @note If fixed point(BMP5_USE_FIXED_POINT) is selected then data return type is uin64_t for pressure
* and int64_t for temperature. While for floating point(BMP5_USE_FLOATING_POINT) data return type is float for
* pressure and temperature.
*
* @return Result of API execution status.
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_get_sensor_data(struct bmp5_sensor_data *sensor_data,
const struct bmp5_osr_odr_press_config *osr_odr_press_cfg,
struct bmp5_dev *dev);
/**
* \ingroup bmp5
* \defgroup bmp5ApiInterrupt Interrupt
* @brief Interrupt API
*/
/*!
* \ingroup bmp5ApiInterrupt
* \page bmp5_api_bmp5_int_source_select bmp5_int_source_select
* \code
* int8_t bmp5_int_source_select(const struct bmp5_int_source_select *int_source_select, struct bmp5_dev *dev);
* \endcode
* @details This API is used to enable the interrupts(drdy interrupt, fifo full interrupt,
* fifo threshold enable and pressure data out of range interrupt).
*
* @param[in] int_source_select : Structure instance of bmp5_int_enable.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status.
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_int_source_select(const struct bmp5_int_source_select *int_source_select, struct bmp5_dev *dev);
/*!
* \ingroup bmp5ApiInterrupt
* \page bmp5_api_bmp5_configure_interrupt bmp5_configure_interrupt
* \code
* int8_t bmp5_configure_interrupt(enum bmp5_intr_mode int_mode,
* enum bmp5_intr_polarity int_pol,
* enum bmp5_intr_drive int_od,
* enum bmp5_intr_en_dis int_en,
* struct bmp5_dev *dev);
* \endcode
* @details This API is used to configure the interrupt settings.
*
* @param[in] int_mode : Sets either latched or pulsed.
* @param[in] int_pol : Sets either polarity high or low.
* @param[in] int_od : Sets either open drain or push pull.
* @param[in] int_en : Enable/ Disable interrupt pin.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status.
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_configure_interrupt(enum bmp5_intr_mode int_mode,
enum bmp5_intr_polarity int_pol,
enum bmp5_intr_drive int_od,
enum bmp5_intr_en_dis int_en,
struct bmp5_dev *dev);
/**
* \ingroup bmp5
* \defgroup bmp5ApiSettings Settings
* @brief Get/set sensor settings APIs
*/
/*!
* \ingroup bmp5ApiSettings
* \page bmp5_api_bmp5_get_osr_odr_press_config bmp5_get_osr_odr_press_config
* \code
* int8_t bmp5_get_osr_odr_press_config(struct bmp5_osr_odr_press_config *osr_odr_press_cfg, struct bmp5_dev *dev);
* \endcode
* @details This API gets the configuration for oversampling of temperature, oversampling of
* pressure and ODR configuration for normal mode along with pressure enable.
*
* @param[out] osr_odr_press_cfg : Structure instance of bmp5_osr_odr_press_config.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status.
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_get_osr_odr_press_config(struct bmp5_osr_odr_press_config *osr_odr_press_cfg, struct bmp5_dev *dev);
/*!
* \ingroup bmp5ApiSettings
* \page bmp5_api_bmp5_set_osr_odr_press_config bmp5_set_osr_odr_press_config
* \code
* int8_t bmp5_set_osr_odr_press_config(const struct bmp5_osr_odr_press_config *osr_odr_press_cfg, struct bmp5_dev *dev);
* \endcode
* @details This API sets the configuration for oversampling of temperature, oversampling of
* pressure and ODR configuration along with pressure enable.
*
* @param[in] osr_odr_press_cfg : Structure instance of bmp5_osr_odr_press_config.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @note If ODR is set to a value higher than 5Hz then powermode is set as standby mode, as ODR value greater than 5HZ
* without disabling deep-standby mode makes powermode invalid.
*
* @return Result of API execution status.
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_set_osr_odr_press_config(const struct bmp5_osr_odr_press_config *osr_odr_press_cfg, struct bmp5_dev *dev);
/*!
* \ingroup bmp5ApiSettings
* \page bmp5_api_bmp5_get_iir_config bmp5_get_iir_config
* \code
* int8_t bmp5_get_iir_config(struct bmp5_iir_config *iir_cfg, struct bmp5_dev *dev);
* \endcode
* @details This API gets the configuration for IIR of temperature and pressure.
*
* @param[out] iir_cfg : Structure instance of bmp5_iir_config.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status.
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_get_iir_config(struct bmp5_iir_config *iir_cfg, struct bmp5_dev *dev);
/*!
* \ingroup bmp5ApiSettings
* \page bmp5_api_bmp5_set_iir_config bmp5_set_iir_config
* \code
* int8_t bmp5_set_iir_config(const struct bmp5_iir_config *iir_cfg, struct bmp5_dev *dev);
* \endcode
* @details This API sets the configuration for IIR of temperature and pressure.
*
* @note
* 1. The IIR configuration can be performed only in standby mode. So in this API before updating IIR
* configuration powermode is switched to standby mode and reverted back to earlier powermode after
* IIR configuration is updated.
* 2. If IIR value for both temperature and pressure is set a value other than bypass then powermode is set
* as standby mode, as IIR with value other than bypass without disabling deep-standby mode makes powermode invalid.
*
* @param[in] iir_cfg : Structure instance of bmp5_iir_config.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status.
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_set_iir_config(const struct bmp5_iir_config *iir_cfg, struct bmp5_dev *dev);
/*!
* \ingroup bmp5ApiSettings
* \page bmp5_api_bmp5_get_osr_odr_eff bmp5_get_osr_odr_eff
* \code
* int8_t bmp5_get_osr_odr_eff(struct bmp5_osr_odr_eff *osr_odr_eff, struct bmp5_dev *dev);
* \endcode
* @details This API gets the configuration for effective OSR of temperature,
* effective OSR of pressure and ODR valid status.
*
* @param[out] osr_odr_eff : Structure instance of bmp5_osr_odr_eff.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status.
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_get_osr_odr_eff(struct bmp5_osr_odr_eff *osr_odr_eff, struct bmp5_dev *dev);
/**
* \ingroup bmp5
* \defgroup bmp5ApiFIFO FIFO
* @brief FIFO operations of the sensor
*/
/*!
* \ingroup bmp5ApiFIFO
* \page bmp5_api_bmp5_get_fifo_configuration bmp5_get_fifo_configuration
* \code
* int8_t bmp5_get_fifo_configuration(struct bmp5_fifo *fifo, struct bmp5_dev *dev);
* \endcode
* @details This API used to get the configurations of fifo from the sensor.
*
* @param[out] fifo : Structure instance of bmp5_fifo.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status.
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_get_fifo_configuration(struct bmp5_fifo *fifo, struct bmp5_dev *dev);
/*!
* \ingroup bmp5ApiFIFO
* \page bmp5_api_bmp5_set_fifo_configuration bmp5_set_fifo_configuration
* \code
* int8_t bmp5_set_fifo_configuration(const struct bmp5_fifo *fifo, struct bmp5_dev *dev);
* \endcode
* @details This API used to set the configurations of fifo in the sensor.
*
* @param[in] fifo : Structure instance of bmp5_fifo.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @note If Fifo frame selection is enabled then powermode is set as standby mode, as fifo frame selection
* enabled without disabling deep-standby mode makes powermode invalid.
*
* @return Result of API execution status.
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_set_fifo_configuration(const struct bmp5_fifo *fifo, struct bmp5_dev *dev);
/*!
* \ingroup bmp5ApiFIFO
* \page bmp5_api_bmp5_get_fifo_len bmp5_get_fifo_len
* \code
* int8_t bmp5_get_fifo_len(uint8_t *fifo_len, struct bmp5_fifo *fifo, struct bmp5_dev *dev);
* \endcode
* @details This API is used to get the length of fifo from the sensor.
*
* @param[out] fifo_len : Variable to store fifo length.
* @param[out] fifo : Structure instance of bmp5_fifo.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status.
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_get_fifo_len(uint16_t *fifo_len, struct bmp5_fifo *fifo, struct bmp5_dev *dev);
/*!
* \ingroup bmp5ApiFIFO
* \page bmp5_api_bmp5_get_fifo_data bmp5_get_fifo_data
* \code
* int8_t bmp5_get_fifo_data(struct bmp5_fifo *fifo, struct bmp5_dev *dev);
* \endcode
* @details This API is used to get the fifo data from the sensor.
*
* @param[out] fifo : Structure instance of bmp5_fifo.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status.
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_get_fifo_data(struct bmp5_fifo *fifo, struct bmp5_dev *dev);
/*!
* \ingroup bmp5ApiFIFO
* \page bmp5_api_bmp5_extract_fifo_data bmp5_extract_fifo_data
* \code
* int8_t bmp5_extract_fifo_data(const struct bmp5_fifo *fifo, struct bmp5_sensor_data *sensor_data);
* \endcode
* @details This API extract the temperature and/or pressure data from the fifo data which is
* already read from the fifo.
*
* @param[in] fifo : Structure instance of bmp5_fifo.
* @param[out] sensor_data : Structure instance of bmp5_sensor_data.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status.
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_extract_fifo_data(const struct bmp5_fifo *fifo, struct bmp5_sensor_data *sensor_data);
/**
* \ingroup bmp5
* \defgroup bmp5ApiOOR OOR pressure
* @brief OOR pressure API
*/
/*!
* \ingroup bmp5ApiOOR
* \page bmp5_api_bmp5_get_oor_configuration bmp5_get_oor_configuration
* \code
* int8_t bmp5_get_oor_configuration(struct bmp5_oor_press_configuration *oor_press_config, struct bmp5_dev *dev);
* \endcode
* @details This API gets the configuration for out-of-range pressure threshold, range
* count limit and IIR.
*
* @param[out] oor_press_config : Structure instance of bmp5_oor_press_configuration.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status.
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_get_oor_configuration(struct bmp5_oor_press_configuration *oor_press_config, struct bmp5_dev *dev);
/*!
* \ingroup bmp5ApiOOR
* \page bmp5_api_bmp5_set_oor_configuration bmp5_set_oor_configuration
* \code
* int8_t bmp5_set_oor_configuration(const struct bmp5_oor_press_configuration *oor_press_config, struct bmp5_dev *dev);
* \endcode
* @details This API sets the configuration for out-of-range pressure threshold, range
* count limit and IIR.
*
* @param[in] oor_press_config : Structure instance of bmp5_oor_press_configuration.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status.
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_set_oor_configuration(const struct bmp5_oor_press_configuration *oor_press_config, struct bmp5_dev *dev);
/**
* \ingroup bmp5
* \defgroup bmp5ApiNVM NVM
* @brief NVM operation of the sensor
*/
/*!
* \ingroup bmp5ApiNVM
* \page bmp5_api_bmp5_nvm_read bmp5_nvm_read
* \code
* int8_t bmp5_nvm_read(uint8_t nvm_addr, uint16_t *nvm_data, struct bmp5_dev *dev);
* \endcode
* @details This API is used to perform NVM read.
*
* @param[in] nvm_addr : Variable that holds the nvm address.
* @param[out] nvm_data : Variable to store nvm data.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status.
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_nvm_read(uint8_t nvm_addr, uint16_t *nvm_data, struct bmp5_dev *dev);
/*!
* \ingroup bmp5ApiNVM
* \page bmp5_api_bmp5_nvm_write bmp5_nvm_write
* \code
* int8_t bmp5_nvm_write(uint8_t nvm_addr, const uint16_t *nvm_data, struct bmp5_dev *dev);
* \endcode
* @details This API used to perform NVM write.
*
* @param[in] nvm_addr : Variable that holds the nvm address.
* @param[in] nvm_data : Variable that holds the nvm data.
* @param[in] dev : Structure instance of bmp5_dev.
*
* @return Result of API execution status.
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_nvm_write(uint8_t nvm_addr, const uint16_t *nvm_data, struct bmp5_dev *dev);
#ifdef __cplusplus
}
#endif /* End of CPP guard */
#endif /* End of header guard macro */
/**
* Copyright (c) 2022 Bosch Sensortec GmbH. All rights reserved.
*
* BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @file bmp5_defs.h
* @date 2022-08-11
* @version v1.1.1
*
*/
/*! @file bmp5_defs.h
* @brief Sensor Driver for BMP5 sensor
*/
#ifndef _BMP5_DEFS_H
#define _BMP5_DEFS_H
/******************************************************************************/
/*! @name HEADER INCLUDES */
/******************************************************************************/
#ifdef __KERNEL__
#include <linux/types.h>
#else
#include <stdint.h>
#include <stddef.h>
#include <math.h>
#endif
/******************************************************************************/
/*! @name COMMON MACROS */
/******************************************************************************/
#ifdef __KERNEL__
#if (!defined(UINT8_C) && !defined(INT8_C))
#define INT8_C(x) S8_C(x)
#define UINT8_C(x) U8_C(x)
#endif
#if (!defined(UINT16_C) && !defined(INT16_C))
#define INT16_C(x) S16_C(x)
#define UINT16_C(x) U16_C(x)
#endif
#if (!defined(INT32_C) && !defined(UINT32_C))
#define INT32_C(x) S32_C(x)
#define UINT32_C(x) U32_C(x)
#endif
#if (!defined(INT64_C) && !defined(UINT64_C))
#define INT64_C(x) S64_C(x)
#define UINT64_C(x) U64_C(x)
#endif
#else /* __KERNEL__ */
#if (!defined(UINT8_C) && !defined(INT8_C))
#define INT8_C(x) (x)
#define UINT8_C(x) (x##U)
#endif
#if (!defined(UINT16_C) && !defined(INT16_C))
#define INT16_C(x) (x)
#define UINT16_C(x) (x##U)
#endif
#if (!defined(INT32_C) && !defined(UINT32_C))
#define INT32_C(x) (x)
#define UINT32_C(x) (x##U)
#endif
#if (!defined(INT64_C) && !defined(UINT64_C))
#define INT64_C(x) (x##LL)
#define UINT64_C(x) (x##ULL)
#endif
#endif /* __KERNEL__ */
/*! @name C standard macros */
#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *) 0)
#endif
#endif
/******************************************************************************/
/*! @name Compiler switch macros Definitions */
/******************************************************************************/
#ifndef BMP5_USE_FIXED_POINT /*< Check if floating point (using BMP5_USE_FIXED_POINT) is enabled */
#ifndef BMP5_USE_FLOATING_POINT /*< If fixed point is not enabled then enable BMP5_USE_FLOATING_POINT */
#define BMP5_USE_FLOATING_POINT
#endif
#endif
#ifdef BMP5_USE_FIXED_POINT /*< If Fixed point is defined set BMP5_FIXED_POINT_DIGIT_PRECISION */
#ifdef BMP5_FIXED_POINT_DIGIT_PRECISION
#if BMP5_FIXED_POINT_DIGIT_PRECISION > 6 /* If BMP5_FIXED_POINT_DIGIT_PRECISION(provided by user) is greater than 6 then
* set precision value to 6 digits */
#undef BMP5_FIXED_POINT_DIGIT_PRECISION
#define BMP5_FIXED_POINT_DIGIT_PRECISION UINT8_C(6)
#endif
#endif
/* By default BMP5_FIXED_POINT_DIGIT_PRECISION will be 6 digits */
/* User can vary the precision between 0 to 6 digits */
#ifndef BMP5_FIXED_POINT_DIGIT_PRECISION
#define BMP5_FIXED_POINT_DIGIT_PRECISION UINT8_C(6)
#endif
#endif
/******************************************************************************/
/*! @name GENERAL MACRO DEFINITIONS */
/******************************************************************************/
/*!
* BMP5_INTF_RET_TYPE is the read/write interface return type which can be overwritten by the build system.
*/
#ifndef BMP5_INTF_RET_TYPE
#define BMP5_INTF_RET_TYPE int8_t
#endif
/*!
* The last error code from read/write interface is stored in the device structure as intf_rslt.
*/
#ifndef BMP5_INTF_RET_SUCCESS
#define BMP5_INTF_RET_SUCCESS INT8_C(0)
#endif
/*! @name BOOLEAN TYPES */
#ifndef TRUE
#define TRUE UINT8_C(0x01)
#endif
#ifndef FALSE
#define FALSE UINT8_C(0x00)
#endif
#ifndef NULL
#define NULL UINT8_C(0x00)
#endif
#ifndef ABS
#define ABS(a) ((a) > 0 ? (a) : -(a)) /*!< Absolute value */
#endif
/*! @name UTILITY MACROS */
#define BMP5_SET_LOW_BYTE UINT16_C(0x00FF)
#define BMP5_SET_HIGH_BYTE UINT16_C(0xFF00)
/*! @name BIT SLICE GET AND SET FUNCTIONS */
#define BMP5_GET_BITSLICE(regvar, bitname) \
((regvar & bitname##_MSK) >> bitname##_POS)
#define BMP5_SET_BITSLICE(regvar, bitname, val) \
((regvar & ~bitname##_MSK) | \
((val << bitname##_POS) & bitname##_MSK))
#define BMP5_GET_LSB(var) (uint8_t)(var & BMP5_SET_LOW_BYTE)
#define BMP5_GET_MSB(var) (uint8_t)((var & BMP5_SET_HIGH_BYTE) >> 8)
#define BMP5_SET_BIT_VAL_0(reg_data, bitname) (reg_data & ~(bitname##_MSK))
#define BMP5_SET_BITS_POS_0(reg_data, bitname, data) \
((reg_data & ~(bitname##_MSK)) | \
(data & bitname##_MSK))
#define BMP5_GET_BITS_POS_0(reg_data, bitname) (reg_data & (bitname##_MSK))
/*! @name Chip id of BMP5 */
#define BMP5_CHIP_ID_PRIM UINT8_C(0x50)
#define BMP5_CHIP_ID_SEC UINT8_C(0x51)
/*! @name API success code */
#define BMP5_OK INT8_C(0)
/*! @name API error codes */
#define BMP5_E_NULL_PTR INT8_C(-1)
#define BMP5_E_COM_FAIL INT8_C(-2)
#define BMP5_E_DEV_NOT_FOUND INT8_C(-3)
#define BMP5_E_INVALID_CHIP_ID INT8_C(-4)
#define BMP5_E_POWER_UP INT8_C(-5)
#define BMP5_E_POR_SOFTRESET INT8_C(-6)
#define BMP5_E_INVALID_POWERMODE INT8_C(-7)
#define BMP5_E_INVALID_THRESHOLD INT8_C(-8)
#define BMP5_E_FIFO_FRAME_EMPTY INT8_C(-9)
#define BMP5_E_NVM_INVALID_ADDR INT8_C(-10)
#define BMP5_E_NVM_NOT_READY INT8_C(-11)
#define BMP5_ENABLE UINT8_C(0x01)
#define BMP5_DISABLE UINT8_C(0x00)
/*! @name Register addresses */
#define BMP5_REG_CHIP_ID UINT8_C(0x01)
#define BMP5_REG_REV_ID UINT8_C(0x02)
#define BMP5_REG_CHIP_STATUS UINT8_C(0x11)
#define BMP5_REG_DRIVE_CONFIG UINT8_C(0x13)
#define BMP5_REG_INT_CONFIG UINT8_C(0x14)
#define BMP5_REG_INT_SOURCE UINT8_C(0x15)
#define BMP5_REG_FIFO_CONFIG UINT8_C(0x16)
#define BMP5_REG_FIFO_COUNT UINT8_C(0x17)
#define BMP5_REG_FIFO_SEL UINT8_C(0x18)
#define BMP5_REG_TEMP_DATA_XLSB UINT8_C(0x1D)
#define BMP5_REG_TEMP_DATA_LSB UINT8_C(0x1E)
#define BMP5_REG_TEMP_DATA_MSB UINT8_C(0x1F)
#define BMP5_REG_PRESS_DATA_XLSB UINT8_C(0x20)
#define BMP5_REG_PRESS_DATA_LSB UINT8_C(0x21)
#define BMP5_REG_PRESS_DATA_MSB UINT8_C(0x22)
#define BMP5_REG_INT_STATUS UINT8_C(0x27)
#define BMP5_REG_STATUS UINT8_C(0x28)
#define BMP5_REG_FIFO_DATA UINT8_C(0x29)
#define BMP5_REG_NVM_ADDR UINT8_C(0x2B)
#define BMP5_REG_NVM_DATA_LSB UINT8_C(0x2C)
#define BMP5_REG_NVM_DATA_MSB UINT8_C(0x2D)
#define BMP5_REG_DSP_CONFIG UINT8_C(0x30)
#define BMP5_REG_DSP_IIR UINT8_C(0x31)
#define BMP5_REG_OOR_THR_P_LSB UINT8_C(0x32)
#define BMP5_REG_OOR_THR_P_MSB UINT8_C(0x33)
#define BMP5_REG_OOR_RANGE UINT8_C(0x34)
#define BMP5_REG_OOR_CONFIG UINT8_C(0x35)
#define BMP5_REG_OSR_CONFIG UINT8_C(0x36)
#define BMP5_REG_ODR_CONFIG UINT8_C(0x37)
#define BMP5_REG_OSR_EFF UINT8_C(0x38)
#define BMP5_REG_CMD UINT8_C(0x7E)
/*! @name I2C addresses */
#define BMP5_I2C_ADDR_PRIM UINT8_C(0x46)
#define BMP5_I2C_ADDR_SEC UINT8_C(0x47)
/*! @name NVM addresses */
#define BMP5_NVM_START_ADDR UINT8_C(0x20)
#define BMP5_NVM_END_ADDR UINT8_C(0x22)
/*! @name Interface settings */
#define BMP5_SPI_RD_MASK UINT8_C(0x80)
/*! @name Delay definition */
#define BMP5_DELAY_US_SOFT_RESET UINT16_C(2000)
#define BMP5_DELAY_US_STANDBY UINT16_C(2500)
#define BMP5_DELAY_US_NVM_READY_READ UINT8_C(800)
#define BMP5_DELAY_US_NVM_READY_WRITE UINT16_C(10000)
/*! @name Soft reset command */
#define BMP5_SOFT_RESET_CMD UINT8_C(0xB6)
/*! NVM command */
#define BMP5_NVM_FIRST_CMND UINT8_C(0x5D)
#define BMP5_NVM_READ_ENABLE_CMND UINT8_C(0xA5)
#define BMP5_NVM_WRITE_ENABLE_CMND UINT8_C(0xA0)
/*! @name Deepstandby enable/disable */
#define BMP5_DEEP_ENABLED UINT8_C(0)
#define BMP5_DEEP_DISABLED UINT8_C(1)
/*! @name ODR settings */
#define BMP5_ODR_240_HZ UINT8_C(0x00)
#define BMP5_ODR_218_5_HZ UINT8_C(0x01)
#define BMP5_ODR_199_1_HZ UINT8_C(0x02)
#define BMP5_ODR_179_2_HZ UINT8_C(0x03)
#define BMP5_ODR_160_HZ UINT8_C(0x04)
#define BMP5_ODR_149_3_HZ UINT8_C(0x05)
#define BMP5_ODR_140_HZ UINT8_C(0x06)
#define BMP5_ODR_129_8_HZ UINT8_C(0x07)
#define BMP5_ODR_120_HZ UINT8_C(0x08)
#define BMP5_ODR_110_1_HZ UINT8_C(0x09)
#define BMP5_ODR_100_2_HZ UINT8_C(0x0A)
#define BMP5_ODR_89_6_HZ UINT8_C(0x0B)
#define BMP5_ODR_80_HZ UINT8_C(0x0C)
#define BMP5_ODR_70_HZ UINT8_C(0x0D)
#define BMP5_ODR_60_HZ UINT8_C(0x0E)
#define BMP5_ODR_50_HZ UINT8_C(0x0F)
#define BMP5_ODR_45_HZ UINT8_C(0x10)
#define BMP5_ODR_40_HZ UINT8_C(0x11)
#define BMP5_ODR_35_HZ UINT8_C(0x12)
#define BMP5_ODR_30_HZ UINT8_C(0x13)
#define BMP5_ODR_25_HZ UINT8_C(0x14)
#define BMP5_ODR_20_HZ UINT8_C(0x15)
#define BMP5_ODR_15_HZ UINT8_C(0x16)
#define BMP5_ODR_10_HZ UINT8_C(0x17)
#define BMP5_ODR_05_HZ UINT8_C(0x18)
#define BMP5_ODR_04_HZ UINT8_C(0x19)
#define BMP5_ODR_03_HZ UINT8_C(0x1A)
#define BMP5_ODR_02_HZ UINT8_C(0x1B)
#define BMP5_ODR_01_HZ UINT8_C(0x1C)
#define BMP5_ODR_0_5_HZ UINT8_C(0x1D)
#define BMP5_ODR_0_250_HZ UINT8_C(0x1E)
#define BMP5_ODR_0_125_HZ UINT8_C(0x1F)
/*! @name Oversampling for temperature and pressure */
#define BMP5_OVERSAMPLING_1X UINT8_C(0x00)
#define BMP5_OVERSAMPLING_2X UINT8_C(0x01)
#define BMP5_OVERSAMPLING_4X UINT8_C(0x02)
#define BMP5_OVERSAMPLING_8X UINT8_C(0x03)
#define BMP5_OVERSAMPLING_16X UINT8_C(0x04)
#define BMP5_OVERSAMPLING_32X UINT8_C(0x05)
#define BMP5_OVERSAMPLING_64X UINT8_C(0x06)
#define BMP5_OVERSAMPLING_128X UINT8_C(0x07)
/*! @name IIR filter for temperature and pressure */
#define BMP5_IIR_FILTER_BYPASS UINT8_C(0x00)
#define BMP5_IIR_FILTER_COEFF_1 UINT8_C(0x01)
#define BMP5_IIR_FILTER_COEFF_3 UINT8_C(0x02)
#define BMP5_IIR_FILTER_COEFF_7 UINT8_C(0x03)
#define BMP5_IIR_FILTER_COEFF_15 UINT8_C(0x04)
#define BMP5_IIR_FILTER_COEFF_31 UINT8_C(0x05)
#define BMP5_IIR_FILTER_COEFF_63 UINT8_C(0x06)
#define BMP5_IIR_FILTER_COEFF_127 UINT8_C(0x07)
/*! Fifo frame configuration */
#define BMP5_FIFO_EMPTY UINT8_C(0X7F)
#define BMP5_FIFO_MAX_THRESHOLD_P_T_MODE UINT8_C(0x0F)
#define BMP5_FIFO_MAX_THRESHOLD_P_MODE UINT8_C(0x1F)
/*! @name Macro is used to bypass both iir_t and iir_p together */
#define BMP5_IIR_BYPASS UINT8_C(0xC0)
/*! @name Pressure Out-of-range count limit */
#define BMP5_OOR_COUNT_LIMIT_1 UINT8_C(0x00)
#define BMP5_OOR_COUNT_LIMIT_3 UINT8_C(0x01)
#define BMP5_OOR_COUNT_LIMIT_7 UINT8_C(0x02)
#define BMP5_OOR_COUNT_LIMIT_15 UINT8_C(0x03)
/*! @name Interrupt configurations */
#define BMP5_INT_MODE_PULSED UINT8_C(0)
#define BMP5_INT_MODE_LATCHED UINT8_C(1)
#define BMP5_INT_POL_ACTIVE_LOW UINT8_C(0)
#define BMP5_INT_POL_ACTIVE_HIGH UINT8_C(1)
#define BMP5_INT_OD_PUSHPULL UINT8_C(0)
#define BMP5_INT_OD_OPENDRAIN UINT8_C(1)
/*! @name NVM and Interrupt status asserted macros */
#define BMP5_INT_ASSERTED_DRDY UINT8_C(0x01)
#define BMP5_INT_ASSERTED_FIFO_FULL UINT8_C(0x02)
#define BMP5_INT_ASSERTED_FIFO_THRES UINT8_C(0x04)
#define BMP5_INT_ASSERTED_PRESSURE_OOR UINT8_C(0x08)
#define BMP5_INT_ASSERTED_POR_SOFTRESET_COMPLETE UINT8_C(0x10)
#define BMP5_INT_NVM_RDY UINT8_C(0x02)
#define BMP5_INT_NVM_ERR UINT8_C(0x04)
#define BMP5_INT_NVM_CMD_ERR UINT8_C(0x08)
/*! @name Interrupt configurations */
#define BMP5_INT_MODE_MSK UINT8_C(0x01)
#define BMP5_INT_POL_MSK UINT8_C(0x02)
#define BMP5_INT_POL_POS UINT8_C(1)
#define BMP5_INT_OD_MSK UINT8_C(0x04)
#define BMP5_INT_OD_POS UINT8_C(2)
#define BMP5_INT_EN_MSK UINT8_C(0x08)
#define BMP5_INT_EN_POS UINT8_C(3)
#define BMP5_INT_DRDY_EN_MSK UINT8_C(0x01)
#define BMP5_INT_FIFO_FULL_EN_MSK UINT8_C(0x02)
#define BMP5_INT_FIFO_FULL_EN_POS UINT8_C(1)
#define BMP5_INT_FIFO_THRES_EN_MSK UINT8_C(0x04)
#define BMP5_INT_FIFO_THRES_EN_POS UINT8_C(2)
#define BMP5_INT_OOR_PRESS_EN_MSK UINT8_C(0x08)
#define BMP5_INT_OOR_PRESS_EN_POS UINT8_C(3)
/*! @name ODR configuration */
#define BMP5_ODR_MSK UINT8_C(0x7C)
#define BMP5_ODR_POS UINT8_C(2)
/*! @name OSR configurations */
#define BMP5_TEMP_OS_MSK UINT8_C(0x07)
#define BMP5_PRESS_OS_MSK UINT8_C(0x38)
#define BMP5_PRESS_OS_POS UINT8_C(3)
/*! @name Pressure enable */
#define BMP5_PRESS_EN_MSK UINT8_C(0x40)
#define BMP5_PRESS_EN_POS UINT8_C(6)
/*! @name IIR configurations */
#define BMP5_SET_IIR_TEMP_MSK UINT8_C(0x07)
#define BMP5_SET_IIR_PRESS_MSK UINT8_C(0x38)
#define BMP5_SET_IIR_PRESS_POS UINT8_C(3)
#define BMP5_OOR_SEL_IIR_PRESS_MSK UINT8_C(0x80)
#define BMP5_OOR_SEL_IIR_PRESS_POS UINT8_C(7)
#define BMP5_SHDW_SET_IIR_TEMP_MSK UINT8_C(0x08)
#define BMP5_SHDW_SET_IIR_TEMP_POS UINT8_C(3)
#define BMP5_SHDW_SET_IIR_PRESS_MSK UINT8_C(0x20)
#define BMP5_SHDW_SET_IIR_PRESS_POS UINT8_C(5)
#define BMP5_SET_FIFO_IIR_TEMP_MSK UINT8_C(0x10)
#define BMP5_SET_FIFO_IIR_TEMP_POS UINT8_C(4)
#define BMP5_SET_FIFO_IIR_PRESS_MSK UINT8_C(0x40)
#define BMP5_SET_FIFO_IIR_PRESS_POS UINT8_C(6)
#define BMP5_IIR_FLUSH_FORCED_EN_MSK UINT8_C(0x04)
#define BMP5_IIR_FLUSH_FORCED_EN_POS UINT8_C(2)
/*! @name Effective OSR configurations and ODR valid status */
#define BMP5_OSR_TEMP_EFF_MSK UINT8_C(0x07)
#define BMP5_OSR_PRESS_EFF_MSK UINT8_C(0x38)
#define BMP5_OSR_PRESS_EFF_POS UINT8_C(3)
#define BMP5_ODR_IS_VALID_MSK UINT8_C(0x80)
#define BMP5_ODR_IS_VALID_POS UINT8_C(7)
/*! @name Powermode */
#define BMP5_POWERMODE_MSK UINT8_C(0x03)
#define BMP5_DEEP_DISABLE_MSK UINT8_C(0x80)
#define BMP5_DEEP_DISABLE_POS UINT8_C(7)
/*! @name Fifo configurations */
#define BMP5_FIFO_THRESHOLD_MSK UINT8_C(0x1F)
#define BMP5_FIFO_MODE_MSK UINT8_C(0x20)
#define BMP5_FIFO_MODE_POS UINT8_C(5)
#define BMP5_FIFO_DEC_SEL_MSK UINT8_C(0x1C)
#define BMP5_FIFO_DEC_SEL_POS UINT8_C(2)
#define BMP5_FIFO_COUNT_MSK UINT8_C(0x3F)
#define BMP5_FIFO_FRAME_SEL_MSK UINT8_C(0x03)
/*! @name Out-of-range configuration */
#define BMP5_OOR_THR_P_LSB_MSK UINT32_C(0x0000FF)
#define BMP5_OOR_THR_P_MSB_MSK UINT32_C(0x00FF00)
#define BMP5_OOR_THR_P_XMSB_MSK UINT32_C(0x010000)
#define BMP5_OOR_THR_P_XMSB_POS UINT16_C(16)
/* Macro to mask xmsb value of oor threshold from register(0x35) value */
#define BMP5_OOR_THR_P_XMSB_REG_MSK UINT8_C(0x01)
#define BMP5_OOR_COUNT_LIMIT_MSK UINT8_C(0xC0)
#define BMP5_OOR_COUNT_LIMIT_POS UINT8_C(6)
/*! @name NVM configuration */
#define BMP5_NVM_ADDR_MSK UINT8_C(0x3F)
#define BMP5_NVM_PROG_EN_MSK UINT8_C(0x40)
#define BMP5_NVM_PROG_EN_POS UINT8_C(6)
#define BMP5_NVM_DATA_LSB_MSK UINT16_C(0x00FF)
#define BMP5_NVM_DATA_MSB_MSK UINT16_C(0xFF00)
/******************************************************************************/
/*! @name TYPEDEF DEFINITIONS */
/******************************************************************************/
/*!
* @brief Bus communication function pointer which should be mapped to
* the platform specific read functions of the user
*
* @param[in] reg_addr : Register address from which data is read.
* @param[out] read_data : Pointer to data buffer where read data is stored.
* @param[in] len : Number of bytes of data to be read.
* @param[in, out] intf_ptr : Void pointer that can enable the linking of descriptors
* for interface related call backs.
*
* @retval 0 for Success
* @retval Non-zero for Failure
*/
typedef BMP5_INTF_RET_TYPE (*bmp5_read_fptr_t)(uint8_t reg_addr, uint8_t *read_data, uint32_t len, void *intf_ptr);
/*!
* @brief Bus communication function pointer which should be mapped to
* the platform specific write functions of the user
*
* @param[in] reg_addr : Register address to which the data is written.
* @param[in] read_data : Pointer to data buffer in which data to be written
* is stored.
* @param[in] len : Number of bytes of data to be written.
* @param[in, out] intf_ptr : Void pointer that can enable the linking of descriptors
* for interface related call backs
*
* @retval 0 for Success
* @retval Non-zero for Failure
*/
typedef BMP5_INTF_RET_TYPE (*bmp5_write_fptr_t)(uint8_t reg_addr, const uint8_t *read_data, uint32_t len,
void *intf_ptr);
/*!
* @brief Delay function pointer which should be mapped to
* delay function of the user
*
* @param[in] period : Delay in microseconds.
* @param[in, out] intf_ptr : Void pointer that can enable the linking of descriptors
* for interface related call backs
*
*/
typedef void (*bmp5_delay_us_fptr_t)(uint32_t period, void *intf_ptr);
/******************************************************************************/
/*! @name ENUMERATION DEFINITIONS */
/******************************************************************************/
/*!
* @brief Enumerator for interface selection
*/
enum bmp5_intf {
/*! SPI interface */
BMP5_SPI_INTF,
/*! I2C interface */
BMP5_I2C_INTF,
/*! I3C interface */
BMP5_I3C_INTF
};
/*!
* @brief Enumerator for powermode selection
*/
enum bmp5_powermode {
/*! Standby powermode */
BMP5_POWERMODE_STANDBY,
/*! Normal powermode */
BMP5_POWERMODE_NORMAL,
/*! Forced powermode */
BMP5_POWERMODE_FORCED,
/*! Continous powermode */
BMP5_POWERMODE_CONTINOUS,
/*! Deep standby powermode */
BMP5_POWERMODE_DEEP_STANDBY
};
/*!
* @brief Enumerator for interrupt enable disable
*/
enum bmp5_intr_en_dis {
/*! Interrupt diable */
BMP5_INTR_DISABLE = BMP5_DISABLE,
/*! Interrupt enable */
BMP5_INTR_ENABLE = BMP5_ENABLE
};
/*!
* @brief Enumerator for interrupt mode
*/
enum bmp5_intr_mode {
/*! Interrupt mode - pulsed */
BMP5_PULSED = BMP5_INT_MODE_PULSED,
/*! Interrupt mode - latched */
BMP5_LATCHED = BMP5_INT_MODE_LATCHED
};
/*!
* @brief Enumerator for interrupt polarity
*/
enum bmp5_intr_polarity {
/*! Interrupt polarity - active low */
BMP5_ACTIVE_LOW = BMP5_INT_POL_ACTIVE_LOW,
/*! Interrupt polarity - active high */
BMP5_ACTIVE_HIGH = BMP5_INT_POL_ACTIVE_HIGH
};
/*!
* @brief Enumerator for interrupt drive
*/
enum bmp5_intr_drive {
/*! Interrupt drive - push-pull */
BMP5_INTR_PUSH_PULL = BMP5_INT_OD_PUSHPULL,
/*! Interrupt drive - open drain */
BMP5_INTR_OPEN_DRAIN = BMP5_INT_OD_OPENDRAIN
};
/*!
* @brief Enumerator for fifo frame selection
*/
enum bmp5_fifo_frame_sel {
/*! Fifo disabled */
BMP5_FIFO_NOT_ENABLED,
/*! Fifo temperature data only enabled */
BMP5_FIFO_TEMPERATURE_DATA,
/*! Fifo pressure data only enabled */
BMP5_FIFO_PRESSURE_DATA,
/*! Fifo pressure and temperature data enabled */
BMP5_FIFO_PRESS_TEMP_DATA
};
/*!
* @brief Enumerator for fifo decimation factor(downsampling) selection
*/
enum bmp5_fifo_dec_sel {
/*! Fifo downsampling disabled */
BMP5_FIFO_NO_DOWNSAMPLING,
/*! Fifo 2X downsampling */
BMP5_FIFO_DOWNSAMPLING_2X,
/*! Fifo 4X downsampling */
BMP5_FIFO_DOWNSAMPLING_4X,
/*! Fifo 8X downsampling */
BMP5_FIFO_DOWNSAMPLING_8X,
/*! Fifo 16X downsampling */
BMP5_FIFO_DOWNSAMPLING_16X,
/*! Fifo 32X downsampling */
BMP5_FIFO_DOWNSAMPLING_32X,
/*! Fifo 64X downsampling */
BMP5_FIFO_DOWNSAMPLING_64X,
/*! Fifo 128X downsampling */
BMP5_FIFO_DOWNSAMPLING_128X
};
/*!
* @brief Enumerator for fifo mode selection
*/
enum bmp5_fifo_mode {
/*! Fifo mode - streaming */
BMP5_FIFO_MODE_STREAMING,
/*! Fifo mode - stop on full */
BMP5_FIFO_MODE_STOP_ON_FULL
};
/******************************************************************************/
/*! @name STRUCTURE DEFINITIONS */
/******************************************************************************/
/*!
* @brief OSR, ODR and pressure configuration structure
*/
struct bmp5_osr_odr_press_config
{
/*! Temperature oversampling
* Assignable macros :
* - BMP5_OVERSAMPLING_1X
* - BMP5_OVERSAMPLING_2X
* - BMP5_OVERSAMPLING_4X
* - BMP5_OVERSAMPLING_8X
* - BMP5_OVERSAMPLING_16X
* - BMP5_OVERSAMPLING_32X
* - BMP5_OVERSAMPLING_64X
* - BMP5_OVERSAMPLING_128X
*/
uint8_t osr_t;
/*! Pressure oversampling
* Assignable macros :
* - BMP5_OVERSAMPLING_1X
* - BMP5_OVERSAMPLING_2X
* - BMP5_OVERSAMPLING_4X
* - BMP5_OVERSAMPLING_8X
* - BMP5_OVERSAMPLING_16X
* - BMP5_OVERSAMPLING_32X
* - BMP5_OVERSAMPLING_64X
* - BMP5_OVERSAMPLING_128X
*/
uint8_t osr_p;
/*! Enable pressure
* BMP5_ENABLE = Enables pressure data
* BMP5_DISABLE = Disables pressure data
*/
uint8_t press_en;
/*! Output Data Rate */
uint8_t odr;
};
/*!
* @brief IIR configuration structure
*/
struct bmp5_iir_config
{
/*! Temperature IIR
* Assignable macros :
* - BMP5_IIR_FILTER_BYPASS
* - BMP5_IIR_FILTER_0_20980
* - BMP5_IIR_FILTER_0_08045
* - BMP5_IIR_FILTER_0_03695
* - BMP5_IIR_FILTER_0_01785
* - BMP5_IIR_FILTER_0_00880
* - BMP5_IIR_FILTER_0_00435
* - BMP5_IIR_FILTER_0_00220
*/
uint8_t set_iir_t;
/*! Pressure IIR
* Assignable macros :
* - BMP5_IIR_FILTER_BYPASS
* - BMP5_IIR_FILTER_0_20980
* - BMP5_IIR_FILTER_0_08045
* - BMP5_IIR_FILTER_0_03695
* - BMP5_IIR_FILTER_0_01785
* - BMP5_IIR_FILTER_0_00880
* - BMP5_IIR_FILTER_0_00435
* - BMP5_IIR_FILTER_0_00220
*/
uint8_t set_iir_p;
/*! Shadow IIR selection for temperature
* Assignable macros :
* - BMP5_ENABLE
* - BMP5_DISABLE
*/
uint8_t shdw_set_iir_t;
/*! Shadow IIR selection for pressure
* Assignable macros :
* - BMP5_ENABLE
* - BMP5_DISABLE
*/
uint8_t shdw_set_iir_p;
/*! IIR flush in forced mode enable
* Assignable macros :
* - BMP5_ENABLE
* - BMP5_DISABLE
*/
uint8_t iir_flush_forced_en;
};
/*!
* @brief Effective OSR configuration and ODR valid status structure
*/
struct bmp5_osr_odr_eff
{
/*! Effective temperature OSR */
uint8_t osr_t_eff;
/*! Effective pressure OSR */
uint8_t osr_p_eff;
/*! If asserted, the ODR parametrization is valid */
uint8_t odr_is_valid;
};
/*!
* @brief BMP5 interrupt source selection.
*/
struct bmp5_int_source_select
{
/*! Data ready interrupt enable
* BMP5_ENABLE = Enables data ready interrupt
* BMP5_DISABLE = Disables data ready interrupt
*/
uint8_t drdy_en;
/*! Fifo full interrupt enable
* BMP5_ENABLE = Enables fifo full interrupt
* BMP5_DISABLE = Disables fifo full interrupt
*/
uint8_t fifo_full_en;
/*! Fifo threshold interrupt enable
* BMP5_ENABLE = Enables fifo threshold interrupt
* BMP5_DISABLE = Disables fifo threshold interrupt
*/
uint8_t fifo_thres_en;
/*! Pressure out of range interrupt enable
* BMP5_ENABLE = Enables pressure out of range interrupt
* BMP5_DISABLE = Disables pressure out of range interrupt
*/
uint8_t oor_press_en;
};
/*!
* @brief BMP5 fifo configurations.
*/
struct bmp5_fifo
{
/*! Pointer to fifo data */
uint8_t *data;
/*! Length of user defined bytes of fifo to be read */
uint16_t length;
/*! Fifo frame data source selection
* Assignable macros :
* - BMP5_FIFO_NOT_ENABLED
* - BMP5_FIFO_TEMPERATURE_DATA
* - BMP5_FIFO_PRESSURE_DATA
* - BMP5_FIFO_PRESS_TEMP_DATA
*/
uint8_t frame_sel;
/*! Fifo decimation factor(downsampling) selection
* Assignable macros :
* - BMP5_FIFO_NO_DOWNSAMPLING
* - BMP5_FIFO_DOWNSAMPLING_2X
* - BMP5_FIFO_DOWNSAMPLING_4X
* - BMP5_FIFO_DOWNSAMPLING_8X
* - BMP5_FIFO_DOWNSAMPLING_16X
* - BMP5_FIFO_DOWNSAMPLING_32X
* - BMP5_FIFO_DOWNSAMPLING_64X
* - BMP5_FIFO_DOWNSAMPLING_128X
*/
uint8_t dec_sel;
/*! Fifo frame count */
uint8_t fifo_count;
/*! Fifo mode selection
* Assignable macros :
* - BMP5_FIFO_MODE_STREAMING
* - BMP5_FIFO_MODE_STOP_ON_FULL
*/
uint8_t mode;
/*! Threshold for fifo */
uint8_t threshold;
/*! Fifo temperature IIR
* Assignable macros :
* - BMP5_ENABLE
* - BMP5_DISABLE
*/
uint8_t set_fifo_iir_t;
/*! Fifo pressure IIR
* Assignable macros :
* - BMP5_ENABLE
* - BMP5_DISABLE
*/
uint8_t set_fifo_iir_p;
};
/*!
* @brief BMP5 Out-of-range pressure configuration.
*/
struct bmp5_oor_press_configuration
{
/*! Out-of-range pressure threshold */
uint32_t oor_thr_p;
/*! Out-of-range pressure range
* Range can span up to +/- 255 Pa around the threshold value.
*/
uint8_t oor_range_p;
/*! Out-of-range pressure count limit
* Assignable macros :
* - BMP5_OOR_COUNT_LIMIT_1
* - BMP5_OOR_COUNT_LIMIT_3
* - BMP5_OOR_COUNT_LIMIT_7
* - BMP5_OOR_COUNT_LIMIT_15
*/
uint8_t cnt_lim;
/*! Out-of-range pressure IIR
* Assignable macros :
* - BMP5_ENABLE
* - BMP5_DISABLE
*/
uint8_t oor_sel_iir_p;
};
/*!
* @brief BMP5 sensor data structure which comprises of temperature and pressure.
*/
#ifdef BMP5_USE_FIXED_POINT
/*!
* @brief BMP5 sensor data structure which comprises of temperature and pressure in fixed point with data type as
* uint64_t for pressure and int64_t for temperature.
*/
struct bmp5_sensor_data
{
/*! Pressure data */
uint64_t pressure;
/*! Temperature data */
int64_t temperature;
};
#else
/*!
* @brief BMP5 sensor data structure which comprises of temperature and pressure in floating point with data type as
* float for pressure and temperature.
*/
struct bmp5_sensor_data
{
/*! Pressure data */
float pressure;
/*! Temperature data */
float temperature;
};
#endif
/*!
* @brief API device structure
*/
struct bmp5_dev
{
/*! Chip ID */
uint8_t chip_id;
/*!
* The interface pointer is used to enable the user
* to link their interface descriptors for reference during the
* implementation of the read and write interfaces to the
* hardware.
*/
void *intf_ptr;
/*! Read function pointer */
bmp5_read_fptr_t read;
/*! Write function pointer */
bmp5_write_fptr_t write;
/*! Delay function pointer */
bmp5_delay_us_fptr_t delay_us;
/*! To store interface pointer error */
BMP5_INTF_RET_TYPE intf_rslt;
/*! Type of Interface */
enum bmp5_intf intf;
};
#endif /* End of _BMP5_DEFS_H */
Checks: '-clang-analyzer-core.CallAndMessage'
*.sw*
binaries
idf_component_register(
SRCS
ctx.c
INCLUDE_DIRS
.
./fonts/
)
\ No newline at end of file
menu "Ctx Config"
choice FLOW3R_CTX_FLAVOUR
prompt "Ctx flavour"
default FLOW3R_CTX_FLAVOUR_FULL
config FLOW3R_CTX_FLAVOUR_FULL
bool "Full (all fonts, high memory, for main app, cherry)"
config FLOW3R_CTX_FLAVOUR_SMOL
bool "Smol (one font, low memory, for recovery, vanilla)"
endchoice
endmenu
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.