yc_dma.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. File Name : yc_dma.h
  3. Author : Yichip
  4. Version : V1.0
  5. Date : 2018/03/27
  6. Description : DMA Mem_TO_Mem Mode encapsulation.
  7. If enable DMA interrupt ,enter interrupt after sending data by default,and just one DMA IT Mode.
  8. */
  9. #ifndef __YC_DMA_H_
  10. #define __YC_DMA_H_
  11. #include "yc3121.h"
  12. #define DMACH_QSPI 0
  13. #define DMA_ENABLE_BIT_Pos 7
  14. #define DMA_ENABLE ((uint8_t)1 << DMA_ENABLE_BIT_Pos)
  15. #define DMA_IT_BIT_Pos 1
  16. #define DMA_IT_ENABLE ((uint32_t)1 << DMA_IT_BIT_Pos)
  17. /*Peripheral DMA Channel*/
  18. typedef struct
  19. {
  20. uint32_t DMA_MemorySourceAddr; /*!< Specifies the memory Source address for Channel Mem_to_Mem. */
  21. uint32_t DMA_MemoryDestAddr; /*!<Specifies the memory Destination address for Channel Mem_to_Mem. */
  22. uint32_t DMA_BlockSize; /*!< Specifies the Total Number of data items during the transaction. */
  23. } DMA_InitTypeDef;
  24. /**
  25. * @brief Initializes the DMA Mem_to_Mem Channelx according to the specified
  26. * parameters in the DMA_InitStruct.
  27. * @param DMA_InitStruct: pointer to a DMA_InitTypeDef structure that
  28. * contains the configuration information for the specified DMA Channel.
  29. * @retval None
  30. */
  31. void DMA_Init(DMA_InitTypeDef *DMA_InitStruct);
  32. /**
  33. * @brief Enables or disables Channel DMACH_MEMCP.
  34. * @param NewState: new state of the DMAy Channelx.
  35. * This parameter can be: ENABLE or DISABLE.
  36. * @retval None
  37. */
  38. void DMA_ChannelCmd(FunctionalState NewState);
  39. /**
  40. * @brief Set DMA Source Address.
  41. * @param Address: DMA source address
  42. * @retval None
  43. */
  44. void DMA_SetSRCAddress(uint32_t Address);
  45. /**
  46. * @brief Set DMA destination Address.
  47. * @param Address: DMA source address
  48. * @retval None
  49. */
  50. void DMA_SetDSRAddress(uint32_t Address);
  51. /**
  52. * @brief Checks whether the DMACH_MEMCP Channelx flag is set or not.
  53. * @param None
  54. * @retval None
  55. */
  56. FlagStatus DMA_GetFlagStatus(void);
  57. /**
  58. * @brief Clears the DMACH_MEMCP Channelx's pending flags.
  59. * @param None
  60. * @retval Enable or Disable.
  61. */
  62. FunctionalState DMA_IsChannelEnabled(void);
  63. /**
  64. * @brief Clears the DMACH_MEMCP Channelx's interrupt pending bits.
  65. * @param None
  66. * @retval None
  67. */
  68. void DMA_ClearITPendingBit(void);
  69. /**
  70. * @brief ENABLE or DISABLE intterrupt
  71. * @param NewState
  72. * @retval None
  73. */
  74. void DMA_ITConfig(FunctionalState NewState);
  75. #endif