mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-18 15:53:53 +00:00
refactor(spi): replace dma_ll related in spi by dma driver (part1)
This commit is contained in:
47
components/esp_driver_spi/src/gpspi/spi_dma.c
Normal file
47
components/esp_driver_spi/src/gpspi/spi_dma.c
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "esp_private/spi_dma.h"
|
||||
#include "hal/spi_ll.h"
|
||||
|
||||
#if !SOC_GDMA_SUPPORTED
|
||||
void spi_dma_enable_burst(spi_dma_chan_handle_t chan_handle, bool data_burst, bool desc_burst)
|
||||
{
|
||||
spi_dma_dev_t *spi_dma = SPI_LL_GET_HW(chan_handle.host_id);
|
||||
|
||||
if (chan_handle.dir == DMA_CHANNEL_DIRECTION_TX) {
|
||||
spi_dma_ll_tx_enable_burst_data(spi_dma, chan_handle.chan_id, data_burst);
|
||||
spi_dma_ll_tx_enable_burst_desc(spi_dma, chan_handle.chan_id, desc_burst);
|
||||
} else {
|
||||
spi_dma_ll_rx_enable_burst_data(spi_dma, chan_handle.chan_id, data_burst);
|
||||
spi_dma_ll_rx_enable_burst_desc(spi_dma, chan_handle.chan_id, desc_burst);
|
||||
}
|
||||
}
|
||||
|
||||
/************************************* IRAM CONTEXT **************************************/
|
||||
|
||||
void spi_dma_reset(spi_dma_chan_handle_t chan_handle)
|
||||
{
|
||||
spi_dma_dev_t *spi_dma = SPI_LL_GET_HW(chan_handle.host_id);
|
||||
|
||||
if (chan_handle.dir == DMA_CHANNEL_DIRECTION_TX) {
|
||||
spi_dma_ll_tx_reset(spi_dma, chan_handle.chan_id);
|
||||
} else {
|
||||
spi_dma_ll_rx_reset(spi_dma, chan_handle.chan_id);
|
||||
}
|
||||
}
|
||||
|
||||
void spi_dma_start(spi_dma_chan_handle_t chan_handle, void *addr)
|
||||
{
|
||||
spi_dma_dev_t *spi_dma = SPI_LL_GET_HW(chan_handle.host_id);
|
||||
|
||||
if (chan_handle.dir == DMA_CHANNEL_DIRECTION_TX) {
|
||||
spi_dma_ll_tx_start(spi_dma, chan_handle.chan_id, (lldesc_t *)addr);
|
||||
} else {
|
||||
spi_dma_ll_rx_start(spi_dma, chan_handle.chan_id, (lldesc_t *)addr);
|
||||
}
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user