1 /**
2   ******************************************************************************
3   * @file    stm32n6xx_hal_mdf.h
4   * @author  MCD Application Team
5   * @brief   Header file of MDF HAL module.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2023 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 STM32N6xx_HAL_MDF_H
21 #define STM32N6xx_HAL_MDF_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32n6xx_hal_def.h"
29 
30 /** @addtogroup STM32N6xx_HAL_Driver
31   * @{
32   */
33 
34 /** @addtogroup MDF
35   * @{
36   */
37 
38 /* Exported types ------------------------------------------------------------*/
39 /** @defgroup MDF_Exported_Types  MDF Exported Types
40   * @{
41   */
42 
43 /**
44   * @brief  HAL MDF states definition
45   */
46 typedef enum
47 {
48   HAL_MDF_STATE_RESET       = 0x00U, /*!< MDF not initialized */
49   HAL_MDF_STATE_READY       = 0x01U, /*!< MDF initialized and ready for use */
50   HAL_MDF_STATE_ACQUISITION = 0x02U, /*!< MDF acquisition in progress */
51   HAL_MDF_STATE_ERROR       = 0xFFU  /*!< MDF state error */
52 } HAL_MDF_StateTypeDef;
53 
54 /**
55   * @brief  MDF clock trigger structure definition
56   */
57 typedef struct
58 {
59   FunctionalState Activation;  /*!< Output clock trigger enable/disable */
60   uint32_t        Source;      /*!< Output clock trigger source.
61                                     This parameter can be a value of @ref MDF_ClockTriggerSource */
62   uint32_t        Edge;        /*!< Output clock trigger edge.
63                                     This parameter can be a value of @ref MDF_ClockTriggerEdge */
64 } MDF_ClockTriggerTypeDef;
65 
66 /**
67   * @brief  MDF output clock structure definition
68   */
69 typedef struct
70 {
71   FunctionalState         Activation; /*!< Output clock enable/disable */
72   uint32_t                Pins;       /*!< Output clock pins.
73                                            This parameter can be a value of @ref MDF_OuputClockPins */
74   uint32_t                Divider;    /*!< Output clock divider.
75                                            This parameter must be a number between Min_Data = 1 and Max_Data = 16 */
76   MDF_ClockTriggerTypeDef Trigger;    /*!< Output clock trigger parameters */
77 } MDF_OutputClockTypeDef;
78 
79 /**
80   * @brief  MDF common parameters structure definition
81   */
82 typedef struct
83 {
84   uint32_t               InterleavedFilters; /*!< Number of filters in interleaved mode with filter 0.
85                                                   This parameter must be a number between Min_Data = 0
86                                                   and Max_Data = 5.
87                                                   @note This parameter is not used for ADF instance */
88   uint32_t               ProcClockDivider;   /*!< Processing clock divider.
89                                                   This parameter must be a number between Min_Data = 1
90                                                   and Max_Data = 128 */
91   MDF_OutputClockTypeDef OutputClock;        /*!< Output clock parameters */
92 } MDF_CommonParamTypeDef;
93 
94 /**
95   * @brief  MDF serial interface structure definition
96   */
97 typedef struct
98 {
99   FunctionalState  Activation;  /*!< Serial interface enable/disable */
100   uint32_t         Mode;        /*!< Serial interface mode.
101                                      This parameter can be a value of @ref MDF_SitfMode */
102   uint32_t         ClockSource; /*!< Serial interface clock source.
103                                      This parameter can be a value of @ref MDF_SitfClockSource */
104   uint32_t         Threshold;   /*!< SPI threshold for clock absence detection or Manchester symbol threshold.
105                                      This parameter must be a number between Min_Data = 4 and Max_Data = 31 */
106 } MDF_SerialInterfaceTypeDef;
107 
108 /**
109   * @brief  MDF init structure definition
110   */
111 typedef struct
112 {
113   MDF_CommonParamTypeDef      CommonParam;      /*!< MDF common parameters */
114   MDF_SerialInterfaceTypeDef  SerialInterface;  /*!< MDF serial interface parameters */
115   uint32_t                    FilterBistream;   /*!< MDF filter bitstream selection.
116                                                      This parameter can be a value of @ref MDF_FilterBitstream */
117 } MDF_InitTypeDef;
118 
119 /**
120   * @brief  MDF handle structure definition
121   */
122 #if (USE_HAL_MDF_REGISTER_CALLBACKS == 1)
123 typedef struct __MDF_HandleTypeDef
124 #else
125 typedef struct
126 #endif /* USE_HAL_MDF_REGISTER_CALLBACKS */
127 {
128   MDF_Filter_TypeDef        *Instance;  /*!< MDF instance */
129   MDF_InitTypeDef            Init;      /*!< MDF init parameters */
130   DMA_HandleTypeDef         *hdma;      /*!< Pointer on DMA handler for acquisitions */
131   __IO HAL_MDF_StateTypeDef  State;     /*!< MDF state */
132   __IO uint32_t              ErrorCode; /*!< MDF error code */
133 #if (USE_HAL_MDF_REGISTER_CALLBACKS == 1)
134   void (*OldCallback)(struct __MDF_HandleTypeDef *hmdf,
135                       uint32_t Threshold);                        /*!< MDF out-off limit detector callback.
136                                                                        @note Not used for ADF instance */
137   void (*AcqCpltCallback)(struct __MDF_HandleTypeDef *hmdf);      /*!< MDF acquisition complete callback */
138   void (*AcqHalfCpltCallback)(struct __MDF_HandleTypeDef *hmdf);  /*!< MDF acquisition half complete callback */
139   void (*SndLvCallback)(struct __MDF_HandleTypeDef *hmdf,
140                         uint32_t SoundLevel,
141                         uint32_t AmbientNoise);                   /*!< MDF sound level callback.
142                                                                        @note Not used for MDF instance */
143   void (*SadCallback)(struct __MDF_HandleTypeDef *hmdf);          /*!< MDF sound activity detector callback.
144                                                                        @note Not used for MDF instance */
145   void (*ErrorCallback)(struct __MDF_HandleTypeDef *hmdf);        /*!< MDF error callback */
146   void (*MspInitCallback)(struct __MDF_HandleTypeDef *hmdf);      /*!< MDF MSP init callback */
147   void (*MspDeInitCallback)(struct __MDF_HandleTypeDef *hmdf);    /*!< MDF MSP de-init callback */
148 #endif /* USE_HAL_MDF_REGISTER_CALLBACKS */
149 } MDF_HandleTypeDef;
150 
151 #if (USE_HAL_MDF_REGISTER_CALLBACKS == 1)
152 /**
153   * @brief  MDF callback ID enumeration definition
154   */
155 typedef enum
156 {
157   HAL_MDF_OLD_CB_ID              = 0x00U, /*!< MDF out-off limit detector callback ID.
158                                                @note Not used for ADF instance */
159   HAL_MDF_ACQ_COMPLETE_CB_ID     = 0x01U, /*!< MDF acquisition complete callback ID */
160   HAL_MDF_ACQ_HALFCOMPLETE_CB_ID = 0x02U, /*!< MDF acquisition half complete callback ID */
161   HAL_MDF_SNDLVL_CB_ID           = 0x03U, /*!< MDF sound level callback ID.
162                                                @note Not used for MDF instance */
163   HAL_MDF_SAD_CB_ID              = 0x04U, /*!< MDF sound activity detector callback ID.
164                                                @note Not used for MDF instance */
165   HAL_MDF_ERROR_CB_ID            = 0x05U, /*!< MDF error callback ID */
166   HAL_MDF_MSPINIT_CB_ID          = 0x06U, /*!< MDF MSP init callback ID */
167   HAL_MDF_MSPDEINIT_CB_ID        = 0x07U  /*!< MDF MSP de-init callback ID */
168 } HAL_MDF_CallbackIDTypeDef;
169 
170 /**
171   * @brief  MDF callback pointers definition
172   */
173 typedef void (*pMDF_CallbackTypeDef)(MDF_HandleTypeDef *hmdf);
174 typedef void (*pMDF_OldCallbackTypeDef)(MDF_HandleTypeDef *hmdf, uint32_t Threshold);
175 typedef void (*pMDF_SndLvlCallbackTypeDef)(MDF_HandleTypeDef *hmdf, uint32_t SoundLevel, uint32_t AmbientNoise);
176 #endif /* USE_HAL_MDF_REGISTER_CALLBACKS */
177 
178 /**
179   * @brief  MDF reshape filter structure definition
180   */
181 typedef struct
182 {
183   FunctionalState  Activation;       /*!< Reshape filter enable/disable */
184   uint32_t         DecimationRatio;  /*!< Reshape filter decimation ratio.
185                                           This parameter can be a value of @ref MDF_ReshapeDecimationRatio */
186 } MDF_ReshapeFilterTypeDef;
187 
188 /**
189   * @brief  MDF high pass filter structure definition
190   */
191 typedef struct
192 {
193   FunctionalState  Activation;       /*!< High pass filter enable/disable */
194   uint32_t         CutOffFrequency;  /*!< High pass filter cut-off frequency.
195                                           This parameter can be a value of @ref MDF_HighPassCutOffFreq */
196 } MDF_HighPassFilterTypeDef;
197 
198 /**
199   * @brief  MDF integrator structure definition
200   */
201 typedef struct
202 {
203   FunctionalState  Activation;      /*!< Integrator enable/disable */
204   uint32_t         Value;           /*!< Integrator value.
205                                          This parameter must be a number between Min_Data = 2 and Max_Data = 128 */
206   uint32_t         OutputDivision;  /*!< Integrator output division.
207                                          This parameter can be a value of @ref MDF_IntegratorOutputDiv */
208 } MDF_IntegratorTypeDef;
209 
210 /**
211   * @brief  MDF sound activity structure definition
212   */
213 typedef struct
214 {
215   FunctionalState  Activation;            /*!< Sound activity detector enable/disable */
216   uint32_t         Mode;                  /*!< Sound activity detector mode.
217                                                This parameter can be a value of @ref MDF_SadMode */
218   uint32_t         FrameSize;             /*!< Size of one frame to compute short-term signal level.
219                                                This parameter can be a value of @ref MDF_SadFrameSize */
220   FunctionalState  Hysteresis;            /*!< Hysteresis enable/disable.
221                                                @note This parameter is not used if Mode is set
222                                                      to MDF_SAD_AMBIENT_NOISE_ESTIMATOR */
223   uint32_t         SoundTriggerEvent;     /*!< Sound trigger event configuration.
224                                                This parameter can be a value of @ref MDF_SadSoundTriggerEvent */
225   uint32_t         DataMemoryTransfer;    /*!< Data memory transfer mode.
226                                                This parameter can be a value of @ref MDF_SadDataMemoryTransfer */
227   uint32_t         MinNoiseLevel;         /*!< Minimum noise level.
228                                                This parameter must be a number between Min_Data = 0
229                                                and Max_Data = 8191 */
230   uint32_t         HangoverWindow;        /*!< Hangover time window in frames.
231                                                This parameter can be a value of @ref MDF_SadHangoverWindow */
232   uint32_t         LearningFrames;        /*!< Number of learning frames for the first estimation of noise level.
233                                                This parameter can be a value of @ref MDF_SadLearningFrames */
234   uint32_t         AmbientNoiseSlope;     /*!< Ambient noise slope control.
235                                                This parameter must be a number between Min_Data = 0 and Max_Data = 7.
236                                                @note This parameter is not used if Mode is set
237                                                      to MDF_SAD_SOUND_DETECTOR */
238   uint32_t         SignalNoiseThreshold;  /*!< Signal to noise threshold.
239                                                This parameter can be a value of @ref MDF_SadSignalNoiseThreshold */
240   FunctionalState  SoundLevelInterrupt;    /*!< Sound level interrupt enable/disable.
241                                                @note This interrupt is mainly used for debug purpose*/
242 
243 } MDF_SoundActivityTypeDef;
244 
245 /**
246   * @brief  MDF filter trigger structure definition
247   */
248 typedef struct
249 {
250   uint32_t  Source;  /*!< Filter trigger source.
251                           This parameter can be a value of @ref MDF_FilterTriggerSource */
252   uint32_t  Edge;    /*!< Filter trigger edge.
253                           This parameter can be a value of @ref MDF_FilterTriggerEdge */
254 } MDF_FilterTriggerTypeDef;
255 
256 /**
257   * @brief  MDF filter configuration structure definition
258   */
259 typedef struct
260 {
261   uint32_t                  DataSource;      /*!< Filter data source.
262                                                   This parameter can be a value of @ref MDF_DataSource */
263   uint32_t                  Delay;           /*!< Delay to apply on data source in number of samples.
264                                                   This parameter must be a number between Min_Data = 0
265                                                   and Max_Data = 127 */
266   uint32_t                  CicMode;         /*!< CIC filter mode.
267                                                   This parameter can be a value of @ref MDF_CicMode */
268   uint32_t                  DecimationRatio; /*!< Filter decimation ratio.
269                                                   This parameter must be a number between Min_Data = 2
270                                                   and Max_Data = 512 */
271   int32_t                   Offset;          /*!< Filter offset error compensation.
272                                                   This parameter must be a number between Min_Data = -33554432
273                                                   and Max_Data = 33554431.
274                                                   @note This parameter is not used for ADF instance */
275   int32_t                   Gain;            /*!< Filter gain in step of around 3db (from -48db to 72dB).
276                                                   This parameter must be a number between Min_Data = -16
277                                                   and Max_Data = 24 */
278   MDF_ReshapeFilterTypeDef  ReshapeFilter;   /*!< Reshape filter configuration */
279   MDF_HighPassFilterTypeDef HighPassFilter;  /*!< High pass filter configuration */
280   MDF_IntegratorTypeDef     Integrator;      /*!< Integrator configuration.
281                                                   @note This parameter is not used for ADF instance */
282   MDF_SoundActivityTypeDef  SoundActivity;   /*!< Sound activity detector configuration.
283                                                   @note This parameter is not used for MDF instance */
284   uint32_t                  AcquisitionMode; /*!< Filter acquisition mode.
285                                                   This parameter can be a value of @ref MDF_AcquisitionMode */
286   uint32_t                  FifoThreshold;   /*!< Filter RXFIFO threshold.
287                                                   This parameter can be a value of @ref MDF_FifoThreshold */
288   uint32_t                  DiscardSamples;  /*!< Number of samples to discard after filter enable.
289                                                   This parameter must be a number between Min_Data = 0
290                                                   and Max_Data = 255 */
291   MDF_FilterTriggerTypeDef  Trigger;         /*!< Filter trigger configuration.
292                                                   @note This parameter is not used if AcquisitionMode is set
293                                                         to MDF_MODE_ASYNC_CONT or MDF_MODE_ASYNC_SINGLE */
294   uint32_t                  SnapshotFormat;  /*!< Snapshot format.
295                                                   This parameter can be a value of @ref MDF_SnapshotFormat.
296                                                   @note This parameter is used only if AcquisitionMode is set
297                                                         to MDF_MODE_SYNC_SNAPSHOT and for MDF instance */
298 } MDF_FilterConfigTypeDef;
299 
300 /**
301   * @brief  MDF snapshot parameters structure definition
302   */
303 typedef struct
304 {
305   int32_t   Value;              /*!< Snapshot acquisition value on 16 or 23 MSB depending on snapshot format */
306   uint32_t  DecimationCounter;  /*!< Decimation counter value when snapshot trigger occurs */
307   uint32_t  IntegratorCounter;  /*!< Integrator counter value when snapshot trigger occurs.
308                                      This value is available only if snapshot format is 16 bits resolution */
309 } MDF_SnapshotParamTypeDef;
310 
311 /**
312   * @brief  MDF DMA configuration structure definition
313   */
314 typedef struct
315 {
316   uint32_t         Address;     /*!< DMA destination address */
317   uint32_t         DataLength;  /*!< Length of data to transfer in bytes */
318   FunctionalState  MsbOnly;     /*!< Transfer only the 16MSB of the acquistion data */
319 } MDF_DmaConfigTypeDef;
320 
321 /**
322   * @brief  MDF short-circuit detector configuration structure definition
323   */
324 typedef struct
325 {
326   uint32_t  Threshold;    /*!< Short-circuit detector threshold.
327                                This parameter must be a number between Min_Data = 2 and Max_Data = 256 */
328   uint32_t  BreakSignal;  /*!< Break signal assignment for short-circuit detector.
329                                This parameter can be a values combination of @ref MDF_BreakSignals */
330 } MDF_ScdConfigTypeDef;
331 
332 /**
333   * @brief  MDF out-off limit detector configuration structure definition
334   */
335 typedef struct
336 {
337   uint32_t  OldCicMode;          /*!< Out-off limit detector CIC filter mode.
338                                       This parameter can be a value of @ref MDF_OldCicMode */
339   uint32_t  OldDecimationRatio;  /*!< Out-off limit detector decimation ratio.
340                                       This parameter must be a number between Min_Data = 1 and Max_Data = 32 */
341   int32_t   HighThreshold;       /*!< Out-off limit detector high threshold.
342                                       This parameter must be a number between Min_Data = -33554432
343                                       and Max_Data = 33554431 */
344   int32_t   LowThreshold;        /*!< Out-off limit detector low threshold.
345                                       This parameter must be a number between Min_Data = -33554432
346                                       and Max_Data = 33554431 */
347   uint32_t  OldEventConfig;      /*!< Out-off limit event configuration.
348                                       This parameter can be a value of @ref MDF_OldEventConfig */
349   uint32_t  BreakSignal;         /*!< Break signal assignment for out-off limit detector.
350                                       This parameter can be a values combination of @ref MDF_BreakSignals */
351 } MDF_OldConfigTypeDef;
352 
353 /**
354   * @}
355   */
356 
357 /* Exported constants --------------------------------------------------------*/
358 /** @defgroup MDF_Exported_Constants  MDF Exported Constants
359   * @{
360   */
361 
362 /** @defgroup MDF_ErrorCode MDF error code
363   * @{
364   */
365 #define MDF_ERROR_NONE                  0x00000000U /*!< No error */
366 #define MDF_ERROR_ACQUISITION_OVERFLOW  0x00000001U /*!< Overflow occurs during acquisition */
367 #define MDF_ERROR_RSF_OVERRUN           0x00000002U /*!< Overrun occurs on reshape filter */
368 #define MDF_ERROR_CLOCK_ABSENCE         0x00000004U /*!< Clock absence detection occurs */
369 #define MDF_ERROR_SHORT_CIRCUIT         0x00000008U /*!< Short circuit detection occurs.
370                                                          @note Not used for ADF instance */
371 #define MDF_ERROR_SATURATION            0x00000010U /*!< Saturation detection occurs */
372 #define MDF_ERROR_OUT_OFF_LIMIT         0x00000020U /*!< Out-off limit detection occurs.
373                                                          @note Not used for ADF instance */
374 #define MDF_ERROR_DMA                   0x00000040U /*!< DMA error occurs */
375 #if (USE_HAL_MDF_REGISTER_CALLBACKS == 1)
376 #define MDF_ERROR_INVALID_CALLBACK      0x00000080U /*!< Invalid callback error occurs */
377 #endif /* USE_HAL_MDF_REGISTER_CALLBACKS */
378 /**
379   * @}
380   */
381 
382 /** @defgroup MDF_ClockTriggerSource MDF output clock trigger source
383   * @{
384   */
385 #define MDF_CLOCK_TRIG_TRGO        0x00000000U
386 #define MDF_CLOCK_TRIG_EXTI15      MDF_CKGCR_TRGSRC_1
387 #define MDF_CLOCK_TRIG_EXTI11     (MDF_CKGCR_TRGSRC_0 | \
388                                    MDF_CKGCR_TRGSRC_1)     /*!< @note Not available for ADF instance */
389 #define MDF_CLOCK_TRIG_TIM1_TRGO   MDF_CKGCR_TRGSRC_2      /*!< @note Not available for ADF instance */
390 #define MDF_CLOCK_TRIG_TIM1_TRGO2 (MDF_CKGCR_TRGSRC_0 | \
391                                    MDF_CKGCR_TRGSRC_2)     /*!< @note Not available for ADF instance */
392 #define MDF_CLOCK_TRIG_TIM3_TRGO  (MDF_CKGCR_TRGSRC_1 | \
393                                    MDF_CKGCR_TRGSRC_2)     /*!< @note Not available for ADF instance */
394 #define MDF_CLOCK_TRIG_TIM4_TRGO  (MDF_CKGCR_TRGSRC_0 | \
395                                    MDF_CKGCR_TRGSRC_1 | \
396                                    MDF_CKGCR_TRGSRC_2)     /*!< @note Not available for ADF instance */
397 #define MDF_CLOCK_TRIG_TIM6_TRGO   MDF_CKGCR_TRGSRC_3      /*!< @note Not available for ADF instance */
398 #define MDF_CLOCK_TRIG_TIM7_TRGO  (MDF_CKGCR_TRGSRC_0 | \
399                                    MDF_CKGCR_TRGSRC_3)     /*!< @note Not available for ADF instance */
400 #define MDF_CLOCK_TRIG_TIM8_TRGO  (MDF_CKGCR_TRGSRC_1 | \
401                                    MDF_CKGCR_TRGSRC_3)     /*!< @note Not available for ADF instance */
402 #define MDF_CLOCK_TRIG_TIM8_TRGO2 (MDF_CKGCR_TRGSRC_0 | \
403                                    MDF_CKGCR_TRGSRC_1 | \
404                                    MDF_CKGCR_TRGSRC_3)     /*!< @note Not available for ADF instance */
405 #define MDF_CLOCK_TRIG_TIM15_TRGO (MDF_CKGCR_TRGSRC_2 | \
406                                    MDF_CKGCR_TRGSRC_3)     /*!< @note Not available for ADF instance */
407 #define MDF_CLOCK_TRIG_LPTIM1_OUT (MDF_CKGCR_TRGSRC_0 | \
408                                    MDF_CKGCR_TRGSRC_2 | \
409                                    MDF_CKGCR_TRGSRC_3)     /*!< @note Not available for ADF instance */
410 #define MDF_CLOCK_TRIG_SAD_DET    (MDF_CKGCR_TRGSRC_1 | \
411                                    MDF_CKGCR_TRGSRC_2 | \
412                                    MDF_CKGCR_TRGSRC_3)     /*!< @note Not available for ADF instance */
413 #define MDF_CLOCK_TRIG_SAD_TRGO    MDF_CKGCR_TRGSRC        /*!< @note Not available for ADF instance */
414 /**
415   * @}
416   */
417 
418 /** @defgroup MDF_ClockTriggerEdge MDF output clock trigger edge
419   * @{
420   */
421 #define MDF_CLOCK_TRIG_RISING_EDGE   0x00000000U        /*!< Rising edge */
422 #define MDF_CLOCK_TRIG_FALLING_EDGE  MDF_CKGCR_TRGSENS  /*!< Falling edge */
423 /**
424   * @}
425   */
426 
427 /** @defgroup MDF_OuputClockPins MDF output clock pins
428   * @{
429   */
430 #define MDF_OUTPUT_CLOCK_0    MDF_CKGCR_CCK0DIR      /*!< MDF_CCK0 is used as output clock */
431 #define MDF_OUTPUT_CLOCK_1    MDF_CKGCR_CCK1DIR      /*!< MDF_CCK1 is used as output clock */
432 #define MDF_OUTPUT_CLOCK_ALL (MDF_CKGCR_CCK0DIR | \
433                               MDF_CKGCR_CCK1DIR)     /*!< MDF_CCK0 and MDF_CCK1 are used as output clock */
434 /**
435   * @}
436   */
437 
438 /** @defgroup MDF_SitfMode MDF serial interface mode
439   * @{
440   */
441 #define MDF_SITF_LF_MASTER_SPI_MODE       0x00000000U           /*!< Low frequency master SPI mode */
442 #define MDF_SITF_NORMAL_SPI_MODE          MDF_SITFCR_SITFMOD_0  /*!< Normal SPI mode */
443 #define MDF_SITF_MANCHESTER_FALLING_MODE  MDF_SITFCR_SITFMOD_1  /*!< Manchester mode rising edge logic 0
444                                                                      and falling edge logic 1 */
445 #define MDF_SITF_MANCHESTER_RISING_MODE   MDF_SITFCR_SITFMOD    /*!< Manchester mode rising edge logic 1
446                                                                      and falling edge logic 0 */
447 /**
448   * @}
449   */
450 
451 /** @defgroup MDF_SitfClockSource MDF serial interface clock source
452   * @{
453   */
454 #define MDF_SITF_CCK0_SOURCE  0x00000000U          /*!< Common clock 0 source */
455 #define MDF_SITF_CCK1_SOURCE  MDF_SITFCR_SCKSRC_0  /*!< Common clock 1 source */
456 #define MDF_SITF_CKI_SOURCE   MDF_SITFCR_SCKSRC_1  /*!< Dedicated input clock source.
457                                                         @note Not available for ADF instance */
458 /**
459   * @}
460   */
461 
462 /** @defgroup MDF_FilterBitstream MDF filter bitstream
463   * @{
464   */
465 #define MDF_BITSTREAM0_RISING   0x00000000U
466 #define MDF_BITSTREAM0_FALLING  MDF_BSMXCR_BSSEL_0
467 #define MDF_BITSTREAM1_RISING   MDF_BSMXCR_BSSEL_1      /*!< @note Not available for ADF instance */
468 #define MDF_BITSTREAM1_FALLING (MDF_BSMXCR_BSSEL_0 | \
469                                 MDF_BSMXCR_BSSEL_1)     /*!< @note Not available for ADF instance */
470 #define MDF_BITSTREAM2_RISING   MDF_BSMXCR_BSSEL_2      /*!< @note Not available for ADF instance */
471 #define MDF_BITSTREAM2_FALLING (MDF_BSMXCR_BSSEL_0 | \
472                                 MDF_BSMXCR_BSSEL_2)     /*!< @note Not available for ADF instance */
473 #define MDF_BITSTREAM3_RISING  (MDF_BSMXCR_BSSEL_1 | \
474                                 MDF_BSMXCR_BSSEL_2)     /*!< @note Not available for ADF instance */
475 #define MDF_BITSTREAM3_FALLING (MDF_BSMXCR_BSSEL_0 | \
476                                 MDF_BSMXCR_BSSEL_1 | \
477                                 MDF_BSMXCR_BSSEL_2)     /*!< @note Not available for ADF instance */
478 #define MDF_BITSTREAM4_RISING   MDF_BSMXCR_BSSEL_3      /*!< @note Not available for ADF instance */
479 #define MDF_BITSTREAM4_FALLING (MDF_BSMXCR_BSSEL_0 | \
480                                 MDF_BSMXCR_BSSEL_3)     /*!< @note Not available for ADF instance */
481 #define MDF_BITSTREAM5_RISING  (MDF_BSMXCR_BSSEL_1 | \
482                                 MDF_BSMXCR_BSSEL_3)     /*!< @note Not available for ADF instance */
483 #define MDF_BITSTREAM5_FALLING (MDF_BSMXCR_BSSEL_0 | \
484                                 MDF_BSMXCR_BSSEL_1 | \
485                                 MDF_BSMXCR_BSSEL_3)     /*!< @note Not available for ADF instance */
486 /**
487   * @}
488   */
489 
490 /** @defgroup MDF_ReshapeDecimationRatio MDF reshape filter decimation ratio
491   * @{
492   */
493 #define MDF_RSF_DECIMATION_RATIO_4  0x00000000U          /*!< Reshape filter decimation ratio is 4 */
494 #define MDF_RSF_DECIMATION_RATIO_1  MDF_DFLTRSFR_RSFLTD  /*!< Reshape filter decimation ratio is 1 */
495 /**
496   * @}
497   */
498 
499 /** @defgroup MDF_HighPassCutOffFreq MDF high pass filter cut-off frequency
500   * @{
501   */
502 #define MDF_HPF_CUTOFF_0_000625FPCM  0x00000000U          /*!< Cut-off frequency of 0.000625xFpcm */
503 #define MDF_HPF_CUTOFF_0_00125FPCM   MDF_DFLTRSFR_HPFC_0  /*!< Cut-off frequency of 0.00125xFpcm */
504 #define MDF_HPF_CUTOFF_0_0025FPCM    MDF_DFLTRSFR_HPFC_1  /*!< Cut-off frequency of 0.0025xFpcm */
505 #define MDF_HPF_CUTOFF_0_0095FPCM    MDF_DFLTRSFR_HPFC    /*!< Cut-off frequency of 0.0095xFpcm */
506 /**
507   * @}
508   */
509 
510 /** @defgroup MDF_IntegratorOutputDiv MDF integrator output division
511   * @{
512   */
513 #define MDF_INTEGRATOR_OUTPUT_DIV_128  0x00000000U            /*!< Integrator data outputs divided by 128 */
514 #define MDF_INTEGRATOR_OUTPUT_DIV_32   MDF_DFLTINTR_INTDIV_0  /*!< Integrator data outputs divided by 32 */
515 #define MDF_INTEGRATOR_OUTPUT_DIV_4    MDF_DFLTINTR_INTDIV_1  /*!< Integrator data outputs divided by 4 */
516 #define MDF_INTEGRATOR_OUTPUT_NO_DIV   MDF_DFLTINTR_INTDIV    /*!< Integrator data outputs not divided */
517 /**
518   * @}
519   */
520 
521 /** @defgroup MDF_SadMode MDF sound activity detector mode
522   * @{
523   */
524 #define MDF_SAD_VOICE_ACTIVITY_DETECTOR  0x00000000U         /*!< Voice activity detector */
525 #define MDF_SAD_SOUND_DETECTOR           MDF_SADCR_SADMOD_0  /*!< Sound detector */
526 #define MDF_SAD_AMBIENT_NOISE_DETECTOR   MDF_SADCR_SADMOD    /*!< Ambient noise detector */
527 /**
528   * @}
529   */
530 
531 /** @defgroup MDF_SadFrameSize MDF sound activity detector frame size
532   * @{
533   */
534 #define MDF_SAD_8_PCM_SAMPLES    0x00000000U                               /*!< Frame size of 8 PCM samples */
535 #define MDF_SAD_16_PCM_SAMPLES   MDF_SADCR_FRSIZE_0                        /*!< Frame size of 16 PCM samples */
536 #define MDF_SAD_32_PCM_SAMPLES   MDF_SADCR_FRSIZE_1                        /*!< Frame size of 32 PCM samples */
537 #define MDF_SAD_64_PCM_SAMPLES  (MDF_SADCR_FRSIZE_0 | MDF_SADCR_FRSIZE_1)  /*!< Frame size of 64 PCM samples */
538 #define MDF_SAD_128_PCM_SAMPLES  MDF_SADCR_FRSIZE_2                        /*!< Frame size of 128 PCM samples */
539 #define MDF_SAD_256_PCM_SAMPLES (MDF_SADCR_FRSIZE_0 | MDF_SADCR_FRSIZE_2)  /*!< Frame size of 256 PCM samples */
540 #define MDF_SAD_512_PCM_SAMPLES  MDF_SADCR_FRSIZE                          /*!< Frame size of 512 PCM samples */
541 /**
542   * @}
543   */
544 
545 /** @defgroup MDF_SadSoundTriggerEvent MDF sound activity detector trigger event
546   * @{
547   */
548 #define MDF_SAD_ENTER_DETECT       0x00000000U       /*!< Event when SAD enters in detect state */
549 #define MDF_SAD_ENTER_EXIT_DETECT  MDF_SADCR_DETCFG  /*!< Event when SAD enters or exits from detect state */
550 /**
551   * @}
552   */
553 
554 /** @defgroup MDF_SadDataMemoryTransfer MDF sound activity detector data memory transfer mode
555   * @{
556   */
557 #define MDF_SAD_NO_MEMORY_TRANSFER         0x00000000U         /*!< No memory transfer */
558 #define MDF_SAD_MEMORY_TRANSFER_IN_DETECT  MDF_SADCR_DATCAP_0  /*!< Memory transfer only in detect state */
559 #define MDF_SAD_MEMORY_TRANSFER_ALWAYS     MDF_SADCR_DATCAP    /*!< Memory transfer always */
560 /**
561   * @}
562   */
563 
564 /** @defgroup MDF_SadHangoverWindow MDF sound activity detector data hangover time window
565   * @{
566   */
567 #define MDF_SAD_HANGOVER_4_FRAMES    0x00000000U              /*!< Hangover window of 4 frames */
568 #define MDF_SAD_HANGOVER_8_FRAMES    MDF_SADCFGR_HGOVR_0      /*!< Hangover window of 8 frames */
569 #define MDF_SAD_HANGOVER_16_FRAMES   MDF_SADCFGR_HGOVR_1      /*!< Hangover window of 16 frames */
570 #define MDF_SAD_HANGOVER_32_FRAMES  (MDF_SADCFGR_HGOVR_0 | \
571                                      MDF_SADCFGR_HGOVR_1)     /*!< Hangover window of 32 frames */
572 #define MDF_SAD_HANGOVER_64_FRAMES   MDF_SADCFGR_HGOVR_2      /*!< Hangover window of 64 frames */
573 #define MDF_SAD_HANGOVER_128_FRAMES (MDF_SADCFGR_HGOVR_0 | \
574                                      MDF_SADCFGR_HGOVR_2)     /*!< Hangover window of 128 frames */
575 #define MDF_SAD_HANGOVER_256_FRAMES (MDF_SADCFGR_HGOVR_1 | \
576                                      MDF_SADCFGR_HGOVR_2)     /*!< Hangover window of 256 frames */
577 #define MDF_SAD_HANGOVER_512_FRAMES (MDF_SADCFGR_HGOVR_0 | \
578                                      MDF_SADCFGR_HGOVR_1 | \
579                                      MDF_SADCFGR_HGOVR_2)     /*!< Hangover window of 512 frames */
580 /**
581   * @}
582   */
583 
584 /** @defgroup MDF_SadLearningFrames MDF sound activity detector data learning frames
585   * @{
586   */
587 #define MDF_SAD_LEARNING_2_FRAMES   0x00000000U                                 /*!< 2 learning frames */
588 #define MDF_SAD_LEARNING_4_FRAMES   MDF_SADCFGR_LFRNB_0                         /*!< 4 learning frames */
589 #define MDF_SAD_LEARNING_8_FRAMES   MDF_SADCFGR_LFRNB_1                         /*!< 8 learning frames */
590 #define MDF_SAD_LEARNING_16_FRAMES (MDF_SADCFGR_LFRNB_0 | MDF_SADCFGR_LFRNB_1)  /*!< 16 learning frames */
591 #define MDF_SAD_LEARNING_32_FRAMES  MDF_SADCFGR_LFRNB                           /*!< 32 learning frames */
592 /**
593   * @}
594   */
595 
596 /** @defgroup MDF_SadSignalNoiseThreshold MDF sound activity detector data signal to noise threshold
597   * @{
598   */
599 #define MDF_SAD_SIGNAL_NOISE_3_5DB   0x00000000U              /*!< Signal to noise threshold is 3.5dB */
600 #define MDF_SAD_SIGNAL_NOISE_6DB     MDF_SADCFGR_SNTHR_0      /*!< Signal to noise threshold is 6dB */
601 #define MDF_SAD_SIGNAL_NOISE_9_5DB   MDF_SADCFGR_SNTHR_1      /*!< Signal to noise threshold is 9.5dB */
602 #define MDF_SAD_SIGNAL_NOISE_12DB   (MDF_SADCFGR_SNTHR_0 | \
603                                      MDF_SADCFGR_SNTHR_1)     /*!< Signal to noise threshold is 12dB */
604 #define MDF_SAD_SIGNAL_NOISE_15_6DB  MDF_SADCFGR_SNTHR_2      /*!< Signal to noise threshold is 15.6dB */
605 #define MDF_SAD_SIGNAL_NOISE_18DB   (MDF_SADCFGR_SNTHR_0 | \
606                                      MDF_SADCFGR_SNTHR_2)     /*!< Signal to noise threshold is 18dB */
607 #define MDF_SAD_SIGNAL_NOISE_21_6DB (MDF_SADCFGR_SNTHR_1 | \
608                                      MDF_SADCFGR_SNTHR_2)     /*!< Signal to noise threshold is 21.6dB */
609 #define MDF_SAD_SIGNAL_NOISE_24_1DB (MDF_SADCFGR_SNTHR_0 | \
610                                      MDF_SADCFGR_SNTHR_1 | \
611                                      MDF_SADCFGR_SNTHR_2)     /*!< Signal to noise threshold is 24.1dB */
612 #define MDF_SAD_SIGNAL_NOISE_27_6DB  MDF_SADCFGR_SNTHR_3      /*!< Signal to noise threshold is 27.6dB */
613 #define MDF_SAD_SIGNAL_NOISE_30_1DB (MDF_SADCFGR_SNTHR_0 | \
614                                      MDF_SADCFGR_SNTHR_3)     /*!< Signal to noise threshold is 30.1dB */
615 /**
616   * @}
617   */
618 
619 /** @defgroup MDF_FilterTriggerSource MDF filter trigger source
620   * @{
621   */
622 #define MDF_FILTER_TRIG_TRGO         0x00000000U
623 #define MDF_FILTER_TRIG_OLD_EVENT    MDF_DFLTCR_TRGSRC_0      /*!< @note Not available for ADF instance */
624 #define MDF_FILTER_TRIG_EXTI15       MDF_DFLTCR_TRGSRC_1
625 #define MDF_FILTER_TRIG_EXTI11      (MDF_DFLTCR_TRGSRC_0 | \
626                                      MDF_DFLTCR_TRGSRC_1)     /*!< @note Not available for ADF instance */
627 #define MDF_FILTER_TRIG_TIM1_TRGO    MDF_DFLTCR_TRGSRC_2      /*!< @note Not available for ADF instance */
628 #define MDF_FILTER_TRIG_TIM1_TRGO2  (MDF_DFLTCR_TRGSRC_0 | \
629                                      MDF_DFLTCR_TRGSRC_2)     /*!< @note Not available for ADF instance */
630 #define MDF_FILTER_TRIG_TIM3_TRGO   (MDF_DFLTCR_TRGSRC_1 | \
631                                      MDF_DFLTCR_TRGSRC_2)     /*!< @note Not available for ADF instance */
632 #define MDF_FILTER_TRIG_TIM4_TRGO   (MDF_DFLTCR_TRGSRC_0 | \
633                                      MDF_DFLTCR_TRGSRC_1 | \
634                                      MDF_DFLTCR_TRGSRC_2)     /*!< @note Not available for ADF instance */
635 #define MDF_FILTER_TRIG_TIM6_TRGO    MDF_DFLTCR_TRGSRC_3      /*!< @note Not available for ADF instance */
636 #define MDF_FILTER_TRIG_TIM7_TRGO   (MDF_DFLTCR_TRGSRC_0 | \
637                                      MDF_DFLTCR_TRGSRC_3)     /*!< @note Not available for ADF instance */
638 #define MDF_FILTER_TRIG_TIM8_TRGO   (MDF_DFLTCR_TRGSRC_1 | \
639                                      MDF_DFLTCR_TRGSRC_3)     /*!< @note Not available for ADF instance */
640 #define MDF_FILTER_TRIG_TIM8_TRGO2  (MDF_DFLTCR_TRGSRC_0 | \
641                                      MDF_DFLTCR_TRGSRC_1 | \
642                                      MDF_DFLTCR_TRGSRC_3)     /*!< @note Not available for ADF instance */
643 #define MDF_FILTER_TRIG_TIM15_TRGO  (MDF_DFLTCR_TRGSRC_2 | \
644                                      MDF_DFLTCR_TRGSRC_3)     /*!< @note Not available for ADF instance */
645 #define MDF_FILTER_TRIG_LPTIM1_OUT  (MDF_DFLTCR_TRGSRC_0 | \
646                                      MDF_DFLTCR_TRGSRC_2 | \
647                                      MDF_DFLTCR_TRGSRC_3)     /*!< @note Not available for ADF instance */
648 #define MDF_FILTER_TRIG_ADF_SAD_DET (MDF_DFLTCR_TRGSRC_1 | \
649                                      MDF_DFLTCR_TRGSRC_2 | \
650                                      MDF_DFLTCR_TRGSRC_3)     /*!< @note Not available for ADF instance */
651 #define MDF_FILTER_TRIG_ADF_TRGO     MDF_DFLTCR_TRGSRC        /*!< @note Not available for ADF instance */
652 /**
653   * @}
654   */
655 
656 /** @defgroup MDF_FilterTriggerEdge MDF filter trigger edge
657   * @{
658   */
659 #define MDF_FILTER_TRIG_RISING_EDGE   0x00000000U         /*!< Rising edge */
660 #define MDF_FILTER_TRIG_FALLING_EDGE  MDF_DFLTCR_TRGSENS  /*!< Falling edge */
661 /**
662   * @}
663   */
664 
665 /** @defgroup MDF_DataSource MDF data source
666   * @{
667   */
668 #define MDF_DATA_SOURCE_BSMX     0x00000000U            /*!< Data from bitstream matrix */
669 #define MDF_DATA_SOURCE_ADCITF1  MDF_DFLTCICR_DATSRC_1  /*!< Data from ADC interface 1.
670                                                              @note Not available for ADF instance */
671 #define MDF_DATA_SOURCE_ADCITF2  MDF_DFLTCICR_DATSRC    /*!< Data from ADC interface 2.
672                                                              @note Not available for ADF instance */
673 /**
674   * @}
675   */
676 
677 /** @defgroup MDF_CicMode MDF CIC mode
678   * @{
679   */
680 #define MDF_TWO_FILTERS_MCIC_FASTSINC  0x00000000U                /*!< Two filters, main filter in FastSinc order.
681                                                                        @note Not available for ADF instance */
682 #define MDF_TWO_FILTERS_MCIC_SINC1     MDF_DFLTCICR_CICMOD_0      /*!< Two filters, main filter in Sinc1 order.
683                                                                        @note Not available for ADF instance */
684 #define MDF_TWO_FILTERS_MCIC_SINC2     MDF_DFLTCICR_CICMOD_1      /*!< Two filters, main filter in Sinc2 order.
685                                                                        @note Not available for ADF instance */
686 #define MDF_TWO_FILTERS_MCIC_SINC3    (MDF_DFLTCICR_CICMOD_0 | \
687                                        MDF_DFLTCICR_CICMOD_1)     /*!< Two filters, main filter in Sinc3 order.
688                                                                        @note Not available for ADF instance */
689 #define MDF_ONE_FILTER_SINC4           MDF_DFLTCICR_CICMOD_2      /*!< One filter in Sinc4 order */
690 #define MDF_ONE_FILTER_SINC5          (MDF_DFLTCICR_CICMOD_0 | \
691                                        MDF_DFLTCICR_CICMOD_2)     /*!< One filter in Sinc5 order */
692 /**
693   * @}
694   */
695 
696 /** @defgroup MDF_AcquisitionMode MDF acquisition mode
697   * @{
698   */
699 #define MDF_MODE_ASYNC_CONT     0x00000000U              /*!< Asynchronous, continuous acquisition mode */
700 #define MDF_MODE_ASYNC_SINGLE   MDF_DFLTCR_ACQMOD_0      /*!< Asynchronous, single-shot acquisition mode.
701                                                               @note Not available for ADF instance with SAD usage */
702 #define MDF_MODE_SYNC_CONT      MDF_DFLTCR_ACQMOD_1      /*!< Synchronous, continuous acquisition mode */
703 #define MDF_MODE_SYNC_SINGLE   (MDF_DFLTCR_ACQMOD_0 | \
704                                 MDF_DFLTCR_ACQMOD_1)     /*!< Synchronous, single-shot acquisition mode.
705                                                               @note Not available for ADF instance with SAD usage*/
706 #define MDF_MODE_WINDOW_CONT    MDF_DFLTCR_ACQMOD_2      /*!< Window, continuous acquisition mode.
707                                                               @note Not available for ADF instance with SAD usage*/
708 #define MDF_MODE_SYNC_SNAPSHOT (MDF_DFLTCR_ACQMOD_0 | \
709                                 MDF_DFLTCR_ACQMOD_2)     /*!< Synchronous, snapshot acquisition mode.
710                                                               @note Not available for ADF instance */
711 /**
712   * @}
713   */
714 
715 /** @defgroup MDF_FifoThreshold MDF RXFIFO threshold
716   * @{
717   */
718 #define MDF_FIFO_THRESHOLD_NOT_EMPTY  0x00000000U     /*!< Event generated when RXFIFO is not empty */
719 #define MDF_FIFO_THRESHOLD_HALF_FULL  MDF_DFLTCR_FTH  /*!< Event generated when RXFIFO is half_full */
720 /**
721   * @}
722   */
723 
724 /** @defgroup MDF_SnapshotFormat MDF snapshot format
725   * @{
726   */
727 #define MDF_SNAPSHOT_23BITS  0x00000000U         /*!< Snapshot data resolution of 23 bits */
728 #define MDF_SNAPSHOT_16BITS  MDF_DFLTCR_SNPSFMT  /*!< Snapshot data resolution of 16 bits */
729 /**
730   * @}
731   */
732 
733 /** @defgroup MDF_BreakSignals MDF break signals
734   * @{
735   */
736 #define MDF_NO_BREAK_SIGNAL     0x00000000U /*!< No break signal */
737 #define MDF_TIM1_BREAK_SIGNAL   0x00000001U /*!< TIM1_BREAK signal */
738 #define MDF_TIM1_BREAK2_SIGNAL  0x00000002U /*!< TIM1_BREAK2 signal */
739 #define MDF_TIM8_BREAK_SIGNAL   0x00000004U /*!< TIM8_BREAK signal */
740 #define MDF_TIM8_BREAK2_SIGNAL  0x00000008U /*!< TIM8_BREAK2 signal */
741 /**
742   * @}
743   */
744 
745 /** @defgroup MDF_OldCicMode MDF out-off limit detector CIC mode
746   * @{
747   */
748 #define MDF_OLD_FILTER_FASTSINC  0x00000000U        /*!< Out-off limit detector filter in FastSinc order */
749 #define MDF_OLD_FILTER_SINC1     MDF_OLDCR_ACICN_0  /*!< Out-off limit detector filter in Sinc1 order */
750 #define MDF_OLD_FILTER_SINC2     MDF_OLDCR_ACICN_1  /*!< Out-off limit detector filter in Sinc2 order */
751 #define MDF_OLD_FILTER_SINC3     MDF_OLDCR_ACICN    /*!< Out-off limit detector filter in Sinc3 order */
752 /**
753   * @}
754   */
755 
756 /** @defgroup MDF_OldEventConfig MDF out-off limit detector event configuration
757   * @{
758   */
759 #define MDF_OLD_SIGNAL_OUTSIDE_THRESHOLDS  0x00000000U      /*!< Out-off limit detector event is generated
760                                                                  if signal is outside thresholds */
761 #define MDF_OLD_SIGNAL_IN_THRESHOLDS       MDF_OLDCR_THINB  /*!< Out-off limit detector event is generated
762                                                                  if signal is in thresholds */
763 /**
764   * @}
765   */
766 
767 /** @defgroup MDF_OldThresholdInfo MDF out-off limit detector threshold information
768   * @{
769   */
770 #define MDF_OLD_IN_THRESHOLDS   0x00000000U  /*!< The signal was in thresholds when out-off limit detection occurs */
771 #define MDF_OLD_HIGH_THRESHOLD  0x00000001U  /*!< The signal was higher than high threshold
772                                                   when out-off limit detection occurs */
773 #define MDF_OLD_LOW_THRESHOLD   0x00000002U  /*!< The signal was lower than low threshold
774                                                   when out-off limit detection occurs */
775 /**
776   * @}
777   */
778 
779 /**
780   * @}
781   */
782 
783 /* Exported macro ------------------------------------------------------------*/
784 /** @defgroup MDF_Exported_Macros  MDF Exported Macros
785   * @{
786   */
787 
788 /** @brief  Reset MDF handle state.
789   * @param  __HANDLE__ MDF handle.
790   * @retval None
791   */
792 #if (USE_HAL_MDF_REGISTER_CALLBACKS == 1)
793 #define __HAL_MDF_RESET_HANDLE_STATE(__HANDLE__) do{                                             \
794                                                       (__HANDLE__)->State = HAL_MDF_STATE_RESET; \
795                                                       (__HANDLE__)->MspInitCallback = NULL;      \
796                                                       (__HANDLE__)->MspDeInitCallback = NULL;    \
797                                                     } while(0)
798 #else /* USE_HAL_MDF_REGISTER_CALLBACKS */
799 #define __HAL_MDF_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_MDF_STATE_RESET)
800 #endif /* USE_HAL_MDF_REGISTER_CALLBACKS */
801 
802 /**
803   * @}
804   */
805 
806 /* Exported functions --------------------------------------------------------*/
807 /** @addtogroup MDF_Exported_Functions
808   * @{
809   */
810 
811 /* Initialization and de-initialization functions  ****************************/
812 /** @addtogroup MDF_Exported_Functions_Group1
813   * @{
814   */
815 HAL_StatusTypeDef HAL_MDF_Init(MDF_HandleTypeDef *hmdf);
816 HAL_StatusTypeDef HAL_MDF_DeInit(MDF_HandleTypeDef *hmdf);
817 void              HAL_MDF_MspInit(MDF_HandleTypeDef *hmdf);
818 void              HAL_MDF_MspDeInit(MDF_HandleTypeDef *hmdf);
819 #if (USE_HAL_MDF_REGISTER_CALLBACKS == 1)
820 HAL_StatusTypeDef HAL_MDF_RegisterCallback(MDF_HandleTypeDef        *hmdf,
821                                            HAL_MDF_CallbackIDTypeDef CallbackID,
822                                            pMDF_CallbackTypeDef      pCallback);
823 HAL_StatusTypeDef HAL_MDF_UnRegisterCallback(MDF_HandleTypeDef        *hmdf,
824                                              HAL_MDF_CallbackIDTypeDef CallbackID);
825 HAL_StatusTypeDef HAL_MDF_RegisterOldCallback(MDF_HandleTypeDef      *hmdf,
826                                               pMDF_OldCallbackTypeDef pCallback);
827 HAL_StatusTypeDef HAL_MDF_UnRegisterOldCallback(MDF_HandleTypeDef *hmdf);
828 HAL_StatusTypeDef HAL_MDF_RegisterSndLvlCallback(MDF_HandleTypeDef         *hmdf,
829                                                  pMDF_SndLvlCallbackTypeDef pCallback);
830 HAL_StatusTypeDef HAL_MDF_UnRegisterSndLvlCallback(MDF_HandleTypeDef *hmdf);
831 #endif /* USE_HAL_MDF_REGISTER_CALLBACKS */
832 /**
833   * @}
834   */
835 
836 /* Acquisition functions  *****************************************************/
837 /** @addtogroup MDF_Exported_Functions_Group2
838   * @{
839   */
840 HAL_StatusTypeDef HAL_MDF_AcqStart(MDF_HandleTypeDef *hmdf, const MDF_FilterConfigTypeDef *pFilterConfig);
841 HAL_StatusTypeDef HAL_MDF_PollForAcq(MDF_HandleTypeDef *hmdf, uint32_t Timeout);
842 HAL_StatusTypeDef HAL_MDF_PollForSnapshotAcq(MDF_HandleTypeDef *hmdf, uint32_t Timeout);
843 HAL_StatusTypeDef HAL_MDF_GetAcqValue(const MDF_HandleTypeDef *hmdf, int32_t *pValue);
844 HAL_StatusTypeDef HAL_MDF_GetSnapshotAcqValue(MDF_HandleTypeDef *hmdf, MDF_SnapshotParamTypeDef *pSnapshotParam);
845 HAL_StatusTypeDef HAL_MDF_AcqStop(MDF_HandleTypeDef *hmdf);
846 HAL_StatusTypeDef HAL_MDF_AcqStart_IT(MDF_HandleTypeDef *hmdf, const MDF_FilterConfigTypeDef *pFilterConfig);
847 HAL_StatusTypeDef HAL_MDF_AcqStop_IT(MDF_HandleTypeDef *hmdf);
848 HAL_StatusTypeDef HAL_MDF_AcqStart_DMA(MDF_HandleTypeDef *hmdf, const MDF_FilterConfigTypeDef *pFilterConfig,
849                                        const MDF_DmaConfigTypeDef *pDmaConfig);
850 HAL_StatusTypeDef HAL_MDF_AcqStop_DMA(MDF_HandleTypeDef *hmdf);
851 HAL_StatusTypeDef HAL_MDF_GenerateTrgo(const MDF_HandleTypeDef *hmdf);
852 HAL_StatusTypeDef HAL_MDF_SetDelay(MDF_HandleTypeDef *hmdf, uint32_t Delay);
853 HAL_StatusTypeDef HAL_MDF_GetDelay(const MDF_HandleTypeDef *hmdf, uint32_t *pDelay);
854 HAL_StatusTypeDef HAL_MDF_SetGain(MDF_HandleTypeDef *hmdf, int32_t Gain);
855 HAL_StatusTypeDef HAL_MDF_GetGain(const MDF_HandleTypeDef *hmdf, int32_t *pGain);
856 HAL_StatusTypeDef HAL_MDF_SetOffset(MDF_HandleTypeDef *hmdf, int32_t Offset);
857 HAL_StatusTypeDef HAL_MDF_GetOffset(const MDF_HandleTypeDef *hmdf, int32_t *pOffset);
858 HAL_StatusTypeDef HAL_MDF_PollForSndLvl(MDF_HandleTypeDef *hmdf, uint32_t Timeout, uint32_t *pSoundLevel,
859                                         uint32_t *pAmbientNoise);
860 HAL_StatusTypeDef HAL_MDF_PollForSad(MDF_HandleTypeDef *hmdf, uint32_t Timeout);
861 void              HAL_MDF_AcqCpltCallback(MDF_HandleTypeDef *hmdf);
862 void              HAL_MDF_AcqHalfCpltCallback(MDF_HandleTypeDef *hmdf);
863 void              HAL_MDF_SndLvlCallback(MDF_HandleTypeDef *hmdf, uint32_t SoundLevel, uint32_t AmbientNoise);
864 void              HAL_MDF_SadCallback(MDF_HandleTypeDef *hmdf);
865 /**
866   * @}
867   */
868 
869 /* Clock absence detection functions  *****************************************/
870 /** @addtogroup MDF_Exported_Functions_Group3
871   * @{
872   */
873 HAL_StatusTypeDef HAL_MDF_PollForCkab(MDF_HandleTypeDef *hmdf, uint32_t Timeout);
874 HAL_StatusTypeDef HAL_MDF_CkabStart_IT(MDF_HandleTypeDef *hmdf);
875 HAL_StatusTypeDef HAL_MDF_CkabStop_IT(MDF_HandleTypeDef *hmdf);
876 /**
877   * @}
878   */
879 
880 /* Short circuit detection functions  *****************************************/
881 /** @addtogroup MDF_Exported_Functions_Group4
882   * @{
883   */
884 HAL_StatusTypeDef HAL_MDF_ScdStart(MDF_HandleTypeDef *hmdf, const MDF_ScdConfigTypeDef *pScdConfig);
885 HAL_StatusTypeDef HAL_MDF_PollForScd(MDF_HandleTypeDef *hmdf, uint32_t Timeout);
886 HAL_StatusTypeDef HAL_MDF_ScdStop(MDF_HandleTypeDef *hmdf);
887 HAL_StatusTypeDef HAL_MDF_ScdStart_IT(MDF_HandleTypeDef *hmdf, const MDF_ScdConfigTypeDef *pScdConfig);
888 HAL_StatusTypeDef HAL_MDF_ScdStop_IT(MDF_HandleTypeDef *hmdf);
889 /**
890   * @}
891   */
892 
893 /* Out-off limit detection functions  *****************************************/
894 /** @addtogroup MDF_Exported_Functions_Group5
895   * @{
896   */
897 HAL_StatusTypeDef HAL_MDF_OldStart(MDF_HandleTypeDef *hmdf, const MDF_OldConfigTypeDef *pOldConfig);
898 HAL_StatusTypeDef HAL_MDF_PollForOld(MDF_HandleTypeDef *hmdf, uint32_t Timeout, uint32_t *pThresholdInfo);
899 HAL_StatusTypeDef HAL_MDF_OldStop(MDF_HandleTypeDef *hmdf);
900 HAL_StatusTypeDef HAL_MDF_OldStart_IT(MDF_HandleTypeDef *hmdf, const MDF_OldConfigTypeDef *pOldConfig);
901 HAL_StatusTypeDef HAL_MDF_OldStop_IT(MDF_HandleTypeDef *hmdf);
902 void              HAL_MDF_OldCallback(MDF_HandleTypeDef *hmdf, uint32_t ThresholdInfo);
903 /**
904   * @}
905   */
906 
907 /* Generic functions  *********************************************************/
908 /** @addtogroup MDF_Exported_Functions_Group6
909   * @{
910   */
911 void                 HAL_MDF_IRQHandler(MDF_HandleTypeDef *hmdf);
912 void                 HAL_MDF_ErrorCallback(MDF_HandleTypeDef *hmdf);
913 HAL_MDF_StateTypeDef HAL_MDF_GetState(const MDF_HandleTypeDef *hmdf);
914 uint32_t             HAL_MDF_GetError(const MDF_HandleTypeDef *hmdf);
915 /**
916   * @}
917   */
918 
919 /**
920   * @}
921   */
922 
923 /* Private macros ------------------------------------------------------------*/
924 /** @defgroup MDF_Private_Macros  MDF Private Macros
925   * @{
926   */
927 #define IS_MDF_INSTANCE(PARAM) (((PARAM) == MDF1_Filter0) || \
928                                 ((PARAM) == MDF1_Filter1) || \
929                                 ((PARAM) == MDF1_Filter2) || \
930                                 ((PARAM) == MDF1_Filter3) || \
931                                 ((PARAM) == MDF1_Filter4) || \
932                                 ((PARAM) == MDF1_Filter5))
933 
934 #define IS_ADF_INSTANCE(PARAM) ((PARAM) == ADF1_Filter0)
935 
936 #define IS_MDF_FILTER_BITSTREAM(PARAM) (((PARAM) == MDF_BITSTREAM0_RISING)  || \
937                                         ((PARAM) == MDF_BITSTREAM0_FALLING) || \
938                                         ((PARAM) == MDF_BITSTREAM1_RISING)  || \
939                                         ((PARAM) == MDF_BITSTREAM1_FALLING) || \
940                                         ((PARAM) == MDF_BITSTREAM2_RISING)  || \
941                                         ((PARAM) == MDF_BITSTREAM2_FALLING) || \
942                                         ((PARAM) == MDF_BITSTREAM3_RISING)  || \
943                                         ((PARAM) == MDF_BITSTREAM3_FALLING) || \
944                                         ((PARAM) == MDF_BITSTREAM4_RISING)  || \
945                                         ((PARAM) == MDF_BITSTREAM4_FALLING) || \
946                                         ((PARAM) == MDF_BITSTREAM5_RISING)  || \
947                                         ((PARAM) == MDF_BITSTREAM5_FALLING))
948 
949 #define IS_MDF_INTERLEAVED_FILTERS(PARAM) ((PARAM) <= 5U)
950 
951 #define IS_MDF_PROC_CLOCK_DIVIDER(PARAM) ((1U <= (PARAM)) && ((PARAM) <= 128U))
952 
953 #define IS_MDF_OUTPUT_CLOCK_PINS(PARAM) (((PARAM) == MDF_OUTPUT_CLOCK_0) || \
954                                          ((PARAM) == MDF_OUTPUT_CLOCK_1) || \
955                                          ((PARAM) == MDF_OUTPUT_CLOCK_ALL))
956 
957 #define IS_MDF_OUTPUT_CLOCK_DIVIDER(PARAM) ((1U <= (PARAM)) && ((PARAM) <= 16U))
958 
959 #define IS_MDF_OUTPUT_CLOCK_TRIGGER_SOURCE(PARAM) (((PARAM) == MDF_CLOCK_TRIG_TRGO)       || \
960                                                    ((PARAM) == MDF_CLOCK_TRIG_TIM1_TRGO)  || \
961                                                    ((PARAM) == MDF_CLOCK_TRIG_TIM1_TRGO2) || \
962                                                    ((PARAM) == MDF_CLOCK_TRIG_TIM8_TRGO)  || \
963                                                    ((PARAM) == MDF_CLOCK_TRIG_TIM8_TRGO2) || \
964                                                    ((PARAM) == MDF_CLOCK_TRIG_TIM3_TRGO)  || \
965                                                    ((PARAM) == MDF_CLOCK_TRIG_TIM4_TRGO)  || \
966                                                    ((PARAM) == MDF_CLOCK_TRIG_TIM6_TRGO)  || \
967                                                    ((PARAM) == MDF_CLOCK_TRIG_TIM7_TRGO)  || \
968                                                    ((PARAM) == MDF_CLOCK_TRIG_TIM15_TRGO) || \
969                                                    ((PARAM) == MDF_CLOCK_TRIG_SAD_DET)    || \
970                                                    ((PARAM) == MDF_CLOCK_TRIG_EXTI11)     || \
971                                                    ((PARAM) == MDF_CLOCK_TRIG_EXTI15)     || \
972                                                    ((PARAM) == MDF_CLOCK_TRIG_LPTIM1_OUT) || \
973                                                    ((PARAM) == MDF_CLOCK_TRIG_SAD_TRGO))
974 
975 #define IS_ADF_OUTPUT_CLOCK_TRIGGER_SOURCE(PARAM) (((PARAM) == MDF_CLOCK_TRIG_TRGO)       || \
976                                                    ((PARAM) == MDF_CLOCK_TRIG_EXTI15))
977 
978 #define IS_MDF_OUTPUT_CLOCK_TRIGGER_EDGE(PARAM) (((PARAM) == MDF_CLOCK_TRIG_RISING_EDGE) || \
979                                                  ((PARAM) == MDF_CLOCK_TRIG_FALLING_EDGE))
980 
981 #define IS_MDF_SITF_MODE(PARAM) (((PARAM) == MDF_SITF_LF_MASTER_SPI_MODE)      || \
982                                  ((PARAM) == MDF_SITF_NORMAL_SPI_MODE)         || \
983                                  ((PARAM) == MDF_SITF_MANCHESTER_FALLING_MODE) || \
984                                  ((PARAM) == MDF_SITF_MANCHESTER_RISING_MODE))
985 
986 #define IS_MDF_SITF_CLOCK_SOURCE(PARAM) (((PARAM) == MDF_SITF_CCK0_SOURCE) || \
987                                          ((PARAM) == MDF_SITF_CCK1_SOURCE) || \
988                                          ((PARAM) == MDF_SITF_CKI_SOURCE))
989 
990 #define IS_MDF_SITF_THRESHOLD(PARAM) ((4U <= (PARAM)) && ((PARAM) <= 31U))
991 
992 #define IS_MDF_CIC_MODE(PARAM) (((PARAM) == MDF_TWO_FILTERS_MCIC_FASTSINC) || \
993                                 ((PARAM) == MDF_TWO_FILTERS_MCIC_SINC1)    || \
994                                 ((PARAM) == MDF_TWO_FILTERS_MCIC_SINC2)    || \
995                                 ((PARAM) == MDF_TWO_FILTERS_MCIC_SINC3)    || \
996                                 ((PARAM) == MDF_ONE_FILTER_SINC4)          || \
997                                 ((PARAM) == MDF_ONE_FILTER_SINC5))
998 
999 #define IS_ADF_CIC_MODE(PARAM) (((PARAM) == MDF_ONE_FILTER_SINC4) || \
1000                                 ((PARAM) == MDF_ONE_FILTER_SINC5))
1001 
1002 #define IS_MDF_ACQUISITION_MODE(PARAM) (((PARAM) == MDF_MODE_ASYNC_CONT)   || \
1003                                         ((PARAM) == MDF_MODE_ASYNC_SINGLE) || \
1004                                         ((PARAM) == MDF_MODE_SYNC_CONT)    || \
1005                                         ((PARAM) == MDF_MODE_SYNC_SINGLE)  || \
1006                                         ((PARAM) == MDF_MODE_WINDOW_CONT)  || \
1007                                         ((PARAM) == MDF_MODE_SYNC_SNAPSHOT))
1008 
1009 #define IS_ADF_ACQUISITION_MODE(PARAM) (((PARAM) == MDF_MODE_ASYNC_CONT)   || \
1010                                         ((PARAM) == MDF_MODE_ASYNC_SINGLE) || \
1011                                         ((PARAM) == MDF_MODE_SYNC_CONT)    || \
1012                                         ((PARAM) == MDF_MODE_SYNC_SINGLE)  || \
1013                                         ((PARAM) == MDF_MODE_WINDOW_CONT))
1014 
1015 #define IS_MDF_DISCARD_SAMPLES(PARAM) ((PARAM) <= 255U)
1016 
1017 #define IS_MDF_FIFO_THRESHOLD(PARAM) (((PARAM) == MDF_FIFO_THRESHOLD_NOT_EMPTY) || \
1018                                       ((PARAM) == MDF_FIFO_THRESHOLD_HALF_FULL))
1019 
1020 #define IS_MDF_TRIGGER_SOURCE(PARAM) (((PARAM) == MDF_FILTER_TRIG_TRGO)        || \
1021                                       ((PARAM) == MDF_FILTER_TRIG_OLD_EVENT)   || \
1022                                       ((PARAM) == MDF_FILTER_TRIG_TIM1_TRGO)   || \
1023                                       ((PARAM) == MDF_FILTER_TRIG_TIM1_TRGO2)  || \
1024                                       ((PARAM) == MDF_FILTER_TRIG_TIM8_TRGO)   || \
1025                                       ((PARAM) == MDF_FILTER_TRIG_TIM8_TRGO2)  || \
1026                                       ((PARAM) == MDF_FILTER_TRIG_TIM3_TRGO)   || \
1027                                       ((PARAM) == MDF_FILTER_TRIG_TIM4_TRGO)   || \
1028                                       ((PARAM) == MDF_FILTER_TRIG_TIM6_TRGO)   || \
1029                                       ((PARAM) == MDF_FILTER_TRIG_TIM7_TRGO)   || \
1030                                       ((PARAM) == MDF_FILTER_TRIG_TIM15_TRGO)  || \
1031                                       ((PARAM) == MDF_FILTER_TRIG_ADF_SAD_DET) || \
1032                                       ((PARAM) == MDF_FILTER_TRIG_EXTI11)      || \
1033                                       ((PARAM) == MDF_FILTER_TRIG_EXTI15)      || \
1034                                       ((PARAM) == MDF_FILTER_TRIG_LPTIM1_OUT)  || \
1035                                       ((PARAM) == MDF_FILTER_TRIG_ADF_TRGO))
1036 
1037 #define IS_ADF_TRIGGER_SOURCE(PARAM) (((PARAM) == MDF_FILTER_TRIG_TRGO) || \
1038                                       ((PARAM) == MDF_FILTER_TRIG_EXTI15))
1039 
1040 #define IS_MDF_TRIGGER_EDGE(PARAM) (((PARAM) == MDF_FILTER_TRIG_RISING_EDGE) || \
1041                                     ((PARAM) == MDF_FILTER_TRIG_FALLING_EDGE))
1042 
1043 #define IS_MDF_SNAPSHOT_FORMAT(PARAM) (((PARAM) == MDF_SNAPSHOT_23BITS) || \
1044                                        ((PARAM) == MDF_SNAPSHOT_16BITS))
1045 
1046 #define IS_MDF_DATA_SOURCE(PARAM) (((PARAM) == MDF_DATA_SOURCE_BSMX)    || \
1047                                    ((PARAM) == MDF_DATA_SOURCE_ADCITF1) || \
1048                                    ((PARAM) == MDF_DATA_SOURCE_ADCITF2))
1049 
1050 #define IS_ADF_DATA_SOURCE(PARAM) ((PARAM) == MDF_DATA_SOURCE_BSMX)
1051 
1052 #define IS_MDF_DECIMATION_RATIO(PARAM) ((2U <= (PARAM)) && ((PARAM) <= 512U))
1053 
1054 #define IS_MDF_GAIN(PARAM) ((-16 <= (PARAM)) && ((PARAM) <= 24))
1055 
1056 #define IS_MDF_DELAY(PARAM) ((PARAM) <= 127U)
1057 
1058 #define IS_MDF_OFFSET(PARAM) ((-33554432 <= (PARAM)) && ((PARAM) <= 33554431))
1059 
1060 #define IS_MDF_RSF_DECIMATION_RATIO(PARAM) (((PARAM) == MDF_RSF_DECIMATION_RATIO_4) || \
1061                                             ((PARAM) == MDF_RSF_DECIMATION_RATIO_1))
1062 
1063 #define IS_MDF_HPF_CUTOFF_FREQ(PARAM) (((PARAM) == MDF_HPF_CUTOFF_0_000625FPCM) || \
1064                                        ((PARAM) == MDF_HPF_CUTOFF_0_00125FPCM)  || \
1065                                        ((PARAM) == MDF_HPF_CUTOFF_0_0025FPCM)   || \
1066                                        ((PARAM) == MDF_HPF_CUTOFF_0_0095FPCM))
1067 
1068 #define IS_MDF_INTEGRATOR_VALUE(PARAM) ((2U <= (PARAM)) && ((PARAM) <= 128U))
1069 
1070 #define IS_MDF_INTEGRATOR_OUTPUT_DIV(PARAM) (((PARAM) == MDF_INTEGRATOR_OUTPUT_DIV_128) || \
1071                                              ((PARAM) == MDF_INTEGRATOR_OUTPUT_DIV_32)  || \
1072                                              ((PARAM) == MDF_INTEGRATOR_OUTPUT_DIV_4)   || \
1073                                              ((PARAM) == MDF_INTEGRATOR_OUTPUT_NO_DIV))
1074 
1075 #define IS_MDF_SAD_MODE(PARAM) (((PARAM) == MDF_SAD_VOICE_ACTIVITY_DETECTOR) || \
1076                                 ((PARAM) == MDF_SAD_SOUND_DETECTOR)          || \
1077                                 ((PARAM) == MDF_SAD_AMBIENT_NOISE_DETECTOR))
1078 
1079 #define IS_MDF_SAD_FRAME_SIZE(PARAM) (((PARAM) == MDF_SAD_8_PCM_SAMPLES)   || \
1080                                       ((PARAM) == MDF_SAD_16_PCM_SAMPLES)  || \
1081                                       ((PARAM) == MDF_SAD_32_PCM_SAMPLES)  || \
1082                                       ((PARAM) == MDF_SAD_64_PCM_SAMPLES)  || \
1083                                       ((PARAM) == MDF_SAD_128_PCM_SAMPLES) || \
1084                                       ((PARAM) == MDF_SAD_256_PCM_SAMPLES) || \
1085                                       ((PARAM) == MDF_SAD_512_PCM_SAMPLES))
1086 
1087 #define IS_MDF_SAD_SOUND_TRIGGER(PARAM) (((PARAM) == MDF_SAD_ENTER_DETECT) || \
1088                                          ((PARAM) == MDF_SAD_ENTER_EXIT_DETECT))
1089 
1090 #define IS_MDF_SAD_DATA_MEMORY_TRANSFER(PARAM) (((PARAM) == MDF_SAD_NO_MEMORY_TRANSFER)        || \
1091                                                 ((PARAM) == MDF_SAD_MEMORY_TRANSFER_IN_DETECT) || \
1092                                                 ((PARAM) == MDF_SAD_MEMORY_TRANSFER_ALWAYS))
1093 
1094 #define IS_MDF_SAD_MIN_NOISE_LEVEL(PARAM) ((PARAM) <= 8191U)
1095 
1096 #define IS_MDF_SAD_HANGOVER_WINDOW(PARAM) (((PARAM) == MDF_SAD_HANGOVER_4_FRAMES)   || \
1097                                            ((PARAM) == MDF_SAD_HANGOVER_8_FRAMES)   || \
1098                                            ((PARAM) == MDF_SAD_HANGOVER_16_FRAMES)  || \
1099                                            ((PARAM) == MDF_SAD_HANGOVER_32_FRAMES)  || \
1100                                            ((PARAM) == MDF_SAD_HANGOVER_64_FRAMES)  || \
1101                                            ((PARAM) == MDF_SAD_HANGOVER_128_FRAMES) || \
1102                                            ((PARAM) == MDF_SAD_HANGOVER_256_FRAMES) || \
1103                                            ((PARAM) == MDF_SAD_HANGOVER_512_FRAMES))
1104 
1105 #define IS_MDF_SAD_LEARNING_FRAMES(PARAM) (((PARAM) == MDF_SAD_LEARNING_2_FRAMES)  || \
1106                                            ((PARAM) == MDF_SAD_LEARNING_4_FRAMES)  || \
1107                                            ((PARAM) == MDF_SAD_LEARNING_8_FRAMES)  || \
1108                                            ((PARAM) == MDF_SAD_LEARNING_16_FRAMES) || \
1109                                            ((PARAM) == MDF_SAD_LEARNING_32_FRAMES))
1110 
1111 #define IS_MDF_SAD_AMBIENT_NOISE_SLOPE(PARAM) ((PARAM) <= 7U)
1112 
1113 #define IS_MDF_SAD_SIGNAL_NOISE_THRESHOLD(PARAM) (((PARAM) == MDF_SAD_SIGNAL_NOISE_3_5DB)  || \
1114                                                   ((PARAM) == MDF_SAD_SIGNAL_NOISE_6DB)    || \
1115                                                   ((PARAM) == MDF_SAD_SIGNAL_NOISE_9_5DB)  || \
1116                                                   ((PARAM) == MDF_SAD_SIGNAL_NOISE_12DB)   || \
1117                                                   ((PARAM) == MDF_SAD_SIGNAL_NOISE_15_6DB) || \
1118                                                   ((PARAM) == MDF_SAD_SIGNAL_NOISE_18DB)   || \
1119                                                   ((PARAM) == MDF_SAD_SIGNAL_NOISE_21_6DB) || \
1120                                                   ((PARAM) == MDF_SAD_SIGNAL_NOISE_24_1DB) || \
1121                                                   ((PARAM) == MDF_SAD_SIGNAL_NOISE_27_6DB) || \
1122                                                   ((PARAM) == MDF_SAD_SIGNAL_NOISE_30_1DB))
1123 
1124 #define IS_MDF_SCD_THRESHOLD(PARAM) ((2U <= (PARAM)) && ((PARAM) <= 256U))
1125 
1126 #define IS_MDF_BREAK_SIGNAL(PARAM) ((PARAM) <= 15U)
1127 
1128 #define IS_MDF_OLD_CIC_MODE(PARAM) (((PARAM) == MDF_OLD_FILTER_FASTSINC) || \
1129                                     ((PARAM) == MDF_OLD_FILTER_SINC1)    || \
1130                                     ((PARAM) == MDF_OLD_FILTER_SINC2)    || \
1131                                     ((PARAM) == MDF_OLD_FILTER_SINC3))
1132 
1133 #define IS_MDF_OLD_DECIMATION_RATIO(PARAM) ((1U <= (PARAM)) && ((PARAM) <= 32U))
1134 
1135 #define IS_MDF_OLD_THRESHOLD(PARAM) ((-33554432 <= (PARAM)) && ((PARAM) <= 33554431))
1136 
1137 #define IS_MDF_OLD_EVENT_CONFIG(PARAM) (((PARAM) == MDF_OLD_SIGNAL_OUTSIDE_THRESHOLDS) || \
1138                                         ((PARAM) == MDF_OLD_SIGNAL_IN_THRESHOLDS))
1139 /**
1140   * @}
1141   */
1142 
1143 /**
1144   * @}
1145   */
1146 
1147 /**
1148   * @}
1149   */
1150 
1151 #ifdef __cplusplus
1152 }
1153 #endif
1154 
1155 #endif /* STM32N6xx_HAL_MDF_H */
1156