Voss Connection Detection  1
Detect a connector click using realtime code on Bela hardware
ICM20948.h
Go to the documentation of this file.
1 
2 #ifndef ICM20948_H_
3 #define ICM20948_H_
4 #define ICM20948_I2C_BUFFER 0x80
5 
11 };
12 /*
13 enum ICM20948_BANDWIDTH {
14  BW_10HZ = 0,
15  BW_20HZ = 1,
16  BW_40HZ = 2,
17  BW_75HZ = 3,
18  BW_150HZ = 4,
19  BW_300HZ = 5,
20  BW_600HZ = 6,
21  BW_12OOHZ = 7,
22  BW_HIGHPASS = 8,
23  BW_BANDPASS = 9
24 };
25 
26 enum ICM20948_MODECONFIG {
27  MODE_LOW_NOISE = 0,
28  MODE_LOW_POWER = 3
29 };
30 */
31 class ICM20948 {
32 
33 private:
34  int I2CBus, I2CAddress;
35  char dataBuffer[ICM20948_I2C_BUFFER];
36 
37  float gyroX = 0.0f;
38  float gyroY = 0.0f;
39  float gyroZ = 0.0f;
40 
41  float accX = 0.0f;
42  float accY = 0.0f;
43  float accZ = 0.0f;
44 
45  float gyroAbs = 0.0f, accAbs = 0.0f;
46 
47  float convertGyro(int msb_addr, int lsb_addr);
48  float convertAcc(int msb_addr, int lsb_addr);
49  int writeI2CDeviceByte(char address, char value);
50  //char readI2CDeviceByte(char address);
51  void calculateAbs();
52 
53  bool _error = false;
54 
55 public:
56  ICM20948(int bus, int address);
57  void displayMode(int iterations);
58 
59  int readFullSensorState();
60 
61  void WakeUp();
62  void GetScale();
63  void SetScale250();
64  void SetScale2000();
65  void ResetChip();
66 
67  float getGyroX() const { return gyroX; }
68  float getGyroY() const { return gyroY; }
69  float getGyroZ() const { return gyroZ; }
70 
71  float getGyroAbs() { return gyroAbs; }
72  float getAccAbs() { return accAbs; }
73 
74  float getAccX() const { return accX; }
75  float getAccY() const { return accY; }
76  float getAccZ() const { return accZ; }
77 
78  bool error() const {return _error;}
79  void resetError() {_error = false;}
80 
81 };
82 
83 #endif /* ICM20948_H_ */
ICM20948::WakeUp
void WakeUp()
Definition: ICM20948.cpp:127
ICM20948::ICM20948
ICM20948(int bus, int address)
Definition: ICM20948.cpp:30
ICM20948::getGyroAbs
float getGyroAbs()
Definition: ICM20948.h:71
ICM20948_RANGE
ICM20948_RANGE
Definition: ICM20948.h:6
PLUSMINUS_2G
@ PLUSMINUS_2G
Definition: ICM20948.h:7
ICM20948::GetScale
void GetScale()
Definition: ICM20948.cpp:139
ICM20948::displayMode
void displayMode(int iterations)
Definition: ICM20948.cpp:120
ICM20948::getAccZ
float getAccZ() const
Definition: ICM20948.h:76
ICM20948::readFullSensorState
int readFullSensorState()
Definition: ICM20948.cpp:50
PLUSMINUS_8G
@ PLUSMINUS_8G
Definition: ICM20948.h:9
ICM20948::getAccX
float getAccX() const
Definition: ICM20948.h:74
ICM20948::ResetChip
void ResetChip()
Definition: ICM20948.cpp:183
ICM20948::error
bool error() const
Definition: ICM20948.h:78
PLUSMINUS_4G
@ PLUSMINUS_4G
Definition: ICM20948.h:8
ICM20948::getAccY
float getAccY() const
Definition: ICM20948.h:75
ICM20948::getGyroX
float getGyroX() const
Definition: ICM20948.h:67
PLUSMINUS_16G
@ PLUSMINUS_16G
Definition: ICM20948.h:10
ICM20948
Definition: ICM20948.h:31
ICM20948::SetScale2000
void SetScale2000()
Definition: ICM20948.cpp:149
ICM20948::getGyroY
float getGyroY() const
Definition: ICM20948.h:68
ICM20948_I2C_BUFFER
#define ICM20948_I2C_BUFFER
Definition: ICM20948.h:4
ICM20948::getGyroZ
float getGyroZ() const
Definition: ICM20948.h:69
ICM20948::getAccAbs
float getAccAbs()
Definition: ICM20948.h:72
ICM20948::SetScale250
void SetScale250()
Definition: ICM20948.cpp:166
ICM20948::resetError
void resetError()
Definition: ICM20948.h:79