DMP_ICM20948.h 2.8 KB

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