EFM32 Gecko Software Documentation  efm32g-doc-4.2.1
em_dma.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef __SILICON_LABS_EM_DMA_H__
34 #define __SILICON_LABS_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;
256 } DMA_CfgLoop_TypeDef;
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;
272 } DMA_CfgRect_TypeDef;
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  void *src,
364  unsigned int nMinus1);
365 void DMA_ActivateBasic(unsigned int channel,
366  bool primary,
367  bool useBurst,
368  void *dst,
369  void *src,
370  unsigned int nMinus1);
371 void DMA_ActivatePingPong(unsigned int channel,
372  bool useBurst,
373  void *primDst,
374  void *primSrc,
375  unsigned int primNMinus1,
376  void *altDst,
377  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_Init(DMA_Init_TypeDef *init);
443 void DMA_IRQHandler(void);
444 void DMA_RefreshPingPong(unsigned int channel,
445  bool primary,
446  bool useBurst,
447  void *dst,
448  void *src,
449  unsigned int nMinus1,
450  bool last);
451 void DMA_Reset(void);
452 
453 /***************************************************************************/
461 __STATIC_INLINE void DMA_IntClear(uint32_t flags)
462 {
463  DMA->IFC = flags;
464 }
465 
466 
467 /***************************************************************************/
475 __STATIC_INLINE void DMA_IntDisable(uint32_t flags)
476 {
477  DMA->IEN &= ~flags;
478 }
479 
480 
481 /***************************************************************************/
494 __STATIC_INLINE void DMA_IntEnable(uint32_t flags)
495 {
496  DMA->IEN |= flags;
497 }
498 
499 
500 /***************************************************************************/
511 __STATIC_INLINE uint32_t DMA_IntGet(void)
512 {
513  return DMA->IF;
514 }
515 
516 
517 /***************************************************************************/
531 __STATIC_INLINE uint32_t DMA_IntGetEnabled(void)
532 {
533  uint32_t ien;
534 
535  ien = DMA->IEN;
536  return DMA->IF & ien;
537 }
538 
539 
540 /***************************************************************************/
548 __STATIC_INLINE void DMA_IntSet(uint32_t flags)
549 {
550  DMA->IFS = flags;
551 }
552 
556 #ifdef __cplusplus
557 }
558 #endif
559 
560 #endif /* defined( DMA_PRESENT ) */
561 #endif /* __SILICON_LABS_EM_DMA_H__ */
__STATIC_INLINE void DMA_IntSet(uint32_t flags)
Set one or more pending DMA interrupts.
Definition: em_dma.h:548
DMA_DataSize_TypeDef size
Definition: em_dma.h:292
#define _DMA_CTRL_R_POWER_2
uint8_t hprot
Definition: em_dma.h:335
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:475
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_1
#define DMA
#define _DMA_CTRL_SRC_SIZE_HALFWORD
void DMA_RefreshPingPong(unsigned int channel, bool primary, bool useBurst, void *dst, void *src, unsigned int nMinus1, bool last)
Refresh a descriptor used in a DMA ping-pong cycle.
Definition: em_dma.c:1111
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:903
void DMA_IRQHandler(void)
Interrupt handler for DMA cycle completion handling.
Definition: em_dma.c:284
__STATIC_INLINE uint32_t DMA_IntGet(void)
Get pending DMA interrupt flags.
Definition: em_dma.h:511
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
#define _DMA_CTRL_SRC_INC_BYTE
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
#define _DMA_CTRL_SRC_INC_HALFWORD
__STATIC_INLINE void DMA_IntClear(uint32_t flags)
Clear one or more pending DMA interrupts.
Definition: em_dma.h:461
bool DMA_ChannelEnabled(unsigned int channel)
Check if DMA channel is enabled.
Definition: em_dma.c:1008
#define _DMA_CTRL_SRC_INC_WORD
#define _DMA_CTRL_R_POWER_4
#define _DMA_CTRL_CYCLE_CTRL_MEM_SCATTER_GATHER
void DMA_Reset(void)
Reset the DMA controller.
Definition: em_dma.c:1203
void(* DMA_FuncPtr_TypeDef)(unsigned int channel, bool primary, void *user)
DMA interrupt callback function pointer.
Definition: em_dma.h:135
uint8_t primary
Definition: em_dma.h:165
void DMA_ActivatePingPong(unsigned int channel, bool useBurst, void *primDst, void *primSrc, unsigned int primNMinus1, void *altDst, void *altSrc, unsigned int altNMinus1)
Activate DMA ping-pong cycle (used for memory-peripheral transfers).
Definition: em_dma.c:526
void DMA_ActivateBasic(unsigned int channel, bool primary, bool useBurst, void *dst, void *src, unsigned int nMinus1)
Activate DMA basic cycle (used for memory-peripheral transfers).
Definition: em_dma.c:454
#define _DMA_CTRL_R_POWER_128
void DMA_Init(DMA_Init_TypeDef *init)
Initializes DMA controller.
Definition: em_dma.c:1033
void DMA_CfgChannel(unsigned int channel, DMA_CfgChannel_TypeDef *cfg)
Configure a DMA channel.
Definition: em_dma.c:706
#define _DMA_CTRL_CYCLE_CTRL_BASIC
#define _DMA_CTRL_R_POWER_1024
DMA_DataSize_TypeDef size
Definition: em_dma.h:225
#define _DMA_CTRL_R_POWER_16
#define _DMA_CTRL_R_POWER_8
DMA_DataInc_TypeDef srcInc
Definition: em_dma.h:222
#define _DMA_CTRL_CYCLE_CTRL_PINGPONG
DMA_DataInc_TypeDef dstInc
Definition: em_dma.h:286
#define _DMA_CTRL_SRC_SIZE_WORD
void DMA_ActivateAuto(unsigned int channel, bool primary, void *dst, void *src, unsigned int nMinus1)
Activate DMA auto-request cycle (used for memory-memory transfers).
Definition: em_dma.c:391
#define _DMA_CTRL_CYCLE_CTRL_PER_SCATTER_GATHER
DMA_DESCRIPTOR_TypeDef * controlBlock
Definition: em_dma.h:352
__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:531
#define _DMA_CTRL_R_POWER_256
DMA_DataSize_TypeDef
Definition: em_dma.h:74
void * userPtr
Definition: em_dma.h:158
#define _DMA_CTRL_SRC_INC_NONE
#define _DMA_CTRL_CYCLE_CTRL_AUTO
DMA_CycleCtrl_TypeDef
Definition: em_dma.h:83
DMA_FuncPtr_TypeDef cbFunc
Definition: em_dma.h:155
#define _DMA_CTRL_SRC_SIZE_BYTE
__STATIC_INLINE void DMA_IntEnable(uint32_t flags)
Enable one or more DMA interrupts.
Definition: em_dma.h:494
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:596
#define _DMA_CTRL_R_POWER_64
#define _DMA_CTRL_R_POWER_32
#define _DMA_CTRL_R_POWER_512
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:979
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:781