mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Committer:
shaoziyang
Date:
Sat Sep 13 14:25:46 2014 +0000
Revision:
323:9e901b0a5aa1
Parent:
237:f3da66175598
test with CLOCK_SETUP = 0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 237:f3da66175598 1 /**
mbed_official 237:f3da66175598 2 ******************************************************************************
mbed_official 237:f3da66175598 3 * @file stm32f3xx_hal_dma.c
mbed_official 237:f3da66175598 4 * @author MCD Application Team
mbed_official 237:f3da66175598 5 * @version V1.0.1
mbed_official 237:f3da66175598 6 * @date 18-June-2014
mbed_official 237:f3da66175598 7 * @brief DMA HAL module driver.
mbed_official 237:f3da66175598 8 *
mbed_official 237:f3da66175598 9 * This file provides firmware functions to manage the following
mbed_official 237:f3da66175598 10 * functionalities of the Direct Memory Access (DMA) peripheral:
mbed_official 237:f3da66175598 11 * + Initialization and de-initialization functions
mbed_official 237:f3da66175598 12 * + IO operation functions
mbed_official 237:f3da66175598 13 * + Peripheral State and errors functions
mbed_official 237:f3da66175598 14 @verbatim
mbed_official 237:f3da66175598 15 ==============================================================================
mbed_official 237:f3da66175598 16 ##### How to use this driver #####
mbed_official 237:f3da66175598 17 ==============================================================================
mbed_official 237:f3da66175598 18 [..]
mbed_official 237:f3da66175598 19 (#) Enable and configure the peripheral to be connected to the DMA Channel
mbed_official 237:f3da66175598 20 (except for internal SRAM / FLASH memories: no initialization is
mbed_official 237:f3da66175598 21 necessary) please refer to Reference manual for connection between peripherals
mbed_official 237:f3da66175598 22 and DMA requests .
mbed_official 237:f3da66175598 23
mbed_official 237:f3da66175598 24 (#) For a given Channel, program the required configuration through the following parameters:
mbed_official 237:f3da66175598 25 Transfer Direction, Source and Destination data formats,
mbed_official 237:f3da66175598 26 Circular, Normal or peripheral flow control mode, Channel Priority level,
mbed_official 237:f3da66175598 27 Source and Destination Increment mode, FIFO mode and its Threshold (if needed),
mbed_official 237:f3da66175598 28 Burst mode for Source and/or Destination (if needed) using HAL_DMA_Init() function.
mbed_official 237:f3da66175598 29
mbed_official 237:f3da66175598 30 *** Polling mode IO operation ***
mbed_official 237:f3da66175598 31 =================================
mbed_official 237:f3da66175598 32 [..]
mbed_official 237:f3da66175598 33 (+) Use HAL_DMA_Start() to start DMA transfer after the configuration of Source
mbed_official 237:f3da66175598 34 address and destination address and the Length of data to be transferred
mbed_official 237:f3da66175598 35 (+) Use HAL_DMA_PollForTransfer() to poll for the end of current transfer, in this
mbed_official 237:f3da66175598 36 case a fixed Timeout can be configured by User depending from his application.
mbed_official 237:f3da66175598 37
mbed_official 237:f3da66175598 38 *** Interrupt mode IO operation ***
mbed_official 237:f3da66175598 39 ===================================
mbed_official 237:f3da66175598 40 [..]
mbed_official 237:f3da66175598 41 (+) Configure the DMA interrupt priority using HAL_NVIC_SetPriority()
mbed_official 237:f3da66175598 42 (+) Enable the DMA IRQ handler using HAL_NVIC_EnableIRQ()
mbed_official 237:f3da66175598 43 (+) Use HAL_DMA_Start_IT() to start DMA transfer after the configuration of
mbed_official 237:f3da66175598 44 Source address and destination address and the Length of data to be transferred. In this
mbed_official 237:f3da66175598 45 case the DMA interrupt is configured
mbed_official 237:f3da66175598 46 (+) Use HAL_DMA_IRQHandler() called under DMA_IRQHandler() Interrupt subroutine
mbed_official 237:f3da66175598 47 (+) At the end of data transfer HAL_DMA_IRQHandler() function is executed and user can
mbed_official 237:f3da66175598 48 add his own function by customization of function pointer XferCpltCallback and
mbed_official 237:f3da66175598 49 XferErrorCallback (i.e a member of DMA handle structure).
mbed_official 237:f3da66175598 50
mbed_official 237:f3da66175598 51 (#) Use HAL_DMA_GetState() function to return the DMA state and HAL_DMA_GetError() in case of error
mbed_official 237:f3da66175598 52 detection.
mbed_official 237:f3da66175598 53
mbed_official 237:f3da66175598 54 (#) Use HAL_DMA_Abort() function to abort the current transfer
mbed_official 237:f3da66175598 55
mbed_official 237:f3da66175598 56 -@- In Memory-to-Memory transfer mode, Circular mode is not allowed.
mbed_official 237:f3da66175598 57
mbed_official 237:f3da66175598 58 *** DMA HAL driver macros list ***
mbed_official 237:f3da66175598 59 =============================================
mbed_official 237:f3da66175598 60 [..]
mbed_official 237:f3da66175598 61 Below the list of most used macros in DMA HAL driver.
mbed_official 237:f3da66175598 62
mbed_official 237:f3da66175598 63 (+) __HAL_DMA_ENABLE: Enable the specified DMA Channel.
mbed_official 237:f3da66175598 64 (+) __HAL_DMA_DISABLE: Disable the specified DMA Channel.
mbed_official 237:f3da66175598 65 (+) __HAL_DMA_GET_FLAG: Get the DMA Channel pending flags.
mbed_official 237:f3da66175598 66 (+) __HAL_DMA_CLEAR_FLAG: Clear the DMA Channel pending flags.
mbed_official 237:f3da66175598 67 (+) __HAL_DMA_ENABLE_IT: Enable the specified DMA Channel interrupts.
mbed_official 237:f3da66175598 68 (+) __HAL_DMA_DISABLE_IT: Disable the specified DMA Channel interrupts.
mbed_official 237:f3da66175598 69 (+) __HAL_DMA_IT_STATUS: Check whether the specified DMA Channel interrupt has occurred or not.
mbed_official 237:f3da66175598 70
mbed_official 237:f3da66175598 71 [..]
mbed_official 237:f3da66175598 72 (@) You can refer to the DMA HAL driver header file for more useful macros
mbed_official 237:f3da66175598 73
mbed_official 237:f3da66175598 74 @endverbatim
mbed_official 237:f3da66175598 75 ******************************************************************************
mbed_official 237:f3da66175598 76 * @attention
mbed_official 237:f3da66175598 77 *
mbed_official 237:f3da66175598 78 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 237:f3da66175598 79 *
mbed_official 237:f3da66175598 80 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 237:f3da66175598 81 * are permitted provided that the following conditions are met:
mbed_official 237:f3da66175598 82 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 237:f3da66175598 83 * this list of conditions and the following disclaimer.
mbed_official 237:f3da66175598 84 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 237:f3da66175598 85 * this list of conditions and the following disclaimer in the documentation
mbed_official 237:f3da66175598 86 * and/or other materials provided with the distribution.
mbed_official 237:f3da66175598 87 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 237:f3da66175598 88 * may be used to endorse or promote products derived from this software
mbed_official 237:f3da66175598 89 * without specific prior written permission.
mbed_official 237:f3da66175598 90 *
mbed_official 237:f3da66175598 91 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 237:f3da66175598 92 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 237:f3da66175598 93 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 237:f3da66175598 94 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 237:f3da66175598 95 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 237:f3da66175598 96 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 237:f3da66175598 97 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 237:f3da66175598 98 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 237:f3da66175598 99 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 237:f3da66175598 100 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 237:f3da66175598 101 *
mbed_official 237:f3da66175598 102 ******************************************************************************
mbed_official 237:f3da66175598 103 */
mbed_official 237:f3da66175598 104
mbed_official 237:f3da66175598 105 /* Includes ------------------------------------------------------------------*/
mbed_official 237:f3da66175598 106 #include "stm32f3xx_hal.h"
mbed_official 237:f3da66175598 107
mbed_official 237:f3da66175598 108 /** @addtogroup STM32F3xx_HAL_Driver
mbed_official 237:f3da66175598 109 * @{
mbed_official 237:f3da66175598 110 */
mbed_official 237:f3da66175598 111
mbed_official 237:f3da66175598 112 /** @defgroup DMA
mbed_official 237:f3da66175598 113 * @brief DMA HAL module driver
mbed_official 237:f3da66175598 114 * @{
mbed_official 237:f3da66175598 115 */
mbed_official 237:f3da66175598 116
mbed_official 237:f3da66175598 117 #ifdef HAL_DMA_MODULE_ENABLED
mbed_official 237:f3da66175598 118
mbed_official 237:f3da66175598 119 /* Private typedef -----------------------------------------------------------*/
mbed_official 237:f3da66175598 120 /* Private define ------------------------------------------------------------*/
mbed_official 237:f3da66175598 121 #define HAL_TIMEOUT_DMA_ABORT ((uint32_t)1000) /* 1s */
mbed_official 237:f3da66175598 122 /* Private macro -------------------------------------------------------------*/
mbed_official 237:f3da66175598 123 /* Private variables ---------------------------------------------------------*/
mbed_official 237:f3da66175598 124 /* Private function prototypes -----------------------------------------------*/
mbed_official 237:f3da66175598 125 static void DMA_SetConfig(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength);
mbed_official 237:f3da66175598 126
mbed_official 237:f3da66175598 127 /* Private functions ---------------------------------------------------------*/
mbed_official 237:f3da66175598 128
mbed_official 237:f3da66175598 129 /** @defgroup DMA_Private_Functions
mbed_official 237:f3da66175598 130 * @{
mbed_official 237:f3da66175598 131 */
mbed_official 237:f3da66175598 132
mbed_official 237:f3da66175598 133 /** @defgroup DMA_Group1 Initialization and de-initialization functions
mbed_official 237:f3da66175598 134 * @brief Initialization and de-initialization functions
mbed_official 237:f3da66175598 135 *
mbed_official 237:f3da66175598 136 @verbatim
mbed_official 237:f3da66175598 137 ===============================================================================
mbed_official 237:f3da66175598 138 ##### Initialization and de-initialization functions #####
mbed_official 237:f3da66175598 139 ===============================================================================
mbed_official 237:f3da66175598 140 [..]
mbed_official 237:f3da66175598 141 This section provides functions allowing to initialize the DMA Channel source
mbed_official 237:f3da66175598 142 and destination addresses, incrementation and data sizes, transfer direction,
mbed_official 237:f3da66175598 143 circular/normal mode selection, memory-to-memory mode selection and Channel priority value.
mbed_official 237:f3da66175598 144 [..]
mbed_official 237:f3da66175598 145 The HAL_DMA_Init() function follows the DMA configuration procedures as described in
mbed_official 237:f3da66175598 146 reference manual.
mbed_official 237:f3da66175598 147
mbed_official 237:f3da66175598 148 @endverbatim
mbed_official 237:f3da66175598 149 * @{
mbed_official 237:f3da66175598 150 */
mbed_official 237:f3da66175598 151
mbed_official 237:f3da66175598 152 /**
mbed_official 237:f3da66175598 153 * @brief Initializes the DMA according to the specified
mbed_official 237:f3da66175598 154 * parameters in the DMA_InitTypeDef and create the associated handle.
mbed_official 237:f3da66175598 155 * @param hdma: Pointer to a DMA_HandleTypeDef structure that contains
mbed_official 237:f3da66175598 156 * the configuration information for the specified DMA Channel.
mbed_official 237:f3da66175598 157 * @retval HAL status
mbed_official 237:f3da66175598 158 */
mbed_official 237:f3da66175598 159 HAL_StatusTypeDef HAL_DMA_Init(DMA_HandleTypeDef *hdma)
mbed_official 237:f3da66175598 160 {
mbed_official 237:f3da66175598 161 uint32_t tmp = 0;
mbed_official 237:f3da66175598 162
mbed_official 237:f3da66175598 163 /* Check the DMA handle allocation */
mbed_official 237:f3da66175598 164 if(hdma == NULL)
mbed_official 237:f3da66175598 165 {
mbed_official 237:f3da66175598 166 return HAL_ERROR;
mbed_official 237:f3da66175598 167 }
mbed_official 237:f3da66175598 168
mbed_official 237:f3da66175598 169 /* Check the parameters */
mbed_official 237:f3da66175598 170 assert_param(IS_DMA_ALL_INSTANCE(hdma->Instance));
mbed_official 237:f3da66175598 171 assert_param(IS_DMA_DIRECTION(hdma->Init.Direction));
mbed_official 237:f3da66175598 172 assert_param(IS_DMA_PERIPHERAL_INC_STATE(hdma->Init.PeriphInc));
mbed_official 237:f3da66175598 173 assert_param(IS_DMA_MEMORY_INC_STATE(hdma->Init.MemInc));
mbed_official 237:f3da66175598 174 assert_param(IS_DMA_PERIPHERAL_DATA_SIZE(hdma->Init.PeriphDataAlignment));
mbed_official 237:f3da66175598 175 assert_param(IS_DMA_MEMORY_DATA_SIZE(hdma->Init.MemDataAlignment));
mbed_official 237:f3da66175598 176 assert_param(IS_DMA_MODE(hdma->Init.Mode));
mbed_official 237:f3da66175598 177 assert_param(IS_DMA_PRIORITY(hdma->Init.Priority));
mbed_official 237:f3da66175598 178
mbed_official 237:f3da66175598 179 /* Change DMA peripheral state */
mbed_official 237:f3da66175598 180 hdma->State = HAL_DMA_STATE_BUSY;
mbed_official 237:f3da66175598 181
mbed_official 237:f3da66175598 182 /* Get the CR register value */
mbed_official 237:f3da66175598 183 tmp = hdma->Instance->CCR;
mbed_official 237:f3da66175598 184
mbed_official 237:f3da66175598 185 /* Clear PL, MSIZE, PSIZE, MINC, PINC, CIRC, DIR bits */
mbed_official 237:f3da66175598 186 tmp &= ((uint32_t)~(DMA_CCR_PL | DMA_CCR_MSIZE | DMA_CCR_PSIZE | \
mbed_official 237:f3da66175598 187 DMA_CCR_MINC | DMA_CCR_PINC | DMA_CCR_CIRC | \
mbed_official 237:f3da66175598 188 DMA_CCR_DIR));
mbed_official 237:f3da66175598 189
mbed_official 237:f3da66175598 190 /* Prepare the DMA Channel configuration */
mbed_official 237:f3da66175598 191 tmp |= hdma->Init.Direction |
mbed_official 237:f3da66175598 192 hdma->Init.PeriphInc | hdma->Init.MemInc |
mbed_official 237:f3da66175598 193 hdma->Init.PeriphDataAlignment | hdma->Init.MemDataAlignment |
mbed_official 237:f3da66175598 194 hdma->Init.Mode | hdma->Init.Priority;
mbed_official 237:f3da66175598 195
mbed_official 237:f3da66175598 196 /* Write to DMA Channel CR register */
mbed_official 237:f3da66175598 197 hdma->Instance->CCR = tmp;
mbed_official 237:f3da66175598 198
mbed_official 237:f3da66175598 199 /* Initialise the error code */
mbed_official 237:f3da66175598 200 hdma->ErrorCode = HAL_DMA_ERROR_NONE;
mbed_official 237:f3da66175598 201
mbed_official 237:f3da66175598 202 /* Initialize the DMA state*/
mbed_official 237:f3da66175598 203 hdma->State = HAL_DMA_STATE_READY;
mbed_official 237:f3da66175598 204
mbed_official 237:f3da66175598 205 return HAL_OK;
mbed_official 237:f3da66175598 206 }
mbed_official 237:f3da66175598 207
mbed_official 237:f3da66175598 208 /**
mbed_official 237:f3da66175598 209 * @brief DeInitializes the DMA peripheral
mbed_official 237:f3da66175598 210 * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
mbed_official 237:f3da66175598 211 * the configuration information for the specified DMA Channel.
mbed_official 237:f3da66175598 212 * @retval HAL status
mbed_official 237:f3da66175598 213 */
mbed_official 237:f3da66175598 214 HAL_StatusTypeDef HAL_DMA_DeInit(DMA_HandleTypeDef *hdma)
mbed_official 237:f3da66175598 215 {
mbed_official 237:f3da66175598 216 /* Check the DMA handle allocation */
mbed_official 237:f3da66175598 217 if(hdma == NULL)
mbed_official 237:f3da66175598 218 {
mbed_official 237:f3da66175598 219 return HAL_ERROR;
mbed_official 237:f3da66175598 220 }
mbed_official 237:f3da66175598 221
mbed_official 237:f3da66175598 222 /* Check the parameters */
mbed_official 237:f3da66175598 223 assert_param(IS_DMA_ALL_INSTANCE(hdma->Instance));
mbed_official 237:f3da66175598 224
mbed_official 237:f3da66175598 225 /* Check the DMA peripheral state */
mbed_official 237:f3da66175598 226 if(hdma->State == HAL_DMA_STATE_BUSY)
mbed_official 237:f3da66175598 227 {
mbed_official 237:f3da66175598 228 return HAL_ERROR;
mbed_official 237:f3da66175598 229 }
mbed_official 237:f3da66175598 230
mbed_official 237:f3da66175598 231 /* Disable the selected DMA Channelx */
mbed_official 237:f3da66175598 232 __HAL_DMA_DISABLE(hdma);
mbed_official 237:f3da66175598 233
mbed_official 237:f3da66175598 234 /* Reset DMA Channel control register */
mbed_official 237:f3da66175598 235 hdma->Instance->CCR = 0;
mbed_official 237:f3da66175598 236
mbed_official 237:f3da66175598 237 /* Reset DMA Channel Number of Data to Transfer register */
mbed_official 237:f3da66175598 238 hdma->Instance->CNDTR = 0;
mbed_official 237:f3da66175598 239
mbed_official 237:f3da66175598 240 /* Reset DMA Channel peripheral address register */
mbed_official 237:f3da66175598 241 hdma->Instance->CPAR = 0;
mbed_official 237:f3da66175598 242
mbed_official 237:f3da66175598 243 /* Reset DMA Channel memory address register */
mbed_official 237:f3da66175598 244 hdma->Instance->CMAR = 0;
mbed_official 237:f3da66175598 245
mbed_official 237:f3da66175598 246 /* Clear all flags */
mbed_official 237:f3da66175598 247 __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_TC_FLAG_INDEX(hdma));
mbed_official 237:f3da66175598 248 __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_TE_FLAG_INDEX(hdma));
mbed_official 237:f3da66175598 249 __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_HT_FLAG_INDEX(hdma));
mbed_official 237:f3da66175598 250
mbed_official 237:f3da66175598 251 /* Initialise the error code */
mbed_official 237:f3da66175598 252 hdma->ErrorCode = HAL_DMA_ERROR_NONE;
mbed_official 237:f3da66175598 253
mbed_official 237:f3da66175598 254 /* Initialize the DMA state */
mbed_official 237:f3da66175598 255 hdma->State = HAL_DMA_STATE_RESET;
mbed_official 237:f3da66175598 256
mbed_official 237:f3da66175598 257 /* Release Lock */
mbed_official 237:f3da66175598 258 __HAL_UNLOCK(hdma);
mbed_official 237:f3da66175598 259
mbed_official 237:f3da66175598 260 return HAL_OK;
mbed_official 237:f3da66175598 261 }
mbed_official 237:f3da66175598 262
mbed_official 237:f3da66175598 263 /**
mbed_official 237:f3da66175598 264 * @}
mbed_official 237:f3da66175598 265 */
mbed_official 237:f3da66175598 266
mbed_official 237:f3da66175598 267 /** @defgroup DMA_Group2 I/O operation functions
mbed_official 237:f3da66175598 268 * @brief I/O operation functions
mbed_official 237:f3da66175598 269 *
mbed_official 237:f3da66175598 270 @verbatim
mbed_official 237:f3da66175598 271 ===============================================================================
mbed_official 237:f3da66175598 272 ##### IO operation functions #####
mbed_official 237:f3da66175598 273 ===============================================================================
mbed_official 237:f3da66175598 274 [..] This section provides functions allowing to:
mbed_official 237:f3da66175598 275 (+) Configure the source, destination address and data length and Start DMA transfer
mbed_official 237:f3da66175598 276 (+) Configure the source, destination address and data length and
mbed_official 237:f3da66175598 277 Start DMA transfer with interrupt
mbed_official 237:f3da66175598 278 (+) Abort DMA transfer
mbed_official 237:f3da66175598 279 (+) Poll for transfer complete
mbed_official 237:f3da66175598 280 (+) Handle DMA interrupt request
mbed_official 237:f3da66175598 281
mbed_official 237:f3da66175598 282 @endverbatim
mbed_official 237:f3da66175598 283 * @{
mbed_official 237:f3da66175598 284 */
mbed_official 237:f3da66175598 285
mbed_official 237:f3da66175598 286 /**
mbed_official 237:f3da66175598 287 * @brief Starts the DMA Transfer.
mbed_official 237:f3da66175598 288 * @param hdma : pointer to a DMA_HandleTypeDef structure that contains
mbed_official 237:f3da66175598 289 * the configuration information for the specified DMA Channel.
mbed_official 237:f3da66175598 290 * @param SrcAddress: The source memory Buffer address
mbed_official 237:f3da66175598 291 * @param DstAddress: The destination memory Buffer address
mbed_official 237:f3da66175598 292 * @param DataLength: The length of data to be transferred from source to destination
mbed_official 237:f3da66175598 293 * @retval HAL status
mbed_official 237:f3da66175598 294 */
mbed_official 237:f3da66175598 295 HAL_StatusTypeDef HAL_DMA_Start(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
mbed_official 237:f3da66175598 296 {
mbed_official 237:f3da66175598 297 /* Process locked */
mbed_official 237:f3da66175598 298 __HAL_LOCK(hdma);
mbed_official 237:f3da66175598 299
mbed_official 237:f3da66175598 300 /* Change DMA peripheral state */
mbed_official 237:f3da66175598 301 hdma->State = HAL_DMA_STATE_BUSY;
mbed_official 237:f3da66175598 302
mbed_official 237:f3da66175598 303 /* Check the parameters */
mbed_official 237:f3da66175598 304 assert_param(IS_DMA_BUFFER_SIZE(DataLength));
mbed_official 237:f3da66175598 305
mbed_official 237:f3da66175598 306 /* Disable the peripheral */
mbed_official 237:f3da66175598 307 __HAL_DMA_DISABLE(hdma);
mbed_official 237:f3da66175598 308
mbed_official 237:f3da66175598 309 /* Configure the source, destination address and the data length */
mbed_official 237:f3da66175598 310 DMA_SetConfig(hdma, SrcAddress, DstAddress, DataLength);
mbed_official 237:f3da66175598 311
mbed_official 237:f3da66175598 312 /* Enable the Peripheral */
mbed_official 237:f3da66175598 313 __HAL_DMA_ENABLE(hdma);
mbed_official 237:f3da66175598 314
mbed_official 237:f3da66175598 315 return HAL_OK;
mbed_official 237:f3da66175598 316 }
mbed_official 237:f3da66175598 317
mbed_official 237:f3da66175598 318 /**
mbed_official 237:f3da66175598 319 * @brief Start the DMA Transfer with interrupt enabled.
mbed_official 237:f3da66175598 320 * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
mbed_official 237:f3da66175598 321 * the configuration information for the specified DMA Channel.
mbed_official 237:f3da66175598 322 * @param SrcAddress: The source memory Buffer address
mbed_official 237:f3da66175598 323 * @param DstAddress: The destination memory Buffer address
mbed_official 237:f3da66175598 324 * @param DataLength: The length of data to be transferred from source to destination
mbed_official 237:f3da66175598 325 * @retval HAL status
mbed_official 237:f3da66175598 326 */
mbed_official 237:f3da66175598 327 HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
mbed_official 237:f3da66175598 328 {
mbed_official 237:f3da66175598 329 /* Process locked */
mbed_official 237:f3da66175598 330 __HAL_LOCK(hdma);
mbed_official 237:f3da66175598 331
mbed_official 237:f3da66175598 332 /* Change DMA peripheral state */
mbed_official 237:f3da66175598 333 hdma->State = HAL_DMA_STATE_BUSY;
mbed_official 237:f3da66175598 334
mbed_official 237:f3da66175598 335 /* Check the parameters */
mbed_official 237:f3da66175598 336 assert_param(IS_DMA_BUFFER_SIZE(DataLength));
mbed_official 237:f3da66175598 337
mbed_official 237:f3da66175598 338 /* Disable the peripheral */
mbed_official 237:f3da66175598 339 __HAL_DMA_DISABLE(hdma);
mbed_official 237:f3da66175598 340
mbed_official 237:f3da66175598 341 /* Configure the source, destination address and the data length */
mbed_official 237:f3da66175598 342 DMA_SetConfig(hdma, SrcAddress, DstAddress, DataLength);
mbed_official 237:f3da66175598 343
mbed_official 237:f3da66175598 344 /* Enable the transfer complete interrupt */
mbed_official 237:f3da66175598 345 __HAL_DMA_ENABLE_IT(hdma, DMA_IT_TC);
mbed_official 237:f3da66175598 346
mbed_official 237:f3da66175598 347 /* Enable the Half transfer complete interrupt */
mbed_official 237:f3da66175598 348 __HAL_DMA_ENABLE_IT(hdma, DMA_IT_HT);
mbed_official 237:f3da66175598 349
mbed_official 237:f3da66175598 350 /* Enable the transfer Error interrupt */
mbed_official 237:f3da66175598 351 __HAL_DMA_ENABLE_IT(hdma, DMA_IT_TE);
mbed_official 237:f3da66175598 352
mbed_official 237:f3da66175598 353 /* Enable the Peripheral */
mbed_official 237:f3da66175598 354 __HAL_DMA_ENABLE(hdma);
mbed_official 237:f3da66175598 355
mbed_official 237:f3da66175598 356 return HAL_OK;
mbed_official 237:f3da66175598 357 }
mbed_official 237:f3da66175598 358
mbed_official 237:f3da66175598 359 /**
mbed_official 237:f3da66175598 360 * @brief Aborts the DMA Transfer.
mbed_official 237:f3da66175598 361 * @param hdma : pointer to a DMA_HandleTypeDef structure that contains
mbed_official 237:f3da66175598 362 * the configuration information for the specified DMA Channel.
mbed_official 237:f3da66175598 363 *
mbed_official 237:f3da66175598 364 * @note After disabling a DMA Channel, a check for wait until the DMA Channel is
mbed_official 237:f3da66175598 365 * effectively disabled is added. If a Channel is disabled
mbed_official 237:f3da66175598 366 * while a data transfer is ongoing, the current data will be transferred
mbed_official 237:f3da66175598 367 * and the Channel will be effectively disabled only after the transfer of
mbed_official 237:f3da66175598 368 * this single data is finished.
mbed_official 237:f3da66175598 369 * @retval HAL status
mbed_official 237:f3da66175598 370 */
mbed_official 237:f3da66175598 371 HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
mbed_official 237:f3da66175598 372 {
mbed_official 237:f3da66175598 373 uint32_t tickstart = 0x00;
mbed_official 237:f3da66175598 374
mbed_official 237:f3da66175598 375 /* Disable the channel */
mbed_official 237:f3da66175598 376 __HAL_DMA_DISABLE(hdma);
mbed_official 237:f3da66175598 377
mbed_official 237:f3da66175598 378 /* Get timeout */
mbed_official 237:f3da66175598 379 tickstart = HAL_GetTick();
mbed_official 237:f3da66175598 380
mbed_official 237:f3da66175598 381 /* Check if the DMA Channel is effectively disabled */
mbed_official 237:f3da66175598 382 while((hdma->Instance->CCR & DMA_CCR_EN) != 0)
mbed_official 237:f3da66175598 383 {
mbed_official 237:f3da66175598 384 /* Check for the Timeout */
mbed_official 237:f3da66175598 385 if((HAL_GetTick()-tickstart) > HAL_TIMEOUT_DMA_ABORT)
mbed_official 237:f3da66175598 386 {
mbed_official 237:f3da66175598 387 /* Update error code */
mbed_official 237:f3da66175598 388 hdma->ErrorCode |= HAL_DMA_ERROR_TIMEOUT;
mbed_official 237:f3da66175598 389
mbed_official 237:f3da66175598 390 /* Change the DMA state */
mbed_official 237:f3da66175598 391 hdma->State = HAL_DMA_STATE_TIMEOUT;
mbed_official 237:f3da66175598 392
mbed_official 237:f3da66175598 393 /* Process Unlocked */
mbed_official 237:f3da66175598 394 __HAL_UNLOCK(hdma);
mbed_official 237:f3da66175598 395
mbed_official 237:f3da66175598 396 return HAL_TIMEOUT;
mbed_official 237:f3da66175598 397 }
mbed_official 237:f3da66175598 398 }
mbed_official 237:f3da66175598 399 /* Change the DMA state*/
mbed_official 237:f3da66175598 400 hdma->State = HAL_DMA_STATE_READY;
mbed_official 237:f3da66175598 401
mbed_official 237:f3da66175598 402 /* Process Unlocked */
mbed_official 237:f3da66175598 403 __HAL_UNLOCK(hdma);
mbed_official 237:f3da66175598 404
mbed_official 237:f3da66175598 405 return HAL_OK;
mbed_official 237:f3da66175598 406 }
mbed_official 237:f3da66175598 407
mbed_official 237:f3da66175598 408 /**
mbed_official 237:f3da66175598 409 * @brief Polling for transfer complete.
mbed_official 237:f3da66175598 410 * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
mbed_official 237:f3da66175598 411 * the configuration information for the specified DMA Channel.
mbed_official 237:f3da66175598 412 * @param CompleteLevel: Specifies the DMA level complete.
mbed_official 237:f3da66175598 413 * @param Timeout: Timeout duration.
mbed_official 237:f3da66175598 414 * @retval HAL status
mbed_official 237:f3da66175598 415 */
mbed_official 237:f3da66175598 416 HAL_StatusTypeDef HAL_DMA_PollForTransfer(DMA_HandleTypeDef *hdma, uint32_t CompleteLevel, uint32_t Timeout)
mbed_official 237:f3da66175598 417 {
mbed_official 237:f3da66175598 418 uint32_t temp;
mbed_official 237:f3da66175598 419 uint32_t tickstart = 0x00;
mbed_official 237:f3da66175598 420
mbed_official 237:f3da66175598 421 /* Get the level transfer complete flag */
mbed_official 237:f3da66175598 422 if(CompleteLevel == HAL_DMA_FULL_TRANSFER)
mbed_official 237:f3da66175598 423 {
mbed_official 237:f3da66175598 424 /* Transfer Complete flag */
mbed_official 237:f3da66175598 425 temp = __HAL_DMA_GET_TC_FLAG_INDEX(hdma);
mbed_official 237:f3da66175598 426 }
mbed_official 237:f3da66175598 427 else
mbed_official 237:f3da66175598 428 {
mbed_official 237:f3da66175598 429 /* Half Transfer Complete flag */
mbed_official 237:f3da66175598 430 temp = __HAL_DMA_GET_HT_FLAG_INDEX(hdma);
mbed_official 237:f3da66175598 431 }
mbed_official 237:f3da66175598 432
mbed_official 237:f3da66175598 433 /* Get timeout */
mbed_official 237:f3da66175598 434 tickstart = HAL_GetTick();
mbed_official 237:f3da66175598 435
mbed_official 237:f3da66175598 436 while(__HAL_DMA_GET_FLAG(hdma, temp) == RESET)
mbed_official 237:f3da66175598 437 {
mbed_official 237:f3da66175598 438 if((__HAL_DMA_GET_FLAG(hdma, __HAL_DMA_GET_TE_FLAG_INDEX(hdma)) != RESET))
mbed_official 237:f3da66175598 439 {
mbed_official 237:f3da66175598 440 /* Clear the transfer error flags */
mbed_official 237:f3da66175598 441 __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_TE_FLAG_INDEX(hdma));
mbed_official 237:f3da66175598 442
mbed_official 237:f3da66175598 443 /* Change the DMA state */
mbed_official 237:f3da66175598 444 hdma->State= HAL_DMA_STATE_ERROR;
mbed_official 237:f3da66175598 445
mbed_official 237:f3da66175598 446 /* Process Unlocked */
mbed_official 237:f3da66175598 447 __HAL_UNLOCK(hdma);
mbed_official 237:f3da66175598 448
mbed_official 237:f3da66175598 449 return HAL_ERROR;
mbed_official 237:f3da66175598 450 }
mbed_official 237:f3da66175598 451 /* Check for the Timeout */
mbed_official 237:f3da66175598 452 if(Timeout != HAL_MAX_DELAY)
mbed_official 237:f3da66175598 453 {
mbed_official 237:f3da66175598 454 if((Timeout == 0) || ((HAL_GetTick()-tickstart) > Timeout))
mbed_official 237:f3da66175598 455 {
mbed_official 237:f3da66175598 456 /* Update error code */
mbed_official 237:f3da66175598 457 hdma->ErrorCode |= HAL_DMA_ERROR_TIMEOUT;
mbed_official 237:f3da66175598 458
mbed_official 237:f3da66175598 459 /* Change the DMA state */
mbed_official 237:f3da66175598 460 hdma->State = HAL_DMA_STATE_TIMEOUT;
mbed_official 237:f3da66175598 461
mbed_official 237:f3da66175598 462 /* Process Unlocked */
mbed_official 237:f3da66175598 463 __HAL_UNLOCK(hdma);
mbed_official 237:f3da66175598 464
mbed_official 237:f3da66175598 465 return HAL_TIMEOUT;
mbed_official 237:f3da66175598 466 }
mbed_official 237:f3da66175598 467 }
mbed_official 237:f3da66175598 468 }
mbed_official 237:f3da66175598 469
mbed_official 237:f3da66175598 470 if(CompleteLevel == HAL_DMA_FULL_TRANSFER)
mbed_official 237:f3da66175598 471 {
mbed_official 237:f3da66175598 472 /* Clear the transfer complete flag */
mbed_official 237:f3da66175598 473 __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_TC_FLAG_INDEX(hdma));
mbed_official 237:f3da66175598 474
mbed_official 237:f3da66175598 475 /* The selected Channelx EN bit is cleared (DMA is disabled and
mbed_official 237:f3da66175598 476 all transfers are complete) */
mbed_official 237:f3da66175598 477 hdma->State = HAL_DMA_STATE_READY;
mbed_official 237:f3da66175598 478
mbed_official 237:f3da66175598 479 }
mbed_official 237:f3da66175598 480 else
mbed_official 237:f3da66175598 481 {
mbed_official 237:f3da66175598 482 /* Clear the half transfer complete flag */
mbed_official 237:f3da66175598 483 __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_HT_FLAG_INDEX(hdma));
mbed_official 237:f3da66175598 484
mbed_official 237:f3da66175598 485 hdma->State = HAL_DMA_STATE_READY_HALF;
mbed_official 237:f3da66175598 486 }
mbed_official 237:f3da66175598 487
mbed_official 237:f3da66175598 488 /* Process unlocked */
mbed_official 237:f3da66175598 489 __HAL_UNLOCK(hdma);
mbed_official 237:f3da66175598 490
mbed_official 237:f3da66175598 491 return HAL_OK;
mbed_official 237:f3da66175598 492 }
mbed_official 237:f3da66175598 493
mbed_official 237:f3da66175598 494 /**
mbed_official 237:f3da66175598 495 * @brief Handles DMA interrupt request.
mbed_official 237:f3da66175598 496 * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
mbed_official 237:f3da66175598 497 * the configuration information for the specified DMA Channel.
mbed_official 237:f3da66175598 498 * @retval None
mbed_official 237:f3da66175598 499 */
mbed_official 237:f3da66175598 500 void HAL_DMA_IRQHandler(DMA_HandleTypeDef *hdma)
mbed_official 237:f3da66175598 501 {
mbed_official 237:f3da66175598 502 /* Transfer Error Interrupt management ***************************************/
mbed_official 237:f3da66175598 503 if(__HAL_DMA_GET_FLAG(hdma, __HAL_DMA_GET_TE_FLAG_INDEX(hdma)) != RESET)
mbed_official 237:f3da66175598 504 {
mbed_official 237:f3da66175598 505 if(__HAL_DMA_GET_IT_SOURCE(hdma, DMA_IT_TE) != RESET)
mbed_official 237:f3da66175598 506 {
mbed_official 237:f3da66175598 507 /* Disable the transfer error interrupt */
mbed_official 237:f3da66175598 508 __HAL_DMA_DISABLE_IT(hdma, DMA_IT_TE);
mbed_official 237:f3da66175598 509
mbed_official 237:f3da66175598 510 /* Clear the transfer error flag */
mbed_official 237:f3da66175598 511 __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_TE_FLAG_INDEX(hdma));
mbed_official 237:f3da66175598 512
mbed_official 237:f3da66175598 513 /* Update error code */
mbed_official 237:f3da66175598 514 hdma->ErrorCode |= HAL_DMA_ERROR_TE;
mbed_official 237:f3da66175598 515
mbed_official 237:f3da66175598 516 /* Change the DMA state */
mbed_official 237:f3da66175598 517 hdma->State = HAL_DMA_STATE_ERROR;
mbed_official 237:f3da66175598 518
mbed_official 237:f3da66175598 519 /* Process Unlocked */
mbed_official 237:f3da66175598 520 __HAL_UNLOCK(hdma);
mbed_official 237:f3da66175598 521
mbed_official 237:f3da66175598 522 if (hdma->XferErrorCallback != NULL)
mbed_official 237:f3da66175598 523 {
mbed_official 237:f3da66175598 524 /* Transfer error callback */
mbed_official 237:f3da66175598 525 hdma->XferErrorCallback(hdma);
mbed_official 237:f3da66175598 526 }
mbed_official 237:f3da66175598 527 }
mbed_official 237:f3da66175598 528 }
mbed_official 237:f3da66175598 529
mbed_official 237:f3da66175598 530 /* Half Transfer Complete Interrupt management ******************************/
mbed_official 237:f3da66175598 531 if(__HAL_DMA_GET_FLAG(hdma, __HAL_DMA_GET_HT_FLAG_INDEX(hdma)) != RESET)
mbed_official 237:f3da66175598 532 {
mbed_official 237:f3da66175598 533 if(__HAL_DMA_GET_IT_SOURCE(hdma, DMA_IT_HT) != RESET)
mbed_official 237:f3da66175598 534 {
mbed_official 237:f3da66175598 535 /* Disable the half transfer interrupt if the DMA mode is not CIRCULAR */
mbed_official 237:f3da66175598 536 if((hdma->Instance->CCR & DMA_CCR_CIRC) == 0)
mbed_official 237:f3da66175598 537 {
mbed_official 237:f3da66175598 538 /* Disable the half transfer interrupt */
mbed_official 237:f3da66175598 539 __HAL_DMA_DISABLE_IT(hdma, DMA_IT_HT);
mbed_official 237:f3da66175598 540 }
mbed_official 237:f3da66175598 541 /* Clear the half transfer complete flag */
mbed_official 237:f3da66175598 542 __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_HT_FLAG_INDEX(hdma));
mbed_official 237:f3da66175598 543
mbed_official 237:f3da66175598 544 /* Change DMA peripheral state */
mbed_official 237:f3da66175598 545 hdma->State = HAL_DMA_STATE_READY_HALF;
mbed_official 237:f3da66175598 546
mbed_official 237:f3da66175598 547 if(hdma->XferHalfCpltCallback != NULL)
mbed_official 237:f3da66175598 548 {
mbed_official 237:f3da66175598 549 /* Half transfer callback */
mbed_official 237:f3da66175598 550 hdma->XferHalfCpltCallback(hdma);
mbed_official 237:f3da66175598 551 }
mbed_official 237:f3da66175598 552 }
mbed_official 237:f3da66175598 553 }
mbed_official 237:f3da66175598 554
mbed_official 237:f3da66175598 555 /* Transfer Complete Interrupt management ***********************************/
mbed_official 237:f3da66175598 556 if(__HAL_DMA_GET_FLAG(hdma, __HAL_DMA_GET_TC_FLAG_INDEX(hdma)) != RESET)
mbed_official 237:f3da66175598 557 {
mbed_official 237:f3da66175598 558 if(__HAL_DMA_GET_IT_SOURCE(hdma, DMA_IT_TC) != RESET)
mbed_official 237:f3da66175598 559 {
mbed_official 237:f3da66175598 560 if((hdma->Instance->CCR & DMA_CCR_CIRC) == 0)
mbed_official 237:f3da66175598 561 {
mbed_official 237:f3da66175598 562 /* Disable the transfer complete interrupt */
mbed_official 237:f3da66175598 563 __HAL_DMA_DISABLE_IT(hdma, DMA_IT_TC);
mbed_official 237:f3da66175598 564 }
mbed_official 237:f3da66175598 565 /* Clear the transfer complete flag */
mbed_official 237:f3da66175598 566 __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_TC_FLAG_INDEX(hdma));
mbed_official 237:f3da66175598 567
mbed_official 237:f3da66175598 568 /* Update error code */
mbed_official 237:f3da66175598 569 hdma->ErrorCode |= HAL_DMA_ERROR_NONE;
mbed_official 237:f3da66175598 570
mbed_official 237:f3da66175598 571 /* Change the DMA state */
mbed_official 237:f3da66175598 572 hdma->State = HAL_DMA_STATE_READY;
mbed_official 237:f3da66175598 573
mbed_official 237:f3da66175598 574 /* Process Unlocked */
mbed_official 237:f3da66175598 575 __HAL_UNLOCK(hdma);
mbed_official 237:f3da66175598 576
mbed_official 237:f3da66175598 577 if(hdma->XferCpltCallback != NULL)
mbed_official 237:f3da66175598 578 {
mbed_official 237:f3da66175598 579 /* Transfer complete callback */
mbed_official 237:f3da66175598 580 hdma->XferCpltCallback(hdma);
mbed_official 237:f3da66175598 581 }
mbed_official 237:f3da66175598 582 }
mbed_official 237:f3da66175598 583 }
mbed_official 237:f3da66175598 584 }
mbed_official 237:f3da66175598 585
mbed_official 237:f3da66175598 586 /**
mbed_official 237:f3da66175598 587 * @}
mbed_official 237:f3da66175598 588 */
mbed_official 237:f3da66175598 589
mbed_official 237:f3da66175598 590 /** @defgroup DMA_Group3 Peripheral State functions
mbed_official 237:f3da66175598 591 * @brief Peripheral State functions
mbed_official 237:f3da66175598 592 *
mbed_official 237:f3da66175598 593 @verbatim
mbed_official 237:f3da66175598 594 ===============================================================================
mbed_official 237:f3da66175598 595 ##### State and Errors functions #####
mbed_official 237:f3da66175598 596 ===============================================================================
mbed_official 237:f3da66175598 597 [..]
mbed_official 237:f3da66175598 598 This subsection provides functions allowing to
mbed_official 237:f3da66175598 599 (+) Check the DMA state
mbed_official 237:f3da66175598 600 (+) Get error code
mbed_official 237:f3da66175598 601
mbed_official 237:f3da66175598 602 @endverbatim
mbed_official 237:f3da66175598 603 * @{
mbed_official 237:f3da66175598 604 */
mbed_official 237:f3da66175598 605
mbed_official 237:f3da66175598 606 /**
mbed_official 237:f3da66175598 607 * @brief Returns the DMA state.
mbed_official 237:f3da66175598 608 * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
mbed_official 237:f3da66175598 609 * the configuration information for the specified DMA Channel.
mbed_official 237:f3da66175598 610 * @retval HAL state
mbed_official 237:f3da66175598 611 */
mbed_official 237:f3da66175598 612 HAL_DMA_StateTypeDef HAL_DMA_GetState(DMA_HandleTypeDef *hdma)
mbed_official 237:f3da66175598 613 {
mbed_official 237:f3da66175598 614 return hdma->State;
mbed_official 237:f3da66175598 615 }
mbed_official 237:f3da66175598 616
mbed_official 237:f3da66175598 617 /**
mbed_official 237:f3da66175598 618 * @brief Return the DMA error code
mbed_official 237:f3da66175598 619 * @param hdma : pointer to a DMA_HandleTypeDef structure that contains
mbed_official 237:f3da66175598 620 * the configuration information for the specified DMA Channel.
mbed_official 237:f3da66175598 621 * @retval DMA Error Code
mbed_official 237:f3da66175598 622 */
mbed_official 237:f3da66175598 623 uint32_t HAL_DMA_GetError(DMA_HandleTypeDef *hdma)
mbed_official 237:f3da66175598 624 {
mbed_official 237:f3da66175598 625 return hdma->ErrorCode;
mbed_official 237:f3da66175598 626 }
mbed_official 237:f3da66175598 627
mbed_official 237:f3da66175598 628 /**
mbed_official 237:f3da66175598 629 * @}
mbed_official 237:f3da66175598 630 */
mbed_official 237:f3da66175598 631
mbed_official 237:f3da66175598 632 /**
mbed_official 237:f3da66175598 633 * @brief Sets the DMA Transfer parameter.
mbed_official 237:f3da66175598 634 * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
mbed_official 237:f3da66175598 635 * the configuration information for the specified DMA Channel.
mbed_official 237:f3da66175598 636 * @param SrcAddress: The source memory Buffer address
mbed_official 237:f3da66175598 637 * @param DstAddress: The destination memory Buffer address
mbed_official 237:f3da66175598 638 * @param DataLength: The length of data to be transferred from source to destination
mbed_official 237:f3da66175598 639 * @retval HAL status
mbed_official 237:f3da66175598 640 */
mbed_official 237:f3da66175598 641 static void DMA_SetConfig(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
mbed_official 237:f3da66175598 642 {
mbed_official 237:f3da66175598 643 /* Configure DMA Channel data length */
mbed_official 237:f3da66175598 644 hdma->Instance->CNDTR = DataLength;
mbed_official 237:f3da66175598 645
mbed_official 237:f3da66175598 646 /* Peripheral to Memory */
mbed_official 237:f3da66175598 647 if((hdma->Init.Direction) == DMA_MEMORY_TO_PERIPH)
mbed_official 237:f3da66175598 648 {
mbed_official 237:f3da66175598 649 /* Configure DMA Channel destination address */
mbed_official 237:f3da66175598 650 hdma->Instance->CPAR = DstAddress;
mbed_official 237:f3da66175598 651
mbed_official 237:f3da66175598 652 /* Configure DMA Channel source address */
mbed_official 237:f3da66175598 653 hdma->Instance->CMAR = SrcAddress;
mbed_official 237:f3da66175598 654 }
mbed_official 237:f3da66175598 655 /* Memory to Peripheral */
mbed_official 237:f3da66175598 656 else
mbed_official 237:f3da66175598 657 {
mbed_official 237:f3da66175598 658 /* Configure DMA Channel source address */
mbed_official 237:f3da66175598 659 hdma->Instance->CPAR = SrcAddress;
mbed_official 237:f3da66175598 660
mbed_official 237:f3da66175598 661 /* Configure DMA Channel destination address */
mbed_official 237:f3da66175598 662 hdma->Instance->CMAR = DstAddress;
mbed_official 237:f3da66175598 663 }
mbed_official 237:f3da66175598 664 }
mbed_official 237:f3da66175598 665
mbed_official 237:f3da66175598 666 /**
mbed_official 237:f3da66175598 667 * @}
mbed_official 237:f3da66175598 668 */
mbed_official 237:f3da66175598 669
mbed_official 237:f3da66175598 670 #endif /* HAL_DMA_MODULE_ENABLED */
mbed_official 237:f3da66175598 671 /**
mbed_official 237:f3da66175598 672 * @}
mbed_official 237:f3da66175598 673 */
mbed_official 237:f3da66175598 674
mbed_official 237:f3da66175598 675 /**
mbed_official 237:f3da66175598 676 * @}
mbed_official 237:f3da66175598 677 */
mbed_official 237:f3da66175598 678
mbed_official 237:f3da66175598 679 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/