Skip to content
Snippets Groups Projects
Select Git revision
  • bae4944b908c0c3d3f54a984a3aa96db0ece2a96
  • 5.1-flow3r default
  • v5.1-flow3r
  • v4.2.5
  • v5.1
  • v5.1-rc2
  • v4.4.5
  • v5.1-rc1
  • v5.0.2
  • v5.1-beta1
  • v5.2-dev
  • v4.3.5
  • v5.0.1
  • v4.4.4
  • v4.1.4
  • v5.0
  • v5.0-rc1
  • v4.4.3
  • v4.3.4
  • v4.2.4
  • v5.0-beta1
  • v5.1-dev
22 results

i2s_legacy.c

Blame
  • i2s_legacy.c 76.78 KiB
    /*
     * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    #include <string.h>
    #include <stdbool.h>
    #include <math.h>
    #include <esp_types.h>
    #include "freertos/FreeRTOS.h"
    #include "freertos/queue.h"
    #include "freertos/semphr.h"
    
    #include "sdkconfig.h"
    
    #if CONFIG_I2S_ENABLE_DEBUG_LOG
    // The local log level must be defined before including esp_log.h
    // Set the maximum log level for this source file
    #define LOG_LOCAL_LEVEL ESP_LOG_DEBUG
    #endif
    
    #include "soc/lldesc.h"
    #include "driver/gpio.h"
    #include "hal/gpio_hal.h"
    #include "driver/i2s_types_legacy.h"
    #include "hal/i2s_hal.h"
    #if SOC_I2S_SUPPORTS_DAC
    #include "driver/dac.h"
    #include "esp_private/adc_share_hw_ctrl.h"
    #include "adc1_private.h"
    #include "driver/adc_i2s_legacy.h"
    #include "driver/adc_types_legacy.h"
    #endif // SOC_I2S_SUPPORTS_ADC
    
    #if SOC_GDMA_SUPPORTED
    #include "esp_private/gdma.h"
    #endif
    
    #include "clk_ctrl_os.h"
    #include "esp_intr_alloc.h"
    #include "esp_err.h"
    #include "esp_check.h"
    #include "esp_attr.h"
    #include "esp_log.h"
    #include "esp_pm.h"
    #include "esp_efuse.h"
    #include "esp_rom_gpio.h"
    #include "esp_private/periph_ctrl.h"
    #include "esp_private/esp_clk.h"
    
    static const char *TAG = "i2s(legacy)";
    
    #define I2S_ENTER_CRITICAL_ISR(i2s_num)          portENTER_CRITICAL_ISR(&i2s_spinlock[i2s_num])
    #define I2S_EXIT_CRITICAL_ISR(i2s_num)           portEXIT_CRITICAL_ISR(&i2s_spinlock[i2s_num])
    #define I2S_ENTER_CRITICAL(i2s_num)              portENTER_CRITICAL(&i2s_spinlock[i2s_num])
    #define I2S_EXIT_CRITICAL(i2s_num)               portEXIT_CRITICAL(&i2s_spinlock[i2s_num])
    
    #define I2S_DMA_BUFFER_MAX_SIZE     4092
    
    #if SOC_I2S_SUPPORTS_ADC_DAC
    #define    I2S_COMM_MODE_ADC_DAC    -1
    #endif
    
    /**
     * @brief General clock configuration information
     * @note It is a general purpose struct, not supposed to be used directly by user
     */
    typedef struct {
        uint32_t                sample_rate_hz;     /*!< I2S sample rate */