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 * Copyright (c) 2017 STMicroelectronics. 10 * All rights reserved. 11 * 12 * This software is licensed under terms that can be found in the LICENSE file 13 * in the root directory of this software component. 14 * If no LICENSE file comes with this software, it is provided AS-IS. 15 * 16 ****************************************************************************** 17 */ 18 19 /* Define to prevent recursive inclusion -------------------------------------*/ 20 #ifndef STM32L4xx_HAL_DMA_EX_H 21 #define STM32L4xx_HAL_DMA_EX_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 #if defined(DMAMUX1) 28 29 /* Includes ------------------------------------------------------------------*/ 30 #include "stm32l4xx_hal_def.h" 31 32 /** @addtogroup STM32L4xx_HAL_Driver 33 * @{ 34 */ 35 36 /** @addtogroup DMAEx 37 * @{ 38 */ 39 40 /* Exported types ------------------------------------------------------------*/ 41 /** @defgroup DMAEx_Exported_Types DMAEx Exported Types 42 * @{ 43 */ 44 45 /** 46 * @brief HAL DMA Synchro definition 47 */ 48 49 50 /** 51 * @brief HAL DMAMUX Synchronization configuration structure definition 52 */ 53 typedef struct 54 { 55 uint32_t SyncSignalID; /*!< Specifies the synchronization signal gating the DMA request in periodic mode. 56 This parameter can be a value of @ref DMAEx_DMAMUX_SyncSignalID_selection */ 57 58 uint32_t SyncPolarity; /*!< Specifies the polarity of the signal on which the DMA request is synchronized. 59 This parameter can be a value of @ref DMAEx_DMAMUX_SyncPolarity_selection */ 60 61 FunctionalState SyncEnable; /*!< Specifies if the synchronization shall be enabled or disabled 62 This parameter can take the value ENABLE or DISABLE*/ 63 64 65 FunctionalState EventEnable; /*!< Specifies if an event shall be generated once the RequestNumber is reached. 66 This parameter can take the value ENABLE or DISABLE */ 67 68 uint32_t RequestNumber; /*!< Specifies the number of DMA request that will be authorized after a sync event 69 This parameter must be a number between Min_Data = 1 and Max_Data = 32 */ 70 71 72 }HAL_DMA_MuxSyncConfigTypeDef; 73 74 75 /** 76 * @brief HAL DMAMUX request generator parameters structure definition 77 */ 78 typedef struct 79 { 80 uint32_t SignalID; /*!< Specifies the ID of the signal used for DMAMUX request generator 81 This parameter can be a value of @ref DMAEx_DMAMUX_SignalGeneratorID_selection */ 82 83 uint32_t Polarity; /*!< Specifies the polarity of the signal on which the request is generated. 84 This parameter can be a value of @ref DMAEx_DMAMUX_RequestGeneneratorPolarity_selection */ 85 86 uint32_t RequestNumber; /*!< Specifies the number of DMA request that will be generated after a signal event 87 This parameter must be a number between Min_Data = 1 and Max_Data = 32 */ 88 89 }HAL_DMA_MuxRequestGeneratorConfigTypeDef; 90 91 /** 92 * @} 93 */ 94 95 /* Exported constants --------------------------------------------------------*/ 96 /** @defgroup DMAEx_Exported_Constants DMAEx Exported Constants 97 * @{ 98 */ 99 100 /** @defgroup DMAEx_DMAMUX_SyncSignalID_selection DMAMUX SyncSignalID selection 101 * @{ 102 */ 103 #define HAL_DMAMUX1_SYNC_EXTI0 0U /*!< Synchronization Signal is EXTI0 IT */ 104 #define HAL_DMAMUX1_SYNC_EXTI1 1U /*!< Synchronization Signal is EXTI1 IT */ 105 #define HAL_DMAMUX1_SYNC_EXTI2 2U /*!< Synchronization Signal is EXTI2 IT */ 106 #define HAL_DMAMUX1_SYNC_EXTI3 3U /*!< Synchronization Signal is EXTI3 IT */ 107 #define HAL_DMAMUX1_SYNC_EXTI4 4U /*!< Synchronization Signal is EXTI4 IT */ 108 #define HAL_DMAMUX1_SYNC_EXTI5 5U /*!< Synchronization Signal is EXTI5 IT */ 109 #define HAL_DMAMUX1_SYNC_EXTI6 6U /*!< Synchronization Signal is EXTI6 IT */ 110 #define HAL_DMAMUX1_SYNC_EXTI7 7U /*!< Synchronization Signal is EXTI7 IT */ 111 #define HAL_DMAMUX1_SYNC_EXTI8 8U /*!< Synchronization Signal is EXTI8 IT */ 112 #define HAL_DMAMUX1_SYNC_EXTI9 9U /*!< Synchronization Signal is EXTI9 IT */ 113 #define HAL_DMAMUX1_SYNC_EXTI10 10U /*!< Synchronization Signal is EXTI10 IT */ 114 #define HAL_DMAMUX1_SYNC_EXTI11 11U /*!< Synchronization Signal is EXTI11 IT */ 115 #define HAL_DMAMUX1_SYNC_EXTI12 12U /*!< Synchronization Signal is EXTI12 IT */ 116 #define HAL_DMAMUX1_SYNC_EXTI13 13U /*!< Synchronization Signal is EXTI13 IT */ 117 #define HAL_DMAMUX1_SYNC_EXTI14 14U /*!< Synchronization Signal is EXTI14 IT */ 118 #define HAL_DMAMUX1_SYNC_EXTI15 15U /*!< Synchronization Signal is EXTI15 IT */ 119 #define HAL_DMAMUX1_SYNC_DMAMUX1_CH0_EVT 16U /*!< Synchronization Signal is DMAMUX1 Channel0 Event */ 120 #define HAL_DMAMUX1_SYNC_DMAMUX1_CH1_EVT 17U /*!< Synchronization Signal is DMAMUX1 Channel1 Event */ 121 #define HAL_DMAMUX1_SYNC_DMAMUX1_CH2_EVT 18U /*!< Synchronization Signal is DMAMUX1 Channel2 Event */ 122 #define HAL_DMAMUX1_SYNC_DMAMUX1_CH3_EVT 19U /*!< Synchronization Signal is DMAMUX1 Channel3 Event */ 123 #define HAL_DMAMUX1_SYNC_LPTIM1_OUT 20U /*!< Synchronization Signal is LPTIM1 OUT */ 124 #define HAL_DMAMUX1_SYNC_LPTIM2_OUT 21U /*!< Synchronization Signal is LPTIM2 OUT */ 125 #if defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx) 126 #define HAL_DMAMUX1_SYNC_DSI_TE 22U /*!< Synchronization Signal is DSI Tearing Effect */ 127 #define HAL_DMAMUX1_SYNC_DSI_EOT 23U /*!< Synchronization Signal is DSI End of refresh */ 128 #endif /* STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */ 129 #define HAL_DMAMUX1_SYNC_DMA2D_EOT 24U /*!< Synchronization Signal is DMA2D End of Transfer */ 130 #define HAL_DMAMUX1_SYNC_LDTC_IT 25U /*!< Synchronization Signal is LDTC IT */ 131 132 /** 133 * @} 134 */ 135 136 /** @defgroup DMAEx_DMAMUX_SyncPolarity_selection DMAMUX SyncPolarity selection 137 * @{ 138 */ 139 #define HAL_DMAMUX_SYNC_NO_EVENT 0U /*!< block synchronization events */ 140 #define HAL_DMAMUX_SYNC_RISING DMAMUX_CxCR_SPOL_0 /*!< synchronize with rising edge events */ 141 #define HAL_DMAMUX_SYNC_FALLING DMAMUX_CxCR_SPOL_1 /*!< synchronize with falling edge events */ 142 #define HAL_DMAMUX_SYNC_RISING_FALLING DMAMUX_CxCR_SPOL /*!< synchronize with rising and falling edge events */ 143 144 /** 145 * @} 146 */ 147 148 /** @defgroup DMAEx_DMAMUX_SignalGeneratorID_selection DMAMUX SignalGeneratorID selection 149 * @{ 150 */ 151 152 #define HAL_DMAMUX1_REQ_GEN_EXTI0 0U /*!< Request generator Signal is EXTI0 IT */ 153 #define HAL_DMAMUX1_REQ_GEN_EXTI1 1U /*!< Request generator Signal is EXTI1 IT */ 154 #define HAL_DMAMUX1_REQ_GEN_EXTI2 2U /*!< Request generator Signal is EXTI2 IT */ 155 #define HAL_DMAMUX1_REQ_GEN_EXTI3 3U /*!< Request generator Signal is EXTI3 IT */ 156 #define HAL_DMAMUX1_REQ_GEN_EXTI4 4U /*!< Request generator Signal is EXTI4 IT */ 157 #define HAL_DMAMUX1_REQ_GEN_EXTI5 5U /*!< Request generator Signal is EXTI5 IT */ 158 #define HAL_DMAMUX1_REQ_GEN_EXTI6 6U /*!< Request generator Signal is EXTI6 IT */ 159 #define HAL_DMAMUX1_REQ_GEN_EXTI7 7U /*!< Request generator Signal is EXTI7 IT */ 160 #define HAL_DMAMUX1_REQ_GEN_EXTI8 8U /*!< Request generator Signal is EXTI8 IT */ 161 #define HAL_DMAMUX1_REQ_GEN_EXTI9 9U /*!< Request generator Signal is EXTI9 IT */ 162 #define HAL_DMAMUX1_REQ_GEN_EXTI10 10U /*!< Request generator Signal is EXTI10 IT */ 163 #define HAL_DMAMUX1_REQ_GEN_EXTI11 11U /*!< Request generator Signal is EXTI11 IT */ 164 #define HAL_DMAMUX1_REQ_GEN_EXTI12 12U /*!< Request generator Signal is EXTI12 IT */ 165 #define HAL_DMAMUX1_REQ_GEN_EXTI13 13U /*!< Request generator Signal is EXTI13 IT */ 166 #define HAL_DMAMUX1_REQ_GEN_EXTI14 14U /*!< Request generator Signal is EXTI14 IT */ 167 #define HAL_DMAMUX1_REQ_GEN_EXTI15 15U /*!< Request generator Signal is EXTI15 IT */ 168 #define HAL_DMAMUX1_REQ_GEN_DMAMUX1_CH0_EVT 16U /*!< Request generator Signal is DMAMUX1 Channel0 Event */ 169 #define HAL_DMAMUX1_REQ_GEN_DMAMUX1_CH1_EVT 17U /*!< Request generator Signal is DMAMUX1 Channel1 Event */ 170 #define HAL_DMAMUX1_REQ_GEN_DMAMUX1_CH2_EVT 18U /*!< Request generator Signal is DMAMUX1 Channel2 Event */ 171 #define HAL_DMAMUX1_REQ_GEN_DMAMUX1_CH3_EVT 19U /*!< Request generator Signal is DMAMUX1 Channel3 Event */ 172 #define HAL_DMAMUX1_REQ_GEN_LPTIM1_OUT 20U /*!< Request generator Signal is LPTIM1 OUT */ 173 #define HAL_DMAMUX1_REQ_GEN_LPTIM2_OUT 21U /*!< Request generator Signal is LPTIM2 OUT */ 174 #if defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx) 175 #define HAL_DMAMUX1_REQ_GEN_DSI_TE 22U /*!< Request generator Signal is DSI Tearing Effect */ 176 #define HAL_DMAMUX1_REQ_GEN_DSI_EOT 23U /*!< Request generator Signal is DSI End of refresh */ 177 #endif /* STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */ 178 #define HAL_DMAMUX1_REQ_GEN_DMA2D_EOT 24U /*!< Request generator Signal is DMA2D End of Transfer */ 179 #define HAL_DMAMUX1_REQ_GEN_LTDC_IT 25U /*!< Request generator Signal is LTDC IT */ 180 181 /** 182 * @} 183 */ 184 185 /** @defgroup DMAEx_DMAMUX_RequestGeneneratorPolarity_selection DMAMUX RequestGeneneratorPolarity selection 186 * @{ 187 */ 188 #define HAL_DMAMUX_REQ_GEN_NO_EVENT 0U /*!< block request generator events */ 189 #define HAL_DMAMUX_REQ_GEN_RISING DMAMUX_RGxCR_GPOL_0 /*!< generate request on rising edge events */ 190 #define HAL_DMAMUX_REQ_GEN_FALLING DMAMUX_RGxCR_GPOL_1 /*!< generate request on falling edge events */ 191 #define HAL_DMAMUX_REQ_GEN_RISING_FALLING DMAMUX_RGxCR_GPOL /*!< generate request on rising and falling edge events */ 192 193 /** 194 * @} 195 */ 196 197 /** 198 * @} 199 */ 200 201 /* Exported macro ------------------------------------------------------------*/ 202 203 /* Exported functions --------------------------------------------------------*/ 204 /** @addtogroup DMAEx_Exported_Functions 205 * @{ 206 */ 207 208 /* IO operation functions *****************************************************/ 209 /** @addtogroup DMAEx_Exported_Functions_Group1 210 * @{ 211 */ 212 213 /* ------------------------- REQUEST -----------------------------------------*/ 214 HAL_StatusTypeDef HAL_DMAEx_ConfigMuxRequestGenerator (DMA_HandleTypeDef *hdma, 215 HAL_DMA_MuxRequestGeneratorConfigTypeDef *pRequestGeneratorConfig); 216 HAL_StatusTypeDef HAL_DMAEx_EnableMuxRequestGenerator (DMA_HandleTypeDef *hdma); 217 HAL_StatusTypeDef HAL_DMAEx_DisableMuxRequestGenerator (DMA_HandleTypeDef *hdma); 218 /* -------------------------------------------------------------------------- */ 219 220 /* ------------------------- SYNCHRO -----------------------------------------*/ 221 HAL_StatusTypeDef HAL_DMAEx_ConfigMuxSync(DMA_HandleTypeDef *hdma, HAL_DMA_MuxSyncConfigTypeDef *pSyncConfig); 222 /* -------------------------------------------------------------------------- */ 223 224 void HAL_DMAEx_MUX_IRQHandler(DMA_HandleTypeDef *hdma); 225 226 /** 227 * @} 228 */ 229 230 /** 231 * @} 232 */ 233 234 235 /* Private defines -----------------------------------------------------------*/ 236 /* Private macros ------------------------------------------------------------*/ 237 /** @defgroup DMAEx_Private_Macros DMAEx Private Macros 238 * @brief DMAEx private macros 239 * @{ 240 */ 241 242 #define IS_DMAMUX_SYNC_SIGNAL_ID(SIGNAL_ID) ((SIGNAL_ID) <= HAL_DMAMUX1_SYNC_LDTC_IT) 243 244 #define IS_DMAMUX_SYNC_REQUEST_NUMBER(REQUEST_NUMBER) (((REQUEST_NUMBER) > 0U) && ((REQUEST_NUMBER) <= 32U)) 245 246 #define IS_DMAMUX_SYNC_POLARITY(POLARITY) (((POLARITY) == HAL_DMAMUX_SYNC_NO_EVENT) || \ 247 ((POLARITY) == HAL_DMAMUX_SYNC_RISING) || \ 248 ((POLARITY) == HAL_DMAMUX_SYNC_FALLING) || \ 249 ((POLARITY) == HAL_DMAMUX_SYNC_RISING_FALLING)) 250 251 #define IS_DMAMUX_SYNC_STATE(SYNC) (((SYNC) == DISABLE) || ((SYNC) == ENABLE)) 252 253 #define IS_DMAMUX_SYNC_EVENT(EVENT) (((EVENT) == DISABLE) || \ 254 ((EVENT) == ENABLE)) 255 256 #define IS_DMAMUX_REQUEST_GEN_SIGNAL_ID(SIGNAL_ID) ((SIGNAL_ID) <= HAL_DMAMUX1_REQ_GEN_LTDC_IT) 257 258 #define IS_DMAMUX_REQUEST_GEN_REQUEST_NUMBER(REQUEST_NUMBER) (((REQUEST_NUMBER) > 0U) && ((REQUEST_NUMBER) <= 32U)) 259 260 #define IS_DMAMUX_REQUEST_GEN_POLARITY(POLARITY) (((POLARITY) == HAL_DMAMUX_REQ_GEN_NO_EVENT) || \ 261 ((POLARITY) == HAL_DMAMUX_REQ_GEN_RISING) || \ 262 ((POLARITY) == HAL_DMAMUX_REQ_GEN_FALLING) || \ 263 ((POLARITY) == HAL_DMAMUX_REQ_GEN_RISING_FALLING)) 264 265 /** 266 * @} 267 */ 268 269 270 /** 271 * @} 272 */ 273 274 /** 275 * @} 276 */ 277 278 #endif /* DMAMUX1 */ 279 280 #ifdef __cplusplus 281 } 282 #endif 283 284 #endif /* STM32L4xx_HAL_DMA_H */ 285