AM263x MCU+ SDK  08.02.01
mcspi_dma.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021-22 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 
39 #ifndef MCSPI_DMA_H_
40 #define MCSPI_DMA_H_
41 
42 #include <stdint.h>
43 #include <kernel/dpl/SystemP.h>
44 #include <drivers/mcspi.h>
45 
46 #ifdef __cplusplus
47 extern "C"
48 {
49 #endif
50 
63 typedef void* MCSPI_DmaHandle;
64 
75 typedef int32_t (*MCSPI_dmaOpenFxn)(void *mcspiDmaArgs);
76 
88 typedef int32_t (*MCSPI_dmaCloseFxn)(MCSPI_Handle handle, const MCSPI_ChConfig *chCfg);
89 
102 typedef int32_t (*MCSPI_dmaChInitFxn)(MCSPI_Handle handle,
103  const MCSPI_ChConfig *chCfg,
104  const MCSPI_DmaChConfig *dmaChCfg);
105 
119 typedef int32_t (*MCSPI_dmaTransferMasterFxn)(MCSPI_Object *obj,
120  MCSPI_ChObject *chObj,
121  const MCSPI_Attrs *attrs,
122  MCSPI_Transaction *transaction);
136 typedef int32_t (*MCSPI_dmaStopFxn)(MCSPI_Object *obj,
137  const MCSPI_Attrs *attrs,
138  MCSPI_ChObject *chObj,
139  uint32_t chNum);
140 
144 typedef struct MCSPI_DmaFxns_s
145 {
151 
152 } MCSPI_DmaFxns;
153 
154 #if defined (DMA_VERSION_MCSPI_UDMA)
155 extern MCSPI_DmaFxns gMcspiDmaUdmaFxns;
156 #endif
157 #if defined (DMA_VERSION_MCSPI_EDMA)
158 extern MCSPI_DmaFxns gMcspiDmaEdmaFxns;
159 #endif
160 
164 typedef struct MCSPI_DmaConfig_s
165 {
167  /* Registered callbacks for a particular DMA driver. This will be set by Sysconfig depending on the DMA driver selected*/
169  /* Arguments specific to a DMA driver. This will be typecasted to the specific DMA driver args struct
170  * when used by the appropriate callback. This struct will be defined in the specific DMA driver header file.
171  * Allocation of this struct will be done statically using Sysconfig code generation in the example code
172  */
174 
185 
196 int32_t MCSPI_dmaClose(MCSPI_Handle handle, const MCSPI_ChConfig *chCfg);
197 
209 int32_t MCSPI_dmaChInit(MCSPI_Handle handle, const MCSPI_ChConfig *chCfg,
210  const MCSPI_DmaChConfig *dmaChCfg);
211 
226  const MCSPI_Attrs *attrs, MCSPI_Transaction *transaction);
227 
242  const MCSPI_Attrs *attrs,
243  MCSPI_ChObject *chObj,
244  uint32_t chNum);
247 #ifdef __cplusplus
248 }
249 #endif
250 
251 #endif /* MCSPI_DMA_H_ */
MCSPI_DmaChConfig
Definition: mcspi_dma_edma.h:51
MCSPI_Attrs
MCSPI instance attributes - used during init time.
Definition: mcspi/v0/mcspi.h:484
MCSPI_ChObject
MCSPI channel object.
Definition: mcspi/v0/mcspi.h:522
MCSPI_DmaFxns::dmaCloseFxn
MCSPI_dmaCloseFxn dmaCloseFxn
Definition: mcspi_dma.h:147
MCSPI_dmaChInit
int32_t MCSPI_dmaChInit(MCSPI_Handle handle, const MCSPI_ChConfig *chCfg, const MCSPI_DmaChConfig *dmaChCfg)
API to init a DMA Channel opened.
MCSPI_Transaction
Data structure used with MCSPI_transfer()
Definition: mcspi/v0/mcspi.h:352
SystemP.h
MCSPI_dmaChInitFxn
int32_t(* MCSPI_dmaChInitFxn)(MCSPI_Handle handle, const MCSPI_ChConfig *chCfg, const MCSPI_DmaChConfig *dmaChCfg)
Driver implementation to init a DMA channel params using a specific DMA driver - UDMA,...
Definition: mcspi_dma.h:102
MCSPI_Object
MCSPI driver object.
Definition: mcspi/v0/mcspi.h:577
MCSPI_DmaFxns::dmaOpenFxn
MCSPI_dmaOpenFxn dmaOpenFxn
Definition: mcspi_dma.h:146
MCSPI_dmaCloseFxn
int32_t(* MCSPI_dmaCloseFxn)(MCSPI_Handle handle, const MCSPI_ChConfig *chCfg)
Driver implementation to close a specific DMA driver channel - UDMA, EDMA etc.
Definition: mcspi_dma.h:88
MCSPI_Handle
void * MCSPI_Handle
A handle that is returned from a MCSPI_open() call.
Definition: mcspi/v0/mcspi.h:82
MCSPI_dmaTransfer
int32_t MCSPI_dmaTransfer(MCSPI_Object *obj, MCSPI_ChObject *chObj, const MCSPI_Attrs *attrs, MCSPI_Transaction *transaction)
API to do a DMA transfer using a specific DMA driver - UDMA, EDMA etc.
mcspi.h
MCSPI_dmaStop
int32_t MCSPI_dmaStop(MCSPI_Object *obj, const MCSPI_Attrs *attrs, MCSPI_ChObject *chObj, uint32_t chNum)
API to Stop DMA using a specific DMA driver - UDMA, EDMA etc.
MCSPI_dmaTransferMasterFxn
int32_t(* MCSPI_dmaTransferMasterFxn)(MCSPI_Object *obj, MCSPI_ChObject *chObj, const MCSPI_Attrs *attrs, MCSPI_Transaction *transaction)
Driver implementation to do a DMA transfer using a specific DMA driver - UDMA, EDMA etc.
Definition: mcspi_dma.h:119
MCSPI_DmaFxns
Driver implementation callbacks.
Definition: mcspi_dma.h:145
MCSPI_DmaFxns::dmaTransferMasterFxn
MCSPI_dmaTransferMasterFxn dmaTransferMasterFxn
Definition: mcspi_dma.h:149
MCSPI_DmaFxns::dmaChInitFxn
MCSPI_dmaChInitFxn dmaChInitFxn
Definition: mcspi_dma.h:148
MCSPI_DmaHandle
void * MCSPI_DmaHandle
Handle to the MCSPI DMA Config Object returned by MCSPI_dmaOpen.
Definition: mcspi_dma.h:63
MCSPI_dmaOpenFxn
int32_t(* MCSPI_dmaOpenFxn)(void *mcspiDmaArgs)
Driver implementation to open a specific DMA driver channel - UDMA, EDMA etc.
Definition: mcspi_dma.h:75
MCSPI_dmaOpen
MCSPI_DmaHandle MCSPI_dmaOpen(int32_t index)
API to open an MCSPI DMA channel.
MCSPI_dmaClose
int32_t MCSPI_dmaClose(MCSPI_Handle handle, const MCSPI_ChConfig *chCfg)
API to close an MCSPI DMA channel.
MCSPI_DmaConfig::fxns
MCSPI_DmaFxns * fxns
Definition: mcspi_dma.h:166
MCSPI_dmaStopFxn
int32_t(* MCSPI_dmaStopFxn)(MCSPI_Object *obj, const MCSPI_Attrs *attrs, MCSPI_ChObject *chObj, uint32_t chNum)
Driver implementation to Stop DMA using a specific DMA driver - UDMA, EDMA etc.
Definition: mcspi_dma.h:136
MCSPI_DmaFxns::dmaStopFxn
MCSPI_dmaStopFxn dmaStopFxn
Definition: mcspi_dma.h:150
MCSPI_DmaConfig::mcspiDmaArgs
void * mcspiDmaArgs
Definition: mcspi_dma.h:168
MCSPI_ChConfig
MCSPI configuration parameters for the channel.
Definition: mcspi/v0/mcspi.h:448
MCSPI_DmaConfig
MCSPI DMA Configuration, these are filled by SysCfg based on the DMA driver that is selected.
Definition: mcspi_dma.h:165