annotate Common/Drivers/STM32F4xx_HAL_DRIVER_v120/Src/stm32f4xx_hal_dma_ex.c @ 38:5f11787b4f42

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