mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/fix_pdm_rx_high_pass_cut_off_coeff' into 'master'
bugfix(i2s): fix pdm rx high pass filter cut off coeff See merge request espressif/esp-idf!26835
This commit is contained in:
commit
3ea8519a9e
@ -103,10 +103,14 @@ static esp_err_t i2s_pdm_tx_set_slot(i2s_chan_handle_t handle, const i2s_pdm_tx_
|
||||
/* Share bck and ws signal in full-duplex mode */
|
||||
i2s_ll_share_bck_ws(handle->controller->hal.dev, handle->controller->full_duplex);
|
||||
|
||||
/* Update the mode info: slot configuration */
|
||||
i2s_pdm_tx_config_t *pdm_tx_cfg = (i2s_pdm_tx_config_t *)handle->mode_info;
|
||||
memcpy(&(pdm_tx_cfg->slot_cfg), slot_cfg, sizeof(i2s_pdm_tx_slot_config_t));
|
||||
|
||||
portENTER_CRITICAL(&g_i2s.spinlock);
|
||||
/* Configure the hardware to apply PDM format */
|
||||
bool is_slave = handle->role == I2S_ROLE_SLAVE;
|
||||
i2s_hal_slot_config_t *slot_hal_cfg = (i2s_hal_slot_config_t *)slot_cfg;
|
||||
i2s_hal_slot_config_t *slot_hal_cfg = (i2s_hal_slot_config_t *)(&(pdm_tx_cfg->slot_cfg));
|
||||
#if SOC_I2S_HW_VERSION_2
|
||||
/* Times 10 to transform the float type to integer because we should avoid float type in hal */
|
||||
slot_hal_cfg->pdm_tx.hp_cut_off_freq_hzx10 = (uint32_t)(slot_cfg->hp_cut_off_freq_hz * 10);
|
||||
@ -114,10 +118,6 @@ static esp_err_t i2s_pdm_tx_set_slot(i2s_chan_handle_t handle, const i2s_pdm_tx_
|
||||
i2s_hal_pdm_set_tx_slot(&(handle->controller->hal), is_slave, slot_hal_cfg);
|
||||
portEXIT_CRITICAL(&g_i2s.spinlock);
|
||||
|
||||
/* Update the mode info: slot configuration */
|
||||
i2s_pdm_tx_config_t *pdm_tx_cfg = (i2s_pdm_tx_config_t *)handle->mode_info;
|
||||
memcpy(&(pdm_tx_cfg->slot_cfg), slot_cfg, sizeof(i2s_pdm_tx_slot_config_t));
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@ -389,16 +389,21 @@ static esp_err_t i2s_pdm_rx_set_slot(i2s_chan_handle_t handle, const i2s_pdm_rx_
|
||||
/* Share bck and ws signal in full-duplex mode */
|
||||
i2s_ll_share_bck_ws(handle->controller->hal.dev, handle->controller->full_duplex);
|
||||
|
||||
portENTER_CRITICAL(&g_i2s.spinlock);
|
||||
/* Configure the hardware to apply PDM format */
|
||||
bool is_slave = (handle->role == I2S_ROLE_SLAVE) | handle->controller->full_duplex;
|
||||
i2s_hal_pdm_set_rx_slot(&(handle->controller->hal), is_slave, (i2s_hal_slot_config_t *)slot_cfg);
|
||||
portEXIT_CRITICAL(&g_i2s.spinlock);
|
||||
|
||||
/* Update the mode info: slot configuration */
|
||||
i2s_pdm_rx_config_t *pdm_rx_cfg = (i2s_pdm_rx_config_t *)handle->mode_info;
|
||||
memcpy(&(pdm_rx_cfg->slot_cfg), slot_cfg, sizeof(i2s_pdm_rx_slot_config_t));
|
||||
|
||||
portENTER_CRITICAL(&g_i2s.spinlock);
|
||||
/* Configure the hardware to apply PDM format */
|
||||
bool is_slave = (handle->role == I2S_ROLE_SLAVE) | handle->controller->full_duplex;
|
||||
i2s_hal_slot_config_t *slot_hal_cfg = (i2s_hal_slot_config_t *)(&(pdm_rx_cfg->slot_cfg));
|
||||
#if SOC_I2S_SUPPORTS_PDM_RX_HP_FILTER
|
||||
/* Times 10 to transform the float type to integer because we should avoid float type in hal */
|
||||
slot_hal_cfg->pdm_rx.hp_cut_off_freq_hzx10 = (uint32_t)(slot_cfg->hp_cut_off_freq_hz * 10);
|
||||
#endif
|
||||
i2s_hal_pdm_set_rx_slot(&(handle->controller->hal), is_slave, slot_hal_cfg);
|
||||
portEXIT_CRITICAL(&g_i2s.spinlock);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
@ -255,7 +255,7 @@ void i2s_hal_pdm_set_rx_slot(i2s_hal_context_t *hal, bool is_slave, const i2s_ha
|
||||
#if SOC_I2S_SUPPORTS_PDM_RX_HP_FILTER
|
||||
uint32_t param0;
|
||||
uint32_t param5;
|
||||
s_i2s_hal_get_cut_off_coef(slot_cfg->pdm_rx.hp_cut_off_freq_hz, ¶m0, ¶m5);
|
||||
s_i2s_hal_get_cut_off_coef(slot_cfg->pdm_rx.hp_cut_off_freq_hzx10, ¶m0, ¶m5);
|
||||
i2s_ll_rx_enable_pdm_hp_filter(hal->dev, slot_cfg->pdm_rx.hp_en);
|
||||
i2s_ll_rx_set_pdm_hp_filter_param0(hal->dev, param0);
|
||||
i2s_ll_rx_set_pdm_hp_filter_param5(hal->dev, param5);
|
||||
|
@ -94,7 +94,7 @@ typedef struct {
|
||||
i2s_pdm_slot_mask_t slot_mask; /*!< Choose the slots to activate */
|
||||
#if SOC_I2S_SUPPORTS_PDM_RX_HP_FILTER
|
||||
bool hp_en; /*!< High pass filter enable */
|
||||
float hp_cut_off_freq_hz; /*!< High pass filter cut-off frequency, range 23.3Hz ~ 185Hz, see cut-off frequency sheet above */
|
||||
uint32_t hp_cut_off_freq_hzx10; /*!< High pass filter cut-off frequency times 10, range 23.3Hz ~ 185Hz, see cut-off frequency sheet above */
|
||||
uint32_t amplify_num; /*!< The amplification number of the final conversion result */
|
||||
#endif // SOC_I2S_SUPPORTS_PDM_RX_HP_FILTER
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user