components/driver/i2s.c
/**
 * @brief   I2S destroy the whole DMA object
 *
 * @param   i2s_num     I2S device number
 * @param   dma         Secondary pointer to the DMA object
 * @return
 *      - ESP_OK                I2S DMA buffer has been destroyed successfully
 *      - ESP_ERR_INVALID_ARG   I2S driver has not installed yet
 */
@brief   I2S destroy the whole DMA object
@param   i2s_num     I2S device number
@param   dma         Secondary pointer to the DMA object
@return
- ESP_OK                I2S DMA buffer has been destroyed successfully
- ESP_ERR_INVALID_ARG   I2S driver has not installed yet
@brief I2S destroy the whole DMA object @param i2s_num I2S device number @param dma Secondary pointer to the DMA object @return - ESP_OK I2S DMA buffer has been destroyed successfully - ESP_ERR_INVALID_ARG I2S driver has not installed yet
static esp_err_t i2s_destroy_dma_object(i2s_port_t i2s_num, i2s_dma_t **dma)
{
    ESP_RETURN_ON_FALSE(p_i2s[i2s_num], ESP_ERR_INVALID_ARG, TAG, "I2S not initialized yet");
    if (!(*dma)) {
        return ESP_OK;
    }
    i2s_delete_dma_buffer(i2s_num, (*dma));
    if ((*dma)->desc) {
        free((*dma)->desc);
        (*dma)->desc = NULL;
    }
    if ((*dma)->buf) {
        free((*dma)->buf);
        (*dma)->buf = NULL;
    }
    vSemaphoreDelete((*dma)->mux);
    vQueueDelete((*dma)->queue);
    free(*dma);
    *dma = NULL;
    ESP_LOGI(TAG, "DMA queue destroyed");
    return ESP_OK;
}
static esp_err_t i2s_destroy_dma_object ( i2s_port_t i2s_num , i2s_dma_t * * dma ) { ESP_RETURN_ON_FALSE ( p_i2s [ i2s_num ] , ESP_ERR_INVALID_ARG , TAG , " " ) ; if ( ! ( * dma ) ) { return ESP_OK ; } i2s_delete_dma_buffer ( i2s_num , ( * dma ) ) ; if ( ( * dma ) -> desc ) { free ( ( * dma ) -> desc ) ; ( * dma ) -> desc = NULL ; } if ( ( * dma ) -> buf ) { free ( ( * dma ) -> buf ) ; ( * dma ) -> buf = NULL ; } vSemaphoreDelete ( ( * dma ) -> mux ) ; vQueueDelete ( ( * dma ) -> queue ) ; free ( * dma ) ; * dma = NULL ; ESP_LOGI ( TAG , " " ) ; return ESP_OK ; }
@brief   I2S destroy the whole DMA object
 @param   i2s_num     I2S device number
 @param   dma         Secondary pointer to the DMA object
 @return
      - ESP_OK                I2S DMA buffer has been destroyed successfully
      - ESP_ERR_INVALID_ARG   I2S driver has not installed yet
@brief I2S destroy the whole DMA object @param i2s_num I2S device number @param dma Secondary pointer to the DMA object @return - ESP_OK I2S DMA buffer has been destroyed successfully - ESP_ERR_INVALID_ARG I2S driver has not installed yet
/* Check if DMA truely need destroy */ /* Destroy every descriptor and buffer */ /* Destroy descriptor pointer */ /* Destroy buffer pointer */ /* Delete DMA mux */ /* Delete DMA queue */ /* Free DMA structure */