diff --git a/.build-test-rules.yml b/.build-test-rules.yml index 6bf667c2..7ed960d8 100644 --- a/.build-test-rules.yml +++ b/.build-test-rules.yml @@ -7,7 +7,7 @@ examples: reason: Example depends on BSP, which is supported only for IDF >= 5.2 - if: (IDF_VERSION_MAJOR == 5 and IDF_VERSION_MINOR < 3) and CONFIG_NAME in ["esp32_p4_function_ev_board", "esp-box-3"] reason: Example depends on BSP, which is supported only for IDF >= 5.3 - - if: (IDF_VERSION_MAJOR == 5 and IDF_VERSION_MINOR < 4) and CONFIG_NAME == "m5stack_core_s3" + - if: (IDF_VERSION_MAJOR == 5 and IDF_VERSION_MINOR < 4) and CONFIG_NAME in ["m5stack_core_s3", "esp32_s2_kaluga_kit"] reason: Example depends on BSP, which is supported only for IDF >= 5.4 examples/generic_button_led: diff --git a/bsp/esp32_s2_kaluga_kit/CMakeLists.txt b/bsp/esp32_s2_kaluga_kit/CMakeLists.txt index c8d7f57c..c9532c87 100644 --- a/bsp/esp32_s2_kaluga_kit/CMakeLists.txt +++ b/bsp/esp32_s2_kaluga_kit/CMakeLists.txt @@ -1,14 +1,7 @@ -#IDF version is less than IDF5.0 -if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_LESS "5.0") - set(SRC_VER "esp32_s2_kaluga_kit_idf4.c") -else() - set(SRC_VER "esp32_s2_kaluga_kit_idf5.c") -endif() - idf_component_register( - SRCS "esp32_s2_kaluga_kit.c" ${SRC_VER} + SRCS "esp32_s2_kaluga_kit.c" "esp32_s2_kaluga_kit_idf5.c" INCLUDE_DIRS "include" PRIV_INCLUDE_DIRS "priv_include" - REQUIRES driver - PRIV_REQUIRES esp_lcd spiffs + REQUIRES esp_lcd esp_driver_gpio esp_driver_i2s driver + PRIV_REQUIRES spiffs esp_driver_i2c esp_driver_spi esp_psram ) diff --git a/bsp/esp32_s2_kaluga_kit/README.md b/bsp/esp32_s2_kaluga_kit/README.md index 61708320..f6994168 100644 --- a/bsp/esp32_s2_kaluga_kit/README.md +++ b/bsp/esp32_s2_kaluga_kit/README.md @@ -20,17 +20,17 @@ The ESP32-S2-Kaluga-1 kit v1.3 is a development kit by Espressif that is mainly ### Capabilities and dependencies -| Capability | Available | Component | Version | -|-------------|------------------|----------------------------------------------------------------------------------------------|-----------| -| DISPLAY |:heavy_check_mark:| idf | >=4.4.5 | -| LVGL_PORT |:heavy_check_mark:|[espressif/esp_lvgl_port](https://components.espressif.com/components/espressif/esp_lvgl_port)| ^2 | -| TOUCH | :x: | | | -| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) | >=2.5,<4.0| -| AUDIO |:heavy_check_mark:|[espressif/esp_codec_dev](https://components.espressif.com/components/espressif/esp_codec_dev)|^1.0.3,<1.2| -|AUDIO_SPEAKER|:heavy_check_mark:| | | -| AUDIO_MIC |:heavy_check_mark:| | | -| LED |:heavy_check_mark:| idf | >=4.4.5 | -| SDCARD | :x: | | | -| IMU | :x: | | | -| CAMERA |:heavy_check_mark:| [espressif/esp32-camera](https://components.espressif.com/components/espressif/esp32-camera) | ^2.0.2 | +| Capability | Available | Component | Version | +|-------------|------------------|----------------------------------------------------------------------------------------------|----------| +| DISPLAY |:heavy_check_mark:| idf | >=5.4 | +| LVGL_PORT |:heavy_check_mark:|[espressif/esp_lvgl_port](https://components.espressif.com/components/espressif/esp_lvgl_port)| ^2 | +| TOUCH | :x: | | | +| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) |>=2.5,<4.0| +| AUDIO |:heavy_check_mark:|[espressif/esp_codec_dev](https://components.espressif.com/components/espressif/esp_codec_dev)| ~1.3.1 | +|AUDIO_SPEAKER|:heavy_check_mark:| | | +| AUDIO_MIC |:heavy_check_mark:| | | +| LED |:heavy_check_mark:| idf | >=5.4 | +| SDCARD | :x: | | | +| IMU | :x: | | | +| CAMERA |:heavy_check_mark:| [espressif/esp32-camera](https://components.espressif.com/components/espressif/esp32-camera) | ^2.0.14 | diff --git a/bsp/esp32_s2_kaluga_kit/esp32_s2_kaluga_kit.c b/bsp/esp32_s2_kaluga_kit/esp32_s2_kaluga_kit.c index eb034ba5..e113b3a2 100644 --- a/bsp/esp32_s2_kaluga_kit/esp32_s2_kaluga_kit.c +++ b/bsp/esp32_s2_kaluga_kit/esp32_s2_kaluga_kit.c @@ -5,7 +5,7 @@ */ #include "driver/spi_master.h" -#include "driver/i2c.h" +#include "driver/i2c_master.h" #include "esp_err.h" #include "esp_log.h" #include "esp_check.h" @@ -22,10 +22,17 @@ static const char *TAG = "Kaluga"; +/** + * @brief I2C handle for BSP usage + * + * In IDF v5.4 you can call i2c_master_get_bus_handle(BSP_I2C_NUM, i2c_master_bus_handle_t *ret_handle) + * from #include "esp_private/i2c_platform.h" to get this handle + * + * For IDF 5.2 and 5.3 you must call bsp_i2c_get_handle() + */ +static i2c_master_bus_handle_t i2c_handle = NULL; static bool i2c_initialized = false; -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) static adc_oneshot_unit_handle_t bsp_adc_handle = NULL; -#endif static const touch_pad_t bsp_touch_button[TOUCH_BUTTON_NUM] = { TOUCH_BUTTON_PHOTO, /*!< 'PHOTO' button */ @@ -40,9 +47,7 @@ static const touch_pad_t bsp_touch_button[TOUCH_BUTTON_NUM] = { static const button_config_t bsp_button_config[BSP_BUTTON_NUM] = { { .type = BUTTON_TYPE_ADC, -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) .adc_button_config.adc_handle = &bsp_adc_handle, -#endif .adc_button_config.adc_channel = ADC_CHANNEL_5, // ADC1 channel 5 is GPIO6 .adc_button_config.button_index = BSP_BUTTON_REC, .adc_button_config.min = 2310, // middle is 2410mV @@ -50,9 +55,7 @@ static const button_config_t bsp_button_config[BSP_BUTTON_NUM] = { }, { .type = BUTTON_TYPE_ADC, -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) .adc_button_config.adc_handle = &bsp_adc_handle, -#endif .adc_button_config.adc_channel = ADC_CHANNEL_5, // ADC1 channel 5 is GPIO6 .adc_button_config.button_index = BSP_BUTTON_MODE, .adc_button_config.min = 1880, // middle is 1980mV @@ -60,9 +63,7 @@ static const button_config_t bsp_button_config[BSP_BUTTON_NUM] = { }, { .type = BUTTON_TYPE_ADC, -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) .adc_button_config.adc_handle = &bsp_adc_handle, -#endif .adc_button_config.adc_channel = ADC_CHANNEL_5, // ADC1 channel 5 is GPIO6 .adc_button_config.button_index = BSP_BUTTON_PLAY, .adc_button_config.min = 1550, // middle is 1650mV @@ -70,9 +71,7 @@ static const button_config_t bsp_button_config[BSP_BUTTON_NUM] = { }, { .type = BUTTON_TYPE_ADC, -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) .adc_button_config.adc_handle = &bsp_adc_handle, -#endif .adc_button_config.adc_channel = ADC_CHANNEL_5, // ADC1 channel 5 is GPIO6 .adc_button_config.button_index = BSP_BUTTON_SET, .adc_button_config.min = 1010, // middle is 1110mV @@ -80,9 +79,7 @@ static const button_config_t bsp_button_config[BSP_BUTTON_NUM] = { }, { .type = BUTTON_TYPE_ADC, -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) .adc_button_config.adc_handle = &bsp_adc_handle, -#endif .adc_button_config.adc_channel = ADC_CHANNEL_5, // ADC1 channel 5 is GPIO6 .adc_button_config.button_index = BSP_BUTTON_VOLDOWN, .adc_button_config.min = 720, // middle is 820mV @@ -90,9 +87,7 @@ static const button_config_t bsp_button_config[BSP_BUTTON_NUM] = { }, { .type = BUTTON_TYPE_ADC, -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) .adc_button_config.adc_handle = &bsp_adc_handle, -#endif .adc_button_config.adc_channel = ADC_CHANNEL_5, // ADC1 channel 5 is GPIO6 .adc_button_config.button_index = BSP_BUTTON_VOLUP, .adc_button_config.min = 280, // middle is 380mV @@ -108,11 +103,9 @@ esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int b return ESP_ERR_INVALID_ARG; } -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) /* Initialize ADC and get ADC handle */ BSP_ERROR_CHECK_RETURN_NULL(bsp_adc_initialize()); bsp_adc_handle = bsp_adc_get_handle(); -#endif if (btn_cnt) { *btn_cnt = 0; @@ -137,29 +130,31 @@ esp_err_t bsp_i2c_init(void) return ESP_OK; } - const i2c_config_t i2c_conf = { - .mode = I2C_MODE_MASTER, + const i2c_master_bus_config_t i2c_config = { + .i2c_port = BSP_I2C_NUM, .sda_io_num = BSP_I2C_SDA, - .sda_pullup_en = GPIO_PULLUP_DISABLE, .scl_io_num = BSP_I2C_SCL, - .scl_pullup_en = GPIO_PULLUP_DISABLE, - .master.clk_speed = CONFIG_BSP_I2C_CLK_SPEED_HZ + .clk_source = I2C_CLK_SRC_DEFAULT, }; - BSP_ERROR_CHECK_RETURN_ERR(i2c_param_config(BSP_I2C_NUM, &i2c_conf)); - BSP_ERROR_CHECK_RETURN_ERR(i2c_driver_install(BSP_I2C_NUM, i2c_conf.mode, 0, 0, 0)); + BSP_ERROR_CHECK_RETURN_ERR(i2c_new_master_bus(&i2c_config, &i2c_handle)); i2c_initialized = true; - return ESP_OK; } esp_err_t bsp_i2c_deinit(void) { - BSP_ERROR_CHECK_RETURN_ERR(i2c_driver_delete(BSP_I2C_NUM)); + BSP_ERROR_CHECK_RETURN_ERR(i2c_del_master_bus(i2c_handle)); i2c_initialized = false; return ESP_OK; } +i2c_master_bus_handle_t bsp_i2c_get_handle(void) +{ + bsp_i2c_init(); + return i2c_handle; +} + /** * @brief Common codec init * @@ -187,6 +182,7 @@ static esp_codec_dev_handle_t bsp_audio_codec_init(void) audio_codec_i2c_cfg_t i2c_cfg = { .port = BSP_I2C_NUM, .addr = ES8311_CODEC_DEFAULT_ADDR, + .bus_handle = i2c_handle, }; const audio_codec_ctrl_if_t *i2c_ctrl_if = audio_codec_new_i2c_ctrl(&i2c_cfg); BSP_NULL_CHECK(i2c_ctrl_if, NULL); diff --git a/bsp/esp32_s2_kaluga_kit/esp32_s2_kaluga_kit_idf4.c b/bsp/esp32_s2_kaluga_kit/esp32_s2_kaluga_kit_idf4.c deleted file mode 100644 index ccc38a61..00000000 --- a/bsp/esp32_s2_kaluga_kit/esp32_s2_kaluga_kit_idf4.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "driver/i2s.h" -#include "bsp/esp32_s2_kaluga_kit.h" -#include "bsp_err_check.h" -#include "esp_codec_dev_defaults.h" -#include "driver/adc.h" -#include "esp_adc_cal.h" - -/* This configuration is used by default in bsp_audio_init() */ -#define BSP_I2S_DUPLEX_MONO_CFG(_sample_rate) \ - { \ - .mode = I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_RX, \ - .sample_rate = _sample_rate, \ - .bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT, \ - .channel_format = I2S_CHANNEL_FMT_ONLY_LEFT, \ - .communication_format = I2S_COMM_FORMAT_STAND_I2S, \ - .dma_buf_count = 3, \ - .dma_buf_len = 1024, \ - .use_apll = true, \ - .tx_desc_auto_clear = true, \ - .intr_alloc_flags = ESP_INTR_FLAG_LEVEL2 | ESP_INTR_FLAG_IRAM \ - } - -static const audio_codec_data_if_t *i2s_data_if = NULL; /* Codec data interface */ -static esp_adc_cal_characteristics_t bsp_adc_chars; - -esp_err_t bsp_audio_init(const i2s_config_t *i2s_config) -{ - esp_err_t ret = ESP_FAIL; - - /* Setup I2S peripheral */ - const i2s_pin_config_t i2s_pin_config = { - .mck_io_num = BSP_I2S_MCLK, - .bck_io_num = BSP_I2S_SCLK, - .ws_io_num = BSP_I2S_LCLK, - .data_out_num = BSP_I2S_DOUT, - .data_in_num = BSP_I2S_DSIN - }; - - /* Setup I2S channels */ - const i2s_config_t std_cfg_default = BSP_I2S_DUPLEX_MONO_CFG(22050); - const i2s_config_t *p_i2s_cfg = &std_cfg_default; - if (i2s_config != NULL) { - p_i2s_cfg = i2s_config; - } - - BSP_ERROR_CHECK_RETURN_NULL(i2s_driver_install(I2S_NUM_0, p_i2s_cfg, 0, NULL)); - if (i2s_set_pin(I2S_NUM_0, &i2s_pin_config) != ESP_OK) { - goto err; - } - - audio_codec_i2s_cfg_t i2s_cfg = { - .port = I2S_NUM_0, - }; - i2s_data_if = audio_codec_new_i2s_data(&i2s_cfg); - BSP_NULL_CHECK_GOTO(i2s_data_if, err); - return ESP_OK; - -err: - i2s_driver_uninstall(I2S_NUM_0); - return ret; -} - -const audio_codec_data_if_t *bsp_audio_get_codec_itf(void) -{ - return i2s_data_if; -} - -esp_err_t bsp_adc_initialize(void) -{ - esp_err_t ret = ESP_OK; - BSP_ERROR_CHECK_RETURN_ERR(esp_adc_cal_check_efuse(ESP_ADC_CAL_VAL_EFUSE_TP_FIT)); - esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, ADC_WIDTH_BIT_DEFAULT, 0, &bsp_adc_chars); - - /* ADC1 config */ - BSP_ERROR_CHECK_RETURN_ERR(adc1_config_width(ADC_WIDTH_BIT_DEFAULT)); - return ret; -} diff --git a/bsp/esp32_s2_kaluga_kit/idf_component.yml b/bsp/esp32_s2_kaluga_kit/idf_component.yml index 396d8e19..0325d095 100644 --- a/bsp/esp32_s2_kaluga_kit/idf_component.yml +++ b/bsp/esp32_s2_kaluga_kit/idf_component.yml @@ -1,4 +1,4 @@ -version: "3.1.0~1" +version: "4.0.0" description: Board Support Package (BSP) for ESP32-S2-Kaluga kit url: https://github.com/espressif/esp-bsp/tree/master/bsp/esp32_s2_kaluga_kit @@ -9,7 +9,7 @@ tags: - bsp dependencies: - idf: ">=4.4.5" + idf: ">=5.4" # I2C Driver-NG is supported in esp32-camera only from IDFv5.4 espressif/esp_lvgl_port: version: "^2" @@ -21,15 +21,15 @@ dependencies: public: true esp_codec_dev: - version: "^1.0.3,<1.2" + version: "~1.3.1" public: true led_strip: - version: "^2.5" + version: "^3.0" public: true esp32-camera: - version: "^2.0.2" + version: "^2.0.14" public: true examples: diff --git a/bsp/esp32_s2_kaluga_kit/include/bsp/esp32_s2_kaluga_kit.h b/bsp/esp32_s2_kaluga_kit/include/bsp/esp32_s2_kaluga_kit.h index a9fa535a..e2b4d2fd 100644 --- a/bsp/esp32_s2_kaluga_kit/include/bsp/esp32_s2_kaluga_kit.h +++ b/bsp/esp32_s2_kaluga_kit/include/bsp/esp32_s2_kaluga_kit.h @@ -13,18 +13,14 @@ #include "sdkconfig.h" #include "driver/gpio.h" -#include "driver/touch_pad.h" +#include "driver/touch_sensor.h" +#include "driver/i2s_std.h" #include "iot_button.h" #include "lvgl.h" #include "esp_lvgl_port.h" #include "esp_codec_dev.h" #include "bsp/display.h" -#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) -#include "driver/i2s.h" -#else -#include "driver/i2s_std.h" -#endif /************************************************************************************************** * BSP Capabilities **************************************************************************************************/ @@ -145,11 +141,7 @@ typedef struct { * - ESP_ERR_NO_MEM No memory for storing the channel information * - ESP_ERR_INVALID_STATE This channel has not initialized or already started */ -#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) -esp_err_t bsp_audio_init(const i2s_config_t *i2s_config); -#else esp_err_t bsp_audio_init(const i2s_std_config_t *i2s_config); -#endif /** * @brief Get codec I2S interface (initialized in bsp_audio_init) @@ -204,6 +196,13 @@ esp_err_t bsp_i2c_init(void); */ esp_err_t bsp_i2c_deinit(void); +/** + * @brief Get I2C driver handle + * + * @return + * - I2C handle + */ +i2c_master_bus_handle_t bsp_i2c_get_handle(void); /************************************************************************************************** * @@ -394,8 +393,6 @@ void bsp_display_rotate(lv_display_t *disp, lv_disp_rotation_t rotation); */ esp_err_t bsp_adc_initialize(void); - -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) /** * @brief Get ADC handle * @@ -404,7 +401,6 @@ esp_err_t bsp_adc_initialize(void); * @return ADC handle */ adc_oneshot_unit_handle_t bsp_adc_get_handle(void); -#endif /************************************************************************************************** * diff --git a/examples/audio/sdkconfig.bsp.esp32_s2_kaluga_kit b/examples/audio/sdkconfig.bsp.esp32_s2_kaluga_kit index 06572aa8..0b840635 100644 --- a/examples/audio/sdkconfig.bsp.esp32_s2_kaluga_kit +++ b/examples/audio/sdkconfig.bsp.esp32_s2_kaluga_kit @@ -7,3 +7,6 @@ CONFIG_PARTITION_TABLE_CUSTOM=y CONFIG_LV_USE_PERF_MONITOR=y CONFIG_LV_SPRINTF_CUSTOM=y # CONFIG_LV_BUILD_EXAMPLES is not set + +CONFIG_CODEC_I2C_BACKWARD_COMPATIBLE=n +CONFIG_TOUCH_SUPPRESS_DEPRECATE_WARN=y diff --git a/examples/display/sdkconfig.bsp.esp32_s2_kaluga_kit b/examples/display/sdkconfig.bsp.esp32_s2_kaluga_kit index 9eb3f87f..571ef0ca 100644 --- a/examples/display/sdkconfig.bsp.esp32_s2_kaluga_kit +++ b/examples/display/sdkconfig.bsp.esp32_s2_kaluga_kit @@ -25,3 +25,6 @@ CONFIG_LV_USE_CLIB_STRING=y CONFIG_LV_USE_OBSERVER=y CONFIG_LV_USE_SYSMON=y CONFIG_LV_USE_PERF_MONITOR=y + +CONFIG_CODEC_I2C_BACKWARD_COMPATIBLE=n +CONFIG_TOUCH_SUPPRESS_DEPRECATE_WARN=y diff --git a/examples/display_camera/sdkconfig.bsp.esp32_s2_kaluga_kit b/examples/display_camera/sdkconfig.bsp.esp32_s2_kaluga_kit index a928bf8d..059ab612 100644 --- a/examples/display_camera/sdkconfig.bsp.esp32_s2_kaluga_kit +++ b/examples/display_camera/sdkconfig.bsp.esp32_s2_kaluga_kit @@ -29,3 +29,6 @@ CONFIG_LV_USE_CLIB_STRING=y CONFIG_LV_USE_OBSERVER=y CONFIG_LV_USE_SYSMON=y CONFIG_LV_USE_PERF_MONITOR=y + +CONFIG_CODEC_I2C_BACKWARD_COMPATIBLE=n +CONFIG_TOUCH_SUPPRESS_DEPRECATE_WARN=y diff --git a/examples/display_lvgl_demos/sdkconfig.bsp.esp32_s2_kaluga_kit b/examples/display_lvgl_demos/sdkconfig.bsp.esp32_s2_kaluga_kit index 9e3ba752..b27e37c0 100644 --- a/examples/display_lvgl_demos/sdkconfig.bsp.esp32_s2_kaluga_kit +++ b/examples/display_lvgl_demos/sdkconfig.bsp.esp32_s2_kaluga_kit @@ -39,3 +39,6 @@ CONFIG_LV_USE_CLIB_STRING=y CONFIG_LV_USE_OBSERVER=y CONFIG_LV_USE_SYSMON=y CONFIG_LV_USE_PERF_MONITOR=y + +CONFIG_CODEC_I2C_BACKWARD_COMPATIBLE=n +CONFIG_TOUCH_SUPPRESS_DEPRECATE_WARN=y