EZR32 Wonder Gecko Software Documentation  ezr32wg-doc-5.1.2
em_dma.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef EM_DMA_H
34 #define EM_DMA_H
35 
36 #include "em_device.h"
37 #if defined( DMA_PRESENT )
38 
39 #include <stdio.h>
40 #include <stdbool.h>
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /***************************************************************************/
51 /***************************************************************************/
56 /*******************************************************************************
57  ******************************** ENUMS ************************************
58  ******************************************************************************/
59 
64 typedef enum
65 {
71 
72 
74 typedef enum
75 {
80 
81 
83 typedef enum
84 {
96 
97 
99 typedef enum
100 {
113 
114 
115 /*******************************************************************************
116  ******************************* STRUCTS ***********************************
117  ******************************************************************************/
118 
135 typedef void (*DMA_FuncPtr_TypeDef)(unsigned int channel, bool primary, void *user);
136 
137 
148 typedef struct
149 {
156 
158  void *userPtr;
159 
165  uint8_t primary;
167 
168 
170 typedef struct
171 {
177  bool highPri;
178 
185  bool enableInt;
186 
192  uint32_t select;
193 
210 
211 
216 typedef struct
217 {
220 
223 
226 
232 
242  uint8_t hprot;
244 
245 
246 #if defined( _DMA_LOOP0_MASK ) && defined( _DMA_LOOP1_MASK )
247 
250 typedef struct
251 {
253  bool enable;
255  uint16_t nMinus1;
257 #endif
258 
259 
260 #if defined( _DMA_RECT0_MASK )
261 
264 typedef struct
265 {
267  uint16_t dstStride;
269  uint16_t srcStride;
271  uint16_t height;
273 #endif
274 
275 
277 typedef struct
278 {
280  void *src;
281 
283  void *dst;
284 
287 
290 
293 
299 
301  uint16_t nMinus1;
302 
312  uint8_t hprot;
313 
322 
323 
325 typedef struct
326 {
335  uint8_t hprot;
336 
354 
355 
356 /*******************************************************************************
357  ***************************** PROTOTYPES **********************************
358  ******************************************************************************/
359 
360 void DMA_ActivateAuto(unsigned int channel,
361  bool primary,
362  void *dst,
363  const void *src,
364  unsigned int nMinus1);
365 void DMA_ActivateBasic(unsigned int channel,
366  bool primary,
367  bool useBurst,
368  void *dst,
369  const void *src,
370  unsigned int nMinus1);
371 void DMA_ActivatePingPong(unsigned int channel,
372  bool useBurst,
373  void *primDst,
374  const void *primSrc,
375  unsigned int primNMinus1,
376  void *altDst,
377  const void *altSrc,
378  unsigned int altNMinus1);
379 void DMA_ActivateScatterGather(unsigned int channel,
380  bool useBurst,
381  DMA_DESCRIPTOR_TypeDef *altDescr,
382  unsigned int count);
383 void DMA_CfgChannel(unsigned int channel, DMA_CfgChannel_TypeDef *cfg);
384 void DMA_CfgDescr(unsigned int channel,
385  bool primary,
386  DMA_CfgDescr_TypeDef *cfg);
387 #if defined( _DMA_LOOP0_MASK ) && defined( _DMA_LOOP1_MASK )
388 void DMA_CfgLoop(unsigned int channel, DMA_CfgLoop_TypeDef *cfg);
389 #endif
390 
391 #if defined( _DMA_RECT0_MASK )
392 void DMA_CfgRect(unsigned int channel, DMA_CfgRect_TypeDef *cfg);
393 #endif
394 
395 #if defined( _DMA_LOOP0_MASK ) && defined( _DMA_LOOP1_MASK )
396 /***************************************************************************/
403 __STATIC_INLINE void DMA_ResetLoop(unsigned int channel)
404 {
405  /* Clean loop copy operation */
406  switch(channel)
407  {
408  case 0:
409  DMA->LOOP0 = _DMA_LOOP0_RESETVALUE;
410  break;
411  case 1:
412  DMA->LOOP1 = _DMA_LOOP1_RESETVALUE;
413  break;
414  default:
415  break;
416  }
417 }
418 #endif
419 
420 
421 #if defined( _DMA_RECT0_MASK )
422 /***************************************************************************/
429 __STATIC_INLINE void DMA_ResetRect(unsigned int channel)
430 {
431  (void) channel;
432 
433  /* Clear rect copy operation */
434  DMA->RECT0 = _DMA_RECT0_RESETVALUE;
435 }
436 #endif
438  unsigned int indx,
440 void DMA_ChannelEnable(unsigned int channel, bool enable);
441 bool DMA_ChannelEnabled(unsigned int channel);
442 void DMA_ChannelRequestEnable(unsigned int channel, bool enable);
443 void DMA_Init(DMA_Init_TypeDef *init);
444 void DMA_IRQHandler(void);
445 void DMA_RefreshPingPong(unsigned int channel,
446  bool primary,
447  bool useBurst,
448  void *dst,
449  const void *src,
450  unsigned int nMinus1,
451  bool last);
452 void DMA_Reset(void);
453 
454 /***************************************************************************/
462 __STATIC_INLINE void DMA_IntClear(uint32_t flags)
463 {
464  DMA->IFC = flags;
465 }
466 
467 
468 /***************************************************************************/
476 __STATIC_INLINE void DMA_IntDisable(uint32_t flags)
477 {
478  DMA->IEN &= ~flags;
479 }
480 
481 
482 /***************************************************************************/
495 __STATIC_INLINE void DMA_IntEnable(uint32_t flags)
496 {
497  DMA->IEN |= flags;
498 }
499 
500 
501 /***************************************************************************/
512 __STATIC_INLINE uint32_t DMA_IntGet(void)
513 {
514  return DMA->IF;
515 }
516 
517 
518 /***************************************************************************/
532 __STATIC_INLINE uint32_t DMA_IntGetEnabled(void)
533 {
534  uint32_t ien;
535 
536  ien = DMA->IEN;
537  return DMA->IF & ien;
538 }
539 
540 
541 /***************************************************************************/
549 __STATIC_INLINE void DMA_IntSet(uint32_t flags)
550 {
551  DMA->IFS = flags;
552 }
553 
557 #ifdef __cplusplus
558 }
559 #endif
560 
561 #endif /* defined( DMA_PRESENT ) */
562 #endif /* EM_DMA_H */
#define _DMA_CTRL_SRC_SIZE_WORD
#define _DMA_CTRL_SRC_SIZE_HALFWORD
__STATIC_INLINE void DMA_IntSet(uint32_t flags)
Set one or more pending DMA interrupts.
Definition: em_dma.h:549
#define _DMA_CTRL_R_POWER_8
#define _DMA_LOOP0_RESETVALUE
Definition: ezr32wg_dma.h:1423
DMA_DataSize_TypeDef size
Definition: em_dma.h:292
#define _DMA_CTRL_R_POWER_128
uint8_t hprot
Definition: em_dma.h:335
#define _DMA_CTRL_SRC_INC_NONE
DMA_ArbiterConfig_TypeDef arbRate
Definition: em_dma.h:231
DMA_DataInc_TypeDef dstInc
Definition: em_dma.h:219
__STATIC_INLINE void DMA_IntDisable(uint32_t flags)
Disable one or more DMA interrupts.
Definition: em_dma.h:476
Callback structure that can be used to define DMA complete actions.
Definition: em_dma.h:148
DMA_ArbiterConfig_TypeDef arbRate
Definition: em_dma.h:298
#define _DMA_CTRL_R_POWER_512
void DMA_CfgDescrScatterGather(DMA_DESCRIPTOR_TypeDef *descr, unsigned int indx, DMA_CfgDescrSGAlt_TypeDef *cfg)
Configure an alternate DMA descriptor for use with scatter-gather DMA cycles.
Definition: em_dma.c:898
void DMA_IRQHandler(void)
Interrupt handler for DMA cycle completion handling.
Definition: em_dma.c:284
void DMA_CfgRect(unsigned int channel, DMA_CfgRect_TypeDef *cfg)
Configure DMA channel 2D transfer properties.
Definition: em_dma.c:855
__STATIC_INLINE uint32_t DMA_IntGet(void)
Get pending DMA interrupt flags.
Definition: em_dma.h:512
#define _DMA_CTRL_CYCLE_CTRL_MEM_SCATTER_GATHER
DMA_CB_TypeDef * cb
User definable callback handling configuration.
Definition: em_dma.h:208
DMA_DataInc_TypeDef srcInc
Definition: em_dma.h:289
DMA_ArbiterConfig_TypeDef
Definition: em_dma.h:99
uint16_t srcStride
Definition: em_dma.h:269
#define _DMA_CTRL_R_POWER_16
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
#define _DMA_CTRL_R_POWER_4
__STATIC_INLINE void DMA_IntClear(uint32_t flags)
Clear one or more pending DMA interrupts.
Definition: em_dma.h:462
bool DMA_ChannelEnabled(unsigned int channel)
Check if DMA channel is enabled.
Definition: em_dma.c:1003
#define _DMA_CTRL_SRC_INC_WORD
__STATIC_INLINE void DMA_ResetLoop(unsigned int channel)
Clear Loop configuration for channel.
Definition: em_dma.h:403
void DMA_RefreshPingPong(unsigned int channel, bool primary, bool useBurst, void *dst, const void *src, unsigned int nMinus1, bool last)
Refresh a descriptor used in a DMA ping-pong cycle.
Definition: em_dma.c:1135
#define _DMA_CTRL_CYCLE_CTRL_PER_SCATTER_GATHER
void DMA_ChannelRequestEnable(unsigned int channel, bool enable)
Enable or disable a DMA channel request.
Definition: em_dma.c:1025
void DMA_Reset(void)
Reset the DMA controller.
Definition: em_dma.c:1227
#define _DMA_CTRL_CYCLE_CTRL_BASIC
void(* DMA_FuncPtr_TypeDef)(unsigned int channel, bool primary, void *user)
DMA interrupt callback function pointer.
Definition: em_dma.h:135
void DMA_ActivateBasic(unsigned int channel, bool primary, bool useBurst, void *dst, const void *src, unsigned int nMinus1)
Activate DMA basic cycle (used for memory-peripheral transfers).
Definition: em_dma.c:449
#define _DMA_CTRL_R_POWER_64
void DMA_CfgLoop(unsigned int channel, DMA_CfgLoop_TypeDef *cfg)
Configure DMA channel for Loop mode or 2D transfer.
Definition: em_dma.c:824
uint8_t primary
Definition: em_dma.h:165
uint16_t nMinus1
Definition: em_dma.h:255
#define _DMA_LOOP1_RESETVALUE
Definition: ezr32wg_dma.h:1436
#define _DMA_CTRL_SRC_INC_BYTE
void DMA_ActivatePingPong(unsigned int channel, bool useBurst, void *primDst, const void *primSrc, unsigned int primNMinus1, void *altDst, const void *altSrc, unsigned int altNMinus1)
Activate DMA ping-pong cycle (used for memory-peripheral transfers).
Definition: em_dma.c:521
void DMA_Init(DMA_Init_TypeDef *init)
Initializes DMA controller.
Definition: em_dma.c:1057
void DMA_CfgChannel(unsigned int channel, DMA_CfgChannel_TypeDef *cfg)
Configure a DMA channel.
Definition: em_dma.c:701
#define _DMA_CTRL_R_POWER_32
DMA_DataSize_TypeDef size
Definition: em_dma.h:225
DMA_DataInc_TypeDef srcInc
Definition: em_dma.h:222
__STATIC_INLINE void DMA_ResetRect(unsigned int channel)
Clear Rect/2D DMA configuration for channel.
Definition: em_dma.h:429
uint16_t dstStride
Definition: em_dma.h:267
DMA_DataInc_TypeDef dstInc
Definition: em_dma.h:286
DMA_DESCRIPTOR_TypeDef * controlBlock
Definition: em_dma.h:352
#define DMA
__STATIC_INLINE uint32_t DMA_IntGetEnabled(void)
Get enabled and pending DMA interrupt flags. Useful for handling more interrupt sources in the same i...
Definition: em_dma.h:532
DMA_DataSize_TypeDef
Definition: em_dma.h:74
void * userPtr
Definition: em_dma.h:158
DMA_CycleCtrl_TypeDef
Definition: em_dma.h:83
#define _DMA_CTRL_CYCLE_CTRL_AUTO
DMA_FuncPtr_TypeDef cbFunc
Definition: em_dma.h:155
__STATIC_INLINE void DMA_IntEnable(uint32_t flags)
Enable one or more DMA interrupts.
Definition: em_dma.h:495
#define _DMA_CTRL_R_POWER_256
#define _DMA_CTRL_R_POWER_2
#define _DMA_CTRL_SRC_INC_HALFWORD
#define _DMA_CTRL_R_POWER_1
void DMA_ActivateScatterGather(unsigned int channel, bool useBurst, DMA_DESCRIPTOR_TypeDef *altDescr, unsigned int count)
Activate DMA scatter-gather cycle (used for either memory-peripheral or memory-memory transfers)...
Definition: em_dma.c:591
#define _DMA_RECT0_RESETVALUE
Definition: ezr32wg_dma.h:1449
#define _DMA_CTRL_R_POWER_1024
#define _DMA_CTRL_SRC_SIZE_BYTE
void DMA_ActivateAuto(unsigned int channel, bool primary, void *dst, const void *src, unsigned int nMinus1)
Activate DMA auto-request cycle (used for memory-memory transfers).
Definition: em_dma.c:386
uint16_t height
Definition: em_dma.h:271
#define _DMA_CTRL_CYCLE_CTRL_PINGPONG
DMA_DataInc_TypeDef
Definition: em_dma.h:64
void DMA_ChannelEnable(unsigned int channel, bool enable)
Enable or disable a DMA channel.
Definition: em_dma.c:974
void DMA_CfgDescr(unsigned int channel, bool primary, DMA_CfgDescr_TypeDef *cfg)
Configure DMA descriptor for auto-request, basic or ping-pong DMA cycles.
Definition: em_dma.c:776