diff --git a/.gitlab/ci/build-micropython-adf.yml b/.gitlab/ci/build-micropython-adf.yml index f7647e761..3362f02f1 100644 --- a/.gitlab/ci/build-micropython-adf.yml +++ b/.gitlab/ci/build-micropython-adf.yml @@ -56,7 +56,7 @@ build_micropython_adf: extends: - - .rules:build:non-regular-board-idf-ver-tag + - .rules:build:micropython-test - .build_micropython_cmake_template - .matrix_template variables: diff --git a/.gitlab/ci/rules.yml b/.gitlab/ci/rules.yml index 310df8d98..3bfdd43c1 100644 --- a/.gitlab/ci/rules.yml +++ b/.gitlab/ci/rules.yml @@ -47,6 +47,9 @@ .if-label-example: &if-label-example if: '$BOT_LABEL_EXAMPLE_TEST || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*example(?:,[^,\n\r]+)*$/i' +.if-label-micropython-test: &if-label-micropython-test + if: '$BOT_LABEL_EXAMPLE_TEST || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*micropython_test(?:,[^,\n\r]+)*$/i' + .if-idf-version-tag-v5-0: &if-idf-version-tag-v5-0 if: '($IDF_VERSION_TAG == "v5.0.4" || $IDF_VERSION_TAG == "v5.0")' variables: @@ -95,6 +98,12 @@ - <<: *if-ref-master - <<: *if-schedule +.rules:build:micropython-test: + rules: + - <<: *if-label-micropython-test + - <<: *if-protected + - <<: *if-schedule + .rules:ref:check-label: rules: - <<: *if-protected diff --git a/components/audio_board/Kconfig.projbuild b/components/audio_board/Kconfig.projbuild index b2b1a34ce..16b2b26b5 100644 --- a/components/audio_board/Kconfig.projbuild +++ b/components/audio_board/Kconfig.projbuild @@ -40,20 +40,6 @@ config ESP32_P4_FUNCTION_EV_BOARD endchoice -choice ESP_LYRAT_MINI_V1_1_ADC - prompt "ESP LYRAT MINI Board ADC chip" - depends on ESP_LYRAT_MINI_V1_1_BOARD - default ESP_LYRAT_MINI_V1_1_ADC_ES7243E - help - Select ADC chip to use on ESP_LYRAT_MINI_V1_1 board - -config ESP_LYRAT_MINI_V1_1_ADC_ES7243E - bool "ESP_LYRAT_MINI_V1_1_ADC_ES7243E" -config ESP_LYRAT_MINI_V1_1_ADC_ES7243 - bool "ESP_LYRAT_MINI_V1_1_ADC_ES7243" - -endchoice - choice ESP32_KORVO_DU1906_DAC prompt "ESP32 KORVO DU1906 Board DAC chip" depends on ESP32_KORVO_DU1906_BOARD diff --git a/components/audio_board/lyrat_mini_v1_1/board.c b/components/audio_board/lyrat_mini_v1_1/board.c index 2190140a0..4f5ee65ba 100644 --- a/components/audio_board/lyrat_mini_v1_1/board.c +++ b/components/audio_board/lyrat_mini_v1_1/board.c @@ -29,11 +29,40 @@ #include "periph_sdcard.h" #include "led_indicator.h" #include "periph_adc_button.h" +#include "i2c_bus.h" + +#define ES7243E_ADDR 0x20 +#define ES7243_ADDR 0x26 static const char *TAG = "AUDIO_BOARD"; static audio_board_handle_t board_handle = 0; +static int audio_board_probe_adc(uint8_t addr) +{ + static i2c_bus_handle_t i2c_handle = NULL; + int res = 0; + + if (i2c_handle == NULL) { + i2c_config_t es_i2c_cfg = { + .mode = I2C_MODE_MASTER, + .sda_pullup_en = GPIO_PULLUP_ENABLE, + .scl_pullup_en = GPIO_PULLUP_ENABLE, + .master.clk_speed = 100000, + }; + res = get_i2c_pins(I2C_NUM_0, &es_i2c_cfg); + if (res != 0) { + return res; + } + i2c_handle = i2c_bus_create(I2C_NUM_0, &es_i2c_cfg); + } + + if (i2c_handle) { + return i2c_bus_probe_addr(i2c_handle, addr); + } + return ESP_FAIL; +} + audio_board_handle_t audio_board_init(void) { if (board_handle) { @@ -52,11 +81,15 @@ audio_hal_handle_t audio_board_adc_init(void) audio_hal_handle_t adc_hal = NULL; audio_hal_codec_config_t audio_codec_cfg = AUDIO_CODEC_DEFAULT_CONFIG(); audio_codec_cfg.codec_mode = AUDIO_HAL_CODEC_MODE_ENCODE; -#ifdef CONFIG_ESP_LYRAT_MINI_V1_1_ADC_ES7243E - adc_hal = audio_hal_init(&audio_codec_cfg, &AUDIO_CODEC_ES7243E_DEFAULT_HANDLE); -#elif CONFIG_ESP_LYRAT_MINI_V1_1_ADC_ES7243 - adc_hal = audio_hal_init(&audio_codec_cfg, &AUDIO_CODEC_ES7243_DEFAULT_HANDLE); -#endif /* CONFIG_ESP_LYRAT_MINI_V1_1_ADC_ES7243E */ + + // The new version of the esp32_lyrat_mini development board has replaced the ADC from ES7243 to ES7243E. + // Check the current ADC in use and initialize it. + if (audio_board_probe_adc(ES7243E_ADDR) == ESP_OK) { + adc_hal = audio_hal_init(&audio_codec_cfg, &AUDIO_CODEC_ES7243E_DEFAULT_HANDLE); + } else if (audio_board_probe_adc(ES7243_ADDR) == ESP_OK) { + adc_hal = audio_hal_init(&audio_codec_cfg, &AUDIO_CODEC_ES7243_DEFAULT_HANDLE); + } + AUDIO_NULL_CHECK(TAG, adc_hal, return NULL); return adc_hal; } diff --git a/components/audio_board/lyrat_mini_v1_1/board_def.h b/components/audio_board/lyrat_mini_v1_1/board_def.h index ffbdf1575..1466a831c 100644 --- a/components/audio_board/lyrat_mini_v1_1/board_def.h +++ b/components/audio_board/lyrat_mini_v1_1/board_def.h @@ -60,11 +60,8 @@ #define BOARD_PA_GAIN (20) /* Power amplifier gain defined by board (dB) */ extern audio_hal_func_t AUDIO_CODEC_ES8311_DEFAULT_HANDLE; -#ifdef CONFIG_ESP_LYRAT_MINI_V1_1_ADC_ES7243E extern audio_hal_func_t AUDIO_CODEC_ES7243E_DEFAULT_HANDLE; -#elif CONFIG_ESP_LYRAT_MINI_V1_1_ADC_ES7243 extern audio_hal_func_t AUDIO_CODEC_ES7243_DEFAULT_HANDLE; -#endif /* CONFIG_ESP_LYRAT_MINI_V1_1_ADC_ES7243E */ #define AUDIO_CODEC_DEFAULT_CONFIG() { \ .adc_input = AUDIO_HAL_ADC_INPUT_LINE1, \ diff --git a/micropython_adf/boards/lyratmini/board_init.c b/micropython_adf/boards/lyratmini/board_init.c index 1ea53b270..eaf23f07b 100644 --- a/micropython_adf/boards/lyratmini/board_init.c +++ b/micropython_adf/boards/lyratmini/board_init.c @@ -1,10 +1,36 @@ #include "board_init.h" #include "esp_log.h" #include "driver/gpio.h" +#include "i2c_bus.h" + +#define ES7243E_ADDR 0x20 +#define ES7243_ADDR 0x26 static char *TAG = "LyraTMini_board"; static audio_hal_handle_t audio_hal = NULL; +static int audio_board_probe_adc(uint8_t addr) +{ + static i2c_bus_handle_t i2c_handle = NULL; + + if (i2c_handle == NULL) { + i2c_config_t es_i2c_cfg = { + .mode = I2C_MODE_MASTER, + .sda_pullup_en = GPIO_PULLUP_ENABLE, + .scl_pullup_en = GPIO_PULLUP_ENABLE, + .master.clk_speed = 100000, + }; + es_i2c_cfg.sda_io_num = 18; + es_i2c_cfg.scl_io_num = 23; + i2c_handle = i2c_bus_create(I2C_NUM_0, &es_i2c_cfg); + } + + if (i2c_handle) { + return i2c_bus_probe_addr(i2c_handle, addr); + } + return ESP_FAIL; +} + audio_hal_handle_t board_codec_init(void) { if (audio_hal) { @@ -15,7 +41,14 @@ audio_hal_handle_t board_codec_init(void) audio_hal = audio_hal_init(&audio_codec_cfg, &AUDIO_CODEC_ES8311_DEFAULT_HANDLE); audio_hal_ctrl_codec(audio_hal, AUDIO_HAL_CODEC_MODE_DECODE, AUDIO_HAL_CTRL_START); - audio_hal_handle_t adc_hal = audio_hal_init(&audio_codec_cfg, &AUDIO_CODEC_ES7243_DEFAULT_HANDLE); + // The new version of the esp32_lyrat_mini development board has replaced the ADC from ES7243 to ES7243E. + // Check the current ADC in use and initialize it. + audio_hal_handle_t adc_hal = NULL; + if (audio_board_probe_adc(ES7243E_ADDR) == ESP_OK) { + audio_hal = audio_hal_init(&audio_codec_cfg, &AUDIO_CODEC_ES7243E_DEFAULT_HANDLE); + } else if (audio_board_probe_adc(ES7243_ADDR) == ESP_OK) { + audio_hal = audio_hal_init(&audio_codec_cfg, &AUDIO_CODEC_ES7243_DEFAULT_HANDLE); + } audio_hal_ctrl_codec(adc_hal, AUDIO_HAL_CODEC_MODE_ENCODE, AUDIO_HAL_CTRL_START); return audio_hal; diff --git a/micropython_adf/boards/lyratmini/mpconfigboard.cmake b/micropython_adf/boards/lyratmini/mpconfigboard.cmake index 417bbde0c..4603e0a05 100644 --- a/micropython_adf/boards/lyratmini/mpconfigboard.cmake +++ b/micropython_adf/boards/lyratmini/mpconfigboard.cmake @@ -14,10 +14,12 @@ set(ADF_BOARD_DIR "$ENV{ADF_PATH}/components/audio_board/lyrat_mini_v1_1") set(ADF_BOARD_CODEC_SRC ${ADF_COMPS}/audio_hal/driver/es8311/es8311.c - ${ADF_COMPS}/audio_hal/driver/es7243/es7243.c) + ${ADF_COMPS}/audio_hal/driver/es7243/es7243.c + ${ADF_COMPS}/audio_hal/driver/es7243e/es7243e.c) set(ADF_BOARD_CODEC_INC ${ADF_COMPS}/audio_hal/driver/es8311 - ${ADF_COMPS}/audio_hal/driver/es7243) + ${ADF_COMPS}/audio_hal/driver/es7243 + ${ADF_COMPS}/audio_hal/driver/es7243e) set(ADF_BOARD_INIT_SRC $ENV{ADF_PATH}/components $ENV{ADF_PATH}/micropython_adf/boards/lyratmini/board_init.c)