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 
10 #ifndef __YC_DMA_H_
11 #define __YC_DMA_H_
12 
13 #include "yc3121.h"
14 #define DMACH_QSPI 0
15 
16 #define DMA_ENABLE_BIT_Pos 7
17 #define DMA_ENABLE ((uint8_t)1 << DMA_ENABLE_BIT_Pos)
18 
19 #define DMA_IT_BIT_Pos 1
20 #define DMA_IT_ENABLE ((uint32_t)1 << DMA_IT_BIT_Pos)
21 /*Peripheral DMA Channel*/
22 
23 typedef struct
24 {
25   uint32_t DMA_MemorySourceAddr; /*!< Specifies the memory Source address for Channel Mem_to_Mem. */
26 
27   uint32_t DMA_MemoryDestAddr; /*!<Specifies the memory Destination  address for Channel Mem_to_Mem. */
28 
29   uint32_t DMA_BlockSize; /*!< Specifies the  Total Number of data items during the transaction. */
30 
31 } DMA_InitTypeDef;
32 
33 /**
34   * @brief  Initializes the DMA Mem_to_Mem Channelx according to the specified
35   *         parameters in the DMA_InitStruct.
36   * @param  DMA_InitStruct: pointer to a DMA_InitTypeDef structure that
37   *         contains the configuration information for the specified DMA Channel.
38   * @retval None
39   */
40 void DMA_Init(DMA_InitTypeDef *DMA_InitStruct);
41 
42 /**
43   * @brief  Enables or disables  Channel DMACH_MEMCP.
44   * @param  NewState: new state of the DMAy Channelx.
45   *   This parameter can be: ENABLE or DISABLE.
46   * @retval None
47   */
48 void DMA_ChannelCmd(FunctionalState NewState);
49 
50 /**
51   * @brief  Set  DMA Source Address.
52   * @param  Address: DMA source address
53   * @retval None
54   */
55 void DMA_SetSRCAddress(uint32_t Address);
56 
57 /**
58   * @brief  Set  DMA destination Address.
59   * @param  Address: DMA source address
60   * @retval None
61   */
62 void DMA_SetDSRAddress(uint32_t Address);
63 
64 /**
65   * @brief  Checks whether the DMACH_MEMCP Channelx flag is set or not.
66   * @param  None
67   * @retval None
68   */
69 FlagStatus DMA_GetFlagStatus(void);
70 
71 /**
72   * @brief  Clears the  DMACH_MEMCP Channelx's pending flags.
73   * @param  None
74   * @retval Enable or Disable.
75   */
76 FunctionalState DMA_IsChannelEnabled(void);
77 
78 /**
79   * @brief   Clears the DMACH_MEMCP Channelx's interrupt pending bits.
80   * @param  None
81   * @retval None
82   */
83 void DMA_ClearITPendingBit(void);
84 
85 /**
86   * @brief   ENABLE or DISABLE intterrupt
87   * @param  NewState
88   * @retval None
89   */
90 void DMA_ITConfig(FunctionalState NewState);
91 #endif
92