1 /**
2   ******************************************************************************
3   * @file    stm32h7xx_hal_fmac.h
4   * @author  MCD Application Team
5   * @brief   Header for stm32h7xx_hal_fmac.c module
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2017 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 STM32H7xx_HAL_FMAC_H
21 #define STM32H7xx_HAL_FMAC_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32h7xx_hal_def.h"
29 
30 #if defined(FMAC)
31 /** @addtogroup STM32H7xx_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 Macros-----------------------------------------------------------*/
487 /** @addtogroup  FMAC_Private_Macros FMAC Private Macros
488   * @{
489   */
490 
491 /**
492   * @brief  Verify the FMAC function.
493   * @param  __FUNCTION__ ID of the function.
494   * @retval SET (__FUNCTION__ is a valid value) or RESET (__FUNCTION__ is invalid)
495   */
496 #define IS_FMAC_FUNCTION(__FUNCTION__) (((__FUNCTION__) == FMAC_FUNC_LOAD_X1)                         || \
497                                         ((__FUNCTION__) == FMAC_FUNC_LOAD_X2)                         || \
498                                         ((__FUNCTION__) == FMAC_FUNC_LOAD_Y)                          || \
499                                         ((__FUNCTION__) == FMAC_FUNC_CONVO_FIR)                       || \
500                                         ((__FUNCTION__) == FMAC_FUNC_IIR_DIRECT_FORM_1))
501 
502 /**
503   * @brief  Verify the FMAC load function used for input data, output data or coefficients.
504   * @param  __FUNCTION__ ID of the load function.
505   * @retval SET (__FUNCTION__ is a valid value) or RESET (__FUNCTION__ is invalid)
506   */
507 #define IS_FMAC_LOAD_FUNCTION(__FUNCTION__) (((__FUNCTION__) == FMAC_FUNC_LOAD_X1)                    || \
508                                              ((__FUNCTION__) == FMAC_FUNC_LOAD_X2)                    || \
509                                              ((__FUNCTION__) == FMAC_FUNC_LOAD_Y))
510 
511 /**
512   * @brief  Verify the FMAC load function used with N values as input or output data.
513   * @param  __FUNCTION__ ID of the load function.
514   * @retval SET (__FUNCTION__ is a valid value) or RESET (__FUNCTION__ is invalid)
515   */
516 #define IS_FMAC_N_LOAD_FUNCTION(__FUNCTION__) (((__FUNCTION__) == FMAC_FUNC_LOAD_X1)                  || \
517                                                ((__FUNCTION__) == FMAC_FUNC_LOAD_Y))
518 
519 /**
520   * @brief  Verify the FMAC load function used with N + M values as coefficients.
521   * @param  __FUNCTION__ ID of the load function.
522   * @retval SET (__FUNCTION__ is a valid value) or RESET (__FUNCTION__ is invalid)
523   */
524 #define IS_FMAC_N_M_LOAD_FUNCTION(__FUNCTION__) ((__FUNCTION__) == FMAC_FUNC_LOAD_X2)
525 
526 /**
527   * @brief  Verify the FMAC filter function.
528   * @param  __FUNCTION__ ID of the filter function.
529   * @retval SET (__FUNCTION__ is a valid value) or RESET (__FUNCTION__ is invalid)
530   */
531 #define IS_FMAC_FILTER_FUNCTION(__FUNCTION__) (((__FUNCTION__) == FMAC_FUNC_CONVO_FIR)                || \
532                                                ((__FUNCTION__) == FMAC_FUNC_IIR_DIRECT_FORM_1))
533 
534 
535 /**
536   * @brief  Verify the FMAC threshold.
537   * @param  __THRESHOLD__ Value of the threshold.
538   * @retval SET (__THRESHOLD__ is a valid value) or RESET (__THRESHOLD__ is invalid)
539   */
540 #define IS_FMAC_THRESHOLD(__THRESHOLD__) (((__THRESHOLD__) == FMAC_THRESHOLD_1)                       || \
541                                           ((__THRESHOLD__) == FMAC_THRESHOLD_2)                       || \
542                                           ((__THRESHOLD__) == FMAC_THRESHOLD_4)                       || \
543                                           ((__THRESHOLD__) == FMAC_THRESHOLD_NO_VALUE)                || \
544                                           ((__THRESHOLD__) == FMAC_THRESHOLD_8))
545 
546 /**
547   * @brief  Verify the FMAC filter parameter P.
548   * @param  __P__ Value of the filter parameter P.
549   * @param  __FUNCTION__ ID of the filter function.
550   * @retval SET (__P__ is a valid value) or RESET (__P__ is invalid)
551   */
552 #define IS_FMAC_PARAM_P(__FUNCTION__, __P__) ( (((__FUNCTION__) == FMAC_FUNC_CONVO_FIR)               && \
553                                                 (((__P__) >= 2U) && ((__P__) <= 127U)))               || \
554                                                (((__FUNCTION__) == FMAC_FUNC_IIR_DIRECT_FORM_1)       && \
555                                                 (((__P__) >= 2U) && ((__P__) <= 64U))) )
556 
557 /**
558   * @brief  Verify the FMAC filter parameter Q.
559   * @param  __Q__ Value of the filter parameter Q.
560   * @param  __FUNCTION__ ID of the filter function.
561   * @retval SET (__Q__ is a valid value) or RESET (__Q__ is invalid)
562   */
563 #define IS_FMAC_PARAM_Q(__FUNCTION__, __Q__) ( ((__FUNCTION__) == FMAC_FUNC_CONVO_FIR)                || \
564                                                (((__FUNCTION__) == FMAC_FUNC_IIR_DIRECT_FORM_1)       && \
565                                                 (((__Q__) >= 1U) && ((__Q__) <= 63U))) )
566 
567 /**
568   * @brief  Verify the FMAC filter parameter R.
569   * @param  __R__ Value of the filter parameter.
570   * @param  __FUNCTION__ ID of the filter function.
571   * @retval SET (__R__ is a valid value) or RESET (__R__ is invalid)
572   */
573 #define IS_FMAC_PARAM_R(__FUNCTION__, __R__) ( (((__FUNCTION__) == FMAC_FUNC_CONVO_FIR)               || \
574                                                 ((__FUNCTION__) == FMAC_FUNC_IIR_DIRECT_FORM_1))      && \
575                                                ((__R__) <= 7U))
576 
577 /**
578   * @brief  Verify the FMAC buffer access.
579   * @param  __BUFFER_ACCESS__ Type of access.
580   * @retval SET (__BUFFER_ACCESS__ is a valid value) or RESET (__BUFFER_ACCESS__ is invalid)
581   */
582 #define IS_FMAC_BUFFER_ACCESS(__BUFFER_ACCESS__) (((__BUFFER_ACCESS__) == FMAC_BUFFER_ACCESS_NONE)    || \
583                                                   ((__BUFFER_ACCESS__) == FMAC_BUFFER_ACCESS_DMA)     || \
584                                                   ((__BUFFER_ACCESS__) == FMAC_BUFFER_ACCESS_POLLING) || \
585                                                   ((__BUFFER_ACCESS__) == FMAC_BUFFER_ACCESS_IT))
586 
587 /**
588   * @brief  Verify the FMAC clip feature.
589   * @param  __CLIP_STATE__ Clip state.
590   * @retval SET (__CLIP_STATE__ is a valid value) or RESET (__CLIP_STATE__ is invalid)
591   */
592 #define IS_FMAC_CLIP_STATE(__CLIP_STATE__) (((__CLIP_STATE__) == FMAC_CLIP_DISABLED)                  || \
593                                             ((__CLIP_STATE__) == FMAC_CLIP_ENABLED))
594 
595 /**
596   * @brief  Check whether the threshold is applicable.
597   * @param  __SIZE__ Size of the matching buffer.
598   * @param  __WM__ Watermark value.
599   * @param  __ACCESS__ Access to the buffer (polling, it, dma, none).
600   * @retval THRESHOLD
601   */
602 #define IS_FMAC_THRESHOLD_APPLICABLE(__SIZE__, __WM__, __ACCESS__) \
603   (( (__SIZE__) >= (((__WM__) == FMAC_THRESHOLD_1)? 1U: \
604                     ((__WM__) == FMAC_THRESHOLD_2)? 2U: \
605                     ((__WM__) == FMAC_THRESHOLD_4)? 4U:8U))&& \
606    ((((__ACCESS__) == FMAC_BUFFER_ACCESS_DMA)&& \
607      ((__WM__) == FMAC_THRESHOLD_1))|| \
608     ((__ACCESS__ )!= FMAC_BUFFER_ACCESS_DMA)))
609 
610 /**
611   * @}
612   */
613 
614 /* Exported functions ------------------------------------------------------- */
615 /** @addtogroup FMAC_Exported_Functions
616   * @{
617   */
618 
619 /** @addtogroup FMAC_Exported_Functions_Group1
620   * @{
621   */
622 /* Initialization and de-initialization functions  ****************************/
623 HAL_StatusTypeDef HAL_FMAC_Init(FMAC_HandleTypeDef *hfmac);
624 HAL_StatusTypeDef HAL_FMAC_DeInit(FMAC_HandleTypeDef *hfmac);
625 void HAL_FMAC_MspInit(FMAC_HandleTypeDef *hfmac);
626 void HAL_FMAC_MspDeInit(FMAC_HandleTypeDef *hfmac);
627 
628 #if (USE_HAL_FMAC_REGISTER_CALLBACKS == 1)
629 /* Callbacks Register/UnRegister functions  ***********************************/
630 HAL_StatusTypeDef HAL_FMAC_RegisterCallback(FMAC_HandleTypeDef *hfmac, HAL_FMAC_CallbackIDTypeDef CallbackID,
631                                             pFMAC_CallbackTypeDef pCallback);
632 HAL_StatusTypeDef HAL_FMAC_UnRegisterCallback(FMAC_HandleTypeDef *hfmac, HAL_FMAC_CallbackIDTypeDef CallbackID);
633 #endif /* USE_HAL_FMAC_REGISTER_CALLBACKS */
634 /**
635   * @}
636   */
637 
638 /** @addtogroup FMAC_Exported_Functions_Group2
639   * @{
640   */
641 /* Peripheral Control functions ***********************************************/
642 HAL_StatusTypeDef HAL_FMAC_FilterConfig(FMAC_HandleTypeDef *hfmac, FMAC_FilterConfigTypeDef *pConfig);
643 HAL_StatusTypeDef HAL_FMAC_FilterConfig_DMA(FMAC_HandleTypeDef *hfmac, FMAC_FilterConfigTypeDef *pConfig);
644 HAL_StatusTypeDef HAL_FMAC_FilterPreload(FMAC_HandleTypeDef *hfmac, int16_t *pInput, uint8_t InputSize,
645                                          int16_t *pOutput, uint8_t OutputSize);
646 HAL_StatusTypeDef HAL_FMAC_FilterPreload_DMA(FMAC_HandleTypeDef *hfmac, int16_t *pInput, uint8_t InputSize,
647                                              int16_t *pOutput, uint8_t OutputSize);
648 HAL_StatusTypeDef HAL_FMAC_FilterStart(FMAC_HandleTypeDef *hfmac, int16_t *pOutput, uint16_t *pOutputSize);
649 HAL_StatusTypeDef HAL_FMAC_AppendFilterData(FMAC_HandleTypeDef *hfmac, int16_t *pInput, uint16_t *pInputSize);
650 HAL_StatusTypeDef HAL_FMAC_ConfigFilterOutputBuffer(FMAC_HandleTypeDef *hfmac, int16_t *pOutput, uint16_t *pOutputSize);
651 HAL_StatusTypeDef HAL_FMAC_PollFilterData(FMAC_HandleTypeDef *hfmac, uint32_t Timeout);
652 HAL_StatusTypeDef HAL_FMAC_FilterStop(FMAC_HandleTypeDef  *hfmac);
653 /**
654   * @}
655   */
656 
657 /** @addtogroup FMAC_Exported_Functions_Group3
658   * @{
659   */
660 /* Callback functions *********************************************************/
661 void HAL_FMAC_ErrorCallback(FMAC_HandleTypeDef *hfmac);
662 void HAL_FMAC_HalfGetDataCallback(FMAC_HandleTypeDef *hfmac);
663 void HAL_FMAC_GetDataCallback(FMAC_HandleTypeDef *hfmac);
664 void HAL_FMAC_HalfOutputDataReadyCallback(FMAC_HandleTypeDef *hfmac);
665 void HAL_FMAC_OutputDataReadyCallback(FMAC_HandleTypeDef *hfmac);
666 void HAL_FMAC_FilterConfigCallback(FMAC_HandleTypeDef *hfmac);
667 void HAL_FMAC_FilterPreloadCallback(FMAC_HandleTypeDef *hfmac);
668 /**
669   * @}
670   */
671 
672 /** @addtogroup FMAC_Exported_Functions_Group4
673   * @{
674   */
675 /* IRQ handler management *****************************************************/
676 void HAL_FMAC_IRQHandler(FMAC_HandleTypeDef *hfmac);
677 /**
678   * @}
679   */
680 
681 /** @addtogroup FMAC_Exported_Functions_Group5
682   * @{
683   */
684 /* Peripheral State functions *************************************************/
685 HAL_FMAC_StateTypeDef HAL_FMAC_GetState(FMAC_HandleTypeDef *hfmac);
686 uint32_t HAL_FMAC_GetError(FMAC_HandleTypeDef *hfmac);
687 /**
688   * @}
689   */
690 
691 /**
692   * @}
693   */
694 
695 /**
696   * @}
697   */
698 
699 /**
700   * @}
701   */
702 
703 #endif /* FMAC */
704 
705 #ifdef __cplusplus
706 }
707 #endif
708 
709 #endif /* STM32H7xx_HAL_FMAC_H */
710