2 ******************************************************************************
3 * @file stm32g4xx_fmac.h
4 * @author MCD Application Team
5 * @brief This file contains all the functions prototypes for the FMAC firmware
7 ******************************************************************************
10 * <h2><center>© Copyright (c) 2017 STMicroelectronics.
11 * All rights reserved.</center></h2>
13 * This software component is licensed by ST under BSD 3-Clause license,
14 * the "License"; You may not use this file except in compliance with the
15 * License. You may obtain a copy of the License at:
16 * opensource.org/licenses/BSD-3-Clause
18 ******************************************************************************
21 /* Define to prevent recursive inclusion -------------------------------------*/
22 #ifndef STM32G4xx_HAL_FMAC_H
23 #define STM32G4xx_HAL_FMAC_H
29 /* Includes ------------------------------------------------------------------*/
30 #include "stm32g4xx_hal_def.h"
32 /** @addtogroup STM32G4xx_HAL_Driver
40 /* Exported types ------------------------------------------------------------*/
41 /** @defgroup FMAC_Exported_Types FMAC Exported Types
46 * @brief FMAC HAL State Structure definition
50 HAL_FMAC_STATE_RESET
= 0x00U
, /*!< FMAC not yet initialized or disabled */
51 HAL_FMAC_STATE_READY
= 0x20U
, /*!< FMAC initialized and ready for use */
52 HAL_FMAC_STATE_BUSY
= 0x24U
, /*!< FMAC internal process is ongoing */
53 HAL_FMAC_STATE_BUSY_RD
= 0x25U
, /*!< FMAC reading configuration is ongoing */
54 HAL_FMAC_STATE_BUSY_WR
= 0x26U
, /*!< FMAC writing configuration is ongoing */
55 HAL_FMAC_STATE_TIMEOUT
= 0xA0U
, /*!< FMAC in Timeout state */
56 HAL_FMAC_STATE_ERROR
= 0xE0U
/*!< FMAC in Error state */
57 } HAL_FMAC_StateTypeDef
;
60 * @brief FMAC Handle Structure definition
62 #if (USE_HAL_FMAC_REGISTER_CALLBACKS == 1)
63 typedef struct __FMAC_HandleTypeDef
66 #endif /* USE_HAL_FMAC_REGISTER_CALLBACKS */
68 FMAC_TypeDef
*Instance
; /*!< Register base address */
70 uint32_t FilterParam
; /*!< Filter configuration (operation and parameters).
71 Set to 0 if no valid configuration was applied. */
73 uint8_t InputAccess
; /*!< Access to the input buffer (internal memory area): DMA, IT, Polling, None.
74 This parameter can be a value of @ref FMAC_Buffer_Access. */
76 uint8_t OutputAccess
; /*!< Access to the output buffer (internal memory area): DMA, IT, Polling, None.
77 This parameter can be a value of @ref FMAC_Buffer_Access. */
79 int16_t *pInput
; /*!< Pointer to FMAC input data buffer */
81 uint16_t InputCurrentSize
; /*!< Number of the input elements already written into FMAC */
83 uint16_t *pInputSize
; /*!< Number of input elements to write (memory allocated to pInput).
84 In case of early interruption of the filter operation, its value will be updated. */
86 int16_t *pOutput
; /*!< Pointer to FMAC output data buffer */
88 uint16_t OutputCurrentSize
; /*!< Number of the output elements already read from FMAC */
90 uint16_t *pOutputSize
; /*!< Number of output elements to read (memory allocated to pOutput).
91 In case of early interruption of the filter operation, its value will be updated. */
93 DMA_HandleTypeDef
*hdmaIn
; /*!< FMAC peripheral input data DMA handle parameters */
95 DMA_HandleTypeDef
*hdmaOut
; /*!< FMAC peripheral output data DMA handle parameters */
97 DMA_HandleTypeDef
*hdmaPreload
; /*!< FMAC peripheral preloaded data (X1, X2 and Y) DMA handle parameters */
99 #if (USE_HAL_FMAC_REGISTER_CALLBACKS == 1)
100 void (* ErrorCallback
)(struct __FMAC_HandleTypeDef
*hfmac
); /*!< FMAC error callback */
102 void (* HalfGetDataCallback
)(struct __FMAC_HandleTypeDef
*hfmac
); /*!< FMAC get half data callback */
104 void (* GetDataCallback
)(struct __FMAC_HandleTypeDef
*hfmac
); /*!< FMAC get data callback */
106 void (* HalfOutputDataReadyCallback
)(struct __FMAC_HandleTypeDef
*hfmac
); /*!< FMAC half output data ready callback */
108 void (* OutputDataReadyCallback
)(struct __FMAC_HandleTypeDef
*hfmac
); /*!< FMAC output data ready callback */
110 void (* FilterConfigCallback
)(struct __FMAC_HandleTypeDef
*hfmac
); /*!< FMAC filter configuration callback */
112 void (* FilterPreloadCallback
)(struct __FMAC_HandleTypeDef
*hfmac
); /*!< FMAC filter preload callback */
114 void (* MspInitCallback
)(struct __FMAC_HandleTypeDef
*hfmac
); /*!< FMAC Msp Init callback */
116 void (* MspDeInitCallback
)(struct __FMAC_HandleTypeDef
*hfmac
); /*!< FMAC Msp DeInit callback */
118 #endif /* (USE_HAL_FMAC_REGISTER_CALLBACKS) */
120 HAL_LockTypeDef Lock
; /*!< FMAC locking object */
122 __IO HAL_FMAC_StateTypeDef State
; /*!< FMAC state related to global handle management
123 This parameter can be a value of @ref HAL_FMAC_StateTypeDef */
125 __IO HAL_FMAC_StateTypeDef RdState
; /*!< FMAC state related to read operations (access to Y buffer)
126 This parameter can be a value of @ref HAL_FMAC_StateTypeDef */
128 __IO HAL_FMAC_StateTypeDef WrState
; /*!< FMAC state related to write operations (access to X1 buffer)
129 This parameter can be a value of @ref HAL_FMAC_StateTypeDef */
131 __IO
uint32_t ErrorCode
; /*!< FMAC peripheral error code
132 This parameter can be a value of @ref FMAC_Error_Code */
134 } FMAC_HandleTypeDef
;
136 #if (USE_HAL_FMAC_REGISTER_CALLBACKS == 1)
138 * @brief FMAC Callback ID structure definition
142 HAL_FMAC_ERROR_CB_ID
= 0x00U
, /*!< FMAC error callback ID */
143 HAL_FMAC_HALF_GET_DATA_CB_ID
= 0x01U
, /*!< FMAC get half data callback ID */
144 HAL_FMAC_GET_DATA_CB_ID
= 0x02U
, /*!< FMAC get data callback ID */
145 HAL_FMAC_HALF_OUTPUT_DATA_READY_CB_ID
= 0x03U
, /*!< FMAC half output data ready callback ID */
146 HAL_FMAC_OUTPUT_DATA_READY_CB_ID
= 0x04U
, /*!< FMAC output data ready callback ID */
147 HAL_FMAC_FILTER_CONFIG_CB_ID
= 0x05U
, /*!< FMAC filter configuration callback ID */
148 HAL_FMAC_FILTER_PRELOAD_CB_ID
= 0x06U
, /*!< FMAC filter preload callback ID */
150 HAL_FMAC_MSPINIT_CB_ID
= 0x07U
, /*!< FMAC MspInit callback ID */
151 HAL_FMAC_MSPDEINIT_CB_ID
= 0x08U
, /*!< FMAC MspDeInit callback ID */
152 } HAL_FMAC_CallbackIDTypeDef
;
155 * @brief HAL FMAC Callback pointer definition
157 typedef void (*pFMAC_CallbackTypeDef
)(FMAC_HandleTypeDef
*hfmac
); /*!< pointer to an FMAC callback function */
159 #endif /* USE_HAL_FMAC_REGISTER_CALLBACKS */
162 * @brief FMAC Filter Configuration Structure definition
166 uint8_t InputBaseAddress
; /*!< Base address of the input buffer (X1) within the internal memory (0x00 to 0xFF).
167 Ignored if InputBufferSize is set to 0 (previous configuration kept).
168 NB: the buffers can overlap or even coincide exactly. */
170 uint8_t InputBufferSize
; /*!< Number of 16-bit addresses allocated to the input buffer (including the optional "headroom").
171 0 if a previous configuration should be kept. */
173 uint32_t InputThreshold
; /*!< Input threshold: the buffer full flag will be set if the number of free spaces
174 in the buffer is inferior to this threshold.
175 This parameter can be a value of @ref FMAC_Data_Buffer_Threshold. */
177 uint8_t CoeffBaseAddress
; /*!< Base address of the coefficient buffer (X2) within the internal memory (0x00 to 0xFF).
178 Ignored if CoeffBufferSize is set to 0 (previous configuration kept).
179 NB: the buffers can overlap or even coincide exactly. */
181 uint8_t CoeffBufferSize
; /*!< Number of 16-bit addresses allocated to the coefficient buffer.
182 0 if a previous configuration should be kept. */
184 uint8_t OutputBaseAddress
; /*!< Base address of the output buffer (Y) within the internal memory (0x00 to 0xFF).
185 Ignored if OuputBufferSize is set to 0 (previous configuration kept).
186 NB: the buffers can overlap or even coincide exactly. */
188 uint8_t OutputBufferSize
; /*!< Number of 16-bit addresses allocated to the output buffer (including the optional "headroom").
189 0 if a previous configuration should be kept. */
191 uint32_t OutputThreshold
; /*!< Output threshold: the buffer empty flag will be set if the number of unread values
192 in the buffer is inferior to this threshold.
193 This parameter can be a value of @ref FMAC_Data_Buffer_Threshold. */
195 int16_t *pCoeffA
; /*!< [IIR only] Initialization of the coefficient vector A.
196 If not needed, it should be set to NULL. */
198 uint8_t CoeffASize
; /*!< Size of the coefficient vector A. */
200 int16_t *pCoeffB
; /*!< Initialization of the coefficient vector B.
201 If not needed (re-use of a previously loaded buffer), it should be set to NULL. */
203 uint8_t CoeffBSize
; /*!< Size of the coefficient vector B. */
205 uint8_t InputAccess
; /*!< Access to the input buffer (internal memory area): DMT, IT, Polling, None.
206 This parameter can be a value of @ref FMAC_Buffer_Access. */
208 uint8_t OutputAccess
; /*!< Access to the output buffer (internal memory area): DMA, IT, Polling, None.
209 This parameter can be a value of @ref FMAC_Buffer_Access. */
211 uint32_t Clip
; /*!< Enable or disable the clipping feature (wrapping when the q1.15 range is exceeded).
212 This parameter can be a value of @ref FMAC_Clip_State. */
214 uint32_t Filter
; /*!< Filter type.
215 This parameter can be a value of @ref FMAC_Functions (filter related values). */
217 uint8_t P
; /*!< Parameter P (vector length, number of filter taps, etc.). */
219 uint8_t Q
; /*!< Parameter Q (vector length, etc.). Ignored if not needed. */
221 uint8_t R
; /*!< Parameter R (gain, etc.). Ignored if not needed. */
223 } FMAC_FilterConfigTypeDef
;
230 /* Exported constants --------------------------------------------------------*/
233 /** @defgroup FMAC_Exported_Constants FMAC Exported Constants
237 /** @defgroup FMAC_Error_Code FMAC Error code
240 #define HAL_FMAC_ERROR_NONE 0x00000000UL /*!< No error */
241 #define HAL_FMAC_ERROR_SAT 0x00000001UL /*!< Saturation error */
242 #define HAL_FMAC_ERROR_UNFL 0x00000002UL /*!< Underflow error */
243 #define HAL_FMAC_ERROR_OVFL 0x00000004UL /*!< Overflow error */
244 #define HAL_FMAC_ERROR_DMA 0x00000008UL /*!< DMA error */
245 #define HAL_FMAC_ERROR_RESET 0x00000010UL /*!< Reset error */
246 #define HAL_FMAC_ERROR_PARAM 0x00000020UL /*!< Parameter error */
247 #if (USE_HAL_FMAC_REGISTER_CALLBACKS == 1)
248 #define HAL_FMAC_ERROR_INVALID_CALLBACK 0x00000040UL /*!< Invalid Callback error */
249 #endif /* USE_HAL_FMAC_REGISTER_CALLBACKS */
250 #define HAL_FMAC_ERROR_TIMEOUT 0x00000080UL /*!< Timeout error */
256 /** @defgroup FMAC_Functions FMAC Functions
259 #define FMAC_FUNC_LOAD_X1 ((uint32_t)(FMAC_PARAM_FUNC_0)) /*!< Load X1 buffer */
260 #define FMAC_FUNC_LOAD_X2 ((uint32_t)(FMAC_PARAM_FUNC_1)) /*!< Load X2 buffer */
261 #define FMAC_FUNC_LOAD_Y ((uint32_t)(FMAC_PARAM_FUNC_1 | FMAC_PARAM_FUNC_0)) /*!< Load Y buffer */
262 #define FMAC_FUNC_CONVO_FIR ((uint32_t)(FMAC_PARAM_FUNC_3)) /*!< Convolution (FIR filter) */
263 #define FMAC_FUNC_IIR_DIRECT_FORM_1 ((uint32_t)(FMAC_PARAM_FUNC_3 | FMAC_PARAM_FUNC_0)) /*!< IIR filter (direct form 1) */
268 /** @defgroup FMAC_Data_Buffer_Threshold FMAC Data Buffer Threshold
270 * @note This parameter sets a watermark for buffer full (input) or buffer empty (output).
272 #define FMAC_THRESHOLD_1 0x00000000UL /*!< Input: Buffer full flag set if the number of free spaces in the buffer is less than 1.
273 Output: Buffer empty flag set if the number of unread values in the buffer is less than 1. */
274 #define FMAC_THRESHOLD_2 0x01000000UL /*!< Input: Buffer full flag set if the number of free spaces in the buffer is less than 2.
275 Output: Buffer empty flag set if the number of unread values in the buffer is less than 2. */
276 #define FMAC_THRESHOLD_4 0x02000000UL /*!< Input: Buffer full flag set if the number of free spaces in the buffer is less than 4.
277 Output: Buffer empty flag set if the number of unread values in the buffer is less than 4. */
278 #define FMAC_THRESHOLD_8 0x03000000UL /*!< Input: Buffer full flag set if the number of free spaces in the buffer is less than 8.
279 Output: Buffer empty flag set if the number of unread values in the buffer is less than 8. */
280 #define FMAC_THRESHOLD_NO_VALUE 0xFFFFFFFFUL /*!< The configured threshold value shouldn't be changed */
285 /** @defgroup FMAC_Buffer_Access FMAC Buffer Access
288 #define FMAC_BUFFER_ACCESS_NONE 0x00U /*!< Buffer handled by an external IP (ADC for instance) */
289 #define FMAC_BUFFER_ACCESS_DMA 0x01U /*!< Buffer accessed through the FMAC DMA */
290 #define FMAC_BUFFER_ACCESS_POLLING 0x02U /*!< Buffer accessed through polling */
291 #define FMAC_BUFFER_ACCESS_IT 0x03U /*!< Buffer accessed through interruptions */
296 /** @defgroup FMAC_Clip_State FMAC Clip State
299 #define FMAC_CLIP_DISABLED 0x00000000UL /*!< Clipping disabled */
300 #define FMAC_CLIP_ENABLED FMAC_CR_CLIPEN /*!< Clipping enabled */
305 /** @defgroup FMAC_Flags FMAC status flags
308 #define FMAC_FLAG_YEMPTY FMAC_SR_YEMPTY /*!< Y Buffer Empty Flag */
309 #define FMAC_FLAG_X1FULL FMAC_SR_X1FULL /*!< X1 Buffer Full Flag */
310 #define FMAC_FLAG_OVFL FMAC_SR_OVFL /*!< Overflow Error Flag */
311 #define FMAC_FLAG_UNFL FMAC_SR_UNFL /*!< Underflow Error Flag */
312 #define FMAC_FLAG_SAT FMAC_SR_SAT /*!< Saturation Error Flag (this helps in debugging a filter) */
317 /** @defgroup FMAC_Interrupts_Enable FMAC Interrupts Enable bit
320 #define FMAC_IT_RIEN FMAC_CR_RIEN /*!< Read Interrupt Enable */
321 #define FMAC_IT_WIEN FMAC_CR_WIEN /*!< Write Interrupt Enable */
322 #define FMAC_IT_OVFLIEN FMAC_CR_OVFLIEN /*!< Overflow Error Interrupt Enable */
323 #define FMAC_IT_UNFLIEN FMAC_CR_UNFLIEN /*!< Underflow Error Interrupt Enable */
324 #define FMAC_IT_SATIEN FMAC_CR_SATIEN /*!< Saturation Error Interrupt Enable (this helps in debugging a filter) */
329 /** @defgroup FMAC_DMAR DMA Read Request Enable bit
332 #define FMAC_DMA_REN FMAC_CR_DMAREN /*!< DMA Read Requests Enable */
337 /** @defgroup FMAC_DMAW DMA Write Request Enable bit
340 #define FMAC_DMA_WEN FMAC_CR_DMAWEN /*!< DMA Write Channel Enable */
345 /** @defgroup FMAC_DMAS DMA START bit
348 #define FMAC_START FMAC_PARAM_START /*!< DMA Start */
353 /** @defgroup FMAC_TimeOut_Value FMAC polling-based communications time-out value
356 #define HAL_FMAC_TIMEOUT_VALUE 1000UL /*!< FMAC polling-based communications time-out value */
361 /** @defgroup FMAC_Reset_TimeOut_Value FMAC reset time-out value
364 #define HAL_FMAC_RESET_TIMEOUT_VALUE 500UL /*!< FMAC reset time-out value */
374 /* Exported macro ------------------------------------------------------------*/
375 /** @defgroup FMAC_Exported_Macros FMAC Exported Macros
379 /** @brief Reset FMAC handle state.
380 * @param __HANDLE__ FMAC handle.
383 #if (USE_HAL_FMAC_REGISTER_CALLBACKS == 1)
384 #define __HAL_FMAC_RESET_HANDLE_STATE(__HANDLE__) do{ \
385 (__HANDLE__)->State = HAL_FMAC_STATE_RESET; \
386 (__HANDLE__)->MspInitCallback = NULL; \
387 (__HANDLE__)->MspDeInitCallback = NULL; \
390 #define __HAL_FMAC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_FMAC_STATE_RESET)
391 #endif /* USE_HAL_FMAC_REGISTER_CALLBACKS */
394 * @brief Enable the FMAC interrupt when result is ready
395 * @param __HANDLE__ FMAC handle.
396 * @param __INTERRUPT__ FMAC Interrupt.
397 * This parameter can be one of the following values:
398 * @arg @ref FMAC_IT_RIEN Read interrupt enable
399 * @arg @ref FMAC_IT_WIEN Write interrupt enable
400 * @arg @ref FMAC_IT_OVFLIEN Overflow error interrupt enable
401 * @arg @ref FMAC_IT_UNFLIEN Underflow error interrupt enable
402 * @arg @ref FMAC_IT_SATIEN Saturation error interrupt enable (this helps in debugging a filter)
405 #define __HAL_FMAC_ENABLE_IT(__HANDLE__, __INTERRUPT__) \
406 (((__HANDLE__)->Instance->CR) |= (__INTERRUPT__))
409 * @brief Disable the FMAC interrupt
410 * @param __HANDLE__ FMAC handle.
411 * @param __INTERRUPT__ FMAC Interrupt.
412 * This parameter can be one of the following values:
413 * @arg @ref FMAC_IT_RIEN Read interrupt enable
414 * @arg @ref FMAC_IT_WIEN Write interrupt enable
415 * @arg @ref FMAC_IT_OVFLIEN Overflow error interrupt enable
416 * @arg @ref FMAC_IT_UNFLIEN Underflow error interrupt enable
417 * @arg @ref FMAC_IT_SATIEN Saturation error interrupt enable (this helps in debugging a filter)
420 #define __HAL_FMAC_DISABLE_IT(__HANDLE__, __INTERRUPT__) \
421 (((__HANDLE__)->Instance->CR) &= ~(__INTERRUPT__))
423 /** @brief Check whether the specified FMAC interrupt occurred or not.
424 * @param __HANDLE__ FMAC handle.
425 * @param __INTERRUPT__ FMAC interrupt to check.
426 * This parameter can be one of the following values:
427 * @arg @ref FMAC_FLAG_YEMPTY Y Buffer Empty Flag
428 * @arg @ref FMAC_FLAG_X1FULL X1 Buffer Full Flag
429 * @arg @ref FMAC_FLAG_OVFL Overflow Error Flag
430 * @arg @ref FMAC_FLAG_UNFL Underflow Error Flag
431 * @arg @ref FMAC_FLAG_SAT Saturation Error Flag
432 * @retval SET (interrupt occurred) or RESET (interrupt did not occurred)
434 #define __HAL_FMAC_GET_IT(__HANDLE__, __INTERRUPT__) \
435 (((__HANDLE__)->Instance->SR) &= ~(__INTERRUPT__))
437 /** @brief Clear specified FMAC interrupt status. Dummy macro as the
438 interrupt status flags are read-only.
439 * @param __HANDLE__ FMAC handle.
440 * @param __INTERRUPT__ FMAC interrupt to clear.
443 #define __HAL_FMAC_CLEAR_IT(__HANDLE__, __INTERRUPT__) /* Dummy macro */
445 /** @brief Check whether the specified FMAC status flag is set or not.
446 * @param __HANDLE__ FMAC handle.
447 * @param __FLAG__ FMAC flag to check.
448 * This parameter can be one of the following values:
449 * @arg @ref FMAC_FLAG_YEMPTY Y Buffer Empty Flag
450 * @arg @ref FMAC_FLAG_X1FULL X1 Buffer Full Flag
451 * @arg @ref FMAC_FLAG_OVFL Overflow Error Flag
452 * @arg @ref FMAC_FLAG_UNFL Underflow Error Flag
453 * @arg @ref FMAC_FLAG_SAT Saturation error Flag
454 * @retval SET (flag is set) or RESET (flag is reset)
456 #define __HAL_FMAC_GET_FLAG(__HANDLE__, __FLAG__) \
457 ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
459 /** @brief Clear specified FMAC status flag. Dummy macro as no
461 * @param __HANDLE__ FMAC handle.
462 * @param __FLAG__ FMAC flag to clear.
465 #define __HAL_FMAC_CLEAR_FLAG(__HANDLE__, __FLAG__) /* Dummy macro */
467 /** @brief Check whether the specified FMAC interrupt is enabled or not.
468 * @param __HANDLE__ FMAC handle.
469 * @param __INTERRUPT__ FMAC interrupt to check.
470 * This parameter can be one of the following values:
471 * @arg @ref FMAC_IT_RIEN Read interrupt enable
472 * @arg @ref FMAC_IT_WIEN Write interrupt enable
473 * @arg @ref FMAC_IT_OVFLIEN Overflow error interrupt enable
474 * @arg @ref FMAC_IT_UNFLIEN Underflow error interrupt enable
475 * @arg @ref FMAC_IT_SATIEN Saturation error interrupt enable (this helps in debugging a filter)
478 #define __HAL_FMAC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) \
479 (((__HANDLE__)->Instance->CR) & (__INTERRUPT__))
485 /* Private macros --------------------------------------------------------*/
486 /** @addtogroup FMAC_Private_Macros
491 * @brief Verify the FMAC function.
492 * @param __FUNCTION__ ID of the function.
493 * @retval SET (__FUNCTION__ is a valid value) or RESET (__FUNCTION__ is invalid)
495 #define IS_FMAC_FUNCTION(__FUNCTION__) (((__FUNCTION__) == FMAC_FUNC_LOAD_X1) || \
496 ((__FUNCTION__) == FMAC_FUNC_LOAD_X2) || \
497 ((__FUNCTION__) == FMAC_FUNC_LOAD_Y) || \
498 ((__FUNCTION__) == FMAC_FUNC_CONVO_FIR) || \
499 ((__FUNCTION__) == FMAC_FUNC_IIR_DIRECT_FORM_1))
502 * @brief Verify the FMAC load function.
503 * @param __FUNCTION__ ID of the load function.
504 * @retval SET (__FUNCTION__ is a valid value) or RESET (__FUNCTION__ is invalid)
506 #define IS_FMAC_LOAD_FUNCTION(__FUNCTION__) (((__FUNCTION__) == FMAC_FUNC_LOAD_X1) || \
507 ((__FUNCTION__) == FMAC_FUNC_LOAD_X2) || \
508 ((__FUNCTION__) == FMAC_FUNC_LOAD_Y))
511 * @brief Verify the FMAC load function.
512 * @param __FUNCTION__ ID of the load function.
513 * @retval SET (__FUNCTION__ is a valid value) or RESET (__FUNCTION__ is invalid)
515 #define IS_FMAC_N_LOAD_FUNCTION(__FUNCTION__) (((__FUNCTION__) == FMAC_FUNC_LOAD_X1) || \
516 ((__FUNCTION__) == FMAC_FUNC_LOAD_Y))
519 * @brief Verify the FMAC load function.
520 * @param __FUNCTION__ ID of the load function.
521 * @retval SET (__FUNCTION__ is a valid value) or RESET (__FUNCTION__ is invalid)
523 #define IS_FMAC_N_M_LOAD_FUNCTION(__FUNCTION__) ((__FUNCTION__) == FMAC_FUNC_LOAD_X2)
526 * @brief Verify the FMAC filter function.
527 * @param __FUNCTION__ ID of the filter function.
528 * @retval SET (__FUNCTION__ is a valid value) or RESET (__FUNCTION__ is invalid)
530 #define IS_FMAC_FILTER_FUNCTION(__FUNCTION__) (((__FUNCTION__) == FMAC_FUNC_CONVO_FIR) || \
531 ((__FUNCTION__) == FMAC_FUNC_IIR_DIRECT_FORM_1))
535 * @brief Verify the FMAC threshold.
536 * @param __THRESHOLD__ Value of the threshold.
537 * @retval SET (__THRESHOLD__ is a valid value) or RESET (__THRESHOLD__ is invalid)
539 #define IS_FMAC_THRESHOLD(__THRESHOLD__) (((__THRESHOLD__) == FMAC_THRESHOLD_1) || \
540 ((__THRESHOLD__) == FMAC_THRESHOLD_2) || \
541 ((__THRESHOLD__) == FMAC_THRESHOLD_4) || \
542 ((__THRESHOLD__) == FMAC_THRESHOLD_NO_VALUE) || \
543 ((__THRESHOLD__) == FMAC_THRESHOLD_8))
546 * @brief Verify the FMAC filter parameter P.
547 * @param __P__ Value of the filter parameter P.
548 * @param __FUNCTION__ ID of the filter function.
549 * @retval SET (__P__ is a valid value) or RESET (__P__ is invalid)
551 #define IS_FMAC_PARAM_P(__FUNCTION__, __P__) ( (((__FUNCTION__) == FMAC_FUNC_CONVO_FIR) && \
552 (((__P__) >= 2U) && ((__P__) <= 127U))) || \
553 (((__FUNCTION__) == FMAC_FUNC_IIR_DIRECT_FORM_1) && \
554 (((__P__) >= 2U) && ((__P__) <= 64U))) )
557 * @brief Verify the FMAC filter parameter Q.
558 * @param __Q__ Value of the filter parameter Q.
559 * @param __FUNCTION__ ID of the filter function.
560 * @retval SET (__Q__ is a valid value) or RESET (__Q__ is invalid)
562 #define IS_FMAC_PARAM_Q(__FUNCTION__, __Q__) ( ((__FUNCTION__) == FMAC_FUNC_CONVO_FIR) || \
563 (((__FUNCTION__) == FMAC_FUNC_IIR_DIRECT_FORM_1) && \
564 (((__Q__) >= 1U) && ((__Q__) <= 63U))) )
567 * @brief Verify the FMAC filter parameter R.
568 * @param __R__ Value of the filter parameter.
569 * @param __FUNCTION__ ID of the filter function.
570 * @retval SET (__R__ is a valid value) or RESET (__R__ is invalid)
572 #define IS_FMAC_PARAM_R(__FUNCTION__, __R__) ( (((__FUNCTION__) == FMAC_FUNC_CONVO_FIR) || \
573 ((__FUNCTION__) == FMAC_FUNC_IIR_DIRECT_FORM_1)) && \
577 * @brief Verify the FMAC buffer access.
578 * @param __BUFFER_ACCESS__ Type of access.
579 * @retval SET (__BUFFER_ACCESS__ is a valid value) or RESET (__BUFFER_ACCESS__ is invalid)
581 #define IS_FMAC_BUFFER_ACCESS(__BUFFER_ACCESS__) (((__BUFFER_ACCESS__) == FMAC_BUFFER_ACCESS_NONE) || \
582 ((__BUFFER_ACCESS__) == FMAC_BUFFER_ACCESS_DMA) || \
583 ((__BUFFER_ACCESS__) == FMAC_BUFFER_ACCESS_POLLING) || \
584 ((__BUFFER_ACCESS__) == FMAC_BUFFER_ACCESS_IT))
587 * @brief Verify the FMAC clip feature.
588 * @param __CLIP_STATE__ Clip state.
589 * @retval SET (__CLIP_STATE__ is a valid value) or RESET (__CLIP_STATE__ is invalid)
591 #define IS_FMAC_CLIP_STATE(__CLIP_STATE__) (((__CLIP_STATE__) == FMAC_CLIP_DISABLED) || \
592 ((__CLIP_STATE__) == FMAC_CLIP_ENABLED))
598 /* Exported functions ------------------------------------------------------- */
599 /** @addtogroup FMAC_Exported_Functions
603 /** @addtogroup FMAC_Exported_Functions_Group1
606 /* Initialization and de-initialization functions ****************************/
607 HAL_StatusTypeDef
HAL_FMAC_Init(FMAC_HandleTypeDef
*hfmac
);
608 HAL_StatusTypeDef
HAL_FMAC_DeInit(FMAC_HandleTypeDef
*hfmac
);
609 void HAL_FMAC_MspInit(FMAC_HandleTypeDef
*hfmac
);
610 void HAL_FMAC_MspDeInit(FMAC_HandleTypeDef
*hfmac
);
612 #if (USE_HAL_FMAC_REGISTER_CALLBACKS == 1)
613 /* Callbacks Register/UnRegister functions ***********************************/
614 HAL_StatusTypeDef
HAL_FMAC_RegisterCallback(FMAC_HandleTypeDef
*hfmac
, HAL_FMAC_CallbackIDTypeDef CallbackID
,
615 pFMAC_CallbackTypeDef pCallback
);
616 HAL_StatusTypeDef
HAL_FMAC_UnRegisterCallback(FMAC_HandleTypeDef
*hfmac
, HAL_FMAC_CallbackIDTypeDef CallbackID
);
617 #endif /* USE_HAL_FMAC_REGISTER_CALLBACKS */
622 /** @addtogroup FMAC_Exported_Functions_Group2
625 /* Peripheral Control functions ***********************************************/
626 HAL_StatusTypeDef
HAL_FMAC_FilterConfig(FMAC_HandleTypeDef
*hfmac
, FMAC_FilterConfigTypeDef
*sConfig
);
627 HAL_StatusTypeDef
HAL_FMAC_FilterConfig_DMA(FMAC_HandleTypeDef
*hfmac
, FMAC_FilterConfigTypeDef
*sConfig
);
628 HAL_StatusTypeDef
HAL_FMAC_FilterPreload(FMAC_HandleTypeDef
*hfmac
, int16_t *pInput
, uint8_t InputSize
,
629 int16_t *pOutput
, uint8_t OutputSize
);
630 HAL_StatusTypeDef
HAL_FMAC_FilterPreload_DMA(FMAC_HandleTypeDef
*hfmac
, int16_t *pInput
, uint8_t InputSize
,
631 int16_t *pOutput
, uint8_t OutputSize
);
632 HAL_StatusTypeDef
HAL_FMAC_FilterStart(FMAC_HandleTypeDef
*hfmac
, int16_t *pOutput
, uint16_t *pOutputSize
);
633 HAL_StatusTypeDef
HAL_FMAC_AppendFilterData(FMAC_HandleTypeDef
*hfmac
, int16_t *pInput
, uint16_t *pInputSize
);
634 HAL_StatusTypeDef
HAL_FMAC_ConfigFilterOutputBuffer(FMAC_HandleTypeDef
*hfmac
, int16_t *pOutput
, uint16_t *pOutputSize
);
635 HAL_StatusTypeDef
HAL_FMAC_PollFilterData(FMAC_HandleTypeDef
*hfmac
, uint32_t Timeout
);
636 HAL_StatusTypeDef
HAL_FMAC_FilterStop(FMAC_HandleTypeDef
*hfmac
);
641 /** @addtogroup FMAC_Exported_Functions_Group3
644 /* Callback functions *********************************************************/
645 void HAL_FMAC_ErrorCallback(FMAC_HandleTypeDef
*hfmac
);
646 void HAL_FMAC_HalfGetDataCallback(FMAC_HandleTypeDef
*hfmac
);
647 void HAL_FMAC_GetDataCallback(FMAC_HandleTypeDef
*hfmac
);
648 void HAL_FMAC_HalfOutputDataReadyCallback(FMAC_HandleTypeDef
*hfmac
);
649 void HAL_FMAC_OutputDataReadyCallback(FMAC_HandleTypeDef
*hfmac
);
650 void HAL_FMAC_FilterConfigCallback(FMAC_HandleTypeDef
*hfmac
);
651 void HAL_FMAC_FilterPreloadCallback(FMAC_HandleTypeDef
*hfmac
);
656 /** @addtogroup FMAC_Exported_Functions_Group4
659 /* IRQ handler management *****************************************************/
660 void HAL_FMAC_IRQHandler(FMAC_HandleTypeDef
*hfmac
);
665 /** @addtogroup FMAC_Exported_Functions_Group5
668 /* Peripheral State functions *************************************************/
669 HAL_FMAC_StateTypeDef
HAL_FMAC_GetState(FMAC_HandleTypeDef
*hfmac
);
670 uint32_t HAL_FMAC_GetError(FMAC_HandleTypeDef
*hfmac
);
683 #endif /* STM32G4xx_HAL_FMAC_H */
693 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/