inport from local
Dependents: Hobbyking_Cheetah_0511
targets/TARGET_STM/TARGET_STM32F4/device/stm32f4xx_hal_dma_ex.c@0:85b3fd62ea1a, 2020-03-16 (annotated)
- Committer:
- NYX
- Date:
- Mon Mar 16 06:35:48 2020 +0000
- Revision:
- 0:85b3fd62ea1a
reinport to mbed;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
NYX | 0:85b3fd62ea1a | 1 | /** |
NYX | 0:85b3fd62ea1a | 2 | ****************************************************************************** |
NYX | 0:85b3fd62ea1a | 3 | * @file stm32f4xx_hal_dma_ex.c |
NYX | 0:85b3fd62ea1a | 4 | * @author MCD Application Team |
NYX | 0:85b3fd62ea1a | 5 | * @version V1.7.1 |
NYX | 0:85b3fd62ea1a | 6 | * @date 14-April-2017 |
NYX | 0:85b3fd62ea1a | 7 | * @brief DMA Extension HAL module driver |
NYX | 0:85b3fd62ea1a | 8 | * This file provides firmware functions to manage the following |
NYX | 0:85b3fd62ea1a | 9 | * functionalities of the DMA Extension peripheral: |
NYX | 0:85b3fd62ea1a | 10 | * + Extended features functions |
NYX | 0:85b3fd62ea1a | 11 | * |
NYX | 0:85b3fd62ea1a | 12 | @verbatim |
NYX | 0:85b3fd62ea1a | 13 | ============================================================================== |
NYX | 0:85b3fd62ea1a | 14 | ##### How to use this driver ##### |
NYX | 0:85b3fd62ea1a | 15 | ============================================================================== |
NYX | 0:85b3fd62ea1a | 16 | [..] |
NYX | 0:85b3fd62ea1a | 17 | The DMA Extension HAL driver can be used as follows: |
NYX | 0:85b3fd62ea1a | 18 | (#) Start a multi buffer transfer using the HAL_DMA_MultiBufferStart() function |
NYX | 0:85b3fd62ea1a | 19 | for polling mode or HAL_DMA_MultiBufferStart_IT() for interrupt mode. |
NYX | 0:85b3fd62ea1a | 20 | |
NYX | 0:85b3fd62ea1a | 21 | -@- In Memory-to-Memory transfer mode, Multi (Double) Buffer mode is not allowed. |
NYX | 0:85b3fd62ea1a | 22 | -@- When Multi (Double) Buffer mode is enabled the, transfer is circular by default. |
NYX | 0:85b3fd62ea1a | 23 | -@- In Multi (Double) buffer mode, it is possible to update the base address for |
NYX | 0:85b3fd62ea1a | 24 | the AHB memory port on the fly (DMA_SxM0AR or DMA_SxM1AR) when the stream is enabled. |
NYX | 0:85b3fd62ea1a | 25 | |
NYX | 0:85b3fd62ea1a | 26 | @endverbatim |
NYX | 0:85b3fd62ea1a | 27 | ****************************************************************************** |
NYX | 0:85b3fd62ea1a | 28 | * @attention |
NYX | 0:85b3fd62ea1a | 29 | * |
NYX | 0:85b3fd62ea1a | 30 | * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> |
NYX | 0:85b3fd62ea1a | 31 | * |
NYX | 0:85b3fd62ea1a | 32 | * Redistribution and use in source and binary forms, with or without modification, |
NYX | 0:85b3fd62ea1a | 33 | * are permitted provided that the following conditions are met: |
NYX | 0:85b3fd62ea1a | 34 | * 1. Redistributions of source code must retain the above copyright notice, |
NYX | 0:85b3fd62ea1a | 35 | * this list of conditions and the following disclaimer. |
NYX | 0:85b3fd62ea1a | 36 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
NYX | 0:85b3fd62ea1a | 37 | * this list of conditions and the following disclaimer in the documentation |
NYX | 0:85b3fd62ea1a | 38 | * and/or other materials provided with the distribution. |
NYX | 0:85b3fd62ea1a | 39 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
NYX | 0:85b3fd62ea1a | 40 | * may be used to endorse or promote products derived from this software |
NYX | 0:85b3fd62ea1a | 41 | * without specific prior written permission. |
NYX | 0:85b3fd62ea1a | 42 | * |
NYX | 0:85b3fd62ea1a | 43 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
NYX | 0:85b3fd62ea1a | 44 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
NYX | 0:85b3fd62ea1a | 45 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
NYX | 0:85b3fd62ea1a | 46 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
NYX | 0:85b3fd62ea1a | 47 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
NYX | 0:85b3fd62ea1a | 48 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
NYX | 0:85b3fd62ea1a | 49 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
NYX | 0:85b3fd62ea1a | 50 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
NYX | 0:85b3fd62ea1a | 51 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
NYX | 0:85b3fd62ea1a | 52 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
NYX | 0:85b3fd62ea1a | 53 | * |
NYX | 0:85b3fd62ea1a | 54 | ****************************************************************************** |
NYX | 0:85b3fd62ea1a | 55 | */ |
NYX | 0:85b3fd62ea1a | 56 | |
NYX | 0:85b3fd62ea1a | 57 | /* Includes ------------------------------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 58 | #include "stm32f4xx_hal.h" |
NYX | 0:85b3fd62ea1a | 59 | |
NYX | 0:85b3fd62ea1a | 60 | /** @addtogroup STM32F4xx_HAL_Driver |
NYX | 0:85b3fd62ea1a | 61 | * @{ |
NYX | 0:85b3fd62ea1a | 62 | */ |
NYX | 0:85b3fd62ea1a | 63 | |
NYX | 0:85b3fd62ea1a | 64 | /** @defgroup DMAEx DMAEx |
NYX | 0:85b3fd62ea1a | 65 | * @brief DMA Extended HAL module driver |
NYX | 0:85b3fd62ea1a | 66 | * @{ |
NYX | 0:85b3fd62ea1a | 67 | */ |
NYX | 0:85b3fd62ea1a | 68 | |
NYX | 0:85b3fd62ea1a | 69 | #ifdef HAL_DMA_MODULE_ENABLED |
NYX | 0:85b3fd62ea1a | 70 | |
NYX | 0:85b3fd62ea1a | 71 | /* Private types -------------------------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 72 | /* Private variables ---------------------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 73 | /* Private Constants ---------------------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 74 | /* Private macros ------------------------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 75 | /* Private functions ---------------------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 76 | /** @addtogroup DMAEx_Private_Functions |
NYX | 0:85b3fd62ea1a | 77 | * @{ |
NYX | 0:85b3fd62ea1a | 78 | */ |
NYX | 0:85b3fd62ea1a | 79 | static void DMA_MultiBufferSetConfig(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength); |
NYX | 0:85b3fd62ea1a | 80 | /** |
NYX | 0:85b3fd62ea1a | 81 | * @} |
NYX | 0:85b3fd62ea1a | 82 | */ |
NYX | 0:85b3fd62ea1a | 83 | |
NYX | 0:85b3fd62ea1a | 84 | /* Exported functions ---------------------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 85 | |
NYX | 0:85b3fd62ea1a | 86 | /** @addtogroup DMAEx_Exported_Functions |
NYX | 0:85b3fd62ea1a | 87 | * @{ |
NYX | 0:85b3fd62ea1a | 88 | */ |
NYX | 0:85b3fd62ea1a | 89 | |
NYX | 0:85b3fd62ea1a | 90 | |
NYX | 0:85b3fd62ea1a | 91 | /** @addtogroup DMAEx_Exported_Functions_Group1 |
NYX | 0:85b3fd62ea1a | 92 | * |
NYX | 0:85b3fd62ea1a | 93 | @verbatim |
NYX | 0:85b3fd62ea1a | 94 | =============================================================================== |
NYX | 0:85b3fd62ea1a | 95 | ##### Extended features functions ##### |
NYX | 0:85b3fd62ea1a | 96 | =============================================================================== |
NYX | 0:85b3fd62ea1a | 97 | [..] This section provides functions allowing to: |
NYX | 0:85b3fd62ea1a | 98 | (+) Configure the source, destination address and data length and |
NYX | 0:85b3fd62ea1a | 99 | Start MultiBuffer DMA transfer |
NYX | 0:85b3fd62ea1a | 100 | (+) Configure the source, destination address and data length and |
NYX | 0:85b3fd62ea1a | 101 | Start MultiBuffer DMA transfer with interrupt |
NYX | 0:85b3fd62ea1a | 102 | (+) Change on the fly the memory0 or memory1 address. |
NYX | 0:85b3fd62ea1a | 103 | |
NYX | 0:85b3fd62ea1a | 104 | @endverbatim |
NYX | 0:85b3fd62ea1a | 105 | * @{ |
NYX | 0:85b3fd62ea1a | 106 | */ |
NYX | 0:85b3fd62ea1a | 107 | |
NYX | 0:85b3fd62ea1a | 108 | |
NYX | 0:85b3fd62ea1a | 109 | /** |
NYX | 0:85b3fd62ea1a | 110 | * @brief Starts the multi_buffer DMA Transfer. |
NYX | 0:85b3fd62ea1a | 111 | * @param hdma : pointer to a DMA_HandleTypeDef structure that contains |
NYX | 0:85b3fd62ea1a | 112 | * the configuration information for the specified DMA Stream. |
NYX | 0:85b3fd62ea1a | 113 | * @param SrcAddress: The source memory Buffer address |
NYX | 0:85b3fd62ea1a | 114 | * @param DstAddress: The destination memory Buffer address |
NYX | 0:85b3fd62ea1a | 115 | * @param SecondMemAddress: The second memory Buffer address in case of multi buffer Transfer |
NYX | 0:85b3fd62ea1a | 116 | * @param DataLength: The length of data to be transferred from source to destination |
NYX | 0:85b3fd62ea1a | 117 | * @retval HAL status |
NYX | 0:85b3fd62ea1a | 118 | */ |
NYX | 0:85b3fd62ea1a | 119 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength) |
NYX | 0:85b3fd62ea1a | 120 | { |
NYX | 0:85b3fd62ea1a | 121 | HAL_StatusTypeDef status = HAL_OK; |
NYX | 0:85b3fd62ea1a | 122 | |
NYX | 0:85b3fd62ea1a | 123 | /* Check the parameters */ |
NYX | 0:85b3fd62ea1a | 124 | assert_param(IS_DMA_BUFFER_SIZE(DataLength)); |
NYX | 0:85b3fd62ea1a | 125 | |
NYX | 0:85b3fd62ea1a | 126 | /* Memory-to-memory transfer not supported in double buffering mode */ |
NYX | 0:85b3fd62ea1a | 127 | if (hdma->Init.Direction == DMA_MEMORY_TO_MEMORY) |
NYX | 0:85b3fd62ea1a | 128 | { |
NYX | 0:85b3fd62ea1a | 129 | hdma->ErrorCode = HAL_DMA_ERROR_NOT_SUPPORTED; |
NYX | 0:85b3fd62ea1a | 130 | status = HAL_ERROR; |
NYX | 0:85b3fd62ea1a | 131 | } |
NYX | 0:85b3fd62ea1a | 132 | else |
NYX | 0:85b3fd62ea1a | 133 | { |
NYX | 0:85b3fd62ea1a | 134 | /* Process Locked */ |
NYX | 0:85b3fd62ea1a | 135 | __HAL_LOCK(hdma); |
NYX | 0:85b3fd62ea1a | 136 | |
NYX | 0:85b3fd62ea1a | 137 | if(HAL_DMA_STATE_READY == hdma->State) |
NYX | 0:85b3fd62ea1a | 138 | { |
NYX | 0:85b3fd62ea1a | 139 | /* Change DMA peripheral state */ |
NYX | 0:85b3fd62ea1a | 140 | hdma->State = HAL_DMA_STATE_BUSY; |
NYX | 0:85b3fd62ea1a | 141 | |
NYX | 0:85b3fd62ea1a | 142 | /* Enable the double buffer mode */ |
NYX | 0:85b3fd62ea1a | 143 | hdma->Instance->CR |= (uint32_t)DMA_SxCR_DBM; |
NYX | 0:85b3fd62ea1a | 144 | |
NYX | 0:85b3fd62ea1a | 145 | /* Configure DMA Stream destination address */ |
NYX | 0:85b3fd62ea1a | 146 | hdma->Instance->M1AR = SecondMemAddress; |
NYX | 0:85b3fd62ea1a | 147 | |
NYX | 0:85b3fd62ea1a | 148 | /* Configure the source, destination address and the data length */ |
NYX | 0:85b3fd62ea1a | 149 | DMA_MultiBufferSetConfig(hdma, SrcAddress, DstAddress, DataLength); |
NYX | 0:85b3fd62ea1a | 150 | |
NYX | 0:85b3fd62ea1a | 151 | /* Enable the peripheral */ |
NYX | 0:85b3fd62ea1a | 152 | __HAL_DMA_ENABLE(hdma); |
NYX | 0:85b3fd62ea1a | 153 | } |
NYX | 0:85b3fd62ea1a | 154 | else |
NYX | 0:85b3fd62ea1a | 155 | { |
NYX | 0:85b3fd62ea1a | 156 | /* Return error status */ |
NYX | 0:85b3fd62ea1a | 157 | status = HAL_BUSY; |
NYX | 0:85b3fd62ea1a | 158 | } |
NYX | 0:85b3fd62ea1a | 159 | } |
NYX | 0:85b3fd62ea1a | 160 | return status; |
NYX | 0:85b3fd62ea1a | 161 | } |
NYX | 0:85b3fd62ea1a | 162 | |
NYX | 0:85b3fd62ea1a | 163 | /** |
NYX | 0:85b3fd62ea1a | 164 | * @brief Starts the multi_buffer DMA Transfer with interrupt enabled. |
NYX | 0:85b3fd62ea1a | 165 | * @param hdma: pointer to a DMA_HandleTypeDef structure that contains |
NYX | 0:85b3fd62ea1a | 166 | * the configuration information for the specified DMA Stream. |
NYX | 0:85b3fd62ea1a | 167 | * @param SrcAddress: The source memory Buffer address |
NYX | 0:85b3fd62ea1a | 168 | * @param DstAddress: The destination memory Buffer address |
NYX | 0:85b3fd62ea1a | 169 | * @param SecondMemAddress: The second memory Buffer address in case of multi buffer Transfer |
NYX | 0:85b3fd62ea1a | 170 | * @param DataLength: The length of data to be transferred from source to destination |
NYX | 0:85b3fd62ea1a | 171 | * @retval HAL status |
NYX | 0:85b3fd62ea1a | 172 | */ |
NYX | 0:85b3fd62ea1a | 173 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength) |
NYX | 0:85b3fd62ea1a | 174 | { |
NYX | 0:85b3fd62ea1a | 175 | HAL_StatusTypeDef status = HAL_OK; |
NYX | 0:85b3fd62ea1a | 176 | |
NYX | 0:85b3fd62ea1a | 177 | /* Check the parameters */ |
NYX | 0:85b3fd62ea1a | 178 | assert_param(IS_DMA_BUFFER_SIZE(DataLength)); |
NYX | 0:85b3fd62ea1a | 179 | |
NYX | 0:85b3fd62ea1a | 180 | /* Memory-to-memory transfer not supported in double buffering mode */ |
NYX | 0:85b3fd62ea1a | 181 | if (hdma->Init.Direction == DMA_MEMORY_TO_MEMORY) |
NYX | 0:85b3fd62ea1a | 182 | { |
NYX | 0:85b3fd62ea1a | 183 | hdma->ErrorCode = HAL_DMA_ERROR_NOT_SUPPORTED; |
NYX | 0:85b3fd62ea1a | 184 | return HAL_ERROR; |
NYX | 0:85b3fd62ea1a | 185 | } |
NYX | 0:85b3fd62ea1a | 186 | |
NYX | 0:85b3fd62ea1a | 187 | /* Check callback functions */ |
NYX | 0:85b3fd62ea1a | 188 | if ((NULL == hdma->XferCpltCallback) || (NULL == hdma->XferM1CpltCallback) || (NULL == hdma->XferErrorCallback)) |
NYX | 0:85b3fd62ea1a | 189 | { |
NYX | 0:85b3fd62ea1a | 190 | hdma->ErrorCode = HAL_DMA_ERROR_PARAM; |
NYX | 0:85b3fd62ea1a | 191 | return HAL_ERROR; |
NYX | 0:85b3fd62ea1a | 192 | } |
NYX | 0:85b3fd62ea1a | 193 | |
NYX | 0:85b3fd62ea1a | 194 | /* Process locked */ |
NYX | 0:85b3fd62ea1a | 195 | __HAL_LOCK(hdma); |
NYX | 0:85b3fd62ea1a | 196 | |
NYX | 0:85b3fd62ea1a | 197 | if(HAL_DMA_STATE_READY == hdma->State) |
NYX | 0:85b3fd62ea1a | 198 | { |
NYX | 0:85b3fd62ea1a | 199 | /* Change DMA peripheral state */ |
NYX | 0:85b3fd62ea1a | 200 | hdma->State = HAL_DMA_STATE_BUSY; |
NYX | 0:85b3fd62ea1a | 201 | |
NYX | 0:85b3fd62ea1a | 202 | /* Initialize the error code */ |
NYX | 0:85b3fd62ea1a | 203 | hdma->ErrorCode = HAL_DMA_ERROR_NONE; |
NYX | 0:85b3fd62ea1a | 204 | |
NYX | 0:85b3fd62ea1a | 205 | /* Enable the Double buffer mode */ |
NYX | 0:85b3fd62ea1a | 206 | hdma->Instance->CR |= (uint32_t)DMA_SxCR_DBM; |
NYX | 0:85b3fd62ea1a | 207 | |
NYX | 0:85b3fd62ea1a | 208 | /* Configure DMA Stream destination address */ |
NYX | 0:85b3fd62ea1a | 209 | hdma->Instance->M1AR = SecondMemAddress; |
NYX | 0:85b3fd62ea1a | 210 | |
NYX | 0:85b3fd62ea1a | 211 | /* Configure the source, destination address and the data length */ |
NYX | 0:85b3fd62ea1a | 212 | DMA_MultiBufferSetConfig(hdma, SrcAddress, DstAddress, DataLength); |
NYX | 0:85b3fd62ea1a | 213 | |
NYX | 0:85b3fd62ea1a | 214 | /* Clear all flags */ |
NYX | 0:85b3fd62ea1a | 215 | __HAL_DMA_CLEAR_FLAG (hdma, __HAL_DMA_GET_TC_FLAG_INDEX(hdma)); |
NYX | 0:85b3fd62ea1a | 216 | __HAL_DMA_CLEAR_FLAG (hdma, __HAL_DMA_GET_HT_FLAG_INDEX(hdma)); |
NYX | 0:85b3fd62ea1a | 217 | __HAL_DMA_CLEAR_FLAG (hdma, __HAL_DMA_GET_TE_FLAG_INDEX(hdma)); |
NYX | 0:85b3fd62ea1a | 218 | __HAL_DMA_CLEAR_FLAG (hdma, __HAL_DMA_GET_DME_FLAG_INDEX(hdma)); |
NYX | 0:85b3fd62ea1a | 219 | __HAL_DMA_CLEAR_FLAG (hdma, __HAL_DMA_GET_FE_FLAG_INDEX(hdma)); |
NYX | 0:85b3fd62ea1a | 220 | |
NYX | 0:85b3fd62ea1a | 221 | /* Enable Common interrupts*/ |
NYX | 0:85b3fd62ea1a | 222 | hdma->Instance->CR |= DMA_IT_TC | DMA_IT_TE | DMA_IT_DME; |
NYX | 0:85b3fd62ea1a | 223 | hdma->Instance->FCR |= DMA_IT_FE; |
NYX | 0:85b3fd62ea1a | 224 | |
NYX | 0:85b3fd62ea1a | 225 | if((hdma->XferHalfCpltCallback != NULL) || (hdma->XferM1HalfCpltCallback != NULL)) |
NYX | 0:85b3fd62ea1a | 226 | { |
NYX | 0:85b3fd62ea1a | 227 | hdma->Instance->CR |= DMA_IT_HT; |
NYX | 0:85b3fd62ea1a | 228 | } |
NYX | 0:85b3fd62ea1a | 229 | |
NYX | 0:85b3fd62ea1a | 230 | /* Enable the peripheral */ |
NYX | 0:85b3fd62ea1a | 231 | __HAL_DMA_ENABLE(hdma); |
NYX | 0:85b3fd62ea1a | 232 | } |
NYX | 0:85b3fd62ea1a | 233 | else |
NYX | 0:85b3fd62ea1a | 234 | { |
NYX | 0:85b3fd62ea1a | 235 | /* Process unlocked */ |
NYX | 0:85b3fd62ea1a | 236 | __HAL_UNLOCK(hdma); |
NYX | 0:85b3fd62ea1a | 237 | |
NYX | 0:85b3fd62ea1a | 238 | /* Return error status */ |
NYX | 0:85b3fd62ea1a | 239 | status = HAL_BUSY; |
NYX | 0:85b3fd62ea1a | 240 | } |
NYX | 0:85b3fd62ea1a | 241 | return status; |
NYX | 0:85b3fd62ea1a | 242 | } |
NYX | 0:85b3fd62ea1a | 243 | |
NYX | 0:85b3fd62ea1a | 244 | /** |
NYX | 0:85b3fd62ea1a | 245 | * @brief Change the memory0 or memory1 address on the fly. |
NYX | 0:85b3fd62ea1a | 246 | * @param hdma: pointer to a DMA_HandleTypeDef structure that contains |
NYX | 0:85b3fd62ea1a | 247 | * the configuration information for the specified DMA Stream. |
NYX | 0:85b3fd62ea1a | 248 | * @param Address: The new address |
NYX | 0:85b3fd62ea1a | 249 | * @param memory: the memory to be changed, This parameter can be one of |
NYX | 0:85b3fd62ea1a | 250 | * the following values: |
NYX | 0:85b3fd62ea1a | 251 | * MEMORY0 / |
NYX | 0:85b3fd62ea1a | 252 | * MEMORY1 |
NYX | 0:85b3fd62ea1a | 253 | * @note The MEMORY0 address can be changed only when the current transfer use |
NYX | 0:85b3fd62ea1a | 254 | * MEMORY1 and the MEMORY1 address can be changed only when the current |
NYX | 0:85b3fd62ea1a | 255 | * transfer use MEMORY0. |
NYX | 0:85b3fd62ea1a | 256 | * @retval HAL status |
NYX | 0:85b3fd62ea1a | 257 | */ |
NYX | 0:85b3fd62ea1a | 258 | HAL_StatusTypeDef HAL_DMAEx_ChangeMemory(DMA_HandleTypeDef *hdma, uint32_t Address, HAL_DMA_MemoryTypeDef memory) |
NYX | 0:85b3fd62ea1a | 259 | { |
NYX | 0:85b3fd62ea1a | 260 | if(memory == MEMORY0) |
NYX | 0:85b3fd62ea1a | 261 | { |
NYX | 0:85b3fd62ea1a | 262 | /* change the memory0 address */ |
NYX | 0:85b3fd62ea1a | 263 | hdma->Instance->M0AR = Address; |
NYX | 0:85b3fd62ea1a | 264 | } |
NYX | 0:85b3fd62ea1a | 265 | else |
NYX | 0:85b3fd62ea1a | 266 | { |
NYX | 0:85b3fd62ea1a | 267 | /* change the memory1 address */ |
NYX | 0:85b3fd62ea1a | 268 | hdma->Instance->M1AR = Address; |
NYX | 0:85b3fd62ea1a | 269 | } |
NYX | 0:85b3fd62ea1a | 270 | |
NYX | 0:85b3fd62ea1a | 271 | return HAL_OK; |
NYX | 0:85b3fd62ea1a | 272 | } |
NYX | 0:85b3fd62ea1a | 273 | |
NYX | 0:85b3fd62ea1a | 274 | /** |
NYX | 0:85b3fd62ea1a | 275 | * @} |
NYX | 0:85b3fd62ea1a | 276 | */ |
NYX | 0:85b3fd62ea1a | 277 | |
NYX | 0:85b3fd62ea1a | 278 | /** |
NYX | 0:85b3fd62ea1a | 279 | * @} |
NYX | 0:85b3fd62ea1a | 280 | */ |
NYX | 0:85b3fd62ea1a | 281 | |
NYX | 0:85b3fd62ea1a | 282 | /** @addtogroup DMAEx_Private_Functions |
NYX | 0:85b3fd62ea1a | 283 | * @{ |
NYX | 0:85b3fd62ea1a | 284 | */ |
NYX | 0:85b3fd62ea1a | 285 | |
NYX | 0:85b3fd62ea1a | 286 | /** |
NYX | 0:85b3fd62ea1a | 287 | * @brief Set the DMA Transfer parameter. |
NYX | 0:85b3fd62ea1a | 288 | * @param hdma: pointer to a DMA_HandleTypeDef structure that contains |
NYX | 0:85b3fd62ea1a | 289 | * the configuration information for the specified DMA Stream. |
NYX | 0:85b3fd62ea1a | 290 | * @param SrcAddress: The source memory Buffer address |
NYX | 0:85b3fd62ea1a | 291 | * @param DstAddress: The destination memory Buffer address |
NYX | 0:85b3fd62ea1a | 292 | * @param DataLength: The length of data to be transferred from source to destination |
NYX | 0:85b3fd62ea1a | 293 | * @retval HAL status |
NYX | 0:85b3fd62ea1a | 294 | */ |
NYX | 0:85b3fd62ea1a | 295 | static void DMA_MultiBufferSetConfig(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength) |
NYX | 0:85b3fd62ea1a | 296 | { |
NYX | 0:85b3fd62ea1a | 297 | /* Configure DMA Stream data length */ |
NYX | 0:85b3fd62ea1a | 298 | hdma->Instance->NDTR = DataLength; |
NYX | 0:85b3fd62ea1a | 299 | |
NYX | 0:85b3fd62ea1a | 300 | /* Peripheral to Memory */ |
NYX | 0:85b3fd62ea1a | 301 | if((hdma->Init.Direction) == DMA_MEMORY_TO_PERIPH) |
NYX | 0:85b3fd62ea1a | 302 | { |
NYX | 0:85b3fd62ea1a | 303 | /* Configure DMA Stream destination address */ |
NYX | 0:85b3fd62ea1a | 304 | hdma->Instance->PAR = DstAddress; |
NYX | 0:85b3fd62ea1a | 305 | |
NYX | 0:85b3fd62ea1a | 306 | /* Configure DMA Stream source address */ |
NYX | 0:85b3fd62ea1a | 307 | hdma->Instance->M0AR = SrcAddress; |
NYX | 0:85b3fd62ea1a | 308 | } |
NYX | 0:85b3fd62ea1a | 309 | /* Memory to Peripheral */ |
NYX | 0:85b3fd62ea1a | 310 | else |
NYX | 0:85b3fd62ea1a | 311 | { |
NYX | 0:85b3fd62ea1a | 312 | /* Configure DMA Stream source address */ |
NYX | 0:85b3fd62ea1a | 313 | hdma->Instance->PAR = SrcAddress; |
NYX | 0:85b3fd62ea1a | 314 | |
NYX | 0:85b3fd62ea1a | 315 | /* Configure DMA Stream destination address */ |
NYX | 0:85b3fd62ea1a | 316 | hdma->Instance->M0AR = DstAddress; |
NYX | 0:85b3fd62ea1a | 317 | } |
NYX | 0:85b3fd62ea1a | 318 | } |
NYX | 0:85b3fd62ea1a | 319 | |
NYX | 0:85b3fd62ea1a | 320 | /** |
NYX | 0:85b3fd62ea1a | 321 | * @} |
NYX | 0:85b3fd62ea1a | 322 | */ |
NYX | 0:85b3fd62ea1a | 323 | |
NYX | 0:85b3fd62ea1a | 324 | #endif /* HAL_DMA_MODULE_ENABLED */ |
NYX | 0:85b3fd62ea1a | 325 | /** |
NYX | 0:85b3fd62ea1a | 326 | * @} |
NYX | 0:85b3fd62ea1a | 327 | */ |
NYX | 0:85b3fd62ea1a | 328 | |
NYX | 0:85b3fd62ea1a | 329 | /** |
NYX | 0:85b3fd62ea1a | 330 | * @} |
NYX | 0:85b3fd62ea1a | 331 | */ |
NYX | 0:85b3fd62ea1a | 332 | |
NYX | 0:85b3fd62ea1a | 333 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |