You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/ICM_20948.h
+88-97Lines changed: 88 additions & 97 deletions
Original file line number
Diff line number
Diff line change
@@ -7,142 +7,136 @@ A C++ interface to the ICM-20948
7
7
#ifndef _ICM_20948_H_
8
8
#define_ICM_20948_H_
9
9
10
-
#include"util/ICM_20948_C.h"// The C backbone
10
+
#include"util/ICM_20948_C.h"// The C backbone
11
11
12
-
#include"Arduino.h"// Arduino support
12
+
#include"Arduino.h"// Arduino support
13
13
#include"Wire.h"
14
14
#include"SPI.h"
15
15
16
16
#defineICM_20948_ARD_UNUSED_PIN0xFF
17
17
18
-
19
18
// Base
20
-
classICM_20948 {
19
+
classICM_20948
20
+
{
21
21
private:
22
22
protected:
23
-
ICM_20948_Device_t _device;
24
-
bool_has_magnetometer;
23
+
ICM_20948_Device_t _device;
24
+
bool _has_magnetometer;
25
25
26
-
floatgetTempC ( int16_t val);
27
-
floatgetGyrDPS ( int16_t axis_val);
28
-
floatgetAccMG ( int16_t axis_val);
29
-
floatgetMagUT ( int16_t axis_val);
26
+
floatgetTempC(int16_t val);
27
+
floatgetGyrDPS(int16_t axis_val);
28
+
floatgetAccMG(int16_t axis_val);
29
+
floatgetMagUT(int16_t axis_val);
30
30
31
31
public:
32
-
ICM_20948(); // Constructor
33
-
34
-
ICM_20948_AGMT_t agmt; // Acceleometer, Gyroscope, Magenetometer, and Temperature data
35
-
ICM_20948_AGMT_t getAGMT ( void ); // Updates the agmt field in the object and also returns a copy directly
32
+
ICM_20948(); // Constructor
36
33
37
-
floatmagX ( void );// micro teslas
38
-
floatmagY ( void );// micro teslas
39
-
floatmagZ ( void );// micro teslas
34
+
ICM_20948_AGMT_t agmt; // Acceleometer, Gyroscope, Magenetometer, and Temperature data
35
+
ICM_20948_AGMT_t getAGMT(void); // Updates the agmt field in the object and also returns a copy directly
40
36
41
-
floataccX ( void );//milli g's
42
-
floataccY ( void );//milli g's
43
-
floataccZ ( void );//milli g's
37
+
floatmagX(void); //micro teslas
38
+
floatmagY(void); //micro teslas
39
+
floatmagZ(void); //micro teslas
44
40
45
-
floatgyrX ( void );//degrees per second
46
-
floatgyrY ( void );//degrees per second
47
-
floatgyrZ ( void );//degrees per second
41
+
floataccX(void); //milli g's
42
+
floataccY(void); //milli g's
43
+
floataccZ(void); //milli g's
48
44
49
-
floattemp ( void );// degrees celsius
45
+
floatgyrX(void); // degrees per second
46
+
floatgyrY(void); // degrees per second
47
+
floatgyrZ(void); // degrees per second
50
48
49
+
floattemp(void); // degrees celsius
51
50
52
-
ICM_20948_Status_e status;// Status from latest operation
53
-
constchar* statusString ( ICM_20948_Status_e stat = ICM_20948_Stat_NUM); // Returns a human-readable status message. Defaults to status member, but prints string for supplied status if supplied
51
+
ICM_20948_Status_e status; // Status from latest operation
52
+
constchar *statusString(ICM_20948_Status_e stat = ICM_20948_Stat_NUM); // Returns a human-readable status message. Defaults to status member, but prints string for supplied status if supplied
54
53
55
54
// Device Level
56
-
ICM_20948_Status_e setBank ( uint8_t bank ); // Sets the bank
57
-
ICM_20948_Status_e swReset ( void ); // Performs a SW reset
58
-
ICM_20948_Status_e sleep ( bool on = false ); // Set sleep mode for the chip
59
-
ICM_20948_Status_e lowPower ( bool on = true ); // Set low power mode for the chip
ICM_20948_Status_e checkID(void); // Return 'ICM_20948_Stat_Ok' if whoami matches ICM_20948_WHOAMI
66
61
62
+
booldataReady(void); // Returns 'true' if data is ready
63
+
uint8_tgetWhoAmI(void); // Return whoami in out prarmeter
64
+
boolisConnected(void); // Returns true if communications with the device are sucessful
67
65
68
66
// Internal Sensor Options
69
-
ICM_20948_Status_esetSampleMode ( uint8_t sensor_id_bm, uint8_t lp_config_cycle_mode ); // Use to set accel, gyro, and I2C master into cycled or continuous modes
ICM_20948_Status_esetSampleMode(uint8_t sensor_id_bm, uint8_t lp_config_cycle_mode); // Use to set accel, gyro, and I2C master into cycled or continuous modes
ICM_20948_Status_e cfgIntLatch ( bool latching ); // If not latching then the interrupt is a 50 us pulse
81
-
ICM_20948_Status_e cfgIntAnyReadToClear ( bool enabled ); // If enabled, *ANY* read will clear the INT_STATUS register. So if you have multiple interrupt sources enabled be sure to read INT_STATUS first
ICM_20948_Status_e cfgFsyncIntMode ( bool interrupt_mode ); // Can ue FSYNC as an interrupt input that sets the I2C Master Status register's PASS_THROUGH bit
ICM_20948_Status_e cfgIntLatch(bool latching);// If not latching then the interrupt is a 50 us pulse
79
+
ICM_20948_Status_e cfgIntAnyReadToClear(bool enabled);// If enabled, *ANY* read will clear the INT_STATUS register. So if you have multiple interrupt sources enabled be sure to read INT_STATUS first
ICM_20948_Status_e cfgFsyncIntMode(bool interrupt_mode);// Can ue FSYNC as an interrupt input that sets the I2C Master Status register's PASS_THROUGH bit
0 commit comments