Skip to content

Commit 20d57b8

Browse files
author
Nathan Seidle
committed
VSC doing white space changes
1 parent b786553 commit 20d57b8

File tree

1 file changed

+88
-97
lines changed

1 file changed

+88
-97
lines changed

src/ICM_20948.h

Lines changed: 88 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -7,142 +7,136 @@ A C++ interface to the ICM-20948
77
#ifndef _ICM_20948_H_
88
#define _ICM_20948_H_
99

10-
#include "util/ICM_20948_C.h" // The C backbone
10+
#include "util/ICM_20948_C.h" // The C backbone
1111

12-
#include "Arduino.h" // Arduino support
12+
#include "Arduino.h" // Arduino support
1313
#include "Wire.h"
1414
#include "SPI.h"
1515

1616
#define ICM_20948_ARD_UNUSED_PIN 0xFF
1717

18-
1918
// Base
20-
class ICM_20948 {
19+
class ICM_20948
20+
{
2121
private:
2222
protected:
23-
ICM_20948_Device_t _device;
24-
bool _has_magnetometer;
23+
ICM_20948_Device_t _device;
24+
bool _has_magnetometer;
2525

26-
float getTempC ( int16_t val );
27-
float getGyrDPS ( int16_t axis_val );
28-
float getAccMG ( int16_t axis_val );
29-
float getMagUT ( int16_t axis_val );
26+
float getTempC(int16_t val);
27+
float getGyrDPS(int16_t axis_val);
28+
float getAccMG(int16_t axis_val);
29+
float getMagUT(int16_t axis_val);
3030

3131
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
3633

37-
float magX ( void );// micro teslas
38-
float magY ( void );// micro teslas
39-
float magZ ( 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
4036

41-
float accX ( void );// milli g's
42-
float accY ( void );// milli g's
43-
float accZ ( void );// milli g's
37+
float magX(void); // micro teslas
38+
float magY(void); // micro teslas
39+
float magZ(void); // micro teslas
4440

45-
float gyrX ( void );// degrees per second
46-
float gyrY ( void );// degrees per second
47-
float gyrZ ( void );// degrees per second
41+
float accX(void); // milli g's
42+
float accY(void); // milli g's
43+
float accZ(void); // milli g's
4844

49-
float temp ( void );// degrees celsius
45+
float gyrX(void); // degrees per second
46+
float gyrY(void); // degrees per second
47+
float gyrZ(void); // degrees per second
5048

49+
float temp(void); // degrees celsius
5150

52-
ICM_20948_Status_e status; // Status from latest operation
53-
const char* 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+
const char *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
5453

5554
// 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
60-
ICM_20948_Status_e setClockSource ( ICM_20948_PWR_MGMT_1_CLKSEL_e source ); // Choose clock source
61-
ICM_20948_Status_e checkID ( void ); // Return 'ICM_20948_Stat_Ok' if whoami matches ICM_20948_WHOAMI
62-
63-
bool dataReady ( void ); // Returns 'true' if data is ready
64-
uint8_t getWhoAmI ( void ); // Return whoami in out prarmeter
65-
bool isConnected ( void ); // Returns true if communications with the device are sucessful
55+
ICM_20948_Status_e setBank(uint8_t bank); // Sets the bank
56+
ICM_20948_Status_e swReset(void); // Performs a SW reset
57+
ICM_20948_Status_e sleep(bool on = false); // Set sleep mode for the chip
58+
ICM_20948_Status_e lowPower(bool on = true); // Set low power mode for the chip
59+
ICM_20948_Status_e setClockSource(ICM_20948_PWR_MGMT_1_CLKSEL_e source); // Choose clock source
60+
ICM_20948_Status_e checkID(void); // Return 'ICM_20948_Stat_Ok' if whoami matches ICM_20948_WHOAMI
6661

62+
bool dataReady(void); // Returns 'true' if data is ready
63+
uint8_t getWhoAmI(void); // Return whoami in out prarmeter
64+
bool isConnected(void); // Returns true if communications with the device are sucessful
6765

6866
// Internal Sensor Options
69-
ICM_20948_Status_e setSampleMode ( uint8_t sensor_id_bm, uint8_t lp_config_cycle_mode ); // Use to set accel, gyro, and I2C master into cycled or continuous modes
70-
ICM_20948_Status_e setFullScale ( uint8_t sensor_id_bm, ICM_20948_fss_t fss );
71-
ICM_20948_Status_e setDLPFcfg ( uint8_t sensor_id_bm, ICM_20948_dlpcfg_t cfg );
72-
ICM_20948_Status_e enableDLPF ( uint8_t sensor_id_bm, bool enable );
73-
ICM_20948_Status_e setSampleRate ( uint8_t sensor_id_bm, ICM_20948_smplrt_t smplrt );
67+
ICM_20948_Status_e setSampleMode(uint8_t sensor_id_bm, uint8_t lp_config_cycle_mode); // Use to set accel, gyro, and I2C master into cycled or continuous modes
68+
ICM_20948_Status_e setFullScale(uint8_t sensor_id_bm, ICM_20948_fss_t fss);
69+
ICM_20948_Status_e setDLPFcfg(uint8_t sensor_id_bm, ICM_20948_dlpcfg_t cfg);
70+
ICM_20948_Status_e enableDLPF(uint8_t sensor_id_bm, bool enable);
71+
ICM_20948_Status_e setSampleRate(uint8_t sensor_id_bm, ICM_20948_smplrt_t smplrt);
7472

7573
// Interrupts on INT and FSYNC Pins
76-
ICM_20948_Status_e clearInterrupts ( void );
77-
78-
ICM_20948_Status_e cfgIntActiveLow ( bool active_low );
79-
ICM_20948_Status_e cfgIntOpenDrain ( bool open_drain );
80-
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
82-
ICM_20948_Status_e cfgFsyncActiveLow ( bool active_low );
83-
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
84-
85-
ICM_20948_Status_e intEnableI2C ( bool enable );
86-
ICM_20948_Status_e intEnableDMP ( bool enable );
87-
ICM_20948_Status_e intEnablePLL ( bool enable );
88-
ICM_20948_Status_e intEnableWOM ( bool enable );
89-
ICM_20948_Status_e intEnableWOF ( bool enable );
90-
ICM_20948_Status_e intEnableRawDataReady ( bool enable );
91-
ICM_20948_Status_e intEnableOverflowFIFO ( uint8_t bm_enable );
92-
ICM_20948_Status_e intEnableWatermarkFIFO ( uint8_t bm_enable );
74+
ICM_20948_Status_e clearInterrupts(void);
75+
76+
ICM_20948_Status_e cfgIntActiveLow(bool active_low);
77+
ICM_20948_Status_e cfgIntOpenDrain(bool open_drain);
78+
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
80+
ICM_20948_Status_e cfgFsyncActiveLow(bool active_low);
81+
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
82+
83+
ICM_20948_Status_e intEnableI2C(bool enable);
84+
ICM_20948_Status_e intEnableDMP(bool enable);
85+
ICM_20948_Status_e intEnablePLL(bool enable);
86+
ICM_20948_Status_e intEnableWOM(bool enable);
87+
ICM_20948_Status_e intEnableWOF(bool enable);
88+
ICM_20948_Status_e intEnableRawDataReady(bool enable);
89+
ICM_20948_Status_e intEnableOverflowFIFO(uint8_t bm_enable);
90+
ICM_20948_Status_e intEnableWatermarkFIFO(uint8_t bm_enable);
9391

9492
// Interface Options
95-
ICM_20948_Status_e i2cMasterPassthrough ( bool passthrough = true );
96-
ICM_20948_Status_e i2cMasterEnable ( bool enable = true );
97-
ICM_20948_Status_e i2cMasterConfigureSlave ( uint8_t slave, uint8_t addr, uint8_t reg, uint8_t len, bool Rw = true, bool enable = true, bool data_only = false, bool grp = false, bool swap = false );
98-
99-
ICM_20948_Status_e i2cMasterSLV4Transaction( uint8_t addr, uint8_t reg, uint8_t* data, uint8_t len, bool Rw, bool send_reg_addr = true );
100-
ICM_20948_Status_e i2cMasterSingleW ( uint8_t addr, uint8_t reg, uint8_t data );
101-
uint8_t i2cMasterSingleR ( uint8_t addr, uint8_t reg );
93+
ICM_20948_Status_e i2cMasterPassthrough(bool passthrough = true);
94+
ICM_20948_Status_e i2cMasterEnable(bool enable = true);
95+
ICM_20948_Status_e i2cMasterConfigureSlave(uint8_t slave, uint8_t addr, uint8_t reg, uint8_t len, bool Rw = true, bool enable = true, bool data_only = false, bool grp = false, bool swap = false);
10296

97+
ICM_20948_Status_e i2cMasterSLV4Transaction(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len, bool Rw, bool send_reg_addr = true);
98+
ICM_20948_Status_e i2cMasterSingleW(uint8_t addr, uint8_t reg, uint8_t data);
99+
uint8_t i2cMasterSingleR(uint8_t addr, uint8_t reg);
103100

104101
// Default Setup
105-
ICM_20948_Status_e startupDefault ( void );
106-
virtual ICM_20948_Status_e startupMagnetometer ( void );
107-
virtual ICM_20948_Status_e getMagnetometerData ( ICM_20948_AGMT_t* pagmt );
108-
102+
ICM_20948_Status_e startupDefault(void);
103+
virtual ICM_20948_Status_e startupMagnetometer(void);
104+
virtual ICM_20948_Status_e getMagnetometerData(ICM_20948_AGMT_t *pagmt);
109105

110106
// direct read/write
111-
ICM_20948_Status_e read ( uint8_t reg, uint8_t* pdata, uint32_t len);
112-
ICM_20948_Status_e write ( uint8_t reg, uint8_t* pdata, uint32_t len);
107+
ICM_20948_Status_e read(uint8_t reg, uint8_t *pdata, uint32_t len);
108+
ICM_20948_Status_e write(uint8_t reg, uint8_t *pdata, uint32_t len);
113109
};
114110

115-
116111
// I2C
117112

118113
// Forward declarations of TwoWire and Wire for board/variant combinations that don't have a default 'SPI'
119114
class TwoWire;
120115
extern TwoWire Wire;
121116

122-
class ICM_20948_I2C : public ICM_20948 {
117+
class ICM_20948_I2C : public ICM_20948
118+
{
123119
private:
124120
protected:
125121
public:
126-
TwoWire* _i2c;
127-
uint8_t _addr;
128-
uint8_t _ad0;
129-
bool _ad0val;
130-
ICM_20948_Serif_t _serif;
122+
TwoWire *_i2c;
123+
uint8_t _addr;
124+
uint8_t _ad0;
125+
bool _ad0val;
126+
ICM_20948_Serif_t _serif;
131127

132128
ICM_20948_I2C(); // Constructor
133129

134-
virtual ICM_20948_Status_e begin(TwoWire &wirePort = Wire, bool ad0val = true, uint8_t ad0pin = ICM_20948_ARD_UNUSED_PIN);
135-
virtual ICM_20948_Status_e readMag( uint8_t reg, uint8_t* pdata, uint8_t len );
136-
virtual ICM_20948_Status_e writeMag( uint8_t reg, uint8_t* pdata, uint8_t len );
130+
virtual ICM_20948_Status_e begin(TwoWire &wirePort = Wire, bool ad0val = true, uint8_t ad0pin = ICM_20948_ARD_UNUSED_PIN);
131+
virtual ICM_20948_Status_e readMag(uint8_t reg, uint8_t *pdata, uint8_t len);
132+
virtual ICM_20948_Status_e writeMag(uint8_t reg, uint8_t *pdata, uint8_t len);
137133

138-
ICM_20948_Status_e startupMagnetometer( void );
139-
ICM_20948_Status_e magWhoIAm( void );
140-
bool magIsConnected( void );
141-
ICM_20948_Status_e getMagnetometerData ( ICM_20948_AGMT_t* pagmt );
134+
ICM_20948_Status_e startupMagnetometer(void);
135+
ICM_20948_Status_e magWhoIAm(void);
136+
bool magIsConnected(void);
137+
ICM_20948_Status_e getMagnetometerData(ICM_20948_AGMT_t *pagmt);
142138
};
143139

144-
145-
146140
// SPI
147141
#define ICM_20948_SPI_DEFAULT_FREQ 7000000
148142
#define ICM_20948_SPI_DEFAULT_ORDER MSBFIRST
@@ -152,22 +146,19 @@ class ICM_20948_I2C : public ICM_20948 {
152146
class SPIClass;
153147
extern SPIClass SPI;
154148

155-
class ICM_20948_SPI : public ICM_20948 {
149+
class ICM_20948_SPI : public ICM_20948
150+
{
156151
private:
157152
protected:
158153
public:
159-
SPIClass* _spi;
160-
SPISettings _spisettings;
161-
uint8_t _cs;
162-
ICM_20948_Serif_t _serif;
154+
SPIClass *_spi;
155+
SPISettings _spisettings;
156+
uint8_t _cs;
157+
ICM_20948_Serif_t _serif;
163158

164159
ICM_20948_SPI(); // Constructor
165160

166-
ICM_20948_Status_e begin( uint8_t csPin, SPIClass &spiPort = SPI, uint32_t SPIFreq = ICM_20948_SPI_DEFAULT_FREQ );
161+
ICM_20948_Status_e begin(uint8_t csPin, SPIClass &spiPort = SPI, uint32_t SPIFreq = ICM_20948_SPI_DEFAULT_FREQ);
167162
};
168163

169-
170-
171-
172-
173164
#endif /* _ICM_20948_H_ */

0 commit comments

Comments
 (0)