stm32l4xx_hal_dma_ex.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_hal_dma_ex.h
  4. * @author MCD Application Team
  5. * @brief Header file of DMA HAL extension module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. /* Define to prevent recursive inclusion -------------------------------------*/
  36. #ifndef __STM32L4xx_HAL_DMA_EX_H
  37. #define __STM32L4xx_HAL_DMA_EX_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. #if defined(DMAMUX1)
  42. /* Includes ------------------------------------------------------------------*/
  43. #include "stm32l4xx_hal_def.h"
  44. /** @addtogroup STM32L4xx_HAL_Driver
  45. * @{
  46. */
  47. /** @addtogroup DMAEx
  48. * @{
  49. */
  50. /* Exported types ------------------------------------------------------------*/
  51. /** @defgroup DMAEx_Exported_Types DMAEx Exported Types
  52. * @{
  53. */
  54. /**
  55. * @brief HAL DMA Synchro definition
  56. */
  57. /**
  58. * @brief HAL DMAMUX Synchronization configuration structure definition
  59. */
  60. typedef struct
  61. {
  62. uint32_t SyncSignalID; /*!< Specifies the synchronization signal gating the DMA request in periodic mode.
  63. This parameter can be a value of @ref DMAEx_DMAMUX_SyncSignalID_selection */
  64. uint32_t SyncPolarity; /*!< Specifies the polarity of the signal on which the DMA request is synchronized.
  65. This parameter can be a value of @ref DMAEx_DMAMUX_SyncPolarity_selection */
  66. FunctionalState SyncEnable; /*!< Specifies if the synchronization shall be enabled or disabled
  67. This parameter can take the value ENABLE or DISABLE*/
  68. FunctionalState EventEnable; /*!< Specifies if an event shall be generated once the RequestNumber is reached.
  69. This parameter can take the value ENABLE or DISABLE */
  70. uint32_t RequestNumber; /*!< Specifies the number of DMA request that will be authorized after a sync event
  71. This parameter must be a number between Min_Data = 1 and Max_Data = 32 */
  72. }HAL_DMA_MuxSyncConfigTypeDef;
  73. /**
  74. * @brief HAL DMAMUX request generator parameters structure definition
  75. */
  76. typedef struct
  77. {
  78. uint32_t SignalID; /*!< Specifies the ID of the signal used for DMAMUX request generator
  79. This parameter can be a value of @ref DMAEx_DMAMUX_SignalGeneratorID_selection */
  80. uint32_t Polarity; /*!< Specifies the polarity of the signal on which the request is generated.
  81. This parameter can be a value of @ref DMAEx_DMAMUX_RequestGeneneratorPolarity_selection */
  82. uint32_t RequestNumber; /*!< Specifies the number of DMA request that will be generated after a signal event
  83. This parameter must be a number between Min_Data = 1 and Max_Data = 32 */
  84. }HAL_DMA_MuxRequestGeneratorConfigTypeDef;
  85. /**
  86. * @}
  87. */
  88. /* Exported constants --------------------------------------------------------*/
  89. /** @defgroup DMAEx_Exported_Constants DMAEx Exported Constants
  90. * @{
  91. */
  92. /** @defgroup DMAEx_DMAMUX_SyncSignalID_selection DMAMUX SyncSignalID selection
  93. * @{
  94. */
  95. #define HAL_DMAMUX1_SYNC_EXTI0 0U /*!< Synchronization Signal is EXTI0 IT */
  96. #define HAL_DMAMUX1_SYNC_EXTI1 1U /*!< Synchronization Signal is EXTI1 IT */
  97. #define HAL_DMAMUX1_SYNC_EXTI2 2U /*!< Synchronization Signal is EXTI2 IT */
  98. #define HAL_DMAMUX1_SYNC_EXTI3 3U /*!< Synchronization Signal is EXTI3 IT */
  99. #define HAL_DMAMUX1_SYNC_EXTI4 4U /*!< Synchronization Signal is EXTI4 IT */
  100. #define HAL_DMAMUX1_SYNC_EXTI5 5U /*!< Synchronization Signal is EXTI5 IT */
  101. #define HAL_DMAMUX1_SYNC_EXTI6 6U /*!< Synchronization Signal is EXTI6 IT */
  102. #define HAL_DMAMUX1_SYNC_EXTI7 7U /*!< Synchronization Signal is EXTI7 IT */
  103. #define HAL_DMAMUX1_SYNC_EXTI8 8U /*!< Synchronization Signal is EXTI8 IT */
  104. #define HAL_DMAMUX1_SYNC_EXTI9 9U /*!< Synchronization Signal is EXTI9 IT */
  105. #define HAL_DMAMUX1_SYNC_EXTI10 10U /*!< Synchronization Signal is EXTI10 IT */
  106. #define HAL_DMAMUX1_SYNC_EXTI11 11U /*!< Synchronization Signal is EXTI11 IT */
  107. #define HAL_DMAMUX1_SYNC_EXTI12 12U /*!< Synchronization Signal is EXTI12 IT */
  108. #define HAL_DMAMUX1_SYNC_EXTI13 13U /*!< Synchronization Signal is EXTI13 IT */
  109. #define HAL_DMAMUX1_SYNC_EXTI14 14U /*!< Synchronization Signal is EXTI14 IT */
  110. #define HAL_DMAMUX1_SYNC_EXTI15 15U /*!< Synchronization Signal is EXTI15 IT */
  111. #define HAL_DMAMUX1_SYNC_DMAMUX1_CH0_EVT 16U /*!< Synchronization Signal is DMAMUX1 Channel0 Event */
  112. #define HAL_DMAMUX1_SYNC_DMAMUX1_CH1_EVT 17U /*!< Synchronization Signal is DMAMUX1 Channel1 Event */
  113. #define HAL_DMAMUX1_SYNC_DMAMUX1_CH2_EVT 18U /*!< Synchronization Signal is DMAMUX1 Channel2 Event */
  114. #define HAL_DMAMUX1_SYNC_DMAMUX1_CH3_EVT 19U /*!< Synchronization Signal is DMAMUX1 Channel3 Event */
  115. #define HAL_DMAMUX1_SYNC_LPTIM1_OUT 20U /*!< Synchronization Signal is LPTIM1 OUT */
  116. #define HAL_DMAMUX1_SYNC_LPTIM2_OUT 21U /*!< Synchronization Signal is LPTIM2 OUT */
  117. #define HAL_DMAMUX1_SYNC_DSI_TE 22U /*!< Synchronization Signal is DSI Tearing Effect */
  118. #define HAL_DMAMUX1_SYNC_DSI_EOT 23U /*!< Synchronization Signal is DSI End of refresh */
  119. #define HAL_DMAMUX1_SYNC_DMA2D_EOT 24U /*!< Synchronization Signal is DMA2D End of Transfer */
  120. #define HAL_DMAMUX1_SYNC_LDTC_IT 25U /*!< Synchronization Signal is LDTC IT */
  121. /**
  122. * @}
  123. */
  124. /** @defgroup DMAEx_DMAMUX_SyncPolarity_selection DMAMUX SyncPolarity selection
  125. * @{
  126. */
  127. #define HAL_DMAMUX_SYNC_NO_EVENT 0U /*!< block synchronization events */
  128. #define HAL_DMAMUX_SYNC_RISING ((uint32_t)DMAMUX_CxCR_SPOL_0) /*!< synchronize with rising edge events */
  129. #define HAL_DMAMUX_SYNC_FALLING ((uint32_t)DMAMUX_CxCR_SPOL_1) /*!< synchronize with falling edge events */
  130. #define HAL_DMAMUX_SYNC_RISING_FALLING ((uint32_t)DMAMUX_CxCR_SPOL) /*!< synchronize with rising and falling edge events */
  131. /**
  132. * @}
  133. */
  134. /** @defgroup DMAEx_DMAMUX_SignalGeneratorID_selection DMAMUX SignalGeneratorID selection
  135. * @{
  136. */
  137. #define HAL_DMAMUX1_REQUEST_GEN_EXTI0 0U /*!< Request generator Signal is EXTI0 IT */
  138. #define HAL_DMAMUX1_REQUEST_GEN_EXTI1 1U /*!< Request generator Signal is EXTI1 IT */
  139. #define HAL_DMAMUX1_REQUEST_GEN_EXTI2 2U /*!< Request generator Signal is EXTI2 IT */
  140. #define HAL_DMAMUX1_REQUEST_GEN_EXTI3 3U /*!< Request generator Signal is EXTI3 IT */
  141. #define HAL_DMAMUX1_REQUEST_GEN_EXTI4 4U /*!< Request generator Signal is EXTI4 IT */
  142. #define HAL_DMAMUX1_REQUEST_GEN_EXTI5 5U /*!< Request generator Signal is EXTI5 IT */
  143. #define HAL_DMAMUX1_REQUEST_GEN_EXTI6 6U /*!< Request generator Signal is EXTI6 IT */
  144. #define HAL_DMAMUX1_REQUEST_GEN_EXTI7 7U /*!< Request generator Signal is EXTI7 IT */
  145. #define HAL_DMAMUX1_REQUEST_GEN_EXTI8 8U /*!< Request generator Signal is EXTI8 IT */
  146. #define HAL_DMAMUX1_REQUEST_GEN_EXTI9 9U /*!< Request generator Signal is EXTI9 IT */
  147. #define HAL_DMAMUX1_REQUEST_GEN_EXTI10 10U /*!< Request generator Signal is EXTI10 IT */
  148. #define HAL_DMAMUX1_REQUEST_GEN_EXTI11 11U /*!< Request generator Signal is EXTI11 IT */
  149. #define HAL_DMAMUX1_REQUEST_GEN_EXTI12 12U /*!< Request generator Signal is EXTI12 IT */
  150. #define HAL_DMAMUX1_REQUEST_GEN_EXTI13 13U /*!< Request generator Signal is EXTI13 IT */
  151. #define HAL_DMAMUX1_REQUEST_GEN_EXTI14 14U /*!< Request generator Signal is EXTI14 IT */
  152. #define HAL_DMAMUX1_REQUEST_GEN_EXTI15 15U /*!< Request generator Signal is EXTI15 IT */
  153. #define HAL_DMAMUX1_REQUEST_GEN_DMAMUX1_CH0_EVT 16U /*!< Request generator Signal is DMAMUX1 Channel0 Event */
  154. #define HAL_DMAMUX1_REQUEST_GEN_DMAMUX1_CH1_EVT 17U /*!< Request generator Signal is DMAMUX1 Channel1 Event */
  155. #define HAL_DMAMUX1_REQUEST_GEN_DMAMUX1_CH2_EVT 18U /*!< Request generator Signal is DMAMUX1 Channel2 Event */
  156. #define HAL_DMAMUX1_REQUEST_GEN_DMAMUX1_CH3_EVT 19U /*!< Request generator Signal is DMAMUX1 Channel3 Event */
  157. #define HAL_DMAMUX1_REQUEST_GEN_LPTIM1_OUT 20U /*!< Request generator Signal is LPTIM1 OUT */
  158. #define HAL_DMAMUX1_REQUEST_GEN_LPTIM2_OUT 21U /*!< Request generator Signal is LPTIM2 OUT */
  159. #define HAL_DMAMUX1_REQUEST_GEN_DSI_TE 22U /*!< Request generator Signal is DSI Tearing Effect */
  160. #define HAL_DMAMUX1_REQUEST_GEN_DSI_EOT 23U /*!< Request generator Signal is DSI End of refresh */
  161. #define HAL_DMAMUX1_REQUEST_GEN_DMA2D_EOT 24U /*!< Request generator Signal is DMA2D End of Transfer */
  162. #define HAL_DMAMUX1_REQUEST_GEN_LTDC_IT 25U /*!< Request generator Signal is LTDC IT */
  163. /**
  164. * @}
  165. */
  166. /** @defgroup DMAEx_DMAMUX_RequestGeneneratorPolarity_selection DMAMUX RequestGeneneratorPolarity selection
  167. * @{
  168. */
  169. #define HAL_DMAMUX_REQUEST_GEN_NO_EVENT 0U /*!< block request generator events */
  170. #define HAL_DMAMUX_REQUEST_GEN_RISING DMAMUX_RGxCR_GPOL_0 /*!< generate request on rising edge events */
  171. #define HAL_DMAMUX_REQUEST_GEN_FALLING DMAMUX_RGxCR_GPOL_1 /*!< generate request on falling edge events */
  172. #define HAL_DMAMUX_REQUEST_GEN_RISING_FALLING DMAMUX_RGxCR_GPOL /*!< generate request on rising and falling edge events */
  173. /**
  174. * @}
  175. */
  176. /**
  177. * @}
  178. */
  179. /* Exported macro ------------------------------------------------------------*/
  180. /* Exported functions --------------------------------------------------------*/
  181. /** @addtogroup DMAEx_Exported_Functions
  182. * @{
  183. */
  184. /* IO operation functions *****************************************************/
  185. /** @addtogroup DMAEx_Exported_Functions_Group1
  186. * @{
  187. */
  188. /* ------------------------- REQUEST -----------------------------------------*/
  189. HAL_StatusTypeDef HAL_DMAEx_ConfigMuxRequestGenerator (DMA_HandleTypeDef *hdma,
  190. HAL_DMA_MuxRequestGeneratorConfigTypeDef *pRequestGeneratorConfig);
  191. HAL_StatusTypeDef HAL_DMAEx_EnableMuxRequestGenerator (DMA_HandleTypeDef *hdma);
  192. HAL_StatusTypeDef HAL_DMAEx_DisableMuxRequestGenerator (DMA_HandleTypeDef *hdma);
  193. /* -------------------------------------------------------------------------- */
  194. /* ------------------------- SYNCHRO -----------------------------------------*/
  195. HAL_StatusTypeDef HAL_DMAEx_ConfigMuxSync(DMA_HandleTypeDef *hdma, HAL_DMA_MuxSyncConfigTypeDef *pSyncConfig);
  196. /* -------------------------------------------------------------------------- */
  197. void HAL_DMAEx_MUX_IRQHandler(DMA_HandleTypeDef *hdma);
  198. /**
  199. * @}
  200. */
  201. /**
  202. * @}
  203. */
  204. /* Private macros ------------------------------------------------------------*/
  205. /** @defgroup DMAEx_Private_Macros DMAEx Private Macros
  206. * @brief DMAEx private macros
  207. * @{
  208. */
  209. #define IS_DMAMUX_SYNC_SIGNAL_ID(SIGNAL_ID) ((SIGNAL_ID) <= HAL_DMAMUX1_SYNC_LDTC_IT)
  210. #define IS_DMAMUX_SYNC_REQUEST_NUMBER(REQUEST_NUMBER) (((REQUEST_NUMBER) > 0) && ((REQUEST_NUMBER) <= 32))
  211. #define IS_DMAMUX_SYNC_POLARITY(POLARITY) (((POLARITY) == HAL_DMAMUX_SYNC_NO_EVENT) || \
  212. ((POLARITY) == HAL_DMAMUX_SYNC_RISING) || \
  213. ((POLARITY) == HAL_DMAMUX_SYNC_FALLING) || \
  214. ((POLARITY) == HAL_DMAMUX_SYNC_RISING_FALLING))
  215. #define IS_DMAMUX_SYNC_STATE(SYNC) (((SYNC) == DISABLE) || ((SYNC) == ENABLE))
  216. #define IS_DMAMUX_SYNC_EVENT(EVENT) (((EVENT) == DISABLE) || \
  217. ((EVENT) == ENABLE))
  218. #define IS_DMAMUX_REQUEST_GEN_SIGNAL_ID(SIGNAL_ID) ((SIGNAL_ID) <= HAL_DMAMUX1_REQUEST_GEN_LTDC_IT)
  219. #define IS_DMAMUX_REQUEST_GEN_REQUEST_NUMBER(REQUEST_NUMBER) (((REQUEST_NUMBER) > 0) && ((REQUEST_NUMBER) <= 32))
  220. #define IS_DMAMUX_REQUEST_GEN_POLARITY(POLARITY) (((POLARITY) == HAL_DMAMUX_REQUEST_GEN_NO_EVENT) || \
  221. ((POLARITY) == HAL_DMAMUX_REQUEST_GEN_RISING) || \
  222. ((POLARITY) == HAL_DMAMUX_REQUEST_GEN_FALLING) || \
  223. ((POLARITY) == HAL_DMAMUX_REQUEST_GEN_RISING_FALLING))
  224. /**
  225. * @}
  226. */
  227. /**
  228. * @}
  229. */
  230. /**
  231. * @}
  232. */
  233. #endif /* DMAMUX1 */
  234. #ifdef __cplusplus
  235. }
  236. #endif
  237. #endif /* __STM32L4xx_HAL_DMA_H */
  238. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/