1 /**
2   ******************************************************************************
3   * @file    stm32h7xx_hal_dfsdm.h
4   * @author  MCD Application Team
5   * @brief   Header file of DFSDM HAL 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 STM32H7xx_HAL_DFSDM_H
21 #define STM32H7xx_HAL_DFSDM_H
22 
23 #ifdef __cplusplus
24  extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32h7xx_hal_def.h"
29 
30 /** @addtogroup STM32H7xx_HAL_Driver
31   * @{
32   */
33 
34 /** @addtogroup DFSDM
35   * @{
36   */
37 
38 /* Exported types ------------------------------------------------------------*/
39 /** @defgroup DFSDM_Exported_Types DFSDM Exported Types
40   * @{
41   */
42 
43 /**
44   * @brief  HAL DFSDM Channel states definition
45   */
46 typedef enum
47 {
48   HAL_DFSDM_CHANNEL_STATE_RESET = 0x00U, /*!< DFSDM channel not initialized */
49   HAL_DFSDM_CHANNEL_STATE_READY = 0x01U, /*!< DFSDM channel initialized and ready for use */
50   HAL_DFSDM_CHANNEL_STATE_ERROR = 0xFFU  /*!< DFSDM channel state error */
51 } HAL_DFSDM_Channel_StateTypeDef;
52 
53 /**
54   * @brief  DFSDM channel output clock structure definition
55   */
56 typedef struct
57 {
58   FunctionalState Activation; /*!< Output clock enable/disable */
59   uint32_t        Selection;  /*!< Output clock is system clock or audio clock.
60                                    This parameter can be a value of @ref DFSDM_Channel_OuputClock */
61   uint32_t        Divider;    /*!< Output clock divider.
62                                    This parameter must be a number between Min_Data = 2 and Max_Data = 256 */
63 } DFSDM_Channel_OutputClockTypeDef;
64 
65 /**
66   * @brief  DFSDM channel input structure definition
67   */
68 typedef struct
69 {
70   uint32_t Multiplexer; /*!< Input is external serial inputs, internal register or ADC output.
71                              This parameter can be a value of @ref DFSDM_Channel_InputMultiplexer */
72   uint32_t DataPacking; /*!< Standard, interleaved or dual mode for internal register.
73                              This parameter can be a value of @ref DFSDM_Channel_DataPacking */
74   uint32_t Pins;        /*!< Input pins are taken from same or following channel.
75                              This parameter can be a value of @ref DFSDM_Channel_InputPins */
76 } DFSDM_Channel_InputTypeDef;
77 
78 /**
79   * @brief  DFSDM channel serial interface structure definition
80   */
81 typedef struct
82 {
83   uint32_t Type;     /*!< SPI or Manchester modes.
84                           This parameter can be a value of @ref DFSDM_Channel_SerialInterfaceType */
85   uint32_t SpiClock; /*!< SPI clock select (external or internal with different sampling point).
86                           This parameter can be a value of @ref DFSDM_Channel_SpiClock */
87 } DFSDM_Channel_SerialInterfaceTypeDef;
88 
89 /**
90   * @brief  DFSDM channel analog watchdog structure definition
91   */
92 typedef struct
93 {
94   uint32_t FilterOrder;  /*!< Analog watchdog Sinc filter order.
95                               This parameter can be a value of @ref DFSDM_Channel_AwdFilterOrder */
96   uint32_t Oversampling; /*!< Analog watchdog filter oversampling ratio.
97                               This parameter must be a number between Min_Data = 1 and Max_Data = 32 */
98 } DFSDM_Channel_AwdTypeDef;
99 
100 /**
101   * @brief  DFSDM channel init structure definition
102   */
103 typedef struct
104 {
105   DFSDM_Channel_OutputClockTypeDef     OutputClock;     /*!< DFSDM channel output clock parameters */
106   DFSDM_Channel_InputTypeDef           Input;           /*!< DFSDM channel input parameters */
107   DFSDM_Channel_SerialInterfaceTypeDef SerialInterface; /*!< DFSDM channel serial interface parameters */
108   DFSDM_Channel_AwdTypeDef             Awd;             /*!< DFSDM channel analog watchdog parameters */
109   int32_t                              Offset;          /*!< DFSDM channel offset.
110                                                              This parameter must be a number between Min_Data = -8388608 and Max_Data = 8388607 */
111   uint32_t                             RightBitShift;   /*!< DFSDM channel right bit shift.
112                                                              This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x1F */
113 } DFSDM_Channel_InitTypeDef;
114 
115 /**
116   * @brief  DFSDM channel handle structure definition
117   */
118 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
119 typedef struct __DFSDM_Channel_HandleTypeDef
120 #else
121 typedef struct
122 #endif /* USE_HAL_DFSDM_REGISTER_CALLBACKS */
123 {
124   DFSDM_Channel_TypeDef          *Instance; /*!< DFSDM channel instance */
125   DFSDM_Channel_InitTypeDef      Init;      /*!< DFSDM channel init parameters */
126   HAL_DFSDM_Channel_StateTypeDef State;     /*!< DFSDM channel state */
127 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
128   void (*CkabCallback)      (struct __DFSDM_Channel_HandleTypeDef *hdfsdm_channel); /*!< DFSDM channel clock absence detection callback */
129   void (*ScdCallback)       (struct __DFSDM_Channel_HandleTypeDef *hdfsdm_channel); /*!< DFSDM channel short circuit detection callback */
130   void (*MspInitCallback)   (struct __DFSDM_Channel_HandleTypeDef *hdfsdm_channel); /*!< DFSDM channel MSP init callback */
131   void (*MspDeInitCallback) (struct __DFSDM_Channel_HandleTypeDef *hdfsdm_channel); /*!< DFSDM channel MSP de-init callback */
132 #endif
133 } DFSDM_Channel_HandleTypeDef;
134 
135 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
136 /**
137   * @brief  DFSDM channel callback ID enumeration definition
138   */
139 typedef enum
140 {
141   HAL_DFSDM_CHANNEL_CKAB_CB_ID      = 0x00U, /*!< DFSDM channel clock absence detection callback ID */
142   HAL_DFSDM_CHANNEL_SCD_CB_ID       = 0x01U, /*!< DFSDM channel short circuit detection callback ID */
143   HAL_DFSDM_CHANNEL_MSPINIT_CB_ID   = 0x02U, /*!< DFSDM channel MSP init callback ID */
144   HAL_DFSDM_CHANNEL_MSPDEINIT_CB_ID = 0x03U  /*!< DFSDM channel MSP de-init callback ID */
145 } HAL_DFSDM_Channel_CallbackIDTypeDef;
146 
147 /**
148   * @brief  DFSDM channel callback pointer definition
149   */
150 typedef void (*pDFSDM_Channel_CallbackTypeDef)(DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
151 #endif
152 
153 /**
154   * @brief  HAL DFSDM Filter states definition
155   */
156 typedef enum
157 {
158   HAL_DFSDM_FILTER_STATE_RESET   = 0x00U, /*!< DFSDM filter not initialized */
159   HAL_DFSDM_FILTER_STATE_READY   = 0x01U, /*!< DFSDM filter initialized and ready for use */
160   HAL_DFSDM_FILTER_STATE_REG     = 0x02U, /*!< DFSDM filter regular conversion in progress */
161   HAL_DFSDM_FILTER_STATE_INJ     = 0x03U, /*!< DFSDM filter injected conversion in progress */
162   HAL_DFSDM_FILTER_STATE_REG_INJ = 0x04U, /*!< DFSDM filter regular and injected conversions in progress */
163   HAL_DFSDM_FILTER_STATE_ERROR   = 0xFFU  /*!< DFSDM filter state error */
164 } HAL_DFSDM_Filter_StateTypeDef;
165 
166 /**
167   * @brief  DFSDM filter regular conversion parameters structure definition
168   */
169 typedef struct
170 {
171   uint32_t        Trigger;  /*!< Trigger used to start regular conversion: software or synchronous.
172                                  This parameter can be a value of @ref DFSDM_Filter_Trigger */
173   FunctionalState FastMode; /*!< Enable/disable fast mode for regular conversion */
174   FunctionalState DmaMode;  /*!< Enable/disable DMA for regular conversion */
175 } DFSDM_Filter_RegularParamTypeDef;
176 
177 /**
178   * @brief  DFSDM filter injected conversion parameters structure definition
179   */
180 typedef struct
181 {
182   uint32_t        Trigger;        /*!< Trigger used to start injected conversion: software, external or synchronous.
183                                        This parameter can be a value of @ref DFSDM_Filter_Trigger */
184   FunctionalState ScanMode;       /*!< Enable/disable scanning mode for injected conversion */
185   FunctionalState DmaMode;        /*!< Enable/disable DMA for injected conversion */
186   uint32_t        ExtTrigger;     /*!< External trigger.
187                                        This parameter can be a value of @ref DFSDM_Filter_ExtTrigger */
188   uint32_t        ExtTriggerEdge; /*!< External trigger edge: rising, falling or both.
189                                        This parameter can be a value of @ref DFSDM_Filter_ExtTriggerEdge */
190 } DFSDM_Filter_InjectedParamTypeDef;
191 
192 /**
193   * @brief  DFSDM filter parameters structure definition
194   */
195 typedef struct
196 {
197   uint32_t SincOrder;       /*!< Sinc filter order.
198                                  This parameter can be a value of @ref DFSDM_Filter_SincOrder */
199   uint32_t Oversampling;    /*!< Filter oversampling ratio.
200                                  This parameter must be a number between Min_Data = 1 and Max_Data = 1024 */
201   uint32_t IntOversampling; /*!< Integrator oversampling ratio.
202                                  This parameter must be a number between Min_Data = 1 and Max_Data = 256 */
203 } DFSDM_Filter_FilterParamTypeDef;
204 
205 /**
206   * @brief  DFSDM filter init structure definition
207   */
208 typedef struct
209 {
210   DFSDM_Filter_RegularParamTypeDef  RegularParam;  /*!< DFSDM regular conversion parameters */
211   DFSDM_Filter_InjectedParamTypeDef InjectedParam; /*!< DFSDM injected conversion parameters */
212   DFSDM_Filter_FilterParamTypeDef   FilterParam;   /*!< DFSDM filter parameters */
213 } DFSDM_Filter_InitTypeDef;
214 
215 /**
216   * @brief  DFSDM filter handle structure definition
217   */
218 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
219 typedef struct __DFSDM_Filter_HandleTypeDef
220 #else
221 typedef struct
222 #endif /* USE_HAL_DFSDM_REGISTER_CALLBACKS */
223 {
224   DFSDM_Filter_TypeDef          *Instance;           /*!< DFSDM filter instance */
225   DFSDM_Filter_InitTypeDef      Init;                /*!< DFSDM filter init parameters */
226   DMA_HandleTypeDef             *hdmaReg;            /*!< Pointer on DMA handler for regular conversions */
227   DMA_HandleTypeDef             *hdmaInj;            /*!< Pointer on DMA handler for injected conversions */
228   uint32_t                      RegularContMode;     /*!< Regular conversion continuous mode */
229   uint32_t                      RegularTrigger;      /*!< Trigger used for regular conversion */
230   uint32_t                      InjectedTrigger;     /*!< Trigger used for injected conversion */
231   uint32_t                      ExtTriggerEdge;      /*!< Rising, falling or both edges selected */
232   FunctionalState               InjectedScanMode;    /*!< Injected scanning mode */
233   uint32_t                      InjectedChannelsNbr; /*!< Number of channels in injected sequence */
234   uint32_t                      InjConvRemaining;    /*!< Injected conversions remaining */
235   HAL_DFSDM_Filter_StateTypeDef State;               /*!< DFSDM filter state */
236   uint32_t                      ErrorCode;           /*!< DFSDM filter error code */
237 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
238   void (*AwdCallback)             (struct __DFSDM_Filter_HandleTypeDef *hdfsdm_filter,
239                       uint32_t Channel, uint32_t Threshold);                            /*!< DFSDM filter analog watchdog callback */
240   void (*RegConvCpltCallback)     (struct __DFSDM_Filter_HandleTypeDef *hdfsdm_filter); /*!< DFSDM filter regular conversion complete callback */
241   void (*RegConvHalfCpltCallback) (struct __DFSDM_Filter_HandleTypeDef *hdfsdm_filter); /*!< DFSDM filter half regular conversion complete callback */
242   void (*InjConvCpltCallback)     (struct __DFSDM_Filter_HandleTypeDef *hdfsdm_filter); /*!< DFSDM filter injected conversion complete callback */
243   void (*InjConvHalfCpltCallback) (struct __DFSDM_Filter_HandleTypeDef *hdfsdm_filter); /*!< DFSDM filter half injected conversion complete callback */
244   void (*ErrorCallback)           (struct __DFSDM_Filter_HandleTypeDef *hdfsdm_filter); /*!< DFSDM filter error callback */
245   void (*MspInitCallback)         (struct __DFSDM_Filter_HandleTypeDef *hdfsdm_filter); /*!< DFSDM filter MSP init callback */
246   void (*MspDeInitCallback)       (struct __DFSDM_Filter_HandleTypeDef *hdfsdm_filter); /*!< DFSDM filter MSP de-init callback */
247 #endif
248 }DFSDM_Filter_HandleTypeDef;
249 
250 /**
251   * @brief  DFSDM filter analog watchdog parameters structure definition
252   */
253 typedef struct
254 {
255   uint32_t DataSource;      /*!< Values from digital filter or from channel watchdog filter.
256                                  This parameter can be a value of @ref DFSDM_Filter_AwdDataSource */
257   uint32_t Channel;         /*!< Analog watchdog channel selection.
258                                  This parameter can be a values combination of @ref DFSDM_Channel_Selection */
259   int32_t  HighThreshold;   /*!< High threshold for the analog watchdog.
260                                  This parameter must be a number between Min_Data = -8388608 and Max_Data = 8388607 */
261   int32_t  LowThreshold;    /*!< Low threshold for the analog watchdog.
262                                  This parameter must be a number between Min_Data = -8388608 and Max_Data = 8388607 */
263   uint32_t HighBreakSignal; /*!< Break signal assigned to analog watchdog high threshold event.
264                                  This parameter can be a values combination of @ref DFSDM_BreakSignals */
265   uint32_t LowBreakSignal;  /*!< Break signal assigned to analog watchdog low threshold event.
266                                  This parameter can be a values combination of @ref DFSDM_BreakSignals */
267 } DFSDM_Filter_AwdParamTypeDef;
268 
269 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
270 /**
271   * @brief  DFSDM filter callback ID enumeration definition
272   */
273 typedef enum
274 {
275   HAL_DFSDM_FILTER_REGCONV_COMPLETE_CB_ID     = 0x00U, /*!< DFSDM filter regular conversion complete callback ID */
276   HAL_DFSDM_FILTER_REGCONV_HALFCOMPLETE_CB_ID = 0x01U, /*!< DFSDM filter half regular conversion complete callback ID */
277   HAL_DFSDM_FILTER_INJCONV_COMPLETE_CB_ID     = 0x02U, /*!< DFSDM filter injected conversion complete callback ID */
278   HAL_DFSDM_FILTER_INJCONV_HALFCOMPLETE_CB_ID = 0x03U, /*!< DFSDM filter half injected conversion complete callback ID */
279   HAL_DFSDM_FILTER_ERROR_CB_ID                = 0x04U, /*!< DFSDM filter error callback ID */
280   HAL_DFSDM_FILTER_MSPINIT_CB_ID              = 0x05U, /*!< DFSDM filter MSP init callback ID */
281   HAL_DFSDM_FILTER_MSPDEINIT_CB_ID            = 0x06U  /*!< DFSDM filter MSP de-init callback ID */
282 } HAL_DFSDM_Filter_CallbackIDTypeDef;
283 
284 /**
285   * @brief  DFSDM filter callback pointer definition
286   */
287 typedef void (*pDFSDM_Filter_CallbackTypeDef)(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
288 typedef void (*pDFSDM_Filter_AwdCallbackTypeDef)(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t Channel, uint32_t Threshold);
289 #endif
290 
291 /**
292   * @}
293   */
294 /* End of exported types -----------------------------------------------------*/
295 
296 /* Exported constants --------------------------------------------------------*/
297 /** @defgroup DFSDM_Exported_Constants DFSDM Exported Constants
298   * @{
299   */
300 
301 /** @defgroup DFSDM_Channel_OuputClock DFSDM channel output clock selection
302   * @{
303   */
304 #define DFSDM_CHANNEL_OUTPUT_CLOCK_SYSTEM    0x00000000U             /*!< Source for output clock is system clock */
305 #define DFSDM_CHANNEL_OUTPUT_CLOCK_AUDIO     DFSDM_CHCFGR1_CKOUTSRC  /*!< Source for output clock is audio clock */
306 /**
307   * @}
308   */
309 
310 /** @defgroup DFSDM_Channel_InputMultiplexer DFSDM channel input multiplexer
311   * @{
312   */
313 #define DFSDM_CHANNEL_EXTERNAL_INPUTS    0x00000000U             /*!< Data are taken from external inputs */
314 #define DFSDM_CHANNEL_ADC_OUTPUT         DFSDM_CHCFGR1_DATMPX_0  /*!< Data are taken from ADC output */
315 #define DFSDM_CHANNEL_INTERNAL_REGISTER  DFSDM_CHCFGR1_DATMPX_1  /*!< Data are taken from internal register */
316 /**
317   * @}
318   */
319 
320 /** @defgroup DFSDM_Channel_DataPacking DFSDM channel input data packing
321   * @{
322   */
323 #define DFSDM_CHANNEL_STANDARD_MODE         0x00000000U             /*!< Standard data packing mode */
324 #define DFSDM_CHANNEL_INTERLEAVED_MODE      DFSDM_CHCFGR1_DATPACK_0 /*!< Interleaved data packing mode */
325 #define DFSDM_CHANNEL_DUAL_MODE             DFSDM_CHCFGR1_DATPACK_1 /*!< Dual data packing mode */
326 /**
327   * @}
328   */
329 
330 /** @defgroup DFSDM_Channel_InputPins DFSDM channel input pins
331   * @{
332   */
333 #define DFSDM_CHANNEL_SAME_CHANNEL_PINS      0x00000000U             /*!< Input from pins on same channel */
334 #define DFSDM_CHANNEL_FOLLOWING_CHANNEL_PINS DFSDM_CHCFGR1_CHINSEL   /*!< Input from pins on following channel */
335 /**
336   * @}
337   */
338 
339 /** @defgroup DFSDM_Channel_SerialInterfaceType DFSDM channel serial interface type
340   * @{
341   */
342 #define DFSDM_CHANNEL_SPI_RISING         0x00000000U             /*!< SPI with rising edge */
343 #define DFSDM_CHANNEL_SPI_FALLING        DFSDM_CHCFGR1_SITP_0    /*!< SPI with falling edge */
344 #define DFSDM_CHANNEL_MANCHESTER_RISING  DFSDM_CHCFGR1_SITP_1    /*!< Manchester with rising edge */
345 #define DFSDM_CHANNEL_MANCHESTER_FALLING DFSDM_CHCFGR1_SITP      /*!< Manchester with falling edge */
346 /**
347   * @}
348   */
349 
350 /** @defgroup DFSDM_Channel_SpiClock DFSDM channel SPI clock selection
351   * @{
352   */
353 #define DFSDM_CHANNEL_SPI_CLOCK_EXTERNAL              0x00000000U              /*!< External SPI clock */
354 #define DFSDM_CHANNEL_SPI_CLOCK_INTERNAL              DFSDM_CHCFGR1_SPICKSEL_0 /*!< Internal SPI clock */
355 #define DFSDM_CHANNEL_SPI_CLOCK_INTERNAL_DIV2_FALLING DFSDM_CHCFGR1_SPICKSEL_1 /*!< Internal SPI clock divided by 2, falling edge */
356 #define DFSDM_CHANNEL_SPI_CLOCK_INTERNAL_DIV2_RISING  DFSDM_CHCFGR1_SPICKSEL   /*!< Internal SPI clock divided by 2, rising edge */
357 /**
358   * @}
359   */
360 
361 /** @defgroup DFSDM_Channel_AwdFilterOrder DFSDM channel analog watchdog filter order
362   * @{
363   */
364 #define DFSDM_CHANNEL_FASTSINC_ORDER 0x00000000U             /*!< FastSinc filter type */
365 #define DFSDM_CHANNEL_SINC1_ORDER    DFSDM_CHAWSCDR_AWFORD_0 /*!< Sinc 1 filter type */
366 #define DFSDM_CHANNEL_SINC2_ORDER    DFSDM_CHAWSCDR_AWFORD_1 /*!< Sinc 2 filter type */
367 #define DFSDM_CHANNEL_SINC3_ORDER    DFSDM_CHAWSCDR_AWFORD   /*!< Sinc 3 filter type */
368 /**
369   * @}
370   */
371 
372 /** @defgroup DFSDM_Filter_Trigger DFSDM filter conversion trigger
373   * @{
374   */
375 #define DFSDM_FILTER_SW_TRIGGER   0x00000000U /*!< Software trigger */
376 #define DFSDM_FILTER_SYNC_TRIGGER 0x00000001U /*!< Synchronous with DFSDM_FLT0 */
377 #define DFSDM_FILTER_EXT_TRIGGER  0x00000002U /*!< External trigger (only for injected conversion) */
378 /**
379   * @}
380   */
381 
382 /** @defgroup DFSDM_Filter_ExtTrigger DFSDM filter external trigger
383   * @{
384   */
385 #define DFSDM_FILTER_EXT_TRIG_TIM1_TRGO      0x00000000U                                       /*!< For all DFSDM filters */
386 #define DFSDM_FILTER_EXT_TRIG_TIM1_TRGO2     DFSDM_FLTCR1_JEXTSEL_0                            /*!< For all DFSDM filters */
387 #define DFSDM_FILTER_EXT_TRIG_TIM8_TRGO      DFSDM_FLTCR1_JEXTSEL_1                            /*!< For all DFSDM filters */
388 #define DFSDM_FILTER_EXT_TRIG_TIM8_TRGO2     (DFSDM_FLTCR1_JEXTSEL_0 | DFSDM_FLTCR1_JEXTSEL_1) /*!< For all DFSDM filters */
389 #define DFSDM_FILTER_EXT_TRIG_TIM3_TRGO      DFSDM_FLTCR1_JEXTSEL_2                            /*!< For all DFSDM filters */
390 #define DFSDM_FILTER_EXT_TRIG_TIM4_TRGO      (DFSDM_FLTCR1_JEXTSEL_0 | DFSDM_FLTCR1_JEXTSEL_2) /*!< For all DFSDM filters */
391 #define DFSDM_FILTER_EXT_TRIG_TIM16_OC1       (DFSDM_FLTCR1_JEXTSEL_2 | DFSDM_FLTCR1_JEXTSEL_1)                        /*!< For all DFSDM filters */
392 #define DFSDM_FILTER_EXT_TRIG_TIM6_TRGO       (DFSDM_FLTCR1_JEXTSEL_0 | DFSDM_FLTCR1_JEXTSEL_2 | DFSDM_FLTCR1_JEXTSEL_1) /*!< For all DFSDM filters */
393 #define DFSDM_FILTER_EXT_TRIG_TIM7_TRGO      DFSDM_FLTCR1_JEXTSEL_3                            /*!< For all DFSDM filters */
394 #define DFSDM_FILTER_EXT_TRIG_HRTIM1_ADCTRG1  (DFSDM_FLTCR1_JEXTSEL_3 | DFSDM_FLTCR1_JEXTSEL_0)
395 #define DFSDM_FILTER_EXT_TRIG_HRTIM1_ADCTRG3  (DFSDM_FLTCR1_JEXTSEL_3 | DFSDM_FLTCR1_JEXTSEL_1)
396 #define DFSDM_FILTER_EXT_TRIG_EXTI11          (DFSDM_FLTCR1_JEXTSEL_4 | DFSDM_FLTCR1_JEXTSEL_3) /*!< For all DFSDM filters */
397 #define DFSDM_FILTER_EXT_TRIG_EXTI15          (DFSDM_FLTCR1_JEXTSEL_4 | DFSDM_FLTCR1_JEXTSEL_3 | DFSDM_FLTCR1_JEXTSEL_0)                           /*!< For all DFSDM filters */
398 #define DFSDM_FILTER_EXT_TRIG_LPTIM1_OUT      (DFSDM_FLTCR1_JEXTSEL_4 | DFSDM_FLTCR1_JEXTSEL_3 | DFSDM_FLTCR1_JEXTSEL_1)                           /*!< For all DFSDM filters */
399 #define DFSDM_FILTER_EXT_TRIG_LPTIM2_OUT      (DFSDM_FLTCR1_JEXTSEL_4 | DFSDM_FLTCR1_JEXTSEL_3 | DFSDM_FLTCR1_JEXTSEL_1 | DFSDM_FLTCR1_JEXTSEL_0)  /*!< For all DFSDM filters */
400 #define DFSDM_FILTER_EXT_TRIG_LPTIM3_OUT      (DFSDM_FLTCR1_JEXTSEL_4 | DFSDM_FLTCR1_JEXTSEL_3 | DFSDM_FLTCR1_JEXTSEL_2)                           /*!< For all DFSDM filters */
401 #if (STM32H7_DEV_ID == 0x480UL)
402 #define DFSDM_FILTER_EXT_TRIG_COMP1_OUT      (DFSDM_FLTCR1_JEXTSEL_4 | DFSDM_FLTCR1_JEXTSEL_3 | \
403                                               DFSDM_FLTCR1_JEXTSEL_2 | DFSDM_FLTCR1_JEXTSEL_0)
404 #define DFSDM_FILTER_EXT_TRIG_COMP2_OUT      (DFSDM_FLTCR1_JEXTSEL_4 | DFSDM_FLTCR1_JEXTSEL_3 | \
405                                               DFSDM_FLTCR1_JEXTSEL_2 | DFSDM_FLTCR1_JEXTSEL_1)
406 #elif (STM32H7_DEV_ID == 0x483UL)
407 #define DFSDM_FILTER_EXT_TRIG_TIM23_TRGO     (DFSDM_FLTCR1_JEXTSEL_3 | DFSDM_FLTCR1_JEXTSEL_1 | \
408                                               DFSDM_FLTCR1_JEXTSEL_0)
409 #define DFSDM_FILTER_EXT_TRIG_TIM24_TRGO     (DFSDM_FLTCR1_JEXTSEL_3 | DFSDM_FLTCR1_JEXTSEL_2 )
410 #endif /* STM32H7_DEV_ID == 0x480UL */
411 /**
412   * @}
413   */
414 
415 /** @defgroup DFSDM_Filter_ExtTriggerEdge DFSDM filter external trigger edge
416   * @{
417   */
418 #define DFSDM_FILTER_EXT_TRIG_RISING_EDGE  DFSDM_FLTCR1_JEXTEN_0 /*!< External rising edge */
419 #define DFSDM_FILTER_EXT_TRIG_FALLING_EDGE DFSDM_FLTCR1_JEXTEN_1 /*!< External falling edge */
420 #define DFSDM_FILTER_EXT_TRIG_BOTH_EDGES   DFSDM_FLTCR1_JEXTEN   /*!< External rising and falling edges */
421 /**
422   * @}
423   */
424 
425 /** @defgroup DFSDM_Filter_SincOrder DFSDM filter sinc order
426   * @{
427   */
428 #define DFSDM_FILTER_FASTSINC_ORDER 0x00000000U                                 /*!< FastSinc filter type */
429 #define DFSDM_FILTER_SINC1_ORDER    DFSDM_FLTFCR_FORD_0                         /*!< Sinc 1 filter type */
430 #define DFSDM_FILTER_SINC2_ORDER    DFSDM_FLTFCR_FORD_1                         /*!< Sinc 2 filter type */
431 #define DFSDM_FILTER_SINC3_ORDER    (DFSDM_FLTFCR_FORD_0 | DFSDM_FLTFCR_FORD_1) /*!< Sinc 3 filter type */
432 #define DFSDM_FILTER_SINC4_ORDER    DFSDM_FLTFCR_FORD_2                         /*!< Sinc 4 filter type */
433 #define DFSDM_FILTER_SINC5_ORDER    (DFSDM_FLTFCR_FORD_0 | DFSDM_FLTFCR_FORD_2) /*!< Sinc 5 filter type */
434 /**
435   * @}
436   */
437 
438 /** @defgroup DFSDM_Filter_AwdDataSource DFSDM filter analog watchdog data source
439   * @{
440   */
441 #define DFSDM_FILTER_AWD_FILTER_DATA  0x00000000U             /*!< From digital filter */
442 #define DFSDM_FILTER_AWD_CHANNEL_DATA DFSDM_FLTCR1_AWFSEL     /*!< From analog watchdog channel */
443 /**
444   * @}
445   */
446 
447 /** @defgroup DFSDM_Filter_ErrorCode DFSDM filter error code
448   * @{
449   */
450 #define DFSDM_FILTER_ERROR_NONE             0x00000000U /*!< No error */
451 #define DFSDM_FILTER_ERROR_REGULAR_OVERRUN  0x00000001U /*!< Overrun occurs during regular conversion */
452 #define DFSDM_FILTER_ERROR_INJECTED_OVERRUN 0x00000002U /*!< Overrun occurs during injected conversion */
453 #define DFSDM_FILTER_ERROR_DMA              0x00000003U /*!< DMA error occurs */
454 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
455 #define DFSDM_FILTER_ERROR_INVALID_CALLBACK 0x00000004U /*!< Invalid callback error occurs */
456 #endif
457 /**
458   * @}
459   */
460 
461 /** @defgroup DFSDM_BreakSignals DFSDM break signals
462   * @{
463   */
464 #define DFSDM_NO_BREAK_SIGNAL 0x00000000U /*!< No break signal */
465 #define DFSDM_BREAK_SIGNAL_0  0x00000001U /*!< Break signal 0 */
466 #define DFSDM_BREAK_SIGNAL_1  0x00000002U /*!< Break signal 1 */
467 #define DFSDM_BREAK_SIGNAL_2  0x00000004U /*!< Break signal 2 */
468 #define DFSDM_BREAK_SIGNAL_3  0x00000008U /*!< Break signal 3 */
469 /**
470   * @}
471   */
472 
473 /** @defgroup DFSDM_Channel_Selection DFSDM Channel Selection
474   * @{
475   */
476 /* DFSDM Channels ------------------------------------------------------------*/
477 /* The DFSDM channels are defined as follows:
478    - in 16-bit LSB the channel mask is set
479    - in 16-bit MSB the channel number is set
480    e.g. for channel 5 definition:
481         - the channel mask is 0x00000020 (bit 5 is set)
482         - the channel number 5 is 0x00050000
483         --> Consequently, channel 5 definition is 0x00000020 | 0x00050000 = 0x00050020 */
484 #define DFSDM_CHANNEL_0                              0x00000001U
485 #define DFSDM_CHANNEL_1                              0x00010002U
486 #define DFSDM_CHANNEL_2                              0x00020004U
487 #define DFSDM_CHANNEL_3                              0x00030008U
488 #define DFSDM_CHANNEL_4                              0x00040010U
489 #define DFSDM_CHANNEL_5                              0x00050020U
490 #define DFSDM_CHANNEL_6                              0x00060040U
491 #define DFSDM_CHANNEL_7                              0x00070080U
492 /**
493   * @}
494   */
495 
496 /** @defgroup DFSDM_ContinuousMode DFSDM Continuous Mode
497   * @{
498   */
499 #define DFSDM_CONTINUOUS_CONV_OFF            0x00000000U /*!< Conversion are not continuous */
500 #define DFSDM_CONTINUOUS_CONV_ON             0x00000001U /*!< Conversion are continuous */
501 /**
502   * @}
503   */
504 
505 /** @defgroup DFSDM_AwdThreshold DFSDM analog watchdog threshold
506   * @{
507   */
508 #define DFSDM_AWD_HIGH_THRESHOLD            0x00000000U /*!< Analog watchdog high threshold */
509 #define DFSDM_AWD_LOW_THRESHOLD             0x00000001U /*!< Analog watchdog low threshold */
510 /**
511   * @}
512   */
513 
514 /**
515   * @}
516   */
517 /* End of exported constants -------------------------------------------------*/
518 
519 /* Exported macros -----------------------------------------------------------*/
520 /** @defgroup DFSDM_Exported_Macros DFSDM Exported Macros
521  * @{
522  */
523 
524 /** @brief  Reset DFSDM channel handle state.
525   * @param  __HANDLE__ DFSDM channel handle.
526   * @retval None
527   */
528 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
529 #define __HAL_DFSDM_CHANNEL_RESET_HANDLE_STATE(__HANDLE__) do{                                                      \
530                                                                (__HANDLE__)->State = HAL_DFSDM_CHANNEL_STATE_RESET; \
531                                                                (__HANDLE__)->MspInitCallback = NULL;                \
532                                                                (__HANDLE__)->MspDeInitCallback = NULL;              \
533                                                              } while(0)
534 #else
535 #define __HAL_DFSDM_CHANNEL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DFSDM_CHANNEL_STATE_RESET)
536 #endif
537 
538 /** @brief  Reset DFSDM filter handle state.
539   * @param  __HANDLE__ DFSDM filter handle.
540   * @retval None
541   */
542 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
543 #define __HAL_DFSDM_FILTER_RESET_HANDLE_STATE(__HANDLE__) do{                                                     \
544                                                               (__HANDLE__)->State = HAL_DFSDM_FILTER_STATE_RESET; \
545                                                               (__HANDLE__)->MspInitCallback = NULL;               \
546                                                               (__HANDLE__)->MspDeInitCallback = NULL;             \
547                                                             } while(0)
548 #else
549 #define __HAL_DFSDM_FILTER_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DFSDM_FILTER_STATE_RESET)
550 #endif
551 
552 /**
553   * @}
554   */
555 /* End of exported macros ----------------------------------------------------*/
556 
557 #if defined(DFSDM_CHDLYR_PLSSKP)
558 /* Include DFSDM HAL Extension module */
559 #include "stm32h7xx_hal_dfsdm_ex.h"
560 #endif /* DFSDM_CHDLYR_PLSSKP */
561 
562 /* Exported functions --------------------------------------------------------*/
563 /** @addtogroup DFSDM_Exported_Functions DFSDM Exported Functions
564   * @{
565   */
566 
567 /** @addtogroup DFSDM_Exported_Functions_Group1_Channel Channel initialization and de-initialization functions
568   * @{
569   */
570 /* Channel initialization and de-initialization functions *********************/
571 HAL_StatusTypeDef HAL_DFSDM_ChannelInit(DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
572 HAL_StatusTypeDef HAL_DFSDM_ChannelDeInit(DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
573 void HAL_DFSDM_ChannelMspInit(DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
574 void HAL_DFSDM_ChannelMspDeInit(DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
575 
576 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
577 /* Channel callbacks register/unregister functions ****************************/
578 HAL_StatusTypeDef HAL_DFSDM_Channel_RegisterCallback(DFSDM_Channel_HandleTypeDef        *hdfsdm_channel,
579                                                      HAL_DFSDM_Channel_CallbackIDTypeDef CallbackID,
580                                                      pDFSDM_Channel_CallbackTypeDef      pCallback);
581 HAL_StatusTypeDef HAL_DFSDM_Channel_UnRegisterCallback(DFSDM_Channel_HandleTypeDef        *hdfsdm_channel,
582                                                        HAL_DFSDM_Channel_CallbackIDTypeDef CallbackID);
583 #endif
584 /**
585   * @}
586   */
587 
588 /** @addtogroup DFSDM_Exported_Functions_Group2_Channel Channel operation functions
589   * @{
590   */
591 /* Channel operation functions ************************************************/
592 HAL_StatusTypeDef HAL_DFSDM_ChannelCkabStart(DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
593 HAL_StatusTypeDef HAL_DFSDM_ChannelCkabStart_IT(DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
594 HAL_StatusTypeDef HAL_DFSDM_ChannelCkabStop(DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
595 HAL_StatusTypeDef HAL_DFSDM_ChannelCkabStop_IT(DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
596 
597 HAL_StatusTypeDef HAL_DFSDM_ChannelScdStart(DFSDM_Channel_HandleTypeDef *hdfsdm_channel, uint32_t Threshold, uint32_t BreakSignal);
598 HAL_StatusTypeDef HAL_DFSDM_ChannelScdStart_IT(DFSDM_Channel_HandleTypeDef *hdfsdm_channel, uint32_t Threshold, uint32_t BreakSignal);
599 HAL_StatusTypeDef HAL_DFSDM_ChannelScdStop(DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
600 HAL_StatusTypeDef HAL_DFSDM_ChannelScdStop_IT(DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
601 
602 int16_t           HAL_DFSDM_ChannelGetAwdValue(const DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
603 HAL_StatusTypeDef HAL_DFSDM_ChannelModifyOffset(DFSDM_Channel_HandleTypeDef *hdfsdm_channel, int32_t Offset);
604 
605 HAL_StatusTypeDef HAL_DFSDM_ChannelPollForCkab(const DFSDM_Channel_HandleTypeDef *hdfsdm_channel, uint32_t Timeout);
606 HAL_StatusTypeDef HAL_DFSDM_ChannelPollForScd(const DFSDM_Channel_HandleTypeDef *hdfsdm_channel, uint32_t Timeout);
607 
608 void HAL_DFSDM_ChannelCkabCallback(DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
609 void HAL_DFSDM_ChannelScdCallback(DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
610 /**
611   * @}
612   */
613 
614 /** @defgroup DFSDM_Exported_Functions_Group3_Channel Channel state function
615   * @{
616   */
617 /* Channel state function *****************************************************/
618 HAL_DFSDM_Channel_StateTypeDef HAL_DFSDM_ChannelGetState(const DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
619 /**
620   * @}
621   */
622 
623 /** @addtogroup DFSDM_Exported_Functions_Group1_Filter Filter initialization and de-initialization functions
624   * @{
625   */
626 /* Filter initialization and de-initialization functions *********************/
627 HAL_StatusTypeDef HAL_DFSDM_FilterInit(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
628 HAL_StatusTypeDef HAL_DFSDM_FilterDeInit(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
629 void HAL_DFSDM_FilterMspInit(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
630 void HAL_DFSDM_FilterMspDeInit(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
631 
632 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
633 /* Filter callbacks register/unregister functions ****************************/
634 HAL_StatusTypeDef HAL_DFSDM_Filter_RegisterCallback(DFSDM_Filter_HandleTypeDef        *hdfsdm_filter,
635                                                     HAL_DFSDM_Filter_CallbackIDTypeDef CallbackID,
636                                                     pDFSDM_Filter_CallbackTypeDef      pCallback);
637 HAL_StatusTypeDef HAL_DFSDM_Filter_UnRegisterCallback(DFSDM_Filter_HandleTypeDef        *hdfsdm_filter,
638                                                       HAL_DFSDM_Filter_CallbackIDTypeDef CallbackID);
639 HAL_StatusTypeDef HAL_DFSDM_Filter_RegisterAwdCallback(DFSDM_Filter_HandleTypeDef      *hdfsdm_filter,
640                                                        pDFSDM_Filter_AwdCallbackTypeDef pCallback);
641 HAL_StatusTypeDef HAL_DFSDM_Filter_UnRegisterAwdCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
642 #endif
643 /**
644   * @}
645   */
646 
647 /** @addtogroup DFSDM_Exported_Functions_Group2_Filter Filter control functions
648   * @{
649   */
650 /* Filter control functions *********************/
651 HAL_StatusTypeDef HAL_DFSDM_FilterConfigRegChannel(DFSDM_Filter_HandleTypeDef *hdfsdm_filter,
652                                                    uint32_t                    Channel,
653                                                    uint32_t                    ContinuousMode);
654 HAL_StatusTypeDef HAL_DFSDM_FilterConfigInjChannel(DFSDM_Filter_HandleTypeDef *hdfsdm_filter,
655                                                    uint32_t                    Channel);
656 /**
657   * @}
658   */
659 
660 /** @addtogroup DFSDM_Exported_Functions_Group3_Filter Filter operation functions
661   * @{
662   */
663 /* Filter operation functions *********************/
664 HAL_StatusTypeDef HAL_DFSDM_FilterRegularStart(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
665 HAL_StatusTypeDef HAL_DFSDM_FilterRegularStart_IT(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
666 HAL_StatusTypeDef HAL_DFSDM_FilterRegularStart_DMA(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, int32_t *pData, uint32_t Length);
667 HAL_StatusTypeDef HAL_DFSDM_FilterRegularMsbStart_DMA(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, int16_t *pData, uint32_t Length);
668 HAL_StatusTypeDef HAL_DFSDM_FilterRegularStop(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
669 HAL_StatusTypeDef HAL_DFSDM_FilterRegularStop_IT(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
670 HAL_StatusTypeDef HAL_DFSDM_FilterRegularStop_DMA(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
671 HAL_StatusTypeDef HAL_DFSDM_FilterInjectedStart(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
672 HAL_StatusTypeDef HAL_DFSDM_FilterInjectedStart_IT(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
673 HAL_StatusTypeDef HAL_DFSDM_FilterInjectedStart_DMA(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, int32_t *pData, uint32_t Length);
674 HAL_StatusTypeDef HAL_DFSDM_FilterInjectedMsbStart_DMA(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, int16_t *pData, uint32_t Length);
675 HAL_StatusTypeDef HAL_DFSDM_FilterInjectedStop(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
676 HAL_StatusTypeDef HAL_DFSDM_FilterInjectedStop_IT(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
677 HAL_StatusTypeDef HAL_DFSDM_FilterInjectedStop_DMA(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
678 HAL_StatusTypeDef HAL_DFSDM_FilterAwdStart_IT(DFSDM_Filter_HandleTypeDef *hdfsdm_filter,
679                                               const DFSDM_Filter_AwdParamTypeDef *awdParam);
680 HAL_StatusTypeDef HAL_DFSDM_FilterAwdStop_IT(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
681 HAL_StatusTypeDef HAL_DFSDM_FilterExdStart(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t Channel);
682 HAL_StatusTypeDef HAL_DFSDM_FilterExdStop(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
683 
684 int32_t  HAL_DFSDM_FilterGetRegularValue(const DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t *Channel);
685 int32_t  HAL_DFSDM_FilterGetInjectedValue(const DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t *Channel);
686 int32_t  HAL_DFSDM_FilterGetExdMaxValue(const DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t *Channel);
687 int32_t  HAL_DFSDM_FilterGetExdMinValue(const DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t *Channel);
688 uint32_t HAL_DFSDM_FilterGetConvTimeValue(const DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
689 
690 void HAL_DFSDM_IRQHandler(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
691 
692 HAL_StatusTypeDef HAL_DFSDM_FilterPollForRegConversion(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t Timeout);
693 HAL_StatusTypeDef HAL_DFSDM_FilterPollForInjConversion(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t Timeout);
694 
695 void HAL_DFSDM_FilterRegConvCpltCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
696 void HAL_DFSDM_FilterRegConvHalfCpltCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
697 void HAL_DFSDM_FilterInjConvCpltCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
698 void HAL_DFSDM_FilterInjConvHalfCpltCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
699 void HAL_DFSDM_FilterAwdCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t Channel, uint32_t Threshold);
700 void HAL_DFSDM_FilterErrorCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
701 /**
702   * @}
703   */
704 
705 /** @defgroup DFSDM_Exported_Functions_Group4_Filter Filter state functions
706   * @{
707   */
708 /* Filter state functions *****************************************************/
709 HAL_DFSDM_Filter_StateTypeDef HAL_DFSDM_FilterGetState(const DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
710 uint32_t                      HAL_DFSDM_FilterGetError(const DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
711 /**
712   * @}
713   */
714 
715 /**
716   * @}
717   */
718 /* End of exported functions -------------------------------------------------*/
719 
720 /* Private macros ------------------------------------------------------------*/
721 /** @defgroup DFSDM_Private_Macros DFSDM Private Macros
722 * @{
723 */
724 #define IS_DFSDM_CHANNEL_OUTPUT_CLOCK(CLOCK)          (((CLOCK) == DFSDM_CHANNEL_OUTPUT_CLOCK_SYSTEM) || \
725                                                        ((CLOCK) == DFSDM_CHANNEL_OUTPUT_CLOCK_AUDIO))
726 #define IS_DFSDM_CHANNEL_OUTPUT_CLOCK_DIVIDER(DIVIDER) ((2U <= (DIVIDER)) && ((DIVIDER) <= 256U))
727 #define IS_DFSDM_CHANNEL_INPUT(INPUT)                 (((INPUT) == DFSDM_CHANNEL_EXTERNAL_INPUTS) || \
728                                                        ((INPUT) == DFSDM_CHANNEL_ADC_OUTPUT) || \
729                                                        ((INPUT) == DFSDM_CHANNEL_INTERNAL_REGISTER))
730 #define IS_DFSDM_CHANNEL_DATA_PACKING(MODE)           (((MODE) == DFSDM_CHANNEL_STANDARD_MODE) || \
731                                                        ((MODE) == DFSDM_CHANNEL_INTERLEAVED_MODE) || \
732                                                        ((MODE) == DFSDM_CHANNEL_DUAL_MODE))
733 #define IS_DFSDM_CHANNEL_INPUT_PINS(PINS)             (((PINS) == DFSDM_CHANNEL_SAME_CHANNEL_PINS) || \
734                                                        ((PINS) == DFSDM_CHANNEL_FOLLOWING_CHANNEL_PINS))
735 #define IS_DFSDM_CHANNEL_SERIAL_INTERFACE_TYPE(MODE)  (((MODE) == DFSDM_CHANNEL_SPI_RISING) || \
736                                                        ((MODE) == DFSDM_CHANNEL_SPI_FALLING) || \
737                                                        ((MODE) == DFSDM_CHANNEL_MANCHESTER_RISING) || \
738                                                        ((MODE) == DFSDM_CHANNEL_MANCHESTER_FALLING))
739 #define IS_DFSDM_CHANNEL_SPI_CLOCK(TYPE)              (((TYPE) == DFSDM_CHANNEL_SPI_CLOCK_EXTERNAL) || \
740                                                        ((TYPE) == DFSDM_CHANNEL_SPI_CLOCK_INTERNAL) || \
741                                                        ((TYPE) == DFSDM_CHANNEL_SPI_CLOCK_INTERNAL_DIV2_FALLING) || \
742                                                        ((TYPE) == DFSDM_CHANNEL_SPI_CLOCK_INTERNAL_DIV2_RISING))
743 #define IS_DFSDM_CHANNEL_FILTER_ORDER(ORDER)          (((ORDER) == DFSDM_CHANNEL_FASTSINC_ORDER) || \
744                                                        ((ORDER) == DFSDM_CHANNEL_SINC1_ORDER) || \
745                                                        ((ORDER) == DFSDM_CHANNEL_SINC2_ORDER) || \
746                                                        ((ORDER) == DFSDM_CHANNEL_SINC3_ORDER))
747 #define IS_DFSDM_CHANNEL_FILTER_OVS_RATIO(RATIO)       ((1U <= (RATIO)) && ((RATIO) <= 32U))
748 #define IS_DFSDM_CHANNEL_OFFSET(VALUE)                 ((-8388608 <= (VALUE)) && ((VALUE) <= 8388607))
749 #define IS_DFSDM_CHANNEL_RIGHT_BIT_SHIFT(VALUE)        ((VALUE) <= 0x1FU)
750 #define IS_DFSDM_CHANNEL_SCD_THRESHOLD(VALUE)          ((VALUE) <= 0xFFU)
751 #define IS_DFSDM_FILTER_REG_TRIGGER(TRIG)             (((TRIG) == DFSDM_FILTER_SW_TRIGGER) || \
752                                                        ((TRIG) == DFSDM_FILTER_SYNC_TRIGGER))
753 #define IS_DFSDM_FILTER_INJ_TRIGGER(TRIG)             (((TRIG) == DFSDM_FILTER_SW_TRIGGER) || \
754                                                        ((TRIG) == DFSDM_FILTER_SYNC_TRIGGER) || \
755                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIGGER))
756 #if (STM32H7_DEV_ID == 0x480UL)
757 #define IS_DFSDM_FILTER_EXT_TRIG(TRIG)                (((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM1_TRGO) || \
758                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM1_TRGO2) || \
759                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM8_TRGO) || \
760                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM8_TRGO2) || \
761                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM3_TRGO) || \
762                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM4_TRGO) || \
763                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM16_OC1) || \
764                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM6_TRGO) || \
765                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM7_TRGO) || \
766                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_EXTI11) || \
767                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_EXTI15) || \
768                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_LPTIM1_OUT) || \
769                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_LPTIM2_OUT) || \
770                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_LPTIM3_OUT) || \
771                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_COMP1_OUT) || \
772                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_COMP2_OUT))
773 #elif (STM32H7_DEV_ID == 0x483UL)
774 #define IS_DFSDM_FILTER_EXT_TRIG(TRIG)                (((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM1_TRGO) || \
775                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM1_TRGO2) || \
776                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM8_TRGO) || \
777                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM8_TRGO2) || \
778                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM3_TRGO) || \
779                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM4_TRGO) || \
780                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM16_OC1) || \
781                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM6_TRGO) || \
782                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM7_TRGO) || \
783                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_EXTI11) || \
784                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_EXTI15) || \
785                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_LPTIM1_OUT) || \
786                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_LPTIM2_OUT) || \
787                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_LPTIM3_OUT) || \
788                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM23_TRGO) || \
789                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM24_TRGO))
790 
791 #else
792 #define IS_DFSDM_FILTER_EXT_TRIG(TRIG)                (((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM1_TRGO) || \
793                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM1_TRGO2) || \
794                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM8_TRGO) || \
795                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM8_TRGO2) || \
796                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM3_TRGO) || \
797                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM4_TRGO) || \
798                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM16_OC1) || \
799                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM6_TRGO) || \
800                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM7_TRGO) || \
801                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_HRTIM1_ADCTRG1) || \
802                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_HRTIM1_ADCTRG3) || \
803                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_EXTI11) || \
804                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_EXTI15) || \
805                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_LPTIM1_OUT) || \
806                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_LPTIM2_OUT) || \
807                                                        ((TRIG) == DFSDM_FILTER_EXT_TRIG_LPTIM3_OUT))
808 #endif /* STM32H7_DEV_ID == 0x480UL */
809 #define IS_DFSDM_FILTER_EXT_TRIG_EDGE(EDGE)           (((EDGE) == DFSDM_FILTER_EXT_TRIG_RISING_EDGE)  || \
810                                                        ((EDGE) == DFSDM_FILTER_EXT_TRIG_FALLING_EDGE)  || \
811                                                        ((EDGE) == DFSDM_FILTER_EXT_TRIG_BOTH_EDGES))
812 #define IS_DFSDM_FILTER_SINC_ORDER(ORDER)             (((ORDER) == DFSDM_FILTER_FASTSINC_ORDER) || \
813                                                        ((ORDER) == DFSDM_FILTER_SINC1_ORDER) || \
814                                                        ((ORDER) == DFSDM_FILTER_SINC2_ORDER) || \
815                                                        ((ORDER) == DFSDM_FILTER_SINC3_ORDER) || \
816                                                        ((ORDER) == DFSDM_FILTER_SINC4_ORDER) || \
817                                                        ((ORDER) == DFSDM_FILTER_SINC5_ORDER))
818 #define IS_DFSDM_FILTER_OVS_RATIO(RATIO)               ((1U <= (RATIO)) && ((RATIO) <= 1024U))
819 #define IS_DFSDM_FILTER_INTEGRATOR_OVS_RATIO(RATIO)    ((1U <= (RATIO)) && ((RATIO) <= 256U))
820 #define IS_DFSDM_FILTER_AWD_DATA_SOURCE(DATA)         (((DATA) == DFSDM_FILTER_AWD_FILTER_DATA)  || \
821                                                        ((DATA) == DFSDM_FILTER_AWD_CHANNEL_DATA))
822 #define IS_DFSDM_FILTER_AWD_THRESHOLD(VALUE)           ((-8388608 <= (VALUE)) && ((VALUE) <= 8388607))
823 #define IS_DFSDM_BREAK_SIGNALS(VALUE)                  ((VALUE) <= 0xFU)
824 #define IS_DFSDM_REGULAR_CHANNEL(CHANNEL)             (((CHANNEL) == DFSDM_CHANNEL_0)  || \
825                                                        ((CHANNEL) == DFSDM_CHANNEL_1)  || \
826                                                        ((CHANNEL) == DFSDM_CHANNEL_2)  || \
827                                                        ((CHANNEL) == DFSDM_CHANNEL_3)  || \
828                                                        ((CHANNEL) == DFSDM_CHANNEL_4)  || \
829                                                        ((CHANNEL) == DFSDM_CHANNEL_5)  || \
830                                                        ((CHANNEL) == DFSDM_CHANNEL_6)  || \
831                                                        ((CHANNEL) == DFSDM_CHANNEL_7))
832 #define IS_DFSDM_INJECTED_CHANNEL(CHANNEL)            (((CHANNEL) != 0U) && ((CHANNEL) <= 0x000F00FFU))
833 #define IS_DFSDM_CONTINUOUS_MODE(MODE)                (((MODE) == DFSDM_CONTINUOUS_CONV_OFF)  || \
834                                                        ((MODE) == DFSDM_CONTINUOUS_CONV_ON))
835 #if defined(DFSDM2_Channel0)
836 #define IS_DFSDM1_CHANNEL_INSTANCE(INSTANCE)          (((INSTANCE) == DFSDM1_Channel0) || \
837                                                        ((INSTANCE) == DFSDM1_Channel1) || \
838                                                        ((INSTANCE) == DFSDM1_Channel2) || \
839                                                        ((INSTANCE) == DFSDM1_Channel3) || \
840                                                        ((INSTANCE) == DFSDM1_Channel4) || \
841                                                        ((INSTANCE) == DFSDM1_Channel5) || \
842                                                        ((INSTANCE) == DFSDM1_Channel6) || \
843                                                        ((INSTANCE) == DFSDM1_Channel7))
844 #define IS_DFSDM1_FILTER_INSTANCE(INSTANCE)           (((INSTANCE) == DFSDM1_Filter0) || \
845                                                        ((INSTANCE) == DFSDM1_Filter1) || \
846                                                        ((INSTANCE) == DFSDM1_Filter2) || \
847                                                        ((INSTANCE) == DFSDM1_Filter3) || \
848                                                        ((INSTANCE) == DFSDM1_Filter4) || \
849                                                        ((INSTANCE) == DFSDM1_Filter5) || \
850                                                        ((INSTANCE) == DFSDM1_Filter6) || \
851                                                        ((INSTANCE) == DFSDM1_Filter7))
852 #endif /* DFSDM2_Channel0 */
853 /**
854   * @}
855   */
856 /* End of private macros -----------------------------------------------------*/
857 
858 /**
859   * @}
860   */
861 
862 /**
863   * @}
864   */
865 
866 #ifdef __cplusplus
867 }
868 #endif
869 
870 #endif /* STM32H7xx_HAL_DFSDM_H */
871 
872