RTEMS: bsps/arm/atsam/include/libchip/include/xdmad.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
xdmad.h
1/* ---------------------------------------------------------------------------- */
2/* Atmel Microcontroller Software Support */
3/* SAM Software Package License */
4/* ---------------------------------------------------------------------------- */
5/* Copyright (c) 2015, Atmel Corporation */
6/* */
7/* All rights reserved. */
8/* */
9/* Redistribution and use in source and binary forms, with or without */
10/* modification, are permitted provided that the following condition is met: */
11/* */
12/* - Redistributions of source code must retain the above copyright notice, */
13/* this list of conditions and the disclaimer below. */
14/* */
15/* Atmel's name may not be used to endorse or promote products derived from */
16/* this software without specific prior written permission. */
17/* */
18/* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR */
19/* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
20/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE */
21/* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, */
22/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
23/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
24/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
25/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
26/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */
27/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
28/* ---------------------------------------------------------------------------- */
29
30#ifndef _XDMAD_H
31#define _XDMAD_H
32
33
34/*----------------------------------------------------------------------------
35 * Includes
36 *----------------------------------------------------------------------------*/
37
38#include "chip.h"
39#include <assert.h>
40
41
44/*----------------------------------------------------------------------------
45 * Consts
46 *----------------------------------------------------------------------------*/
47#define XDMAD_TRANSFER_MEMORY 0xFF
48#define XDMAD_ALLOC_FAILED 0xFFFF
50#define XDMAD_TRANSFER_TX 0
51#define XDMAD_TRANSFER_RX 1
52
53/* XDMA_MBR_UBC */
54#define XDMA_UBC_NDE (0x1u << 24)
55#define XDMA_UBC_NDE_FETCH_DIS (0x0u << 24)
56#define XDMA_UBC_NDE_FETCH_EN (0x1u << 24)
57#define XDMA_UBC_NSEN (0x1u << 25)
58#define XDMA_UBC_NSEN_UNCHANGED (0x0u << 25)
59#define XDMA_UBC_NSEN_UPDATED (0x1u << 25)
60#define XDMA_UBC_NDEN (0x1u << 26)
61#define XDMA_UBC_NDEN_UNCHANGED (0x0u << 26)
62#define XDMA_UBC_NDEN_UPDATED (0x1u << 26)
63#define XDMA_UBC_NVIEW_Pos 27
64#define XDMA_UBC_NVIEW_Msk (0x3u << XDMA_UBC_NVIEW_Pos)
65#define XDMA_UBC_NVIEW_NDV0 (0x0u << XDMA_UBC_NVIEW_Pos)
66#define XDMA_UBC_NVIEW_NDV1 (0x1u << XDMA_UBC_NVIEW_Pos)
67#define XDMA_UBC_NVIEW_NDV2 (0x2u << XDMA_UBC_NVIEW_Pos)
68#define XDMA_UBC_NVIEW_NDV3 (0x3u << XDMA_UBC_NVIEW_Pos)
69
70/*----------------------------------------------------------------------------
71 * MACRO
72 *----------------------------------------------------------------------------*/
73
76/*----------------------------------------------------------------------------
77 * Types
78 *----------------------------------------------------------------------------*/
83 typedef enum _XdmadStatus {
84 XDMAD_OK = 0,
85 XDMAD_PARTIAL_DONE,
86 XDMAD_DONE,
87 XDMAD_BUSY,
88 XDMAD_ERROR,
89 XDMAD_CANCELED
90} eXdmadStatus, eXdmadRC;
91
93 typedef enum _XdmadState {
94 XDMAD_STATE_FREE = 0,
95 XDMAD_STATE_ALLOCATED,
96 XDMAD_STATE_START,
97 XDMAD_STATE_IN_XFR,
98 XDMAD_STATE_DONE,
99 XDMAD_STATE_HALTED,
100} eXdmadState;
101
103 typedef enum _XdmadProgState {
104 XDMAD_SINGLE = 0,
105 XDMAD_MULTI,
106 XDMAD_LLI,
107} eXdmadProgState;
108
110 typedef void (*XdmadTransferCallback)(uint32_t Channel, void *pArg, uint32_t status);
111
113 typedef struct _XdmadChannel {
114 XdmadTransferCallback fCallback;
115 void *pArg;
116 uint8_t bIrqOwner;
117 uint8_t bSrcPeriphID;
118 uint8_t bDstPeriphID;
119 uint8_t bSrcTxIfID;
120 uint8_t bSrcRxIfID;
121 uint8_t bDstTxIfID;
122 uint8_t bDstRxIfID;
123 volatile uint8_t state;
124} sXdmadChannel;
125
127 typedef struct _Xdmad {
128 Xdmac *pXdmacs;
129 sXdmadChannel XdmaChannels[XDMACCHID_NUMBER];
130 uint8_t numControllers;
131 uint8_t numChannels;
132 uint8_t xdmaMutex;
133} sXdmad;
134
135 typedef struct _XdmadCfg {
137 uint32_t mbr_ubc;
139 uint32_t mbr_sa;
141 uint32_t mbr_da;
143 uint32_t mbr_cfg;
145 uint32_t mbr_bc;
147 uint32_t mbr_ds;
149 uint32_t mbr_sus;
151 uint32_t mbr_dus;
152} sXdmadCfg;
153
156 typedef struct _LinkedListDescriporView0 {
158 uint32_t mbr_nda;
160 uint32_t mbr_ubc;
162 uint32_t mbr_ta;
163} LinkedListDescriporView0;
164
167 typedef struct _LinkedListDescriporView1 {
169 uint32_t mbr_nda;
171 uint32_t mbr_ubc;
173 uint32_t mbr_sa;
175 uint32_t mbr_da;
176} LinkedListDescriporView1;
177
180 typedef struct _LinkedListDescriporView2 {
182 uint32_t mbr_nda;
184 uint32_t mbr_ubc;
186 uint32_t mbr_sa;
188 uint32_t mbr_da;
190 uint32_t mbr_cfg;
191} LinkedListDescriporView2;
192
195 typedef struct _LinkedListDescriporView3 {
197 uint32_t mbr_nda;
199 uint32_t mbr_ubc;
201 uint32_t mbr_sa;
203 uint32_t mbr_da;
205 uint32_t mbr_cfg;
207 uint32_t mbr_bc;
209 uint32_t mbr_ds;
211 uint32_t mbr_sus;
213 uint32_t mbr_dus;
214} LinkedListDescriporView3;
215
218extern sXdmad XDMAD_Instance;
219
220/*----------------------------------------------------------------------------
221 * Exported functions
222 *----------------------------------------------------------------------------*/
225extern uint32_t XDMAD_AllocateChannel(sXdmad *pXdmad,
226 uint8_t bSrcID, uint8_t bDstID);
227extern eXdmadRC XDMAD_FreeChannel(sXdmad *pXdmad, uint32_t dwChannel);
228
229extern eXdmadRC XDMAD_ConfigureTransfer(sXdmad *pXdmad,
230 uint32_t dwChannel,
231 sXdmadCfg *pXdmaParam,
232 uint32_t dwXdmaDescCfg,
233 uint32_t dwXdmaDescAddr,
234 uint32_t dwXdmaIntEn);
235
236extern eXdmadRC XDMAD_PrepareChannel(sXdmad *pXdmad, uint32_t dwChannel);
237
238extern eXdmadRC XDMAD_IsTransferDone(sXdmad *pXdmad, uint32_t dwChannel);
239
240extern eXdmadRC XDMAD_StartTransfer(sXdmad *pXdmad, uint32_t dwChannel);
241
242extern void XDMAD_DoNothingCallback(uint32_t Channel, void *pArg, uint32_t status);
243
244extern bool XDMAD_UpdateStatusFromCallback(sXdmad *pXdmad,
245 uint32_t Channel,
246 uint32_t status);
247
248extern eXdmadRC XDMAD_SetCallback(sXdmad *pXdmad,
249 uint32_t dwChannel,
250 XdmadTransferCallback fCallback,
251 void *pArg);
252
253extern eXdmadRC XDMAD_StopTransfer(sXdmad *pXdmad, uint32_t dwChannel);
256#endif //#ifndef _XDMAD_H
257
assert.h
Information for the Assert Handler.
XDMAD_ConfigureTransfer
eXdmadRC XDMAD_ConfigureTransfer(sXdmad *pXdmad, uint32_t dwChannel, sXdmadCfg *pXdmaParam, uint32_t dwXdmaDescCfg, uint32_t dwXdmaDescAddr, uint32_t dwXdmaIntEn)
Configure DMA for a single transfer.
Definition: xdmad.c:396
XDMAD_StartTransfer
eXdmadRC XDMAD_StartTransfer(sXdmad *pXdmad, uint32_t dwChannel)
Start xDMA transfer.
Definition: xdmad.c:457
XDMAD_FreeChannel
eXdmadRC XDMAD_FreeChannel(sXdmad *pXdmad, uint32_t dwChannel)
Free the specified xDMA channel.
Definition: xdmad.c:263
XDMAD_PrepareChannel
eXdmadRC XDMAD_PrepareChannel(sXdmad *pXdmad, uint32_t dwChannel)
Enable clock of the xDMA peripheral, Enable the dma peripheral, configure configuration register for ...
Definition: xdmad.c:323
XDMAD_StopTransfer
eXdmadRC XDMAD_StopTransfer(sXdmad *pXdmad, uint32_t dwChannel)
Stop DMA transfer.
Definition: xdmad.c:489
XDMAD_SetCallback
eXdmadRC XDMAD_SetCallback(sXdmad *pXdmad, uint32_t dwChannel, XdmadTransferCallback fCallback, void *pArg)
Set the callback function for xDMA channel transfer.
Definition: xdmad.c:293
XDMAD_AllocateChannel
uint32_t XDMAD_AllocateChannel(sXdmad *pXdmad, uint8_t bSrcID, uint8_t bDstID)
Allocate a XDMA channel for upper layer.
Definition: xdmad.c:244
LinkedListDescriporView2
struct _LinkedListDescriporView2 LinkedListDescriporView2
Structure for storing parameters for DMA view2 that can be performed by the DMA Master transfer.
eXdmadState
enum _XdmadState eXdmadState
eXdmadProgState
enum _XdmadProgState eXdmadProgState
sXdmadChannel
struct _XdmadChannel sXdmadChannel
XdmadTransferCallback
void(* XdmadTransferCallback)(uint32_t Channel, void *pArg, uint32_t status)
Definition: xdmad.h:110
_XdmadState
_XdmadState
Definition: xdmad.h:93
eXdmadStatus
enum _XdmadStatus eXdmadStatus
LinkedListDescriporView0
struct _LinkedListDescriporView0 LinkedListDescriporView0
Structure for storing parameters for DMA view0 that can be performed by the DMA Master transfer.
sXdmad
struct _Xdmad sXdmad
LinkedListDescriporView3
struct _LinkedListDescriporView3 LinkedListDescriporView3
Structure for storing parameters for DMA view3 that can be performed by the DMA Master transfer.
LinkedListDescriporView1
struct _LinkedListDescriporView1 LinkedListDescriporView1
Structure for storing parameters for DMA view1 that can be performed by the DMA Master transfer.
_XdmadProgState
_XdmadProgState
Definition: xdmad.h:103
_XdmadStatus
_XdmadStatus
Definition: xdmad.h:83
XDMAD_STATE_HALTED
@ XDMAD_STATE_HALTED
Definition: xdmad.h:99
XDMAD_STATE_IN_XFR
@ XDMAD_STATE_IN_XFR
Definition: xdmad.h:97
XDMAD_STATE_FREE
@ XDMAD_STATE_FREE
Definition: xdmad.h:94
XDMAD_STATE_ALLOCATED
@ XDMAD_STATE_ALLOCATED
Definition: xdmad.h:95
XDMAD_STATE_DONE
@ XDMAD_STATE_DONE
Definition: xdmad.h:98
XDMAD_STATE_START
@ XDMAD_STATE_START
Definition: xdmad.h:96
XDMAD_CANCELED
@ XDMAD_CANCELED
Definition: xdmad.h:89
XDMAD_BUSY
@ XDMAD_BUSY
Definition: xdmad.h:87
XDMAD_ERROR
@ XDMAD_ERROR
Definition: xdmad.h:88
XDMAD_OK
@ XDMAD_OK
Definition: xdmad.h:84
Xdmac
Definition: component_xdmac.h:60
_LinkedListDescriporView0
Structure for storing parameters for DMA view0 that can be performed by the DMA Master transfer.
Definition: xdmad.h:156
_LinkedListDescriporView0::mbr_nda
uint32_t mbr_nda
Definition: xdmad.h:158
_LinkedListDescriporView0::mbr_ta
uint32_t mbr_ta
Definition: xdmad.h:162
_LinkedListDescriporView0::mbr_ubc
uint32_t mbr_ubc
Definition: xdmad.h:160
_LinkedListDescriporView1
Structure for storing parameters for DMA view1 that can be performed by the DMA Master transfer.
Definition: xdmad.h:167
_LinkedListDescriporView1::mbr_da
uint32_t mbr_da
Definition: xdmad.h:175
_LinkedListDescriporView1::mbr_nda
uint32_t mbr_nda
Definition: xdmad.h:169
_LinkedListDescriporView1::mbr_sa
uint32_t mbr_sa
Definition: xdmad.h:173
_LinkedListDescriporView1::mbr_ubc
uint32_t mbr_ubc
Definition: xdmad.h:171
_LinkedListDescriporView2
Structure for storing parameters for DMA view2 that can be performed by the DMA Master transfer.
Definition: xdmad.h:180
_LinkedListDescriporView2::mbr_da
uint32_t mbr_da
Definition: xdmad.h:188
_LinkedListDescriporView2::mbr_cfg
uint32_t mbr_cfg
Definition: xdmad.h:190
_LinkedListDescriporView2::mbr_sa
uint32_t mbr_sa
Definition: xdmad.h:186
_LinkedListDescriporView2::mbr_ubc
uint32_t mbr_ubc
Definition: xdmad.h:184
_LinkedListDescriporView2::mbr_nda
uint32_t mbr_nda
Definition: xdmad.h:182
_LinkedListDescriporView3
Structure for storing parameters for DMA view3 that can be performed by the DMA Master transfer.
Definition: xdmad.h:195
_LinkedListDescriporView3::mbr_cfg
uint32_t mbr_cfg
Definition: xdmad.h:205
_LinkedListDescriporView3::mbr_dus
uint32_t mbr_dus
Definition: xdmad.h:213
_LinkedListDescriporView3::mbr_nda
uint32_t mbr_nda
Definition: xdmad.h:197
_LinkedListDescriporView3::mbr_ds
uint32_t mbr_ds
Definition: xdmad.h:209
_LinkedListDescriporView3::mbr_sa
uint32_t mbr_sa
Definition: xdmad.h:201
_LinkedListDescriporView3::mbr_sus
uint32_t mbr_sus
Definition: xdmad.h:211
_LinkedListDescriporView3::mbr_bc
uint32_t mbr_bc
Definition: xdmad.h:207
_LinkedListDescriporView3::mbr_ubc
uint32_t mbr_ubc
Definition: xdmad.h:199
_LinkedListDescriporView3::mbr_da
uint32_t mbr_da
Definition: xdmad.h:203
_XdmadCfg
Definition: xdmad.h:135
_XdmadCfg::mbr_sus
uint32_t mbr_sus
Definition: xdmad.h:149
_XdmadCfg::mbr_bc
uint32_t mbr_bc
Definition: xdmad.h:145
_XdmadCfg::mbr_dus
uint32_t mbr_dus
Definition: xdmad.h:151
_XdmadCfg::mbr_sa
uint32_t mbr_sa
Definition: xdmad.h:139
_XdmadCfg::mbr_ds
uint32_t mbr_ds
Definition: xdmad.h:147
_XdmadCfg::mbr_cfg
uint32_t mbr_cfg
Definition: xdmad.h:143
_XdmadCfg::mbr_da
uint32_t mbr_da
Definition: xdmad.h:141
_XdmadCfg::mbr_ubc
uint32_t mbr_ubc
Definition: xdmad.h:137
_XdmadChannel
Definition: xdmad.h:113
_XdmadChannel::bDstRxIfID
uint8_t bDstRxIfID
Definition: xdmad.h:122
_XdmadChannel::state
volatile uint8_t state
Definition: xdmad.h:123
_XdmadChannel::bDstPeriphID
uint8_t bDstPeriphID
Definition: xdmad.h:118
_XdmadChannel::bSrcTxIfID
uint8_t bSrcTxIfID
Definition: xdmad.h:119
_XdmadChannel::bSrcPeriphID
uint8_t bSrcPeriphID
Definition: xdmad.h:117
_XdmadChannel::bDstTxIfID
uint8_t bDstTxIfID
Definition: xdmad.h:121
_XdmadChannel::bIrqOwner
uint8_t bIrqOwner
Definition: xdmad.h:116
_XdmadChannel::fCallback
XdmadTransferCallback fCallback
Definition: xdmad.h:114
_XdmadChannel::pArg
void * pArg
Definition: xdmad.h:115
_XdmadChannel::bSrcRxIfID
uint8_t bSrcRxIfID
Definition: xdmad.h:120
_Xdmad
Definition: xdmad.h:127