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