]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F3XX/stm32f30x_dma.c
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[qmk_firmware.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_STM / TARGET_STM32F3XX / stm32f30x_dma.c
1 /**
2   ******************************************************************************
3   * @file    stm32f30x_dma.c
4   * @author  MCD Application Team
5   * @version V1.1.0
6   * @date    27-February-2014
7   * @brief   This file provides firmware functions to manage the following 
8   *          functionalities of the Direct Memory Access controller (DMA):
9   *           + Initialization and Configuration
10   *           + Data Counter
11   *           + Interrupts and flags management
12   *
13   @verbatim
14     
15  ===============================================================================
16                        ##### How to use this driver #####
17  ===============================================================================
18     [..]
19     (#) Enable The DMA controller clock using 
20         RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE) function for DMA1 or 
21         using RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA2, ENABLE) function for DMA2.
22     (#) Enable and configure the peripheral to be connected to the DMA channel
23         (except for internal SRAM / FLASH memories: no initialization is necessary). 
24     (#) For a given Channel, program the Source and Destination addresses,  
25         the transfer Direction, the Buffer Size, the Peripheral and Memory
26         Incrementation mode and Data Size, the Circular or Normal mode, 
27         the channel transfer Priority and the Memory-to-Memory transfer 
28         mode (if needed) using the DMA_Init() function.
29     (#) Enable the NVIC and the corresponding interrupt(s) using the function 
30         DMA_ITConfig() if you need to use DMA interrupts.
31     (#) Enable the DMA channel using the DMA_Cmd() function.
32     (#) Activate the needed channel Request using PPP_DMACmd() function for
33         any PPP peripheral except internal SRAM and FLASH (ie. SPI, USART ...)
34         The function allowing this operation is provided in each PPP peripheral
35         driver (ie. SPI_DMACmd for SPI peripheral).
36     (#) Optionally, you can configure the number of data to be transferred
37         when the channel is disabled (ie. after each Transfer Complete event
38         or when a Transfer Error occurs) using the function DMA_SetCurrDataCounter().
39         And you can get the number of remaining data to be transferred using 
40         the function DMA_GetCurrDataCounter() at run time (when the DMA channel is
41         enabled and running).
42     (#) To control DMA events you can use one of the following two methods:
43         (##) Check on DMA channel flags using the function DMA_GetFlagStatus().
44         (##) Use DMA interrupts through the function DMA_ITConfig() at initialization
45              phase and DMA_GetITStatus() function into interrupt routines in
46              communication phase.
47              After checking on a flag you should clear it using DMA_ClearFlag()
48              function. And after checking on an interrupt event you should 
49              clear it using DMA_ClearITPendingBit() function.
50
51   @endverbatim
52
53   ******************************************************************************
54   * @attention
55   *
56   * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
57   *
58   * Redistribution and use in source and binary forms, with or without modification,
59   * are permitted provided that the following conditions are met:
60   *   1. Redistributions of source code must retain the above copyright notice,
61   *      this list of conditions and the following disclaimer.
62   *   2. Redistributions in binary form must reproduce the above copyright notice,
63   *      this list of conditions and the following disclaimer in the documentation
64   *      and/or other materials provided with the distribution.
65   *   3. Neither the name of STMicroelectronics nor the names of its contributors
66   *      may be used to endorse or promote products derived from this software
67   *      without specific prior written permission.
68   *
69   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
70   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
71   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
72   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
73   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
74   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
75   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
76   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
77   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
78   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
79   *
80   ******************************************************************************
81   */
82
83 /* Includes ------------------------------------------------------------------*/
84 #include "stm32f30x_dma.h"
85
86 /** @addtogroup STM32F30x_StdPeriph_Driver
87   * @{
88   */
89
90 /** @defgroup DMA 
91   * @brief DMA driver modules
92   * @{
93   */
94
95 /* Private typedef -----------------------------------------------------------*/
96 /* Private define ------------------------------------------------------------*/
97 #define CCR_CLEAR_MASK   ((uint32_t)0xFFFF800F) /* DMA Channel config registers Masks */
98 #define FLAG_Mask        ((uint32_t)0x10000000) /* DMA2 FLAG mask */
99
100
101 /* DMA1 Channelx interrupt pending bit masks */
102 #define DMA1_CHANNEL1_IT_MASK    ((uint32_t)(DMA_ISR_GIF1 | DMA_ISR_TCIF1 | DMA_ISR_HTIF1 | DMA_ISR_TEIF1))
103 #define DMA1_CHANNEL2_IT_MASK    ((uint32_t)(DMA_ISR_GIF2 | DMA_ISR_TCIF2 | DMA_ISR_HTIF2 | DMA_ISR_TEIF2))
104 #define DMA1_CHANNEL3_IT_MASK    ((uint32_t)(DMA_ISR_GIF3 | DMA_ISR_TCIF3 | DMA_ISR_HTIF3 | DMA_ISR_TEIF3))
105 #define DMA1_CHANNEL4_IT_MASK    ((uint32_t)(DMA_ISR_GIF4 | DMA_ISR_TCIF4 | DMA_ISR_HTIF4 | DMA_ISR_TEIF4))
106 #define DMA1_CHANNEL5_IT_MASK    ((uint32_t)(DMA_ISR_GIF5 | DMA_ISR_TCIF5 | DMA_ISR_HTIF5 | DMA_ISR_TEIF5))
107 #define DMA1_CHANNEL6_IT_MASK    ((uint32_t)(DMA_ISR_GIF6 | DMA_ISR_TCIF6 | DMA_ISR_HTIF6 | DMA_ISR_TEIF6))
108 #define DMA1_CHANNEL7_IT_MASK    ((uint32_t)(DMA_ISR_GIF7 | DMA_ISR_TCIF7 | DMA_ISR_HTIF7 | DMA_ISR_TEIF7))
109
110 /* DMA2 Channelx interrupt pending bit masks */
111 #define DMA2_CHANNEL1_IT_MASK    ((uint32_t)(DMA_ISR_GIF1 | DMA_ISR_TCIF1 | DMA_ISR_HTIF1 | DMA_ISR_TEIF1))
112 #define DMA2_CHANNEL2_IT_MASK    ((uint32_t)(DMA_ISR_GIF2 | DMA_ISR_TCIF2 | DMA_ISR_HTIF2 | DMA_ISR_TEIF2))
113 #define DMA2_CHANNEL3_IT_MASK    ((uint32_t)(DMA_ISR_GIF3 | DMA_ISR_TCIF3 | DMA_ISR_HTIF3 | DMA_ISR_TEIF3))
114 #define DMA2_CHANNEL4_IT_MASK    ((uint32_t)(DMA_ISR_GIF4 | DMA_ISR_TCIF4 | DMA_ISR_HTIF4 | DMA_ISR_TEIF4))
115 #define DMA2_CHANNEL5_IT_MASK    ((uint32_t)(DMA_ISR_GIF5 | DMA_ISR_TCIF5 | DMA_ISR_HTIF5 | DMA_ISR_TEIF5))
116
117 /* Private macro -------------------------------------------------------------*/
118 /* Private variables ---------------------------------------------------------*/
119 /* Private function prototypes -----------------------------------------------*/
120 /* Private functions ---------------------------------------------------------*/
121
122 /** @defgroup DMA_Private_Functions 
123   * @{
124   */
125
126 /** @defgroup  DMA_Group1 Initialization and Configuration functions
127  *  @brief   Initialization and Configuration functions
128  *
129 @verbatim
130  ===============================================================================
131               ##### Initialization and Configuration functions #####
132  ===============================================================================
133     [..] This subsection provides functions allowing to initialize the DMA channel 
134          source and destination addresses, incrementation and data sizes, transfer 
135          direction, buffer size, circular/normal mode selection, memory-to-memory 
136          mode selection and channel priority value.
137     [..] The DMA_Init() function follows the DMA configuration procedures as described 
138          in reference manual (RM00316).
139
140 @endverbatim
141   * @{
142   */
143   
144 /**
145   * @brief  Deinitializes the DMAy Channelx registers to their default reset
146   *         values.
147   * @param  DMAy_Channelx: where y can be 1 or 2 to select the DMA and 
148   *         x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the DMA Channel.
149   * @retval None
150   */
151 void DMA_DeInit(DMA_Channel_TypeDef* DMAy_Channelx)
152 {
153   /* Check the parameters */
154   assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
155
156   /* Disable the selected DMAy Channelx */
157   DMAy_Channelx->CCR &= (uint16_t)(~DMA_CCR_EN);
158
159   /* Reset DMAy Channelx control register */
160   DMAy_Channelx->CCR  = 0;
161
162   /* Reset DMAy Channelx remaining bytes register */
163   DMAy_Channelx->CNDTR = 0;
164
165   /* Reset DMAy Channelx peripheral address register */
166   DMAy_Channelx->CPAR  = 0;
167
168   /* Reset DMAy Channelx memory address register */
169   DMAy_Channelx->CMAR = 0;
170
171   if (DMAy_Channelx == DMA1_Channel1)
172   {
173     /* Reset interrupt pending bits for DMA1 Channel1 */
174     DMA1->IFCR |= DMA1_CHANNEL1_IT_MASK;
175   }
176   else if (DMAy_Channelx == DMA1_Channel2)
177   {
178     /* Reset interrupt pending bits for DMA1 Channel2 */
179     DMA1->IFCR |= DMA1_CHANNEL2_IT_MASK;
180   }
181   else if (DMAy_Channelx == DMA1_Channel3)
182   {
183     /* Reset interrupt pending bits for DMA1 Channel3 */
184     DMA1->IFCR |= DMA1_CHANNEL3_IT_MASK;
185   }
186   else if (DMAy_Channelx == DMA1_Channel4)
187   {
188     /* Reset interrupt pending bits for DMA1 Channel4 */
189     DMA1->IFCR |= DMA1_CHANNEL4_IT_MASK;
190   }
191   else if (DMAy_Channelx == DMA1_Channel5)
192   {
193     /* Reset interrupt pending bits for DMA1 Channel5 */
194     DMA1->IFCR |= DMA1_CHANNEL5_IT_MASK;
195   }
196   else if (DMAy_Channelx == DMA1_Channel6)
197   {
198     /* Reset interrupt pending bits for DMA1 Channel6 */
199     DMA1->IFCR |= DMA1_CHANNEL6_IT_MASK;
200   }
201   else if (DMAy_Channelx == DMA1_Channel7)
202   {
203     /* Reset interrupt pending bits for DMA1 Channel7 */
204     DMA1->IFCR |= DMA1_CHANNEL7_IT_MASK;
205   }
206   else if (DMAy_Channelx == DMA2_Channel1)
207   {
208     /* Reset interrupt pending bits for DMA2 Channel1 */
209     DMA2->IFCR |= DMA2_CHANNEL1_IT_MASK;
210   }
211   else if (DMAy_Channelx == DMA2_Channel2)
212   {
213     /* Reset interrupt pending bits for DMA2 Channel2 */
214     DMA2->IFCR |= DMA2_CHANNEL2_IT_MASK;
215   }
216   else if (DMAy_Channelx == DMA2_Channel3)
217   {
218     /* Reset interrupt pending bits for DMA2 Channel3 */
219     DMA2->IFCR |= DMA2_CHANNEL3_IT_MASK;
220   }
221   else if (DMAy_Channelx == DMA2_Channel4)
222   {
223     /* Reset interrupt pending bits for DMA2 Channel4 */
224     DMA2->IFCR |= DMA2_CHANNEL4_IT_MASK;
225   }
226   else
227   { 
228     if (DMAy_Channelx == DMA2_Channel5)
229     {
230       /* Reset interrupt pending bits for DMA2 Channel5 */
231       DMA2->IFCR |= DMA2_CHANNEL5_IT_MASK;
232     }
233   }
234 }
235
236 /**
237   * @brief  Initializes the DMAy Channelx according to the specified parameters 
238   *         in the DMA_InitStruct.
239   * @param  DMAy_Channelx: where y can be 1 or 2 to select the DMA and 
240   *         x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the DMA Channel.
241   * @param  DMA_InitStruct: pointer to a DMA_InitTypeDef structure that contains
242   *         the configuration information for the specified DMA Channel.
243   * @retval None
244   */
245 void DMA_Init(DMA_Channel_TypeDef* DMAy_Channelx, DMA_InitTypeDef* DMA_InitStruct)
246 {
247   uint32_t tmpreg = 0;
248
249   /* Check the parameters */
250   assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
251   assert_param(IS_DMA_DIR(DMA_InitStruct->DMA_DIR));
252   assert_param(IS_DMA_PERIPHERAL_INC_STATE(DMA_InitStruct->DMA_PeripheralInc));
253   assert_param(IS_DMA_MEMORY_INC_STATE(DMA_InitStruct->DMA_MemoryInc));
254   assert_param(IS_DMA_PERIPHERAL_DATA_SIZE(DMA_InitStruct->DMA_PeripheralDataSize));
255   assert_param(IS_DMA_MEMORY_DATA_SIZE(DMA_InitStruct->DMA_MemoryDataSize));
256   assert_param(IS_DMA_MODE(DMA_InitStruct->DMA_Mode));
257   assert_param(IS_DMA_PRIORITY(DMA_InitStruct->DMA_Priority));
258   assert_param(IS_DMA_M2M_STATE(DMA_InitStruct->DMA_M2M));
259
260 /*--------------------------- DMAy Channelx CCR Configuration ----------------*/
261   /* Get the DMAy_Channelx CCR value */
262   tmpreg = DMAy_Channelx->CCR;
263
264   /* Clear MEM2MEM, PL, MSIZE, PSIZE, MINC, PINC, CIRC and DIR bits */
265   tmpreg &= CCR_CLEAR_MASK;
266
267   /* Configure DMAy Channelx: data transfer, data size, priority level and mode */
268   /* Set DIR bit according to DMA_DIR value */
269   /* Set CIRC bit according to DMA_Mode value */
270   /* Set PINC bit according to DMA_PeripheralInc value */
271   /* Set MINC bit according to DMA_MemoryInc value */
272   /* Set PSIZE bits according to DMA_PeripheralDataSize value */
273   /* Set MSIZE bits according to DMA_MemoryDataSize value */
274   /* Set PL bits according to DMA_Priority value */
275   /* Set the MEM2MEM bit according to DMA_M2M value */
276   tmpreg |= DMA_InitStruct->DMA_DIR | DMA_InitStruct->DMA_Mode |
277             DMA_InitStruct->DMA_PeripheralInc | DMA_InitStruct->DMA_MemoryInc |
278             DMA_InitStruct->DMA_PeripheralDataSize | DMA_InitStruct->DMA_MemoryDataSize |
279             DMA_InitStruct->DMA_Priority | DMA_InitStruct->DMA_M2M;
280
281   /* Write to DMAy Channelx CCR */
282   DMAy_Channelx->CCR = tmpreg;
283
284 /*--------------------------- DMAy Channelx CNDTR Configuration --------------*/
285   /* Write to DMAy Channelx CNDTR */
286   DMAy_Channelx->CNDTR = DMA_InitStruct->DMA_BufferSize;
287
288 /*--------------------------- DMAy Channelx CPAR Configuration ---------------*/
289   /* Write to DMAy Channelx CPAR */
290   DMAy_Channelx->CPAR = DMA_InitStruct->DMA_PeripheralBaseAddr;
291
292 /*--------------------------- DMAy Channelx CMAR Configuration ---------------*/
293   /* Write to DMAy Channelx CMAR */
294   DMAy_Channelx->CMAR = DMA_InitStruct->DMA_MemoryBaseAddr;
295 }
296
297 /**
298   * @brief  Fills each DMA_InitStruct member with its default value.
299   * @param  DMA_InitStruct: pointer to a DMA_InitTypeDef structure which will
300   *         be initialized.
301   * @retval None
302   */
303 void DMA_StructInit(DMA_InitTypeDef* DMA_InitStruct)
304 {
305 /*-------------- Reset DMA init structure parameters values ------------------*/
306   /* Initialize the DMA_PeripheralBaseAddr member */
307   DMA_InitStruct->DMA_PeripheralBaseAddr = 0;
308   /* Initialize the DMA_MemoryBaseAddr member */
309   DMA_InitStruct->DMA_MemoryBaseAddr = 0;
310   /* Initialize the DMA_DIR member */
311   DMA_InitStruct->DMA_DIR = DMA_DIR_PeripheralSRC;
312   /* Initialize the DMA_BufferSize member */
313   DMA_InitStruct->DMA_BufferSize = 0;
314   /* Initialize the DMA_PeripheralInc member */
315   DMA_InitStruct->DMA_PeripheralInc = DMA_PeripheralInc_Disable;
316   /* Initialize the DMA_MemoryInc member */
317   DMA_InitStruct->DMA_MemoryInc = DMA_MemoryInc_Disable;
318   /* Initialize the DMA_PeripheralDataSize member */
319   DMA_InitStruct->DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
320   /* Initialize the DMA_MemoryDataSize member */
321   DMA_InitStruct->DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
322   /* Initialize the DMA_Mode member */
323   DMA_InitStruct->DMA_Mode = DMA_Mode_Normal;
324   /* Initialize the DMA_Priority member */
325   DMA_InitStruct->DMA_Priority = DMA_Priority_Low;
326   /* Initialize the DMA_M2M member */
327   DMA_InitStruct->DMA_M2M = DMA_M2M_Disable;
328 }
329
330 /**
331   * @brief  Enables or disables the specified DMAy Channelx.
332   * @param  DMAy_Channelx: where y can be 1 or 2 to select the DMA and 
333   *         x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the DMA Channel.
334   * @param  NewState: new state of the DMAy Channelx. 
335   *         This parameter can be: ENABLE or DISABLE.
336   * @retval None
337   */
338 void DMA_Cmd(DMA_Channel_TypeDef* DMAy_Channelx, FunctionalState NewState)
339 {
340   /* Check the parameters */
341   assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
342   assert_param(IS_FUNCTIONAL_STATE(NewState));
343
344   if (NewState != DISABLE)
345   {
346     /* Enable the selected DMAy Channelx */
347     DMAy_Channelx->CCR |= DMA_CCR_EN;
348   }
349   else
350   {
351     /* Disable the selected DMAy Channelx */
352     DMAy_Channelx->CCR &= (uint16_t)(~DMA_CCR_EN);
353   }
354 }
355
356 /**
357   * @}
358   */
359   
360 /** @defgroup DMA_Group2 Data Counter functions
361  *  @brief   Data Counter functions
362  *
363 @verbatim  
364  ===============================================================================
365                       ##### Data Counter functions #####
366  ===============================================================================
367     [..] This subsection provides function allowing to configure and read the buffer 
368          size (number of data to be transferred).The DMA data counter can be written 
369          only when the DMA channel is disabled (ie. after transfer complete event).
370     [..] The following function can be used to write the Channel data counter value:
371          (+) void DMA_SetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx, uint16_t DataNumber).
372     [..]
373     (@) It is advised to use this function rather than DMA_Init() in situations 
374         where only the Data buffer needs to be reloaded.
375     [..] The DMA data counter can be read to indicate the number of remaining transfers 
376          for the relative DMA channel. This counter is decremented at the end of each 
377          data transfer and when the transfer is complete: 
378          (+) If Normal mode is selected: the counter is set to 0.
379          (+) If Circular mode is selected: the counter is reloaded with the initial 
380          value(configured before enabling the DMA channel).
381     [..] The following function can be used to read the Channel data counter value:
382          (+) uint16_t DMA_GetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx).
383
384 @endverbatim
385   * @{
386   */
387
388 /**
389   * @brief  Sets the number of data units in the current DMAy Channelx transfer.
390   * @param  DMAy_Channelx: where y can be 1 or 2 to select the DMA and 
391   *         x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the DMA Channel.
392   * @param  DataNumber: The number of data units in the current DMAy Channelx
393   *         transfer.   
394   * @note   This function can only be used when the DMAy_Channelx is disabled.
395   * @retval None.
396   */
397 void DMA_SetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx, uint16_t DataNumber)
398 {
399   /* Check the parameters */
400   assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
401
402 /*--------------------------- DMAy Channelx CNDTR Configuration --------------*/
403   /* Write to DMAy Channelx CNDTR */
404   DMAy_Channelx->CNDTR = DataNumber;
405 }
406
407 /**
408   * @brief  Returns the number of remaining data units in the current
409   *         DMAy Channelx transfer.
410   * @param  DMAy_Channelx: where y can be 1 or 2 to select the DMA and 
411   *         x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the DMA Channel.
412   * @retval The number of remaining data units in the current DMAy Channelx
413   *         transfer.
414   */
415 uint16_t DMA_GetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx)
416 {
417   /* Check the parameters */
418   assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
419   /* Return the number of remaining data units for DMAy Channelx */
420   return ((uint16_t)(DMAy_Channelx->CNDTR));
421 }
422
423 /**
424   * @}
425   */
426   
427 /** @defgroup DMA_Group3 Interrupts and flags management functions
428  *  @brief   Interrupts and flags management functions  
429  *
430 @verbatim
431  ===============================================================================
432           ##### Interrupts and flags management functions #####
433  ===============================================================================
434     [..] This subsection provides functions allowing to configure the DMA Interrupt 
435          sources and check or clear the flags or pending bits status.
436          The user should identify which mode will be used in his application to manage 
437          the DMA controller events: Polling mode or Interrupt mode. 
438   
439   *** Polling Mode ***
440   ====================
441     [..] Each DMA channel can be managed through 4 event Flags (y : DMA Controller 
442          number, x : DMA channel number):
443          (#) DMAy_FLAG_TCx : to indicate that a Transfer Complete event occurred.
444          (#) DMAy_FLAG_HTx : to indicate that a Half-Transfer Complete event occurred.
445          (#) DMAy_FLAG_TEx : to indicate that a Transfer Error occurred.
446          (#) DMAy_FLAG_GLx : to indicate that at least one of the events described 
447              above occurred.
448     [..]         
449     (@) Clearing DMAy_FLAG_GLx results in clearing all other pending flags of the 
450         same channel (DMAy_FLAG_TCx, DMAy_FLAG_HTx and DMAy_FLAG_TEx).
451     [..] In this Mode it is advised to use the following functions:
452          (+) FlagStatus DMA_GetFlagStatus(uint32_t DMA_FLAG);
453          (+) void DMA_ClearFlag(uint32_t DMA_FLAG);
454
455   *** Interrupt Mode ***
456   ======================
457     [..] Each DMA channel can be managed through 4 Interrupts:
458     (+) Interrupt Source
459        (##) DMA_IT_TC: specifies the interrupt source for the Transfer Complete 
460             event.
461        (##) DMA_IT_HT: specifies the interrupt source for the Half-transfer Complete 
462             event.
463        (##) DMA_IT_TE: specifies the interrupt source for the transfer errors event.
464        (##) DMA_IT_GL: to indicate that at least one of the interrupts described 
465             above occurred.
466     -@@- Clearing DMA_IT_GL interrupt results in clearing all other interrupts of 
467          the same channel (DMA_IT_TCx, DMA_IT_HT and DMA_IT_TE).
468     [..] In this Mode it is advised to use the following functions:
469          (+) void DMA_ITConfig(DMA_Channel_TypeDef* DMAy_Channelx, uint32_t DMA_IT, FunctionalState NewState);
470          (+) ITStatus DMA_GetITStatus(uint32_t DMA_IT);
471          (+) void DMA_ClearITPendingBit(uint32_t DMA_IT);
472
473 @endverbatim
474   * @{
475   */ 
476
477 /**
478   * @brief  Enables or disables the specified DMAy Channelx interrupts.
479   * @param  DMAy_Channelx: where y can be 1 or 2 to select the DMA and 
480   *         x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the DMA Channel.
481   * @param  DMA_IT: specifies the DMA interrupts sources to be enabled
482   *         or disabled. 
483   *   This parameter can be any combination of the following values:
484   *     @arg DMA_IT_TC: Transfer complete interrupt mask
485   *     @arg DMA_IT_HT: Half transfer interrupt mask
486   *     @arg DMA_IT_TE: Transfer error interrupt mask
487   * @param  NewState: new state of the specified DMA interrupts.
488   *         This parameter can be: ENABLE or DISABLE.
489   * @retval None
490   */
491 void DMA_ITConfig(DMA_Channel_TypeDef* DMAy_Channelx, uint32_t DMA_IT, FunctionalState NewState)
492 {
493   /* Check the parameters */
494   assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
495   assert_param(IS_DMA_CONFIG_IT(DMA_IT));
496   assert_param(IS_FUNCTIONAL_STATE(NewState));
497   
498   if (NewState != DISABLE)
499   {
500     /* Enable the selected DMA interrupts */
501     DMAy_Channelx->CCR |= DMA_IT;
502   }
503   else
504   {
505     /* Disable the selected DMA interrupts */
506     DMAy_Channelx->CCR &= ~DMA_IT;
507   }
508 }
509
510 /**
511   * @brief  Checks whether the specified DMAy Channelx flag is set or not.
512   * @param  DMAy_FLAG: specifies the flag to check.
513   *   This parameter can be one of the following values:
514   *     @arg DMA1_FLAG_GL1: DMA1 Channel1 global flag.
515   *     @arg DMA1_FLAG_TC1: DMA1 Channel1 transfer complete flag.
516   *     @arg DMA1_FLAG_HT1: DMA1 Channel1 half transfer flag.
517   *     @arg DMA1_FLAG_TE1: DMA1 Channel1 transfer error flag.
518   *     @arg DMA1_FLAG_GL2: DMA1 Channel2 global flag.
519   *     @arg DMA1_FLAG_TC2: DMA1 Channel2 transfer complete flag.
520   *     @arg DMA1_FLAG_HT2: DMA1 Channel2 half transfer flag.
521   *     @arg DMA1_FLAG_TE2: DMA1 Channel2 transfer error flag.
522   *     @arg DMA1_FLAG_GL3: DMA1 Channel3 global flag.
523   *     @arg DMA1_FLAG_TC3: DMA1 Channel3 transfer complete flag.
524   *     @arg DMA1_FLAG_HT3: DMA1 Channel3 half transfer flag.
525   *     @arg DMA1_FLAG_TE3: DMA1 Channel3 transfer error flag.
526   *     @arg DMA1_FLAG_GL4: DMA1 Channel4 global flag.
527   *     @arg DMA1_FLAG_TC4: DMA1 Channel4 transfer complete flag.
528   *     @arg DMA1_FLAG_HT4: DMA1 Channel4 half transfer flag.
529   *     @arg DMA1_FLAG_TE4: DMA1 Channel4 transfer error flag.
530   *     @arg DMA1_FLAG_GL5: DMA1 Channel5 global flag.
531   *     @arg DMA1_FLAG_TC5: DMA1 Channel5 transfer complete flag.
532   *     @arg DMA1_FLAG_HT5: DMA1 Channel5 half transfer flag.
533   *     @arg DMA1_FLAG_TE5: DMA1 Channel5 transfer error flag.
534   *     @arg DMA1_FLAG_GL6: DMA1 Channel6 global flag.
535   *     @arg DMA1_FLAG_TC6: DMA1 Channel6 transfer complete flag.
536   *     @arg DMA1_FLAG_HT6: DMA1 Channel6 half transfer flag.
537   *     @arg DMA1_FLAG_TE6: DMA1 Channel6 transfer error flag.
538   *     @arg DMA1_FLAG_GL7: DMA1 Channel7 global flag.
539   *     @arg DMA1_FLAG_TC7: DMA1 Channel7 transfer complete flag.
540   *     @arg DMA1_FLAG_HT7: DMA1 Channel7 half transfer flag.
541   *     @arg DMA1_FLAG_TE7: DMA1 Channel7 transfer error flag.
542   *     @arg DMA2_FLAG_GL1: DMA2 Channel1 global flag.
543   *     @arg DMA2_FLAG_TC1: DMA2 Channel1 transfer complete flag.
544   *     @arg DMA2_FLAG_HT1: DMA2 Channel1 half transfer flag.
545   *     @arg DMA2_FLAG_TE1: DMA2 Channel1 transfer error flag.
546   *     @arg DMA2_FLAG_GL2: DMA2 Channel2 global flag.
547   *     @arg DMA2_FLAG_TC2: DMA2 Channel2 transfer complete flag.
548   *     @arg DMA2_FLAG_HT2: DMA2 Channel2 half transfer flag.
549   *     @arg DMA2_FLAG_TE2: DMA2 Channel2 transfer error flag.
550   *     @arg DMA2_FLAG_GL3: DMA2 Channel3 global flag.
551   *     @arg DMA2_FLAG_TC3: DMA2 Channel3 transfer complete flag.
552   *     @arg DMA2_FLAG_HT3: DMA2 Channel3 half transfer flag.
553   *     @arg DMA2_FLAG_TE3: DMA2 Channel3 transfer error flag.
554   *     @arg DMA2_FLAG_GL4: DMA2 Channel4 global flag.
555   *     @arg DMA2_FLAG_TC4: DMA2 Channel4 transfer complete flag.
556   *     @arg DMA2_FLAG_HT4: DMA2 Channel4 half transfer flag.
557   *     @arg DMA2_FLAG_TE4: DMA2 Channel4 transfer error flag.
558   *     @arg DMA2_FLAG_GL5: DMA2 Channel5 global flag.
559   *     @arg DMA2_FLAG_TC5: DMA2 Channel5 transfer complete flag.
560   *     @arg DMA2_FLAG_HT5: DMA2 Channel5 half transfer flag.
561   *     @arg DMA2_FLAG_TE5: DMA2 Channel5 transfer error flag.
562   *     
563   * @note
564   *    The Global flag (DMAy_FLAG_GLx) is set whenever any of the other flags 
565   *    relative to the same channel is set (Transfer Complete, Half-transfer 
566   *    Complete or Transfer Error flags: DMAy_FLAG_TCx, DMAy_FLAG_HTx or 
567   *    DMAy_FLAG_TEx). 
568   *      
569   * @retval The new state of DMAy_FLAG (SET or RESET).
570   */
571 FlagStatus DMA_GetFlagStatus(uint32_t DMAy_FLAG)
572 {
573   FlagStatus bitstatus = RESET;
574   uint32_t tmpreg = 0;
575   
576   /* Check the parameters */
577   assert_param(IS_DMA_GET_FLAG(DMAy_FLAG));
578
579   /* Calculate the used DMAy */
580   if ((DMAy_FLAG & FLAG_Mask) != (uint32_t)RESET)
581   {
582     /* Get DMA2 ISR register value */
583     tmpreg = DMA2->ISR ;
584   }
585   else
586   {
587     /* Get DMA1 ISR register value */
588     tmpreg = DMA1->ISR ;
589   }
590
591   /* Check the status of the specified DMAy flag */
592   if ((tmpreg & DMAy_FLAG) != (uint32_t)RESET)
593   {
594     /* DMAy_FLAG is set */
595     bitstatus = SET;
596   }
597   else
598   {
599     /* DMAy_FLAG is reset */
600     bitstatus = RESET;
601   }
602   
603   /* Return the DMAy_FLAG status */
604   return  bitstatus;
605 }
606
607 /**
608   * @brief  Clears the DMAy Channelx's pending flags.
609   * @param  DMAy_FLAG: specifies the flag to clear.
610   *   This parameter can be any combination (for the same DMA) of the following values:
611   *     @arg DMA1_FLAG_GL1: DMA1 Channel1 global flag.
612   *     @arg DMA1_FLAG_TC1: DMA1 Channel1 transfer complete flag.
613   *     @arg DMA1_FLAG_HT1: DMA1 Channel1 half transfer flag.
614   *     @arg DMA1_FLAG_TE1: DMA1 Channel1 transfer error flag.
615   *     @arg DMA1_FLAG_GL2: DMA1 Channel2 global flag.
616   *     @arg DMA1_FLAG_TC2: DMA1 Channel2 transfer complete flag.
617   *     @arg DMA1_FLAG_HT2: DMA1 Channel2 half transfer flag.
618   *     @arg DMA1_FLAG_TE2: DMA1 Channel2 transfer error flag.
619   *     @arg DMA1_FLAG_GL3: DMA1 Channel3 global flag.
620   *     @arg DMA1_FLAG_TC3: DMA1 Channel3 transfer complete flag.
621   *     @arg DMA1_FLAG_HT3: DMA1 Channel3 half transfer flag.
622   *     @arg DMA1_FLAG_TE3: DMA1 Channel3 transfer error flag.
623   *     @arg DMA1_FLAG_GL4: DMA1 Channel4 global flag.
624   *     @arg DMA1_FLAG_TC4: DMA1 Channel4 transfer complete flag.
625   *     @arg DMA1_FLAG_HT4: DMA1 Channel4 half transfer flag.
626   *     @arg DMA1_FLAG_TE4: DMA1 Channel4 transfer error flag.
627   *     @arg DMA1_FLAG_GL5: DMA1 Channel5 global flag.
628   *     @arg DMA1_FLAG_TC5: DMA1 Channel5 transfer complete flag.
629   *     @arg DMA1_FLAG_HT5: DMA1 Channel5 half transfer flag.
630   *     @arg DMA1_FLAG_TE5: DMA1 Channel5 transfer error flag.
631   *     @arg DMA1_FLAG_GL6: DMA1 Channel6 global flag.
632   *     @arg DMA1_FLAG_TC6: DMA1 Channel6 transfer complete flag.
633   *     @arg DMA1_FLAG_HT6: DMA1 Channel6 half transfer flag.
634   *     @arg DMA1_FLAG_TE6: DMA1 Channel6 transfer error flag.
635   *     @arg DMA1_FLAG_GL7: DMA1 Channel7 global flag.
636   *     @arg DMA1_FLAG_TC7: DMA1 Channel7 transfer complete flag.
637   *     @arg DMA1_FLAG_HT7: DMA1 Channel7 half transfer flag.
638   *     @arg DMA1_FLAG_TE7: DMA1 Channel7 transfer error flag.
639   *     @arg DMA2_FLAG_GL1: DMA2 Channel1 global flag.
640   *     @arg DMA2_FLAG_TC1: DMA2 Channel1 transfer complete flag.
641   *     @arg DMA2_FLAG_HT1: DMA2 Channel1 half transfer flag.
642   *     @arg DMA2_FLAG_TE1: DMA2 Channel1 transfer error flag.
643   *     @arg DMA2_FLAG_GL2: DMA2 Channel2 global flag.
644   *     @arg DMA2_FLAG_TC2: DMA2 Channel2 transfer complete flag.
645   *     @arg DMA2_FLAG_HT2: DMA2 Channel2 half transfer flag.
646   *     @arg DMA2_FLAG_TE2: DMA2 Channel2 transfer error flag.
647   *     @arg DMA2_FLAG_GL3: DMA2 Channel3 global flag.
648   *     @arg DMA2_FLAG_TC3: DMA2 Channel3 transfer complete flag.
649   *     @arg DMA2_FLAG_HT3: DMA2 Channel3 half transfer flag.
650   *     @arg DMA2_FLAG_TE3: DMA2 Channel3 transfer error flag.
651   *     @arg DMA2_FLAG_GL4: DMA2 Channel4 global flag.
652   *     @arg DMA2_FLAG_TC4: DMA2 Channel4 transfer complete flag.
653   *     @arg DMA2_FLAG_HT4: DMA2 Channel4 half transfer flag.
654   *     @arg DMA2_FLAG_TE4: DMA2 Channel4 transfer error flag.
655   *     @arg DMA2_FLAG_GL5: DMA2 Channel5 global flag.
656   *     @arg DMA2_FLAG_TC5: DMA2 Channel5 transfer complete flag.
657   *     @arg DMA2_FLAG_HT5: DMA2 Channel5 half transfer flag.
658   *     @arg DMA2_FLAG_TE5: DMA2 Channel5 transfer error flag.
659   *
660   * @note
661   *    Clearing the Global flag (DMAy_FLAG_GLx) results in clearing all other flags
662   *    relative to the same channel (Transfer Complete, Half-transfer Complete and
663   *    Transfer Error flags: DMAy_FLAG_TCx, DMAy_FLAG_HTx and DMAy_FLAG_TEx).
664   *
665   * @retval None
666   */
667 void DMA_ClearFlag(uint32_t DMAy_FLAG)
668 {
669   /* Check the parameters */
670   assert_param(IS_DMA_CLEAR_FLAG(DMAy_FLAG));
671
672 /* Calculate the used DMAy */
673   if ((DMAy_FLAG & FLAG_Mask) != (uint32_t)RESET)
674   {
675     /* Clear the selected DMAy flags */
676     DMA2->IFCR = DMAy_FLAG;
677   }
678   else
679   {
680     /* Clear the selected DMAy flags */
681     DMA1->IFCR = DMAy_FLAG;
682   }
683 }
684
685 /**
686   * @brief  Checks whether the specified DMAy Channelx interrupt has occurred or not.
687   * @param  DMAy_IT: specifies the DMAy interrupt source to check. 
688   *   This parameter can be one of the following values:
689   *     @arg DMA1_IT_GL1: DMA1 Channel1 global interrupt.
690   *     @arg DMA1_IT_TC1: DMA1 Channel1 transfer complete interrupt.
691   *     @arg DMA1_IT_HT1: DMA1 Channel1 half transfer interrupt.
692   *     @arg DMA1_IT_TE1: DMA1 Channel1 transfer error interrupt.
693   *     @arg DMA1_IT_GL2: DMA1 Channel2 global interrupt.
694   *     @arg DMA1_IT_TC2: DMA1 Channel2 transfer complete interrupt.
695   *     @arg DMA1_IT_HT2: DMA1 Channel2 half transfer interrupt.
696   *     @arg DMA1_IT_TE2: DMA1 Channel2 transfer error interrupt.
697   *     @arg DMA1_IT_GL3: DMA1 Channel3 global interrupt.
698   *     @arg DMA1_IT_TC3: DMA1 Channel3 transfer complete interrupt.
699   *     @arg DMA1_IT_HT3: DMA1 Channel3 half transfer interrupt.
700   *     @arg DMA1_IT_TE3: DMA1 Channel3 transfer error interrupt.
701   *     @arg DMA1_IT_GL4: DMA1 Channel4 global interrupt.
702   *     @arg DMA1_IT_TC4: DMA1 Channel4 transfer complete interrupt.
703   *     @arg DMA1_IT_HT4: DMA1 Channel4 half transfer interrupt.
704   *     @arg DMA1_IT_TE4: DMA1 Channel4 transfer error interrupt.
705   *     @arg DMA1_IT_GL5: DMA1 Channel5 global interrupt.
706   *     @arg DMA1_IT_TC5: DMA1 Channel5 transfer complete interrupt.
707   *     @arg DMA1_IT_HT5: DMA1 Channel5 half transfer interrupt.
708   *     @arg DMA1_IT_TE5: DMA1 Channel5 transfer error interrupt.
709   *     @arg DMA1_IT_GL6: DMA1 Channel6 global interrupt.
710   *     @arg DMA1_IT_TC6: DMA1 Channel6 transfer complete interrupt.
711   *     @arg DMA1_IT_HT6: DMA1 Channel6 half transfer interrupt.
712   *     @arg DMA1_IT_TE6: DMA1 Channel6 transfer error interrupt.
713   *     @arg DMA1_IT_GL7: DMA1 Channel7 global interrupt.
714   *     @arg DMA1_IT_TC7: DMA1 Channel7 transfer complete interrupt.
715   *     @arg DMA1_IT_HT7: DMA1 Channel7 half transfer interrupt.
716   *     @arg DMA1_IT_TE7: DMA1 Channel7 transfer error interrupt.
717   *     @arg DMA2_IT_GL1: DMA2 Channel1 global interrupt.
718   *     @arg DMA2_IT_TC1: DMA2 Channel1 transfer complete interrupt.
719   *     @arg DMA2_IT_HT1: DMA2 Channel1 half transfer interrupt.
720   *     @arg DMA2_IT_TE1: DMA2 Channel1 transfer error interrupt.
721   *     @arg DMA2_IT_GL2: DMA2 Channel2 global interrupt.
722   *     @arg DMA2_IT_TC2: DMA2 Channel2 transfer complete interrupt.
723   *     @arg DMA2_IT_HT2: DMA2 Channel2 half transfer interrupt.
724   *     @arg DMA2_IT_TE2: DMA2 Channel2 transfer error interrupt.
725   *     @arg DMA2_IT_GL3: DMA2 Channel3 global interrupt.
726   *     @arg DMA2_IT_TC3: DMA2 Channel3 transfer complete interrupt.
727   *     @arg DMA2_IT_HT3: DMA2 Channel3 half transfer interrupt.
728   *     @arg DMA2_IT_TE3: DMA2 Channel3 transfer error interrupt.
729   *     @arg DMA2_IT_GL4: DMA2 Channel4 global interrupt.
730   *     @arg DMA2_IT_TC4: DMA2 Channel4 transfer complete interrupt.
731   *     @arg DMA2_IT_HT4: DMA2 Channel4 half transfer interrupt.
732   *     @arg DMA2_IT_TE4: DMA2 Channel4 transfer error interrupt.
733   *     @arg DMA2_IT_GL5: DMA2 Channel5 global interrupt.
734   *     @arg DMA2_IT_TC5: DMA2 Channel5 transfer complete interrupt.
735   *     @arg DMA2_IT_HT5: DMA2 Channel5 half transfer interrupt.
736   *     @arg DMA2_IT_TE5: DMA2 Channel5 transfer error interrupt.
737   *     
738   * @note
739   *    The Global interrupt (DMAy_FLAG_GLx) is set whenever any of the other 
740   *    interrupts relative to the same channel is set (Transfer Complete, 
741   *    Half-transfer Complete or Transfer Error interrupts: DMAy_IT_TCx, 
742   *    DMAy_IT_HTx or DMAy_IT_TEx). 
743   *      
744   * @retval The new state of DMAy_IT (SET or RESET).
745   */
746 ITStatus DMA_GetITStatus(uint32_t DMAy_IT)
747 {
748   ITStatus bitstatus = RESET;
749   uint32_t tmpreg = 0;
750
751   /* Check the parameters */
752   assert_param(IS_DMA_GET_IT(DMAy_IT));
753
754   /* Calculate the used DMA */
755   if ((DMAy_IT & FLAG_Mask) != (uint32_t)RESET)
756   {
757     /* Get DMA2 ISR register value */
758     tmpreg = DMA2->ISR;
759   }
760   else
761   {
762     /* Get DMA1 ISR register value */
763     tmpreg = DMA1->ISR;
764   }
765
766   /* Check the status of the specified DMAy interrupt */
767   if ((tmpreg & DMAy_IT) != (uint32_t)RESET)
768   {
769     /* DMAy_IT is set */
770     bitstatus = SET;
771   }
772   else
773   {
774     /* DMAy_IT is reset */
775     bitstatus = RESET;
776   }
777   /* Return the DMAy_IT status */
778   return  bitstatus;
779 }
780
781 /**
782   * @brief  Clears the DMAy Channelx's interrupt pending bits.
783   * @param  DMAy_IT: specifies the DMAy interrupt pending bit to clear.
784   *   This parameter can be any combination (for the same DMA) of the following values:
785   *     @arg DMA1_IT_GL1: DMA1 Channel1 global interrupt.
786   *     @arg DMA1_IT_TC1: DMA1 Channel1 transfer complete interrupt.
787   *     @arg DMA1_IT_HT1: DMA1 Channel1 half transfer interrupt.
788   *     @arg DMA1_IT_TE1: DMA1 Channel1 transfer error interrupt.
789   *     @arg DMA1_IT_GL2: DMA1 Channel2 global interrupt.
790   *     @arg DMA1_IT_TC2: DMA1 Channel2 transfer complete interrupt.
791   *     @arg DMA1_IT_HT2: DMA1 Channel2 half transfer interrupt.
792   *     @arg DMA1_IT_TE2: DMA1 Channel2 transfer error interrupt.
793   *     @arg DMA1_IT_GL3: DMA1 Channel3 global interrupt.
794   *     @arg DMA1_IT_TC3: DMA1 Channel3 transfer complete interrupt.
795   *     @arg DMA1_IT_HT3: DMA1 Channel3 half transfer interrupt.
796   *     @arg DMA1_IT_TE3: DMA1 Channel3 transfer error interrupt.
797   *     @arg DMA1_IT_GL4: DMA1 Channel4 global interrupt.
798   *     @arg DMA1_IT_TC4: DMA1 Channel4 transfer complete interrupt.
799   *     @arg DMA1_IT_HT4: DMA1 Channel4 half transfer interrupt.
800   *     @arg DMA1_IT_TE4: DMA1 Channel4 transfer error interrupt.
801   *     @arg DMA1_IT_GL5: DMA1 Channel5 global interrupt.
802   *     @arg DMA1_IT_TC5: DMA1 Channel5 transfer complete interrupt.
803   *     @arg DMA1_IT_HT5: DMA1 Channel5 half transfer interrupt.
804   *     @arg DMA1_IT_TE5: DMA1 Channel5 transfer error interrupt.
805   *     @arg DMA1_IT_GL6: DMA1 Channel6 global interrupt.
806   *     @arg DMA1_IT_TC6: DMA1 Channel6 transfer complete interrupt.
807   *     @arg DMA1_IT_HT6: DMA1 Channel6 half transfer interrupt.
808   *     @arg DMA1_IT_TE6: DMA1 Channel6 transfer error interrupt.
809   *     @arg DMA1_IT_GL7: DMA1 Channel7 global interrupt.
810   *     @arg DMA1_IT_TC7: DMA1 Channel7 transfer complete interrupt.
811   *     @arg DMA1_IT_HT7: DMA1 Channel7 half transfer interrupt.
812   *     @arg DMA1_IT_TE7: DMA1 Channel7 transfer error interrupt.
813   *     @arg DMA2_IT_GL1: DMA2 Channel1 global interrupt.
814   *     @arg DMA2_IT_TC1: DMA2 Channel1 transfer complete interrupt.
815   *     @arg DMA2_IT_HT1: DMA2 Channel1 half transfer interrupt.
816   *     @arg DMA2_IT_TE1: DMA2 Channel1 transfer error interrupt.
817   *     @arg DMA2_IT_GL2: DMA2 Channel2 global interrupt.
818   *     @arg DMA2_IT_TC2: DMA2 Channel2 transfer complete interrupt.
819   *     @arg DMA2_IT_HT2: DMA2 Channel2 half transfer interrupt.
820   *     @arg DMA2_IT_TE2: DMA2 Channel2 transfer error interrupt.
821   *     @arg DMA2_IT_GL3: DMA2 Channel3 global interrupt.
822   *     @arg DMA2_IT_TC3: DMA2 Channel3 transfer complete interrupt.
823   *     @arg DMA2_IT_HT3: DMA2 Channel3 half transfer interrupt.
824   *     @arg DMA2_IT_TE3: DMA2 Channel3 transfer error interrupt.
825   *     @arg DMA2_IT_GL4: DMA2 Channel4 global interrupt.
826   *     @arg DMA2_IT_TC4: DMA2 Channel4 transfer complete interrupt.
827   *     @arg DMA2_IT_HT4: DMA2 Channel4 half transfer interrupt.
828   *     @arg DMA2_IT_TE4: DMA2 Channel4 transfer error interrupt.
829   *     @arg DMA2_IT_GL5: DMA2 Channel5 global interrupt.
830   *     @arg DMA2_IT_TC5: DMA2 Channel5 transfer complete interrupt.
831   *     @arg DMA2_IT_HT5: DMA2 Channel5 half transfer interrupt.
832   *     @arg DMA2_IT_TE5: DMA2 Channel5 transfer error interrupt.
833   *     
834   * @note
835   *    Clearing the Global interrupt (DMAy_IT_GLx) results in clearing all other 
836   *    interrupts relative to the same channel (Transfer Complete, Half-transfer 
837   *    Complete and Transfer Error interrupts: DMAy_IT_TCx, DMAy_IT_HTx and 
838   *    DMAy_IT_TEx).  
839   *        
840   * @retval None
841   */
842 void DMA_ClearITPendingBit(uint32_t DMAy_IT)
843 {
844   /* Check the parameters */
845   assert_param(IS_DMA_CLEAR_IT(DMAy_IT));
846   
847   /* Calculate the used DMAy */
848   if ((DMAy_IT & FLAG_Mask) != (uint32_t)RESET)
849   {
850     /* Clear the selected DMAy interrupt pending bits */
851     DMA2->IFCR = DMAy_IT;
852   }
853   else
854   {
855     /* Clear the selected DMAy interrupt pending bits */
856     DMA1->IFCR = DMAy_IT;
857   }
858 }
859
860 /**
861   * @}
862   */
863
864 /**
865   * @}
866   */
867
868 /**
869   * @}
870   */
871
872 /**
873   * @}
874   */
875
876 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/