@@ -126,6 +126,9 @@ static esp_err_t i2s_pdm_tx_set_slot(i2s_chan_handle_t handle, const i2s_pdm_tx_
126126 /* Update the mode info: slot configuration */
127127 i2s_pdm_tx_config_t * pdm_tx_cfg = (i2s_pdm_tx_config_t * )handle -> mode_info ;
128128 memcpy (& (pdm_tx_cfg -> slot_cfg ), slot_cfg , sizeof (i2s_pdm_tx_slot_config_t ));
129+ /* Update the slot bit width to the actual slot bit width */
130+ pdm_tx_cfg -> slot_cfg .slot_bit_width = (int )pdm_tx_cfg -> slot_cfg .slot_bit_width < (int )pdm_tx_cfg -> slot_cfg .data_bit_width ?
131+ pdm_tx_cfg -> slot_cfg .data_bit_width : pdm_tx_cfg -> slot_cfg .slot_bit_width ;
129132
130133 portENTER_CRITICAL (& g_i2s .spinlock );
131134 /* Configure the hardware to apply PDM format */
@@ -311,7 +314,7 @@ esp_err_t i2s_channel_reconfig_pdm_tx_slot(i2s_chan_handle_t handle, const i2s_p
311314
312315 /* If the slot bit width changed, then need to update the clock */
313316 uint32_t slot_bits = slot_cfg -> slot_bit_width == I2S_SLOT_BIT_WIDTH_AUTO ? slot_cfg -> data_bit_width : slot_cfg -> slot_bit_width ;
314- if (pdm_tx_cfg -> slot_cfg .slot_bit_width = = slot_bits ) {
317+ if (pdm_tx_cfg -> slot_cfg .slot_bit_width ! = slot_bits ) {
315318 ESP_GOTO_ON_ERROR (i2s_pdm_tx_set_clock (handle , & pdm_tx_cfg -> clk_cfg ), err , TAG , "update clock failed" );
316319 }
317320
@@ -438,6 +441,9 @@ static esp_err_t i2s_pdm_rx_set_slot(i2s_chan_handle_t handle, const i2s_pdm_rx_
438441 /* Update the mode info: slot configuration */
439442 i2s_pdm_rx_config_t * pdm_rx_cfg = (i2s_pdm_rx_config_t * )handle -> mode_info ;
440443 memcpy (& (pdm_rx_cfg -> slot_cfg ), slot_cfg , sizeof (i2s_pdm_rx_slot_config_t ));
444+ /* Update the slot bit width to the actual slot bit width */
445+ pdm_rx_cfg -> slot_cfg .slot_bit_width = (int )pdm_rx_cfg -> slot_cfg .slot_bit_width < (int )pdm_rx_cfg -> slot_cfg .data_bit_width ?
446+ pdm_rx_cfg -> slot_cfg .data_bit_width : pdm_rx_cfg -> slot_cfg .slot_bit_width ;
441447
442448 portENTER_CRITICAL (& g_i2s .spinlock );
443449 /* Configure the hardware to apply PDM format */
@@ -624,7 +630,7 @@ esp_err_t i2s_channel_reconfig_pdm_rx_slot(i2s_chan_handle_t handle, const i2s_p
624630
625631 /* If the slot bit width changed, then need to update the clock */
626632 uint32_t slot_bits = slot_cfg -> slot_bit_width == I2S_SLOT_BIT_WIDTH_AUTO ? slot_cfg -> data_bit_width : slot_cfg -> slot_bit_width ;
627- if (pdm_rx_cfg -> slot_cfg .slot_bit_width = = slot_bits ) {
633+ if (pdm_rx_cfg -> slot_cfg .slot_bit_width ! = slot_bits ) {
628634 ESP_GOTO_ON_ERROR (i2s_pdm_rx_set_clock (handle , & pdm_rx_cfg -> clk_cfg ), err , TAG , "update clock failed" );
629635 }
630636
0 commit comments