Go to the documentation of this file.
21 #ifndef __STM32F7xx_HAL_DMA_H
22 #define __STM32F7xx_HAL_DMA_H
64 uint32_t PeriphDataAlignment;
67 uint32_t MemDataAlignment;
83 uint32_t FIFOThreshold;
186 #define HAL_DMA_ERROR_NONE 0x00000000U
187 #define HAL_DMA_ERROR_TE 0x00000001U
188 #define HAL_DMA_ERROR_FE 0x00000002U
189 #define HAL_DMA_ERROR_DME 0x00000004U
190 #define HAL_DMA_ERROR_TIMEOUT 0x00000020U
191 #define HAL_DMA_ERROR_PARAM 0x00000040U
192 #define HAL_DMA_ERROR_NO_XFER 0x00000080U
193 #define HAL_DMA_ERROR_NOT_SUPPORTED 0x00000100U
202 #define DMA_PERIPH_TO_MEMORY 0x00000000U
203 #define DMA_MEMORY_TO_PERIPH DMA_SxCR_DIR_0
204 #define DMA_MEMORY_TO_MEMORY DMA_SxCR_DIR_1
213 #define DMA_PINC_ENABLE DMA_SxCR_PINC
214 #define DMA_PINC_DISABLE 0x00000000U
223 #define DMA_MINC_ENABLE DMA_SxCR_MINC
224 #define DMA_MINC_DISABLE 0x00000000U
233 #define DMA_PDATAALIGN_BYTE 0x00000000U
234 #define DMA_PDATAALIGN_HALFWORD DMA_SxCR_PSIZE_0
235 #define DMA_PDATAALIGN_WORD DMA_SxCR_PSIZE_1
244 #define DMA_MDATAALIGN_BYTE 0x00000000U
245 #define DMA_MDATAALIGN_HALFWORD DMA_SxCR_MSIZE_0
246 #define DMA_MDATAALIGN_WORD DMA_SxCR_MSIZE_1
255 #define DMA_NORMAL 0x00000000U
256 #define DMA_CIRCULAR DMA_SxCR_CIRC
257 #define DMA_PFCTRL DMA_SxCR_PFCTRL
266 #define DMA_PRIORITY_LOW 0x00000000U
267 #define DMA_PRIORITY_MEDIUM DMA_SxCR_PL_0
268 #define DMA_PRIORITY_HIGH DMA_SxCR_PL_1
269 #define DMA_PRIORITY_VERY_HIGH DMA_SxCR_PL
278 #define DMA_FIFOMODE_DISABLE 0x00000000U
279 #define DMA_FIFOMODE_ENABLE DMA_SxFCR_DMDIS
288 #define DMA_FIFO_THRESHOLD_1QUARTERFULL 0x00000000U
289 #define DMA_FIFO_THRESHOLD_HALFFULL DMA_SxFCR_FTH_0
290 #define DMA_FIFO_THRESHOLD_3QUARTERSFULL DMA_SxFCR_FTH_1
291 #define DMA_FIFO_THRESHOLD_FULL DMA_SxFCR_FTH
300 #define DMA_MBURST_SINGLE 0x00000000U
301 #define DMA_MBURST_INC4 DMA_SxCR_MBURST_0
302 #define DMA_MBURST_INC8 DMA_SxCR_MBURST_1
303 #define DMA_MBURST_INC16 DMA_SxCR_MBURST
312 #define DMA_PBURST_SINGLE 0x00000000U
313 #define DMA_PBURST_INC4 DMA_SxCR_PBURST_0
314 #define DMA_PBURST_INC8 DMA_SxCR_PBURST_1
315 #define DMA_PBURST_INC16 DMA_SxCR_PBURST
324 #define DMA_IT_TC DMA_SxCR_TCIE
325 #define DMA_IT_HT DMA_SxCR_HTIE
326 #define DMA_IT_TE DMA_SxCR_TEIE
327 #define DMA_IT_DME DMA_SxCR_DMEIE
328 #define DMA_IT_FE 0x00000080U
337 #define DMA_FLAG_FEIF0_4 0x00000001U
338 #define DMA_FLAG_DMEIF0_4 0x00000004U
339 #define DMA_FLAG_TEIF0_4 0x00000008U
340 #define DMA_FLAG_HTIF0_4 0x00000010U
341 #define DMA_FLAG_TCIF0_4 0x00000020U
342 #define DMA_FLAG_FEIF1_5 0x00000040U
343 #define DMA_FLAG_DMEIF1_5 0x00000100U
344 #define DMA_FLAG_TEIF1_5 0x00000200U
345 #define DMA_FLAG_HTIF1_5 0x00000400U
346 #define DMA_FLAG_TCIF1_5 0x00000800U
347 #define DMA_FLAG_FEIF2_6 0x00010000U
348 #define DMA_FLAG_DMEIF2_6 0x00040000U
349 #define DMA_FLAG_TEIF2_6 0x00080000U
350 #define DMA_FLAG_HTIF2_6 0x00100000U
351 #define DMA_FLAG_TCIF2_6 0x00200000U
352 #define DMA_FLAG_FEIF3_7 0x00400000U
353 #define DMA_FLAG_DMEIF3_7 0x01000000U
354 #define DMA_FLAG_TEIF3_7 0x02000000U
355 #define DMA_FLAG_HTIF3_7 0x04000000U
356 #define DMA_FLAG_TCIF3_7 0x08000000U
371 #define __HAL_DMA_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DMA_STATE_RESET)
385 #define __HAL_DMA_GET_FS(__HANDLE__) (((__HANDLE__)->Instance->FCR & (DMA_SxFCR_FS)))
392 #define __HAL_DMA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= DMA_SxCR_EN)
399 #define __HAL_DMA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~DMA_SxCR_EN)
408 #define __HAL_DMA_GET_TC_FLAG_INDEX(__HANDLE__) \
409 (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream0))? DMA_FLAG_TCIF0_4 :\
410 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream0))? DMA_FLAG_TCIF0_4 :\
411 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream4))? DMA_FLAG_TCIF0_4 :\
412 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream4))? DMA_FLAG_TCIF0_4 :\
413 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream1))? DMA_FLAG_TCIF1_5 :\
414 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream1))? DMA_FLAG_TCIF1_5 :\
415 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream5))? DMA_FLAG_TCIF1_5 :\
416 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream5))? DMA_FLAG_TCIF1_5 :\
417 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream2))? DMA_FLAG_TCIF2_6 :\
418 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream2))? DMA_FLAG_TCIF2_6 :\
419 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream6))? DMA_FLAG_TCIF2_6 :\
420 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream6))? DMA_FLAG_TCIF2_6 :\
428 #define __HAL_DMA_GET_HT_FLAG_INDEX(__HANDLE__)\
429 (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream0))? DMA_FLAG_HTIF0_4 :\
430 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream0))? DMA_FLAG_HTIF0_4 :\
431 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream4))? DMA_FLAG_HTIF0_4 :\
432 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream4))? DMA_FLAG_HTIF0_4 :\
433 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream1))? DMA_FLAG_HTIF1_5 :\
434 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream1))? DMA_FLAG_HTIF1_5 :\
435 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream5))? DMA_FLAG_HTIF1_5 :\
436 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream5))? DMA_FLAG_HTIF1_5 :\
437 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream2))? DMA_FLAG_HTIF2_6 :\
438 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream2))? DMA_FLAG_HTIF2_6 :\
439 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream6))? DMA_FLAG_HTIF2_6 :\
440 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream6))? DMA_FLAG_HTIF2_6 :\
448 #define __HAL_DMA_GET_TE_FLAG_INDEX(__HANDLE__)\
449 (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream0))? DMA_FLAG_TEIF0_4 :\
450 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream0))? DMA_FLAG_TEIF0_4 :\
451 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream4))? DMA_FLAG_TEIF0_4 :\
452 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream4))? DMA_FLAG_TEIF0_4 :\
453 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream1))? DMA_FLAG_TEIF1_5 :\
454 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream1))? DMA_FLAG_TEIF1_5 :\
455 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream5))? DMA_FLAG_TEIF1_5 :\
456 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream5))? DMA_FLAG_TEIF1_5 :\
457 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream2))? DMA_FLAG_TEIF2_6 :\
458 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream2))? DMA_FLAG_TEIF2_6 :\
459 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream6))? DMA_FLAG_TEIF2_6 :\
460 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream6))? DMA_FLAG_TEIF2_6 :\
468 #define __HAL_DMA_GET_FE_FLAG_INDEX(__HANDLE__)\
469 (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream0))? DMA_FLAG_FEIF0_4 :\
470 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream0))? DMA_FLAG_FEIF0_4 :\
471 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream4))? DMA_FLAG_FEIF0_4 :\
472 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream4))? DMA_FLAG_FEIF0_4 :\
473 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream1))? DMA_FLAG_FEIF1_5 :\
474 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream1))? DMA_FLAG_FEIF1_5 :\
475 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream5))? DMA_FLAG_FEIF1_5 :\
476 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream5))? DMA_FLAG_FEIF1_5 :\
477 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream2))? DMA_FLAG_FEIF2_6 :\
478 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream2))? DMA_FLAG_FEIF2_6 :\
479 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream6))? DMA_FLAG_FEIF2_6 :\
480 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream6))? DMA_FLAG_FEIF2_6 :\
488 #define __HAL_DMA_GET_DME_FLAG_INDEX(__HANDLE__)\
489 (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream0))? DMA_FLAG_DMEIF0_4 :\
490 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream0))? DMA_FLAG_DMEIF0_4 :\
491 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream4))? DMA_FLAG_DMEIF0_4 :\
492 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream4))? DMA_FLAG_DMEIF0_4 :\
493 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream1))? DMA_FLAG_DMEIF1_5 :\
494 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream1))? DMA_FLAG_DMEIF1_5 :\
495 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream5))? DMA_FLAG_DMEIF1_5 :\
496 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream5))? DMA_FLAG_DMEIF1_5 :\
497 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream2))? DMA_FLAG_DMEIF2_6 :\
498 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream2))? DMA_FLAG_DMEIF2_6 :\
499 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream6))? DMA_FLAG_DMEIF2_6 :\
500 ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream6))? DMA_FLAG_DMEIF2_6 :\
516 #define __HAL_DMA_GET_FLAG(__HANDLE__, __FLAG__)\
517 (((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA2_Stream3)? (DMA2->HISR & (__FLAG__)) :\
518 ((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA1_Stream7)? (DMA2->LISR & (__FLAG__)) :\
519 ((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA1_Stream3)? (DMA1->HISR & (__FLAG__)) : (DMA1->LISR & (__FLAG__)))
534 #define __HAL_DMA_CLEAR_FLAG(__HANDLE__, __FLAG__) \
535 (((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA2_Stream3)? (DMA2->HIFCR = (__FLAG__)) :\
536 ((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA1_Stream7)? (DMA2->LIFCR = (__FLAG__)) :\
537 ((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA1_Stream3)? (DMA1->HIFCR = (__FLAG__)) : (DMA1->LIFCR = (__FLAG__)))
551 #define __HAL_DMA_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__INTERRUPT__) != DMA_IT_FE)? \
552 ((__HANDLE__)->Instance->CR |= (__INTERRUPT__)) : ((__HANDLE__)->Instance->FCR |= (__INTERRUPT__)))
566 #define __HAL_DMA_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__INTERRUPT__) != DMA_IT_FE)? \
567 ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__)) : ((__HANDLE__)->Instance->FCR &= ~(__INTERRUPT__)))
581 #define __HAL_DMA_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__INTERRUPT__) != DMA_IT_FE)? \
582 ((__HANDLE__)->Instance->CR & (__INTERRUPT__)) : \
583 ((__HANDLE__)->Instance->FCR & (__INTERRUPT__)))
602 #define __HAL_DMA_SET_COUNTER(__HANDLE__, __COUNTER__) ((__HANDLE__)->Instance->NDTR = (uint16_t)(__COUNTER__))
610 #define __HAL_DMA_GET_COUNTER(__HANDLE__) ((__HANDLE__)->Instance->NDTR)
676 #define IS_DMA_DIRECTION(DIRECTION) (((DIRECTION) == DMA_PERIPH_TO_MEMORY ) || \
677 ((DIRECTION) == DMA_MEMORY_TO_PERIPH) || \
678 ((DIRECTION) == DMA_MEMORY_TO_MEMORY))
680 #define IS_DMA_BUFFER_SIZE(SIZE) (((SIZE) >= 0x01U) && ((SIZE) < 0x10000U))
682 #define IS_DMA_PERIPHERAL_INC_STATE(STATE) (((STATE) == DMA_PINC_ENABLE) || \
683 ((STATE) == DMA_PINC_DISABLE))
685 #define IS_DMA_MEMORY_INC_STATE(STATE) (((STATE) == DMA_MINC_ENABLE) || \
686 ((STATE) == DMA_MINC_DISABLE))
688 #define IS_DMA_PERIPHERAL_DATA_SIZE(SIZE) (((SIZE) == DMA_PDATAALIGN_BYTE) || \
689 ((SIZE) == DMA_PDATAALIGN_HALFWORD) || \
690 ((SIZE) == DMA_PDATAALIGN_WORD))
692 #define IS_DMA_MEMORY_DATA_SIZE(SIZE) (((SIZE) == DMA_MDATAALIGN_BYTE) || \
693 ((SIZE) == DMA_MDATAALIGN_HALFWORD) || \
694 ((SIZE) == DMA_MDATAALIGN_WORD ))
696 #define IS_DMA_MODE(MODE) (((MODE) == DMA_NORMAL ) || \
697 ((MODE) == DMA_CIRCULAR) || \
698 ((MODE) == DMA_PFCTRL))
700 #define IS_DMA_PRIORITY(PRIORITY) (((PRIORITY) == DMA_PRIORITY_LOW ) || \
701 ((PRIORITY) == DMA_PRIORITY_MEDIUM) || \
702 ((PRIORITY) == DMA_PRIORITY_HIGH) || \
703 ((PRIORITY) == DMA_PRIORITY_VERY_HIGH))
705 #define IS_DMA_FIFO_MODE_STATE(STATE) (((STATE) == DMA_FIFOMODE_DISABLE ) || \
706 ((STATE) == DMA_FIFOMODE_ENABLE))
708 #define IS_DMA_FIFO_THRESHOLD(THRESHOLD) (((THRESHOLD) == DMA_FIFO_THRESHOLD_1QUARTERFULL ) || \
709 ((THRESHOLD) == DMA_FIFO_THRESHOLD_HALFFULL) || \
710 ((THRESHOLD) == DMA_FIFO_THRESHOLD_3QUARTERSFULL) || \
711 ((THRESHOLD) == DMA_FIFO_THRESHOLD_FULL))
713 #define IS_DMA_MEMORY_BURST(BURST) (((BURST) == DMA_MBURST_SINGLE) || \
714 ((BURST) == DMA_MBURST_INC4) || \
715 ((BURST) == DMA_MBURST_INC8) || \
716 ((BURST) == DMA_MBURST_INC16))
718 #define IS_DMA_PERIPHERAL_BURST(BURST) (((BURST) == DMA_PBURST_SINGLE) || \
719 ((BURST) == DMA_PBURST_INC4) || \
720 ((BURST) == DMA_PBURST_INC8) || \
721 ((BURST) == DMA_PBURST_INC16))
HAL_StatusTypeDef
HAL Status structures definition
@ HAL_DMA_XFER_ERROR_CB_ID
void(* XferHalfCpltCallback)(struct __DMA_HandleTypeDef *hdma)
DMA handle Structure definition.
uint32_t StreamBaseAddress
DMA Configuration Structure definition.
HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma)
void(* XferM1CpltCallback)(struct __DMA_HandleTypeDef *hdma)
void(* XferAbortCallback)(struct __DMA_HandleTypeDef *hdma)
HAL_LockTypeDef
HAL Lock structures definition
__IO HAL_DMA_StateTypeDef State
@ HAL_DMA_XFER_ABORT_CB_ID
@ HAL_DMA_XFER_M1HALFCPLT_CB_ID
HAL_StatusTypeDef HAL_DMA_UnRegisterCallback(DMA_HandleTypeDef *hdma, HAL_DMA_CallbackIDTypeDef CallbackID)
HAL_StatusTypeDef HAL_DMA_PollForTransfer(DMA_HandleTypeDef *hdma, HAL_DMA_LevelCompleteTypeDef CompleteLevel, uint32_t Timeout)
HAL_DMA_StateTypeDef HAL_DMA_GetState(DMA_HandleTypeDef *hdma)
DMA_Stream_TypeDef * Instance
HAL_DMA_CallbackIDTypeDef
HAL DMA Error Code structure definition.
struct __DMA_HandleTypeDef DMA_HandleTypeDef
DMA handle Structure definition.
HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
@ HAL_DMA_XFER_M1CPLT_CB_ID
HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
@ HAL_DMA_XFER_CPLT_CB_ID
void(* XferCpltCallback)(struct __DMA_HandleTypeDef *hdma)
This file contains HAL common defines, enumeration, macros and structures definitions.
HAL_StatusTypeDef HAL_DMA_Init(DMA_HandleTypeDef *hdma)
HAL_StatusTypeDef HAL_DMA_DeInit(DMA_HandleTypeDef *hdma)
@ HAL_DMA_XFER_HALFCPLT_CB_ID
void(* XferM1HalfCpltCallback)(struct __DMA_HandleTypeDef *hdma)
uint32_t HAL_DMA_GetError(DMA_HandleTypeDef *hdma)
Header file of DMA HAL extension module.
HAL_StatusTypeDef HAL_DMA_Start(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
HAL_DMA_StateTypeDef
HAL DMA State structures definition.
HAL_DMA_LevelCompleteTypeDef
HAL DMA Error Code structure definition.
void HAL_DMA_IRQHandler(DMA_HandleTypeDef *hdma)
void(* XferErrorCallback)(struct __DMA_HandleTypeDef *hdma)
HAL_StatusTypeDef HAL_DMA_RegisterCallback(DMA_HandleTypeDef *hdma, HAL_DMA_CallbackIDTypeDef CallbackID, void(*pCallback)(DMA_HandleTypeDef *_hdma))