summaryrefslogtreecommitdiff
path: root/bsp/CME_M7/StdPeriph_Driver/inc/cmem7_dma.h
blob: 5e6390244815e3ee85ebbef9bc735c643395f30c (plain)
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
/**
	*****************************************************************************
	* @file     cmem7_dma.h
	*
	* @brief    CMEM7 DMA header file
	*
	*
	* @version  V1.0
	* @date     3. September 2013
	*
	* @note               
	*           
	*****************************************************************************
	* @attention
	*
	* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
	* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
	* TIME. AS A RESULT, CAPITAL-MICRO SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 
	* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
	* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
	* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
	*
	* <h2><center>&copy; COPYRIGHT 2013 Capital-micro </center></h2>
	*****************************************************************************
	*/
	
#ifndef __CMEM7_DMA_H
#define __CMEM7_DMA_H

#ifdef __cplusplus
 extern "C" {
#endif

#include "cmem7.h"
#include "cmem7_conf.h"

/** @defgroup DMA_Int
  * @{
  */
#define DMA_Int_TfrComplete                0x00000001    
#define DMA_Int_Err                        0x00000002
#define DMA_Int_All                        0x00000003

#define IS_DMA_INT(INT)        (((INT) != 0) && (((INT) & ~DMA_Int_All) == 0))
/**
  * @}
  */ 

/**
  * @brief  Descriptor structure
	*	@note		DMA requires users provides a list of descriptors to operation.
	*					Meanwhile, memory occupied by descriptors should be in physical
	*					memory and keep valid during DMA transfer.
	*/ 
typedef struct {                      
	uint32_t srcAddr;                  /*!< source address 														*/		
	uint32_t dstAddr;                  /*!< destination address 											*/	
	uint32_t number;                   /*!< block byte number, no more than 2K Bytes 	*/
	uint32_t nextBlock;                /*!< next block descriptor 										*/
	uint32_t padding;                  /*!< Nonsense, only used to fill 							*/
} BLOCK_DESC;
	
/**
  * @brief  DMA initialization
  * @note   This function should be called at first before any other interfaces.
	* @param  None
	* @retval None
	*/ 
void DMA_Init(void);

/**
  * @brief  Enable or disable DMA interrupt. 
	* @param[in] Int interrupt mask bits, which can be the combination of @ref DMA_Int
	* @param[in] Enable The bit indicates if specific interrupts are enable or not
  * @retval None
	*/ 
void DMA_EnableInt(uint32_t Int, BOOL enable);

/**
  * @brief  Check specific interrupts are set or not 
	* @param[in] Int interrupt mask bits, which can be the combination of @ref DMA_Int
  * @retval BOOL The bit indicates if specific interrupts are set or not
	*/
BOOL DMA_GetIntStatus(uint32_t Int);

/**
  * @brief  Clear specific interrupts
	* @param[in] Int interrupt mask bits, which can be the combination of @ref DMA_Int
  * @retval None
	*/
void DMA_ClearInt(uint32_t Int);

/**
  * @brief  DMA transfer
	* @note		Make sure that memory occupied by descriptors should be in physical
	*					memory and keep valid before DMA transfer is finished (Return false by
	*					calling DMA_IsBusy after DMA transfer started).
	* @param[in] blockList A pointer to header of list of BLOCK_DESC
  * @retval BOOL The bit indicates if DMA begins to transfer
	* @see		DMA_IsBusy
	*/
BOOL DMA_Transfer(BLOCK_DESC *blockList);

/**
  * @brief  DMA is busy or not
  * @param  None
	* @retval BOOL The bit indicates if DMA is busy or not
	*/ 
BOOL DMA_IsBusy(void);

#ifdef __cplusplus
}
#endif

#endif /* __CMEM7_DMA_H */