|
1 | 1 | /* |
2 | | - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD |
| 2 | + * SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD |
3 | 3 | * |
4 | 4 | * SPDX-License-Identifier: Apache-2.0 |
5 | 5 | */ |
6 | 6 |
|
7 | 7 | #pragma once |
8 | 8 |
|
9 | 9 | #ifdef __cplusplus |
10 | | -extern "C" { |
| 10 | +extern "C" |
| 11 | +{ |
11 | 12 | #endif |
12 | 13 |
|
13 | 14 | #include "driver/i2c_master.h" |
14 | 15 | #include "driver/spi_master.h" |
15 | 16 |
|
16 | | -#define ICM42670_I2C_ADDRESS 0x68 /*!< I2C address with AD0 pin low */ |
17 | | -#define ICM42670_I2C_ADDRESS_1 0x69 /*!< I2C address with AD0 pin high */ |
18 | | - |
19 | | -#define ICM42670_SIGNAL_PATH_RESET 0x02 /*!< Signal path reset */ |
20 | | -#define ICM42670_INT_CONFIG 0x06 /*!< Interrupt configuration */ |
21 | | -#define ICM42670_PWR_MGMT0 0x1F /*!< Power management 0 */ |
22 | | -#define ICM42670_APEX_CONFIG0 0x25 /*!< APEX configuration 0 */ |
23 | | -#define ICM42670_APEX_CONFIG1 0x26 /*!< APEX configuration 1 */ |
24 | | -#define ICM42670_WOM_CONFIG 0x27 /*!< Wake on Motion configuration */ |
25 | | -#define ICM42670_INT_SOURCE0 0x2B /*!< Interrupt source 0 */ |
26 | | -#define ICM42670_INT_SOURCE1 0x2C /*!< Interrupt source 1 */ |
27 | | -#define ICM42670_INTF_CONFIG0 0x35 /*!< Interface configuration 0 */ |
28 | | -#define ICM42670_INTF_CONFIG1 0x36 /*!< Interface configuration 1 */ |
29 | | -#define ICM42670_INT_STATUS 0x3A /*!< Interrupt status */ |
30 | | -#define ICM42670_INT_STATUS2 0x3B /*!< Interrupt status 2 */ |
31 | | -#define ICM42670_INT_STATUS3 0x3C /*!< Interrupt status 3 */ |
32 | | -#define ICM42670_BLK_SEL_W 0x79 /*! Select MREG1, MREG2, or MREG3 bank for writing */ |
33 | | -#define ICM42670_MADDR_W 0x7A /*! Set MREG* register address for writing */ |
34 | | -#define ICM42670_M_W 0x7B /*! Write MREG* register value */ |
35 | | -#define ICM42670_BLK_SEL_R 0x7C /*! Select MREG1, MREG2, or MREG3 bank for reading */ |
36 | | -#define ICM42670_MADDR_R 0x7D /*! Set MREG* register address for reading */ |
37 | | -#define ICM42670_M_R 0x7E /*! Read MREG* register value */ |
| 17 | +#define ICM42670_I2C_ADDRESS 0x68 /*!< I2C address with AD0 pin low */ |
| 18 | +#define ICM42670_I2C_ADDRESS_1 0x69 /*!< I2C address with AD0 pin high */ |
| 19 | + |
| 20 | +#define ICM42670_SIGNAL_PATH_RESET 0x02 /*!< Signal path reset */ |
| 21 | +#define ICM42670_INT_CONFIG 0x06 /*!< Interrupt configuration */ |
| 22 | +#define ICM42670_PWR_MGMT0 0x1F /*!< Power management 0 */ |
| 23 | +#define ICM42670_APEX_CONFIG0 0x25 /*!< APEX configuration 0 */ |
| 24 | +#define ICM42670_APEX_CONFIG1 0x26 /*!< APEX configuration 1 */ |
| 25 | +#define ICM42670_WOM_CONFIG 0x27 /*!< Wake on Motion configuration */ |
| 26 | +#define ICM42670_INT_SOURCE0 0x2B /*!< Interrupt source 0 */ |
| 27 | +#define ICM42670_INT_SOURCE1 0x2C /*!< Interrupt source 1 */ |
| 28 | +#define ICM42670_INTF_CONFIG0 0x35 /*!< Interface configuration 0 */ |
| 29 | +#define ICM42670_INTF_CONFIG1 0x36 /*!< Interface configuration 1 */ |
| 30 | +#define ICM42670_INT_STATUS 0x3A /*!< Interrupt status */ |
| 31 | +#define ICM42670_INT_STATUS2 0x3B /*!< Interrupt status 2 */ |
| 32 | +#define ICM42670_INT_STATUS3 0x3C /*!< Interrupt status 3 */ |
| 33 | +#define ICM42670_BLK_SEL_W 0x79 /*! Select MREG1, MREG2, or MREG3 bank for writing */ |
| 34 | +#define ICM42670_MADDR_W 0x7A /*! Set MREG* register address for writing */ |
| 35 | +#define ICM42670_M_W 0x7B /*! Write MREG* register value */ |
| 36 | +#define ICM42670_BLK_SEL_R 0x7C /*! Select MREG1, MREG2, or MREG3 bank for reading */ |
| 37 | +#define ICM42670_MADDR_R 0x7D /*! Set MREG* register address for reading */ |
| 38 | +#define ICM42670_M_R 0x7E /*! Read MREG* register value */ |
38 | 39 |
|
39 | 40 | // MREG1 Registers |
40 | | -#define ICM42670_MREG1_INT_CONFIG0 0x04 /*!< Interrupt configuration 0 */ |
41 | | -#define ICM42670_MREG1_INT_CONFIG1 0x05 /*!< Interrupt configuration 1 */ |
42 | | -#define ICM42670_MREG1_ACCEL_WOM_X_THR 0x4B /*!< WOM X threshold */ |
43 | | -#define ICM42670_MREG1_ACCEL_WOM_Y_THR 0x4C /*!< WOM Y threshold */ |
44 | | -#define ICM42670_MREG1_ACCEL_WOM_Z_THR 0x4D /*!< WOM Z threshold */ |
45 | | - |
| 41 | +#define ICM42670_MREG1_INT_CONFIG0 0x04 /*!< Interrupt configuration 0 */ |
| 42 | +#define ICM42670_MREG1_INT_CONFIG1 0x05 /*!< Interrupt configuration 1 */ |
| 43 | +#define ICM42670_MREG1_ACCEL_WOM_X_THR 0x4B /*!< WOM X threshold */ |
| 44 | +#define ICM42670_MREG1_ACCEL_WOM_Y_THR 0x4C /*!< WOM Y threshold */ |
| 45 | +#define ICM42670_MREG1_ACCEL_WOM_Z_THR 0x4D /*!< WOM Z threshold */ |
46 | 46 |
|
47 | 47 | typedef enum { |
48 | | - ACCE_FS_16G = 0, /*!< Accelerometer full scale range is +/- 16g */ |
49 | | - ACCE_FS_8G = 1, /*!< Accelerometer full scale range is +/- 8g */ |
50 | | - ACCE_FS_4G = 2, /*!< Accelerometer full scale range is +/- 4g */ |
51 | | - ACCE_FS_2G = 3, /*!< Accelerometer full scale range is +/- 2g */ |
52 | | - } icm42670_acce_fs_t; |
| 48 | + ACCE_FS_16G = 0, /*!< Accelerometer full scale range is +/- 16g */ |
| 49 | + ACCE_FS_8G = 1, /*!< Accelerometer full scale range is +/- 8g */ |
| 50 | + ACCE_FS_4G = 2, /*!< Accelerometer full scale range is +/- 4g */ |
| 51 | + ACCE_FS_2G = 3, /*!< Accelerometer full scale range is +/- 2g */ |
| 52 | +} icm42670_acce_fs_t; |
53 | 53 |
|
54 | 54 | typedef enum { |
55 | | - ACCE_PWR_OFF = 0, /*!< Accelerometer power off state */ |
56 | | - ACCE_PWR_ON = 1, /*!< Accelerometer power on state */ |
57 | | - ACCE_PWR_LOWPOWER = 2, /*!< Accelerometer low-power mode */ |
58 | | - ACCE_PWR_LOWNOISE = 3, /*!< Accelerometer low noise state */ |
59 | | - } icm42670_acce_pwr_t; |
| 55 | + ACCE_PWR_OFF = 0, /*!< Accelerometer power off state */ |
| 56 | + ACCE_PWR_ON = 1, /*!< Accelerometer power on state */ |
| 57 | + ACCE_PWR_LOWPOWER = 2, /*!< Accelerometer low-power mode */ |
| 58 | + ACCE_PWR_LOWNOISE = 3, /*!< Accelerometer low noise state */ |
| 59 | +} icm42670_acce_pwr_t; |
60 | 60 |
|
61 | 61 | typedef enum { |
62 | | - ACCE_ODR_1600HZ = 5, /*!< Accelerometer ODR 1.6 kHz */ |
63 | | - ACCE_ODR_800HZ = 6, /*!< Accelerometer ODR 800 Hz */ |
64 | | - ACCE_ODR_400HZ = 7, /*!< Accelerometer ODR 400 Hz */ |
65 | | - ACCE_ODR_200HZ = 8, /*!< Accelerometer ODR 200 Hz */ |
66 | | - ACCE_ODR_100HZ = 9, /*!< Accelerometer ODR 100 Hz */ |
67 | | - ACCE_ODR_50HZ = 10, /*!< Accelerometer ODR 50 Hz */ |
68 | | - ACCE_ODR_25HZ = 11, /*!< Accelerometer ODR 25 Hz */ |
69 | | - ACCE_ODR_12_5HZ = 12, /*!< Accelerometer ODR 12.5 Hz */ |
70 | | - ACCE_ODR_6_25HZ = 13, /*!< Accelerometer ODR 6.25 Hz */ |
71 | | - ACCE_ODR_3_125HZ = 14, /*!< Accelerometer ODR 3.125 Hz */ |
72 | | - ACCE_ODR_1_5625HZ = 15, /*!< Accelerometer ODR 1.5625 Hz */ |
73 | | - } icm42670_acce_odr_t; |
| 62 | + ACCE_ODR_1600HZ = 5, /*!< Accelerometer ODR 1.6 kHz */ |
| 63 | + ACCE_ODR_800HZ = 6, /*!< Accelerometer ODR 800 Hz */ |
| 64 | + ACCE_ODR_400HZ = 7, /*!< Accelerometer ODR 400 Hz */ |
| 65 | + ACCE_ODR_200HZ = 8, /*!< Accelerometer ODR 200 Hz */ |
| 66 | + ACCE_ODR_100HZ = 9, /*!< Accelerometer ODR 100 Hz */ |
| 67 | + ACCE_ODR_50HZ = 10, /*!< Accelerometer ODR 50 Hz */ |
| 68 | + ACCE_ODR_25HZ = 11, /*!< Accelerometer ODR 25 Hz */ |
| 69 | + ACCE_ODR_12_5HZ = 12, /*!< Accelerometer ODR 12.5 Hz */ |
| 70 | + ACCE_ODR_6_25HZ = 13, /*!< Accelerometer ODR 6.25 Hz */ |
| 71 | + ACCE_ODR_3_125HZ = 14, /*!< Accelerometer ODR 3.125 Hz */ |
| 72 | + ACCE_ODR_1_5625HZ = 15, /*!< Accelerometer ODR 1.5625 Hz */ |
| 73 | +} icm42670_acce_odr_t; |
74 | 74 |
|
75 | 75 | typedef enum { |
76 | | - GYRO_FS_2000DPS = 0, /*!< Gyroscope full scale range is +/- 2000 degree per sencond */ |
77 | | - GYRO_FS_1000DPS = 1, /*!< Gyroscope full scale range is +/- 1000 degree per sencond */ |
78 | | - GYRO_FS_500DPS = 2, /*!< Gyroscope full scale range is +/- 500 degree per sencond */ |
79 | | - GYRO_FS_250DPS = 3, /*!< Gyroscope full scale range is +/- 250 degree per sencond */ |
80 | | - } icm42670_gyro_fs_t; |
| 76 | + GYRO_FS_2000DPS = 0, /*!< Gyroscope full scale range is +/- 2000 degree per sencond */ |
| 77 | + GYRO_FS_1000DPS = 1, /*!< Gyroscope full scale range is +/- 1000 degree per sencond */ |
| 78 | + GYRO_FS_500DPS = 2, /*!< Gyroscope full scale range is +/- 500 degree per sencond */ |
| 79 | + GYRO_FS_250DPS = 3, /*!< Gyroscope full scale range is +/- 250 degree per sencond */ |
| 80 | +} icm42670_gyro_fs_t; |
81 | 81 |
|
82 | 82 | typedef enum { |
83 | | - GYRO_PWR_OFF = 0, /*!< Gyroscope power off state */ |
84 | | - GYRO_PWR_STANDBY = 1, /*!< Gyroscope power standby state */ |
85 | | - GYRO_PWR_LOWNOISE = 3, /*!< Gyroscope power low noise state */ |
86 | | - } icm42670_gyro_pwr_t; |
| 83 | + GYRO_PWR_OFF = 0, /*!< Gyroscope power off state */ |
| 84 | + GYRO_PWR_STANDBY = 1, /*!< Gyroscope power standby state */ |
| 85 | + GYRO_PWR_LOWNOISE = 3, /*!< Gyroscope power low noise state */ |
| 86 | +} icm42670_gyro_pwr_t; |
87 | 87 |
|
88 | 88 | typedef enum { |
89 | | - GYRO_ODR_1600HZ = 5, /*!< Gyroscope ODR 1.6 kHz */ |
90 | | - GYRO_ODR_800HZ = 6, /*!< Gyroscope ODR 800 Hz */ |
91 | | - GYRO_ODR_400HZ = 7, /*!< Gyroscope ODR 400 Hz */ |
92 | | - GYRO_ODR_200HZ = 8, /*!< Gyroscope ODR 200 Hz */ |
93 | | - GYRO_ODR_100HZ = 9, /*!< Gyroscope ODR 100 Hz */ |
94 | | - GYRO_ODR_50HZ = 10, /*!< Gyroscope ODR 50 Hz */ |
95 | | - GYRO_ODR_25HZ = 11, /*!< Gyroscope ODR 25 Hz */ |
96 | | - GYRO_ODR_12_5HZ = 12, /*!< Gyroscope ODR 12.5 Hz */ |
97 | | - } icm42670_gyro_odr_t; |
| 89 | + GYRO_ODR_1600HZ = 5, /*!< Gyroscope ODR 1.6 kHz */ |
| 90 | + GYRO_ODR_800HZ = 6, /*!< Gyroscope ODR 800 Hz */ |
| 91 | + GYRO_ODR_400HZ = 7, /*!< Gyroscope ODR 400 Hz */ |
| 92 | + GYRO_ODR_200HZ = 8, /*!< Gyroscope ODR 200 Hz */ |
| 93 | + GYRO_ODR_100HZ = 9, /*!< Gyroscope ODR 100 Hz */ |
| 94 | + GYRO_ODR_50HZ = 10, /*!< Gyroscope ODR 50 Hz */ |
| 95 | + GYRO_ODR_25HZ = 11, /*!< Gyroscope ODR 25 Hz */ |
| 96 | + GYRO_ODR_12_5HZ = 12, /*!< Gyroscope ODR 12.5 Hz */ |
| 97 | +} icm42670_gyro_odr_t; |
98 | 98 |
|
99 | 99 | typedef struct { |
100 | | - icm42670_acce_fs_t acce_fs; /*!< Accelerometer full scale range */ |
101 | | - icm42670_acce_odr_t acce_odr; /*!< Accelerometer ODR selection */ |
102 | | - icm42670_gyro_fs_t gyro_fs; /*!< Gyroscope full scale range */ |
103 | | - icm42670_gyro_odr_t gyro_odr; /*!< Gyroscope ODR selection */ |
| 100 | + icm42670_acce_fs_t acce_fs; /*!< Accelerometer full scale range */ |
| 101 | + icm42670_acce_odr_t acce_odr; /*!< Accelerometer ODR selection */ |
| 102 | + icm42670_gyro_fs_t gyro_fs; /*!< Gyroscope full scale range */ |
| 103 | + icm42670_gyro_odr_t gyro_odr; /*!< Gyroscope ODR selection */ |
104 | 104 | } icm42670_cfg_t; |
105 | 105 |
|
106 | 106 | typedef struct { |
107 | | - int16_t x; |
108 | | - int16_t y; |
109 | | - int16_t z; |
| 107 | + int16_t x; |
| 108 | + int16_t y; |
| 109 | + int16_t z; |
110 | 110 | } icm42670_raw_value_t; |
111 | 111 |
|
112 | 112 | typedef struct { |
113 | | - float x; |
114 | | - float y; |
115 | | - float z; |
| 113 | + float x; |
| 114 | + float y; |
| 115 | + float z; |
116 | 116 | } icm42670_value_t; |
117 | 117 |
|
118 | 118 | typedef struct { |
119 | | - float roll; |
120 | | - float pitch; |
| 119 | + float roll; |
| 120 | + float pitch; |
121 | 121 | } complimentary_angle_t; |
122 | 122 |
|
123 | 123 | typedef void *icm42670_handle_t; |
@@ -372,7 +372,7 @@ esp_err_t icm42670_read_mreg_register(icm42670_handle_t sensor, uint8_t mreg, ui |
372 | 372 | * - ESP_FAIL Fail |
373 | 373 | */ |
374 | 374 | esp_err_t icm42670_write_mreg_register(icm42670_handle_t sensor, uint8_t mreg, uint8_t reg, |
375 | | - uint8_t val); |
| 375 | + uint8_t val); |
376 | 376 |
|
377 | 377 | #ifdef __cplusplus |
378 | 378 | } |
|
0 commit comments