Skip to content

Commit 9e3665f

Browse files
Merge pull request #413 from espressif/fix/icm42670_bugs
Fix/icm42670 bugs
2 parents b5091df + dcd944c commit 9e3665f

File tree

8 files changed

+21
-24
lines changed

8 files changed

+21
-24
lines changed

bsp/m5stack_core_s3/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ idf_component_register(
22
SRCS "m5stack_core_s3.c" "m5stack_core_s3_idf5.c"
33
INCLUDE_DIRS "include"
44
PRIV_INCLUDE_DIRS "priv_include"
5-
REQUIRES esp_driver_i2c esp_driver_i2s esp_driver_gpio esp_driver_sdmmc spiffs
6-
PRIV_REQUIRES fatfs esp_lcd esp_driver_spi
5+
REQUIRES esp_driver_i2s esp_driver_gpio esp_driver_sdmmc spiffs
6+
PRIV_REQUIRES fatfs esp_lcd esp_driver_spi esp_driver_i2c
77
)

bsp/m5stack_core_s3/include/bsp/m5stack_core_s3.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
#include "sdkconfig.h"
1515
#include "driver/gpio.h"
16-
#include "driver/i2c_master.h"
1716
#include "driver/i2s_std.h"
1817
#include "driver/sdmmc_host.h"
1918
#include "soc/usb_pins.h"

bsp/m5stack_core_s3/m5stack_core_s3.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
*/
66

77
#include "driver/gpio.h"
8+
#include "driver/i2c_master.h"
89
#include "driver/spi_master.h"
10+
#include "driver/sdspi_host.h"
911
#include "esp_err.h"
1012
#include "esp_log.h"
1113
#include "esp_check.h"
@@ -14,7 +16,6 @@
1416
#include "esp_lcd_panel_vendor.h"
1517
#include "esp_lcd_panel_ops.h"
1618
#include "esp_vfs_fat.h"
17-
#include "driver/sdspi_host.h"
1819

1920
#include "bsp/m5stack_core_s3.h"
2021
#include "bsp/display.h"
@@ -49,7 +50,7 @@ sdmmc_card_t *bsp_sdcard = NULL; // Global SD card handler
4950
* @brief I2C handle for BSP usage
5051
*
5152
* You can call i2c_master_get_bus_handle(BSP_I2C_NUM, i2c_master_bus_handle_t *ret_handle)
52-
* from #include "esp_private/i2c_platforma.h"
53+
* from #include "esp_private/i2c_platform.h"
5354
*/
5455
static i2c_master_bus_handle_t i2c_handle = NULL;
5556
static bool i2c_initialized = false;
@@ -68,21 +69,21 @@ esp_err_t bsp_i2c_init(void)
6869
.i2c_port = BSP_I2C_NUM,
6970
.sda_io_num = BSP_I2C_SDA,
7071
.scl_io_num = BSP_I2C_SCL,
71-
.clk_source = 1,
72+
.clk_source = I2C_CLK_SRC_DEFAULT,
7273
};
7374
BSP_ERROR_CHECK_RETURN_ERR(i2c_new_master_bus(&i2c_config, &i2c_handle));
7475

7576
// AXP2101 and AW9523 are managed by this BSP
7677
const i2c_device_config_t axp2101_config = {
7778
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
7879
.device_address = BSP_AXP2101_ADDR,
79-
.scl_speed_hz = 400000,
80+
.scl_speed_hz = CONFIG_BSP_I2C_CLK_SPEED_HZ,
8081
};
8182
BSP_ERROR_CHECK_RETURN_ERR(i2c_master_bus_add_device(i2c_handle, &axp2101_config, &axp2101_h));
8283
const i2c_device_config_t aw9523_config = {
8384
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
8485
.device_address = BSP_AW9523_ADDR,
85-
.scl_speed_hz = 400000,
86+
.scl_speed_hz = CONFIG_BSP_I2C_CLK_SPEED_HZ,
8687
};
8788
BSP_ERROR_CHECK_RETURN_ERR(i2c_master_bus_add_device(i2c_handle, &aw9523_config, &aw9523_h));
8889

@@ -435,7 +436,7 @@ esp_err_t bsp_touch_new(const bsp_touch_config_t *config, esp_lcd_touch_handle_t
435436
};
436437
esp_lcd_panel_io_handle_t tp_io_handle = NULL;
437438
esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_FT5x06_CONFIG();
438-
tp_io_config.scl_speed_hz = 400000; // This parameter was introduce together with I2C Driver-NG in IDF v5.2
439+
tp_io_config.scl_speed_hz = CONFIG_BSP_I2C_CLK_SPEED_HZ; // This parameter was introduced together with I2C Driver-NG in IDF v5.2
439440
ESP_RETURN_ON_ERROR(esp_lcd_new_panel_io_i2c(i2c_handle, &tp_io_config, &tp_io_handle), TAG, "");
440441
return esp_lcd_touch_new_i2c_ft5x06(tp_io_handle, &tp_cfg, ret_touch);
441442
}

components/icm42670/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# ICM42607/ICM42670 6-Axis MotionTracking (Accelerometer and Gyroscope)
22

33
[![Component Registry](https://components.espressif.com/components/espressif/icm42670/badge.svg)](https://components.espressif.com/components/espressif/icm42670)
4+
![maintenance-status](https://img.shields.io/badge/maintenance-passively--maintained-yellowgreen.svg)
45

56
C driver for Invensense ICM42607/ICM42670 6-axis gyroscope and accelerometer based on I2C communication.
67

@@ -27,6 +28,4 @@ This driver, along with many other components from this repository, can be used
2728
Another option is to manually create a `idf_component.yml` file. You can find more about using .yml files for components from [Espressif's documentation](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-component-manager.html).
2829

2930
## See Also
30-
* [MPU6050 datasheet](https://invensense.tdk.com/products/motion-tracking/6-axis/icm-42670-p/)
31-
32-
31+
* [ICM42670 datasheet](https://invensense.tdk.com/products/motion-tracking/6-axis/icm-42670-p/)

components/icm42670/icm42670.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ esp_err_t icm42670_get_acce_sensitivity(icm42670_handle_t sensor, float *sensiti
186186

187187
ret = icm42670_read(sensor, ICM42670_ACCEL_CONFIG0, &acce_fs, 1);
188188
if (ret == ESP_OK) {
189-
acce_fs = (acce_fs >> 3) & 0x03;
189+
acce_fs = (acce_fs >> 5) & 0x03;
190190
switch (acce_fs) {
191191
case ACCE_FS_16G:
192192
*sensitivity = ACCE_FS_16G_SENSITIVITY;
@@ -215,9 +215,9 @@ esp_err_t icm42670_get_gyro_sensitivity(icm42670_handle_t sensor, float *sensiti
215215

216216
*sensitivity = 0;
217217

218-
ret = icm42670_read(sensor, ICM42670_ACCEL_CONFIG0, &gyro_fs, 1);
218+
ret = icm42670_read(sensor, ICM42670_GYRO_CONFIG0, &gyro_fs, 1);
219219
if (ret == ESP_OK) {
220-
gyro_fs = (gyro_fs >> 3) & 0x03;
220+
gyro_fs = (gyro_fs >> 5) & 0x03;
221221
switch (gyro_fs) {
222222
case GYRO_FS_2000DPS:
223223
*sensitivity = GYRO_FS_2000_SENSITIVITY;
@@ -326,7 +326,7 @@ esp_err_t icm42670_get_temp_value(icm42670_handle_t sensor, float *value)
326326
ret = icm42670_get_temp_raw_value(sensor, &raw_value);
327327
ESP_RETURN_ON_ERROR(ret, TAG, "Get raw value error!");
328328

329-
*value = (raw_value / 128) + 25;
329+
*value = ((float)raw_value / 128.0) + 25.0;
330330

331331
return ESP_OK;
332332
}

components/icm42670/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "2.0.0"
1+
version: "2.0.1"
22
description: I2C driver for ICM 42670 6-Axis MotionTracking
33
url: https://github.com/espressif/esp-bsp/tree/master/components/icm42670
44
dependencies:

components/icm42670/test_apps/main/test_app_icm42670.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ TEST_CASE("Sensor icm42670 test", "[icm42670]")
9191
vTaskDelay(10); // Give FreeRTOS some time to free its resources
9292
}
9393

94-
#define TEST_MEMORY_LEAK_THRESHOLD (400)
94+
#define TEST_MEMORY_LEAK_THRESHOLD (500)
9595

9696
void setUp(void)
9797
{
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1+
# This file was generated using idf.py save-defconfig. It can be edited manually.
2+
# Espressif IoT Development Framework (ESP-IDF) 5.4.0 Project Minimal Configuration
3+
#
14
CONFIG_IDF_TARGET="esp32s3"
2-
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
35
CONFIG_COMPILER_OPTIMIZATION_PERF=y
4-
CONFIG_SPIRAM=y
5-
CONFIG_SPIRAM_MODE_OCT=y
6-
CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y
7-
CONFIG_SPIRAM_RODATA=y
8-
CONFIG_SPIRAM_SPEED_80M=y
96
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
7+
CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y
108
CONFIG_ESP_TASK_WDT_EN=n
119
CONFIG_FREERTOS_HZ=1000
1210
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=4096

0 commit comments

Comments
 (0)