mbed library sources

Dependents:   bare

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Wed Mar 19 10:15:22 2014 +0000
Revision:
125:23cc3068a9e4
Synchronized with git revision ace35dfba3748c7cdc102eb38ec6b9e1067c3252

Full URL: https://github.com/mbedmicro/mbed/commit/ace35dfba3748c7cdc102eb38ec6b9e1067c3252/

[NUCLEO_F302R8] Add cmsis and hal files + change F401RE clock to 84MHz

Who changed what in which revision?

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