1 /* 2 * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #pragma once 8 9 /* Common header for ESP32-S2 ADC/DAC tests */ 10 11 /** 12 * SPI DMA type. 13 */ 14 typedef enum { 15 DMA_ONLY_ADC_INLINK = BIT(1), /*!<Select ADC-DMA config. */ 16 DMA_ONLY_DAC_OUTLINK = BIT(2), /*!<Select DAC-DMA config. */ 17 DMA_BOTH_ADC_DAC, /*!<Select DAC-DMA and ADC-DMA config. */ 18 #define DMA_BOTH_ADC_DAC (DMA_ONLY_ADC_INLINK | DMA_ONLY_DAC_OUTLINK) 19 } spi_dma_link_type_t; 20 21 /** 22 * Register SPI-DMA interrupt handler. 23 * 24 * @param handler Handler. 25 * @param handler_arg Handler parameter. 26 * @param intr_mask DMA interrupt type mask. 27 */ 28 esp_err_t adc_dac_dma_isr_register(intr_handler_t handler, void* handler_arg, uint32_t intr_mask); 29 30 /** 31 * Deregister SPI-DMA interrupt handler. 32 * 33 * @param handler Handler. 34 * @param handler_arg Handler parameter. 35 */ 36 esp_err_t adc_dac_dma_isr_deregister(intr_handler_t handler, void* handler_arg); 37 38 /** 39 * Reset DMA linker pointer and start DMA. 40 * 41 * @param type DMA linker type. See ``spi_dma_link_type_t``. 42 * @param dma_addr DMA linker addr. 43 * @param int_msk DMA interrupt type mask. 44 */ 45 void adc_dac_dma_linker_start(spi_dma_link_type_t type, void *dma_addr, uint32_t int_msk); 46 47 /** 48 * Stop DMA. 49 * 50 * @param type DMA linker type. See ``spi_dma_link_type_t``. 51 */ 52 void adc_dac_dma_linker_stop(spi_dma_link_type_t type); 53 54 /** 55 * Deinit SPI3 DMA. Disable interrupt, stop DMA trans. 56 */ 57 void adc_dac_dma_linker_deinit(void); 58