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