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