2 ******************************************************************************
\r
3 * @file stm32l4xx_hal_dma.h
\r
4 * @author MCD Application Team
\r
5 * @brief Header file of DMA HAL module.
\r
6 ******************************************************************************
\r
9 * <h2><center>© Copyright (c) 2017 STMicroelectronics.
\r
10 * All rights reserved.</center></h2>
\r
12 * This software component is licensed by ST under BSD 3-Clause license,
\r
13 * the "License"; You may not use this file except in compliance with the
\r
14 * License. You may obtain a copy of the License at:
\r
15 * opensource.org/licenses/BSD-3-Clause
\r
17 ******************************************************************************
\r
20 /* Define to prevent recursive inclusion -------------------------------------*/
\r
21 #ifndef STM32L4xx_HAL_DMA_H
\r
22 #define STM32L4xx_HAL_DMA_H
\r
28 /* Includes ------------------------------------------------------------------*/
\r
29 #include "stm32l4xx_hal_def.h"
\r
31 /** @addtogroup STM32L4xx_HAL_Driver
\r
39 /* Exported types ------------------------------------------------------------*/
\r
40 /** @defgroup DMA_Exported_Types DMA Exported Types
\r
45 * @brief DMA Configuration Structure definition
\r
49 uint32_t Request; /*!< Specifies the request selected for the specified channel.
\r
50 This parameter can be a value of @ref DMA_request */
\r
52 uint32_t Direction; /*!< Specifies if the data will be transferred from memory to peripheral,
\r
53 from memory to memory or from peripheral to memory.
\r
54 This parameter can be a value of @ref DMA_Data_transfer_direction */
\r
56 uint32_t PeriphInc; /*!< Specifies whether the Peripheral address register should be incremented or not.
\r
57 This parameter can be a value of @ref DMA_Peripheral_incremented_mode */
\r
59 uint32_t MemInc; /*!< Specifies whether the memory address register should be incremented or not.
\r
60 This parameter can be a value of @ref DMA_Memory_incremented_mode */
\r
62 uint32_t PeriphDataAlignment; /*!< Specifies the Peripheral data width.
\r
63 This parameter can be a value of @ref DMA_Peripheral_data_size */
\r
65 uint32_t MemDataAlignment; /*!< Specifies the Memory data width.
\r
66 This parameter can be a value of @ref DMA_Memory_data_size */
\r
68 uint32_t Mode; /*!< Specifies the operation mode of the DMAy Channelx.
\r
69 This parameter can be a value of @ref DMA_mode
\r
70 @note The circular buffer mode cannot be used if the memory-to-memory
\r
71 data transfer is configured on the selected Channel */
\r
73 uint32_t Priority; /*!< Specifies the software priority for the DMAy Channelx.
\r
74 This parameter can be a value of @ref DMA_Priority_level */
\r
78 * @brief HAL DMA State structures definition
\r
82 HAL_DMA_STATE_RESET = 0x00U, /*!< DMA not yet initialized or disabled */
\r
83 HAL_DMA_STATE_READY = 0x01U, /*!< DMA initialized and ready for use */
\r
84 HAL_DMA_STATE_BUSY = 0x02U, /*!< DMA process is ongoing */
\r
85 HAL_DMA_STATE_TIMEOUT = 0x03U, /*!< DMA timeout state */
\r
86 }HAL_DMA_StateTypeDef;
\r
89 * @brief HAL DMA Error Code structure definition
\r
93 HAL_DMA_FULL_TRANSFER = 0x00U, /*!< Full transfer */
\r
94 HAL_DMA_HALF_TRANSFER = 0x01U /*!< Half Transfer */
\r
95 }HAL_DMA_LevelCompleteTypeDef;
\r
99 * @brief HAL DMA Callback ID structure definition
\r
103 HAL_DMA_XFER_CPLT_CB_ID = 0x00U, /*!< Full transfer */
\r
104 HAL_DMA_XFER_HALFCPLT_CB_ID = 0x01U, /*!< Half transfer */
\r
105 HAL_DMA_XFER_ERROR_CB_ID = 0x02U, /*!< Error */
\r
106 HAL_DMA_XFER_ABORT_CB_ID = 0x03U, /*!< Abort */
\r
107 HAL_DMA_XFER_ALL_CB_ID = 0x04U /*!< All */
\r
108 }HAL_DMA_CallbackIDTypeDef;
\r
111 * @brief DMA handle Structure definition
\r
113 typedef struct __DMA_HandleTypeDef
\r
115 DMA_Channel_TypeDef *Instance; /*!< Register base address */
\r
117 DMA_InitTypeDef Init; /*!< DMA communication parameters */
\r
119 HAL_LockTypeDef Lock; /*!< DMA locking object */
\r
121 __IO HAL_DMA_StateTypeDef State; /*!< DMA transfer state */
\r
123 void *Parent; /*!< Parent object state */
\r
125 void (* XferCpltCallback)(struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer complete callback */
\r
127 void (* XferHalfCpltCallback)(struct __DMA_HandleTypeDef * hdma); /*!< DMA Half transfer complete callback */
\r
129 void (* XferErrorCallback)(struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer error callback */
\r
131 void (* XferAbortCallback)(struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer abort callback */
\r
133 __IO uint32_t ErrorCode; /*!< DMA Error code */
\r
135 DMA_TypeDef *DmaBaseAddress; /*!< DMA Channel Base Address */
\r
137 uint32_t ChannelIndex; /*!< DMA Channel Index */
\r
139 #if defined(DMAMUX1)
\r
140 DMAMUX_Channel_TypeDef *DMAmuxChannel; /*!< Register base address */
\r
142 DMAMUX_ChannelStatus_TypeDef *DMAmuxChannelStatus; /*!< DMAMUX Channels Status Base Address */
\r
144 uint32_t DMAmuxChannelStatusMask; /*!< DMAMUX Channel Status Mask */
\r
146 DMAMUX_RequestGen_TypeDef *DMAmuxRequestGen; /*!< DMAMUX request generator Base Address */
\r
148 DMAMUX_RequestGenStatus_TypeDef *DMAmuxRequestGenStatus; /*!< DMAMUX request generator Address */
\r
150 uint32_t DMAmuxRequestGenStatusMask; /*!< DMAMUX request generator Status mask */
\r
152 #endif /* DMAMUX1 */
\r
154 }DMA_HandleTypeDef;
\r
159 /* Exported constants --------------------------------------------------------*/
\r
161 /** @defgroup DMA_Exported_Constants DMA Exported Constants
\r
165 /** @defgroup DMA_Error_Code DMA Error Code
\r
168 #define HAL_DMA_ERROR_NONE 0x00000000U /*!< No error */
\r
169 #define HAL_DMA_ERROR_TE 0x00000001U /*!< Transfer error */
\r
170 #define HAL_DMA_ERROR_NO_XFER 0x00000004U /*!< Abort requested with no Xfer ongoing */
\r
171 #define HAL_DMA_ERROR_TIMEOUT 0x00000020U /*!< Timeout error */
\r
172 #define HAL_DMA_ERROR_NOT_SUPPORTED 0x00000100U /*!< Not supported mode */
\r
173 #define HAL_DMA_ERROR_SYNC 0x00000200U /*!< DMAMUX sync overrun error */
\r
174 #define HAL_DMA_ERROR_REQGEN 0x00000400U /*!< DMAMUX request generator overrun error */
\r
180 /** @defgroup DMA_request DMA request
\r
183 #if !defined (DMAMUX1)
\r
185 #define DMA_REQUEST_0 0U
\r
186 #define DMA_REQUEST_1 1U
\r
187 #define DMA_REQUEST_2 2U
\r
188 #define DMA_REQUEST_3 3U
\r
189 #define DMA_REQUEST_4 4U
\r
190 #define DMA_REQUEST_5 5U
\r
191 #define DMA_REQUEST_6 6U
\r
192 #define DMA_REQUEST_7 7U
\r
196 #if defined(DMAMUX1)
\r
198 #define DMA_REQUEST_MEM2MEM 0U /*!< memory to memory transfer */
\r
200 #define DMA_REQUEST_GENERATOR0 1U /*!< DMAMUX1 request generator 0 */
\r
201 #define DMA_REQUEST_GENERATOR1 2U /*!< DMAMUX1 request generator 1 */
\r
202 #define DMA_REQUEST_GENERATOR2 3U /*!< DMAMUX1 request generator 2 */
\r
203 #define DMA_REQUEST_GENERATOR3 4U /*!< DMAMUX1 request generator 3 */
\r
205 #define DMA_REQUEST_ADC1 5U /*!< DMAMUX1 ADC1 request */
\r
207 #define DMA_REQUEST_DAC1_CH1 6U /*!< DMAMUX1 DAC1 CH1 request */
\r
208 #define DMA_REQUEST_DAC1_CH2 7U /*!< DMAMUX1 DAC1 CH2 request */
\r
210 #define DMA_REQUEST_TIM6_UP 8U /*!< DMAMUX1 TIM6 UP request */
\r
211 #define DMA_REQUEST_TIM7_UP 9U /*!< DMAMUX1 TIM7 UP request */
\r
213 #define DMA_REQUEST_SPI1_RX 10U /*!< DMAMUX1 SPI1 RX request */
\r
214 #define DMA_REQUEST_SPI1_TX 11U /*!< DMAMUX1 SPI1 TX request */
\r
215 #define DMA_REQUEST_SPI2_RX 12U /*!< DMAMUX1 SPI2 RX request */
\r
216 #define DMA_REQUEST_SPI2_TX 13U /*!< DMAMUX1 SPI2 TX request */
\r
217 #define DMA_REQUEST_SPI3_RX 14U /*!< DMAMUX1 SPI3 RX request */
\r
218 #define DMA_REQUEST_SPI3_TX 15U /*!< DMAMUX1 SPI3 TX request */
\r
220 #define DMA_REQUEST_I2C1_RX 16U /*!< DMAMUX1 I2C1 RX request */
\r
221 #define DMA_REQUEST_I2C1_TX 17U /*!< DMAMUX1 I2C1 TX request */
\r
222 #define DMA_REQUEST_I2C2_RX 18U /*!< DMAMUX1 I2C2 RX request */
\r
223 #define DMA_REQUEST_I2C2_TX 19U /*!< DMAMUX1 I2C2 TX request */
\r
224 #define DMA_REQUEST_I2C3_RX 20U /*!< DMAMUX1 I2C3 RX request */
\r
225 #define DMA_REQUEST_I2C3_TX 21U /*!< DMAMUX1 I2C3 TX request */
\r
226 #define DMA_REQUEST_I2C4_RX 22U /*!< DMAMUX1 I2C4 RX request */
\r
227 #define DMA_REQUEST_I2C4_TX 23U /*!< DMAMUX1 I2C4 TX request */
\r
229 #define DMA_REQUEST_USART1_RX 24U /*!< DMAMUX1 USART1 RX request */
\r
230 #define DMA_REQUEST_USART1_TX 25U /*!< DMAMUX1 USART1 TX request */
\r
231 #define DMA_REQUEST_USART2_RX 26U /*!< DMAMUX1 USART2 RX request */
\r
232 #define DMA_REQUEST_USART2_TX 27U /*!< DMAMUX1 USART2 TX request */
\r
233 #define DMA_REQUEST_USART3_RX 28U /*!< DMAMUX1 USART3 RX request */
\r
234 #define DMA_REQUEST_USART3_TX 29U /*!< DMAMUX1 USART3 TX request */
\r
236 #define DMA_REQUEST_UART4_RX 30U /*!< DMAMUX1 UART4 RX request */
\r
237 #define DMA_REQUEST_UART4_TX 31U /*!< DMAMUX1 UART4 TX request */
\r
238 #define DMA_REQUEST_UART5_RX 32U /*!< DMAMUX1 UART5 RX request */
\r
239 #define DMA_REQUEST_UART5_TX 33U /*!< DMAMUX1 UART5 TX request */
\r
241 #define DMA_REQUEST_LPUART1_RX 34U /*!< DMAMUX1 LP_UART1_RX request */
\r
242 #define DMA_REQUEST_LPUART1_TX 35U /*!< DMAMUX1 LP_UART1_RX request */
\r
244 #define DMA_REQUEST_SAI1_A 36U /*!< DMAMUX1 SAI1 A request */
\r
245 #define DMA_REQUEST_SAI1_B 37U /*!< DMAMUX1 SAI1 B request */
\r
246 #define DMA_REQUEST_SAI2_A 38U /*!< DMAMUX1 SAI2 A request */
\r
247 #define DMA_REQUEST_SAI2_B 39U /*!< DMAMUX1 SAI2 B request */
\r
249 #define DMA_REQUEST_OCTOSPI1 40U /*!< DMAMUX1 OCTOSPI1 request */
\r
250 #define DMA_REQUEST_OCTOSPI2 41U /*!< DMAMUX1 OCTOSPI2 request */
\r
252 #define DMA_REQUEST_TIM1_CH1 42U /*!< DMAMUX1 TIM1 CH1 request */
\r
253 #define DMA_REQUEST_TIM1_CH2 43U /*!< DMAMUX1 TIM1 CH2 request */
\r
254 #define DMA_REQUEST_TIM1_CH3 44U /*!< DMAMUX1 TIM1 CH3 request */
\r
255 #define DMA_REQUEST_TIM1_CH4 45U /*!< DMAMUX1 TIM1 CH4 request */
\r
256 #define DMA_REQUEST_TIM1_UP 46U /*!< DMAMUX1 TIM1 UP request */
\r
257 #define DMA_REQUEST_TIM1_TRIG 47U /*!< DMAMUX1 TIM1 TRIG request */
\r
258 #define DMA_REQUEST_TIM1_COM 48U /*!< DMAMUX1 TIM1 COM request */
\r
260 #define DMA_REQUEST_TIM8_CH1 49U /*!< DMAMUX1 TIM8 CH1 request */
\r
261 #define DMA_REQUEST_TIM8_CH2 50U /*!< DMAMUX1 TIM8 CH2 request */
\r
262 #define DMA_REQUEST_TIM8_CH3 51U /*!< DMAMUX1 TIM8 CH3 request */
\r
263 #define DMA_REQUEST_TIM8_CH4 52U /*!< DMAMUX1 TIM8 CH4 request */
\r
264 #define DMA_REQUEST_TIM8_UP 53U /*!< DMAMUX1 TIM8 UP request */
\r
265 #define DMA_REQUEST_TIM8_TRIG 54U /*!< DMAMUX1 TIM8 TRIG request */
\r
266 #define DMA_REQUEST_TIM8_COM 55U /*!< DMAMUX1 TIM8 COM request */
\r
268 #define DMA_REQUEST_TIM2_CH1 56U /*!< DMAMUX1 TIM2 CH1 request */
\r
269 #define DMA_REQUEST_TIM2_CH2 57U /*!< DMAMUX1 TIM2 CH2 request */
\r
270 #define DMA_REQUEST_TIM2_CH3 58U /*!< DMAMUX1 TIM2 CH3 request */
\r
271 #define DMA_REQUEST_TIM2_CH4 59U /*!< DMAMUX1 TIM2 CH4 request */
\r
272 #define DMA_REQUEST_TIM2_UP 60U /*!< DMAMUX1 TIM2 UP request */
\r
274 #define DMA_REQUEST_TIM3_CH1 61U /*!< DMAMUX1 TIM3 CH1 request */
\r
275 #define DMA_REQUEST_TIM3_CH2 62U /*!< DMAMUX1 TIM3 CH2 request */
\r
276 #define DMA_REQUEST_TIM3_CH3 63U /*!< DMAMUX1 TIM3 CH3 request */
\r
277 #define DMA_REQUEST_TIM3_CH4 64U /*!< DMAMUX1 TIM3 CH4 request */
\r
278 #define DMA_REQUEST_TIM3_UP 65U /*!< DMAMUX1 TIM3 UP request */
\r
279 #define DMA_REQUEST_TIM3_TRIG 66U /*!< DMAMUX1 TIM3 TRIG request */
\r
281 #define DMA_REQUEST_TIM4_CH1 67U /*!< DMAMUX1 TIM4 CH1 request */
\r
282 #define DMA_REQUEST_TIM4_CH2 68U /*!< DMAMUX1 TIM4 CH2 request */
\r
283 #define DMA_REQUEST_TIM4_CH3 69U /*!< DMAMUX1 TIM4 CH3 request */
\r
284 #define DMA_REQUEST_TIM4_CH4 70U /*!< DMAMUX1 TIM4 CH4 request */
\r
285 #define DMA_REQUEST_TIM4_UP 71U /*!< DMAMUX1 TIM4 UP request */
\r
287 #define DMA_REQUEST_TIM5_CH1 72U /*!< DMAMUX1 TIM5 CH1 request */
\r
288 #define DMA_REQUEST_TIM5_CH2 73U /*!< DMAMUX1 TIM5 CH2 request */
\r
289 #define DMA_REQUEST_TIM5_CH3 74U /*!< DMAMUX1 TIM5 CH3 request */
\r
290 #define DMA_REQUEST_TIM5_CH4 75U /*!< DMAMUX1 TIM5 CH4 request */
\r
291 #define DMA_REQUEST_TIM5_UP 76U /*!< DMAMUX1 TIM5 UP request */
\r
292 #define DMA_REQUEST_TIM5_TRIG 77U /*!< DMAMUX1 TIM5 TRIG request */
\r
294 #define DMA_REQUEST_TIM15_CH1 78U /*!< DMAMUX1 TIM15 CH1 request */
\r
295 #define DMA_REQUEST_TIM15_UP 79U /*!< DMAMUX1 TIM15 UP request */
\r
296 #define DMA_REQUEST_TIM15_TRIG 80U /*!< DMAMUX1 TIM15 TRIG request */
\r
297 #define DMA_REQUEST_TIM15_COM 81U /*!< DMAMUX1 TIM15 COM request */
\r
299 #define DMA_REQUEST_TIM16_CH1 82U /*!< DMAMUX1 TIM16 CH1 request */
\r
300 #define DMA_REQUEST_TIM16_UP 83U /*!< DMAMUX1 TIM16 UP request */
\r
301 #define DMA_REQUEST_TIM17_CH1 84U /*!< DMAMUX1 TIM17 CH1 request */
\r
302 #define DMA_REQUEST_TIM17_UP 85U /*!< DMAMUX1 TIM17 UP request */
\r
304 #define DMA_REQUEST_DFSDM1_FLT0 86U /*!< DMAMUX1 DFSDM1 Filter0 request */
\r
305 #define DMA_REQUEST_DFSDM1_FLT1 87U /*!< DMAMUX1 DFSDM1 Filter1 request */
\r
306 #define DMA_REQUEST_DFSDM1_FLT2 88U /*!< DMAMUX1 DFSDM1 Filter2 request */
\r
307 #define DMA_REQUEST_DFSDM1_FLT3 89U /*!< DMAMUX1 DFSDM1 Filter3 request */
\r
309 #define DMA_REQUEST_DCMI 90U /*!< DMAMUX1 DCMI request */
\r
311 #define DMA_REQUEST_AES_IN 91U /*!< DMAMUX1 AES IN request */
\r
312 #define DMA_REQUEST_AES_OUT 92U /*!< DMAMUX1 AES OUT request */
\r
314 #define DMA_REQUEST_HASH_IN 93U /*!< DMAMUX1 HASH IN request */
\r
316 #endif /* DMAMUX1 */
\r
322 /** @defgroup DMA_Data_transfer_direction DMA Data transfer direction
\r
325 #define DMA_PERIPH_TO_MEMORY 0x00000000U /*!< Peripheral to memory direction */
\r
326 #define DMA_MEMORY_TO_PERIPH DMA_CCR_DIR /*!< Memory to peripheral direction */
\r
327 #define DMA_MEMORY_TO_MEMORY DMA_CCR_MEM2MEM /*!< Memory to memory direction */
\r
332 /** @defgroup DMA_Peripheral_incremented_mode DMA Peripheral incremented mode
\r
335 #define DMA_PINC_ENABLE DMA_CCR_PINC /*!< Peripheral increment mode Enable */
\r
336 #define DMA_PINC_DISABLE 0x00000000U /*!< Peripheral increment mode Disable */
\r
341 /** @defgroup DMA_Memory_incremented_mode DMA Memory incremented mode
\r
344 #define DMA_MINC_ENABLE DMA_CCR_MINC /*!< Memory increment mode Enable */
\r
345 #define DMA_MINC_DISABLE 0x00000000U /*!< Memory increment mode Disable */
\r
350 /** @defgroup DMA_Peripheral_data_size DMA Peripheral data size
\r
353 #define DMA_PDATAALIGN_BYTE 0x00000000U /*!< Peripheral data alignment : Byte */
\r
354 #define DMA_PDATAALIGN_HALFWORD DMA_CCR_PSIZE_0 /*!< Peripheral data alignment : HalfWord */
\r
355 #define DMA_PDATAALIGN_WORD DMA_CCR_PSIZE_1 /*!< Peripheral data alignment : Word */
\r
360 /** @defgroup DMA_Memory_data_size DMA Memory data size
\r
363 #define DMA_MDATAALIGN_BYTE 0x00000000U /*!< Memory data alignment : Byte */
\r
364 #define DMA_MDATAALIGN_HALFWORD DMA_CCR_MSIZE_0 /*!< Memory data alignment : HalfWord */
\r
365 #define DMA_MDATAALIGN_WORD DMA_CCR_MSIZE_1 /*!< Memory data alignment : Word */
\r
370 /** @defgroup DMA_mode DMA mode
\r
373 #define DMA_NORMAL 0x00000000U /*!< Normal mode */
\r
374 #define DMA_CIRCULAR DMA_CCR_CIRC /*!< Circular mode */
\r
379 /** @defgroup DMA_Priority_level DMA Priority level
\r
382 #define DMA_PRIORITY_LOW 0x00000000U /*!< Priority level : Low */
\r
383 #define DMA_PRIORITY_MEDIUM DMA_CCR_PL_0 /*!< Priority level : Medium */
\r
384 #define DMA_PRIORITY_HIGH DMA_CCR_PL_1 /*!< Priority level : High */
\r
385 #define DMA_PRIORITY_VERY_HIGH DMA_CCR_PL /*!< Priority level : Very_High */
\r
391 /** @defgroup DMA_interrupt_enable_definitions DMA interrupt enable definitions
\r
394 #define DMA_IT_TC DMA_CCR_TCIE
\r
395 #define DMA_IT_HT DMA_CCR_HTIE
\r
396 #define DMA_IT_TE DMA_CCR_TEIE
\r
401 /** @defgroup DMA_flag_definitions DMA flag definitions
\r
404 #define DMA_FLAG_GL1 DMA_ISR_GIF1
\r
405 #define DMA_FLAG_TC1 DMA_ISR_TCIF1
\r
406 #define DMA_FLAG_HT1 DMA_ISR_HTIF1
\r
407 #define DMA_FLAG_TE1 DMA_ISR_TEIF1
\r
408 #define DMA_FLAG_GL2 DMA_ISR_GIF2
\r
409 #define DMA_FLAG_TC2 DMA_ISR_TCIF2
\r
410 #define DMA_FLAG_HT2 DMA_ISR_HTIF2
\r
411 #define DMA_FLAG_TE2 DMA_ISR_TEIF2
\r
412 #define DMA_FLAG_GL3 DMA_ISR_GIF3
\r
413 #define DMA_FLAG_TC3 DMA_ISR_TCIF3
\r
414 #define DMA_FLAG_HT3 DMA_ISR_HTIF3
\r
415 #define DMA_FLAG_TE3 DMA_ISR_TEIF3
\r
416 #define DMA_FLAG_GL4 DMA_ISR_GIF4
\r
417 #define DMA_FLAG_TC4 DMA_ISR_TCIF4
\r
418 #define DMA_FLAG_HT4 DMA_ISR_HTIF4
\r
419 #define DMA_FLAG_TE4 DMA_ISR_TEIF4
\r
420 #define DMA_FLAG_GL5 DMA_ISR_GIF5
\r
421 #define DMA_FLAG_TC5 DMA_ISR_TCIF5
\r
422 #define DMA_FLAG_HT5 DMA_ISR_HTIF5
\r
423 #define DMA_FLAG_TE5 DMA_ISR_TEIF5
\r
424 #define DMA_FLAG_GL6 DMA_ISR_GIF6
\r
425 #define DMA_FLAG_TC6 DMA_ISR_TCIF6
\r
426 #define DMA_FLAG_HT6 DMA_ISR_HTIF6
\r
427 #define DMA_FLAG_TE6 DMA_ISR_TEIF6
\r
428 #define DMA_FLAG_GL7 DMA_ISR_GIF7
\r
429 #define DMA_FLAG_TC7 DMA_ISR_TCIF7
\r
430 #define DMA_FLAG_HT7 DMA_ISR_HTIF7
\r
431 #define DMA_FLAG_TE7 DMA_ISR_TEIF7
\r
440 /* Exported macros -----------------------------------------------------------*/
\r
441 /** @defgroup DMA_Exported_Macros DMA Exported Macros
\r
445 /** @brief Reset DMA handle state.
\r
446 * @param __HANDLE__ DMA handle
\r
449 #define __HAL_DMA_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DMA_STATE_RESET)
\r
452 * @brief Enable the specified DMA Channel.
\r
453 * @param __HANDLE__ DMA handle
\r
456 #define __HAL_DMA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CCR |= DMA_CCR_EN)
\r
459 * @brief Disable the specified DMA Channel.
\r
460 * @param __HANDLE__ DMA handle
\r
463 #define __HAL_DMA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CCR &= ~DMA_CCR_EN)
\r
466 /* Interrupt & Flag management */
\r
469 * @brief Return the current DMA Channel transfer complete flag.
\r
470 * @param __HANDLE__ DMA handle
\r
471 * @retval The specified transfer complete flag index.
\r
474 #define __HAL_DMA_GET_TC_FLAG_INDEX(__HANDLE__) \
\r
475 (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_TC1 :\
\r
476 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel1))? DMA_FLAG_TC1 :\
\r
477 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_TC2 :\
\r
478 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel2))? DMA_FLAG_TC2 :\
\r
479 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_TC3 :\
\r
480 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel3))? DMA_FLAG_TC3 :\
\r
481 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_TC4 :\
\r
482 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel4))? DMA_FLAG_TC4 :\
\r
483 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_FLAG_TC5 :\
\r
484 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel5))? DMA_FLAG_TC5 :\
\r
485 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_FLAG_TC6 :\
\r
486 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel6))? DMA_FLAG_TC6 :\
\r
490 * @brief Return the current DMA Channel half transfer complete flag.
\r
491 * @param __HANDLE__ DMA handle
\r
492 * @retval The specified half transfer complete flag index.
\r
494 #define __HAL_DMA_GET_HT_FLAG_INDEX(__HANDLE__)\
\r
495 (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_HT1 :\
\r
496 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel1))? DMA_FLAG_HT1 :\
\r
497 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_HT2 :\
\r
498 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel2))? DMA_FLAG_HT2 :\
\r
499 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_HT3 :\
\r
500 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel3))? DMA_FLAG_HT3 :\
\r
501 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_HT4 :\
\r
502 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel4))? DMA_FLAG_HT4 :\
\r
503 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_FLAG_HT5 :\
\r
504 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel5))? DMA_FLAG_HT5 :\
\r
505 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_FLAG_HT6 :\
\r
506 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel6))? DMA_FLAG_HT6 :\
\r
510 * @brief Return the current DMA Channel transfer error flag.
\r
511 * @param __HANDLE__ DMA handle
\r
512 * @retval The specified transfer error flag index.
\r
514 #define __HAL_DMA_GET_TE_FLAG_INDEX(__HANDLE__)\
\r
515 (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_TE1 :\
\r
516 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel1))? DMA_FLAG_TE1 :\
\r
517 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_TE2 :\
\r
518 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel2))? DMA_FLAG_TE2 :\
\r
519 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_TE3 :\
\r
520 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel3))? DMA_FLAG_TE3 :\
\r
521 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_TE4 :\
\r
522 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel4))? DMA_FLAG_TE4 :\
\r
523 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_FLAG_TE5 :\
\r
524 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel5))? DMA_FLAG_TE5 :\
\r
525 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_FLAG_TE6 :\
\r
526 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel6))? DMA_FLAG_TE6 :\
\r
530 * @brief Return the current DMA Channel Global interrupt flag.
\r
531 * @param __HANDLE__ DMA handle
\r
532 * @retval The specified transfer error flag index.
\r
534 #define __HAL_DMA_GET_GI_FLAG_INDEX(__HANDLE__)\
\r
535 (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_ISR_GIF1 :\
\r
536 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel1))? DMA_ISR_GIF1 :\
\r
537 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_ISR_GIF2 :\
\r
538 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel2))? DMA_ISR_GIF2 :\
\r
539 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_ISR_GIF3 :\
\r
540 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel3))? DMA_ISR_GIF3 :\
\r
541 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_ISR_GIF4 :\
\r
542 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel4))? DMA_ISR_GIF4 :\
\r
543 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_ISR_GIF5 :\
\r
544 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel5))? DMA_ISR_GIF5 :\
\r
545 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_ISR_GIF6 :\
\r
546 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel6))? DMA_ISR_GIF6 :\
\r
550 * @brief Get the DMA Channel pending flags.
\r
551 * @param __HANDLE__ DMA handle
\r
552 * @param __FLAG__ Get the specified flag.
\r
553 * This parameter can be any combination of the following values:
\r
554 * @arg DMA_FLAG_TCx: Transfer complete flag
\r
555 * @arg DMA_FLAG_HTx: Half transfer complete flag
\r
556 * @arg DMA_FLAG_TEx: Transfer error flag
\r
557 * @arg DMA_FLAG_GLx: Global interrupt flag
\r
558 * Where x can be from 1 to 7 to select the DMA Channel x flag.
\r
559 * @retval The state of FLAG (SET or RESET).
\r
561 #define __HAL_DMA_GET_FLAG(__HANDLE__, __FLAG__) (((uint32_t)((__HANDLE__)->Instance) > ((uint32_t)DMA1_Channel7))? \
\r
562 (DMA2->ISR & (__FLAG__)) : (DMA1->ISR & (__FLAG__)))
\r
565 * @brief Clear the DMA Channel pending flags.
\r
566 * @param __HANDLE__ DMA handle
\r
567 * @param __FLAG__ specifies the flag to clear.
\r
568 * This parameter can be any combination of the following values:
\r
569 * @arg DMA_FLAG_TCx: Transfer complete flag
\r
570 * @arg DMA_FLAG_HTx: Half transfer complete flag
\r
571 * @arg DMA_FLAG_TEx: Transfer error flag
\r
572 * @arg DMA_FLAG_GLx: Global interrupt flag
\r
573 * Where x can be from 1 to 7 to select the DMA Channel x flag.
\r
576 #define __HAL_DMA_CLEAR_FLAG(__HANDLE__, __FLAG__) (((uint32_t)((__HANDLE__)->Instance) > ((uint32_t)DMA1_Channel7))? \
\r
577 (DMA2->IFCR = (__FLAG__)) : (DMA1->IFCR = (__FLAG__)))
\r
580 * @brief Enable the specified DMA Channel interrupts.
\r
581 * @param __HANDLE__ DMA handle
\r
582 * @param __INTERRUPT__ specifies the DMA interrupt sources to be enabled or disabled.
\r
583 * This parameter can be any combination of the following values:
\r
584 * @arg DMA_IT_TC: Transfer complete interrupt mask
\r
585 * @arg DMA_IT_HT: Half transfer complete interrupt mask
\r
586 * @arg DMA_IT_TE: Transfer error interrupt mask
\r
589 #define __HAL_DMA_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CCR |= (__INTERRUPT__))
\r
592 * @brief Disable the specified DMA Channel interrupts.
\r
593 * @param __HANDLE__ DMA handle
\r
594 * @param __INTERRUPT__ specifies the DMA interrupt sources to be enabled or disabled.
\r
595 * This parameter can be any combination of the following values:
\r
596 * @arg DMA_IT_TC: Transfer complete interrupt mask
\r
597 * @arg DMA_IT_HT: Half transfer complete interrupt mask
\r
598 * @arg DMA_IT_TE: Transfer error interrupt mask
\r
601 #define __HAL_DMA_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CCR &= ~(__INTERRUPT__))
\r
604 * @brief Check whether the specified DMA Channel interrupt is enabled or not.
\r
605 * @param __HANDLE__ DMA handle
\r
606 * @param __INTERRUPT__ specifies the DMA interrupt source to check.
\r
607 * This parameter can be one of the following values:
\r
608 * @arg DMA_IT_TC: Transfer complete interrupt mask
\r
609 * @arg DMA_IT_HT: Half transfer complete interrupt mask
\r
610 * @arg DMA_IT_TE: Transfer error interrupt mask
\r
611 * @retval The state of DMA_IT (SET or RESET).
\r
613 #define __HAL_DMA_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CCR & (__INTERRUPT__)))
\r
616 * @brief Return the number of remaining data units in the current DMA Channel transfer.
\r
617 * @param __HANDLE__ DMA handle
\r
618 * @retval The number of remaining data units in the current DMA Channel transfer.
\r
620 #define __HAL_DMA_GET_COUNTER(__HANDLE__) ((__HANDLE__)->Instance->CNDTR)
\r
626 #if defined(DMAMUX1)
\r
627 /* Include DMA HAL Extension module */
\r
628 #include "stm32l4xx_hal_dma_ex.h"
\r
629 #endif /* DMAMUX1 */
\r
631 /* Exported functions --------------------------------------------------------*/
\r
633 /** @addtogroup DMA_Exported_Functions
\r
637 /** @addtogroup DMA_Exported_Functions_Group1
\r
640 /* Initialization and de-initialization functions *****************************/
\r
641 HAL_StatusTypeDef HAL_DMA_Init(DMA_HandleTypeDef *hdma);
\r
642 HAL_StatusTypeDef HAL_DMA_DeInit (DMA_HandleTypeDef *hdma);
\r
647 /** @addtogroup DMA_Exported_Functions_Group2
\r
650 /* IO operation functions *****************************************************/
\r
651 HAL_StatusTypeDef HAL_DMA_Start (DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength);
\r
652 HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength);
\r
653 HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma);
\r
654 HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma);
\r
655 HAL_StatusTypeDef HAL_DMA_PollForTransfer(DMA_HandleTypeDef *hdma, HAL_DMA_LevelCompleteTypeDef CompleteLevel, uint32_t Timeout);
\r
656 void HAL_DMA_IRQHandler(DMA_HandleTypeDef *hdma);
\r
657 HAL_StatusTypeDef HAL_DMA_RegisterCallback(DMA_HandleTypeDef *hdma, HAL_DMA_CallbackIDTypeDef CallbackID, void (* pCallback)( DMA_HandleTypeDef * _hdma));
\r
658 HAL_StatusTypeDef HAL_DMA_UnRegisterCallback(DMA_HandleTypeDef *hdma, HAL_DMA_CallbackIDTypeDef CallbackID);
\r
664 /** @addtogroup DMA_Exported_Functions_Group3
\r
667 /* Peripheral State and Error functions ***************************************/
\r
668 HAL_DMA_StateTypeDef HAL_DMA_GetState(DMA_HandleTypeDef *hdma);
\r
669 uint32_t HAL_DMA_GetError(DMA_HandleTypeDef *hdma);
\r
678 /* Private macros ------------------------------------------------------------*/
\r
679 /** @defgroup DMA_Private_Macros DMA Private Macros
\r
683 #define IS_DMA_DIRECTION(DIRECTION) (((DIRECTION) == DMA_PERIPH_TO_MEMORY ) || \
\r
684 ((DIRECTION) == DMA_MEMORY_TO_PERIPH) || \
\r
685 ((DIRECTION) == DMA_MEMORY_TO_MEMORY))
\r
687 #define IS_DMA_BUFFER_SIZE(SIZE) (((SIZE) >= 0x1U) && ((SIZE) < 0x10000U))
\r
689 #define IS_DMA_PERIPHERAL_INC_STATE(STATE) (((STATE) == DMA_PINC_ENABLE) || \
\r
690 ((STATE) == DMA_PINC_DISABLE))
\r
692 #define IS_DMA_MEMORY_INC_STATE(STATE) (((STATE) == DMA_MINC_ENABLE) || \
\r
693 ((STATE) == DMA_MINC_DISABLE))
\r
695 #if !defined (DMAMUX1)
\r
697 #define IS_DMA_ALL_REQUEST(REQUEST) (((REQUEST) == DMA_REQUEST_0) || \
\r
698 ((REQUEST) == DMA_REQUEST_1) || \
\r
699 ((REQUEST) == DMA_REQUEST_2) || \
\r
700 ((REQUEST) == DMA_REQUEST_3) || \
\r
701 ((REQUEST) == DMA_REQUEST_4) || \
\r
702 ((REQUEST) == DMA_REQUEST_5) || \
\r
703 ((REQUEST) == DMA_REQUEST_6) || \
\r
704 ((REQUEST) == DMA_REQUEST_7))
\r
707 #if defined(DMAMUX1)
\r
709 #define IS_DMA_ALL_REQUEST(REQUEST)((REQUEST) <= DMA_REQUEST_HASH_IN)
\r
711 #endif /* DMAMUX1 */
\r
713 #define IS_DMA_PERIPHERAL_DATA_SIZE(SIZE) (((SIZE) == DMA_PDATAALIGN_BYTE) || \
\r
714 ((SIZE) == DMA_PDATAALIGN_HALFWORD) || \
\r
715 ((SIZE) == DMA_PDATAALIGN_WORD))
\r
717 #define IS_DMA_MEMORY_DATA_SIZE(SIZE) (((SIZE) == DMA_MDATAALIGN_BYTE) || \
\r
718 ((SIZE) == DMA_MDATAALIGN_HALFWORD) || \
\r
719 ((SIZE) == DMA_MDATAALIGN_WORD ))
\r
721 #define IS_DMA_MODE(MODE) (((MODE) == DMA_NORMAL ) || \
\r
722 ((MODE) == DMA_CIRCULAR))
\r
724 #define IS_DMA_PRIORITY(PRIORITY) (((PRIORITY) == DMA_PRIORITY_LOW ) || \
\r
725 ((PRIORITY) == DMA_PRIORITY_MEDIUM) || \
\r
726 ((PRIORITY) == DMA_PRIORITY_HIGH) || \
\r
727 ((PRIORITY) == DMA_PRIORITY_VERY_HIGH))
\r
733 /* Private functions ---------------------------------------------------------*/
\r
747 #endif /* STM32L4xx_HAL_DMA_H */
\r
749 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\r