summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/arm/atsam/libraries/libchip/include/xdmac.h
blob: eaaddc307a0b4f0e9c99da17b5f5fa31e43635e9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
/* ---------------------------------------------------------------------------- */
/*                  Atmel Microcontroller Software Support                      */
/*                       SAM Software Package License                           */
/* ---------------------------------------------------------------------------- */
/* Copyright (c) 2015, Atmel Corporation                                        */
/*                                                                              */
/* All rights reserved.                                                         */
/*                                                                              */
/* Redistribution and use in source and binary forms, with or without           */
/* modification, are permitted provided that the following condition is met:    */
/*                                                                              */
/* - Redistributions of source code must retain the above copyright notice,     */
/* this list of conditions and the disclaimer below.                            */
/*                                                                              */
/* Atmel's name may not be used to endorse or promote products derived from     */
/* this software without specific prior written permission.                     */
/*                                                                              */
/* DISCLAIMER:  THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR   */
/* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE   */
/* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,      */
/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,  */
/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    */
/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING         */
/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */
/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                           */
/* ---------------------------------------------------------------------------- */

/** \file */

/** \addtogroup dmac_module Working with DMAC
 *  \ingroup peripherals_module
 *
 * \section Usage
 * <ul>
 * <li> Enable or disable the a DMAC controller with DMAC_Enable() and or
 * DMAC_Disable().</li>
 * <li> Enable or disable %Dma interrupt using DMAC_EnableIt()or
 * DMAC_DisableIt().</li>
 * <li> Get %Dma interrupt status by DMAC_GetStatus() and
 * DMAC_GetInterruptMask().</li>
 * <li> Enable or disable specified %Dma channel with DMAC_EnableChannel() or
 * DMAC_DisableChannel().</li>
 * <li> Get %Dma channel status by DMAC_GetChannelStatus().</li>
 * <li> ControlA and ControlB register is set by DMAC_SetControlA() and
 * DMAC_SetControlB().</li>
 * <li> Configure source and/or destination start address with
 * DMAC_SetSourceAddr() and/or DMAC_SetDestinationAddr().</li>
 * <li> Set %Dma descriptor address using DMAC_SetDescriptorAddr().</li>
 * <li> Set source transfer buffer size with DMAC_SetBufferSize().</li>
 * <li> Configure source and/or destination Picture-In-Picuture mode with
 * DMAC_SetSourcePip() and/or DMAC_SetDestPip().</li>
 * </ul>
 *
 * For more accurate information, please look at the DMAC section of the
 * Datasheet.
 *
 * \sa \ref dmad_module
 *
 * Related files :\n
 * \ref dmac.c\n
 * \ref dmac.h.\n
 *
 */

#ifndef DMAC_H
#define DMAC_H
/**@{*/

/*------------------------------------------------------------------------------
 *         Headers
 *----------------------------------------------------------------------------*/

#include "chip.h"

#ifndef __rtems__
#include <../../../../utils/utility.h>
#endif /* __rtems__ */
#include <stdint.h>
#include <assert.h>

/*------------------------------------------------------------------------------
 *         Definitions
 *----------------------------------------------------------------------------*/

/** \addtogroup dmac_defines DMAC Definitions
 *      @{
 */
/** Number of DMA channels */
#define XDMAC_CONTROLLER_NUM            1
/** Number of DMA channels */
#define XDMAC_CHANNEL_NUM               24
/** Max DMA single transfer size */
#define XDMAC_MAX_BT_SIZE               0xFFFF
/**     @}*/

/*----------------------------------------------------------------------------
 *         Macro
 *----------------------------------------------------------------------------*/
#define XDMA_GET_DATASIZE(size) ((size==0)? XDMAC_CC_DWIDTH_BYTE : \
								 ((size==1)? XDMAC_CC_DWIDTH_HALFWORD : \
								  (XDMAC_CC_DWIDTH_WORD)))
#define XDMA_GET_CC_SAM(s)      ((s==0)? XDMAC_CC_SAM_FIXED_AM : \
								 ((s==1)? XDMAC_CC_SAM_INCREMENTED_AM : \
								  ((s==2)? XDMAC_CC_SAM_UBS_AM : \
								   XDMAC_CC_SAM_UBS_DS_AM)))
#define XDMA_GET_CC_DAM(d)      ((d==0)? XDMAC_CC_DAM_FIXED_AM : \
								 ((d==1)? XDMAC_CC_DAM_INCREMENTED_AM : \
								  ((d==2)? XDMAC_CC_DAM_UBS_AM : \
								   XDMAC_CC_DAM_UBS_DS_AM)))
#define XDMA_GET_CC_MEMSET(m)   ((m==0)? XDMAC_CC_MEMSET_NORMAL_MODE : \
								 XDMAC_CC_MEMSET_HW_MODE)

/*------------------------------------------------------------------------------
 *         Global functions
 *----------------------------------------------------------------------------*/
/** \addtogroup dmac_functions
 *      @{
 */

#ifdef __cplusplus
extern "C" {
#endif

/**
 * \brief Get XDMAC global type.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 */
static inline uint32_t XDMAC_GetType(Xdmac *pXdmac)
{
	assert(pXdmac);
	return pXdmac->XDMAC_GTYPE;
}

/**
 * \brief Get XDMAC global configuration.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 */
static inline uint32_t XDMAC_GetConfig(Xdmac *pXdmac)
{
	assert(pXdmac);
	return pXdmac->XDMAC_GCFG;
}

/**
 * \brief Get XDMAC global weighted arbiter configuration.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 */
static inline uint32_t XDMAC_GetArbiter(Xdmac *pXdmac)
{
	assert(pXdmac);
	return pXdmac->XDMAC_GWAC;
}

/**
 * \brief Enables XDMAC global interrupt.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param dwInteruptMask IT to be enabled.
 */
static inline void XDMAC_EnableGIt (Xdmac *pXdmac, uint8_t dwInteruptMask)
{
	assert(pXdmac);
	pXdmac->XDMAC_GIE = (XDMAC_GIE_IE0 << dwInteruptMask);
}

/**
 * \brief Disables XDMAC global interrupt
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param dwInteruptMask IT to be enabled
 */
static inline void XDMAC_DisableGIt (Xdmac *pXdmac, uint8_t dwInteruptMask)
{
	assert(pXdmac);
	pXdmac->XDMAC_GID = (XDMAC_GID_ID0 << dwInteruptMask);
}

/**
 * \brief Get XDMAC global interrupt mask.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 */
static inline uint32_t XDMAC_GetGItMask(Xdmac *pXdmac)
{
	assert(pXdmac);
	return (pXdmac->XDMAC_GIM);
}

/**
 * \brief Get XDMAC global interrupt status.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 */
static inline uint32_t XDMAC_GetGIsr(Xdmac *pXdmac)
{
	assert(pXdmac);
	return (pXdmac->XDMAC_GIS);
}

/**
 * \brief Get XDMAC masked global interrupt.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 */
static inline uint32_t XDMAC_GetMaskedGIsr(Xdmac *pXdmac)
{
	uint32_t _dwStatus;
	assert(pXdmac);
	_dwStatus = pXdmac->XDMAC_GIS;
	_dwStatus &= pXdmac->XDMAC_GIM;
	return _dwStatus;
}

/**
 * \brief enables the relevant channel of given XDMAC.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param channel Particular channel number.
 */
static inline void XDMAC_EnableChannel(Xdmac *pXdmac, uint8_t channel)
{
	assert(pXdmac);
	assert(channel < XDMAC_CHANNEL_NUM);
	pXdmac->XDMAC_GE = (XDMAC_GE_EN0 << channel);
}

/**
 * \brief enables the relevant channels of given XDMAC.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param bmChannels Channels bitmap.
 */
static inline void XDMAC_EnableChannels(Xdmac *pXdmac, uint32_t bmChannels)
{
	assert(pXdmac);
	pXdmac->XDMAC_GE = bmChannels;
}

/**
 * \brief Disables the relevant channel of given XDMAC.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param channel Particular channel number.
 */
static inline void XDMAC_DisableChannel(Xdmac *pXdmac, uint8_t channel)
{
	assert(pXdmac);
	assert(channel < XDMAC_CHANNEL_NUM);
	pXdmac->XDMAC_GD = (XDMAC_GD_DI0 << channel);
}

/**
 * \brief Disables the relevant channels of given XDMAC.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param bmChannels Channels bitmap.
 */
static inline void XDMAC_DisableChannels(Xdmac *pXdmac, uint32_t bmChannels)
{
	assert(pXdmac);
	pXdmac->XDMAC_GD = bmChannels;
}


/**
 * \brief Get Global channel status of given XDMAC.
 * \note: When set to 1, this bit indicates that the channel x is enabled.
   If a channel disable request is issued, this bit remains asserted
   until pending transaction is completed.
 * \param pXdmac Pointer to the XDMAC peripheral.
 */
static inline uint32_t XDMAC_GetGlobalChStatus(Xdmac *pXdmac)
{
	assert(pXdmac);
	return pXdmac->XDMAC_GS;
}

/**
 * \brief Suspend the relevant channel's read.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param channel Particular channel number.
 */
static inline void XDMAC_SuspendReadChannel(Xdmac *pXdmac, uint8_t channel)
{
	assert(pXdmac);
	assert(channel < XDMAC_CHANNEL_NUM);
	pXdmac->XDMAC_GRS |= XDMAC_GRS_RS0 << channel;
}

/**
 * \brief Suspend the relevant channel's write.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param channel Particular channel number.
 */
static inline void XDMAC_SuspendWriteChannel(Xdmac *pXdmac, uint8_t channel)
{
	assert(pXdmac);
	assert(channel < XDMAC_CHANNEL_NUM);
	pXdmac->XDMAC_GWS |= XDMAC_GWS_WS0 << channel;
}

/**
 * \brief Suspend the relevant channel's read & write.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param channel Particular channel number.
 */
static inline void XDMAC_SuspendReadWriteChannel(Xdmac *pXdmac, uint8_t channel)
{
	assert(pXdmac);
	assert(channel < XDMAC_CHANNEL_NUM);
	pXdmac->XDMAC_GRWS = (XDMAC_GRWS_RWS0 << channel);
}

/**
 * \brief Resume the relevant channel's read & write.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param channel Particular channel number.
 */
static inline void XDMAC_ResumeReadWriteChannel(Xdmac *pXdmac, uint8_t channel)
{
	assert(pXdmac);
	assert(channel < XDMAC_CHANNEL_NUM);
	pXdmac->XDMAC_GRWR = (XDMAC_GRWR_RWR0 << channel);
}

/**
 * \brief Set software transfer request on the relevant channel.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param channel Particular channel number.
 */
static inline void XDMAC_SoftwareTransferReq(Xdmac *pXdmac, uint8_t channel)
{

	assert(pXdmac);
	assert(channel < XDMAC_CHANNEL_NUM);
	pXdmac->XDMAC_GSWR = (XDMAC_GSWR_SWREQ0 << channel);
}

/**
 * \brief Get software transfer status of the relevant channel.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 */
static inline uint32_t XDMAC_GetSoftwareTransferStatus(Xdmac *pXdmac)
{

	assert(pXdmac);
	return pXdmac->XDMAC_GSWS;
}

/**
 * \brief Get interrupt status for the relevant channel of given XDMA.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param channel Particular channel number.
 */
static inline uint32_t XDMAC_GetChannelIsr (Xdmac *pXdmac, uint8_t channel)
{
	assert(pXdmac);
	assert(channel < XDMAC_CHANNEL_NUM);
	return pXdmac->XDMAC_CHID[channel].XDMAC_CIS;
}

/**
 * \brief Set software flush request on the relevant channel.
 * \note: This API is used as polling without enabling FIE interrupt.
 * The user can use it in interrupt mode after deleting while sentense.
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param channel Particular channel number.
 */
static inline void XDMAC_SoftwareFlushReq(Xdmac *pXdmac, uint8_t channel)
{
	assert(pXdmac);
	assert(channel < XDMAC_CHANNEL_NUM);
	pXdmac->XDMAC_GSWF = (XDMAC_GSWF_SWF0 << channel);

	while (!(XDMAC_GetChannelIsr(pXdmac, channel) & XDMAC_CIS_FIS));
}

/**
 * \brief Disable interrupt with mask on the relevant channel of given XDMA.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param channel Particular channel number.
 * \param dwInteruptMask Interrupt mask.
 */
static inline void XDMAC_EnableChannelIt (Xdmac *pXdmac, uint8_t channel,
							uint8_t dwInteruptMask)
{
	assert(pXdmac);
	assert(channel < XDMAC_CHANNEL_NUM);
	pXdmac->XDMAC_CHID[channel].XDMAC_CIE = dwInteruptMask;
}

/**
 * \brief Enable interrupt with mask on the relevant channel of given XDMA.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param channel Particular channel number.
 * \param dwInteruptMask Interrupt mask.
 */
static inline void XDMAC_DisableChannelIt (Xdmac *pXdmac, uint8_t channel,
							 uint8_t dwInteruptMask)
{
	assert(pXdmac);
	assert(channel < XDMAC_CHANNEL_NUM);
	pXdmac->XDMAC_CHID[channel].XDMAC_CID = dwInteruptMask;
}

/**
 * \brief Get interrupt mask for the relevant channel of given XDMA.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param channel Particular channel number.
 */
static inline uint32_t XDMAC_GetChannelItMask (Xdmac *pXdmac, uint8_t channel)
{
	assert(pXdmac);
	assert(channel < XDMAC_CHANNEL_NUM);
	return pXdmac->XDMAC_CHID[channel].XDMAC_CIM;
}

/**
 * \brief Get masked interrupt status for the relevant channel of given XDMA.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param channel Particular channel number.
 */
static inline uint32_t XDMAC_GetMaskChannelIsr (Xdmac *pXdmac, uint8_t channel)
{
	uint32_t status;
	assert(pXdmac);
	assert(channel < XDMAC_CHANNEL_NUM);
	status = pXdmac->XDMAC_CHID[channel].XDMAC_CIS;
	status &= pXdmac->XDMAC_CHID[channel].XDMAC_CIM;

	return status;
}

/**
 * \brief Set source address for the relevant channel of given XDMA.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param channel Particular channel number.
 * \param addr Source address.
 */
static inline void XDMAC_SetSourceAddr(Xdmac *pXdmac, uint8_t channel, uint32_t addr)
{
	assert(pXdmac);
	assert(channel < XDMAC_CHANNEL_NUM);
	pXdmac->XDMAC_CHID[channel].XDMAC_CSA = addr;
}

/**
 * \brief Set destination address for the relevant channel of given XDMA.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param channel Particular channel number.
 * \param addr Destination address.
 */
static inline void XDMAC_SetDestinationAddr(Xdmac *pXdmac, uint8_t channel, uint32_t addr)
{
	assert(pXdmac);
	assert(channel < XDMAC_CHANNEL_NUM);
	pXdmac->XDMAC_CHID[channel].XDMAC_CDA = addr;
}

/**
 * \brief Set next descriptor's address & interface for the relevant channel of
 *  given XDMA.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param channel Particular channel number.
 * \param addr Address of next descriptor.
 * \param ndaif Interface of next descriptor.
 */
static inline void XDMAC_SetDescriptorAddr(Xdmac *pXdmac, uint8_t channel,
							 uint32_t addr, uint8_t ndaif)
{
	assert(pXdmac);
	assert(ndaif < 2);
	assert(channel < XDMAC_CHANNEL_NUM);
	pXdmac->XDMAC_CHID[channel].XDMAC_CNDA =  (addr & 0xFFFFFFFC) | ndaif;
}

/**
 * \brief Set next descriptor's configuration for the relevant channel of
 *  given XDMA.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param channel Particular channel number.
 * \param config Configuration of next descriptor.
 */
static inline void XDMAC_SetDescriptorControl(Xdmac *pXdmac, uint8_t channel, uint8_t config)
{
	assert(pXdmac);
	assert(channel < XDMAC_CHANNEL_NUM);
	pXdmac->XDMAC_CHID[channel].XDMAC_CNDC = config;
}

/**
 * \brief Set microblock length for the relevant channel of given XDMA.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param channel Particular channel number.
 * \param ublen Microblock length.
 */
static inline void XDMAC_SetMicroblockControl(Xdmac *pXdmac, uint8_t channel, uint32_t ublen)
{
	assert(pXdmac);
	assert(channel < XDMAC_CHANNEL_NUM);
	pXdmac->XDMAC_CHID[channel].XDMAC_CUBC = XDMAC_CUBC_UBLEN(ublen);
}

/**
 * \brief Set block length for the relevant channel of given XDMA.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param channel Particular channel number.
 * \param blen Block length.
 */
static inline void XDMAC_SetBlockControl(Xdmac *pXdmac, uint8_t channel, uint16_t blen)
{
	assert(pXdmac);
	assert(channel < XDMAC_CHANNEL_NUM);
	pXdmac->XDMAC_CHID[channel].XDMAC_CBC = XDMAC_CBC_BLEN(blen);
}

/**
 * \brief Set configuration for the relevant channel of given XDMA.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param channel Particular channel number.
 * \param config Channel configuration.
 */
static inline void XDMAC_SetChannelConfig(Xdmac *pXdmac, uint8_t channel, uint32_t config)
{
	assert(pXdmac);
	assert(channel < XDMAC_CHANNEL_NUM);
	pXdmac->XDMAC_CHID[channel].XDMAC_CC = config;
}

/**
 * \brief Get the relevant channel's configuration of given XDMA.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param channel Particular channel number.
 */
static inline uint32_t XDMAC_GetChannelConfig(Xdmac *pXdmac, uint8_t channel)
{
	assert(pXdmac);
	assert(channel < XDMAC_CHANNEL_NUM);
	return pXdmac->XDMAC_CHID[channel].XDMAC_CC;
}

/**
 * \brief Set the relevant channel's data stride memory pattern of given XDMA.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param channel Particular channel number.
 * \param dds_msp Data stride memory pattern.
 */
static inline void XDMAC_SetDataStride_MemPattern(Xdmac *pXdmac, uint8_t channel,
									uint32_t dds_msp)
{

	assert(pXdmac);
	assert(channel < XDMAC_CHANNEL_NUM);
	pXdmac->XDMAC_CHID[channel].XDMAC_CDS_MSP = dds_msp;
}

/**
 * \brief Set the relevant channel's source microblock stride of given XDMA.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param channel Particular channel number.
 * \param subs Source microblock stride.
 */
static inline void XDMAC_SetSourceMicroBlockStride(Xdmac *pXdmac, uint8_t channel,
									 uint32_t subs)
{
	assert(pXdmac);
	assert(channel < XDMAC_CHANNEL_NUM);
	pXdmac->XDMAC_CHID[channel].XDMAC_CSUS = XDMAC_CSUS_SUBS(subs);
}

/**
 * \brief Set the relevant channel's destination microblock stride of given XDMA.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param channel Particular channel number.
 * \param dubs Destination microblock stride.
 */
static inline void XDMAC_SetDestinationMicroBlockStride(Xdmac *pXdmac, uint8_t channel,
		uint32_t dubs)
{
	assert(pXdmac);
	assert(channel < XDMAC_CHANNEL_NUM);
	pXdmac->XDMAC_CHID[channel].XDMAC_CDUS = XDMAC_CDUS_DUBS(dubs);
}

/**
 * \brief Get the relevant channel's destination address of given XDMA.
 *
 * \param pXdmac Pointer to the XDMAC peripheral.
 * \param channel Particular channel number.
 */
static inline uint32_t XDMAC_GetChDestinationAddr(Xdmac *pXdmac, uint8_t channel)
{
	assert(pXdmac);
	assert(channel < XDMAC_CHANNEL_NUM);
	return pXdmac->XDMAC_CHID[channel].XDMAC_CDA;
}

static inline void XDMAC_StartTransfer(Xdmac *pXdmac, uint8_t channel)
{
	assert(pXdmac);
	assert(channel < XDMAC_CHANNEL_NUM);
	pXdmac->XDMAC_GE = (XDMAC_GE_EN0 << channel);
	pXdmac->XDMAC_GIE = (XDMAC_GIE_IE0 << channel);
}

#ifdef __cplusplus
}
#endif

/**     @}*/
/**@}*/
#endif //#ifndef DMAC_H