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