Arduino TKJHAT
Arduino library for Pico HAT extension board
Loading...
Searching...
No Matches
ICM42670.h
1#ifndef ICM42670_H
2#define ICM42670_H
3
4#include <Arduino.h>
5#include <Wire.h>
6
28
29class ICM42670 {
30public:
31
36 ICM42670(); // default uses Wire
37 ICM42670(TwoWire& w); // optional I2C bus
38
45 bool begin();
46
47 bool detectAddress();
48
55 bool reset();
56
57 bool readWhoAmI(uint8_t& who);
58
59 void calibrateAccel(float *dest1);
60 void calibrateGyro(float *dest2);
61
71 bool startAccel(uint16_t odr_hz, uint16_t fsr_g);
72
82 bool startGyro(uint16_t odr_hz, uint16_t fsr_dps);
83
88 bool readSensorData(float& ax, float& ay, float& az,
89 float& gx, float& gy, float& gz, float& t);
90
96
111
112private:
113 TwoWire* wire;
114 uint8_t address;
115 float aRes;
116 float gRes;
117
118 bool readByte(uint8_t reg, uint8_t& value);
119 bool readBytes(uint8_t reg, uint8_t* buffer, size_t len);
120 bool writeByte(uint8_t reg, uint8_t value);
121};
122
128
129#endif
bool startAccel(uint16_t odr_hz, uint16_t fsr_g)
Start the accelerometer.
bool begin()
Initialize the IMU.
bool startGyro(uint16_t odr_hz, uint16_t fsr_dps)
Start the gyroscope.
bool enableAccelGyroLnMode(void)
Enable low-noise mode for both accelerometer and gyroscope.
bool readSensorData(float &ax, float &ay, float &az, float &gx, float &gy, float &gz, float &t)
Enable low-noise mode for both accelerometer and gyroscope.
bool reset()
Perform a soft reset of the IMU.
bool startWithDefaultValues(void)
Start IMU with SDK default settings and enable LN mode.
ICM42670()
Construct a new ICM42670 object Default constructor uses the default Wire I2C bus....