bmi160_defs.h 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329
  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 23 Aug 2017
  44. * @version 3.6.1
  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_RES_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. /* Output Data Rate settings */
  391. /* Accel Output data rate */
  392. #define BMI160_ACCEL_ODR_RESERVED UINT8_C(0x00)
  393. #define BMI160_ACCEL_ODR_0_78HZ UINT8_C(0x01)
  394. #define BMI160_ACCEL_ODR_1_56HZ UINT8_C(0x02)
  395. #define BMI160_ACCEL_ODR_3_12HZ UINT8_C(0x03)
  396. #define BMI160_ACCEL_ODR_6_25HZ UINT8_C(0x04)
  397. #define BMI160_ACCEL_ODR_12_5HZ UINT8_C(0x05)
  398. #define BMI160_ACCEL_ODR_25HZ UINT8_C(0x06)
  399. #define BMI160_ACCEL_ODR_50HZ UINT8_C(0x07)
  400. #define BMI160_ACCEL_ODR_100HZ UINT8_C(0x08)
  401. #define BMI160_ACCEL_ODR_200HZ UINT8_C(0x09)
  402. #define BMI160_ACCEL_ODR_400HZ UINT8_C(0x0A)
  403. #define BMI160_ACCEL_ODR_800HZ UINT8_C(0x0B)
  404. #define BMI160_ACCEL_ODR_1600HZ UINT8_C(0x0C)
  405. #define BMI160_ACCEL_ODR_RESERVED0 UINT8_C(0x0D)
  406. #define BMI160_ACCEL_ODR_RESERVED1 UINT8_C(0x0E)
  407. #define BMI160_ACCEL_ODR_RESERVED2 UINT8_C(0x0F)
  408. /* Gyro Output data rate */
  409. #define BMI160_GYRO_ODR_RESERVED UINT8_C(0x00)
  410. #define BMI160_GYRO_ODR_25HZ UINT8_C(0x06)
  411. #define BMI160_GYRO_ODR_50HZ UINT8_C(0x07)
  412. #define BMI160_GYRO_ODR_100HZ UINT8_C(0x08)
  413. #define BMI160_GYRO_ODR_200HZ UINT8_C(0x09)
  414. #define BMI160_GYRO_ODR_400HZ UINT8_C(0x0A)
  415. #define BMI160_GYRO_ODR_800HZ UINT8_C(0x0B)
  416. #define BMI160_GYRO_ODR_1600HZ UINT8_C(0x0C)
  417. #define BMI160_GYRO_ODR_3200HZ UINT8_C(0x0D)
  418. /* Auxiliary sensor Output data rate */
  419. #define BMI160_AUX_ODR_RESERVED UINT8_C(0x00)
  420. #define BMI160_AUX_ODR_0_78HZ UINT8_C(0x01)
  421. #define BMI160_AUX_ODR_1_56HZ UINT8_C(0x02)
  422. #define BMI160_AUX_ODR_3_12HZ UINT8_C(0x03)
  423. #define BMI160_AUX_ODR_6_25HZ UINT8_C(0x04)
  424. #define BMI160_AUX_ODR_12_5HZ UINT8_C(0x05)
  425. #define BMI160_AUX_ODR_25HZ UINT8_C(0x06)
  426. #define BMI160_AUX_ODR_50HZ UINT8_C(0x07)
  427. #define BMI160_AUX_ODR_100HZ UINT8_C(0x08)
  428. #define BMI160_AUX_ODR_200HZ UINT8_C(0x09)
  429. #define BMI160_AUX_ODR_400HZ UINT8_C(0x0A)
  430. #define BMI160_AUX_ODR_800HZ UINT8_C(0x0B)
  431. /* Maximum limits definition */
  432. #define BMI160_ACCEL_ODR_MAX UINT8_C(15)
  433. #define BMI160_ACCEL_BW_MAX UINT8_C(2)
  434. #define BMI160_ACCEL_RANGE_MAX UINT8_C(12)
  435. #define BMI160_GYRO_ODR_MAX UINT8_C(13)
  436. #define BMI160_GYRO_BW_MAX UINT8_C(2)
  437. #define BMI160_GYRO_RANGE_MAX UINT8_C(4)
  438. /** FIFO_CONFIG Definitions */
  439. #define BMI160_FIFO_TIME_ENABLE UINT8_C(0x02)
  440. #define BMI160_FIFO_TAG_INT2_ENABLE UINT8_C(0x04)
  441. #define BMI160_FIFO_TAG_INT1_ENABLE UINT8_C(0x08)
  442. #define BMI160_FIFO_HEAD_ENABLE UINT8_C(0x10)
  443. #define BMI160_FIFO_M_ENABLE UINT8_C(0x20)
  444. #define BMI160_FIFO_A_ENABLE UINT8_C(0x40)
  445. #define BMI160_FIFO_M_A_ENABLE UINT8_C(0x60)
  446. #define BMI160_FIFO_G_ENABLE UINT8_C(0x80)
  447. #define BMI160_FIFO_M_G_ENABLE UINT8_C(0xA0)
  448. #define BMI160_FIFO_G_A_ENABLE UINT8_C(0xC0)
  449. #define BMI160_FIFO_M_G_A_ENABLE UINT8_C(0xE0)
  450. /* Accel, gyro and aux. sensor length and also their combined
  451. * length definitions in FIFO */
  452. #define BMI160_FIFO_G_LENGTH UINT8_C(6)
  453. #define BMI160_FIFO_A_LENGTH UINT8_C(6)
  454. #define BMI160_FIFO_M_LENGTH UINT8_C(8)
  455. #define BMI160_FIFO_GA_LENGTH UINT8_C(12)
  456. #define BMI160_FIFO_MA_LENGTH UINT8_C(14)
  457. #define BMI160_FIFO_MG_LENGTH UINT8_C(14)
  458. #define BMI160_FIFO_MGA_LENGTH UINT8_C(20)
  459. /** FIFO Header Data definitions */
  460. #define BMI160_FIFO_HEAD_SKIP_FRAME UINT8_C(0x40)
  461. #define BMI160_FIFO_HEAD_SENSOR_TIME UINT8_C(0x44)
  462. #define BMI160_FIFO_HEAD_INPUT_CONFIG UINT8_C(0x48)
  463. #define BMI160_FIFO_HEAD_OVER_READ UINT8_C(0x80)
  464. #define BMI160_FIFO_HEAD_A UINT8_C(0x84)
  465. #define BMI160_FIFO_HEAD_G UINT8_C(0x88)
  466. #define BMI160_FIFO_HEAD_G_A UINT8_C(0x8C)
  467. #define BMI160_FIFO_HEAD_M UINT8_C(0x90)
  468. #define BMI160_FIFO_HEAD_M_A UINT8_C(0x94)
  469. #define BMI160_FIFO_HEAD_M_G UINT8_C(0x98)
  470. #define BMI160_FIFO_HEAD_M_G_A UINT8_C(0x9C)
  471. /** FIFO sensor time length definitions */
  472. #define BMI160_SENSOR_TIME_LENGTH UINT8_C(3)
  473. /** FIFO DOWN selection */
  474. /* Accel fifo down-sampling values*/
  475. #define BMI160_ACCEL_FIFO_DOWN_ZERO UINT8_C(0x00)
  476. #define BMI160_ACCEL_FIFO_DOWN_ONE UINT8_C(0x10)
  477. #define BMI160_ACCEL_FIFO_DOWN_TWO UINT8_C(0x20)
  478. #define BMI160_ACCEL_FIFO_DOWN_THREE UINT8_C(0x30)
  479. #define BMI160_ACCEL_FIFO_DOWN_FOUR UINT8_C(0x40)
  480. #define BMI160_ACCEL_FIFO_DOWN_FIVE UINT8_C(0x50)
  481. #define BMI160_ACCEL_FIFO_DOWN_SIX UINT8_C(0x60)
  482. #define BMI160_ACCEL_FIFO_DOWN_SEVEN UINT8_C(0x70)
  483. /* Gyro fifo down-smapling values*/
  484. #define BMI160_GYRO_FIFO_DOWN_ZERO UINT8_C(0x00)
  485. #define BMI160_GYRO_FIFO_DOWN_ONE UINT8_C(0x01)
  486. #define BMI160_GYRO_FIFO_DOWN_TWO UINT8_C(0x02)
  487. #define BMI160_GYRO_FIFO_DOWN_THREE UINT8_C(0x03)
  488. #define BMI160_GYRO_FIFO_DOWN_FOUR UINT8_C(0x04)
  489. #define BMI160_GYRO_FIFO_DOWN_FIVE UINT8_C(0x05)
  490. #define BMI160_GYRO_FIFO_DOWN_SIX UINT8_C(0x06)
  491. #define BMI160_GYRO_FIFO_DOWN_SEVEN UINT8_C(0x07)
  492. /* Accel Fifo filter enable*/
  493. #define BMI160_ACCEL_FIFO_FILT_EN UINT8_C(0x80)
  494. /* Gyro Fifo filter enable*/
  495. #define BMI160_GYRO_FIFO_FILT_EN UINT8_C(0x08)
  496. /** Definitions to check validity of FIFO frames */
  497. #define FIFO_CONFIG_MSB_CHECK UINT8_C(0x80)
  498. #define FIFO_CONFIG_LSB_CHECK UINT8_C(0x00)
  499. /*! BMI160 accel FOC configurations */
  500. #define BMI160_FOC_ACCEL_DISABLED UINT8_C(0x00)
  501. #define BMI160_FOC_ACCEL_POSITIVE_G UINT8_C(0x01)
  502. #define BMI160_FOC_ACCEL_NEGATIVE_G UINT8_C(0x02)
  503. #define BMI160_FOC_ACCEL_0G UINT8_C(0x03)
  504. /** Array Parameter DefinItions */
  505. #define BMI160_SENSOR_TIME_LSB_BYTE UINT8_C(0)
  506. #define BMI160_SENSOR_TIME_XLSB_BYTE UINT8_C(1)
  507. #define BMI160_SENSOR_TIME_MSB_BYTE UINT8_C(2)
  508. /** Interface settings */
  509. #define BMI160_SPI_INTF UINT8_C(1)
  510. #define BMI160_I2C_INTF UINT8_C(0)
  511. #define BMI160_SPI_RD_MASK UINT8_C(0x80)
  512. #define BMI160_SPI_WR_MASK UINT8_C(0x7F)
  513. /* Sensor & time select definition*/
  514. #define BMI160_ACCEL_SEL UINT8_C(0x01)
  515. #define BMI160_GYRO_SEL UINT8_C(0x02)
  516. #define BMI160_TIME_SEL UINT8_C(0x04)
  517. /* Sensor select mask*/
  518. #define BMI160_SEN_SEL_MASK UINT8_C(0x07)
  519. /* Error code mask */
  520. #define BMI160_ERR_REG_MASK UINT8_C(0x0F)
  521. /* BMI160 I2C address */
  522. #define BMI160_I2C_ADDR UINT8_C(0x68)
  523. /* BMI160 secondary IF address */
  524. #define BMI160_AUX_BMM150_I2C_ADDR UINT8_C(0x10)
  525. /** BMI160 Length definitions */
  526. #define BMI160_ONE UINT8_C(1)
  527. #define BMI160_TWO UINT8_C(2)
  528. #define BMI160_THREE UINT8_C(3)
  529. #define BMI160_FOUR UINT8_C(4)
  530. #define BMI160_FIVE UINT8_C(5)
  531. /** BMI160 fifo level Margin */
  532. #define BMI160_FIFO_LEVEL_MARGIN UINT8_C(16)
  533. /** BMI160 fifo flush Command */
  534. #define BMI160_FIFO_FLUSH_VALUE UINT8_C(0xB0)
  535. /** BMI160 offset values for xyz axes of accel */
  536. #define BMI160_ACCEL_MIN_OFFSET INT8_C(-128)
  537. #define BMI160_ACCEL_MAX_OFFSET INT8_C(127)
  538. /** BMI160 offset values for xyz axes of gyro */
  539. #define BMI160_GYRO_MIN_OFFSET INT16_C(-512)
  540. #define BMI160_GYRO_MAX_OFFSET INT16_C(511)
  541. /** BMI160 fifo full interrupt position and mask */
  542. #define BMI160_FIFO_FULL_INT_POS UINT8_C(5)
  543. #define BMI160_FIFO_FULL_INT_MSK UINT8_C(0x20)
  544. #define BMI160_FIFO_WTM_INT_POS UINT8_C(6)
  545. #define BMI160_FIFO_WTM_INT_MSK UINT8_C(0x40)
  546. #define BMI160_FIFO_FULL_INT_PIN1_POS UINT8_C(5)
  547. #define BMI160_FIFO_FULL_INT_PIN1_MSK UINT8_C(0x20)
  548. #define BMI160_FIFO_FULL_INT_PIN2_POS UINT8_C(1)
  549. #define BMI160_FIFO_FULL_INT_PIN2_MSK UINT8_C(0x02)
  550. #define BMI160_FIFO_WTM_INT_PIN1_POS UINT8_C(6)
  551. #define BMI160_FIFO_WTM_INT_PIN1_MSK UINT8_C(0x40)
  552. #define BMI160_FIFO_WTM_INT_PIN2_POS UINT8_C(2)
  553. #define BMI160_FIFO_WTM_INT_PIN2_MSK UINT8_C(0x04)
  554. #define BMI160_MANUAL_MODE_EN_POS UINT8_C(7)
  555. #define BMI160_MANUAL_MODE_EN_MSK UINT8_C(0x80)
  556. #define BMI160_AUX_READ_BURST_POS UINT8_C(0)
  557. #define BMI160_AUX_READ_BURST_MSK UINT8_C(0x03)
  558. #define BMI160_GYRO_SELF_TEST_POS UINT8_C(4)
  559. #define BMI160_GYRO_SELF_TEST_MSK UINT8_C(0x10)
  560. #define BMI160_GYRO_SELF_TEST_STATUS_POS UINT8_C(1)
  561. #define BMI160_GYRO_SELF_TEST_STATUS_MSK UINT8_C(0x02)
  562. #define BMI160_GYRO_FOC_EN_POS UINT8_C(6)
  563. #define BMI160_GYRO_FOC_EN_MSK UINT8_C(0x40)
  564. #define BMI160_ACCEL_FOC_X_CONF_POS UINT8_C(4)
  565. #define BMI160_ACCEL_FOC_X_CONF_MSK UINT8_C(0x30)
  566. #define BMI160_ACCEL_FOC_Y_CONF_POS UINT8_C(2)
  567. #define BMI160_ACCEL_FOC_Y_CONF_MSK UINT8_C(0x0C)
  568. #define BMI160_ACCEL_FOC_Z_CONF_MSK UINT8_C(0x03)
  569. #define BMI160_FOC_STATUS_POS UINT8_C(3)
  570. #define BMI160_FOC_STATUS_MSK UINT8_C(0x08)
  571. #define BMI160_GYRO_OFFSET_X_MSK UINT8_C(0x03)
  572. #define BMI160_GYRO_OFFSET_Y_POS UINT8_C(2)
  573. #define BMI160_GYRO_OFFSET_Y_MSK UINT8_C(0x0C)
  574. #define BMI160_GYRO_OFFSET_Z_POS UINT8_C(4)
  575. #define BMI160_GYRO_OFFSET_Z_MSK UINT8_C(0x30)
  576. #define BMI160_GYRO_OFFSET_EN_POS UINT8_C(7)
  577. #define BMI160_GYRO_OFFSET_EN_MSK UINT8_C(0x80)
  578. #define BMI160_ACCEL_OFFSET_EN_POS UINT8_C(6)
  579. #define BMI160_ACCEL_OFFSET_EN_MSK UINT8_C(0x40)
  580. #define BMI160_GYRO_OFFSET_POS UINT16_C(8)
  581. #define BMI160_GYRO_OFFSET_MSK UINT16_C(0x0300)
  582. #define BMI160_NVM_UPDATE_POS UINT8_C(1)
  583. #define BMI160_NVM_UPDATE_MSK UINT8_C(0x02)
  584. #define BMI160_NVM_STATUS_POS UINT8_C(4)
  585. #define BMI160_NVM_STATUS_MSK UINT8_C(0x10)
  586. /* BIT SLICE GET AND SET FUNCTIONS */
  587. #define BMI160_GET_BITS(regvar, bitname)\
  588. ((regvar & bitname##_MSK) >> bitname##_POS)
  589. #define BMI160_SET_BITS(regvar, bitname, val)\
  590. ((regvar & ~bitname##_MSK) | \
  591. ((val<<bitname##_POS)&bitname##_MSK))
  592. #define BMI160_SET_BITS_POS_0(reg_data, bitname, data) \
  593. ((reg_data & ~(bitname##_MSK)) | \
  594. (data & bitname##_MSK))
  595. #define BMI160_GET_BITS_POS_0(reg_data, bitname) (reg_data & (bitname##_MSK))
  596. /**\name UTILITY MACROS */
  597. #define BMI160_SET_LOW_BYTE UINT16_C(0x00FF)
  598. #define BMI160_SET_HIGH_BYTE UINT16_C(0xFF00)
  599. #define BMI160_GET_LSB(var) (uint8_t)(var & BMI160_SET_LOW_BYTE)
  600. #define BMI160_GET_MSB(var) (uint8_t)((var & BMI160_SET_HIGH_BYTE) >> 8)
  601. /*****************************************************************************/
  602. /* type definitions */
  603. typedef int8_t (*bmi160_com_fptr_t)(uint8_t dev_addr, uint8_t reg_addr,
  604. uint8_t *data, uint16_t len);
  605. typedef void (*bmi160_delay_fptr_t)(uint32_t period);
  606. /*************************** Data structures *********************************/
  607. /*!
  608. * @brief bmi160 sensor data structure which comprises of accel data
  609. */
  610. struct bmi160_sensor_data {
  611. /*! X-axis sensor data */
  612. int16_t x;
  613. /*! Y-axis sensor data */
  614. int16_t y;
  615. /*! Z-axis sensor data */
  616. int16_t z;
  617. /*! sensor time */
  618. uint32_t sensortime;
  619. };
  620. /*!
  621. * @brief bmi160 FOC configuration structure
  622. */
  623. struct bmi160_foc_conf {
  624. /*! Enabling FOC in gyro
  625. * Assignable macros :
  626. * - BMI160_ENABLE
  627. * - BMI160_DISABLE
  628. */
  629. uint8_t foc_gyr_en;
  630. /*! Accel FOC configurations
  631. * Assignable macros :
  632. * - BMI160_FOC_ACCEL_DISABLED
  633. * - BMI160_FOC_ACCEL_POSITIVE_G
  634. * - BMI160_FOC_ACCEL_NEGATIVE_G
  635. * - BMI160_FOC_ACCEL_0G
  636. */
  637. uint8_t foc_acc_x;
  638. uint8_t foc_acc_y;
  639. uint8_t foc_acc_z;
  640. /*! Enabling offset compensation for accel in data registers
  641. * Assignable macros :
  642. * - BMI160_ENABLE
  643. * - BMI160_DISABLE
  644. */
  645. uint8_t acc_off_en;
  646. /*! Enabling offset compensation for gyro in data registers
  647. * Assignable macros :
  648. * - BMI160_ENABLE
  649. * - BMI160_DISABLE
  650. */
  651. uint8_t gyro_off_en;
  652. };
  653. /*!
  654. * @brief bmi160 accel gyro offsets
  655. */
  656. struct bmi160_offsets {
  657. /*! Accel offset for x axis */
  658. int8_t off_acc_x;
  659. /*! Accel offset for y axis */
  660. int8_t off_acc_y;
  661. /*! Accel offset for z axis */
  662. int8_t off_acc_z;
  663. /*! Gyro offset for x axis */
  664. int16_t off_gyro_x;
  665. /*! Gyro offset for y axis */
  666. int16_t off_gyro_y;
  667. /*! Gyro offset for z axis */
  668. int16_t off_gyro_z;
  669. };
  670. /*!
  671. * @brief FIFO aux. sensor data structure
  672. */
  673. struct bmi160_aux_fifo_data {
  674. /*! The value of aux. sensor x LSB data */
  675. uint8_t aux_x_lsb;
  676. /*! The value of aux. sensor x MSB data */
  677. uint8_t aux_x_msb;
  678. /*! The value of aux. sensor y LSB data */
  679. uint8_t aux_y_lsb;
  680. /*! The value of aux. sensor y MSB data */
  681. uint8_t aux_y_msb;
  682. /*! The value of aux. sensor z LSB data */
  683. uint8_t aux_z_lsb;
  684. /*! The value of aux. sensor z MSB data */
  685. uint8_t aux_z_msb;
  686. /*! The value of aux. sensor r for BMM150 LSB data */
  687. uint8_t aux_r_y2_lsb;
  688. /*! The value of aux. sensor r for BMM150 MSB data */
  689. uint8_t aux_r_y2_msb;
  690. };
  691. /*!
  692. * @brief bmi160 sensor select structure
  693. */
  694. enum bmi160_select_sensor {
  695. BMI160_ACCEL_ONLY = 1,
  696. BMI160_GYRO_ONLY,
  697. BMI160_BOTH_ACCEL_AND_GYRO
  698. };
  699. /*!
  700. * @brief bmi160 sensor step detector mode structure
  701. */
  702. enum bmi160_step_detect_mode {
  703. BMI160_STEP_DETECT_NORMAL,
  704. BMI160_STEP_DETECT_SENSITIVE,
  705. BMI160_STEP_DETECT_ROBUST,
  706. /*! Non recommended User defined setting */
  707. BMI160_STEP_DETECT_USER_DEFINE
  708. };
  709. /*!
  710. * @brief enum for auxiliary burst read selection
  711. */
  712. enum bm160_aux_read_len {
  713. BMI160_AUX_READ_LEN_0,
  714. BMI160_AUX_READ_LEN_1,
  715. BMI160_AUX_READ_LEN_2,
  716. BMI160_AUX_READ_LEN_3
  717. };
  718. /*!
  719. * @brief bmi160 sensor configuration structure
  720. */
  721. struct bmi160_cfg {
  722. /*! power mode */
  723. uint8_t power;
  724. /*! output data rate */
  725. uint8_t odr;
  726. /*! range */
  727. uint8_t range;
  728. /*! bandwidth */
  729. uint8_t bw;
  730. };
  731. /*!
  732. * @brief Aux sensor configuration structure
  733. */
  734. struct bmi160_aux_cfg {
  735. /*! Aux sensor, 1 - enable 0 - disable */
  736. uint8_t aux_sensor_enable : 1;
  737. /*! Aux manual/auto mode status */
  738. uint8_t manual_enable : 1;
  739. /*! Aux read burst length */
  740. uint8_t aux_rd_burst_len : 2;
  741. /*! output data rate */
  742. uint8_t aux_odr :4;
  743. /*! i2c addr of auxiliary sensor */
  744. uint8_t aux_i2c_addr;
  745. };
  746. /*!
  747. * @brief bmi160 interrupt channel selection structure
  748. */
  749. enum bmi160_int_channel {
  750. /*! interrupt Channel 1 */
  751. BMI160_INT_CHANNEL_1,
  752. /*! interrupt Channel 2 */
  753. BMI160_INT_CHANNEL_2
  754. };
  755. enum bmi160_int_types {
  756. /*! Slope/Any-motion interrupt */
  757. BMI160_ACC_ANY_MOTION_INT,
  758. /*! Significant motion interrupt */
  759. BMI160_ACC_SIG_MOTION_INT,
  760. /*! Step detector interrupt */
  761. BMI160_STEP_DETECT_INT,
  762. /*! double tap interrupt */
  763. BMI160_ACC_DOUBLE_TAP_INT,
  764. /*! single tap interrupt */
  765. BMI160_ACC_SINGLE_TAP_INT,
  766. /*! orientation interrupt */
  767. BMI160_ACC_ORIENT_INT,
  768. /*! flat interrupt */
  769. BMI160_ACC_FLAT_INT,
  770. /*! high-g interrupt */
  771. BMI160_ACC_HIGH_G_INT,
  772. /*! low-g interrupt */
  773. BMI160_ACC_LOW_G_INT,
  774. /*! slow/no-motion interrupt */
  775. BMI160_ACC_SLOW_NO_MOTION_INT,
  776. /*! data ready interrupt */
  777. BMI160_ACC_GYRO_DATA_RDY_INT,
  778. /*! fifo full interrupt */
  779. BMI160_ACC_GYRO_FIFO_FULL_INT,
  780. /*! fifo watermark interrupt */
  781. BMI160_ACC_GYRO_FIFO_WATERMARK_INT
  782. };
  783. /*!
  784. * @brief bmi160 active state of any & sig motion interrupt.
  785. */
  786. enum bmi160_any_sig_motion_active_interrupt_state {
  787. /*! Both any & sig motion are disabled */
  788. BMI160_BOTH_ANY_SIG_MOTION_DISABLED = -1,
  789. /*! Any-motion selected */
  790. BMI160_ANY_MOTION_ENABLED,
  791. /*! Sig-motion selected */
  792. BMI160_SIG_MOTION_ENABLED
  793. };
  794. struct bmi160_acc_tap_int_cfg {
  795. #if LITTLE_ENDIAN == 1
  796. /*! tap threshold */
  797. uint16_t tap_thr :5;
  798. /*! tap shock */
  799. uint16_t tap_shock :1;
  800. /*! tap quiet */
  801. uint16_t tap_quiet :1;
  802. /*! tap duration */
  803. uint16_t tap_dur :3;
  804. /*! data source 0- filter & 1 pre-filter*/
  805. uint16_t tap_data_src :1;
  806. /*! tap enable, 1 - enable, 0 - disable */
  807. uint16_t tap_en :1;
  808. #elif BIG_ENDIAN == 1
  809. /*! tap enable, 1 - enable, 0 - disable */
  810. uint16_t tap_en :1;
  811. /*! data source 0- filter & 1 pre-filter*/
  812. uint16_t tap_data_src :1;
  813. /*! tap duration */
  814. uint16_t tap_dur : 3;
  815. /*! tap quiet */
  816. uint16_t tap_quiet : 1;
  817. /*! tap shock */
  818. uint16_t tap_shock : 1;
  819. /*! tap threshold */
  820. uint16_t tap_thr : 5;
  821. #endif
  822. };
  823. struct bmi160_acc_any_mot_int_cfg {
  824. #if LITTLE_ENDIAN == 1
  825. /*! 1 any-motion enable, 0 - any-motion disable */
  826. uint8_t anymotion_en :1;
  827. /*! slope interrupt x, 1 - enable, 0 - disable */
  828. uint8_t anymotion_x :1;
  829. /*! slope interrupt y, 1 - enable, 0 - disable */
  830. uint8_t anymotion_y :1;
  831. /*! slope interrupt z, 1 - enable, 0 - disable */
  832. uint8_t anymotion_z :1;
  833. /*! slope duration */
  834. uint8_t anymotion_dur :2;
  835. /*! data source 0- filter & 1 pre-filter*/
  836. uint8_t anymotion_data_src :1;
  837. /*! slope threshold */
  838. uint8_t anymotion_thr;
  839. #elif BIG_ENDIAN == 1
  840. /*! slope threshold */
  841. uint8_t anymotion_thr;
  842. /*! data source 0- filter & 1 pre-filter*/
  843. uint8_t anymotion_data_src :1;
  844. /*! slope duration */
  845. uint8_t anymotion_dur : 2;
  846. /*! slope interrupt z, 1 - enable, 0 - disable */
  847. uint8_t anymotion_z : 1;
  848. /*! slope interrupt y, 1 - enable, 0 - disable */
  849. uint8_t anymotion_y : 1;
  850. /*! slope interrupt x, 1 - enable, 0 - disable */
  851. uint8_t anymotion_x : 1;
  852. /*! 1 any-motion enable, 0 - any-motion disable */
  853. uint8_t anymotion_en :1;
  854. #endif
  855. };
  856. struct bmi160_acc_sig_mot_int_cfg {
  857. #if LITTLE_ENDIAN == 1
  858. /*! skip time of sig-motion interrupt */
  859. uint8_t sig_mot_skip :2;
  860. /*! proof time of sig-motion interrupt */
  861. uint8_t sig_mot_proof :2;
  862. /*! data source 0- filter & 1 pre-filter*/
  863. uint8_t sig_data_src :1;
  864. /*! 1 - enable sig, 0 - disable sig & enable anymotion */
  865. uint8_t sig_en :1;
  866. /*! sig-motion threshold */
  867. uint8_t sig_mot_thres;
  868. #elif BIG_ENDIAN == 1
  869. /*! sig-motion threshold */
  870. uint8_t sig_mot_thres;
  871. /*! 1 - enable sig, 0 - disable sig & enable anymotion */
  872. uint8_t sig_en :1;
  873. /*! data source 0- filter & 1 pre-filter*/
  874. uint8_t sig_data_src :1;
  875. /*! proof time of sig-motion interrupt */
  876. uint8_t sig_mot_proof : 2;
  877. /*! skip time of sig-motion interrupt */
  878. uint8_t sig_mot_skip : 2;
  879. #endif
  880. };
  881. struct bmi160_acc_step_detect_int_cfg {
  882. #if LITTLE_ENDIAN == 1
  883. /*! 1- step detector enable, 0- step detector disable */
  884. uint16_t step_detector_en :1;
  885. /*! minimum threshold */
  886. uint16_t min_threshold :2;
  887. /*! minimal detectable step time */
  888. uint16_t steptime_min :3;
  889. /*! enable step counter mode setting */
  890. uint16_t step_detector_mode :2;
  891. /*! minimum step buffer size*/
  892. uint16_t step_min_buf :3;
  893. #elif BIG_ENDIAN == 1
  894. /*! minimum step buffer size*/
  895. uint16_t step_min_buf :3;
  896. /*! enable step counter mode setting */
  897. uint16_t step_detector_mode : 2;
  898. /*! minimal detectable step time */
  899. uint16_t steptime_min : 3;
  900. /*! minimum threshold */
  901. uint16_t min_threshold : 2;
  902. /*! 1- step detector enable, 0- step detector disable */
  903. uint16_t step_detector_en :1;
  904. #endif
  905. };
  906. struct bmi160_acc_no_motion_int_cfg {
  907. #if LITTLE_ENDIAN == 1
  908. /*! no motion interrupt x */
  909. uint16_t no_motion_x :1;
  910. /*! no motion interrupt y */
  911. uint16_t no_motion_y :1;
  912. /*! no motion interrupt z */
  913. uint16_t no_motion_z :1;
  914. /*! no motion duration */
  915. uint16_t no_motion_dur :6;
  916. /*! no motion sel , 1 - enable no-motion ,0- enable slow-motion */
  917. uint16_t no_motion_sel :1;
  918. /*! data source 0- filter & 1 pre-filter*/
  919. uint16_t no_motion_src :1;
  920. /*! no motion threshold */
  921. uint8_t no_motion_thres;
  922. #elif BIG_ENDIAN == 1
  923. /*! no motion threshold */
  924. uint8_t no_motion_thres;
  925. /*! data source 0- filter & 1 pre-filter*/
  926. uint16_t no_motion_src :1;
  927. /*! no motion sel , 1 - enable no-motion ,0- enable slow-motion */
  928. uint16_t no_motion_sel : 1;
  929. /*! no motion duration */
  930. uint16_t no_motion_dur : 6;
  931. /* no motion interrupt z */
  932. uint16_t no_motion_z :1;
  933. /*! no motion interrupt y */
  934. uint16_t no_motion_y :1;
  935. /*! no motion interrupt x */
  936. uint16_t no_motion_x :1;
  937. #endif
  938. };
  939. struct bmi160_acc_orient_int_cfg {
  940. #if LITTLE_ENDIAN == 1
  941. /*! thresholds for switching between the different orientations */
  942. uint16_t orient_mode :2;
  943. /*! blocking_mode */
  944. uint16_t orient_blocking :2;
  945. /*! Orientation interrupt hysteresis */
  946. uint16_t orient_hyst :4;
  947. /*! Orientation interrupt theta */
  948. uint16_t orient_theta :6;
  949. /*! Enable/disable Orientation interrupt */
  950. uint16_t orient_ud_en :1;
  951. /*! exchange x- and z-axis in algorithm ,0 - z, 1 - x */
  952. uint16_t axes_ex :1;
  953. /*! 1 - orient enable, 0 - orient disable */
  954. uint8_t orient_en :1;
  955. #elif BIG_ENDIAN == 1
  956. /*! 1 - orient enable, 0 - orient disable */
  957. uint8_t orient_en :1;
  958. /*! exchange x- and z-axis in algorithm ,0 - z, 1 - x */
  959. uint16_t axes_ex : 1;
  960. /*! Enable/disable Orientation interrupt */
  961. uint16_t orient_ud_en : 1;
  962. /*! Orientation interrupt theta */
  963. uint16_t orient_theta : 6;
  964. /*! Orientation interrupt hysteresis */
  965. uint16_t orient_hyst : 4;
  966. /*! blocking_mode */
  967. uint16_t orient_blocking : 2;
  968. /*! thresholds for switching between the different orientations */
  969. uint16_t orient_mode : 2;
  970. #endif
  971. };
  972. struct bmi160_acc_flat_detect_int_cfg {
  973. #if LITTLE_ENDIAN == 1
  974. /*! flat threshold */
  975. uint16_t flat_theta :6;
  976. /*! flat interrupt hysteresis */
  977. uint16_t flat_hy :3;
  978. /*! delay time for which the flat value must remain stable for the
  979. * flat interrupt to be generated */
  980. uint16_t flat_hold_time :2;
  981. /*! 1 - flat enable, 0 - flat disable */
  982. uint16_t flat_en :1;
  983. #elif BIG_ENDIAN == 1
  984. /*! 1 - flat enable, 0 - flat disable */
  985. uint16_t flat_en :1;
  986. /*! delay time for which the flat value must remain stable for the
  987. * flat interrupt to be generated */
  988. uint16_t flat_hold_time : 2;
  989. /*! flat interrupt hysteresis */
  990. uint16_t flat_hy : 3;
  991. /*! flat threshold */
  992. uint16_t flat_theta : 6;
  993. #endif
  994. };
  995. struct bmi160_acc_low_g_int_cfg {
  996. #if LITTLE_ENDIAN == 1
  997. /*! low-g interrupt trigger delay */
  998. uint8_t low_dur;
  999. /*! low-g interrupt trigger threshold */
  1000. uint8_t low_thres;
  1001. /*! hysteresis of low-g interrupt */
  1002. uint8_t low_hyst :2;
  1003. /*! 0 - single-axis mode ,1 - axis-summing mode */
  1004. uint8_t low_mode :1;
  1005. /*! data source 0- filter & 1 pre-filter */
  1006. uint8_t low_data_src :1;
  1007. /*! 1 - enable low-g, 0 - disable low-g */
  1008. uint8_t low_en :1;
  1009. #elif BIG_ENDIAN == 1
  1010. /*! 1 - enable low-g, 0 - disable low-g */
  1011. uint8_t low_en :1;
  1012. /*! data source 0- filter & 1 pre-filter */
  1013. uint8_t low_data_src :1;
  1014. /*! 0 - single-axis mode ,1 - axis-summing mode */
  1015. uint8_t low_mode : 1;
  1016. /*! hysteresis of low-g interrupt */
  1017. uint8_t low_hyst : 2;
  1018. /*! low-g interrupt trigger threshold */
  1019. uint8_t low_thres;
  1020. /*! low-g interrupt trigger delay */
  1021. uint8_t low_dur;
  1022. #endif
  1023. };
  1024. struct bmi160_acc_high_g_int_cfg {
  1025. #if LITTLE_ENDIAN == 1
  1026. /*! High-g interrupt x, 1 - enable, 0 - disable */
  1027. uint8_t high_g_x :1;
  1028. /*! High-g interrupt y, 1 - enable, 0 - disable */
  1029. uint8_t high_g_y :1;
  1030. /*! High-g interrupt z, 1 - enable, 0 - disable */
  1031. uint8_t high_g_z :1;
  1032. /*! High-g hysteresis */
  1033. uint8_t high_hy :2;
  1034. /*! data source 0- filter & 1 pre-filter */
  1035. uint8_t high_data_src :1;
  1036. /*! High-g threshold */
  1037. uint8_t high_thres;
  1038. /*! High-g duration */
  1039. uint8_t high_dur;
  1040. #elif BIG_ENDIAN == 1
  1041. /*! High-g duration */
  1042. uint8_t high_dur;
  1043. /*! High-g threshold */
  1044. uint8_t high_thres;
  1045. /*! data source 0- filter & 1 pre-filter */
  1046. uint8_t high_data_src :1;
  1047. /*! High-g hysteresis */
  1048. uint8_t high_hy : 2;
  1049. /*! High-g interrupt z, 1 - enable, 0 - disable */
  1050. uint8_t high_g_z : 1;
  1051. /*! High-g interrupt y, 1 - enable, 0 - disable */
  1052. uint8_t high_g_y : 1;
  1053. /*! High-g interrupt x, 1 - enable, 0 - disable */
  1054. uint8_t high_g_x : 1;
  1055. #endif
  1056. };
  1057. struct bmi160_int_pin_settg {
  1058. #if LITTLE_ENDIAN == 1
  1059. /*! To enable either INT1 or INT2 pin as output.
  1060. * 0- output disabled ,1- output enabled */
  1061. uint16_t output_en :1;
  1062. /*! 0 - push-pull 1- open drain,only valid if output_en is set 1 */
  1063. uint16_t output_mode :1;
  1064. /*! 0 - active low , 1 - active high level.
  1065. * if output_en is 1,this applies to interrupts,else PMU_trigger */
  1066. uint16_t output_type :1;
  1067. /*! 0 - level trigger , 1 - edge trigger */
  1068. uint16_t edge_ctrl :1;
  1069. /*! To enable either INT1 or INT2 pin as input.
  1070. * 0 - input disabled ,1 - input enabled */
  1071. uint16_t input_en :1;
  1072. /*! latch duration*/
  1073. uint16_t latch_dur :4;
  1074. #elif BIG_ENDIAN == 1
  1075. /*! latch duration*/
  1076. uint16_t latch_dur : 4;
  1077. /*! Latched,non-latched or temporary interrupt modes */
  1078. uint16_t input_en : 1;
  1079. /*! 1 - edge trigger, 0 - level trigger */
  1080. uint16_t edge_ctrl : 1;
  1081. /*! 0 - active low , 1 - active high level.
  1082. * if output_en is 1,this applies to interrupts,else PMU_trigger */
  1083. uint16_t output_type : 1;
  1084. /*! 0 - push-pull , 1 - open drain,only valid if output_en is set 1 */
  1085. uint16_t output_mode : 1;
  1086. /*! To enable either INT1 or INT2 pin as output.
  1087. * 0 - output disabled , 1 - output enabled */
  1088. uint16_t output_en : 1;
  1089. #endif
  1090. };
  1091. union bmi160_int_type_cfg {
  1092. /*! Tap interrupt structure */
  1093. struct bmi160_acc_tap_int_cfg acc_tap_int;
  1094. /*! Slope interrupt structure */
  1095. struct bmi160_acc_any_mot_int_cfg acc_any_motion_int;
  1096. /*! Significant motion interrupt structure */
  1097. struct bmi160_acc_sig_mot_int_cfg acc_sig_motion_int;
  1098. /*! Step detector interrupt structure */
  1099. struct bmi160_acc_step_detect_int_cfg acc_step_detect_int;
  1100. /*! No motion interrupt structure */
  1101. struct bmi160_acc_no_motion_int_cfg acc_no_motion_int;
  1102. /*! Orientation interrupt structure */
  1103. struct bmi160_acc_orient_int_cfg acc_orient_int;
  1104. /*! Flat interrupt structure */
  1105. struct bmi160_acc_flat_detect_int_cfg acc_flat_int;
  1106. /*! Low-g interrupt structure */
  1107. struct bmi160_acc_low_g_int_cfg acc_low_g_int;
  1108. /*! High-g interrupt structure */
  1109. struct bmi160_acc_high_g_int_cfg acc_high_g_int;
  1110. };
  1111. struct bmi160_int_settg {
  1112. /*! Interrupt channel */
  1113. enum bmi160_int_channel int_channel;
  1114. /*! Select Interrupt */
  1115. enum bmi160_int_types int_type;
  1116. /*! Structure configuring Interrupt pins */
  1117. struct bmi160_int_pin_settg int_pin_settg;
  1118. /*! Union configures required interrupt */
  1119. union bmi160_int_type_cfg int_type_cfg;
  1120. /*! FIFO FULL INT 1-enable, 0-disable */
  1121. uint8_t fifo_full_int_en :1;
  1122. /*! FIFO WTM INT 1-enable, 0-disable */
  1123. uint8_t fifo_WTM_int_en :1;
  1124. };
  1125. /*!
  1126. * @brief This structure holds the information for usage of
  1127. * FIFO by the user.
  1128. */
  1129. struct bmi160_fifo_frame {
  1130. /*! Data buffer of user defined length is to be mapped here */
  1131. uint8_t *data;
  1132. /*! While calling the API "bmi160_get_fifo_data" , length stores
  1133. * number of bytes in FIFO to be read (specified by user as input)
  1134. * and after execution of the API ,number of FIFO data bytes
  1135. * available is provided as an output to user
  1136. */
  1137. uint16_t length;
  1138. /*! FIFO time enable */
  1139. uint8_t fifo_time_enable;
  1140. /*! Enabling of the FIFO header to stream in header mode */
  1141. uint8_t fifo_header_enable;
  1142. /*! Streaming of the Accelerometer, Gyroscope
  1143. sensor data or both in FIFO */
  1144. uint8_t fifo_data_enable;
  1145. /*! Will be equal to length when no more frames are there to parse */
  1146. uint16_t accel_byte_start_idx;
  1147. /*! Will be equal to length when no more frames are there to parse */
  1148. uint16_t gyro_byte_start_idx;
  1149. /*! Will be equal to length when no more frames are there to parse */
  1150. uint16_t aux_byte_start_idx;
  1151. /*! Value of FIFO sensor time time */
  1152. uint32_t sensor_time;
  1153. /*! Value of Skipped frame counts */
  1154. uint8_t skipped_frame_count;
  1155. };
  1156. struct bmi160_dev {
  1157. /*! Chip Id */
  1158. uint8_t chip_id;
  1159. /*! Device Id */
  1160. uint8_t id;
  1161. /*! 0 - I2C , 1 - SPI Interface */
  1162. uint8_t interface;
  1163. /*! Hold active interrupts status for any and sig motion
  1164. * 0 - Any-motion enable, 1 - Sig-motion enable,
  1165. * -1 neither any-motion nor sig-motion selected */
  1166. enum bmi160_any_sig_motion_active_interrupt_state any_sig_sel;
  1167. /*! Structure to configure Accel sensor */
  1168. struct bmi160_cfg accel_cfg;
  1169. /*! Structure to hold previous/old accel config parameters.
  1170. * This is used at driver level to prevent overwriting of same
  1171. * data, hence user does not change it in the code */
  1172. struct bmi160_cfg prev_accel_cfg;
  1173. /*! Structure to configure Gyro sensor */
  1174. struct bmi160_cfg gyro_cfg;
  1175. /*! Structure to hold previous/old gyro config parameters.
  1176. * This is used at driver level to prevent overwriting of same
  1177. * data, hence user does not change it in the code */
  1178. struct bmi160_cfg prev_gyro_cfg;
  1179. /*! Structure to configure the auxiliary sensor */
  1180. struct bmi160_aux_cfg aux_cfg;
  1181. /*! Structure to hold previous/old aux config parameters.
  1182. * This is used at driver level to prevent overwriting of same
  1183. * data, hence user does not change it in the code */
  1184. struct bmi160_aux_cfg prev_aux_cfg;
  1185. /*! FIFO related configurations */
  1186. struct bmi160_fifo_frame *fifo;
  1187. /*! Read function pointer */
  1188. bmi160_com_fptr_t read;
  1189. /*! Write function pointer */
  1190. bmi160_com_fptr_t write;
  1191. /*! Delay function pointer */
  1192. bmi160_delay_fptr_t delay_ms;
  1193. };
  1194. /*************************** C++ guard macro *****************************/
  1195. #ifdef __cplusplus
  1196. }
  1197. #endif
  1198. #endif /* BMI160_DEFS_H_ */