dma.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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_ENABLE;
  46. hdma_memtomem_dma2_stream0.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
  47. hdma_memtomem_dma2_stream0.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
  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_DISABLE;
  51. if (HAL_DMA_Init(&hdma_memtomem_dma2_stream0) != HAL_OK)
  52. {
  53. Error_Handler();
  54. }
  55. /* Configure DMA request hdma_memtomem_dma2_stream1 on DMA2_Stream1 */
  56. hdma_memtomem_dma2_stream1.Instance = DMA2_Stream1;
  57. hdma_memtomem_dma2_stream1.Init.Channel = DMA_CHANNEL_0;
  58. hdma_memtomem_dma2_stream1.Init.Direction = DMA_MEMORY_TO_MEMORY;
  59. hdma_memtomem_dma2_stream1.Init.PeriphInc = DMA_PINC_ENABLE;
  60. hdma_memtomem_dma2_stream1.Init.MemInc = DMA_MINC_ENABLE;
  61. hdma_memtomem_dma2_stream1.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
  62. hdma_memtomem_dma2_stream1.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
  63. hdma_memtomem_dma2_stream1.Init.Mode = DMA_NORMAL;
  64. hdma_memtomem_dma2_stream1.Init.Priority = DMA_PRIORITY_LOW;
  65. hdma_memtomem_dma2_stream1.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
  66. if (HAL_DMA_Init(&hdma_memtomem_dma2_stream1) != HAL_OK)
  67. {
  68. Error_Handler();
  69. }
  70. /* DMA interrupt init */
  71. /* DMA2_Stream3_IRQn interrupt configuration */
  72. HAL_NVIC_SetPriority(DMA2_Stream3_IRQn, 2, 0);
  73. HAL_NVIC_EnableIRQ(DMA2_Stream3_IRQn);
  74. /* DMA2_Stream6_IRQn interrupt configuration */
  75. HAL_NVIC_SetPriority(DMA2_Stream6_IRQn, 2, 0);
  76. HAL_NVIC_EnableIRQ(DMA2_Stream6_IRQn);
  77. }
  78. /* USER CODE BEGIN 2 */
  79. /* USER CODE END 2 */
  80. /**
  81. * @}
  82. */
  83. /**
  84. * @}
  85. */
  86. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/