M5Unified
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
IMU_Base.hpp
Go to the documentation of this file.
1 // Copyright (c) M5Stack. All rights reserved.
2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 
4 #ifndef __M5_IMU_BASE_H__
5 #define __M5_IMU_BASE_H__
6 
7 #include "../I2C_Class.hpp"
8 
9 namespace m5
10 {
11  class IMU_Base : public I2C_Device
12  {
13  public:
15  {
17  imu_spec_accel = 0b0001,
18  imu_spec_gyro = 0b0010,
19  imu_spec_mag = 0b0100,
20  };
21 
23  {
24  union
25  {
26  int16_t value[3];
27  struct
28  {
29  int16_t x;
30  int16_t y;
31  int16_t z;
32  };
33  } __attribute__((__packed__));
34  };
35 
37  {
38  union
39  {
40  int16_t value[10] = { 0, };
42  struct
43  {
47  int16_t temp;
48  } __attribute__((__packed__));
49  };
50  };
51 
53  {
54  union
55  {
56  float value[3] = { 8.0f / 32768.0f, 2000.0f / 32768.0f, 10.0f * 4912.0f / 32768.0f };
57  struct
58  {
59  float accel_res;
60  float gyro_res;
61  float mag_res;
62  };
63  };
64  float temp_res = 1.0f;
65  float temp_offset = 0.0f;
66  };
67 
68  virtual ~IMU_Base();
69  IMU_Base(std::uint8_t i2c_addr, std::uint32_t freq = 400000, I2C_Class* i2c = &In_I2C);
70  virtual imu_spec_t begin(I2C_Class* i2c = nullptr) = 0;
71  virtual imu_spec_t getImuRawData(imu_raw_data_t* data) const = 0; //{ return (imu_spec_t)0; }
72  virtual void getConvertParam(imu_convert_param_t* param) const = 0;//{}
73  virtual bool getTempAdc(int16_t* adc) const { return false; };
74 
75 /*
76  virtual bool getAccelAdc(std::int16_t* ax, std::int16_t* ay, std::int16_t* az) const { return false; }
77  virtual bool getGyroAdc(std::int16_t* gx, std::int16_t* gy, std::int16_t* gz) const { return false; }
78  virtual bool getAccel(float* ax, float* ay, float* az) const { return false; }
79  virtual bool getGyro(float* gx, float* gy, float* gz) const { return false; }
80  virtual bool getTemp(float *t) const { return false; };
81 //*/
82 
83  virtual bool setINTPinActiveLogic(bool level) { return false; }
84  };
85 }
86 
87 #endif
virtual imu_spec_t getImuRawData(imu_raw_data_t *data) const =0
virtual bool getTempAdc(int16_t *adc) const
Definition: IMU_Base.hpp:73
virtual imu_spec_t begin(I2C_Class *i2c=nullptr)=0
IMU_Base(std::uint8_t i2c_addr, std::uint32_t freq=400000, I2C_Class *i2c=&In_I2C)
Definition: IMU_Base.cpp:9
virtual void getConvertParam(imu_convert_param_t *param) const =0
virtual bool setINTPinActiveLogic(bool level)
Definition: IMU_Base.hpp:83
virtual ~IMU_Base()
Definition: IMU_Base.cpp:8
Definition: M5Unified.cpp:48
struct __attribute__((packed)) rtc_time_t
I2C_Class In_I2C
for internal I2C device
Definition: I2C_Class.cpp:10
point3d_i16_t sensor[3]
Definition: IMU_Base.hpp:41
struct m5::IMU_Base::point3d_i16_t::@9::@10 __attribute__