|
|
@@ -118,9 +118,9 @@ static esp_err_t i2s_pdm_tx_set_gpio(i2s_chan_handle_t handle, const i2s_pdm_tx_
|
|
|
i2s_pdm_tx_config_t *pdm_tx_cfg = (i2s_pdm_tx_config_t *)handle->mode_info;
|
|
|
/* Set data output GPIO */
|
|
|
i2s_gpio_check_and_set(gpio_cfg->dout, i2s_periph_signal[id].data_out_sig, false, false);
|
|
|
-#if SOC_I2S_HW_VERSION_2
|
|
|
+#if SOC_I2S_PDM_MAX_TX_LINES > 1
|
|
|
if (pdm_tx_cfg->slot_cfg.line_mode == I2S_PDM_TX_TWO_LINE_DAC) {
|
|
|
- i2s_gpio_check_and_set(gpio_cfg->dout2, i2s_periph_signal[id].data_out1_sig, false, false);
|
|
|
+ i2s_gpio_check_and_set(gpio_cfg->dout2, i2s_periph_signal[id].data_out_sigs[1], false, false);
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
@@ -393,8 +393,17 @@ static esp_err_t i2s_pdm_rx_set_gpio(i2s_chan_handle_t handle, const i2s_pdm_rx_
|
|
|
ESP_ERR_INVALID_ARG, TAG, "clk gpio is invalid");
|
|
|
ESP_RETURN_ON_FALSE((gpio_cfg->din == -1 || GPIO_IS_VALID_GPIO(gpio_cfg->din)),
|
|
|
ESP_ERR_INVALID_ARG, TAG, "dout gpio is invalid");
|
|
|
+ i2s_pdm_rx_config_t *pdm_rx_cfg = (i2s_pdm_rx_config_t *)handle->mode_info;
|
|
|
/* Set data input GPIO */
|
|
|
+#if SOC_I2S_PDM_MAX_RX_LINES > 1
|
|
|
+ for (int i = 0; i < SOC_I2S_PDM_MAX_RX_LINES; i++) {
|
|
|
+ if (pdm_rx_cfg->slot_cfg.slot_mask & (0x03 << (i * 2))) {
|
|
|
+ i2s_gpio_check_and_set(gpio_cfg->dins[i], i2s_periph_signal[id].data_in_sigs[i], true, false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+#else
|
|
|
i2s_gpio_check_and_set(gpio_cfg->din, i2s_periph_signal[id].data_in_sig, true, false);
|
|
|
+#endif
|
|
|
|
|
|
if (handle->role == I2S_ROLE_SLAVE) {
|
|
|
/* For "tx + rx + slave" or "rx + slave" mode, select RX signal index for ws and bck */
|
|
|
@@ -410,7 +419,6 @@ static esp_err_t i2s_pdm_rx_set_gpio(i2s_chan_handle_t handle, const i2s_pdm_rx_
|
|
|
i2s_ll_mclk_bind_to_rx_clk(handle->controller->hal.dev);
|
|
|
#endif
|
|
|
/* Update the mode info: gpio configuration */
|
|
|
- i2s_pdm_rx_config_t *pdm_rx_cfg = (i2s_pdm_rx_config_t *)handle->mode_info;
|
|
|
memcpy(&(pdm_rx_cfg->gpio_cfg), gpio_cfg, sizeof(i2s_pdm_rx_gpio_config_t));
|
|
|
|
|
|
return ESP_OK;
|
|
|
@@ -433,9 +441,9 @@ esp_err_t i2s_channel_init_pdm_rx_mode(i2s_chan_handle_t handle, const i2s_pdm_r
|
|
|
}
|
|
|
handle->mode_info = calloc(1, sizeof(i2s_pdm_rx_config_t));
|
|
|
ESP_GOTO_ON_FALSE(handle->mode_info, ESP_ERR_NO_MEM, err, TAG, "no memory for storing the configurations");
|
|
|
- ESP_GOTO_ON_ERROR(i2s_pdm_rx_set_gpio(handle, &pdm_rx_cfg->gpio_cfg), err, TAG, "initialize channel failed while setting gpio pins");
|
|
|
- /* i2s_set_pdm_rx_slot should be called before i2s_set_pdm_rx_clock while initializing, because clock is relay on the slot */
|
|
|
+ /* i2s_set_pdm_rx_slot should be called before i2s_set_pdm_rx_clock and i2s_pdm_rx_set_gpio while initializing, because clock is relay on the slot */
|
|
|
ESP_GOTO_ON_ERROR(i2s_pdm_rx_set_slot(handle, &pdm_rx_cfg->slot_cfg), err, TAG, "initialize channel failed while setting slot");
|
|
|
+ ESP_GOTO_ON_ERROR(i2s_pdm_rx_set_gpio(handle, &pdm_rx_cfg->gpio_cfg), err, TAG, "initialize channel failed while setting gpio pins");
|
|
|
#if SOC_I2S_SUPPORTS_APLL
|
|
|
/* Enable APLL and acquire its lock when the clock source is APLL */
|
|
|
if (pdm_rx_cfg->clk_cfg.clk_src == I2S_CLK_SRC_APLL) {
|