cmem7_dma.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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>&copy; COPYRIGHT 2013 Capital-micro </center></h2>
  24. *****************************************************************************
  25. */
  26. #ifndef __CMEM7_DMA_H
  27. #define __CMEM7_DMA_H
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. #include "cmem7.h"
  32. #include "cmem7_conf.h"
  33. /** @defgroup DMA_Int
  34. * @{
  35. */
  36. #define DMA_Int_TfrComplete 0x00000001
  37. #define DMA_Int_Err 0x00000002
  38. #define DMA_Int_All 0x00000003
  39. #define IS_DMA_INT(INT) (((INT) != 0) && (((INT) & ~DMA_Int_All) == 0))
  40. /**
  41. * @}
  42. */
  43. /**
  44. * @brief Descriptor structure
  45. * @note DMA requires users provides a list of descriptors to operation.
  46. * Meanwhile, memory occupied by descriptors should be in physical
  47. * memory and keep valid during DMA transfer.
  48. */
  49. typedef struct {
  50. uint32_t srcAddr; /*!< source address */
  51. uint32_t dstAddr; /*!< destination address */
  52. uint32_t number; /*!< block byte number, no more than 2K Bytes */
  53. uint32_t nextBlock; /*!< next block descriptor */
  54. uint32_t padding; /*!< Nonsense, only used to fill */
  55. } BLOCK_DESC;
  56. /**
  57. * @brief DMA initialization
  58. * @note This function should be called at first before any other interfaces.
  59. * @param None
  60. * @retval None
  61. */
  62. void DMA_Init(void);
  63. /**
  64. * @brief Enable or disable DMA interrupt.
  65. * @param[in] Int interrupt mask bits, which can be the combination of @ref DMA_Int
  66. * @param[in] Enable The bit indicates if specific interrupts are enable or not
  67. * @retval None
  68. */
  69. void DMA_EnableInt(uint32_t Int, BOOL enable);
  70. /**
  71. * @brief Check specific interrupts are set or not
  72. * @param[in] Int interrupt mask bits, which can be the combination of @ref DMA_Int
  73. * @retval BOOL The bit indicates if specific interrupts are set or not
  74. */
  75. BOOL DMA_GetIntStatus(uint32_t Int);
  76. /**
  77. * @brief Clear specific interrupts
  78. * @param[in] Int interrupt mask bits, which can be the combination of @ref DMA_Int
  79. * @retval None
  80. */
  81. void DMA_ClearInt(uint32_t Int);
  82. /**
  83. * @brief DMA transfer
  84. * @note Make sure that memory occupied by descriptors should be in physical
  85. * memory and keep valid before DMA transfer is finished (Return false by
  86. * calling DMA_IsBusy after DMA transfer started).
  87. * @param[in] blockList A pointer to header of list of BLOCK_DESC
  88. * @retval BOOL The bit indicates if DMA begins to transfer
  89. * @see DMA_IsBusy
  90. */
  91. BOOL DMA_Transfer(BLOCK_DESC *blockList);
  92. /**
  93. * @brief DMA is busy or not
  94. * @param None
  95. * @retval BOOL The bit indicates if DMA is busy or not
  96. */
  97. BOOL DMA_IsBusy(void);
  98. #ifdef __cplusplus
  99. }
  100. #endif
  101. #endif /* __CMEM7_DMA_H */