From 01a8614803d1b16aa213fcc09901c68c09834af5 Mon Sep 17 00:00:00 2001 From: Pavel Borcin Date: Wed, 8 Nov 2023 21:20:06 +0100 Subject: [PATCH] add v4.4 idf support (adc, rmt) --- bsp/esp32_s3_korvo_1/CMakeLists.txt | 4 +++- bsp/esp32_s3_korvo_1/README.md | 4 +--- bsp/esp32_s3_korvo_1/esp32_s3_korvo_1.c | 6 ++++- bsp/esp32_s3_korvo_1/esp32_s3_korvo_1_idf4.c | 11 ++++++++- bsp/esp32_s3_korvo_1/esp32_s3_korvo_1_idf5.c | 2 +- bsp/esp32_s3_korvo_1/idf_component.yml | 6 ++--- .../include/bsp/esp32_s3_korvo_1.h | 23 +++++++++++++++---- 7 files changed, 41 insertions(+), 15 deletions(-) diff --git a/bsp/esp32_s3_korvo_1/CMakeLists.txt b/bsp/esp32_s3_korvo_1/CMakeLists.txt index 3199d400..36358625 100644 --- a/bsp/esp32_s3_korvo_1/CMakeLists.txt +++ b/bsp/esp32_s3_korvo_1/CMakeLists.txt @@ -1,13 +1,15 @@ #IDF version is less than IDF5.0 if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_LESS "5.0") set(SRC_VER "esp32_s3_korvo_1_idf4.c") + set(REQ spiffs) else() set(SRC_VER "esp32_s3_korvo_1_idf5.c") + set(REQ spiffs esp_adc) endif() idf_component_register( SRCS "esp32_s3_korvo_1.c" ${SRC_VER} INCLUDE_DIRS "include" PRIV_INCLUDE_DIRS "priv_include" - REQUIRES spiffs + REQUIRES ${REQ} ) diff --git a/bsp/esp32_s3_korvo_1/README.md b/bsp/esp32_s3_korvo_1/README.md index 0495ca00..2dda4f8f 100644 --- a/bsp/esp32_s3_korvo_1/README.md +++ b/bsp/esp32_s3_korvo_1/README.md @@ -2,9 +2,7 @@ [![Component Registry](https://components.espressif.com/components/espressif/esp32_s3_korvo_1/badge.svg)](https://components.espressif.com/components/espressif/esp32_s3_korvo_1) -* [Hardware Reference](https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp32c3/esp32-s3-korvo-1/user_guide.html) - -ESP32-S3-Korvo-1 is a development kit that is based on Espressif’s ESP32-S3 SoC and ESP-Skainet, Espressif’s speech recognition SDK. It features a three-microphone array which is suitable for far-field voice pick-up with low power consumption. The ESP32-S3-Korvo-1 board supports voice wake-up and offline speech command recognition in Chinese and English languages. With ESP-Skainet, you can develop a variety of speech recognition applications, such as smart displays, smart plugs, smart switches, etc. +ESP32-S3-Korvo-1 is a development kit that is based on Espressif’s ESP32-S3 SoC. It features a three-microphone array which is suitable for far-field voice pick-up with low power consumption. The ESP32-S3-Korvo-1 board consists of two parts: the main board (ESP32-S3-Korvo-1) that integrates the ESP32-S3-WROOM-1 module, function buttons, SD card slot, speaker and USB connectors; and the sub board (ESP32-Korvo-Mic, which is also used as the sub board in ESP32-Korvo v1.1) that contains a three-microphone array, function buttons, and addressable LEDs. The main board and sub board are connected via FPC cable. diff --git a/bsp/esp32_s3_korvo_1/esp32_s3_korvo_1.c b/bsp/esp32_s3_korvo_1/esp32_s3_korvo_1.c index 0930965d..373ace10 100644 --- a/bsp/esp32_s3_korvo_1/esp32_s3_korvo_1.c +++ b/bsp/esp32_s3_korvo_1/esp32_s3_korvo_1.c @@ -23,7 +23,7 @@ static led_strip_handle_t led_strip; * This configuration is used by default in bsp_led_init() */ static const led_strip_config_t bsp_strip_config = { - .strip_gpio_num = BSP_RGB_CTRL, + .strip_gpio_num = BSP_LED_RGB_IO, .max_leds = BSP_RGB_LEDS_NUM, .led_pixel_format = LED_PIXEL_FORMAT_GRB, .led_model = LED_MODEL_WS2812, @@ -31,9 +31,13 @@ static const led_strip_config_t bsp_strip_config = { }; static const led_strip_rmt_config_t bsp_rmt_config = { +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) + .rmt_channel = 0, +#else .clk_src = RMT_CLK_SRC_DEFAULT, .resolution_hz = 10 * 1000 * 1000, .flags.with_dma = false, +#endif }; #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) diff --git a/bsp/esp32_s3_korvo_1/esp32_s3_korvo_1_idf4.c b/bsp/esp32_s3_korvo_1/esp32_s3_korvo_1_idf4.c index ca75be15..7102eda8 100644 --- a/bsp/esp32_s3_korvo_1/esp32_s3_korvo_1_idf4.c +++ b/bsp/esp32_s3_korvo_1/esp32_s3_korvo_1_idf4.c @@ -7,8 +7,17 @@ #include "esp_err.h" #include "bsp/esp32_s3_korvo_1.h" #include "bsp_err_check.h" +#include "esp_adc_cal.h" + +static esp_adc_cal_characteristics_t bsp_adc_chars; esp_err_t bsp_adc_initialize(void) { - return ESP_OK; + 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_s3_korvo_1/esp32_s3_korvo_1_idf5.c b/bsp/esp32_s3_korvo_1/esp32_s3_korvo_1_idf5.c index d09600d9..83d23f4b 100644 --- a/bsp/esp32_s3_korvo_1/esp32_s3_korvo_1_idf5.c +++ b/bsp/esp32_s3_korvo_1/esp32_s3_korvo_1_idf5.c @@ -5,7 +5,7 @@ */ #include "esp_err.h" -#include "esp_log.h" +#include "esp_adc/adc_oneshot.h" #include "bsp/esp32_s3_korvo_1.h" #include "bsp_err_check.h" diff --git a/bsp/esp32_s3_korvo_1/idf_component.yml b/bsp/esp32_s3_korvo_1/idf_component.yml index 9931412c..991081ec 100644 --- a/bsp/esp32_s3_korvo_1/idf_component.yml +++ b/bsp/esp32_s3_korvo_1/idf_component.yml @@ -1,12 +1,12 @@ version: "1.0.0" -description: Board Support Package for esp32_s3_korvo_1 -url: https://github.com/espressif/esp-bsp/tree/master/esp32_s3_korvo_1 +description: Board Support Package for ESP32-S3-KORVO-1 +url: https://github.com/espressif/esp-bsp/tree/master/bsp/esp32_s3_korvo_1 targets: - esp32s3 dependencies: - idf: ">=4.4.5" + idf: ">=4.4" led_strip: version: "^2" diff --git a/bsp/esp32_s3_korvo_1/include/bsp/esp32_s3_korvo_1.h b/bsp/esp32_s3_korvo_1/include/bsp/esp32_s3_korvo_1.h index cc4057fc..1bf700d5 100644 --- a/bsp/esp32_s3_korvo_1/include/bsp/esp32_s3_korvo_1.h +++ b/bsp/esp32_s3_korvo_1/include/bsp/esp32_s3_korvo_1.h @@ -18,9 +18,12 @@ * ESP32-S3-Korvo-1 pinout **************************************************************************************************/ -/* Light */ -#define BSP_RGB_CTRL (GPIO_NUM_19) -#define BSP_RGB_LEDS_NUM (12) +/* Leds */ +#define BSP_LED_RGB_IO (GPIO_NUM_19) +#define BSP_RGB_LEDS_NUM (12) + +/* Buttons */ +#define BSP_BUTTONS_IO (GPIO_NUM_8) // All 6 buttons mapped to this GPIO #ifdef __cplusplus extern "C" { @@ -47,6 +50,16 @@ typedef enum { BSP_BUTTON_NUM, } bsp_button_t; +/************************************************************************************************** + * + * ADC interface + * + * There are multiple devices connected to ADC peripheral: + * - Buttons + * + * After initialization of ADC, use adc_handle when using ADC driver. + **************************************************************************************************/ + #define BSP_ADC_UNIT ADC_UNIT_1 /** @@ -59,7 +72,7 @@ typedef enum { esp_err_t bsp_adc_initialize(void); -// #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) /** * @brief Get ADC handle * @@ -68,7 +81,7 @@ esp_err_t bsp_adc_initialize(void); * @return ADC handle */ adc_oneshot_unit_handle_t bsp_adc_get_handle(void); -// #endif +#endif /** * @brief Initialize all buttons