1 /** 2 ****************************************************************************** 3 * @file stm32u5xx_hal_fmac.h 4 * @author MCD Application Team 5 * @brief Header for stm32u5xx_hal_fmac.c 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_FMAC_H 21 #define STM32U5xx_HAL_FMAC_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes ------------------------------------------------------------------*/ 28 #include "stm32u5xx_hal_def.h" 29 30 #if defined(FMAC) 31 /** @addtogroup STM32U5xx_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 /* Exported constants --------------------------------------------------------*/ 247 /** @defgroup FMAC_Exported_Constants FMAC Exported Constants 248 * @{ 249 */ 250 251 /** @defgroup FMAC_Error_Code FMAC Error code 252 * @{ 253 */ 254 #define HAL_FMAC_ERROR_NONE 0x00000000U /*!< No error */ 255 #define HAL_FMAC_ERROR_SAT 0x00000001U /*!< Saturation error */ 256 #define HAL_FMAC_ERROR_UNFL 0x00000002U /*!< Underflow error */ 257 #define HAL_FMAC_ERROR_OVFL 0x00000004U /*!< Overflow error */ 258 #define HAL_FMAC_ERROR_DMA 0x00000008U /*!< DMA error */ 259 #define HAL_FMAC_ERROR_RESET 0x00000010U /*!< Reset error */ 260 #define HAL_FMAC_ERROR_PARAM 0x00000020U /*!< Parameter error */ 261 #if (USE_HAL_FMAC_REGISTER_CALLBACKS == 1) 262 #define HAL_FMAC_ERROR_INVALID_CALLBACK 0x00000040U /*!< Invalid Callback error */ 263 #endif /* USE_HAL_FMAC_REGISTER_CALLBACKS */ 264 #define HAL_FMAC_ERROR_TIMEOUT 0x00000080U /*!< Timeout error */ 265 266 /** 267 * @} 268 */ 269 270 /** @defgroup FMAC_Functions FMAC Functions 271 * @{ 272 */ 273 #define FMAC_FUNC_LOAD_X1 (FMAC_PARAM_FUNC_0) /*!< Load X1 buffer */ 274 #define FMAC_FUNC_LOAD_X2 (FMAC_PARAM_FUNC_1) /*!< Load X2 buffer */ 275 #define FMAC_FUNC_LOAD_Y (FMAC_PARAM_FUNC_1 | FMAC_PARAM_FUNC_0) /*!< Load Y buffer */ 276 #define FMAC_FUNC_CONVO_FIR (FMAC_PARAM_FUNC_3) /*!< Convolution (FIR filter) */ 277 #define FMAC_FUNC_IIR_DIRECT_FORM_1 (FMAC_PARAM_FUNC_3 | FMAC_PARAM_FUNC_0) /*!< IIR filter (direct form 1) */ 278 /** 279 * @} 280 */ 281 282 /** @defgroup FMAC_Data_Buffer_Threshold FMAC Data Buffer Threshold 283 * @{ 284 * @note This parameter sets a watermark for buffer full (input) or buffer empty (output). 285 */ 286 #define FMAC_THRESHOLD_1 0x00000000U /*!< Input: Buffer full flag set if the number of free spaces 287 in the buffer is less than 1. 288 Output: Buffer empty flag set if the number 289 of unread values in the buffer is less than 1. */ 290 #define FMAC_THRESHOLD_2 0x01000000U /*!< Input: Buffer full flag set if the number of free spaces 291 in the buffer is less than 2. 292 Output: Buffer empty flag set if the number 293 of unread values in the buffer is less than 2. */ 294 #define FMAC_THRESHOLD_4 0x02000000U /*!< Input: Buffer full flag set if the number of free spaces 295 in the buffer is less than 4. 296 Output: Buffer empty flag set if the number 297 of unread values in the buffer is less than 4. */ 298 #define FMAC_THRESHOLD_8 0x03000000U /*!< Input: Buffer full flag set if the number of free spaces 299 in the buffer is less than 8. 300 Output: Buffer empty flag set if the number 301 of unread values in the buffer is less than 8. */ 302 #define FMAC_THRESHOLD_NO_VALUE 0xFFFFFFFFU /*!< The configured threshold value shouldn't be changed */ 303 /** 304 * @} 305 */ 306 307 /** @defgroup FMAC_Buffer_Access FMAC Buffer Access 308 * @{ 309 */ 310 #define FMAC_BUFFER_ACCESS_NONE 0x00U /*!< Buffer handled by an external IP (ADC for instance) */ 311 #define FMAC_BUFFER_ACCESS_DMA 0x01U /*!< Buffer accessed through DMA */ 312 #define FMAC_BUFFER_ACCESS_POLLING 0x02U /*!< Buffer accessed through polling */ 313 #define FMAC_BUFFER_ACCESS_IT 0x03U /*!< Buffer accessed through interruptions */ 314 /** 315 * @} 316 */ 317 318 /** @defgroup FMAC_Clip_State FMAC Clip State 319 * @{ 320 */ 321 #define FMAC_CLIP_DISABLED 0x00000000U /*!< Clipping disabled */ 322 #define FMAC_CLIP_ENABLED FMAC_CR_CLIPEN /*!< Clipping enabled */ 323 /** 324 * @} 325 */ 326 327 /** @defgroup FMAC_Flags FMAC status flags 328 * @{ 329 */ 330 #define FMAC_FLAG_YEMPTY FMAC_SR_YEMPTY /*!< Y Buffer Empty Flag */ 331 #define FMAC_FLAG_X1FULL FMAC_SR_X1FULL /*!< X1 Buffer Full Flag */ 332 #define FMAC_FLAG_OVFL FMAC_SR_OVFL /*!< Overflow Error Flag */ 333 #define FMAC_FLAG_UNFL FMAC_SR_UNFL /*!< Underflow Error Flag */ 334 #define FMAC_FLAG_SAT FMAC_SR_SAT /*!< Saturation Error Flag 335 (this helps in debugging a filter) */ 336 /** 337 * @} 338 */ 339 340 /** @defgroup FMAC_Interrupts_Enable FMAC Interrupts Enable bit 341 * @{ 342 */ 343 #define FMAC_IT_RIEN FMAC_CR_RIEN /*!< Read Interrupt Enable */ 344 #define FMAC_IT_WIEN FMAC_CR_WIEN /*!< Write Interrupt Enable */ 345 #define FMAC_IT_OVFLIEN FMAC_CR_OVFLIEN /*!< Overflow Error Interrupt Enable */ 346 #define FMAC_IT_UNFLIEN FMAC_CR_UNFLIEN /*!< Underflow Error Interrupt Enable */ 347 #define FMAC_IT_SATIEN FMAC_CR_SATIEN /*!< Saturation Error Interrupt Enable 348 (this helps in debugging a filter) */ 349 /** 350 * @} 351 */ 352 353 /** 354 * @} 355 */ 356 357 /* Exported variables --------------------------------------------------------*/ 358 /** @defgroup FMAC_Exported_variables FMAC Exported variables 359 * @{ 360 */ 361 /** 362 * @} 363 */ 364 365 /* Exported macros -----------------------------------------------------------*/ 366 /** @defgroup FMAC_Exported_Macros FMAC Exported Macros 367 * @{ 368 */ 369 370 /** 371 * @brief Reset FMAC handle state. 372 * @param __HANDLE__ FMAC handle. 373 * @retval None 374 */ 375 #if (USE_HAL_FMAC_REGISTER_CALLBACKS == 1) 376 #define __HAL_FMAC_RESET_HANDLE_STATE(__HANDLE__) do{ \ 377 (__HANDLE__)->State = HAL_FMAC_STATE_RESET; \ 378 (__HANDLE__)->MspInitCallback = NULL; \ 379 (__HANDLE__)->MspDeInitCallback = NULL; \ 380 } while(0U) 381 #else 382 #define __HAL_FMAC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_FMAC_STATE_RESET) 383 #endif /* USE_HAL_FMAC_REGISTER_CALLBACKS */ 384 385 /** 386 * @brief Enable the specified FMAC interrupt 387 * @param __HANDLE__ FMAC handle. 388 * @param __INTERRUPT__ FMAC Interrupt. 389 * This parameter can be any combination of the following values: 390 * @arg @ref FMAC_IT_RIEN Read interrupt enable 391 * @arg @ref FMAC_IT_WIEN Write interrupt enable 392 * @arg @ref FMAC_IT_OVFLIEN Overflow error interrupt enable 393 * @arg @ref FMAC_IT_UNFLIEN Underflow error interrupt enable 394 * @arg @ref FMAC_IT_SATIEN Saturation error interrupt enable (this helps in debugging a filter) 395 * @retval None 396 */ 397 #define __HAL_FMAC_ENABLE_IT(__HANDLE__, __INTERRUPT__) \ 398 (((__HANDLE__)->Instance->CR) |= (__INTERRUPT__)) 399 400 /** 401 * @brief Disable the FMAC interrupt 402 * @param __HANDLE__ FMAC handle. 403 * @param __INTERRUPT__ FMAC Interrupt. 404 * This parameter can be any combination of the following values: 405 * @arg @ref FMAC_IT_RIEN Read interrupt enable 406 * @arg @ref FMAC_IT_WIEN Write interrupt enable 407 * @arg @ref FMAC_IT_OVFLIEN Overflow error interrupt enable 408 * @arg @ref FMAC_IT_UNFLIEN Underflow error interrupt enable 409 * @arg @ref FMAC_IT_SATIEN Saturation error interrupt enable (this helps in debugging a filter) 410 * @retval None 411 */ 412 #define __HAL_FMAC_DISABLE_IT(__HANDLE__, __INTERRUPT__) \ 413 (((__HANDLE__)->Instance->CR) &= ~(__INTERRUPT__)) 414 415 /** 416 * @brief Check whether the specified FMAC interrupt occurred or not. 417 * @param __HANDLE__ FMAC handle. 418 * @param __INTERRUPT__ FMAC interrupt to check. 419 * This parameter can be any combination of the following values: 420 * @arg @ref FMAC_FLAG_YEMPTY Y Buffer Empty Flag 421 * @arg @ref FMAC_FLAG_X1FULL X1 Buffer Full Flag 422 * @arg @ref FMAC_FLAG_OVFL Overflow Error Flag 423 * @arg @ref FMAC_FLAG_UNFL Underflow Error Flag 424 * @arg @ref FMAC_FLAG_SAT Saturation Error Flag 425 * @retval SET (interrupt occurred) or RESET (interrupt did not occurred) 426 */ 427 #define __HAL_FMAC_GET_IT(__HANDLE__, __INTERRUPT__) \ 428 (((__HANDLE__)->Instance->SR) &= ~(__INTERRUPT__)) 429 430 /** 431 * @brief Clear specified FMAC interrupt status. Dummy macro as the 432 interrupt status flags are read-only. 433 * @param __HANDLE__ FMAC handle. 434 * @param __INTERRUPT__ FMAC interrupt to clear. 435 * @retval None 436 */ 437 #define __HAL_FMAC_CLEAR_IT(__HANDLE__, __INTERRUPT__) /* Dummy macro */ 438 439 /** 440 * @brief Check whether the specified FMAC status flag is set or not. 441 * @param __HANDLE__ FMAC handle. 442 * @param __FLAG__ FMAC flag to check. 443 * This parameter can be any combination of the following values: 444 * @arg @ref FMAC_FLAG_YEMPTY Y Buffer Empty Flag 445 * @arg @ref FMAC_FLAG_X1FULL X1 Buffer Full Flag 446 * @arg @ref FMAC_FLAG_OVFL Overflow Error Flag 447 * @arg @ref FMAC_FLAG_UNFL Underflow Error Flag 448 * @arg @ref FMAC_FLAG_SAT Saturation error Flag 449 * @retval SET (flag is set) or RESET (flag is reset) 450 */ 451 #define __HAL_FMAC_GET_FLAG(__HANDLE__, __FLAG__) \ 452 ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__)) 453 454 /** 455 * @brief Clear specified FMAC status flag. Dummy macro as no 456 flag can be cleared. 457 * @param __HANDLE__ FMAC handle. 458 * @param __FLAG__ FMAC flag to clear. 459 * @retval None 460 */ 461 #define __HAL_FMAC_CLEAR_FLAG(__HANDLE__, __FLAG__) /* Dummy macro */ 462 463 /** 464 * @brief Check whether the specified FMAC interrupt is enabled or not. 465 * @param __HANDLE__ FMAC handle. 466 * @param __INTERRUPT__ FMAC interrupt to check. 467 * This parameter can be one of the following values: 468 * @arg @ref FMAC_IT_RIEN Read interrupt enable 469 * @arg @ref FMAC_IT_WIEN Write interrupt enable 470 * @arg @ref FMAC_IT_OVFLIEN Overflow error interrupt enable 471 * @arg @ref FMAC_IT_UNFLIEN Underflow error interrupt enable 472 * @arg @ref FMAC_IT_SATIEN Saturation error interrupt enable (this helps in debugging a filter) 473 * @retval FlagStatus 474 */ 475 #define __HAL_FMAC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) \ 476 (((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) 477 478 /** 479 * @} 480 */ 481 482 /* Private defines -----------------------------------------------------------*/ 483 /** @addtogroup FMAC_Private_Constants 484 * @{ 485 */ 486 487 #define FMAC_PARAM_P_MAX_IIR 64U /*!< Maximum value of P parameter with IIR */ 488 #define FMAC_PARAM_P_MAX_FIR 127U /*!< Maximum value of P parameter with FIR */ 489 #define FMAC_PARAM_P_MIN 2U /*!< Minimum value of P parameter */ 490 #define FMAC_PARAM_Q_MAX 63U /*!< Maximum value of Q parameter */ 491 #define FMAC_PARAM_Q_MIN 1U /*!< Minimum value of Q parameter */ 492 #define FMAC_PARAM_R_MAX 7U /*!< Maximum value of R parameter */ 493 494 /** 495 * @} 496 */ 497 498 /* Private Macros-------------------------------------------------------------*/ 499 /** @addtogroup FMAC_Private_Macros FMAC Private Macros 500 * @{ 501 */ 502 503 /** 504 * @brief Verify the FMAC function. 505 * @param __FUNCTION__ ID of the function. 506 * @retval SET (__FUNCTION__ is a valid value) or RESET (__FUNCTION__ is invalid) 507 */ 508 #define IS_FMAC_FUNCTION(__FUNCTION__) (((__FUNCTION__) == FMAC_FUNC_LOAD_X1) || \ 509 ((__FUNCTION__) == FMAC_FUNC_LOAD_X2) || \ 510 ((__FUNCTION__) == FMAC_FUNC_LOAD_Y) || \ 511 ((__FUNCTION__) == FMAC_FUNC_CONVO_FIR) || \ 512 ((__FUNCTION__) == FMAC_FUNC_IIR_DIRECT_FORM_1)) 513 514 /** 515 * @brief Verify the FMAC load function used for input data, output data or coefficients. 516 * @param __FUNCTION__ ID of the load function. 517 * @retval SET (__FUNCTION__ is a valid value) or RESET (__FUNCTION__ is invalid) 518 */ 519 #define IS_FMAC_LOAD_FUNCTION(__FUNCTION__) (((__FUNCTION__) == FMAC_FUNC_LOAD_X1) || \ 520 ((__FUNCTION__) == FMAC_FUNC_LOAD_X2) || \ 521 ((__FUNCTION__) == FMAC_FUNC_LOAD_Y)) 522 523 /** 524 * @brief Verify the FMAC load function used with N values as input or output data. 525 * @param __FUNCTION__ ID of the load function. 526 * @retval SET (__FUNCTION__ is a valid value) or RESET (__FUNCTION__ is invalid) 527 */ 528 #define IS_FMAC_N_LOAD_FUNCTION(__FUNCTION__) (((__FUNCTION__) == FMAC_FUNC_LOAD_X1) || \ 529 ((__FUNCTION__) == FMAC_FUNC_LOAD_Y)) 530 531 /** 532 * @brief Verify the FMAC load function used with N + M values as coefficients. 533 * @param __FUNCTION__ ID of the load function. 534 * @retval SET (__FUNCTION__ is a valid value) or RESET (__FUNCTION__ is invalid) 535 */ 536 #define IS_FMAC_N_M_LOAD_FUNCTION(__FUNCTION__) ((__FUNCTION__) == FMAC_FUNC_LOAD_X2) 537 538 /** 539 * @brief Verify the FMAC filter function. 540 * @param __FUNCTION__ ID of the filter function. 541 * @retval SET (__FUNCTION__ is a valid value) or RESET (__FUNCTION__ is invalid) 542 */ 543 #define IS_FMAC_FILTER_FUNCTION(__FUNCTION__) (((__FUNCTION__) == FMAC_FUNC_CONVO_FIR) || \ 544 ((__FUNCTION__) == FMAC_FUNC_IIR_DIRECT_FORM_1)) 545 546 547 /** 548 * @brief Verify the FMAC threshold. 549 * @param __THRESHOLD__ Value of the threshold. 550 * @retval SET (__THRESHOLD__ is a valid value) or RESET (__THRESHOLD__ is invalid) 551 */ 552 #define IS_FMAC_THRESHOLD(__THRESHOLD__) (((__THRESHOLD__) == FMAC_THRESHOLD_1) || \ 553 ((__THRESHOLD__) == FMAC_THRESHOLD_2) || \ 554 ((__THRESHOLD__) == FMAC_THRESHOLD_4) || \ 555 ((__THRESHOLD__) == FMAC_THRESHOLD_NO_VALUE) || \ 556 ((__THRESHOLD__) == FMAC_THRESHOLD_8)) 557 558 /** 559 * @brief Verify the FMAC filter parameter P. 560 * @param __P__ Value of the filter parameter P. 561 * @param __FUNCTION__ ID of the filter function. 562 * @retval SET (__P__ is a valid value) or RESET (__P__ is invalid) 563 */ 564 #define IS_FMAC_PARAM_P(__FUNCTION__, __P__) ((((__FUNCTION__) == FMAC_FUNC_CONVO_FIR) && \ 565 (((__P__) >= FMAC_PARAM_P_MIN) && \ 566 ((__P__) <= FMAC_PARAM_P_MAX_FIR))) || \ 567 (((__FUNCTION__) == FMAC_FUNC_IIR_DIRECT_FORM_1) && \ 568 (((__P__) >= FMAC_PARAM_P_MIN) && \ 569 ((__P__) <= FMAC_PARAM_P_MAX_IIR)))) 570 571 /** 572 * @brief Verify the FMAC filter parameter Q. 573 * @param __Q__ Value of the filter parameter Q. 574 * @param __FUNCTION__ ID of the filter function. 575 * @retval SET (__Q__ is a valid value) or RESET (__Q__ is invalid) 576 */ 577 #define IS_FMAC_PARAM_Q(__FUNCTION__, __Q__) (((__FUNCTION__) == FMAC_FUNC_CONVO_FIR) || \ 578 (((__FUNCTION__) == FMAC_FUNC_IIR_DIRECT_FORM_1) && \ 579 (((__Q__) >= FMAC_PARAM_Q_MIN) && ((__Q__) <= FMAC_PARAM_Q_MAX)))) 580 581 /** 582 * @brief Verify the FMAC filter parameter R. 583 * @param __R__ Value of the filter parameter. 584 * @param __FUNCTION__ ID of the filter function. 585 * @retval SET (__R__ is a valid value) or RESET (__R__ is invalid) 586 */ 587 #define IS_FMAC_PARAM_R(__FUNCTION__, __R__) ( (((__FUNCTION__) == FMAC_FUNC_CONVO_FIR) || \ 588 ((__FUNCTION__) == FMAC_FUNC_IIR_DIRECT_FORM_1)) && \ 589 ((__R__) <= FMAC_PARAM_R_MAX)) 590 591 /** 592 * @brief Verify the FMAC buffer access. 593 * @param __BUFFER_ACCESS__ Type of access. 594 * @retval SET (__BUFFER_ACCESS__ is a valid value) or RESET (__BUFFER_ACCESS__ is invalid) 595 */ 596 #define IS_FMAC_BUFFER_ACCESS(__BUFFER_ACCESS__) (((__BUFFER_ACCESS__) == FMAC_BUFFER_ACCESS_NONE) || \ 597 ((__BUFFER_ACCESS__) == FMAC_BUFFER_ACCESS_DMA) || \ 598 ((__BUFFER_ACCESS__) == FMAC_BUFFER_ACCESS_POLLING) || \ 599 ((__BUFFER_ACCESS__) == FMAC_BUFFER_ACCESS_IT)) 600 601 /** 602 * @brief Verify the FMAC clip feature. 603 * @param __CLIP_STATE__ Clip state. 604 * @retval SET (__CLIP_STATE__ is a valid value) or RESET (__CLIP_STATE__ is invalid) 605 */ 606 #define IS_FMAC_CLIP_STATE(__CLIP_STATE__) (((__CLIP_STATE__) == FMAC_CLIP_DISABLED) || \ 607 ((__CLIP_STATE__) == FMAC_CLIP_ENABLED)) 608 609 /** 610 * @brief Check whether the threshold is applicable. 611 * @param __SIZE__ Size of the matching buffer. 612 * @param __WM__ Watermark value. 613 * @param __ACCESS__ Access to the buffer (polling, it, dma, none). 614 * @retval THRESHOLD 615 */ 616 #define IS_FMAC_THRESHOLD_APPLICABLE(__SIZE__, __WM__, __ACCESS__) \ 617 (( (__SIZE__) >= (((__WM__) == FMAC_THRESHOLD_1)? 1U: \ 618 ((__WM__) == FMAC_THRESHOLD_2)? 2U: \ 619 ((__WM__) == FMAC_THRESHOLD_4)? 4U:8U))&& \ 620 ((((__ACCESS__) == FMAC_BUFFER_ACCESS_DMA)&& \ 621 ((__WM__) == FMAC_THRESHOLD_1))|| \ 622 ((__ACCESS__ )!= FMAC_BUFFER_ACCESS_DMA))) 623 624 /** 625 * @} 626 */ 627 628 /* Exported functions ------------------------------------------------------- */ 629 /** @addtogroup FMAC_Exported_Functions 630 * @{ 631 */ 632 633 /** @addtogroup FMAC_Exported_Functions_Group1 634 * @{ 635 */ 636 /* Initialization and de-initialization functions ****************************/ 637 HAL_StatusTypeDef HAL_FMAC_Init(FMAC_HandleTypeDef *hfmac); 638 HAL_StatusTypeDef HAL_FMAC_DeInit(FMAC_HandleTypeDef *hfmac); 639 void HAL_FMAC_MspInit(FMAC_HandleTypeDef *hfmac); 640 void HAL_FMAC_MspDeInit(FMAC_HandleTypeDef *hfmac); 641 642 #if (USE_HAL_FMAC_REGISTER_CALLBACKS == 1) 643 /* Callbacks Register/UnRegister functions ***********************************/ 644 HAL_StatusTypeDef HAL_FMAC_RegisterCallback(FMAC_HandleTypeDef *hfmac, HAL_FMAC_CallbackIDTypeDef CallbackID, 645 pFMAC_CallbackTypeDef pCallback); 646 HAL_StatusTypeDef HAL_FMAC_UnRegisterCallback(FMAC_HandleTypeDef *hfmac, HAL_FMAC_CallbackIDTypeDef CallbackID); 647 #endif /* USE_HAL_FMAC_REGISTER_CALLBACKS */ 648 /** 649 * @} 650 */ 651 652 /** @addtogroup FMAC_Exported_Functions_Group2 653 * @{ 654 */ 655 /* Peripheral Control functions ***********************************************/ 656 HAL_StatusTypeDef HAL_FMAC_FilterConfig(FMAC_HandleTypeDef *hfmac, FMAC_FilterConfigTypeDef *pConfig); 657 HAL_StatusTypeDef HAL_FMAC_FilterConfig_DMA(FMAC_HandleTypeDef *hfmac, FMAC_FilterConfigTypeDef *pConfig); 658 HAL_StatusTypeDef HAL_FMAC_FilterPreload(FMAC_HandleTypeDef *hfmac, int16_t *pInput, uint8_t InputSize, 659 int16_t *pOutput, uint8_t OutputSize); 660 HAL_StatusTypeDef HAL_FMAC_FilterPreload_DMA(FMAC_HandleTypeDef *hfmac, int16_t *pInput, uint8_t InputSize, 661 int16_t *pOutput, uint8_t OutputSize); 662 HAL_StatusTypeDef HAL_FMAC_FilterStart(FMAC_HandleTypeDef *hfmac, int16_t *pOutput, uint16_t *pOutputSize); 663 HAL_StatusTypeDef HAL_FMAC_AppendFilterData(FMAC_HandleTypeDef *hfmac, int16_t *pInput, uint16_t *pInputSize); 664 HAL_StatusTypeDef HAL_FMAC_ConfigFilterOutputBuffer(FMAC_HandleTypeDef *hfmac, int16_t *pOutput, uint16_t *pOutputSize); 665 HAL_StatusTypeDef HAL_FMAC_PollFilterData(FMAC_HandleTypeDef *hfmac, uint32_t Timeout); 666 HAL_StatusTypeDef HAL_FMAC_FilterStop(FMAC_HandleTypeDef *hfmac); 667 /** 668 * @} 669 */ 670 671 /** @addtogroup FMAC_Exported_Functions_Group3 672 * @{ 673 */ 674 /* Callback functions *********************************************************/ 675 void HAL_FMAC_ErrorCallback(FMAC_HandleTypeDef *hfmac); 676 void HAL_FMAC_HalfGetDataCallback(FMAC_HandleTypeDef *hfmac); 677 void HAL_FMAC_GetDataCallback(FMAC_HandleTypeDef *hfmac); 678 void HAL_FMAC_HalfOutputDataReadyCallback(FMAC_HandleTypeDef *hfmac); 679 void HAL_FMAC_OutputDataReadyCallback(FMAC_HandleTypeDef *hfmac); 680 void HAL_FMAC_FilterConfigCallback(FMAC_HandleTypeDef *hfmac); 681 void HAL_FMAC_FilterPreloadCallback(FMAC_HandleTypeDef *hfmac); 682 /** 683 * @} 684 */ 685 686 /** @addtogroup FMAC_Exported_Functions_Group4 687 * @{ 688 */ 689 /* IRQ handler management *****************************************************/ 690 void HAL_FMAC_IRQHandler(FMAC_HandleTypeDef *hfmac); 691 /** 692 * @} 693 */ 694 695 /** @addtogroup FMAC_Exported_Functions_Group5 696 * @{ 697 */ 698 /* Peripheral State functions *************************************************/ 699 HAL_FMAC_StateTypeDef HAL_FMAC_GetState(const FMAC_HandleTypeDef *hfmac); 700 uint32_t HAL_FMAC_GetError(const FMAC_HandleTypeDef *hfmac); 701 /** 702 * @} 703 */ 704 705 /** 706 * @} 707 */ 708 709 /** 710 * @} 711 */ 712 713 /** 714 * @} 715 */ 716 717 #endif /* FMAC */ 718 719 #ifdef __cplusplus 720 } 721 #endif 722 723 #endif /* STM32U5xx_HAL_FMAC_H */ 724