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