1 // Copyright 2020 Espressif Systems (Shanghai) PTE LTD 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #pragma once 16 17 #include <stdint.h> 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 /** 24 * @brief Type of DMA descriptor 25 * 26 */ 27 typedef struct dma_descriptor_s { 28 struct { 29 uint32_t size : 12; /*!< Buffer size */ 30 uint32_t length : 12; /*!< Number of valid bytes in the buffer */ 31 uint32_t reversed24_27 : 4; /*!< Reserved */ 32 uint32_t err_eof : 1; /*!< Whether the received buffer contains error */ 33 uint32_t reserved29 : 1; /*!< Reserved */ 34 uint32_t suc_eof : 1; /*!< Whether the descriptor is the last one in the link */ 35 uint32_t owner : 1; /*!< Who is allowed to access the buffer that this descriptor points to */ 36 } dw0; /*!< Descriptor Word 0 */ 37 void *buffer; /*!< Pointer to the buffer */ 38 struct dma_descriptor_s *next; /*!< Pointer to the next descriptor (set to NULL if the descriptor is the last one, e.g. suc_eof=1) */ 39 } dma_descriptor_t; 40 41 _Static_assert(sizeof(dma_descriptor_t) == 12, "dma_descriptor_t should occupy 12 bytes in memory"); 42 43 #define DMA_DESCRIPTOR_BUFFER_OWNER_CPU (0) /*!< DMA buffer is allowed to be accessed by CPU */ 44 #define DMA_DESCRIPTOR_BUFFER_OWNER_DMA (1) /*!< DMA buffer is allowed to be accessed by DMA engine */ 45 #define DMA_DESCRIPTOR_BUFFER_MAX_SIZE (4095) /*!< Maximum size of the buffer that can be attached to descriptor */ 46 47 #ifdef __cplusplus 48 } 49 #endif 50