Icm20948MPUFifoControl.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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_mpu_fifo_control inv_mpu_fifo_control
  13. @ingroup SmartSensor_driver
  14. @{
  15. */
  16. #ifndef INV_ICM20948_MPU_FIFO_CONTROL_H__GQWDHE__
  17. #define INV_ICM20948_MPU_FIFO_CONTROL_H__GQWDHE__
  18. #include "Icm20948Defs.h"
  19. #include <stdint.h>
  20. /* forward declaration */
  21. struct inv_icm20948;
  22. /** @brief Struct for the fifo. this contains the sensor data */
  23. struct inv_fifo_decoded_t
  24. {
  25. long dmp_3e_6quat[3];
  26. long dmp_3e_9quat[3];
  27. int dmp_rv_accuracyQ29;
  28. long dmp_3e_geomagquat[3];
  29. int dmp_geomag_accuracyQ29;
  30. short accel_s[3];
  31. long accel[3];
  32. short gyro[3];
  33. short gyro_bias[3];
  34. long gyro_calibr[3];
  35. long compass[3];
  36. long cpass_calibr[3];
  37. long ped_step_det_ts;
  38. short cpass_raw_data[3];
  39. short accel_accuracy;
  40. short gyro_accuracy;
  41. short cpass_accuracy;
  42. long bac_ts;
  43. unsigned short bac_state;
  44. short flip_pickup;
  45. unsigned char cpass_calibr_12chars[12];
  46. unsigned char cpass_calibr_6chars[6];
  47. unsigned short header;
  48. unsigned short header2;
  49. unsigned short footer;
  50. int new_data;
  51. };
  52. #ifdef __cplusplus
  53. extern "C"
  54. {
  55. #endif
  56. /** @brief Identify the interrupt
  57. * @param[in] int_read pointer to the DMP interrupt status
  58. * @return 0 on success, negative value on error.
  59. */
  60. int INV_EXPORT inv_icm20948_identify_interrupt(struct inv_icm20948 * s, short *int_read);
  61. /** @brief Process the fifo.
  62. * @param[in] left_in_fifo pointer for the fifo to be processed
  63. * @param[in] user_header pointer for the user header
  64. * @param[in] user_header2 pointer for the user header 2
  65. * @param[in] time_stamp pointer for the timestamp
  66. * @return 0 on success, negative value on error.
  67. */
  68. int INV_EXPORT inv_icm20948_dmp_process_fifo(struct inv_icm20948 * s, int *left_in_fifo, unsigned short *user_header, unsigned short *user_header2, long *time_stamp);
  69. /** @brief Gets the accelerometer data
  70. * @param[out] acl[3] the accelerometer data
  71. * @return 0 on success, negative value on error.
  72. */
  73. int INV_EXPORT inv_icm20948_dmp_get_accel(long acl[3]);
  74. /** @brief Gets the raw gyrometer data
  75. * @param[out] raw_gyro[3] the raw gyrometer data
  76. * @return 0 on success, negative value on error.
  77. */
  78. int INV_EXPORT inv_icm20948_dmp_get_raw_gyro(short raw_gyro[3]);
  79. /** @brief Gets gyro bias
  80. * @param[out] quat[3] Gyro bias x,y,z
  81. * @return 0 on success, negative value on error.
  82. */
  83. int INV_EXPORT inv_icm20948_dmp_get_gyro_bias(short gyro_bias[3]);
  84. /** @brief Gets calibrated gyro value based on raw gyro and gyro bias
  85. * @param[out] calibratedData[3] Calibred Gyro x,y,z
  86. * @param[in] raw[3] Gyro raw data x,y,z
  87. * @param[in] bias[3] Gyro bias x,y,z
  88. * @return 0 on success, negative value on error.
  89. */
  90. int INV_EXPORT inv_icm20948_dmp_get_calibrated_gyro(signed long calibratedData[3], signed long raw[3], signed long bias[3]);
  91. /** @brief Gets the quaternion 6 axis data
  92. * @param[out] quat[3] the quaternion 6 axis data
  93. * @return 0 on success, negative value on error.
  94. */
  95. int INV_EXPORT inv_icm20948_dmp_get_6quaternion(long quat[3]);
  96. /** @brief Gets the quaternion 9 axis data
  97. * @param[out] quat[3] the quaternion 9 axis data
  98. * @return 0 on success, negative value on error.
  99. */
  100. int INV_EXPORT inv_icm20948_dmp_get_9quaternion(long quat[3]);
  101. /** @brief Gets the quaternion GMRV data
  102. * @param[out] quat[3] the quaternion GMRV 6 axis data
  103. * @return 0 on success, negative value on error.
  104. */
  105. int INV_EXPORT inv_icm20948_dmp_get_gmrvquaternion(long quat[3]);
  106. /** @brief Gets the raw compass data
  107. * @param[out] cal_compass[3] the raw compass data
  108. * @return 0 on success, negative value on error.
  109. */
  110. int INV_EXPORT inv_icm20948_dmp_get_raw_compass(long raw_compass[3]);
  111. /** @brief Gets the calibrated compass data
  112. * @param[out] cal_compass[3] the calibrated compass data
  113. * @return 0 on success, negative value on error.
  114. */
  115. int INV_EXPORT inv_icm20948_dmp_get_calibrated_compass(long cal_compass[3]);
  116. /** @brief Decodes the fifo packet
  117. * @param[in] fifo_ptr pointer to the fifo data
  118. * @param[in] fd pointer to the fifo what contains the sensor data
  119. * @return 0 on success, negative value on error.
  120. */
  121. int INV_EXPORT inv_icm20948_inv_decode_one_ivory_fifo_packet(struct inv_icm20948 * s, struct inv_fifo_decoded_t *fd, const unsigned char *fifo_ptr);
  122. /** @brief Gets the state of the BAC sensor
  123. * @param[in] bac_state pointer for recuperate the state of BAC
  124. * @return 0 on success, negative value on error.
  125. */
  126. int INV_EXPORT inv_icm20948_dmp_get_bac_state(uint16_t *bac_state);
  127. /** @brief Gets the timestamp of the BAC sensor
  128. * @param[in] bac_ts pointer for recuperate the timestamp of BAC
  129. * @return 0 on success, negative value on error.
  130. */
  131. int INV_EXPORT inv_icm20948_dmp_get_bac_ts(long *bac_ts);
  132. /** @brief Gets the state of the pick up sensor
  133. * @param[in] flip_pickup pointer for recuperate the state of pickup
  134. * @return 0 on success, negative value on error.
  135. */
  136. int INV_EXPORT inv_icm20948_dmp_get_flip_pickup_state(uint16_t *flip_pickup);
  137. /** @brief Returns the accelerometer accuracy
  138. * @return the accelerometer accuracy value
  139. */
  140. int INV_EXPORT inv_icm20948_get_accel_accuracy(void);
  141. /** @brief Returns the gyrometer accuracy
  142. * @return the gyrometer accuracy value
  143. */
  144. int INV_EXPORT inv_icm20948_get_gyro_accuracy(void);
  145. /** @brief Returns the magnetometer accuracy
  146. * @return the magnetometer accuracy value
  147. */
  148. int INV_EXPORT inv_icm20948_get_mag_accuracy(void);
  149. /** @brief Returns the geomagnetic rotation vector accuracy
  150. * @return the geomagnetic rotation vector accuracy in Q29
  151. */
  152. int INV_EXPORT inv_icm20948_get_gmrv_accuracy(void);
  153. /** @brief Returns the rotation vector accuracy
  154. * @return the rotation vector accuracy value in Q29
  155. */
  156. int INV_EXPORT inv_icm20948_get_rv_accuracy(void);
  157. /** @brief Resets the fifo
  158. * @param[in] value 0=no, 1=yes
  159. * @return 0 on success, negative value on error.
  160. */
  161. int INV_EXPORT inv_icm20948_mpu_set_FIFO_RST_Diamond(struct inv_icm20948 * s, unsigned char value);
  162. /** @brief Mirror DMP HW FIFO into SW FIFO
  163. * @param[inout] left_in_fifo pointer to number of bytes in SW FIFO : before function is called, must contain number of
  164. bytes still present in FIFO which must not be overwritten
  165. after function is called, will contain number of bytes present in SW FIFO to be analyzed
  166. * @param[out] total_sample_cnt number of total sensor samples present in SW FIFO
  167. * @param[out] sample_cnt_array array of number of sensor samples present in SW FIFO for each sensor, should be inited to 0 before being called
  168. * @return 0 on success, negative value on error.
  169. */
  170. int INV_EXPORT inv_icm20948_fifo_swmirror(struct inv_icm20948 * s, int *left_in_fifo, unsigned short * total_sample_cnt, unsigned short * sample_cnt_array);
  171. /** @brief Pop one sample out of SW FIFO
  172. * @param[out] user_header Header value read from SW FIFO
  173. * @param[out] user_header2 Header2 value read from SW FIFO
  174. * @param[inout] left_in_fifo Contains number of bytes still be parsed from SW FIFO
  175. * @return 0 on success, negative value on error.
  176. */
  177. int INV_EXPORT inv_icm20948_fifo_pop(struct inv_icm20948 * s, unsigned short *user_header, unsigned short *user_header2, int *left_in_fifo);
  178. #ifdef __cplusplus
  179. }
  180. #endif
  181. #endif // INV_ICM20948_MPU_FIFO_CONTROL_H__GQWDHE__
  182. /** @} */