Skip to content

Commit

Permalink
Merge pull request #3 from espressif/bsp/fix_m5stack_core2_audio
Browse files Browse the repository at this point in the history
fix(m5stack_core2): Invert I2S WS signal to stream in right audio cha…
  • Loading branch information
Tinyu-Zhao authored Aug 6, 2024
2 parents db62310 + 0fcc52a commit 7b03240
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 10 deletions.
3 changes: 2 additions & 1 deletion bsp/m5stack_core_2/idf_component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
public: true
2 changes: 1 addition & 1 deletion bsp/m5stack_core_2/include/bsp/m5stack_core_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions bsp/m5stack_core_2/m5stack_core_2_idf5.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
{ \
Expand All @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion examples/bsp_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 == '':
Expand Down
6 changes: 6 additions & 0 deletions examples/display_audio_photo/main/app_disp_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 */
Expand Down
8 changes: 4 additions & 4 deletions examples/display_audio_photo/main/idf_component.yml
Original file line number Diff line number Diff line change
@@ -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: '*'
26 changes: 26 additions & 0 deletions examples/display_audio_photo/sdkconfig.bsp.m5stack_core_2
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7b03240

Please sign in to comment.