1 /** 2 ****************************************************************************** 3 * @file stm32h5xx_hal_fmac.h 4 * @author MCD Application Team 5 * @brief Header for stm32h5xx_hal_fmac.c module 6 ****************************************************************************** 7 * @attention 8 * 9 * Copyright (c) 2022 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 STM32H5xx_HAL_FMAC_H 21 #define STM32H5xx_HAL_FMAC_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes ------------------------------------------------------------------*/ 28 #include "stm32h5xx_hal_def.h" 29 30 #if defined(FMAC) 31 /** @addtogroup STM32H5xx_HAL_Driver 32 * @{ 33 */ 34 35 /** @addtogroup FMAC 36 * @{ 37 */ 38 39 /* Exported types ------------------------------------------------------------*/ 40 /** @defgroup FMAC_Exported_Types FMAC Exported Types 41 * @{ 42 */ 43 44 /** 45 * @brief FMAC HAL State Structure definition 46 */ 47 typedef enum 48 { 49 HAL_FMAC_STATE_RESET = 0x00U, /*!< FMAC not yet initialized or disabled */ 50 HAL_FMAC_STATE_READY = 0x20U, /*!< FMAC initialized and ready for use */ 51 HAL_FMAC_STATE_BUSY = 0x24U, /*!< FMAC internal process is ongoing */ 52 HAL_FMAC_STATE_BUSY_RD = 0x25U, /*!< FMAC reading configuration is ongoing */ 53 HAL_FMAC_STATE_BUSY_WR = 0x26U, /*!< FMAC writing configuration is ongoing */ 54 HAL_FMAC_STATE_TIMEOUT = 0xA0U, /*!< FMAC in Timeout state */ 55 HAL_FMAC_STATE_ERROR = 0xE0U /*!< FMAC in Error state */ 56 } HAL_FMAC_StateTypeDef; 57 58 /** 59 * @brief FMAC Handle Structure definition 60 */ 61 #if (USE_HAL_FMAC_REGISTER_CALLBACKS == 1) 62 typedef struct __FMAC_HandleTypeDef 63 #else 64 typedef struct 65 #endif /* USE_HAL_FMAC_REGISTER_CALLBACKS */ 66 { 67 FMAC_TypeDef *Instance; /*!< Register base address */ 68 69 uint32_t FilterParam; /*!< Filter configuration (operation and parameters). 70 Set to 0 if no valid configuration was applied. */ 71 72 uint8_t InputAccess; /*!< Access to the input buffer (internal memory area): 73 DMA, IT, Polling, None. 74 This parameter can be a value of @ref FMAC_Buffer_Access. */ 75 76 uint8_t OutputAccess; /*!< Access to the output buffer (internal memory area): 77 DMA, IT, Polling, None. 78 This parameter can be a value of @ref FMAC_Buffer_Access. */ 79 80 int16_t *pInput; /*!< Pointer to FMAC input data buffer */ 81 82 uint16_t InputCurrentSize; /*!< Number of the input elements already written into FMAC */ 83 84 uint16_t *pInputSize; /*!< Number of input elements to write (memory allocated to pInput). 85 In case of early interruption of the filter operation, 86 its value will be updated. */ 87 88 int16_t *pOutput; /*!< Pointer to FMAC output data buffer */ 89 90 uint16_t OutputCurrentSize; /*!< Number of the output elements already read from FMAC */ 91 92 uint16_t *pOutputSize; /*!< Number of output elements to read (memory allocated to pOutput). 93 In case of early interruption of the filter operation, 94 its value will be updated. */ 95 96 DMA_HandleTypeDef *hdmaIn; /*!< FMAC peripheral input data DMA handle parameters */ 97 98 DMA_HandleTypeDef *hdmaOut; /*!< FMAC peripheral output data DMA handle parameters */ 99 100 DMA_HandleTypeDef *hdmaPreload; /*!< FMAC peripheral preloaded data (X1, X2 and Y) DMA handle 101 parameters */ 102 103 #if (USE_HAL_FMAC_REGISTER_CALLBACKS == 1) 104 void (* ErrorCallback)(struct __FMAC_HandleTypeDef *hfmac); /*!< FMAC error callback */ 105 106 void (* HalfGetDataCallback)(struct __FMAC_HandleTypeDef *hfmac); /*!< FMAC get half data callback */ 107 108 void (* GetDataCallback)(struct __FMAC_HandleTypeDef *hfmac); /*!< FMAC get data callback */ 109 110 void (* HalfOutputDataReadyCallback)(struct __FMAC_HandleTypeDef *hfmac); /*!< FMAC half output data ready callback */ 111 112 void (* OutputDataReadyCallback)(struct __FMAC_HandleTypeDef *hfmac); /*!< FMAC output data ready callback */ 113 114 void (* FilterConfigCallback)(struct __FMAC_HandleTypeDef *hfmac); /*!< FMAC filter configuration callback */ 115 116 void (* FilterPreloadCallback)(struct __FMAC_HandleTypeDef *hfmac); /*!< FMAC filter preload callback */ 117 118 void (* MspInitCallback)(struct __FMAC_HandleTypeDef *hfmac); /*!< FMAC Msp Init callback */ 119 120 void (* MspDeInitCallback)(struct __FMAC_HandleTypeDef *hfmac); /*!< FMAC Msp DeInit callback */ 121 122 #endif /* (USE_HAL_FMAC_REGISTER_CALLBACKS) */ 123 124 HAL_LockTypeDef Lock; /*!< FMAC locking object */ 125 126 __IO HAL_FMAC_StateTypeDef State; /*!< FMAC state related to global handle management 127 This parameter can be a value of @ref HAL_FMAC_StateTypeDef */ 128 129 __IO HAL_FMAC_StateTypeDef RdState; /*!< FMAC state related to read operations (access to Y buffer) 130 This parameter can be a value of @ref HAL_FMAC_StateTypeDef */ 131 132 __IO HAL_FMAC_StateTypeDef WrState; /*!< FMAC state related to write operations (access to X1 buffer) 133 This parameter can be a value of @ref HAL_FMAC_StateTypeDef */ 134 135 __IO uint32_t ErrorCode; /*!< FMAC peripheral error code 136 This parameter can be a value of @ref FMAC_Error_Code */ 137 138 } FMAC_HandleTypeDef; 139 140 #if (USE_HAL_FMAC_REGISTER_CALLBACKS == 1) 141 /** 142 * @brief FMAC Callback ID enumeration definition 143 */ 144 typedef enum 145 { 146 HAL_FMAC_ERROR_CB_ID = 0x00U, /*!< FMAC error callback ID */ 147 HAL_FMAC_HALF_GET_DATA_CB_ID = 0x01U, /*!< FMAC get half data callback ID */ 148 HAL_FMAC_GET_DATA_CB_ID = 0x02U, /*!< FMAC get data callback ID */ 149 HAL_FMAC_HALF_OUTPUT_DATA_READY_CB_ID = 0x03U, /*!< FMAC half output data ready callback ID */ 150 HAL_FMAC_OUTPUT_DATA_READY_CB_ID = 0x04U, /*!< FMAC output data ready callback ID */ 151 HAL_FMAC_FILTER_CONFIG_CB_ID = 0x05U, /*!< FMAC filter configuration callback ID */ 152 HAL_FMAC_FILTER_PRELOAD_CB_ID = 0x06U, /*!< FMAC filter preload callback ID */ 153 154 HAL_FMAC_MSPINIT_CB_ID = 0x07U, /*!< FMAC MspInit callback ID */ 155 HAL_FMAC_MSPDEINIT_CB_ID = 0x08U, /*!< FMAC MspDeInit callback ID */ 156 } HAL_FMAC_CallbackIDTypeDef; 157 158 /** 159 * @brief HAL FMAC Callback pointer definition 160 */ 161 typedef void (*pFMAC_CallbackTypeDef)(FMAC_HandleTypeDef *hfmac); /*!< pointer to an FMAC callback function */ 162 163 #endif /* USE_HAL_FMAC_REGISTER_CALLBACKS */ 164 165 /** 166 * @brief FMAC Filter Configuration Structure definition 167 */ 168 typedef struct 169 { 170 uint8_t InputBaseAddress; /*!< Base address of the input buffer (X1) within the internal memory 171 (0x00 to 0xFF). Ignored if InputBufferSize is set to 0 172 (previous configuration kept). 173 Note: the buffers can overlap or even coincide exactly. */ 174 175 uint8_t InputBufferSize; /*!< Number of 16-bit words allocated to the input buffer 176 (including the optional "headroom"). 177 0 if a previous configuration should be kept. */ 178 179 uint32_t InputThreshold; /*!< Input threshold: the buffer full flag will be set if the number 180 of free spaces in the buffer is lower than this threshold. 181 This parameter can be a value 182 of @ref FMAC_Data_Buffer_Threshold. */ 183 184 uint8_t CoeffBaseAddress; /*!< Base address of the coefficient buffer (X2) within the internal 185 memory (0x00 to 0xFF). Ignored if CoeffBufferSize is set to 0 186 (previous configuration kept). 187 Note: the buffers can overlap or even coincide exactly. */ 188 189 uint8_t CoeffBufferSize; /*!< Number of 16-bit words allocated to the coefficient buffer. 190 0 if a previous configuration should be kept. */ 191 192 uint8_t OutputBaseAddress; /*!< Base address of the output buffer (Y) within the internal 193 memory (0x00 to 0xFF). Ignored if OuputBufferSize is set to 0 194 (previous configuration kept). 195 Note: the buffers can overlap or even coincide exactly. */ 196 197 uint8_t OutputBufferSize; /*!< Number of 16-bit words allocated to the output buffer 198 (including the optional "headroom"). 199 0 if a previous configuration should be kept. */ 200 201 uint32_t OutputThreshold; /*!< Output threshold: the buffer empty flag will be set if the number 202 of unread values in the buffer is lower than this threshold. 203 This parameter can be a value 204 of @ref FMAC_Data_Buffer_Threshold. */ 205 206 int16_t *pCoeffA; /*!< [IIR only] Initialization of the coefficient vector A. 207 If not needed, it should be set to NULL. */ 208 209 uint8_t CoeffASize; /*!< Size of the coefficient vector A. */ 210 211 int16_t *pCoeffB; /*!< Initialization of the coefficient vector B. 212 If not needed (re-use of a previously loaded buffer), 213 it should be set to NULL. */ 214 215 uint8_t CoeffBSize; /*!< Size of the coefficient vector B. */ 216 217 uint8_t InputAccess; /*!< Access to the input buffer (internal memory area): 218 DMA, IT, Polling, None. 219 This parameter can be a value of @ref FMAC_Buffer_Access. */ 220 221 uint8_t OutputAccess; /*!< Access to the output buffer (internal memory area): 222 DMA, IT, Polling, None. 223 This parameter can be a value of @ref FMAC_Buffer_Access. */ 224 225 uint32_t Clip; /*!< Enable or disable the clipping feature. If the q1.15 range 226 is exceeded, wrapping is done when the clipping feature is disabled 227 and saturation is done when the clipping feature is enabled. 228 This parameter can be a value of @ref FMAC_Clip_State. */ 229 230 uint32_t Filter; /*!< Filter type. 231 This parameter can be a value 232 of @ref FMAC_Functions (filter related values). */ 233 234 uint8_t P; /*!< Parameter P (vector length, number of filter taps, etc.). */ 235 236 uint8_t Q; /*!< Parameter Q (vector length, etc.). Ignored if not needed. */ 237 238 uint8_t R; /*!< Parameter R (gain, etc.). Ignored if not needed. */ 239 240 } FMAC_FilterConfigTypeDef; 241 242 /** 243 * @} 244 */ 245 246 247 /* Exported constants --------------------------------------------------------*/ 248 249 250 /** @defgroup FMAC_Exported_Constants FMAC Exported Constants 251 * @{ 252 */ 253 254 /** @defgroup FMAC_Error_Code FMAC Error code 255 * @{ 256 */ 257 #define HAL_FMAC_ERROR_NONE 0x00000000U /*!< No error */ 258 #define HAL_FMAC_ERROR_SAT 0x00000001U /*!< Saturation error */ 259 #define HAL_FMAC_ERROR_UNFL 0x00000002U /*!< Underflow error */ 260 #define HAL_FMAC_ERROR_OVFL 0x00000004U /*!< Overflow error */ 261 #define HAL_FMAC_ERROR_DMA 0x00000008U /*!< DMA error */ 262 #define HAL_FMAC_ERROR_RESET 0x00000010U /*!< Reset error */ 263 #define HAL_FMAC_ERROR_PARAM 0x00000020U /*!< Parameter error */ 264 #if (USE_HAL_FMAC_REGISTER_CALLBACKS == 1) 265 #define HAL_FMAC_ERROR_INVALID_CALLBACK 0x00000040U /*!< Invalid Callback error */ 266 #endif /* USE_HAL_FMAC_REGISTER_CALLBACKS */ 267 #define HAL_FMAC_ERROR_TIMEOUT 0x00000080U /*!< Timeout error */ 268 269 /** 270 * @} 271 */ 272 273 /** @defgroup FMAC_Functions FMAC Functions 274 * @{ 275 */ 276 #define FMAC_FUNC_LOAD_X1 (FMAC_PARAM_FUNC_0) /*!< Load X1 buffer */ 277 #define FMAC_FUNC_LOAD_X2 (FMAC_PARAM_FUNC_1) /*!< Load X2 buffer */ 278 #define FMAC_FUNC_LOAD_Y (FMAC_PARAM_FUNC_1 | FMAC_PARAM_FUNC_0) /*!< Load Y buffer */ 279 #define FMAC_FUNC_CONVO_FIR (FMAC_PARAM_FUNC_3) /*!< Convolution (FIR filter) */ 280 #define FMAC_FUNC_IIR_DIRECT_FORM_1 (FMAC_PARAM_FUNC_3 | FMAC_PARAM_FUNC_0) /*!< IIR filter (direct form 1) */ 281 /** 282 * @} 283 */ 284 285 /** @defgroup FMAC_Data_Buffer_Threshold FMAC Data Buffer Threshold 286 * @{ 287 * @note This parameter sets a watermark for buffer full (input) or buffer empty (output). 288 */ 289 #define FMAC_THRESHOLD_1 0x00000000U /*!< Input: Buffer full flag set if the number of free spaces 290 in the buffer is less than 1. 291 Output: Buffer empty flag set if the number 292 of unread values in the buffer is less than 1. */ 293 #define FMAC_THRESHOLD_2 0x01000000U /*!< Input: Buffer full flag set if the number of free spaces 294 in the buffer is less than 2. 295 Output: Buffer empty flag set if the number 296 of unread values in the buffer is less than 2. */ 297 #define FMAC_THRESHOLD_4 0x02000000U /*!< Input: Buffer full flag set if the number of free spaces 298 in the buffer is less than 4. 299 Output: Buffer empty flag set if the number 300 of unread values in the buffer is less than 4. */ 301 #define FMAC_THRESHOLD_8 0x03000000U /*!< Input: Buffer full flag set if the number of free spaces 302 in the buffer is less than 8. 303 Output: Buffer empty flag set if the number 304 of unread values in the buffer is less than 8. */ 305 #define FMAC_THRESHOLD_NO_VALUE 0xFFFFFFFFU /*!< The configured threshold value shouldn't be changed */ 306 /** 307 * @} 308 */ 309 310 /** @defgroup FMAC_Buffer_Access FMAC Buffer Access 311 * @{ 312 */ 313 #define FMAC_BUFFER_ACCESS_NONE 0x00U /*!< Buffer handled by an external IP (ADC for instance) */ 314 #define FMAC_BUFFER_ACCESS_DMA 0x01U /*!< Buffer accessed through DMA */ 315 #define FMAC_BUFFER_ACCESS_POLLING 0x02U /*!< Buffer accessed through polling */ 316 #define FMAC_BUFFER_ACCESS_IT 0x03U /*!< Buffer accessed through interruptions */ 317 /** 318 * @} 319 */ 320 321 /** @defgroup FMAC_Clip_State FMAC Clip State 322 * @{ 323 */ 324 #define FMAC_CLIP_DISABLED 0x00000000U /*!< Clipping disabled */ 325 #define FMAC_CLIP_ENABLED FMAC_CR_CLIPEN /*!< Clipping enabled */ 326 /** 327 * @} 328 */ 329 330 /** @defgroup FMAC_Flags FMAC status flags 331 * @{ 332 */ 333 #define FMAC_FLAG_YEMPTY FMAC_SR_YEMPTY /*!< Y Buffer Empty Flag */ 334 #define FMAC_FLAG_X1FULL FMAC_SR_X1FULL /*!< X1 Buffer Full Flag */ 335 #define FMAC_FLAG_OVFL FMAC_SR_OVFL /*!< Overflow Error Flag */ 336 #define FMAC_FLAG_UNFL FMAC_SR_UNFL /*!< Underflow Error Flag */ 337 #define FMAC_FLAG_SAT FMAC_SR_SAT /*!< Saturation Error Flag 338 (this helps in debugging a filter) */ 339 /** 340 * @} 341 */ 342 343 /** @defgroup FMAC_Interrupts_Enable FMAC Interrupts Enable bit 344 * @{ 345 */ 346 #define FMAC_IT_RIEN FMAC_CR_RIEN /*!< Read Interrupt Enable */ 347 #define FMAC_IT_WIEN FMAC_CR_WIEN /*!< Write Interrupt Enable */ 348 #define FMAC_IT_OVFLIEN FMAC_CR_OVFLIEN /*!< Overflow Error Interrupt Enable */ 349 #define FMAC_IT_UNFLIEN FMAC_CR_UNFLIEN /*!< Underflow Error Interrupt Enable */ 350 #define FMAC_IT_SATIEN FMAC_CR_SATIEN /*!< Saturation Error Interrupt Enable 351 (this helps in debugging a filter) */ 352 /** 353 * @} 354 */ 355 356 /** 357 * @} 358 */ 359 360 361 /* Exported variables --------------------------------------------------------*/ 362 /** @defgroup FMAC_Exported_variables FMAC Exported variables 363 * @{ 364 */ 365 /** 366 * @} 367 */ 368 369 /* Exported macros -----------------------------------------------------------*/ 370 /** @defgroup FMAC_Exported_Macros FMAC Exported Macros 371 * @{ 372 */ 373 374 /** 375 * @brief Reset FMAC handle state. 376 * @param __HANDLE__ FMAC handle. 377 * @retval None 378 */ 379 #if (USE_HAL_FMAC_REGISTER_CALLBACKS == 1) 380 #define __HAL_FMAC_RESET_HANDLE_STATE(__HANDLE__) do{ \ 381 (__HANDLE__)->State = HAL_FMAC_STATE_RESET; \ 382 (__HANDLE__)->MspInitCallback = NULL; \ 383 (__HANDLE__)->MspDeInitCallback = NULL; \ 384 } while(0U) 385 #else 386 #define __HAL_FMAC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_FMAC_STATE_RESET) 387 #endif /* USE_HAL_FMAC_REGISTER_CALLBACKS */ 388 389 /** 390 * @brief Enable the specified FMAC interrupt 391 * @param __HANDLE__ FMAC handle. 392 * @param __INTERRUPT__ FMAC Interrupt. 393 * This parameter can be any combination of the following values: 394 * @arg @ref FMAC_IT_RIEN Read interrupt enable 395 * @arg @ref FMAC_IT_WIEN Write interrupt enable 396 * @arg @ref FMAC_IT_OVFLIEN Overflow error interrupt enable 397 * @arg @ref FMAC_IT_UNFLIEN Underflow error interrupt enable 398 * @arg @ref FMAC_IT_SATIEN Saturation error interrupt enable (this helps in debugging a filter) 399 * @retval None 400 */ 401 #define __HAL_FMAC_ENABLE_IT(__HANDLE__, __INTERRUPT__) \ 402 (((__HANDLE__)->Instance->CR) |= (__INTERRUPT__)) 403 404 /** 405 * @brief Disable the FMAC interrupt 406 * @param __HANDLE__ FMAC handle. 407 * @param __INTERRUPT__ FMAC Interrupt. 408 * This parameter can be any combination of the following values: 409 * @arg @ref FMAC_IT_RIEN Read interrupt enable 410 * @arg @ref FMAC_IT_WIEN Write interrupt enable 411 * @arg @ref FMAC_IT_OVFLIEN Overflow error interrupt enable 412 * @arg @ref FMAC_IT_UNFLIEN Underflow error interrupt enable 413 * @arg @ref FMAC_IT_SATIEN Saturation error interrupt enable (this helps in debugging a filter) 414 * @retval None 415 */ 416 #define __HAL_FMAC_DISABLE_IT(__HANDLE__, __INTERRUPT__) \ 417 (((__HANDLE__)->Instance->CR) &= ~(__INTERRUPT__)) 418 419 /** 420 * @brief Check whether the specified FMAC interrupt occurred or not. 421 * @param __HANDLE__ FMAC handle. 422 * @param __INTERRUPT__ FMAC interrupt to check. 423 * This parameter can be any combination of the following values: 424 * @arg @ref FMAC_FLAG_YEMPTY Y Buffer Empty Flag 425 * @arg @ref FMAC_FLAG_X1FULL X1 Buffer Full Flag 426 * @arg @ref FMAC_FLAG_OVFL Overflow Error Flag 427 * @arg @ref FMAC_FLAG_UNFL Underflow Error Flag 428 * @arg @ref FMAC_FLAG_SAT Saturation Error Flag 429 * @retval SET (interrupt occurred) or RESET (interrupt did not occurred) 430 */ 431 #define __HAL_FMAC_GET_IT(__HANDLE__, __INTERRUPT__) \ 432 (((__HANDLE__)->Instance->SR) &= ~(__INTERRUPT__)) 433 434 /** 435 * @brief Clear specified FMAC interrupt status. Dummy macro as the 436 interrupt status flags are read-only. 437 * @param __HANDLE__ FMAC handle. 438 * @param __INTERRUPT__ FMAC interrupt to clear. 439 * @retval None 440 */ 441 #define __HAL_FMAC_CLEAR_IT(__HANDLE__, __INTERRUPT__) /* Dummy macro */ 442 443 /** 444 * @brief Check whether the specified FMAC status flag is set or not. 445 * @param __HANDLE__ FMAC handle. 446 * @param __FLAG__ FMAC flag to check. 447 * This parameter can be any combination of the following values: 448 * @arg @ref FMAC_FLAG_YEMPTY Y Buffer Empty Flag 449 * @arg @ref FMAC_FLAG_X1FULL X1 Buffer Full Flag 450 * @arg @ref FMAC_FLAG_OVFL Overflow Error Flag 451 * @arg @ref FMAC_FLAG_UNFL Underflow Error Flag 452 * @arg @ref FMAC_FLAG_SAT Saturation error Flag 453 * @retval SET (flag is set) or RESET (flag is reset) 454 */ 455 #define __HAL_FMAC_GET_FLAG(__HANDLE__, __FLAG__) \ 456 ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__)) 457 458 /** 459 * @brief Clear specified FMAC status flag. Dummy macro as no 460 flag can be cleared. 461 * @param __HANDLE__ FMAC handle. 462 * @param __FLAG__ FMAC flag to clear. 463 * @retval None 464 */ 465 #define __HAL_FMAC_CLEAR_FLAG(__HANDLE__, __FLAG__) /* Dummy macro */ 466 467 /** 468 * @brief Check whether the specified FMAC interrupt is enabled or not. 469 * @param __HANDLE__ FMAC handle. 470 * @param __INTERRUPT__ FMAC interrupt to check. 471 * This parameter can be one of the following values: 472 * @arg @ref FMAC_IT_RIEN Read interrupt enable 473 * @arg @ref FMAC_IT_WIEN Write interrupt enable 474 * @arg @ref FMAC_IT_OVFLIEN Overflow error interrupt enable 475 * @arg @ref FMAC_IT_UNFLIEN Underflow error interrupt enable 476 * @arg @ref FMAC_IT_SATIEN Saturation error interrupt enable (this helps in debugging a filter) 477 * @retval FlagStatus 478 */ 479 #define __HAL_FMAC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) \ 480 (((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) 481 482 /** 483 * @} 484 */ 485 486 /* Private defines -----------------------------------------------------------*/ 487 /** @addtogroup FMAC_Private_Constants 488 * @{ 489 */ 490 491 #define FMAC_PARAM_P_MAX_IIR 64U /*!< Maximum value of P parameter with IIR */ 492 #define FMAC_PARAM_P_MAX_FIR 127U /*!< Maximum value of P parameter with FIR */ 493 #define FMAC_PARAM_P_MIN 2U /*!< Minimum value of P parameter */ 494 #define FMAC_PARAM_Q_MAX 63U /*!< Maximum value of Q parameter */ 495 #define FMAC_PARAM_Q_MIN 1U /*!< Minimum value of Q parameter */ 496 #define FMAC_PARAM_R_MAX 7U /*!< Maximum value of R parameter */ 497 498 /** 499 * @} 500 */ 501 502 /* Private Macros-----------------------------------------------------------*/ 503 /** @addtogroup FMAC_Private_Macros FMAC Private Macros 504 * @{ 505 */ 506 507 /** 508 * @brief Verify the FMAC function. 509 * @param __FUNCTION__ ID of the function. 510 * @retval SET (__FUNCTION__ is a valid value) or RESET (__FUNCTION__ is invalid) 511 */ 512 #define IS_FMAC_FUNCTION(__FUNCTION__) (((__FUNCTION__) == FMAC_FUNC_LOAD_X1) || \ 513 ((__FUNCTION__) == FMAC_FUNC_LOAD_X2) || \ 514 ((__FUNCTION__) == FMAC_FUNC_LOAD_Y) || \ 515 ((__FUNCTION__) == FMAC_FUNC_CONVO_FIR) || \ 516 ((__FUNCTION__) == FMAC_FUNC_IIR_DIRECT_FORM_1)) 517 518 /** 519 * @brief Verify the FMAC load function used for input data, output data or coefficients. 520 * @param __FUNCTION__ ID of the load function. 521 * @retval SET (__FUNCTION__ is a valid value) or RESET (__FUNCTION__ is invalid) 522 */ 523 #define IS_FMAC_LOAD_FUNCTION(__FUNCTION__) (((__FUNCTION__) == FMAC_FUNC_LOAD_X1) || \ 524 ((__FUNCTION__) == FMAC_FUNC_LOAD_X2) || \ 525 ((__FUNCTION__) == FMAC_FUNC_LOAD_Y)) 526 527 /** 528 * @brief Verify the FMAC load function used with N values as input or output data. 529 * @param __FUNCTION__ ID of the load function. 530 * @retval SET (__FUNCTION__ is a valid value) or RESET (__FUNCTION__ is invalid) 531 */ 532 #define IS_FMAC_N_LOAD_FUNCTION(__FUNCTION__) (((__FUNCTION__) == FMAC_FUNC_LOAD_X1) || \ 533 ((__FUNCTION__) == FMAC_FUNC_LOAD_Y)) 534 535 /** 536 * @brief Verify the FMAC load function used with N + M values as coefficients. 537 * @param __FUNCTION__ ID of the load function. 538 * @retval SET (__FUNCTION__ is a valid value) or RESET (__FUNCTION__ is invalid) 539 */ 540 #define IS_FMAC_N_M_LOAD_FUNCTION(__FUNCTION__) ((__FUNCTION__) == FMAC_FUNC_LOAD_X2) 541 542 /** 543 * @brief Verify the FMAC filter function. 544 * @param __FUNCTION__ ID of the filter function. 545 * @retval SET (__FUNCTION__ is a valid value) or RESET (__FUNCTION__ is invalid) 546 */ 547 #define IS_FMAC_FILTER_FUNCTION(__FUNCTION__) (((__FUNCTION__) == FMAC_FUNC_CONVO_FIR) || \ 548 ((__FUNCTION__) == FMAC_FUNC_IIR_DIRECT_FORM_1)) 549 550 551 /** 552 * @brief Verify the FMAC threshold. 553 * @param __THRESHOLD__ Value of the threshold. 554 * @retval SET (__THRESHOLD__ is a valid value) or RESET (__THRESHOLD__ is invalid) 555 */ 556 #define IS_FMAC_THRESHOLD(__THRESHOLD__) (((__THRESHOLD__) == FMAC_THRESHOLD_1) || \ 557 ((__THRESHOLD__) == FMAC_THRESHOLD_2) || \ 558 ((__THRESHOLD__) == FMAC_THRESHOLD_4) || \ 559 ((__THRESHOLD__) == FMAC_THRESHOLD_NO_VALUE) || \ 560 ((__THRESHOLD__) == FMAC_THRESHOLD_8)) 561 562 /** 563 * @brief Verify the FMAC filter parameter P. 564 * @param __P__ Value of the filter parameter P. 565 * @param __FUNCTION__ ID of the filter function. 566 * @retval SET (__P__ is a valid value) or RESET (__P__ is invalid) 567 */ 568 #define IS_FMAC_PARAM_P(__FUNCTION__, __P__) ((((__FUNCTION__) == FMAC_FUNC_CONVO_FIR) && \ 569 (((__P__) >= FMAC_PARAM_P_MIN) && \ 570 ((__P__) <= FMAC_PARAM_P_MAX_FIR))) || \ 571 (((__FUNCTION__) == FMAC_FUNC_IIR_DIRECT_FORM_1) && \ 572 (((__P__) >= FMAC_PARAM_P_MIN) && \ 573 ((__P__) <= FMAC_PARAM_P_MAX_IIR)))) 574 575 /** 576 * @brief Verify the FMAC filter parameter Q. 577 * @param __Q__ Value of the filter parameter Q. 578 * @param __FUNCTION__ ID of the filter function. 579 * @retval SET (__Q__ is a valid value) or RESET (__Q__ is invalid) 580 */ 581 #define IS_FMAC_PARAM_Q(__FUNCTION__, __Q__) ( ((__FUNCTION__) == FMAC_FUNC_CONVO_FIR) || \ 582 (((__FUNCTION__) == FMAC_FUNC_IIR_DIRECT_FORM_1) && \ 583 (((__Q__) >= FMAC_PARAM_Q_MIN) && ((__Q__) <= FMAC_PARAM_Q_MAX))) ) 584 585 /** 586 * @brief Verify the FMAC filter parameter R. 587 * @param __R__ Value of the filter parameter. 588 * @param __FUNCTION__ ID of the filter function. 589 * @retval SET (__R__ is a valid value) or RESET (__R__ is invalid) 590 */ 591 #define IS_FMAC_PARAM_R(__FUNCTION__, __R__) ( (((__FUNCTION__) == FMAC_FUNC_CONVO_FIR) || \ 592 ((__FUNCTION__) == FMAC_FUNC_IIR_DIRECT_FORM_1)) && \ 593 ((__R__) <= FMAC_PARAM_R_MAX)) 594 595 /** 596 * @brief Verify the FMAC buffer access. 597 * @param __BUFFER_ACCESS__ Type of access. 598 * @retval SET (__BUFFER_ACCESS__ is a valid value) or RESET (__BUFFER_ACCESS__ is invalid) 599 */ 600 #define IS_FMAC_BUFFER_ACCESS(__BUFFER_ACCESS__) (((__BUFFER_ACCESS__) == FMAC_BUFFER_ACCESS_NONE) || \ 601 ((__BUFFER_ACCESS__) == FMAC_BUFFER_ACCESS_DMA) || \ 602 ((__BUFFER_ACCESS__) == FMAC_BUFFER_ACCESS_POLLING) || \ 603 ((__BUFFER_ACCESS__) == FMAC_BUFFER_ACCESS_IT)) 604 605 /** 606 * @brief Verify the FMAC clip feature. 607 * @param __CLIP_STATE__ Clip state. 608 * @retval SET (__CLIP_STATE__ is a valid value) or RESET (__CLIP_STATE__ is invalid) 609 */ 610 #define IS_FMAC_CLIP_STATE(__CLIP_STATE__) (((__CLIP_STATE__) == FMAC_CLIP_DISABLED) || \ 611 ((__CLIP_STATE__) == FMAC_CLIP_ENABLED)) 612 613 /** 614 * @brief Check whether the threshold is applicable. 615 * @param __SIZE__ Size of the matching buffer. 616 * @param __WM__ Watermark value. 617 * @param __ACCESS__ Access to the buffer (polling, it, dma, none). 618 * @retval THRESHOLD 619 */ 620 #define IS_FMAC_THRESHOLD_APPLICABLE(__SIZE__, __WM__, __ACCESS__) \ 621 (( (__SIZE__) >= (((__WM__) == FMAC_THRESHOLD_1)? 1U: \ 622 ((__WM__) == FMAC_THRESHOLD_2)? 2U: \ 623 ((__WM__) == FMAC_THRESHOLD_4)? 4U:8U))&& \ 624 ((((__ACCESS__) == FMAC_BUFFER_ACCESS_DMA)&& \ 625 ((__WM__) == FMAC_THRESHOLD_1))|| \ 626 ((__ACCESS__ )!= FMAC_BUFFER_ACCESS_DMA))) 627 628 /** 629 * @} 630 */ 631 632 /* Exported functions ------------------------------------------------------- */ 633 /** @addtogroup FMAC_Exported_Functions 634 * @{ 635 */ 636 637 /** @addtogroup FMAC_Exported_Functions_Group1 638 * @{ 639 */ 640 /* Initialization and de-initialization functions ****************************/ 641 HAL_StatusTypeDef HAL_FMAC_Init(FMAC_HandleTypeDef *hfmac); 642 HAL_StatusTypeDef HAL_FMAC_DeInit(FMAC_HandleTypeDef *hfmac); 643 void HAL_FMAC_MspInit(FMAC_HandleTypeDef *hfmac); 644 void HAL_FMAC_MspDeInit(FMAC_HandleTypeDef *hfmac); 645 646 #if (USE_HAL_FMAC_REGISTER_CALLBACKS == 1) 647 /* Callbacks Register/UnRegister functions ***********************************/ 648 HAL_StatusTypeDef HAL_FMAC_RegisterCallback(FMAC_HandleTypeDef *hfmac, HAL_FMAC_CallbackIDTypeDef CallbackID, 649 pFMAC_CallbackTypeDef pCallback); 650 HAL_StatusTypeDef HAL_FMAC_UnRegisterCallback(FMAC_HandleTypeDef *hfmac, HAL_FMAC_CallbackIDTypeDef CallbackID); 651 #endif /* USE_HAL_FMAC_REGISTER_CALLBACKS */ 652 /** 653 * @} 654 */ 655 656 /** @addtogroup FMAC_Exported_Functions_Group2 657 * @{ 658 */ 659 /* Peripheral Control functions ***********************************************/ 660 HAL_StatusTypeDef HAL_FMAC_FilterConfig(FMAC_HandleTypeDef *hfmac, FMAC_FilterConfigTypeDef *pConfig); 661 HAL_StatusTypeDef HAL_FMAC_FilterConfig_DMA(FMAC_HandleTypeDef *hfmac, FMAC_FilterConfigTypeDef *pConfig); 662 HAL_StatusTypeDef HAL_FMAC_FilterPreload(FMAC_HandleTypeDef *hfmac, int16_t *pInput, uint8_t InputSize, 663 int16_t *pOutput, uint8_t OutputSize); 664 HAL_StatusTypeDef HAL_FMAC_FilterPreload_DMA(FMAC_HandleTypeDef *hfmac, int16_t *pInput, uint8_t InputSize, 665 int16_t *pOutput, uint8_t OutputSize); 666 HAL_StatusTypeDef HAL_FMAC_FilterStart(FMAC_HandleTypeDef *hfmac, int16_t *pOutput, uint16_t *pOutputSize); 667 HAL_StatusTypeDef HAL_FMAC_AppendFilterData(FMAC_HandleTypeDef *hfmac, int16_t *pInput, uint16_t *pInputSize); 668 HAL_StatusTypeDef HAL_FMAC_ConfigFilterOutputBuffer(FMAC_HandleTypeDef *hfmac, int16_t *pOutput, uint16_t *pOutputSize); 669 HAL_StatusTypeDef HAL_FMAC_PollFilterData(FMAC_HandleTypeDef *hfmac, uint32_t Timeout); 670 HAL_StatusTypeDef HAL_FMAC_FilterStop(FMAC_HandleTypeDef *hfmac); 671 /** 672 * @} 673 */ 674 675 /** @addtogroup FMAC_Exported_Functions_Group3 676 * @{ 677 */ 678 /* Callback functions *********************************************************/ 679 void HAL_FMAC_ErrorCallback(FMAC_HandleTypeDef *hfmac); 680 void HAL_FMAC_HalfGetDataCallback(FMAC_HandleTypeDef *hfmac); 681 void HAL_FMAC_GetDataCallback(FMAC_HandleTypeDef *hfmac); 682 void HAL_FMAC_HalfOutputDataReadyCallback(FMAC_HandleTypeDef *hfmac); 683 void HAL_FMAC_OutputDataReadyCallback(FMAC_HandleTypeDef *hfmac); 684 void HAL_FMAC_FilterConfigCallback(FMAC_HandleTypeDef *hfmac); 685 void HAL_FMAC_FilterPreloadCallback(FMAC_HandleTypeDef *hfmac); 686 /** 687 * @} 688 */ 689 690 /** @addtogroup FMAC_Exported_Functions_Group4 691 * @{ 692 */ 693 /* IRQ handler management *****************************************************/ 694 void HAL_FMAC_IRQHandler(FMAC_HandleTypeDef *hfmac); 695 /** 696 * @} 697 */ 698 699 /** @addtogroup FMAC_Exported_Functions_Group5 700 * @{ 701 */ 702 /* Peripheral State functions *************************************************/ 703 HAL_FMAC_StateTypeDef HAL_FMAC_GetState(FMAC_HandleTypeDef *hfmac); 704 uint32_t HAL_FMAC_GetError(FMAC_HandleTypeDef *hfmac); 705 /** 706 * @} 707 */ 708 709 /** 710 * @} 711 */ 712 713 /** 714 * @} 715 */ 716 717 /** 718 * @} 719 */ 720 721 #endif /* FMAC */ 722 723 #ifdef __cplusplus 724 } 725 #endif 726 727 #endif /* STM32H5xx_HAL_FMAC_H */ 728