ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
icm20689.h
Go to the documentation of this file.
1#pragma once
2
7
8namespace esphome::icm20689 {
9
10// Register map
11static constexpr uint8_t ICM20689_REG_WHO_AM_I = 0x75;
12static constexpr uint8_t ICM20689_REG_PWR_MGMT_1 = 0x6B;
13static constexpr uint8_t ICM20689_REG_USER_CTRL = 0x6A;
14static constexpr uint8_t ICM20689_REG_GYRO_CONFIG = 0x1B;
15static constexpr uint8_t ICM20689_REG_ACCEL_CONFIG = 0x1C;
16static constexpr uint8_t ICM20689_REG_ACCEL_XOUT_H = 0x3B;
17static constexpr uint8_t ICM20689_READ_BIT = 0x80;
18static constexpr uint8_t ICM20689_WHO_AM_I_VALUE = 0x98;
19static constexpr uint8_t ICM20689_SOFT_RESET = 0x81; // PWR_MGMT_1: DEVICE_RESET | CLKSEL=1 (datasheet 4.20)
20static constexpr uint8_t ICM20689_CLKSEL_AUTO = 0x01; // PWR_MGMT_1: SLEEP=0, CLKSEL=1 (auto-select best clock)
21static constexpr uint8_t ICM20689_I2C_IF_DIS = 0x10; // USER_CTRL bit 4
22
23// Accelerometer range options: FS_SEL bits [4:3] of ACCEL_CONFIG
30
31// Gyroscope range options: FS_SEL bits [4:3] of GYRO_CONFIG
38
40 public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW,
41 spi::CLOCK_PHASE_LEADING, spi::DATA_RATE_1MHZ> {
42 public:
43 void setup() override;
44 void dump_config() override;
45
48
49 template<typename F> void add_temperature_listener(F &&callback) {
50 this->temperature_callback_.add(std::forward<F>(callback));
51 }
52
53 protected:
54 bool update_data(motion::MotionData &data) override;
55
56 void write_register_(uint8_t reg, uint8_t value);
57 // Reads len bytes starting at reg in one CS-low transaction.
58 void read_registers_(uint8_t reg, uint8_t *data, size_t len);
59
62
64};
65
66} // namespace esphome::icm20689
void write_register_(uint8_t reg, uint8_t value)
Definition icm20689.cpp:21
bool update_data(motion::MotionData &data) override
Definition icm20689.cpp:88
void set_gyro_range(ICM20689GyroRange range)
Definition icm20689.h:47
void read_registers_(uint8_t reg, uint8_t *data, size_t len)
Definition icm20689.cpp:28
void add_temperature_listener(F &&callback)
Definition icm20689.h:49
ICM20689AccelRange accel_range_
Definition icm20689.h:60
LazyCallbackManager< void(float)> temperature_callback_
Definition icm20689.h:63
void set_accel_range(ICM20689AccelRange range)
Definition icm20689.h:46
The SPIDevice is what components using the SPI will create.
Definition spi.h:450
Range range
Definition msa3xx.h:0
const void size_t len
Definition hal.h:68