1 /*
2  * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #pragma once
8 
9 #include <stdint.h>
10 #include "esp_assert.h"
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 /**
17  * @brief Type of DMA descriptor
18  *
19  */
20 typedef struct dma_descriptor_s {
21     struct {
22         uint32_t size : 12;         /*!< Buffer size */
23         uint32_t length : 12;       /*!< Number of valid bytes in the buffer */
24         uint32_t reversed24_27 : 4; /*!< Reserved */
25         uint32_t err_eof : 1;       /*!< Whether the received buffer contains error */
26         uint32_t reserved29 : 1;    /*!< Reserved */
27         uint32_t suc_eof : 1;       /*!< Whether the descriptor is the last one in the link */
28         uint32_t owner : 1;         /*!< Who is allowed to access the buffer that this descriptor points to */
29     } dw0;                          /*!< Descriptor Word 0 */
30     void *buffer;                   /*!< Pointer to the buffer */
31     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) */
32 } dma_descriptor_t;
33 
34 ESP_STATIC_ASSERT(sizeof(dma_descriptor_t) == 12, "dma_descriptor_t should occupy 12 bytes in memory");
35 
36 #define DMA_DESCRIPTOR_BUFFER_OWNER_CPU (0)   /*!< DMA buffer is allowed to be accessed by CPU */
37 #define DMA_DESCRIPTOR_BUFFER_OWNER_DMA (1)   /*!< DMA buffer is allowed to be accessed by DMA engine */
38 #define DMA_DESCRIPTOR_BUFFER_MAX_SIZE (4095) /*!< Maximum size of the buffer that can be attached to descriptor */
39 #define DMA_DESCRIPTOR_BUFFER_MAX_SIZE_4B_ALIGNED  (4095-3)  /*!< Maximum size of the buffer that can be attached to descriptor, and aligned to 4B */
40 
41 
42 #ifdef __cplusplus
43 }
44 #endif
45