bmi160_defs.h 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330
  1. /**
  2. * Copyright (C) 2015 - 2016 Bosch Sensortec GmbH
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. *
  7. * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. *
  10. * Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. *
  14. * Neither the name of the copyright holder nor the names of the
  15. * contributors may be used to endorse or promote products derived from
  16. * this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  19. * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
  20. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. * DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
  23. * OR CONTRIBUTORS BE LIABLE FOR ANY
  24. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  25. * OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO,
  26. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  27. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  29. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  31. * ANY WAY OUT OF THE USE OF THIS
  32. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
  33. *
  34. * The information provided is believed to be accurate and reliable.
  35. * The copyright holder assumes no responsibility
  36. * for the consequences of use
  37. * of such information nor for any infringement of patents or
  38. * other rights of third parties which may result from its use.
  39. * No license is granted by implication or otherwise under any patent or
  40. * patent rights of the copyright holder.
  41. *
  42. * @file bmi160_defs.h
  43. * @date 04 Aug 2017
  44. * @version 3.6.0
  45. * @brief
  46. *
  47. */
  48. /*!
  49. * @defgroup bmi160_defs
  50. * @brief
  51. * @{*/
  52. #ifndef BMI160_DEFS_H_
  53. #define BMI160_DEFS_H_
  54. /*************************** C types headers *****************************/
  55. #ifdef __KERNEL__
  56. #include <linux/types.h>
  57. #include <linux/kernel.h>
  58. #else
  59. #include <stdint.h>
  60. #include <stddef.h>
  61. #endif
  62. /*************************** C++ guard macro *****************************/
  63. #ifdef __cplusplus
  64. extern "C"
  65. {
  66. #endif
  67. /*************************** Common macros *****************************/
  68. #ifdef __KERNEL__
  69. #if (LONG_MAX) > 0x7fffffff
  70. #define __have_long64 1
  71. #elif (LONG_MAX) == 0x7fffffff
  72. #define __have_long32 1
  73. #endif
  74. #endif
  75. #if !defined(UINT8_C)
  76. #define INT8_C(x) x
  77. #if (INT_MAX) > 0x7f
  78. #define UINT8_C(x) x
  79. #else
  80. #define UINT8_C(x) x##U
  81. #endif
  82. #endif
  83. #if !defined(UINT16_C)
  84. #define INT16_C(x) x
  85. #if (INT_MAX) > 0x7fff
  86. #define UINT16_C(x) x
  87. #else
  88. #define UINT16_C(x) x##U
  89. #endif
  90. #endif
  91. #if !defined(INT32_C) && !defined(UINT32_C)
  92. #if __have_long32
  93. #define INT32_C(x) x##L
  94. #define UINT32_C(x) x##UL
  95. #else
  96. #define INT32_C(x) x
  97. #define UINT32_C(x) x##U
  98. #endif
  99. #endif
  100. #if !defined(INT64_C) && !defined(UINT64_C)
  101. #if __have_long64
  102. #define INT64_C(x) x##L
  103. #define UINT64_C(x) x##UL
  104. #else
  105. #define INT64_C(x) x##LL
  106. #define UINT64_C(x) x##ULL
  107. #endif
  108. #endif
  109. /*************************** Sensor macros *****************************/
  110. /* Test for an endian machine */
  111. #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
  112. #define LITTLE_ENDIAN 1
  113. #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
  114. #define BIG_ENDIAN 1
  115. #else
  116. #error "Code does not support Endian format of the processor"
  117. #endif
  118. /** Mask definitions */
  119. #define BMI160_ACCEL_BW_MASK UINT8_C(0x70)
  120. #define BMI160_ACCEL_ODR_MASK UINT8_C(0x0F)
  121. #define BMI160_ACCEL_UNDERSAMPLING_MASK UINT8_C(0x80)
  122. #define BMI160_ACCEL_RANGE_MASK UINT8_C(0x0F)
  123. #define BMI160_GYRO_BW_MASK UINT8_C(0x30)
  124. #define BMI160_GYRO_ODR_MASK UINT8_C(0x0F)
  125. #define BMI160_GYRO_RANGE_MSK UINT8_C(0x07)
  126. /** Mask definitions for INT_EN registers */
  127. #define BMI160_ANY_MOTION_X_INT_EN_MASK UINT8_C(0x01)
  128. #define BMI160_HIGH_G_X_INT_EN_MASK UINT8_C(0x01)
  129. #define BMI160_NO_MOTION_X_INT_EN_MASK UINT8_C(0x01)
  130. #define BMI160_ANY_MOTION_Y_INT_EN_MASK UINT8_C(0x02)
  131. #define BMI160_HIGH_G_Y_INT_EN_MASK UINT8_C(0x02)
  132. #define BMI160_NO_MOTION_Y_INT_EN_MASK UINT8_C(0x02)
  133. #define BMI160_ANY_MOTION_Z_INT_EN_MASK UINT8_C(0x04)
  134. #define BMI160_HIGH_G_Z_INT_EN_MASK UINT8_C(0x04)
  135. #define BMI160_NO_MOTION_Z_INT_EN_MASK UINT8_C(0x04)
  136. #define BMI160_SIG_MOTION_INT_EN_MASK UINT8_C(0x07)
  137. #define BMI160_ANY_MOTION_ALL_INT_EN_MASK UINT8_C(0x07)
  138. #define BMI160_STEP_DETECT_INT_EN_MASK UINT8_C(0x08)
  139. #define BMI160_DOUBLE_TAP_INT_EN_MASK UINT8_C(0x10)
  140. #define BMI160_SINGLE_TAP_INT_EN_MASK UINT8_C(0x20)
  141. #define BMI160_FIFO_FULL_INT_EN_MASK UINT8_C(0x20)
  142. #define BMI160_ORIENT_INT_EN_MASK UINT8_C(0x40)
  143. #define BMI160_FIFO_WATERMARK_INT_EN_MASK UINT8_C(0x40)
  144. #define BMI160_LOW_G_INT_EN_MASK UINT8_C(0x08)
  145. #define BMI160_STEP_DETECT_EN_MASK UINT8_C(0x08)
  146. #define BMI160_FLAT_INT_EN_MASK UINT8_C(0x80)
  147. #define BMI160_DATA_RDY_INT_EN_MASK UINT8_C(0x10)
  148. /** Mask definitions for INT_OUT_CTRL register */
  149. #define BMI160_INT1_EDGE_CTRL_MASK UINT8_C(0x01)
  150. #define BMI160_INT1_OUTPUT_MODE_MASK UINT8_C(0x04)
  151. #define BMI160_INT1_OUTPUT_TYPE_MASK UINT8_C(0x02)
  152. #define BMI160_INT1_OUTPUT_EN_MASK UINT8_C(0x08)
  153. #define BMI160_INT2_EDGE_CTRL_MASK UINT8_C(0x10)
  154. #define BMI160_INT2_OUTPUT_MODE_MASK UINT8_C(0x40)
  155. #define BMI160_INT2_OUTPUT_TYPE_MASK UINT8_C(0x20)
  156. #define BMI160_INT2_OUTPUT_EN_MASK UINT8_C(0x80)
  157. /** Mask definitions for INT_LATCH register */
  158. #define BMI160_INT1_INPUT_EN_MASK UINT8_C(0x10)
  159. #define BMI160_INT2_INPUT_EN_MASK UINT8_C(0x20)
  160. #define BMI160_INT_LATCH_MASK UINT8_C(0x0F)
  161. /** Mask definitions for INT_MAP register */
  162. #define BMI160_INT1_LOW_G_MASK UINT8_C(0x01)
  163. #define BMI160_INT1_HIGH_G_MASK UINT8_C(0x02)
  164. #define BMI160_INT1_SLOPE_MASK UINT8_C(0x04)
  165. #define BMI160_INT1_NO_MOTION_MASK UINT8_C(0x08)
  166. #define BMI160_INT1_DOUBLE_TAP_MASK UINT8_C(0x10)
  167. #define BMI160_INT1_SINGLE_TAP_MASK UINT8_C(0x20)
  168. #define BMI160_INT1_FIFO_FULL_MASK UINT8_C(0x20)
  169. #define BMI160_INT1_FIFO_WM_MASK UINT8_C(0x40)
  170. #define BMI160_INT1_ORIENT_MASK UINT8_C(0x40)
  171. #define BMI160_INT1_FLAT_MASK UINT8_C(0x80)
  172. #define BMI160_INT1_DATA_READY_MASK UINT8_C(0x80)
  173. #define BMI160_INT2_LOW_G_MASK UINT8_C(0x01)
  174. #define BMI160_INT1_LOW_STEP_DETECT_MASK UINT8_C(0x01)
  175. #define BMI160_INT2_LOW_STEP_DETECT_MASK UINT8_C(0x01)
  176. #define BMI160_INT2_HIGH_G_MASK UINT8_C(0x02)
  177. #define BMI160_INT2_FIFO_FULL_MASK UINT8_C(0x02)
  178. #define BMI160_INT2_FIFO_WM_MASK UINT8_C(0x04)
  179. #define BMI160_INT2_SLOPE_MASK UINT8_C(0x04)
  180. #define BMI160_INT2_DATA_READY_MASK UINT8_C(0x08)
  181. #define BMI160_INT2_NO_MOTION_MASK UINT8_C(0x08)
  182. #define BMI160_INT2_DOUBLE_TAP_MASK UINT8_C(0x10)
  183. #define BMI160_INT2_SINGLE_TAP_MASK UINT8_C(0x20)
  184. #define BMI160_INT2_ORIENT_MASK UINT8_C(0x40)
  185. #define BMI160_INT2_FLAT_MASK UINT8_C(0x80)
  186. /** Mask definitions for INT_DATA register */
  187. #define BMI160_TAP_SRC_INT_MASK UINT8_C(0x08)
  188. #define BMI160_LOW_HIGH_SRC_INT_MASK UINT8_C(0x80)
  189. #define BMI160_MOTION_SRC_INT_MASK UINT8_C(0x80)
  190. /** Mask definitions for INT_MOTION register */
  191. #define BMI160_SLOPE_INT_DUR_MASK UINT8_C(0x03)
  192. #define BMI160_NO_MOTION_INT_DUR_MASK UINT8_C(0xFC)
  193. #define BMI160_NO_MOTION_SEL_BIT_MASK UINT8_C(0x01)
  194. /** Mask definitions for INT_TAP register */
  195. #define BMI160_TAP_DUR_MASK UINT8_C(0x07)
  196. #define BMI160_TAP_SHOCK_DUR_MASK UINT8_C(0x40)
  197. #define BMI160_TAP_QUIET_DUR_MASK UINT8_C(0x80)
  198. #define BMI160_TAP_THRES_MASK UINT8_C(0x1F)
  199. /** Mask definitions for INT_FLAT register */
  200. #define BMI160_FLAT_THRES_MASK UINT8_C(0x3F)
  201. #define BMI160_FLAT_HOLD_TIME_MASK UINT8_C(0x30)
  202. #define BMI160_FLAT_HYST_MASK UINT8_C(0x07)
  203. /** Mask definitions for INT_LOWHIGH register */
  204. #define BMI160_LOW_G_HYST_MASK UINT8_C(0x03)
  205. #define BMI160_LOW_G_LOW_MODE_MASK UINT8_C(0x04)
  206. #define BMI160_HIGH_G_HYST_MASK UINT8_C(0xC0)
  207. /** Mask definitions for INT_SIG_MOTION register */
  208. #define BMI160_SIG_MOTION_SEL_MASK UINT8_C(0x02)
  209. #define BMI160_SIG_MOTION_SKIP_MASK UINT8_C(0x0C)
  210. #define BMI160_SIG_MOTION_PROOF_MASK UINT8_C(0x30)
  211. /** Mask definitions for INT_ORIENT register */
  212. #define BMI160_ORIENT_MODE_MASK UINT8_C(0x03)
  213. #define BMI160_ORIENT_BLOCK_MASK UINT8_C(0x0C)
  214. #define BMI160_ORIENT_HYST_MASK UINT8_C(0xF0)
  215. #define BMI160_ORIENT_THETA_MASK UINT8_C(0x3F)
  216. #define BMI160_ORIENT_UD_ENABLE UINT8_C(0x40)
  217. #define BMI160_AXES_EN_MASK UINT8_C(0x80)
  218. /** Mask definitions for FIFO_CONFIG register */
  219. #define BMI160_FIFO_GYRO UINT8_C(0x80)
  220. #define BMI160_FIFO_ACCEL UINT8_C(0x40)
  221. #define BMI160_FIFO_AUX UINT8_C(0x20)
  222. #define BMI160_FIFO_TAG_INT1 UINT8_C(0x08)
  223. #define BMI160_FIFO_TAG_INT2 UINT8_C(0x04)
  224. #define BMI160_FIFO_TIME UINT8_C(0x02)
  225. #define BMI160_FIFO_HEADER UINT8_C(0x10)
  226. #define BMI160_FIFO_CONFIG_1_MASK UINT8_C(0xFE)
  227. /** Mask definitions for STEP_CONF register */
  228. #define BMI160_STEP_COUNT_EN_BIT_MASK UINT8_C(0x08)
  229. #define BMI160_STEP_DETECT_MIN_THRES_MASK UINT8_C(0x18)
  230. #define BMI160_STEP_DETECT_STEPTIME_MIN_MASK UINT8_C(0x07)
  231. #define BMI160_STEP_MIN_BUF_MASK UINT8_C(0x07)
  232. /** Mask definition for FIFO Header Data Tag */
  233. #define BMI160_FIFO_TAG_INTR_MASK UINT8_C(0xFC)
  234. /** Fifo byte counter mask definitions */
  235. #define BMI160_FIFO_BYTE_COUNTER_MASK UINT8_C(0x07)
  236. /** Enable/disable bit value */
  237. #define BMI160_ENABLE UINT8_C(0x01)
  238. #define BMI160_DISABLE UINT8_C(0x00)
  239. /** Latch Duration */
  240. #define BMI160_LATCH_DUR_NONE UINT8_C(0x00)
  241. #define BMI160_LATCH_DUR_312_5_MICRO_SEC UINT8_C(0x01)
  242. #define BMI160_LATCH_DUR_625_MICRO_SEC UINT8_C(0x02)
  243. #define BMI160_LATCH_DUR_1_25_MILLI_SEC UINT8_C(0x03)
  244. #define BMI160_LATCH_DUR_2_5_MILLI_SEC UINT8_C(0x04)
  245. #define BMI160_LATCH_DUR_5_MILLI_SEC UINT8_C(0x05)
  246. #define BMI160_LATCH_DUR_10_MILLI_SEC UINT8_C(0x06)
  247. #define BMI160_LATCH_DUR_20_MILLI_SEC UINT8_C(0x07)
  248. #define BMI160_LATCH_DUR_40_MILLI_SEC UINT8_C(0x08)
  249. #define BMI160_LATCH_DUR_80_MILLI_SEC UINT8_C(0x09)
  250. #define BMI160_LATCH_DUR_160_MILLI_SEC UINT8_C(0x0A)
  251. #define BMI160_LATCH_DUR_320_MILLI_SEC UINT8_C(0x0B)
  252. #define BMI160_LATCH_DUR_640_MILLI_SEC UINT8_C(0x0C)
  253. #define BMI160_LATCH_DUR_1_28_SEC UINT8_C(0x0D)
  254. #define BMI160_LATCH_DUR_2_56_SEC UINT8_C(0x0E)
  255. #define BMI160_LATCHED UINT8_C(0x0F)
  256. /** BMI160 Register map */
  257. #define BMI160_CHIP_ID_ADDR UINT8_C(0x00)
  258. #define BMI160_ERROR_REG_ADDR UINT8_C(0x02)
  259. #define BMI160_AUX_DATA_ADDR UINT8_C(0x04)
  260. #define BMI160_GYRO_DATA_ADDR UINT8_C(0x0C)
  261. #define BMI160_ACCEL_DATA_ADDR UINT8_C(0x12)
  262. #define BMI160_STATUS_ADDR UINT8_C(0x1B)
  263. #define BMI160_FIFO_LENGTH_ADDR UINT8_C(0x22)
  264. #define BMI160_FIFO_DATA_ADDR UINT8_C(0x24)
  265. #define BMI160_ACCEL_CONFIG_ADDR UINT8_C(0x40)
  266. #define BMI160_ACCEL_RANGE_ADDR UINT8_C(0x41)
  267. #define BMI160_GYRO_CONFIG_ADDR UINT8_C(0x42)
  268. #define BMI160_GYRO_RANGE_ADDR UINT8_C(0x43)
  269. #define BMI160_AUX_ODR_ADDR UINT8_C(0x44)
  270. #define BMI160_FIFO_DOWN_ADDR UINT8_C(0x45)
  271. #define BMI160_FIFO_CONFIG_0_ADDR UINT8_C(0x46)
  272. #define BMI160_FIFO_CONFIG_1_ADDR UINT8_C(0x47)
  273. #define BMI160_AUX_IF_0_ADDR UINT8_C(0x4B)
  274. #define BMI160_AUX_IF_1_ADDR UINT8_C(0x4C)
  275. #define BMI160_AUX_IF_2_ADDR UINT8_C(0x4D)
  276. #define BMI160_AUX_IF_3_ADDR UINT8_C(0x4E)
  277. #define BMI160_AUX_IF_4_ADDR UINT8_C(0x4F)
  278. #define BMI160_INT_ENABLE_0_ADDR UINT8_C(0x50)
  279. #define BMI160_INT_ENABLE_1_ADDR UINT8_C(0x51)
  280. #define BMI160_INT_ENABLE_2_ADDR UINT8_C(0x52)
  281. #define BMI160_INT_OUT_CTRL_ADDR UINT8_C(0x53)
  282. #define BMI160_INT_LATCH_ADDR UINT8_C(0x54)
  283. #define BMI160_INT_MAP_0_ADDR UINT8_C(0x55)
  284. #define BMI160_INT_MAP_1_ADDR UINT8_C(0x56)
  285. #define BMI160_INT_MAP_2_ADDR UINT8_C(0x57)
  286. #define BMI160_INT_DATA_0_ADDR UINT8_C(0x58)
  287. #define BMI160_INT_DATA_1_ADDR UINT8_C(0x59)
  288. #define BMI160_INT_LOWHIGH_0_ADDR UINT8_C(0x5A)
  289. #define BMI160_INT_LOWHIGH_1_ADDR UINT8_C(0x5B)
  290. #define BMI160_INT_LOWHIGH_2_ADDR UINT8_C(0x5C)
  291. #define BMI160_INT_LOWHIGH_3_ADDR UINT8_C(0x5D)
  292. #define BMI160_INT_LOWHIGH_4_ADDR UINT8_C(0x5E)
  293. #define BMI160_INT_MOTION_0_ADDR UINT8_C(0x5F)
  294. #define BMI160_INT_MOTION_1_ADDR UINT8_C(0x60)
  295. #define BMI160_INT_MOTION_2_ADDR UINT8_C(0x61)
  296. #define BMI160_INT_MOTION_3_ADDR UINT8_C(0x62)
  297. #define BMI160_INT_TAP_0_ADDR UINT8_C(0x63)
  298. #define BMI160_INT_TAP_1_ADDR UINT8_C(0x64)
  299. #define BMI160_INT_ORIENT_0_ADDR UINT8_C(0x65)
  300. #define BMI160_INT_ORIENT_1_ADDR UINT8_C(0x66)
  301. #define BMI160_INT_FLAT_0_ADDR UINT8_C(0x67)
  302. #define BMI160_INT_FLAT_1_ADDR UINT8_C(0x68)
  303. #define BMI160_FOC_CONF_ADDR UINT8_C(0x69)
  304. #define BMI160_CONF_ADDR UINT8_C(0x6A)
  305. #define BMI160_IF_CONF_ADDR UINT8_C(0x6B)
  306. #define BMI160_SELF_TEST_ADDR UINT8_C(0x6D)
  307. #define BMI160_OFFSET_ADDR UINT8_C(0x71)
  308. #define BMI160_OFFSET_CONF_ADDR UINT8_C(0x77)
  309. #define BMI160_INT_STEP_CNT_0_ADDR UINT8_C(0x78)
  310. #define BMI160_INT_STEP_CONFIG_0_ADDR UINT8_C(0x7A)
  311. #define BMI160_INT_STEP_CONFIG_1_ADDR UINT8_C(0x7B)
  312. #define BMI160_COMMAND_REG_ADDR UINT8_C(0x7E)
  313. #define BMI160_SPI_COMM_TEST_ADDR UINT8_C(0x7F)
  314. #define BMI160_INTL_PULLUP_CONF_ADDR UINT8_C(0x85)
  315. /** Error code definitions */
  316. #define BMI160_OK INT8_C(0)
  317. #define BMI160_E_NULL_PTR INT8_C(-1)
  318. #define BMI160_E_COM_FAIL INT8_C(-2)
  319. #define BMI160_E_DEV_NOT_FOUND INT8_C(-3)
  320. #define BMI160_E_OUT_OF_RANGE INT8_C(-4)
  321. #define BMI160_E_INVALID_INPUT INT8_C(-5)
  322. #define BMI160_E_ACCEL_ODR_BW_INVALID INT8_C(-6)
  323. #define BMI160_E_GYRO_ODR_BW_INVALID INT8_C(-7)
  324. #define BMI160_E_LWP_PRE_FLTR_INT_INVALID INT8_C(-8)
  325. #define BMI160_E_LWP_PRE_FLTR_INVALID INT8_C(-9)
  326. #define BMI160_E_AUX_NOT_FOUND INT8_C(-10)
  327. #define BMI160_FOC_FAILURE INT8_C(-11)
  328. /**\name API warning codes */
  329. #define BMI160_W_GYRO_SELF_TEST_FAIL INT8_C(1)
  330. #define BMI160_W_ACCEl_SELF_TEST_FAIL INT8_C(2)
  331. /** BMI160 unique chip identifier */
  332. #define BMI160_CHIP_ID UINT8_C(0xD1)
  333. /** Soft reset command */
  334. #define BMI160_SOFT_RESET_CMD UINT8_C(0xb6)
  335. #define BMI160_SOFT_RESET_DELAY_MS UINT8_C(15)
  336. /** Start FOC command */
  337. #define BMI160_START_FOC_CMD UINT8_C(0x03)
  338. /** NVM backup enabling command */
  339. #define BMI160_NVM_BACKUP_EN UINT8_C(0xA0)
  340. /* Delay in ms settings */
  341. #define BMI160_ACCEL_DELAY_MS UINT8_C(5)
  342. #define BMI160_GYRO_DELAY_MS UINT8_C(81)
  343. #define BMI160_ONE_MS_DELAY UINT8_C(1)
  344. #define BMI160_AUX_COM_DELAY UINT8_C(10)
  345. #define BMI160_GYRO_SELF_TEST_DELAY UINT8_C(20)
  346. #define BMI160_ACCEL_SELF_TEST_DELAY UINT8_C(50)
  347. /** Self test configurations */
  348. #define BMI160_ACCEL_SELF_TEST_CONFIG UINT8_C(0x2C)
  349. #define BMI160_ACCEL_SELF_TEST_POSITIVE_EN UINT8_C(0x0D)
  350. #define BMI160_ACCEL_SELF_TEST_NEGATIVE_EN UINT8_C(0x09)
  351. #define BMI160_ACCEL_SELF_TEST_LIMIT UINT16_C(8192)
  352. /** Power mode settings */
  353. /* Accel power mode */
  354. #define BMI160_ACCEL_NORMAL_MODE UINT8_C(0x11)
  355. #define BMI160_ACCEL_LOWPOWER_MODE UINT8_C(0x12)
  356. #define BMI160_ACCEL_SUSPEND_MODE UINT8_C(0x10)
  357. /* Gyro power mode */
  358. #define BMI160_GYRO_SUSPEND_MODE UINT8_C(0x14)
  359. #define BMI160_GYRO_NORMAL_MODE UINT8_C(0x15)
  360. #define BMI160_GYRO_FASTSTARTUP_MODE UINT8_C(0x17)
  361. /* Aux power mode */
  362. #define BMI160_AUX_SUSPEND_MODE UINT8_C(0x18)
  363. #define BMI160_AUX_NORMAL_MODE UINT8_C(0x19)
  364. #define BMI160_AUX_LOWPOWER_MODE UINT8_C(0x1A)
  365. /** Range settings */
  366. /* Accel Range */
  367. #define BMI160_ACCEL_RANGE_2G UINT8_C(0x03)
  368. #define BMI160_ACCEL_RANGE_4G UINT8_C(0x05)
  369. #define BMI160_ACCEL_RANGE_8G UINT8_C(0x08)
  370. #define BMI160_ACCEL_RANGE_16G UINT8_C(0x0C)
  371. /* Gyro Range */
  372. #define BMI160_GYRO_RANGE_2000_DPS UINT8_C(0x00)
  373. #define BMI160_GYRO_RANGE_1000_DPS UINT8_C(0x01)
  374. #define BMI160_GYRO_RANGE_500_DPS UINT8_C(0x02)
  375. #define BMI160_GYRO_RANGE_250_DPS UINT8_C(0x03)
  376. #define BMI160_GYRO_RANGE_125_DPS UINT8_C(0x04)
  377. /** Bandwidth settings */
  378. /* Accel Bandwidth */
  379. #define BMI160_ACCEL_BW_OSR4_AVG1 UINT8_C(0x00)
  380. #define BMI160_ACCEL_BW_OSR2_AVG2 UINT8_C(0x01)
  381. #define BMI160_ACCEL_BW_NORMAL_AVG4 UINT8_C(0x02)
  382. #define BMI160_ACCEL_BW_CIC_AVG8 UINT8_C(0x03)
  383. #define BMI160_ACCEL_BW_RES_AVG16 UINT8_C(0x04)
  384. #define BMI160_ACCEL_BW_RES_AVG32 UINT8_C(0x05)
  385. #define BMI160_ACCEL_BW_RES_AVG64 UINT8_C(0x06)
  386. #define BMI160_ACCEL_BW_RES_AVG128 UINT8_C(0x07)
  387. #define BMI160_GYRO_BW_OSR4_MODE UINT8_C(0x00)
  388. #define BMI160_GYRO_BW_OSR2_MODE UINT8_C(0x01)
  389. #define BMI160_GYRO_BW_NORMAL_MODE UINT8_C(0x02)
  390. #define BMI160_GYRO_BW_CIC_MODE UINT8_C(0x03)
  391. /* Output Data Rate settings */
  392. /* Accel Output data rate */
  393. #define BMI160_ACCEL_ODR_RESERVED UINT8_C(0x00)
  394. #define BMI160_ACCEL_ODR_0_78HZ UINT8_C(0x01)
  395. #define BMI160_ACCEL_ODR_1_56HZ UINT8_C(0x02)
  396. #define BMI160_ACCEL_ODR_3_12HZ UINT8_C(0x03)
  397. #define BMI160_ACCEL_ODR_6_25HZ UINT8_C(0x04)
  398. #define BMI160_ACCEL_ODR_12_5HZ UINT8_C(0x05)
  399. #define BMI160_ACCEL_ODR_25HZ UINT8_C(0x06)
  400. #define BMI160_ACCEL_ODR_50HZ UINT8_C(0x07)
  401. #define BMI160_ACCEL_ODR_100HZ UINT8_C(0x08)
  402. #define BMI160_ACCEL_ODR_200HZ UINT8_C(0x09)
  403. #define BMI160_ACCEL_ODR_400HZ UINT8_C(0x0A)
  404. #define BMI160_ACCEL_ODR_800HZ UINT8_C(0x0B)
  405. #define BMI160_ACCEL_ODR_1600HZ UINT8_C(0x0C)
  406. #define BMI160_ACCEL_ODR_RESERVED0 UINT8_C(0x0D)
  407. #define BMI160_ACCEL_ODR_RESERVED1 UINT8_C(0x0E)
  408. #define BMI160_ACCEL_ODR_RESERVED2 UINT8_C(0x0F)
  409. /* Gyro Output data rate */
  410. #define BMI160_GYRO_ODR_RESERVED UINT8_C(0x00)
  411. #define BMI160_GYRO_ODR_25HZ UINT8_C(0x06)
  412. #define BMI160_GYRO_ODR_50HZ UINT8_C(0x07)
  413. #define BMI160_GYRO_ODR_100HZ UINT8_C(0x08)
  414. #define BMI160_GYRO_ODR_200HZ UINT8_C(0x09)
  415. #define BMI160_GYRO_ODR_400HZ UINT8_C(0x0A)
  416. #define BMI160_GYRO_ODR_800HZ UINT8_C(0x0B)
  417. #define BMI160_GYRO_ODR_1600HZ UINT8_C(0x0C)
  418. #define BMI160_GYRO_ODR_3200HZ UINT8_C(0x0D)
  419. /* Auxiliary sensor Output data rate */
  420. #define BMI160_AUX_ODR_RESERVED UINT8_C(0x00)
  421. #define BMI160_AUX_ODR_0_78HZ UINT8_C(0x01)
  422. #define BMI160_AUX_ODR_1_56HZ UINT8_C(0x02)
  423. #define BMI160_AUX_ODR_3_12HZ UINT8_C(0x03)
  424. #define BMI160_AUX_ODR_6_25HZ UINT8_C(0x04)
  425. #define BMI160_AUX_ODR_12_5HZ UINT8_C(0x05)
  426. #define BMI160_AUX_ODR_25HZ UINT8_C(0x06)
  427. #define BMI160_AUX_ODR_50HZ UINT8_C(0x07)
  428. #define BMI160_AUX_ODR_100HZ UINT8_C(0x08)
  429. #define BMI160_AUX_ODR_200HZ UINT8_C(0x09)
  430. #define BMI160_AUX_ODR_400HZ UINT8_C(0x0A)
  431. #define BMI160_AUX_ODR_800HZ UINT8_C(0x0B)
  432. /* Maximum limits definition */
  433. #define BMI160_ACCEL_ODR_MAX UINT8_C(15)
  434. #define BMI160_ACCEL_BW_MAX UINT8_C(2)
  435. #define BMI160_ACCEL_RANGE_MAX UINT8_C(12)
  436. #define BMI160_GYRO_ODR_MAX UINT8_C(13)
  437. #define BMI160_GYRO_BW_MAX UINT8_C(2)
  438. #define BMI160_GYRO_RANGE_MAX UINT8_C(4)
  439. /** FIFO_CONFIG Definitions */
  440. #define BMI160_FIFO_TIME_ENABLE UINT8_C(0x02)
  441. #define BMI160_FIFO_TAG_INT2_ENABLE UINT8_C(0x04)
  442. #define BMI160_FIFO_TAG_INT1_ENABLE UINT8_C(0x08)
  443. #define BMI160_FIFO_HEAD_ENABLE UINT8_C(0x10)
  444. #define BMI160_FIFO_M_ENABLE UINT8_C(0x20)
  445. #define BMI160_FIFO_A_ENABLE UINT8_C(0x40)
  446. #define BMI160_FIFO_M_A_ENABLE UINT8_C(0x60)
  447. #define BMI160_FIFO_G_ENABLE UINT8_C(0x80)
  448. #define BMI160_FIFO_M_G_ENABLE UINT8_C(0xA0)
  449. #define BMI160_FIFO_G_A_ENABLE UINT8_C(0xC0)
  450. #define BMI160_FIFO_M_G_A_ENABLE UINT8_C(0xE0)
  451. /* Accel, gyro and aux. sensor length and also their combined
  452. * length definitions in FIFO */
  453. #define BMI160_FIFO_G_LENGTH UINT8_C(6)
  454. #define BMI160_FIFO_A_LENGTH UINT8_C(6)
  455. #define BMI160_FIFO_M_LENGTH UINT8_C(8)
  456. #define BMI160_FIFO_GA_LENGTH UINT8_C(12)
  457. #define BMI160_FIFO_MA_LENGTH UINT8_C(14)
  458. #define BMI160_FIFO_MG_LENGTH UINT8_C(14)
  459. #define BMI160_FIFO_MGA_LENGTH UINT8_C(20)
  460. /** FIFO Header Data definitions */
  461. #define BMI160_FIFO_HEAD_SKIP_FRAME UINT8_C(0x40)
  462. #define BMI160_FIFO_HEAD_SENSOR_TIME UINT8_C(0x44)
  463. #define BMI160_FIFO_HEAD_INPUT_CONFIG UINT8_C(0x48)
  464. #define BMI160_FIFO_HEAD_OVER_READ UINT8_C(0x80)
  465. #define BMI160_FIFO_HEAD_A UINT8_C(0x84)
  466. #define BMI160_FIFO_HEAD_G UINT8_C(0x88)
  467. #define BMI160_FIFO_HEAD_G_A UINT8_C(0x8C)
  468. #define BMI160_FIFO_HEAD_M UINT8_C(0x90)
  469. #define BMI160_FIFO_HEAD_M_A UINT8_C(0x94)
  470. #define BMI160_FIFO_HEAD_M_G UINT8_C(0x98)
  471. #define BMI160_FIFO_HEAD_M_G_A UINT8_C(0x9C)
  472. /** FIFO sensor time length definitions */
  473. #define BMI160_SENSOR_TIME_LENGTH UINT8_C(3)
  474. /** FIFO DOWN selection */
  475. /* Accel fifo down-sampling values*/
  476. #define BMI160_ACCEL_FIFO_DOWN_ZERO UINT8_C(0x00)
  477. #define BMI160_ACCEL_FIFO_DOWN_ONE UINT8_C(0x10)
  478. #define BMI160_ACCEL_FIFO_DOWN_TWO UINT8_C(0x20)
  479. #define BMI160_ACCEL_FIFO_DOWN_THREE UINT8_C(0x30)
  480. #define BMI160_ACCEL_FIFO_DOWN_FOUR UINT8_C(0x40)
  481. #define BMI160_ACCEL_FIFO_DOWN_FIVE UINT8_C(0x50)
  482. #define BMI160_ACCEL_FIFO_DOWN_SIX UINT8_C(0x60)
  483. #define BMI160_ACCEL_FIFO_DOWN_SEVEN UINT8_C(0x70)
  484. /* Gyro fifo down-smapling values*/
  485. #define BMI160_GYRO_FIFO_DOWN_ZERO UINT8_C(0x00)
  486. #define BMI160_GYRO_FIFO_DOWN_ONE UINT8_C(0x01)
  487. #define BMI160_GYRO_FIFO_DOWN_TWO UINT8_C(0x02)
  488. #define BMI160_GYRO_FIFO_DOWN_THREE UINT8_C(0x03)
  489. #define BMI160_GYRO_FIFO_DOWN_FOUR UINT8_C(0x04)
  490. #define BMI160_GYRO_FIFO_DOWN_FIVE UINT8_C(0x05)
  491. #define BMI160_GYRO_FIFO_DOWN_SIX UINT8_C(0x06)
  492. #define BMI160_GYRO_FIFO_DOWN_SEVEN UINT8_C(0x07)
  493. /* Accel Fifo filter enable*/
  494. #define BMI160_ACCEL_FIFO_FILT_EN UINT8_C(0x80)
  495. /* Gyro Fifo filter enable*/
  496. #define BMI160_GYRO_FIFO_FILT_EN UINT8_C(0x08)
  497. /** Definitions to check validity of FIFO frames */
  498. #define FIFO_CONFIG_MSB_CHECK UINT8_C(0x80)
  499. #define FIFO_CONFIG_LSB_CHECK UINT8_C(0x00)
  500. /*! BMI160 accel FOC configurations */
  501. #define BMI160_FOC_ACCEL_DISABLED UINT8_C(0x00)
  502. #define BMI160_FOC_ACCEL_POSITIVE_G UINT8_C(0x01)
  503. #define BMI160_FOC_ACCEL_NEGATIVE_G UINT8_C(0x02)
  504. #define BMI160_FOC_ACCEL_0G UINT8_C(0x03)
  505. /** Array Parameter DefinItions */
  506. #define BMI160_SENSOR_TIME_LSB_BYTE UINT8_C(0)
  507. #define BMI160_SENSOR_TIME_XLSB_BYTE UINT8_C(1)
  508. #define BMI160_SENSOR_TIME_MSB_BYTE UINT8_C(2)
  509. /** Interface settings */
  510. #define BMI160_SPI_INTF UINT8_C(1)
  511. #define BMI160_I2C_INTF UINT8_C(0)
  512. #define BMI160_SPI_RD_MASK UINT8_C(0x80)
  513. #define BMI160_SPI_WR_MASK UINT8_C(0x7F)
  514. /* Sensor & time select definition*/
  515. #define BMI160_ACCEL_SEL UINT8_C(0x01)
  516. #define BMI160_GYRO_SEL UINT8_C(0x02)
  517. #define BMI160_TIME_SEL UINT8_C(0x04)
  518. /* Sensor select mask*/
  519. #define BMI160_SEN_SEL_MASK UINT8_C(0x07)
  520. /* Error code mask */
  521. #define BMI160_ERR_REG_MASK UINT8_C(0x0F)
  522. /* BMI160 I2C address */
  523. #define BMI160_I2C_ADDR UINT8_C(0x68)
  524. /* BMI160 secondary IF address */
  525. #define BMI160_AUX_BMM150_I2C_ADDR UINT8_C(0x10)
  526. /** BMI160 Length definitions */
  527. #define BMI160_ONE UINT8_C(1)
  528. #define BMI160_TWO UINT8_C(2)
  529. #define BMI160_THREE UINT8_C(3)
  530. #define BMI160_FOUR UINT8_C(4)
  531. #define BMI160_FIVE UINT8_C(5)
  532. /** BMI160 fifo level Margin */
  533. #define BMI160_FIFO_LEVEL_MARGIN UINT8_C(16)
  534. /** BMI160 fifo flush Command */
  535. #define BMI160_FIFO_FLUSH_VALUE UINT8_C(0xB0)
  536. /** BMI160 offset values for xyz axes of accel */
  537. #define BMI160_ACCEL_MIN_OFFSET INT8_C(-128)
  538. #define BMI160_ACCEL_MAX_OFFSET INT8_C(127)
  539. /** BMI160 offset values for xyz axes of gyro */
  540. #define BMI160_GYRO_MIN_OFFSET INT16_C(-512)
  541. #define BMI160_GYRO_MAX_OFFSET INT16_C(511)
  542. /** BMI160 fifo full interrupt position and mask */
  543. #define BMI160_FIFO_FULL_INT_POS UINT8_C(5)
  544. #define BMI160_FIFO_FULL_INT_MSK UINT8_C(0x20)
  545. #define BMI160_FIFO_WTM_INT_POS UINT8_C(6)
  546. #define BMI160_FIFO_WTM_INT_MSK UINT8_C(0x40)
  547. #define BMI160_FIFO_FULL_INT_PIN1_POS UINT8_C(5)
  548. #define BMI160_FIFO_FULL_INT_PIN1_MSK UINT8_C(0x20)
  549. #define BMI160_FIFO_FULL_INT_PIN2_POS UINT8_C(1)
  550. #define BMI160_FIFO_FULL_INT_PIN2_MSK UINT8_C(0x02)
  551. #define BMI160_FIFO_WTM_INT_PIN1_POS UINT8_C(6)
  552. #define BMI160_FIFO_WTM_INT_PIN1_MSK UINT8_C(0x40)
  553. #define BMI160_FIFO_WTM_INT_PIN2_POS UINT8_C(2)
  554. #define BMI160_FIFO_WTM_INT_PIN2_MSK UINT8_C(0x04)
  555. #define BMI160_MANUAL_MODE_EN_POS UINT8_C(7)
  556. #define BMI160_MANUAL_MODE_EN_MSK UINT8_C(0x80)
  557. #define BMI160_AUX_READ_BURST_POS UINT8_C(0)
  558. #define BMI160_AUX_READ_BURST_MSK UINT8_C(0x03)
  559. #define BMI160_GYRO_SELF_TEST_POS UINT8_C(4)
  560. #define BMI160_GYRO_SELF_TEST_MSK UINT8_C(0x10)
  561. #define BMI160_GYRO_SELF_TEST_STATUS_POS UINT8_C(1)
  562. #define BMI160_GYRO_SELF_TEST_STATUS_MSK UINT8_C(0x02)
  563. #define BMI160_GYRO_FOC_EN_POS UINT8_C(6)
  564. #define BMI160_GYRO_FOC_EN_MSK UINT8_C(0x40)
  565. #define BMI160_ACCEL_FOC_X_CONF_POS UINT8_C(4)
  566. #define BMI160_ACCEL_FOC_X_CONF_MSK UINT8_C(0x30)
  567. #define BMI160_ACCEL_FOC_Y_CONF_POS UINT8_C(2)
  568. #define BMI160_ACCEL_FOC_Y_CONF_MSK UINT8_C(0x0C)
  569. #define BMI160_ACCEL_FOC_Z_CONF_MSK UINT8_C(0x03)
  570. #define BMI160_FOC_STATUS_POS UINT8_C(3)
  571. #define BMI160_FOC_STATUS_MSK UINT8_C(0x08)
  572. #define BMI160_GYRO_OFFSET_X_MSK UINT8_C(0x03)
  573. #define BMI160_GYRO_OFFSET_Y_POS UINT8_C(2)
  574. #define BMI160_GYRO_OFFSET_Y_MSK UINT8_C(0x0C)
  575. #define BMI160_GYRO_OFFSET_Z_POS UINT8_C(4)
  576. #define BMI160_GYRO_OFFSET_Z_MSK UINT8_C(0x30)
  577. #define BMI160_GYRO_OFFSET_EN_POS UINT8_C(7)
  578. #define BMI160_GYRO_OFFSET_EN_MSK UINT8_C(0x80)
  579. #define BMI160_ACCEL_OFFSET_EN_POS UINT8_C(6)
  580. #define BMI160_ACCEL_OFFSET_EN_MSK UINT8_C(0x40)
  581. #define BMI160_GYRO_OFFSET_POS UINT16_C(8)
  582. #define BMI160_GYRO_OFFSET_MSK UINT16_C(0x0300)
  583. #define BMI160_NVM_UPDATE_POS UINT8_C(1)
  584. #define BMI160_NVM_UPDATE_MSK UINT8_C(0x02)
  585. #define BMI160_NVM_STATUS_POS UINT8_C(4)
  586. #define BMI160_NVM_STATUS_MSK UINT8_C(0x10)
  587. /* BIT SLICE GET AND SET FUNCTIONS */
  588. #define BMI160_GET_BITS(regvar, bitname)\
  589. ((regvar & bitname##_MSK) >> bitname##_POS)
  590. #define BMI160_SET_BITS(regvar, bitname, val)\
  591. ((regvar & ~bitname##_MSK) | \
  592. ((val<<bitname##_POS)&bitname##_MSK))
  593. #define BMI160_SET_BITS_POS_0(reg_data, bitname, data) \
  594. ((reg_data & ~(bitname##_MSK)) | \
  595. (data & bitname##_MSK))
  596. #define BMI160_GET_BITS_POS_0(reg_data, bitname) (reg_data & (bitname##_MSK))
  597. /**\name UTILITY MACROS */
  598. #define BMI160_SET_LOW_BYTE UINT16_C(0x00FF)
  599. #define BMI160_SET_HIGH_BYTE UINT16_C(0xFF00)
  600. #define BMI160_GET_LSB(var) (uint8_t)(var & BMI160_SET_LOW_BYTE)
  601. #define BMI160_GET_MSB(var) (uint8_t)((var & BMI160_SET_HIGH_BYTE) >> 8)
  602. /*****************************************************************************/
  603. /* type definitions */
  604. typedef int8_t (*bmi160_com_fptr_t)(uint8_t dev_addr, uint8_t reg_addr,
  605. uint8_t *data, uint16_t len);
  606. typedef void (*bmi160_delay_fptr_t)(uint32_t period);
  607. /*************************** Data structures *********************************/
  608. /*!
  609. * @brief bmi160 sensor data structure which comprises of accel data
  610. */
  611. struct bmi160_sensor_data {
  612. /*! X-axis sensor data */
  613. int16_t x;
  614. /*! Y-axis sensor data */
  615. int16_t y;
  616. /*! Z-axis sensor data */
  617. int16_t z;
  618. /*! sensor time */
  619. uint32_t sensortime;
  620. };
  621. /*!
  622. * @brief bmi160 FOC configuration structure
  623. */
  624. struct bmi160_foc_conf {
  625. /*! Enabling FOC in gyro
  626. * Assignable macros :
  627. * - BMI160_ENABLE
  628. * - BMI160_DISABLE
  629. */
  630. uint8_t foc_gyr_en;
  631. /*! Accel FOC configurations
  632. * Assignable macros :
  633. * - BMI160_FOC_ACCEL_DISABLED
  634. * - BMI160_FOC_ACCEL_POSITIVE_G
  635. * - BMI160_FOC_ACCEL_NEGATIVE_G
  636. * - BMI160_FOC_ACCEL_0G
  637. */
  638. uint8_t foc_acc_x;
  639. uint8_t foc_acc_y;
  640. uint8_t foc_acc_z;
  641. /*! Enabling offset compensation for accel in data registers
  642. * Assignable macros :
  643. * - BMI160_ENABLE
  644. * - BMI160_DISABLE
  645. */
  646. uint8_t acc_off_en;
  647. /*! Enabling offset compensation for gyro in data registers
  648. * Assignable macros :
  649. * - BMI160_ENABLE
  650. * - BMI160_DISABLE
  651. */
  652. uint8_t gyro_off_en;
  653. };
  654. /*!
  655. * @brief bmi160 accel gyro offsets
  656. */
  657. struct bmi160_offsets {
  658. /*! Accel offset for x axis */
  659. int8_t off_acc_x;
  660. /*! Accel offset for y axis */
  661. int8_t off_acc_y;
  662. /*! Accel offset for z axis */
  663. int8_t off_acc_z;
  664. /*! Gyro offset for x axis */
  665. int16_t off_gyro_x;
  666. /*! Gyro offset for y axis */
  667. int16_t off_gyro_y;
  668. /*! Gyro offset for z axis */
  669. int16_t off_gyro_z;
  670. };
  671. /*!
  672. * @brief FIFO aux. sensor data structure
  673. */
  674. struct bmi160_aux_fifo_data {
  675. /*! The value of aux. sensor x LSB data */
  676. uint8_t aux_x_lsb;
  677. /*! The value of aux. sensor x MSB data */
  678. uint8_t aux_x_msb;
  679. /*! The value of aux. sensor y LSB data */
  680. uint8_t aux_y_lsb;
  681. /*! The value of aux. sensor y MSB data */
  682. uint8_t aux_y_msb;
  683. /*! The value of aux. sensor z LSB data */
  684. uint8_t aux_z_lsb;
  685. /*! The value of aux. sensor z MSB data */
  686. uint8_t aux_z_msb;
  687. /*! The value of aux. sensor r for BMM150 LSB data */
  688. uint8_t aux_r_y2_lsb;
  689. /*! The value of aux. sensor r for BMM150 MSB data */
  690. uint8_t aux_r_y2_msb;
  691. };
  692. /*!
  693. * @brief bmi160 sensor select structure
  694. */
  695. enum bmi160_select_sensor {
  696. BMI160_ACCEL_ONLY = 1,
  697. BMI160_GYRO_ONLY,
  698. BMI160_BOTH_ACCEL_AND_GYRO
  699. };
  700. /*!
  701. * @brief bmi160 sensor step detector mode structure
  702. */
  703. enum bmi160_step_detect_mode {
  704. BMI160_STEP_DETECT_NORMAL,
  705. BMI160_STEP_DETECT_SENSITIVE,
  706. BMI160_STEP_DETECT_ROBUST,
  707. /*! Non recommended User defined setting */
  708. BMI160_STEP_DETECT_USER_DEFINE
  709. };
  710. /*!
  711. * @brief enum for auxiliary burst read selection
  712. */
  713. enum bm160_aux_read_len {
  714. BMI160_AUX_READ_LEN_0,
  715. BMI160_AUX_READ_LEN_1,
  716. BMI160_AUX_READ_LEN_2,
  717. BMI160_AUX_READ_LEN_3
  718. };
  719. /*!
  720. * @brief bmi160 sensor configuration structure
  721. */
  722. struct bmi160_cfg {
  723. /*! power mode */
  724. uint8_t power;
  725. /*! output data rate */
  726. uint8_t odr;
  727. /*! range */
  728. uint8_t range;
  729. /*! bandwidth */
  730. uint8_t bw;
  731. };
  732. /*!
  733. * @brief Aux sensor configuration structure
  734. */
  735. struct bmi160_aux_cfg {
  736. /*! Aux sensor, 1 - enable 0 - disable */
  737. uint8_t aux_sensor_enable : 1;
  738. /*! Aux manual/auto mode status */
  739. uint8_t manual_enable : 1;
  740. /*! Aux read burst length */
  741. uint8_t aux_rd_burst_len : 2;
  742. /*! output data rate */
  743. uint8_t aux_odr :4;
  744. /*! i2c addr of auxiliary sensor */
  745. uint8_t aux_i2c_addr;
  746. };
  747. /*!
  748. * @brief bmi160 interrupt channel selection structure
  749. */
  750. enum bmi160_int_channel {
  751. /*! interrupt Channel 1 */
  752. BMI160_INT_CHANNEL_1,
  753. /*! interrupt Channel 2 */
  754. BMI160_INT_CHANNEL_2
  755. };
  756. enum bmi160_int_types {
  757. /*! Slope/Any-motion interrupt */
  758. BMI160_ACC_ANY_MOTION_INT,
  759. /*! Significant motion interrupt */
  760. BMI160_ACC_SIG_MOTION_INT,
  761. /*! Step detector interrupt */
  762. BMI160_STEP_DETECT_INT,
  763. /*! double tap interrupt */
  764. BMI160_ACC_DOUBLE_TAP_INT,
  765. /*! single tap interrupt */
  766. BMI160_ACC_SINGLE_TAP_INT,
  767. /*! orientation interrupt */
  768. BMI160_ACC_ORIENT_INT,
  769. /*! flat interrupt */
  770. BMI160_ACC_FLAT_INT,
  771. /*! high-g interrupt */
  772. BMI160_ACC_HIGH_G_INT,
  773. /*! low-g interrupt */
  774. BMI160_ACC_LOW_G_INT,
  775. /*! slow/no-motion interrupt */
  776. BMI160_ACC_SLOW_NO_MOTION_INT,
  777. /*! data ready interrupt */
  778. BMI160_ACC_GYRO_DATA_RDY_INT,
  779. /*! fifo full interrupt */
  780. BMI160_ACC_GYRO_FIFO_FULL_INT,
  781. /*! fifo watermark interrupt */
  782. BMI160_ACC_GYRO_FIFO_WATERMARK_INT
  783. };
  784. /*!
  785. * @brief bmi160 active state of any & sig motion interrupt.
  786. */
  787. enum bmi160_any_sig_motion_active_interrupt_state {
  788. /*! Both any & sig motion are disabled */
  789. BMI160_BOTH_ANY_SIG_MOTION_DISABLED = -1,
  790. /*! Any-motion selected */
  791. BMI160_ANY_MOTION_ENABLED,
  792. /*! Sig-motion selected */
  793. BMI160_SIG_MOTION_ENABLED
  794. };
  795. struct bmi160_acc_tap_int_cfg {
  796. #if LITTLE_ENDIAN == 1
  797. /*! tap threshold */
  798. uint16_t tap_thr :5;
  799. /*! tap shock */
  800. uint16_t tap_shock :1;
  801. /*! tap quiet */
  802. uint16_t tap_quiet :1;
  803. /*! tap duration */
  804. uint16_t tap_dur :3;
  805. /*! data source 0- filter & 1 pre-filter*/
  806. uint16_t tap_data_src :1;
  807. /*! tap enable, 1 - enable, 0 - disable */
  808. uint16_t tap_en :1;
  809. #elif BIG_ENDIAN == 1
  810. /*! tap enable, 1 - enable, 0 - disable */
  811. uint16_t tap_en :1;
  812. /*! data source 0- filter & 1 pre-filter*/
  813. uint16_t tap_data_src :1;
  814. /*! tap duration */
  815. uint16_t tap_dur : 3;
  816. /*! tap quiet */
  817. uint16_t tap_quiet : 1;
  818. /*! tap shock */
  819. uint16_t tap_shock : 1;
  820. /*! tap threshold */
  821. uint16_t tap_thr : 5;
  822. #endif
  823. };
  824. struct bmi160_acc_any_mot_int_cfg {
  825. #if LITTLE_ENDIAN == 1
  826. /*! 1 any-motion enable, 0 - any-motion disable */
  827. uint8_t anymotion_en :1;
  828. /*! slope interrupt x, 1 - enable, 0 - disable */
  829. uint8_t anymotion_x :1;
  830. /*! slope interrupt y, 1 - enable, 0 - disable */
  831. uint8_t anymotion_y :1;
  832. /*! slope interrupt z, 1 - enable, 0 - disable */
  833. uint8_t anymotion_z :1;
  834. /*! slope duration */
  835. uint8_t anymotion_dur :2;
  836. /*! data source 0- filter & 1 pre-filter*/
  837. uint8_t anymotion_data_src :1;
  838. /*! slope threshold */
  839. uint8_t anymotion_thr;
  840. #elif BIG_ENDIAN == 1
  841. /*! slope threshold */
  842. uint8_t anymotion_thr;
  843. /*! data source 0- filter & 1 pre-filter*/
  844. uint8_t anymotion_data_src :1;
  845. /*! slope duration */
  846. uint8_t anymotion_dur : 2;
  847. /*! slope interrupt z, 1 - enable, 0 - disable */
  848. uint8_t anymotion_z : 1;
  849. /*! slope interrupt y, 1 - enable, 0 - disable */
  850. uint8_t anymotion_y : 1;
  851. /*! slope interrupt x, 1 - enable, 0 - disable */
  852. uint8_t anymotion_x : 1;
  853. /*! 1 any-motion enable, 0 - any-motion disable */
  854. uint8_t anymotion_en :1;
  855. #endif
  856. };
  857. struct bmi160_acc_sig_mot_int_cfg {
  858. #if LITTLE_ENDIAN == 1
  859. /*! skip time of sig-motion interrupt */
  860. uint8_t sig_mot_skip :2;
  861. /*! proof time of sig-motion interrupt */
  862. uint8_t sig_mot_proof :2;
  863. /*! data source 0- filter & 1 pre-filter*/
  864. uint8_t sig_data_src :1;
  865. /*! 1 - enable sig, 0 - disable sig & enable anymotion */
  866. uint8_t sig_en :1;
  867. /*! sig-motion threshold */
  868. uint8_t sig_mot_thres;
  869. #elif BIG_ENDIAN == 1
  870. /*! sig-motion threshold */
  871. uint8_t sig_mot_thres;
  872. /*! 1 - enable sig, 0 - disable sig & enable anymotion */
  873. uint8_t sig_en :1;
  874. /*! data source 0- filter & 1 pre-filter*/
  875. uint8_t sig_data_src :1;
  876. /*! proof time of sig-motion interrupt */
  877. uint8_t sig_mot_proof : 2;
  878. /*! skip time of sig-motion interrupt */
  879. uint8_t sig_mot_skip : 2;
  880. #endif
  881. };
  882. struct bmi160_acc_step_detect_int_cfg {
  883. #if LITTLE_ENDIAN == 1
  884. /*! 1- step detector enable, 0- step detector disable */
  885. uint16_t step_detector_en :1;
  886. /*! minimum threshold */
  887. uint16_t min_threshold :2;
  888. /*! minimal detectable step time */
  889. uint16_t steptime_min :3;
  890. /*! enable step counter mode setting */
  891. uint16_t step_detector_mode :2;
  892. /*! minimum step buffer size*/
  893. uint16_t step_min_buf :3;
  894. #elif BIG_ENDIAN == 1
  895. /*! minimum step buffer size*/
  896. uint16_t step_min_buf :3;
  897. /*! enable step counter mode setting */
  898. uint16_t step_detector_mode : 2;
  899. /*! minimal detectable step time */
  900. uint16_t steptime_min : 3;
  901. /*! minimum threshold */
  902. uint16_t min_threshold : 2;
  903. /*! 1- step detector enable, 0- step detector disable */
  904. uint16_t step_detector_en :1;
  905. #endif
  906. };
  907. struct bmi160_acc_no_motion_int_cfg {
  908. #if LITTLE_ENDIAN == 1
  909. /*! no motion interrupt x */
  910. uint16_t no_motion_x :1;
  911. /*! no motion interrupt y */
  912. uint16_t no_motion_y :1;
  913. /*! no motion interrupt z */
  914. uint16_t no_motion_z :1;
  915. /*! no motion duration */
  916. uint16_t no_motion_dur :6;
  917. /*! no motion sel , 1 - enable no-motion ,0- enable slow-motion */
  918. uint16_t no_motion_sel :1;
  919. /*! data source 0- filter & 1 pre-filter*/
  920. uint16_t no_motion_src :1;
  921. /*! no motion threshold */
  922. uint8_t no_motion_thres;
  923. #elif BIG_ENDIAN == 1
  924. /*! no motion threshold */
  925. uint8_t no_motion_thres;
  926. /*! data source 0- filter & 1 pre-filter*/
  927. uint16_t no_motion_src :1;
  928. /*! no motion sel , 1 - enable no-motion ,0- enable slow-motion */
  929. uint16_t no_motion_sel : 1;
  930. /*! no motion duration */
  931. uint16_t no_motion_dur : 6;
  932. /* no motion interrupt z */
  933. uint16_t no_motion_z :1;
  934. /*! no motion interrupt y */
  935. uint16_t no_motion_y :1;
  936. /*! no motion interrupt x */
  937. uint16_t no_motion_x :1;
  938. #endif
  939. };
  940. struct bmi160_acc_orient_int_cfg {
  941. #if LITTLE_ENDIAN == 1
  942. /*! thresholds for switching between the different orientations */
  943. uint16_t orient_mode :2;
  944. /*! blocking_mode */
  945. uint16_t orient_blocking :2;
  946. /*! Orientation interrupt hysteresis */
  947. uint16_t orient_hyst :4;
  948. /*! Orientation interrupt theta */
  949. uint16_t orient_theta :6;
  950. /*! Enable/disable Orientation interrupt */
  951. uint16_t orient_ud_en :1;
  952. /*! exchange x- and z-axis in algorithm ,0 - z, 1 - x */
  953. uint16_t axes_ex :1;
  954. /*! 1 - orient enable, 0 - orient disable */
  955. uint8_t orient_en :1;
  956. #elif BIG_ENDIAN == 1
  957. /*! 1 - orient enable, 0 - orient disable */
  958. uint8_t orient_en :1;
  959. /*! exchange x- and z-axis in algorithm ,0 - z, 1 - x */
  960. uint16_t axes_ex : 1;
  961. /*! Enable/disable Orientation interrupt */
  962. uint16_t orient_ud_en : 1;
  963. /*! Orientation interrupt theta */
  964. uint16_t orient_theta : 6;
  965. /*! Orientation interrupt hysteresis */
  966. uint16_t orient_hyst : 4;
  967. /*! blocking_mode */
  968. uint16_t orient_blocking : 2;
  969. /*! thresholds for switching between the different orientations */
  970. uint16_t orient_mode : 2;
  971. #endif
  972. };
  973. struct bmi160_acc_flat_detect_int_cfg {
  974. #if LITTLE_ENDIAN == 1
  975. /*! flat threshold */
  976. uint16_t flat_theta :6;
  977. /*! flat interrupt hysteresis */
  978. uint16_t flat_hy :3;
  979. /*! delay time for which the flat value must remain stable for the
  980. * flat interrupt to be generated */
  981. uint16_t flat_hold_time :2;
  982. /*! 1 - flat enable, 0 - flat disable */
  983. uint16_t flat_en :1;
  984. #elif BIG_ENDIAN == 1
  985. /*! 1 - flat enable, 0 - flat disable */
  986. uint16_t flat_en :1;
  987. /*! delay time for which the flat value must remain stable for the
  988. * flat interrupt to be generated */
  989. uint16_t flat_hold_time : 2;
  990. /*! flat interrupt hysteresis */
  991. uint16_t flat_hy : 3;
  992. /*! flat threshold */
  993. uint16_t flat_theta : 6;
  994. #endif
  995. };
  996. struct bmi160_acc_low_g_int_cfg {
  997. #if LITTLE_ENDIAN == 1
  998. /*! low-g interrupt trigger delay */
  999. uint8_t low_dur;
  1000. /*! low-g interrupt trigger threshold */
  1001. uint8_t low_thres;
  1002. /*! hysteresis of low-g interrupt */
  1003. uint8_t low_hyst :2;
  1004. /*! 0 - single-axis mode ,1 - axis-summing mode */
  1005. uint8_t low_mode :1;
  1006. /*! data source 0- filter & 1 pre-filter */
  1007. uint8_t low_data_src :1;
  1008. /*! 1 - enable low-g, 0 - disable low-g */
  1009. uint8_t low_en :1;
  1010. #elif BIG_ENDIAN == 1
  1011. /*! 1 - enable low-g, 0 - disable low-g */
  1012. uint8_t low_en :1;
  1013. /*! data source 0- filter & 1 pre-filter */
  1014. uint8_t low_data_src :1;
  1015. /*! 0 - single-axis mode ,1 - axis-summing mode */
  1016. uint8_t low_mode : 1;
  1017. /*! hysteresis of low-g interrupt */
  1018. uint8_t low_hyst : 2;
  1019. /*! low-g interrupt trigger threshold */
  1020. uint8_t low_thres;
  1021. /*! low-g interrupt trigger delay */
  1022. uint8_t low_dur;
  1023. #endif
  1024. };
  1025. struct bmi160_acc_high_g_int_cfg {
  1026. #if LITTLE_ENDIAN == 1
  1027. /*! High-g interrupt x, 1 - enable, 0 - disable */
  1028. uint8_t high_g_x :1;
  1029. /*! High-g interrupt y, 1 - enable, 0 - disable */
  1030. uint8_t high_g_y :1;
  1031. /*! High-g interrupt z, 1 - enable, 0 - disable */
  1032. uint8_t high_g_z :1;
  1033. /*! High-g hysteresis */
  1034. uint8_t high_hy :2;
  1035. /*! data source 0- filter & 1 pre-filter */
  1036. uint8_t high_data_src :1;
  1037. /*! High-g threshold */
  1038. uint8_t high_thres;
  1039. /*! High-g duration */
  1040. uint8_t high_dur;
  1041. #elif BIG_ENDIAN == 1
  1042. /*! High-g duration */
  1043. uint8_t high_dur;
  1044. /*! High-g threshold */
  1045. uint8_t high_thres;
  1046. /*! data source 0- filter & 1 pre-filter */
  1047. uint8_t high_data_src :1;
  1048. /*! High-g hysteresis */
  1049. uint8_t high_hy : 2;
  1050. /*! High-g interrupt z, 1 - enable, 0 - disable */
  1051. uint8_t high_g_z : 1;
  1052. /*! High-g interrupt y, 1 - enable, 0 - disable */
  1053. uint8_t high_g_y : 1;
  1054. /*! High-g interrupt x, 1 - enable, 0 - disable */
  1055. uint8_t high_g_x : 1;
  1056. #endif
  1057. };
  1058. struct bmi160_int_pin_settg {
  1059. #if LITTLE_ENDIAN == 1
  1060. /*! To enable either INT1 or INT2 pin as output.
  1061. * 0- output disabled ,1- output enabled */
  1062. uint16_t output_en :1;
  1063. /*! 0 - push-pull 1- open drain,only valid if output_en is set 1 */
  1064. uint16_t output_mode :1;
  1065. /*! 0 - active low , 1 - active high level.
  1066. * if output_en is 1,this applies to interrupts,else PMU_trigger */
  1067. uint16_t output_type :1;
  1068. /*! 0 - level trigger , 1 - edge trigger */
  1069. uint16_t edge_ctrl :1;
  1070. /*! To enable either INT1 or INT2 pin as input.
  1071. * 0 - input disabled ,1 - input enabled */
  1072. uint16_t input_en :1;
  1073. /*! latch duration*/
  1074. uint16_t latch_dur :4;
  1075. #elif BIG_ENDIAN == 1
  1076. /*! latch duration*/
  1077. uint16_t latch_dur : 4;
  1078. /*! Latched,non-latched or temporary interrupt modes */
  1079. uint16_t input_en : 1;
  1080. /*! 1 - edge trigger, 0 - level trigger */
  1081. uint16_t edge_ctrl : 1;
  1082. /*! 0 - active low , 1 - active high level.
  1083. * if output_en is 1,this applies to interrupts,else PMU_trigger */
  1084. uint16_t output_type : 1;
  1085. /*! 0 - push-pull , 1 - open drain,only valid if output_en is set 1 */
  1086. uint16_t output_mode : 1;
  1087. /*! To enable either INT1 or INT2 pin as output.
  1088. * 0 - output disabled , 1 - output enabled */
  1089. uint16_t output_en : 1;
  1090. #endif
  1091. };
  1092. union bmi160_int_type_cfg {
  1093. /*! Tap interrupt structure */
  1094. struct bmi160_acc_tap_int_cfg acc_tap_int;
  1095. /*! Slope interrupt structure */
  1096. struct bmi160_acc_any_mot_int_cfg acc_any_motion_int;
  1097. /*! Significant motion interrupt structure */
  1098. struct bmi160_acc_sig_mot_int_cfg acc_sig_motion_int;
  1099. /*! Step detector interrupt structure */
  1100. struct bmi160_acc_step_detect_int_cfg acc_step_detect_int;
  1101. /*! No motion interrupt structure */
  1102. struct bmi160_acc_no_motion_int_cfg acc_no_motion_int;
  1103. /*! Orientation interrupt structure */
  1104. struct bmi160_acc_orient_int_cfg acc_orient_int;
  1105. /*! Flat interrupt structure */
  1106. struct bmi160_acc_flat_detect_int_cfg acc_flat_int;
  1107. /*! Low-g interrupt structure */
  1108. struct bmi160_acc_low_g_int_cfg acc_low_g_int;
  1109. /*! High-g interrupt structure */
  1110. struct bmi160_acc_high_g_int_cfg acc_high_g_int;
  1111. };
  1112. struct bmi160_int_settg {
  1113. /*! Interrupt channel */
  1114. enum bmi160_int_channel int_channel;
  1115. /*! Select Interrupt */
  1116. enum bmi160_int_types int_type;
  1117. /*! Structure configuring Interrupt pins */
  1118. struct bmi160_int_pin_settg int_pin_settg;
  1119. /*! Union configures required interrupt */
  1120. union bmi160_int_type_cfg int_type_cfg;
  1121. /*! FIFO FULL INT 1-enable, 0-disable */
  1122. uint8_t fifo_full_int_en :1;
  1123. /*! FIFO WTM INT 1-enable, 0-disable */
  1124. uint8_t fifo_WTM_int_en :1;
  1125. };
  1126. /*!
  1127. * @brief This structure holds the information for usage of
  1128. * FIFO by the user.
  1129. */
  1130. struct bmi160_fifo_frame {
  1131. /*! Data buffer of user defined length is to be mapped here */
  1132. uint8_t *data;
  1133. /*! While calling the API "bmi160_get_fifo_data" , length stores
  1134. * number of bytes in FIFO to be read (specified by user as input)
  1135. * and after execution of the API ,number of FIFO data bytes
  1136. * available is provided as an output to user
  1137. */
  1138. uint16_t length;
  1139. /*! FIFO time enable */
  1140. uint8_t fifo_time_enable;
  1141. /*! Enabling of the FIFO header to stream in header mode */
  1142. uint8_t fifo_header_enable;
  1143. /*! Streaming of the Accelerometer, Gyroscope
  1144. sensor data or both in FIFO */
  1145. uint8_t fifo_data_enable;
  1146. /*! Will be equal to length when no more frames are there to parse */
  1147. uint16_t accel_byte_start_idx;
  1148. /*! Will be equal to length when no more frames are there to parse */
  1149. uint16_t gyro_byte_start_idx;
  1150. /*! Will be equal to length when no more frames are there to parse */
  1151. uint16_t aux_byte_start_idx;
  1152. /*! Value of FIFO sensor time time */
  1153. uint32_t sensor_time;
  1154. /*! Value of Skipped frame counts */
  1155. uint8_t skipped_frame_count;
  1156. };
  1157. struct bmi160_dev {
  1158. /*! Chip Id */
  1159. uint8_t chip_id;
  1160. /*! Device Id */
  1161. uint8_t id;
  1162. /*! 0 - I2C , 1 - SPI Interface */
  1163. uint8_t interface;
  1164. /*! Hold active interrupts status for any and sig motion
  1165. * 0 - Any-motion enable, 1 - Sig-motion enable,
  1166. * -1 neither any-motion nor sig-motion selected */
  1167. enum bmi160_any_sig_motion_active_interrupt_state any_sig_sel;
  1168. /*! Structure to configure Accel sensor */
  1169. struct bmi160_cfg accel_cfg;
  1170. /*! Structure to hold previous/old accel config parameters.
  1171. * This is used at driver level to prevent overwriting of same
  1172. * data, hence user does not change it in the code */
  1173. struct bmi160_cfg prev_accel_cfg;
  1174. /*! Structure to configure Gyro sensor */
  1175. struct bmi160_cfg gyro_cfg;
  1176. /*! Structure to hold previous/old gyro config parameters.
  1177. * This is used at driver level to prevent overwriting of same
  1178. * data, hence user does not change it in the code */
  1179. struct bmi160_cfg prev_gyro_cfg;
  1180. /*! Structure to configure the auxiliary sensor */
  1181. struct bmi160_aux_cfg aux_cfg;
  1182. /*! Structure to hold previous/old aux config parameters.
  1183. * This is used at driver level to prevent overwriting of same
  1184. * data, hence user does not change it in the code */
  1185. struct bmi160_aux_cfg prev_aux_cfg;
  1186. /*! FIFO related configurations */
  1187. struct bmi160_fifo_frame *fifo;
  1188. /*! Read function pointer */
  1189. bmi160_com_fptr_t read;
  1190. /*! Write function pointer */
  1191. bmi160_com_fptr_t write;
  1192. /*! Delay function pointer */
  1193. bmi160_delay_fptr_t delay_ms;
  1194. };
  1195. /*************************** C++ guard macro *****************************/
  1196. #ifdef __cplusplus
  1197. }
  1198. #endif
  1199. #endif /* BMI160_DEFS_H_ */