1 /**
2   ******************************************************************************
3   * @file    stm32wlxx_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) 2020 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 STM32WLxx_HAL_DMA_EX_H
21 #define STM32WLxx_HAL_DMA_EX_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32wlxx_hal_def.h"
29 #include "stm32wlxx_ll_dmamux.h"
30 
31 /** @addtogroup STM32WLxx_HAL_Driver
32   * @{
33   */
34 
35 /** @addtogroup DMAEx
36   * @{
37   */
38 
39 /* Exported types ------------------------------------------------------------*/
40 /** @defgroup DMAEx_Exported_Types DMAEx Exported Types
41   * @{
42   */
43 
44 /**
45   * @brief  HAL DMAMUX Synchronization configuration structure definition
46   */
47 typedef struct
48 {
49   uint32_t SyncSignalID;        /*!< Specifies the synchronization signal gating the DMA request in periodic mode.
50                                   This parameter can be a value of @ref DMAEx_DMAMUX_SyncSignalID_selection */
51 
52   uint32_t SyncPolarity;        /*!< Specifies the polarity of the signal on which the DMA request is synchronized.
53                                   This parameter can be a value of @ref DMAEx_DMAMUX_SyncPolarity_selection */
54 
55   FunctionalState SyncEnable;   /*!< Specifies if the synchronization shall be enabled or disabled
56                                   This parameter can take the value ENABLE or DISABLE */
57 
58   FunctionalState EventEnable;  /*!< Specifies if an event shall be generated once the RequestNumber is reached.
59                                   This parameter can take the value ENABLE or DISABLE */
60 
61   uint32_t RequestNumber;       /*!< Specifies the number of DMA request that will be authorized after a sync event
62                                   This parameter must be a number between Min_Data = 1 and Max_Data = 32 */
63 
64 
65 } HAL_DMA_MuxSyncConfigTypeDef;
66 
67 
68 /**
69   * @brief  HAL DMAMUX request generator parameters structure definition
70   */
71 typedef struct
72 {
73   uint32_t SignalID;            /*!< Specifies the ID of the signal used for DMAMUX request generator
74                                   This parameter can be a value of @ref DMAEx_DMAMUX_SignalGeneratorID_selection */
75 
76   uint32_t Polarity;            /*!< Specifies the polarity of the signal on which the request is generated.
77                                   This parameter can be a value of @ref DMAEx_DMAMUX_RequestGeneneratorPolarity_selection */
78 
79   uint32_t RequestNumber;       /*!< Specifies the number of DMA request that will be generated after a signal event
80                                   This parameter must be a number between Min_Data = 1 and Max_Data = 32 */
81 
82 } HAL_DMA_MuxRequestGeneratorConfigTypeDef;
83 
84 /**
85   * @}
86   */
87 
88 /* Exported constants --------------------------------------------------------*/
89 /** @defgroup DMAEx_Exported_Constants DMAEx Exported Constants
90   * @{
91   */
92 
93 /** @defgroup DMAEx_DMAMUX_SyncSignalID_selection DMAMUX SyncSignalID selection
94   * @{
95   */
96 #define HAL_DMAMUX1_SYNC_EXTI0            LL_DMAMUX_SYNC_EXTI_LINE0      /*!< Synchronization signal from EXTI Line0  */
97 #define HAL_DMAMUX1_SYNC_EXTI1            LL_DMAMUX_SYNC_EXTI_LINE1      /*!< Synchronization signal from EXTI Line1  */
98 #define HAL_DMAMUX1_SYNC_EXTI2            LL_DMAMUX_SYNC_EXTI_LINE2      /*!< Synchronization signal from EXTI Line2  */
99 #define HAL_DMAMUX1_SYNC_EXTI3            LL_DMAMUX_SYNC_EXTI_LINE3      /*!< Synchronization signal from EXTI Line3  */
100 #define HAL_DMAMUX1_SYNC_EXTI4            LL_DMAMUX_SYNC_EXTI_LINE4      /*!< Synchronization signal from EXTI Line4  */
101 #define HAL_DMAMUX1_SYNC_EXTI5            LL_DMAMUX_SYNC_EXTI_LINE5      /*!< Synchronization signal from EXTI Line5  */
102 #define HAL_DMAMUX1_SYNC_EXTI6            LL_DMAMUX_SYNC_EXTI_LINE6      /*!< Synchronization signal from EXTI Line6  */
103 #define HAL_DMAMUX1_SYNC_EXTI7            LL_DMAMUX_SYNC_EXTI_LINE7      /*!< Synchronization signal from EXTI Line7  */
104 #define HAL_DMAMUX1_SYNC_EXTI8            LL_DMAMUX_SYNC_EXTI_LINE8      /*!< Synchronization signal from EXTI Line8  */
105 #define HAL_DMAMUX1_SYNC_EXTI9            LL_DMAMUX_SYNC_EXTI_LINE9      /*!< Synchronization signal from EXTI Line9  */
106 #define HAL_DMAMUX1_SYNC_EXTI10           LL_DMAMUX_SYNC_EXTI_LINE10     /*!< Synchronization signal from EXTI Line10 */
107 #define HAL_DMAMUX1_SYNC_EXTI11           LL_DMAMUX_SYNC_EXTI_LINE11     /*!< Synchronization signal from EXTI Line11 */
108 #define HAL_DMAMUX1_SYNC_EXTI12           LL_DMAMUX_SYNC_EXTI_LINE12     /*!< Synchronization signal from EXTI Line12 */
109 #define HAL_DMAMUX1_SYNC_EXTI13           LL_DMAMUX_SYNC_EXTI_LINE13     /*!< Synchronization signal from EXTI Line13 */
110 #define HAL_DMAMUX1_SYNC_EXTI14           LL_DMAMUX_SYNC_EXTI_LINE14     /*!< Synchronization signal from EXTI Line14 */
111 #define HAL_DMAMUX1_SYNC_EXTI15           LL_DMAMUX_SYNC_EXTI_LINE15     /*!< Synchronization signal from EXTI Line15 */
112 #define HAL_DMAMUX1_SYNC_DMAMUX1_CH0_EVT  LL_DMAMUX_SYNC_DMAMUX_CH0      /*!< Synchronization signal from DMAMUX channel0 Event */
113 #define HAL_DMAMUX1_SYNC_DMAMUX1_CH1_EVT  LL_DMAMUX_SYNC_DMAMUX_CH1      /*!< Synchronization signal from DMAMUX channel1 Event */
114 #define HAL_DMAMUX1_SYNC_LPTIM1_OUT       LL_DMAMUX_SYNC_LPTIM1_OUT      /*!< Synchronization signal from LPTIM1 Output */
115 #define HAL_DMAMUX1_SYNC_LPTIM2_OUT       LL_DMAMUX_SYNC_LPTIM2_OUT      /*!< Synchronization signal from LPTIM2 Output */
116 #define HAL_DMAMUX1_SYNC_LPTIM3_OUT       LL_DMAMUX_SYNC_LPTIM3_OUT      /*!< Synchronization signal from LPTIM3 Output */
117 
118 #define HAL_DMAMUX1_MAX_SYNC              HAL_DMAMUX1_SYNC_LPTIM3_OUT
119 /**
120   * @}
121   */
122 
123 /** @defgroup DMAEx_DMAMUX_SyncPolarity_selection DMAMUX SyncPolarity selection
124   * @{
125   */
126 #define HAL_DMAMUX_SYNC_NO_EVENT          LL_DMAMUX_SYNC_NO_EVENT               /*!< block synchronization events                       */
127 #define HAL_DMAMUX_SYNC_RISING            LL_DMAMUX_SYNC_POL_RISING             /*!< synchronize with rising edge events                */
128 #define HAL_DMAMUX_SYNC_FALLING           LL_DMAMUX_SYNC_POL_FALLING            /*!< synchronize with falling edge events               */
129 #define HAL_DMAMUX_SYNC_RISING_FALLING    LL_DMAMUX_SYNC_POL_RISING_FALLING     /*!< synchronize with rising and falling edge events    */
130 
131 /**
132   * @}
133   */
134 
135 /** @defgroup DMAEx_DMAMUX_SignalGeneratorID_selection DMAMUX SignalGeneratorID selection
136   * @{
137   */
138 #define HAL_DMAMUX1_REQ_GEN_EXTI0            LL_DMAMUX_REQ_GEN_EXTI_LINE0   /*!< Request signal generation from EXTI Line0  */
139 #define HAL_DMAMUX1_REQ_GEN_EXTI1            LL_DMAMUX_REQ_GEN_EXTI_LINE1   /*!< Request signal generation from EXTI Line1  */
140 #define HAL_DMAMUX1_REQ_GEN_EXTI2            LL_DMAMUX_REQ_GEN_EXTI_LINE2   /*!< Request signal generation from EXTI Line2  */
141 #define HAL_DMAMUX1_REQ_GEN_EXTI3            LL_DMAMUX_REQ_GEN_EXTI_LINE3   /*!< Request signal generation from EXTI Line3  */
142 #define HAL_DMAMUX1_REQ_GEN_EXTI4            LL_DMAMUX_REQ_GEN_EXTI_LINE4   /*!< Request signal generation from EXTI Line4  */
143 #define HAL_DMAMUX1_REQ_GEN_EXTI5            LL_DMAMUX_REQ_GEN_EXTI_LINE5   /*!< Request signal generation from EXTI Line5  */
144 #define HAL_DMAMUX1_REQ_GEN_EXTI6            LL_DMAMUX_REQ_GEN_EXTI_LINE6   /*!< Request signal generation from EXTI Line6  */
145 #define HAL_DMAMUX1_REQ_GEN_EXTI7            LL_DMAMUX_REQ_GEN_EXTI_LINE7   /*!< Request signal generation from EXTI Line7  */
146 #define HAL_DMAMUX1_REQ_GEN_EXTI8            LL_DMAMUX_REQ_GEN_EXTI_LINE8   /*!< Request signal generation from EXTI Line8  */
147 #define HAL_DMAMUX1_REQ_GEN_EXTI9            LL_DMAMUX_REQ_GEN_EXTI_LINE9   /*!< Request signal generation from EXTI Line9  */
148 #define HAL_DMAMUX1_REQ_GEN_EXTI10           LL_DMAMUX_REQ_GEN_EXTI_LINE10  /*!< Request signal generation from EXTI Line10 */
149 #define HAL_DMAMUX1_REQ_GEN_EXTI11           LL_DMAMUX_REQ_GEN_EXTI_LINE11  /*!< Request signal generation from EXTI Line11 */
150 #define HAL_DMAMUX1_REQ_GEN_EXTI12           LL_DMAMUX_REQ_GEN_EXTI_LINE12  /*!< Request signal generation from EXTI Line12 */
151 #define HAL_DMAMUX1_REQ_GEN_EXTI13           LL_DMAMUX_REQ_GEN_EXTI_LINE13  /*!< Request signal generation from EXTI Line13 */
152 #define HAL_DMAMUX1_REQ_GEN_EXTI14           LL_DMAMUX_REQ_GEN_EXTI_LINE14  /*!< Request signal generation from EXTI Line14 */
153 #define HAL_DMAMUX1_REQ_GEN_EXTI15           LL_DMAMUX_REQ_GEN_EXTI_LINE15  /*!< Request signal generation from EXTI Line15 */
154 #define HAL_DMAMUX1_REQ_GEN_DMAMUX1_CH0_EVT  LL_DMAMUX_REQ_GEN_DMAMUX_CH0   /*!< Request signal generation from DMAMUX channel0 Event */
155 #define HAL_DMAMUX1_REQ_GEN_DMAMUX1_CH1_EVT  LL_DMAMUX_REQ_GEN_DMAMUX_CH1   /*!< Request signal generation from DMAMUX channel1 Event */
156 #define HAL_DMAMUX1_REQ_GEN_LPTIM1_OUT       LL_DMAMUX_REQ_GEN_LPTIM1_OUT   /*!< Request signal generation from LPTIM1 Output */
157 #define HAL_DMAMUX1_REQ_GEN_LPTIM2_OUT       LL_DMAMUX_REQ_GEN_LPTIM2_OUT   /*!< Request signal generation from LPTIM2 Output */
158 #define HAL_DMAMUX1_REQ_GEN_LPTIM3_OUT       LL_DMAMUX_REQ_GEN_LPTIM3_OUT   /*!< Request signal generation from LPTIM3 Output */
159 
160 #define HAL_DMAMUX1_MAX_REQ_GEN              HAL_DMAMUX1_REQ_GEN_LPTIM3_OUT
161 /**
162   * @}
163   */
164 
165 /** @defgroup DMAEx_DMAMUX_RequestGeneneratorPolarity_selection DMAMUX RequestGeneneratorPolarity selection
166   * @{
167   */
168 #define HAL_DMAMUX_REQ_GEN_NO_EVENT       LL_DMAMUX_REQ_GEN_NO_EVENT            /*!< block request generator events                     */
169 #define HAL_DMAMUX_REQ_GEN_RISING         LL_DMAMUX_REQ_GEN_POL_RISING          /*!< generate request on rising edge events             */
170 #define HAL_DMAMUX_REQ_GEN_FALLING        LL_DMAMUX_REQ_GEN_POL_FALLING         /*!< generate request on falling edge events            */
171 #define HAL_DMAMUX_REQ_GEN_RISING_FALLING LL_DMAMUX_REQ_GEN_POL_RISING_FALLING  /*!< generate request on rising and falling edge events */
172 
173 /**
174   * @}
175   */
176 
177 /**
178   * @}
179   */
180 
181 /* Exported macro ------------------------------------------------------------*/
182 
183 /* Exported functions --------------------------------------------------------*/
184 /** @addtogroup DMAEx_Exported_Functions
185   * @{
186   */
187 
188 /* IO operation functions *****************************************************/
189 /** @addtogroup DMAEx_Exported_Functions_Group1
190   * @{
191   */
192 
193 /* ------------------------- REQUEST -----------------------------------------*/
194 HAL_StatusTypeDef HAL_DMAEx_ConfigMuxRequestGenerator(DMA_HandleTypeDef *hdma,
195                                                       HAL_DMA_MuxRequestGeneratorConfigTypeDef *pRequestGeneratorConfig);
196 HAL_StatusTypeDef HAL_DMAEx_EnableMuxRequestGenerator(DMA_HandleTypeDef *hdma);
197 HAL_StatusTypeDef HAL_DMAEx_DisableMuxRequestGenerator(DMA_HandleTypeDef *hdma);
198 /* -------------------------------------------------------------------------- */
199 
200 /* ------------------------- SYNCHRO -----------------------------------------*/
201 HAL_StatusTypeDef HAL_DMAEx_ConfigMuxSync(DMA_HandleTypeDef *hdma, HAL_DMA_MuxSyncConfigTypeDef *pSyncConfig);
202 /* -------------------------------------------------------------------------- */
203 
204 void              HAL_DMAEx_MUX_IRQHandler(DMA_HandleTypeDef *hdma);
205 
206 /**
207   * @}
208   */
209 
210 /**
211   * @}
212   */
213 
214 
215 /* Private macros ------------------------------------------------------------*/
216 /** @defgroup DMAEx_Private_Macros DMAEx Private Macros
217   * @brief    DMAEx private macros
218  * @{
219  */
220 
221 #define IS_DMAMUX_SYNC_SIGNAL_ID(SIGNAL_ID)             (((SIGNAL_ID) == HAL_DMAMUX1_SYNC_EXTI0) || \
222                                                          (((SIGNAL_ID) >= HAL_DMAMUX1_SYNC_EXTI1) && \
223                                                           ((SIGNAL_ID) <= HAL_DMAMUX1_MAX_SYNC)))
224 
225 #define IS_DMAMUX_SYNC_REQUEST_NUMBER(REQUEST_NUMBER)   (((REQUEST_NUMBER) > 0U) && ((REQUEST_NUMBER) <= 32U))
226 
227 #define IS_DMAMUX_SYNC_POLARITY(POLARITY)               (((POLARITY) == HAL_DMAMUX_SYNC_NO_EVENT) || \
228                                                          ((POLARITY) == HAL_DMAMUX_SYNC_RISING)   || \
229                                                          ((POLARITY) == HAL_DMAMUX_SYNC_FALLING)  || \
230                                                          ((POLARITY) == HAL_DMAMUX_SYNC_RISING_FALLING))
231 
232 #define IS_DMAMUX_SYNC_STATE(SYNC)                      (((SYNC) == DISABLE)   || ((SYNC) == ENABLE))
233 
234 #define IS_DMAMUX_SYNC_EVENT(EVENT)                     (((EVENT) == DISABLE)   || \
235                                                          ((EVENT) == ENABLE))
236 
237 #define IS_DMAMUX_REQUEST_GEN_SIGNAL_ID(SIGNAL_ID)      (((SIGNAL_ID) == HAL_DMAMUX1_REQ_GEN_EXTI0) || \
238                                                          (((SIGNAL_ID) >= HAL_DMAMUX1_REQ_GEN_EXTI1) && \
239                                                           ((SIGNAL_ID) <= HAL_DMAMUX1_MAX_REQ_GEN)))
240 
241 #define IS_DMAMUX_REQUEST_GEN_REQUEST_NUMBER(REQUEST_NUMBER) (((REQUEST_NUMBER) > 0U) && ((REQUEST_NUMBER) <= 32U))
242 
243 #define IS_DMAMUX_REQUEST_GEN_POLARITY(POLARITY)        (((POLARITY) == HAL_DMAMUX_REQ_GEN_NO_EVENT)|| \
244                                                          ((POLARITY) == HAL_DMAMUX_REQ_GEN_RISING)  || \
245                                                          ((POLARITY) == HAL_DMAMUX_REQ_GEN_FALLING) || \
246                                                          ((POLARITY) == HAL_DMAMUX_REQ_GEN_RISING_FALLING))
247 
248 /**
249   * @}
250   */
251 
252 
253 /**
254   * @}
255   */
256 
257 /**
258   * @}
259   */
260 
261 #ifdef __cplusplus
262 }
263 #endif
264 
265 #endif /* STM32WLxx_HAL_DMA_EX_H */
266