dma.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /**
  2. ******************************************************************************
  3. * File Name : dma.c
  4. * Description : This file provides code for the configuration
  5. * of all the requested memory to memory DMA transfers.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under Ultimate Liberty license
  13. * SLA0044, the "License"; You may not use this file except in compliance with
  14. * the License. You may obtain a copy of the License at:
  15. * www.st.com/SLA0044
  16. *
  17. ******************************************************************************
  18. */
  19. /* Includes ------------------------------------------------------------------*/
  20. #include "dma.h"
  21. /* USER CODE BEGIN 0 */
  22. /* USER CODE END 0 */
  23. /*----------------------------------------------------------------------------*/
  24. /* Configure DMA */
  25. /*----------------------------------------------------------------------------*/
  26. /* USER CODE BEGIN 1 */
  27. /* USER CODE END 1 */
  28. DMA_HandleTypeDef hdma_memtomem_dma2_stream0;
  29. DMA_HandleTypeDef hdma_memtomem_dma2_stream1;
  30. /**
  31. * Enable DMA controller clock
  32. * Configure DMA for memory to memory transfers
  33. * hdma_memtomem_dma2_stream0
  34. * hdma_memtomem_dma2_stream1
  35. */
  36. void MX_DMA_Init(void)
  37. {
  38. /* DMA controller clock enable */
  39. __HAL_RCC_DMA2_CLK_ENABLE();
  40. /* Configure DMA request hdma_memtomem_dma2_stream0 on DMA2_Stream0 */
  41. hdma_memtomem_dma2_stream0.Instance = DMA2_Stream0;
  42. hdma_memtomem_dma2_stream0.Init.Channel = DMA_CHANNEL_0;
  43. hdma_memtomem_dma2_stream0.Init.Direction = DMA_MEMORY_TO_MEMORY;
  44. hdma_memtomem_dma2_stream0.Init.PeriphInc = DMA_PINC_ENABLE;
  45. hdma_memtomem_dma2_stream0.Init.MemInc = DMA_MINC_DISABLE;
  46. hdma_memtomem_dma2_stream0.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
  47. hdma_memtomem_dma2_stream0.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
  48. hdma_memtomem_dma2_stream0.Init.Mode = DMA_NORMAL;
  49. hdma_memtomem_dma2_stream0.Init.Priority = DMA_PRIORITY_LOW;
  50. hdma_memtomem_dma2_stream0.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
  51. hdma_memtomem_dma2_stream0.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
  52. hdma_memtomem_dma2_stream0.Init.MemBurst = DMA_MBURST_INC8;
  53. hdma_memtomem_dma2_stream0.Init.PeriphBurst = DMA_PBURST_INC4;
  54. if (HAL_DMA_Init(&hdma_memtomem_dma2_stream0) != HAL_OK)
  55. {
  56. Error_Handler();
  57. }
  58. /* Configure DMA request hdma_memtomem_dma2_stream1 on DMA2_Stream1 */
  59. hdma_memtomem_dma2_stream1.Instance = DMA2_Stream1;
  60. hdma_memtomem_dma2_stream1.Init.Channel = DMA_CHANNEL_0;
  61. hdma_memtomem_dma2_stream1.Init.Direction = DMA_MEMORY_TO_MEMORY;
  62. hdma_memtomem_dma2_stream1.Init.PeriphInc = DMA_PINC_DISABLE;
  63. hdma_memtomem_dma2_stream1.Init.MemInc = DMA_MINC_ENABLE;
  64. hdma_memtomem_dma2_stream1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
  65. hdma_memtomem_dma2_stream1.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
  66. hdma_memtomem_dma2_stream1.Init.Mode = DMA_NORMAL;
  67. hdma_memtomem_dma2_stream1.Init.Priority = DMA_PRIORITY_LOW;
  68. hdma_memtomem_dma2_stream1.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
  69. hdma_memtomem_dma2_stream1.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
  70. hdma_memtomem_dma2_stream1.Init.MemBurst = DMA_MBURST_INC4;
  71. hdma_memtomem_dma2_stream1.Init.PeriphBurst = DMA_PBURST_INC8;
  72. if (HAL_DMA_Init(&hdma_memtomem_dma2_stream1) != HAL_OK)
  73. {
  74. Error_Handler();
  75. }
  76. /* DMA interrupt init */
  77. /* DMA2_Stream3_IRQn interrupt configuration */
  78. HAL_NVIC_SetPriority(DMA2_Stream3_IRQn, 2, 0);
  79. HAL_NVIC_EnableIRQ(DMA2_Stream3_IRQn);
  80. /* DMA2_Stream6_IRQn interrupt configuration */
  81. HAL_NVIC_SetPriority(DMA2_Stream6_IRQn, 2, 0);
  82. HAL_NVIC_EnableIRQ(DMA2_Stream6_IRQn);
  83. }
  84. /* USER CODE BEGIN 2 */
  85. /* USER CODE END 2 */
  86. /**
  87. * @}
  88. */
  89. /**
  90. * @}
  91. */
  92. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/