Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/icm42670 bugs #413

Merged
merged 2 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bsp/m5stack_core_s3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ idf_component_register(
SRCS "m5stack_core_s3.c" "m5stack_core_s3_idf5.c"
INCLUDE_DIRS "include"
PRIV_INCLUDE_DIRS "priv_include"
REQUIRES esp_driver_i2c esp_driver_i2s esp_driver_gpio esp_driver_sdmmc spiffs
PRIV_REQUIRES fatfs esp_lcd esp_driver_spi
REQUIRES esp_driver_i2s esp_driver_gpio esp_driver_sdmmc spiffs
PRIV_REQUIRES fatfs esp_lcd esp_driver_spi esp_driver_i2c
)
1 change: 0 additions & 1 deletion bsp/m5stack_core_s3/include/bsp/m5stack_core_s3.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

#include "sdkconfig.h"
#include "driver/gpio.h"
#include "driver/i2c_master.h"
#include "driver/i2s_std.h"
#include "driver/sdmmc_host.h"
#include "soc/usb_pins.h"
Expand Down
13 changes: 7 additions & 6 deletions bsp/m5stack_core_s3/m5stack_core_s3.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
*/

#include "driver/gpio.h"
#include "driver/i2c_master.h"
#include "driver/spi_master.h"
#include "driver/sdspi_host.h"
#include "esp_err.h"
#include "esp_log.h"
#include "esp_check.h"
Expand All @@ -14,7 +16,6 @@
#include "esp_lcd_panel_vendor.h"
#include "esp_lcd_panel_ops.h"
#include "esp_vfs_fat.h"
#include "driver/sdspi_host.h"

#include "bsp/m5stack_core_s3.h"
#include "bsp/display.h"
Expand Down Expand Up @@ -49,7 +50,7 @@ sdmmc_card_t *bsp_sdcard = NULL; // Global SD card handler
* @brief I2C handle for BSP usage
*
* You can call i2c_master_get_bus_handle(BSP_I2C_NUM, i2c_master_bus_handle_t *ret_handle)
* from #include "esp_private/i2c_platforma.h"
* from #include "esp_private/i2c_platform.h"
*/
static i2c_master_bus_handle_t i2c_handle = NULL;
static bool i2c_initialized = false;
Expand All @@ -68,21 +69,21 @@ esp_err_t bsp_i2c_init(void)
.i2c_port = BSP_I2C_NUM,
.sda_io_num = BSP_I2C_SDA,
.scl_io_num = BSP_I2C_SCL,
.clk_source = 1,
.clk_source = I2C_CLK_SRC_DEFAULT,
};
BSP_ERROR_CHECK_RETURN_ERR(i2c_new_master_bus(&i2c_config, &i2c_handle));

// AXP2101 and AW9523 are managed by this BSP
const i2c_device_config_t axp2101_config = {
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
.device_address = BSP_AXP2101_ADDR,
.scl_speed_hz = 400000,
.scl_speed_hz = CONFIG_BSP_I2C_CLK_SPEED_HZ,
};
BSP_ERROR_CHECK_RETURN_ERR(i2c_master_bus_add_device(i2c_handle, &axp2101_config, &axp2101_h));
const i2c_device_config_t aw9523_config = {
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
.device_address = BSP_AW9523_ADDR,
.scl_speed_hz = 400000,
.scl_speed_hz = CONFIG_BSP_I2C_CLK_SPEED_HZ,
};
BSP_ERROR_CHECK_RETURN_ERR(i2c_master_bus_add_device(i2c_handle, &aw9523_config, &aw9523_h));

Expand Down Expand Up @@ -435,7 +436,7 @@ esp_err_t bsp_touch_new(const bsp_touch_config_t *config, esp_lcd_touch_handle_t
};
esp_lcd_panel_io_handle_t tp_io_handle = NULL;
esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_FT5x06_CONFIG();
tp_io_config.scl_speed_hz = 400000; // This parameter was introduce together with I2C Driver-NG in IDF v5.2
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
ESP_RETURN_ON_ERROR(esp_lcd_new_panel_io_i2c(i2c_handle, &tp_io_config, &tp_io_handle), TAG, "");
return esp_lcd_touch_new_i2c_ft5x06(tp_io_handle, &tp_cfg, ret_touch);
}
Expand Down
5 changes: 2 additions & 3 deletions components/icm42670/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# ICM42607/ICM42670 6-Axis MotionTracking (Accelerometer and Gyroscope)

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

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

Expand All @@ -27,6 +28,4 @@ This driver, along with many other components from this repository, can be used
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).

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


* [ICM42670 datasheet](https://invensense.tdk.com/products/motion-tracking/6-axis/icm-42670-p/)
8 changes: 4 additions & 4 deletions components/icm42670/icm42670.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ esp_err_t icm42670_get_acce_sensitivity(icm42670_handle_t sensor, float *sensiti

ret = icm42670_read(sensor, ICM42670_ACCEL_CONFIG0, &acce_fs, 1);
if (ret == ESP_OK) {
acce_fs = (acce_fs >> 3) & 0x03;
acce_fs = (acce_fs >> 5) & 0x03;
switch (acce_fs) {
case ACCE_FS_16G:
*sensitivity = ACCE_FS_16G_SENSITIVITY;
Expand Down Expand Up @@ -215,9 +215,9 @@ esp_err_t icm42670_get_gyro_sensitivity(icm42670_handle_t sensor, float *sensiti

*sensitivity = 0;

ret = icm42670_read(sensor, ICM42670_ACCEL_CONFIG0, &gyro_fs, 1);
ret = icm42670_read(sensor, ICM42670_GYRO_CONFIG0, &gyro_fs, 1);
if (ret == ESP_OK) {
gyro_fs = (gyro_fs >> 3) & 0x03;
gyro_fs = (gyro_fs >> 5) & 0x03;
switch (gyro_fs) {
case GYRO_FS_2000DPS:
*sensitivity = GYRO_FS_2000_SENSITIVITY;
Expand Down Expand Up @@ -326,7 +326,7 @@ esp_err_t icm42670_get_temp_value(icm42670_handle_t sensor, float *value)
ret = icm42670_get_temp_raw_value(sensor, &raw_value);
ESP_RETURN_ON_ERROR(ret, TAG, "Get raw value error!");

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

return ESP_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion components/icm42670/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "2.0.0"
version: "2.0.1"
description: I2C driver for ICM 42670 6-Axis MotionTracking
url: https://github.com/espressif/esp-bsp/tree/master/components/icm42670
dependencies:
Expand Down
2 changes: 1 addition & 1 deletion components/icm42670/test_apps/main/test_app_icm42670.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ TEST_CASE("Sensor icm42670 test", "[icm42670]")
vTaskDelay(10); // Give FreeRTOS some time to free its resources
}

#define TEST_MEMORY_LEAK_THRESHOLD (400)
#define TEST_MEMORY_LEAK_THRESHOLD (500)

void setUp(void)
{
Expand Down
10 changes: 4 additions & 6 deletions components/icm42670/test_apps/sdkconfig.defaults
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) 5.4.0 Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32s3"
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
CONFIG_COMPILER_OPTIMIZATION_PERF=y
CONFIG_SPIRAM=y
CONFIG_SPIRAM_MODE_OCT=y
CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y
CONFIG_SPIRAM_RODATA=y
CONFIG_SPIRAM_SPEED_80M=y
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y
CONFIG_ESP_TASK_WDT_EN=n
CONFIG_FREERTOS_HZ=1000
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=4096
Loading