bmm150_defs.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  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 bmm150_defs.h
  43. * @date 12 Sep 2017
  44. * @version 1.0.0
  45. *
  46. */
  47. /*! \file bmm150_defs.h */
  48. /*!
  49. * @defgroup BMM150 SENSOR API
  50. * @brief
  51. * @{*/
  52. #ifndef BMM150_DEFS_H_
  53. #define BMM150_DEFS_H_
  54. /*********************************************************************/
  55. /**\ header files */
  56. #ifdef __KERNEL__
  57. #include <linux/types.h>
  58. #else
  59. #include <stdint.h>
  60. #include <stddef.h>
  61. #endif
  62. /*********************************************************************/
  63. /* macro definitions */
  64. #ifdef __KERNEL__
  65. #if (LONG_MAX) > 0x7fffffff
  66. #define __have_long64 1
  67. #elif (LONG_MAX) == 0x7fffffff
  68. #define __have_long32 1
  69. #endif
  70. #endif
  71. #if !defined(UINT8_C)
  72. #define INT8_C(x) x
  73. #if (INT_MAX) > 0x7f
  74. #define UINT8_C(x) x
  75. #else
  76. #define UINT8_C(x) x##U
  77. #endif
  78. #endif
  79. #if !defined(UINT16_C)
  80. #define INT16_C(x) x
  81. #if (INT_MAX) > 0x7fff
  82. #define UINT16_C(x) x
  83. #else
  84. #define UINT16_C(x) x##U
  85. #endif
  86. #endif
  87. #if !defined(INT32_C) && !defined(UINT32_C)
  88. #if __have_long32
  89. #define INT32_C(x) x##L
  90. #define UINT32_C(x) x##UL
  91. #else
  92. #define INT32_C(x) x
  93. #define UINT32_C(x) x##U
  94. #endif
  95. #endif
  96. #if !defined(INT64_C) && !defined(UINT64_C)
  97. #if __have_long64
  98. #define INT64_C(x) x##L
  99. #define UINT64_C(x) x##UL
  100. #else
  101. #define INT64_C(x) x##LL
  102. #define UINT64_C(x) x##ULL
  103. #endif
  104. #endif
  105. /**\name C standard macros */
  106. #ifndef NULL
  107. #ifdef __cplusplus
  108. #define NULL 0
  109. #else
  110. #define NULL ((void *) 0)
  111. #endif
  112. #endif
  113. #define TRUE UINT8_C(1)
  114. #define FALSE UINT8_C(0)
  115. /********************************************************/
  116. /**\name Compiler switch macros */
  117. /**\name Comment the below line to use fixed-point compensation and
  118. un-comment it to obtain the output data in float */
  119. #define BMM150_USE_FLOATING_POINT
  120. /********************************************************/
  121. /**\name Macro definitions */
  122. /**\name API success code */
  123. #define BMM150_OK INT8_C(0)
  124. /**\name API error codes */
  125. #define BMM150_E_NULL_PTR INT8_C(-1)
  126. #define BMM150_E_DEV_NOT_FOUND INT8_C(-2)
  127. #define BMM150_E_INVALID_CONFIG INT8_C(-3)
  128. /**\name API warning codes */
  129. #define BMM150_W_NORMAL_SELF_TEST_YZ_FAIL INT8_C(1)
  130. #define BMM150_W_NORMAL_SELF_TEST_XZ_FAIL INT8_C(2)
  131. #define BMM150_W_NORMAL_SELF_TEST_Z_FAIL INT8_C(3)
  132. #define BMM150_W_NORMAL_SELF_TEST_XY_FAIL INT8_C(4)
  133. #define BMM150_W_NORMAL_SELF_TEST_Y_FAIL INT8_C(5)
  134. #define BMM150_W_NORMAL_SELF_TEST_X_FAIL INT8_C(6)
  135. #define BMM150_W_NORMAL_SELF_TEST_XYZ_FAIL INT8_C(7)
  136. #define BMM150_W_ADV_SELF_TEST_FAIL INT8_C(8)
  137. /**\name CHIP ID & SOFT RESET VALUES */
  138. #define BMM150_CHIP_ID UINT8_C(0x32)
  139. #define BMM150_SET_SOFT_RESET UINT8_C(0x82)
  140. /**\name POWER MODE DEFINTIONS */
  141. #define BMM150_NORMAL_MODE UINT8_C(0x00)
  142. #define BMM150_FORCED_MODE UINT8_C(0x01)
  143. #define BMM150_SLEEP_MODE UINT8_C(0x03)
  144. #define BMM150_SUSPEND_MODE UINT8_C(0x04)
  145. /**\name I2C ADDRESS */
  146. #define BMM150_DEFAULT_I2C_ADDRESS UINT8_C(0x10)
  147. #define BMM150_I2C_ADDRESS_CSB_LOW_SDO_HIGH UINT8_C(0x11)
  148. #define BMM150_I2C_ADDRESS_CSB_HIGH_SDO_LOW UINT8_C(0x12)
  149. #define BMM150_I2C_ADDRESS_CSB_HIGH_SDO_HIGH UINT8_C(0x13)
  150. /**\name Power mode settings */
  151. #define BMM150_POWER_CNTRL_DISABLE UINT8_C(0x00)
  152. #define BMM150_POWER_CNTRL_ENABLE UINT8_C(0x01)
  153. /**\name Sensor delay time settings */
  154. #define BMM150_SOFT_RESET_DELAY UINT8_C(1)
  155. #define BMM150_NORMAL_SELF_TEST_DELAY UINT8_C(2)
  156. #define BMM150_START_UP_TIME UINT8_C(3)
  157. #define BMM150_ADV_SELF_TEST_DELAY UINT8_C(4)
  158. /**\name ENABLE/DISABLE DEFINITIONS */
  159. #define BMM150_XY_CHANNEL_ENABLE UINT8_C(0x00)
  160. #define BMM150_XY_CHANNEL_DISABLE UINT8_C(0x03)
  161. /**\name Register Address */
  162. #define BMM150_CHIP_ID_ADDR UINT8_C(0x40)
  163. #define BMM150_DATA_X_LSB UINT8_C(0x42)
  164. #define BMM150_DATA_READY_STATUS UINT8_C(0x48)
  165. #define BMM150_INTERRUPT_STATUS UINT8_C(0x4A)
  166. #define BMM150_POWER_CONTROL_ADDR UINT8_C(0x4B)
  167. #define BMM150_OP_MODE_ADDR UINT8_C(0x4C)
  168. #define BMM150_INT_CONFIG_ADDR UINT8_C(0x4D)
  169. #define BMM150_AXES_ENABLE_ADDR UINT8_C(0x4E)
  170. #define BMM150_LOW_THRESHOLD_ADDR UINT8_C(0x4F)
  171. #define BMM150_HIGH_THRESHOLD_ADDR UINT8_C(0x50)
  172. #define BMM150_REP_XY_ADDR UINT8_C(0x51)
  173. #define BMM150_REP_Z_ADDR UINT8_C(0x52)
  174. /**\name Macros to select the sensor settings to be set by the user
  175. These values are internal for API implementation. Don't relate this to
  176. data sheet. */
  177. #define BMM150_DATA_RATE_SEL UINT16_C(1)
  178. #define BMM150_CONTROL_MEASURE_SEL UINT16_C(1 << 1)
  179. #define BMM150_XY_REP_SEL UINT16_C(1 << 2)
  180. #define BMM150_Z_REP_SEL UINT16_C(1 << 3)
  181. #define BMM150_DRDY_PIN_EN_SEL UINT16_C(1 << 4)
  182. #define BMM150_INT_PIN_EN_SEL UINT16_C(1 << 5)
  183. #define BMM150_DRDY_POLARITY_SEL UINT16_C(1 << 6)
  184. #define BMM150_INT_LATCH_SEL UINT16_C(1 << 7)
  185. #define BMM150_INT_POLARITY_SEL UINT16_C(1 << 8)
  186. #define BMM150_DATA_OVERRUN_INT_SEL UINT16_C(1 << 9)
  187. #define BMM150_OVERFLOW_INT_SEL UINT16_C(1 << 10)
  188. #define BMM150_HIGH_THRESHOLD_INT_SEL UINT16_C(1 << 11)
  189. #define BMM150_LOW_THRESHOLD_INT_SEL UINT16_C(1 << 12)
  190. #define BMM150_LOW_THRESHOLD_SETTING_SEL UINT16_C(1 << 13)
  191. #define BMM150_HIGH_THRESHOLD_SETTING_SEL UINT16_C(1 << 14)
  192. /**\name DATA RATE DEFINITIONS */
  193. #define BMM150_DATA_RATE_10HZ UINT8_C(0x00)
  194. #define BMM150_DATA_RATE_02HZ UINT8_C(0x01)
  195. #define BMM150_DATA_RATE_06HZ UINT8_C(0x02)
  196. #define BMM150_DATA_RATE_08HZ UINT8_C(0x03)
  197. #define BMM150_DATA_RATE_15HZ UINT8_C(0x04)
  198. #define BMM150_DATA_RATE_20HZ UINT8_C(0x05)
  199. #define BMM150_DATA_RATE_25HZ UINT8_C(0x06)
  200. #define BMM150_DATA_RATE_30HZ UINT8_C(0x07)
  201. /**\name TRIM REGISTERS */
  202. /* Trim Extended Registers */
  203. #define BMM150_DIG_X1 UINT8_C(0x5D)
  204. #define BMM150_DIG_Y1 UINT8_C(0x5E)
  205. #define BMM150_DIG_Z4_LSB UINT8_C(0x62)
  206. #define BMM150_DIG_Z4_MSB UINT8_C(0x63)
  207. #define BMM150_DIG_X2 UINT8_C(0x64)
  208. #define BMM150_DIG_Y2 UINT8_C(0x65)
  209. #define BMM150_DIG_Z2_LSB UINT8_C(0x68)
  210. #define BMM150_DIG_Z2_MSB UINT8_C(0x69)
  211. #define BMM150_DIG_Z1_LSB UINT8_C(0x6A)
  212. #define BMM150_DIG_Z1_MSB UINT8_C(0x6B)
  213. #define BMM150_DIG_XYZ1_LSB UINT8_C(0x6C)
  214. #define BMM150_DIG_XYZ1_MSB UINT8_C(0x6D)
  215. #define BMM150_DIG_Z3_LSB UINT8_C(0x6E)
  216. #define BMM150_DIG_Z3_MSB UINT8_C(0x6F)
  217. #define BMM150_DIG_XY2 UINT8_C(0x70)
  218. #define BMM150_DIG_XY1 UINT8_C(0x71)
  219. /**\name Threshold interrupt setting macros for x,y,z axes selection */
  220. #define BMM150_THRESHOLD_X UINT8_C(0x06)
  221. #define BMM150_THRESHOLD_Y UINT8_C(0x05)
  222. #define BMM150_THRESHOLD_Z UINT8_C(0x03)
  223. /**\name User configurable interrupt setting macros */
  224. #define BMM150_INT_ENABLE UINT8_C(0x01)
  225. #define BMM150_INT_DISABLE UINT8_C(0x00)
  226. #define BMM150_ACTIVE_HIGH_POLARITY UINT8_C(0x01)
  227. #define BMM150_ACTIVE_LOW_POLARITY UINT8_C(0x00)
  228. #define BMM150_LATCHED UINT8_C(0x01)
  229. #define BMM150_NON_LATCHED UINT8_C(0x00)
  230. /**\name Interrupt status */
  231. #define BMM150_LOW_THRESHOLD_INT_X UINT16_C(0x0001)
  232. #define BMM150_LOW_THRESHOLD_INT_Y UINT16_C(0x0002)
  233. #define BMM150_LOW_THRESHOLD_INT_Z UINT16_C(0x0004)
  234. #define BMM150_HIGH_THRESHOLD_INT_X UINT16_C(0x0008)
  235. #define BMM150_HIGH_THRESHOLD_INT_Y UINT16_C(0x0010)
  236. #define BMM150_HIGH_THRESHOLD_INT_Z UINT16_C(0x0020)
  237. #define BMM150_DATA_OVERFLOW_INT UINT16_C(0x0040)
  238. #define BMM150_DATA_OVERRUN_INT UINT16_C(0x0080)
  239. #define BMM150_DATA_READY_INT UINT16_C(0x0100)
  240. /**\name Macros for bit masking */
  241. #define BMM150_PWR_CNTRL_MSK UINT8_C(0x01)
  242. #define BMM150_CONTROL_MEASURE_MSK UINT8_C(0x38)
  243. #define BMM150_CONTROL_MEASURE_POS UINT8_C(0x03)
  244. #define BMM150_POWER_CONTROL_BIT_MSK UINT8_C(0x01)
  245. #define BMM150_POWER_CONTROL_BIT_POS UINT8_C(0x00)
  246. #define BMM150_OP_MODE_MSK UINT8_C(0x06)
  247. #define BMM150_OP_MODE_POS UINT8_C(0x01)
  248. #define BMM150_ODR_MSK UINT8_C(0x38)
  249. #define BMM150_ODR_POS UINT8_C(0x03)
  250. #define BMM150_DATA_X_MSK UINT8_C(0xF8)
  251. #define BMM150_DATA_X_POS UINT8_C(0x03)
  252. #define BMM150_DATA_Y_MSK UINT8_C(0xF8)
  253. #define BMM150_DATA_Y_POS UINT8_C(0x03)
  254. #define BMM150_DATA_Z_MSK UINT8_C(0xFE)
  255. #define BMM150_DATA_Z_POS UINT8_C(0x01)
  256. #define BMM150_DATA_RHALL_MSK UINT8_C(0xFC)
  257. #define BMM150_DATA_RHALL_POS UINT8_C(0x02)
  258. #define BMM150_SELF_TEST_MSK UINT8_C(0x01)
  259. #define BMM150_ADV_SELF_TEST_MSK UINT8_C(0xC0)
  260. #define BMM150_ADV_SELF_TEST_POS UINT8_C(0x06)
  261. #define BMM150_DRDY_EN_MSK UINT8_C(0x80)
  262. #define BMM150_DRDY_EN_POS UINT8_C(0x07)
  263. #define BMM150_INT_PIN_EN_MSK UINT8_C(0x40)
  264. #define BMM150_INT_PIN_EN_POS UINT8_C(0x06)
  265. #define BMM150_DRDY_POLARITY_MSK UINT8_C(0x04)
  266. #define BMM150_DRDY_POLARITY_POS UINT8_C(0x02)
  267. #define BMM150_INT_LATCH_MSK UINT8_C(0x02)
  268. #define BMM150_INT_LATCH_POS UINT8_C(0x01)
  269. #define BMM150_INT_POLARITY_MSK UINT8_C(0x01)
  270. #define BMM150_DATA_OVERRUN_INT_MSK UINT8_C(0x80)
  271. #define BMM150_DATA_OVERRUN_INT_POS UINT8_C(0x07)
  272. #define BMM150_OVERFLOW_INT_MSK UINT8_C(0x40)
  273. #define BMM150_OVERFLOW_INT_POS UINT8_C(0x06)
  274. #define BMM150_HIGH_THRESHOLD_INT_MSK UINT8_C(0x38)
  275. #define BMM150_HIGH_THRESHOLD_INT_POS UINT8_C(0x03)
  276. #define BMM150_LOW_THRESHOLD_INT_MSK UINT8_C(0x07)
  277. #define BMM150_DRDY_STATUS_MSK UINT8_C(0x01)
  278. /**\name OVERFLOW DEFINITIONS */
  279. #define BMM150_XYAXES_FLIP_OVERFLOW_ADCVAL INT16_C(-4096)
  280. #define BMM150_ZAXIS_HALL_OVERFLOW_ADCVAL INT16_C(-16384)
  281. #define BMM150_OVERFLOW_OUTPUT INT16_C(-32768)
  282. #define BMM150_NEGATIVE_SATURATION_Z INT16_C(-32767)
  283. #define BMM150_POSITIVE_SATURATION_Z UINT16_C(32767)
  284. #ifdef BMM150_USE_FLOATING_POINT
  285. #define BMM150_OVERFLOW_OUTPUT_FLOAT 0.0f
  286. #endif
  287. /**\name PRESET MODE DEFINITIONS */
  288. #define BMM150_PRESETMODE_LOWPOWER UINT8_C(0x01)
  289. #define BMM150_PRESETMODE_REGULAR UINT8_C(0x02)
  290. #define BMM150_PRESETMODE_HIGHACCURACY UINT8_C(0x03)
  291. #define BMM150_PRESETMODE_ENHANCED UINT8_C(0x04)
  292. /**\name PRESET MODES - REPETITIONS-XY RATES */
  293. #define BMM150_LOWPOWER_REPXY UINT8_C(1)
  294. #define BMM150_REGULAR_REPXY UINT8_C(4)
  295. #define BMM150_ENHANCED_REPXY UINT8_C(7)
  296. #define BMM150_HIGHACCURACY_REPXY UINT8_C(23)
  297. /**\name PRESET MODES - REPETITIONS-Z RATES */
  298. #define BMM150_LOWPOWER_REPZ UINT8_C(2)
  299. #define BMM150_REGULAR_REPZ UINT8_C(14)
  300. #define BMM150_ENHANCED_REPZ UINT8_C(26)
  301. #define BMM150_HIGHACCURACY_REPZ UINT8_C(82)
  302. /**\name Register read lengths */
  303. #define BMM150_SELF_TEST_LEN UINT8_C(5)
  304. #define BMM150_SETTING_DATA_LEN UINT8_C(8)
  305. #define BMM150_XYZR_DATA_LEN UINT8_C(8)
  306. /**\name Self test selection macros */
  307. #define BMM150_NORMAL_SELF_TEST UINT8_C(0)
  308. #define BMM150_ADVANCED_SELF_TEST UINT8_C(1)
  309. /**\name Self test settings */
  310. #define BMM150_DISABLE_XY_AXIS UINT8_C(0x03)
  311. #define BMM150_SELF_TEST_REP_Z UINT8_C(0x04)
  312. /**\name Advanced self-test current settings */
  313. #define BMM150_DISABLE_SELF_TEST_CURRENT UINT8_C(0x00)
  314. #define BMM150_ENABLE_NEGATIVE_CURRENT UINT8_C(0x02)
  315. #define BMM150_ENABLE_POSITIVE_CURRENT UINT8_C(0x03)
  316. /**\name Normal self-test status */
  317. #define BMM150_SELF_TEST_STATUS_XYZ_FAIL UINT8_C(0x00)
  318. #define BMM150_SELF_TEST_STATUS_SUCCESS UINT8_C(0x07)
  319. /**\name Macro to SET and GET BITS of a register*/
  320. #define BMM150_SET_BITS(reg_data, bitname, data) \
  321. ((reg_data & ~(bitname##_MSK)) | \
  322. ((data << bitname##_POS) & bitname##_MSK))
  323. #define BMM150_GET_BITS(reg_data, bitname) ((reg_data & (bitname##_MSK)) >> \
  324. (bitname##_POS))
  325. #define BMM150_SET_BITS_POS_0(reg_data, bitname, data) \
  326. ((reg_data & ~(bitname##_MSK)) | \
  327. (data & bitname##_MSK))
  328. #define BMM150_GET_BITS_POS_0(reg_data, bitname) (reg_data & (bitname##_MSK))
  329. /********************************************************/
  330. /*!
  331. * @brief Interface selection Enums
  332. */
  333. enum bmm150_intf {
  334. /*! SPI interface */
  335. BMM150_SPI_INTF,
  336. /*! I2C interface */
  337. BMM150_I2C_INTF
  338. };
  339. /********************************************************/
  340. /**\name TYPE DEFINITIONS */
  341. /*!
  342. * @brief Bus communication function pointer which should be mapped to
  343. * the platform specific read and write functions of the user
  344. */
  345. typedef int8_t (*bmm150_com_fptr_t)(uint8_t dev_id, uint8_t reg_addr, uint8_t *read_data, uint16_t len);
  346. /*! delay function pointer */
  347. typedef void (*bmm150_delay_fptr_t)(uint32_t);
  348. /********************************************************/
  349. /**\name STRUCTURE DEFINITIONS*/
  350. /*!
  351. * @brief bmm150 trim data structure
  352. */
  353. struct bmm150_trim_registers {
  354. /*! trim x1 data */
  355. int8_t dig_x1;
  356. /*! trim y1 data */
  357. int8_t dig_y1;
  358. /*! trim x2 data */
  359. int8_t dig_x2;
  360. /*! trim y2 data */
  361. int8_t dig_y2;
  362. /*! trim z1 data */
  363. uint16_t dig_z1;
  364. /*! trim z2 data */
  365. int16_t dig_z2;
  366. /*! trim z3 data */
  367. int16_t dig_z3;
  368. /*! trim z4 data */
  369. int16_t dig_z4;
  370. /*! trim xy1 data */
  371. uint8_t dig_xy1;
  372. /*! trim xy2 data */
  373. int8_t dig_xy2;
  374. /*! trim xyz1 data */
  375. uint16_t dig_xyz1;
  376. };
  377. /*!
  378. * @brief bmm150 interrupt pin settings
  379. */
  380. struct bmm150_int_ctrl_settings {
  381. /*! Data ready interrupt enable */
  382. uint8_t drdy_pin_en;
  383. /*! Threshold and overflow interrupts enable */
  384. uint8_t int_pin_en;
  385. /*! Data ready interrupt polarity Active high/low */
  386. uint8_t drdy_polarity;
  387. /*! Interrupt pin - Latched or Non-latched */
  388. uint8_t int_latch;
  389. /*! Interrupt polarity Active high/low */
  390. uint8_t int_polarity;
  391. /*! Data overrun interrupt enable */
  392. uint8_t data_overrun_en;
  393. /*! Overflow interrupt enable */
  394. uint8_t overflow_int_en;
  395. /*! high interrupt enable/disable axis selection */
  396. uint8_t high_int_en;
  397. /*! low interrupt enable/disable axis selection */
  398. uint8_t low_int_en;
  399. /*! low threshold limit */
  400. uint8_t low_threshold;
  401. /*! high threshold limit */
  402. uint8_t high_threshold;
  403. };
  404. /*!
  405. * @brief bmm150 sensor settings
  406. */
  407. struct bmm150_settings {
  408. /*! Control measurement of XYZ axes */
  409. uint8_t xyz_axes_control;
  410. /*! Power control bit value */
  411. uint8_t pwr_cntrl_bit;
  412. /*! Power control bit value */
  413. uint8_t pwr_mode;
  414. /*! Data rate value (ODR) */
  415. uint8_t data_rate;
  416. /*! XY Repetitions */
  417. uint8_t xy_rep;
  418. /*! Z Repetitions */
  419. uint8_t z_rep;
  420. /*! Preset mode of sensor */
  421. uint8_t preset_mode;
  422. /*! Interrupt configuration settings */
  423. struct bmm150_int_ctrl_settings int_settings;
  424. };
  425. /*!
  426. * @brief bmm150 un-compensated (raw) magnetometer data
  427. */
  428. struct bmm150_raw_mag_data {
  429. /*! Raw mag X data */
  430. int16_t raw_datax;
  431. /*! Raw mag Y data */
  432. int16_t raw_datay;
  433. /*! Raw mag Z data */
  434. int16_t raw_dataz;
  435. /*! Raw mag resistance value */
  436. uint16_t raw_data_r;
  437. };
  438. #ifdef BMM150_USE_FLOATING_POINT
  439. /*!
  440. * @brief bmm150 compensated magnetometer data in float
  441. */
  442. struct bmm150_mag_data {
  443. /*! compensated mag X data */
  444. float x;
  445. /*! compensated mag Y data */
  446. float y;
  447. /*! compensated mag Z data */
  448. float z;
  449. };
  450. #else
  451. /*!
  452. * @brief bmm150 compensated magnetometer data in int16_t format
  453. */
  454. struct bmm150_mag_data {
  455. /*! compensated mag X data */
  456. int16_t x;
  457. /*! compensated mag Y data */
  458. int16_t y;
  459. /*! compensated mag Z data */
  460. int16_t z;
  461. };
  462. #endif
  463. /*!
  464. * @brief bmm150 device structure
  465. */
  466. struct bmm150_dev {
  467. /*! Chip Id */
  468. uint8_t chip_id;
  469. /*! Device Id */
  470. uint8_t dev_id;
  471. /*! SPI/I2C Interface */
  472. enum bmm150_intf intf;
  473. /*! Bus read function pointer */
  474. bmm150_com_fptr_t read;
  475. /*! Bus write function pointer */
  476. bmm150_com_fptr_t write;
  477. /*! delay(in ms) function pointer */
  478. bmm150_delay_fptr_t delay_ms;
  479. /*! Trim registers */
  480. struct bmm150_trim_registers trim_data;
  481. /*! Sensor settings */
  482. struct bmm150_settings settings;
  483. /*! Interrupt status */
  484. uint16_t int_status;
  485. /*! Structure containing mag data */
  486. struct bmm150_mag_data data;
  487. };
  488. #endif /* BMM150_DEFS_H_ */
  489. /** @}*/
  490. /** @}*/