components/driver/i2s.c
/**
 * @brief   I2S calculate clocks according to the selected I2S mode
 *
 * @param   i2s_num     I2S device number
 * @param   clk_cfg         Struct to restore clock confiuration
 * @return
 *      - ESP_OK                Claculate clock success
 *      - ESP_ERR_INVALID_ARG   Invalid args
 */
@brief   I2S calculate clocks according to the selected I2S mode
@param   i2s_num     I2S device number
@param   clk_cfg         Struct to restore clock confiuration
@return
- ESP_OK                Claculate clock success
- ESP_ERR_INVALID_ARG   Invalid args
@brief I2S calculate clocks according to the selected I2S mode @param i2s_num I2S device number @param clk_cfg Struct to restore clock confiuration @return - ESP_OK Claculate clock success - ESP_ERR_INVALID_ARG Invalid args
static esp_err_t i2s_calculate_clock(i2s_port_t i2s_num, i2s_hal_clock_cfg_t *clk_cfg)
{
#if SOC_I2S_SUPPORTS_ADC
    if (p_i2s[i2s_num]->hal_cfg.mode & I2S_MODE_ADC_BUILT_IN) {
        ESP_RETURN_ON_ERROR(i2s_calculate_adc_dac_clock(i2s_num, clk_cfg), TAG, "ADC clock calculate failed");
        return ESP_OK;
    }
#endif 
#if SOC_I2S_SUPPORTS_DAC
    if (p_i2s[i2s_num]->hal_cfg.mode & I2S_MODE_DAC_BUILT_IN) {
        ESP_RETURN_ON_ERROR(i2s_calculate_adc_dac_clock(i2s_num, clk_cfg), TAG, "DAC clock calculate failed");
        return ESP_OK;
    }
#endif 
#if SOC_I2S_SUPPORTS_PDM_TX || SOC_I2S_SUPPORTS_PDM_RX
    if (p_i2s[i2s_num]->hal_cfg.mode & I2S_MODE_PDM) {
#if SOC_I2S_SUPPORTS_PDM_TX
        if (p_i2s[i2s_num]->hal_cfg.mode & I2S_MODE_TX) {
            ESP_RETURN_ON_ERROR(i2s_calculate_pdm_tx_clock(i2s_num, clk_cfg), TAG, "PDM TX clock calculate failed");
        }
#endif 
#if SOC_I2S_SUPPORTS_PDM_RX
        if (p_i2s[i2s_num]->hal_cfg.mode & I2S_MODE_RX) {
            ESP_RETURN_ON_ERROR(i2s_calculate_pdm_rx_clock(i2s_num, clk_cfg), TAG, "PDM RX clock calculate failed");
        }
#endif 
        return ESP_OK;
    }
#endif  || SOC_I2S_SUPPORTS_PDM_RX
    ESP_RETURN_ON_ERROR(i2s_calculate_common_clock(i2s_num, clk_cfg), TAG, "Common clock calculate failed");
    return ESP_OK;
}
static esp_err_t i2s_calculate_clock ( i2s_port_t i2s_num , i2s_hal_clock_cfg_t * clk_cfg ) { #if SOC_I2S_SUPPORTS_ADC if ( p_i2s [ i2s_num ] -> hal_cfg . mode & I2S_MODE_ADC_BUILT_IN ) { ESP_RETURN_ON_ERROR ( i2s_calculate_adc_dac_clock ( i2s_num , clk_cfg ) , TAG , " " ) ; return ESP_OK ; } #endif #if SOC_I2S_SUPPORTS_DAC if ( p_i2s [ i2s_num ] -> hal_cfg . mode & I2S_MODE_DAC_BUILT_IN ) { ESP_RETURN_ON_ERROR ( i2s_calculate_adc_dac_clock ( i2s_num , clk_cfg ) , TAG , " " ) ; return ESP_OK ; } #endif #if SOC_I2S_SUPPORTS_PDM_TX || SOC_I2S_SUPPORTS_PDM_RX if ( p_i2s [ i2s_num ] -> hal_cfg . mode & I2S_MODE_PDM ) { #if SOC_I2S_SUPPORTS_PDM_TX if ( p_i2s [ i2s_num ] -> hal_cfg . mode & I2S_MODE_TX ) { ESP_RETURN_ON_ERROR ( i2s_calculate_pdm_tx_clock ( i2s_num , clk_cfg ) , TAG , " " ) ; } #endif #if SOC_I2S_SUPPORTS_PDM_RX if ( p_i2s [ i2s_num ] -> hal_cfg . mode & I2S_MODE_RX ) { ESP_RETURN_ON_ERROR ( i2s_calculate_pdm_rx_clock ( i2s_num , clk_cfg ) , TAG , " " ) ; } #endif return ESP_OK ; } #endif ESP_RETURN_ON_ERROR ( i2s_calculate_common_clock ( i2s_num , clk_cfg ) , TAG , " " ) ; return ESP_OK ; }
@brief   I2S calculate clocks according to the selected I2S mode
 @param   i2s_num     I2S device number
 @param   clk_cfg         Struct to restore clock confiuration
 @return
      - ESP_OK                Claculate clock success
      - ESP_ERR_INVALID_ARG   Invalid args
@brief I2S calculate clocks according to the selected I2S mode @param i2s_num I2S device number @param clk_cfg Struct to restore clock confiuration @return - ESP_OK Claculate clock success - ESP_ERR_INVALID_ARG Invalid args
/* Calculate clock for ADC mode */ // SOC_I2S_SUPPORTS_ADC /* Calculate clock for DAC mode */ // SOC_I2S_SUPPORTS_DAC /* Calculate clock for PDM mode */ // SOC_I2S_SUPPORTS_PDM_TX // SOC_I2S_SUPPORTS_PDM_RX // SOC_I2S_SUPPORTS_PDM_TX || SOC_I2S_SUPPORTS_PDM_RX /* Calculate clock for common mode */