1 /** 2 ***************************************************************************** 3 * @file cmem7_dma.h 4 * 5 * @brief CMEM7 DMA header file 6 * 7 * 8 * @version V1.0 9 * @date 3. September 2013 10 * 11 * @note 12 * 13 ***************************************************************************** 14 * @attention 15 * 16 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 17 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 18 * TIME. AS A RESULT, CAPITAL-MICRO SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 19 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 20 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 21 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 22 * 23 * <h2><center>© COPYRIGHT 2013 Capital-micro </center></h2> 24 ***************************************************************************** 25 */ 26 27 #ifndef __CMEM7_DMA_H 28 #define __CMEM7_DMA_H 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 #include "cmem7.h" 35 #include "cmem7_conf.h" 36 37 /** @defgroup DMA_Int 38 * @{ 39 */ 40 #define DMA_Int_TfrComplete 0x00000001 41 #define DMA_Int_Err 0x00000002 42 #define DMA_Int_All 0x00000003 43 44 #define IS_DMA_INT(INT) (((INT) != 0) && (((INT) & ~DMA_Int_All) == 0)) 45 /** 46 * @} 47 */ 48 49 /** 50 * @brief Descriptor structure 51 * @note DMA requires users provides a list of descriptors to operation. 52 * Meanwhile, memory occupied by descriptors should be in physical 53 * memory and keep valid during DMA transfer. 54 */ 55 typedef struct { 56 uint32_t srcAddr; /*!< source address */ 57 uint32_t dstAddr; /*!< destination address */ 58 uint32_t number; /*!< block byte number, no more than 2K Bytes */ 59 uint32_t nextBlock; /*!< next block descriptor */ 60 uint32_t padding; /*!< Nonsense, only used to fill */ 61 } BLOCK_DESC; 62 63 /** 64 * @brief DMA initialization 65 * @note This function should be called at first before any other interfaces. 66 * @param None 67 * @retval None 68 */ 69 void DMA_Init(void); 70 71 /** 72 * @brief Enable or disable DMA interrupt. 73 * @param[in] Int interrupt mask bits, which can be the combination of @ref DMA_Int 74 * @param[in] Enable The bit indicates if specific interrupts are enable or not 75 * @retval None 76 */ 77 void DMA_EnableInt(uint32_t Int, BOOL enable); 78 79 /** 80 * @brief Check specific interrupts are set or not 81 * @param[in] Int interrupt mask bits, which can be the combination of @ref DMA_Int 82 * @retval BOOL The bit indicates if specific interrupts are set or not 83 */ 84 BOOL DMA_GetIntStatus(uint32_t Int); 85 86 /** 87 * @brief Clear specific interrupts 88 * @param[in] Int interrupt mask bits, which can be the combination of @ref DMA_Int 89 * @retval None 90 */ 91 void DMA_ClearInt(uint32_t Int); 92 93 /** 94 * @brief DMA transfer 95 * @note Make sure that memory occupied by descriptors should be in physical 96 * memory and keep valid before DMA transfer is finished (Return false by 97 * calling DMA_IsBusy after DMA transfer started). 98 * @param[in] blockList A pointer to header of list of BLOCK_DESC 99 * @retval BOOL The bit indicates if DMA begins to transfer 100 * @see DMA_IsBusy 101 */ 102 BOOL DMA_Transfer(BLOCK_DESC *blockList); 103 104 /** 105 * @brief DMA is busy or not 106 * @param None 107 * @retval BOOL The bit indicates if DMA is busy or not 108 */ 109 BOOL DMA_IsBusy(void); 110 111 #ifdef __cplusplus 112 } 113 #endif 114 115 #endif /* __CMEM7_DMA_H */ 116 117