DMP_ICM20948.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef __Arduino_ICM20948_H__
  2. #define __Arduino_ICM20948_H__
  3. #include "main.h"
  4. #include "HAL_impl.h"
  5. #include "HAL_STM32_config.h"
  6. /*************************************************************************
  7. Defines
  8. *************************************************************************/
  9. static const uint8_t EXPECTED_WHOAMI[] = { 0xEA }; /* WHOAMI value for ICM20948 or derivative */
  10. #define AK0991x_DEFAULT_I2C_ADDR 0x0C
  11. #define AK0991x_SECONDARY_I2C_ADDR 0x0E /* The secondary I2C address for AK0991x Magnetometers */
  12. #define ICM_I2C_ADDR_REVA 0x68 /* I2C slave address for INV device on Rev A board */
  13. #define ICM_I2C_ADDR_REVB 0x69 /* I2C slave address for INV device on Rev B board */
  14. #define AD0_VAL 1 // The value of the last bit of the I2C address.
  15. #define THREE_AXES 3
  16. #ifdef __cplusplus
  17. typedef struct {
  18. int mode;
  19. uint8_t enable_gyroscope;
  20. uint8_t enable_accelerometer;
  21. uint8_t enable_magnetometer;
  22. uint8_t enable_gravity;
  23. uint8_t enable_linearAcceleration;
  24. uint8_t enable_quaternion6;
  25. uint8_t enable_quaternion9;
  26. uint8_t enable_har;
  27. uint8_t enable_steps;
  28. int gyroscope_frequency;
  29. int accelerometer_frequency;
  30. int magnetometer_frequency;
  31. int gravity_frequency;
  32. int linearAcceleration_frequency;
  33. int quaternion6_frequency;
  34. int quaternion9_frequency;
  35. int har_frequency;
  36. int steps_frequency;
  37. } DMP_ICM20948Settings;
  38. /*************************************************************************
  39. Class
  40. *************************************************************************/
  41. class DMP_ICM20948
  42. {
  43. public:
  44. DMP_ICM20948();
  45. //void init(TwoWire *theWire = &Wire, JTICM20948Settings settings);
  46. void init(DMP_ICM20948Settings settings);
  47. void task();
  48. bool gyroDataIsReady();
  49. bool accelDataIsReady();
  50. bool magDataIsReady();
  51. bool gravDataIsReady();
  52. bool linearAccelDataIsReady();
  53. bool quat6DataIsReady();
  54. bool euler6DataIsReady();
  55. bool quat9DataIsReady();
  56. bool euler9DataIsReady();
  57. bool harDataIsReady();
  58. bool stepsDataIsReady();
  59. void readGyroData(float *x, float *y, float *z);
  60. void readAccelData(float *x, float *y, float *z);
  61. void readMagData(float *x, float *y, float *z);
  62. void readGravData(float* x, float* y, float* z);
  63. void readLinearAccelData(float* x, float* y, float* z);
  64. void readQuat6Data(float *w, float *x, float *y, float *z);
  65. void readEuler6Data(float *roll, float *pitch, float *yaw);
  66. void readQuat9Data(float* w, float* x, float* y, float* z);
  67. void readEuler9Data(float* roll, float* pitch, float* yaw);
  68. void readHarData(char* activity);
  69. void readStepsData(unsigned long* steps_count);
  70. };
  71. #endif
  72. #endif