From 0fcc52a31091d9f79cd8397816900f145fd4c5d5 Mon Sep 17 00:00:00 2001 From: Tomas Rezucha Date: Fri, 12 Jul 2024 12:04:54 +0200 Subject: [PATCH] fix(m5stack_core2): Invert I2S WS signal to stream in right audio channel --- bsp/m5stack_core_2/idf_component.yml | 3 ++- .../include/bsp/m5stack_core_2.h | 2 +- bsp/m5stack_core_2/m5stack_core_2_idf5.c | 5 ++-- examples/bsp_ext.py | 3 ++- .../display_audio_photo/main/app_disp_fs.c | 6 +++++ .../main/idf_component.yml | 8 +++--- .../sdkconfig.bsp.m5stack_core_2 | 26 +++++++++++++++++++ 7 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 examples/display_audio_photo/sdkconfig.bsp.m5stack_core_2 diff --git a/bsp/m5stack_core_2/idf_component.yml b/bsp/m5stack_core_2/idf_component.yml index a7383a10..79e41c5d 100644 --- a/bsp/m5stack_core_2/idf_component.yml +++ b/bsp/m5stack_core_2/idf_component.yml @@ -16,7 +16,8 @@ dependencies: espressif/esp_lvgl_port: version: "^2" public: true + override_path: "../../components/esp_lvgl_port" esp_codec_dev: version: "^1.1" - public: true \ No newline at end of file + public: true diff --git a/bsp/m5stack_core_2/include/bsp/m5stack_core_2.h b/bsp/m5stack_core_2/include/bsp/m5stack_core_2.h index 7b9ece4e..4ea60afb 100644 --- a/bsp/m5stack_core_2/include/bsp/m5stack_core_2.h +++ b/bsp/m5stack_core_2/include/bsp/m5stack_core_2.h @@ -51,7 +51,7 @@ #define BSP_I2C_SDA (GPIO_NUM_21) /* Audio */ #define BSP_I2S_SCLK (GPIO_NUM_12) //I2S_BCK -#define BSP_I2S_MCLK (GPIO_NUM_0) +#define BSP_I2S_MCLK (GPIO_NUM_NC) #define BSP_I2S_LCLK (GPIO_NUM_0) //I2S_WCK #define BSP_I2S_DOUT (GPIO_NUM_2) #define BSP_I2S_DSIN (GPIO_NUM_34) diff --git a/bsp/m5stack_core_2/m5stack_core_2_idf5.c b/bsp/m5stack_core_2/m5stack_core_2_idf5.c index 21029142..7e2e9b60 100644 --- a/bsp/m5stack_core_2/m5stack_core_2_idf5.c +++ b/bsp/m5stack_core_2/m5stack_core_2_idf5.c @@ -22,10 +22,10 @@ static const audio_codec_data_if_t *i2s_data_if = NULL; /* Codec data interface .invert_flags = { \ .mclk_inv = false, \ .bclk_inv = false, \ - .ws_inv = false, \ + .ws_inv = true, \ }, \ + .mclk = BSP_I2S_MCLK, \ } -// .mclk = BSP_I2S_MCLK, /* This configuration is used by default in bsp_audio_init() */ #define BSP_I2S_DUPLEX_MONO_CFG(_sample_rate) \ { \ @@ -49,7 +49,6 @@ esp_err_t bsp_audio_init(const i2s_std_config_t *i2s_config) /* Setup I2S channels */ i2s_std_config_t std_cfg_default = BSP_I2S_DUPLEX_MONO_CFG(44100); - std_cfg_default.slot_cfg.slot_mask = I2S_STD_SLOT_RIGHT; const i2s_std_config_t *p_i2s_cfg = &std_cfg_default; if (i2s_config != NULL) { diff --git a/examples/bsp_ext.py b/examples/bsp_ext.py index 1ed1b2c9..c135cea2 100644 --- a/examples/bsp_ext.py +++ b/examples/bsp_ext.py @@ -59,7 +59,8 @@ def set_bsp_callback(action: str, ctx: Context, args: PropertyDict, **kwargs: st 'esp32_s3_korvo_1', 'esp32_p4_function_ev_board', 'm5stack_core_s3', - 'm5dial' + 'm5dial', + 'm5stack_core_2' } if bsp == '': diff --git a/examples/display_audio_photo/main/app_disp_fs.c b/examples/display_audio_photo/main/app_disp_fs.c index 7918f89f..9c16e2c8 100644 --- a/examples/display_audio_photo/main/app_disp_fs.c +++ b/examples/display_audio_photo/main/app_disp_fs.c @@ -164,10 +164,12 @@ void app_audio_init(void) esp_codec_dev_set_out_vol(spk_codec_dev, DEFAULT_VOLUME); /* Initialize microphone */ +#if BSP_CAPS_AUDIO_MIC mic_codec_dev = bsp_audio_codec_microphone_init(); assert(mic_codec_dev); /* Microphone input gain */ esp_codec_dev_set_in_gain(mic_codec_dev, 50.0); +#endif } void app_disp_fs_init(void) @@ -766,6 +768,7 @@ static void rec_stop_event_cb(lv_event_t *e) static void rec_file(void *arg) { +#if BSP_CAPS_AUDIO_MIC char *path = arg; FILE *record_file = NULL; int16_t *recording_buffer = heap_caps_malloc(BUFFER_SIZE, MALLOC_CAP_DEFAULT); @@ -834,6 +837,9 @@ static void rec_file(void *arg) } vTaskDelete(NULL); +#else + ESP_LOGI(TAG, "Recording not supported!"); +#endif } /* Stop playing recorded audio file */ diff --git a/examples/display_audio_photo/main/idf_component.yml b/examples/display_audio_photo/main/idf_component.yml index fc28d292..e0265637 100644 --- a/examples/display_audio_photo/main/idf_component.yml +++ b/examples/display_audio_photo/main/idf_component.yml @@ -1,6 +1,6 @@ description: BSP Display Audio Photo Example dependencies: - esp_jpeg: "*" - esp-box: - version: "*" - override_path: "../../../bsp/esp-box" + m5stack_core_2: + version: '*' + override_path: ../../../bsp/m5stack_core_2 + esp_jpeg: '*' diff --git a/examples/display_audio_photo/sdkconfig.bsp.m5stack_core_2 b/examples/display_audio_photo/sdkconfig.bsp.m5stack_core_2 new file mode 100644 index 00000000..e885cc57 --- /dev/null +++ b/examples/display_audio_photo/sdkconfig.bsp.m5stack_core_2 @@ -0,0 +1,26 @@ +# This file was generated using idf.py save-defconfig. It can be edited manually. +# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration +# +CONFIG_IDF_TARGET="esp32" +CONFIG_ESPTOOLPY_FLASHFREQ_80M=y +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_SPIRAM=y +CONFIG_SPIRAM_SPEED_80M=y +CONFIG_ESP_INT_WDT_TIMEOUT_MS=300 +CONFIG_LV_USE_CLIB_MALLOC=y +CONFIG_LV_USE_CLIB_STRING=y +CONFIG_LV_USE_CLIB_SPRINTF=y +CONFIG_LV_ATTRIBUTE_FAST_MEM_USE_IRAM=y +CONFIG_LV_FONT_MONTSERRAT_12=y +CONFIG_LV_FONT_MONTSERRAT_16=y +CONFIG_LV_USE_OBSERVER=y +CONFIG_LV_USE_SYSMON=y +CONFIG_LV_USE_PERF_MONITOR=y +CONFIG_LV_BUILD_EXAMPLES=n +CONFIG_LV_USE_DEMO_WIDGETS=y +CONFIG_LV_USE_DEMO_STRESS=y +CONFIG_LV_USE_DEMO_MUSIC=y +CONFIG_LV_DEMO_MUSIC_ROUND=y +CONFIG_LV_DEMO_MUSIC_AUTO_PLAY=y +