AM275 FreeRTOS SDK  11.01.00
aasrc_dma.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2025 Texas Instruments Incorporated
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
48  #ifndef AASRC_DMA_H_
49  #define AASRC_DMA_H_
50 
51  /* ========================================================================== */
52  /* Include Files */
53  /* ========================================================================== */
54 
55  /* None */
56 
57  #ifdef __cplusplus
58  extern "C" {
59  #endif
60 
61  /* ========================================================================== */
62  /* Macros & Typedefs */
63  /* ========================================================================== */
64 
65  /* Element count in Tx Ring */
66 #define AASRC_TX_DMA_RING_ELEM_CNT (1U)
67 
68 /* TR count in TX TRPD */
69 #define AASRC_TX_DMA_TR_COUNT (64U)
70 
71 /* Element count in Rx Ring */
72 #define AASRC_RX_DMA_RING_ELEM_CNT (1U)
73 
74 /* TR count in RX TRPD */
75 #define AASRC_RX_DMA_TR_COUNT (64U)
76 
77 #define AASRC_DMA_L0_MAX_XFER_SIZE (65535U)
78 #define AASRC_DMA_UDMA_XFER_SIZE (64512U)
79 #define AASRC_DMA_TX_CH_FIFO_DEPTH (128U)
80 #define AASRC_DMA_RX_CH_FIFO_DEPTH (128U)
81 
82 #define AASRC_UDMA_TRPD_MEM_SIZE_TX (UDMA_GET_TRPD_TR3_SIZE(AASRC_TX_DMA_TR_COUNT))
83 #define AASRC_UDMA_TRPD_MEM_SIZE_RX (UDMA_GET_TRPD_TR3_SIZE(AASRC_RX_DMA_TR_COUNT))
84 
85 #define AASRC_UDMA_RING_ENTRY_SIZE (sizeof(uint64_t))
86 #define AASRC_UDMA_RING_MEM_SIZE_TX (AASRC_TX_DMA_RING_ELEM_CNT * AASRC_UDMA_RING_ENTRY_SIZE)
87 #define AASRC_UDMA_RING_MEM_SIZE_RX (AASRC_RX_DMA_RING_ELEM_CNT * AASRC_UDMA_RING_ENTRY_SIZE)
88 
89 /* DMA perpertual reload count */
90 #define AASRC_DMA_PERPETUAL_RELOAD_CNT (0x1FFU)
91 
92 #define WORD_BYTE_COUNT (4U)
93 
94 #define AASRC_INVALID_TXN_IDX (0xDEADBEEFU)
95 
96 #define AASRC_ICNT2_MAX (65535U)
97 
98  /* ========================================================================== */
99  /* Structure Declarations */
100  /* ========================================================================== */
101 
107 typedef struct AASRC_DMAChConfig_s
108 {
109  void *txChHandle;
111  void *rxChHandle;
117  void *txTrpdMem;
119  void *rxTrpdMem;
121  uint32_t trpdMemSize;
123  void *txRingMem;
125  void *rxRingMem;
127  void *txCbParams;
129  void *rxCbParams;
131  uint32_t rxEvtNum;
133  uint32_t txEvtNum;
135  uint32_t isOpen;
138 
139  typedef struct
140 {
141  uint8_t initDone;
143  uint32_t txnByteCnt;
145  uint16_t icnt0;
147  uint16_t icnt1;
149  uint16_t icnt2;
151  uint16_t icnt3;
153 } AASRC_DmaIcnt;
154 
155 
156 /* ========================================================================== */
157 /* API Function Declarations */
158 /* ========================================================================== */
159 
160 /* None */
161 
162 /* ========================================================================== */
163 /* Local Function Definitions */
164 /* ========================================================================== */
165 
176 int32_t AASRC_dmaChOpen(AASRC_ChHandle chHandle);
177 
189 
202 
214 
224 
234 
235 
236 #ifdef __cplusplus
237 }
238 #endif
239 
240 #endif /* #ifndef AASRC_DMA_H_ */
241 
AASRC_DmaIcnt::txnByteCnt
uint32_t txnByteCnt
Definition: aasrc_dma.h:143
AASRC_disableDmaTx
int32_t AASRC_disableDmaTx(AASRC_ChHandle chHandle)
Function disables the UDMA channel for AASRC channel Rx.
AASRC_ChHandle
void * AASRC_ChHandle
AASRC channel handle which points to AASRC channnel status and configs.
Definition: aasrc_types.h:71
AASRC_DmaChCfg::txRingMem
void * txRingMem
Definition: aasrc_dma.h:123
AASRC_DmaChCfg::isOpen
uint32_t isOpen
Definition: aasrc_dma.h:135
AASRC_DmaIcnt
Definition: aasrc_dma.h:140
AASRC_DmaChCfg::txCbParams
void * txCbParams
Definition: aasrc_dma.h:127
AASRC_dmaChEnable
int32_t AASRC_dmaChEnable(AASRC_ChHandle chHandle)
Function enables the UDMA channel for AASRC channel RX/TX.
AASRC_DmaChCfg::rxCbParams
void * rxCbParams
Definition: aasrc_dma.h:129
AASRC_DmaChCfg
Data structure used to store DMA channel configuration.
Definition: aasrc_dma.h:108
AASRC_DmaIcnt::icnt2
uint16_t icnt2
Definition: aasrc_dma.h:149
AASRC_DmaIcnt::initDone
uint8_t initDone
Definition: aasrc_dma.h:141
AASRC_DmaChCfg::rxRingMem
void * rxRingMem
Definition: aasrc_dma.h:125
AASRC_DmaChCfg::cqTxEvtHandle
void * cqTxEvtHandle
Definition: aasrc_dma.h:113
AASRC_DmaChCfg::rxTrpdMem
void * rxTrpdMem
Definition: aasrc_dma.h:119
AASRC_DmaChCfg::trpdMemSize
uint32_t trpdMemSize
Definition: aasrc_dma.h:121
AASRC_disableDmaRx
int32_t AASRC_disableDmaRx(AASRC_ChHandle chHandle)
Function disables the UDMA channel for AASRC channel Tx.
AASRC_DmaChCfg::txEvtNum
uint32_t txEvtNum
Definition: aasrc_dma.h:133
AASRC_dmaChClose
int32_t AASRC_dmaChClose(AASRC_ChHandle chHandle)
Function closes the UDMA channel for AASRC channel RX/TX.
AASRC_DmaIcnt::icnt0
uint16_t icnt0
Definition: aasrc_dma.h:145
AASRC_DmaChCfg::rxEvtNum
uint32_t rxEvtNum
Definition: aasrc_dma.h:131
AASRC_DmaIcnt::icnt1
uint16_t icnt1
Definition: aasrc_dma.h:147
AASRC_DmaChCfg::cqRxEvtHandle
void * cqRxEvtHandle
Definition: aasrc_dma.h:115
AASRC_DmaIcnt::icnt3
uint16_t icnt3
Definition: aasrc_dma.h:151
AASRC_dmaChDisable
int32_t AASRC_dmaChDisable(AASRC_ChHandle chHandle)
Function disables the UDMA channel for AASRC channel RX/TX.
AASRC_DmaChCfg::txTrpdMem
void * txTrpdMem
Definition: aasrc_dma.h:117
AASRC_dmaChOpen
int32_t AASRC_dmaChOpen(AASRC_ChHandle chHandle)
Function opens an UDMA channel for AASRC channel RX/TX.
AASRC_DmaChCfg::rxChHandle
void * rxChHandle
Definition: aasrc_dma.h:111
AASRC_DmaChCfg::txChHandle
void * txChHandle
Definition: aasrc_dma.h:109