Icm20948AuxCompassAkm.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * ________________________________________________________________________________________________________
  3. * Copyright © 2014-2015 InvenSense Inc. Portions Copyright © 2014-2015 Movea. All rights reserved.
  4. * This software, related documentation and any modifications thereto (collectively “Software”) is subject
  5. * to InvenSense and its licensors' intellectual property rights under U.S. and international copyright and
  6. * other intellectual property rights laws.
  7. * InvenSense and its licensors retain all intellectual property and proprietary rights in and to the Software
  8. * and any use, reproduction, disclosure or distribution of the Software without an express license
  9. * agreement from InvenSense is strictly prohibited.
  10. * ________________________________________________________________________________________________________
  11. */
  12. /** @defgroup inv_icm20948_slave_compass inv_slave_compass
  13. @ingroup SmartSensor_driver
  14. @{
  15. */
  16. #ifndef INV_ICM20948_SLAVE_COMPASS_H_SDFWQN__
  17. #define INV_ICM20948_SLAVE_COMPASS_H_SDFWQN__
  18. #define CPASS_MTX_00 (23 * 16)
  19. #define CPASS_MTX_01 (23 * 16 + 4)
  20. #define CPASS_MTX_02 (23 * 16 + 8)
  21. #define CPASS_MTX_10 (23 * 16 + 12)
  22. #define CPASS_MTX_11 (24 * 16)
  23. #define CPASS_MTX_12 (24 * 16 + 4)
  24. #define CPASS_MTX_20 (24 * 16 + 8)
  25. #define CPASS_MTX_21 (24 * 16 + 12)
  26. #define CPASS_MTX_22 (25 * 16)
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /* forward declaration */
  31. struct inv_icm20948;
  32. /** @brief Supported auxiliary compass identifer
  33. */
  34. enum inv_icm20948_compass_id {
  35. INV_ICM20948_COMPASS_ID_NONE = 0, /**< no compass */
  36. INV_ICM20948_COMPASS_ID_AK09911, /**< AKM AK09911 */
  37. INV_ICM20948_COMPASS_ID_AK09912, /**< AKM AK09912 */
  38. INV_ICM20948_COMPASS_ID_AK09916, /**< AKM AK09916 */
  39. INV_ICM20948_COMPASS_ID_AK08963, /**< AKM AK08963 */
  40. };
  41. /** @brief Register AUX compass
  42. *
  43. * Will only set internal states and won't perform any transaction on the bus.
  44. * Must be called before inv_icm20948_initialize().
  45. *
  46. * @param[in] compass_id Compass ID
  47. * @param[in] compass_i2c_addr Compass I2C address
  48. * @return 0 on success, negative value on error
  49. */
  50. void INV_EXPORT inv_icm20948_register_aux_compass(struct inv_icm20948 * s,
  51. enum inv_icm20948_compass_id compass_id, uint8_t compass_i2c_addr);
  52. /** @brief Initializes the compass
  53. * @return 0 in case of success, -1 for any error
  54. */
  55. int INV_EXPORT inv_icm20948_setup_compass_akm(struct inv_icm20948 * s);
  56. /** @brief Self test for the compass
  57. * @return 0 in case of success, -1 for any error
  58. */
  59. int INV_EXPORT inv_icm20948_check_akm_self_test(struct inv_icm20948 * s);
  60. /** @brief Changes the scale of the compass
  61. * @param[in] data new scale for the compass
  62. * @return 0 in case of success, -1 for any error
  63. */
  64. int INV_EXPORT inv_icm20948_write_akm_scale(struct inv_icm20948 * s, int data);
  65. /** @brief Reads the scale of the compass
  66. * @param[out] scale pointer to recuperate the scale
  67. * @return 0 in case of success, -1 for any error
  68. */
  69. int INV_EXPORT inv_icm20948_read_akm_scale(struct inv_icm20948 * s, int *scale);
  70. /** @brief Stops the compass
  71. * @return 0 in case of success, -1 for any error
  72. */
  73. int INV_EXPORT inv_icm20948_suspend_akm(struct inv_icm20948 * s);
  74. /** @brief Starts the compass
  75. * @return 0 in case of success, -1 for any error
  76. */
  77. int INV_EXPORT inv_icm20948_resume_akm(struct inv_icm20948 * s);
  78. /** @brief Get compass power status
  79. * @return 1 in case compass is enabled, 0 if not started
  80. */
  81. char INV_EXPORT inv_icm20948_compass_getstate(struct inv_icm20948 * s);
  82. /** @brief detects if the compass is connected
  83. * @return 1 if the compass is connected, 0 otherwise
  84. */
  85. int INV_EXPORT inv_icm20948_compass_isconnected(struct inv_icm20948 * s);
  86. /** @brief Calibrates the data
  87. * @param[in] m pointer to the raw compass data
  88. * @param[out] compass_m pointer to the calibrated compass data
  89. * @return 0 in case of success, -1 for any error
  90. */
  91. int INV_EXPORT inv_icm20948_compass_dmp_cal(struct inv_icm20948 * s, const signed char *m, const signed char *compass_m);
  92. /**
  93. * @brief Applies mounting matrix and scaling to raw compass data.
  94. * @param[in] raw_data Raw compass data
  95. * @param[in] compensated_out Compensated compass data
  96. * @return 0 in case of success, -1 for any error
  97. */
  98. int INV_EXPORT inv_icm20948_apply_raw_compass_matrix(struct inv_icm20948 * s, short *raw_data, long *compensated_out);
  99. #ifdef __cplusplus
  100. }
  101. #endif
  102. #endif // INV_ICM20948_SLAVE_COMPASS_H_SDFWQN__
  103. /** @} */