HAL FMAC How to Use ¶
- group FMAC_How_To_Use
-
An explanation on FMAC overall usage:
The filter math accelerator unit performs arithmetic operations on vectors. The unit includes support for circular buffers on input and output, which allows digital filters to be implemented (finite/infinite impulse response filters).
The unit allows frequent or lengthy filtering operations to be offloaded from the CPU, freeing up the processor for other tasks, and it can accelerate such calculations compared to a software implementation.
This file provides firmware functions to managed the following functionalities of FMAC peripheral:
-
Initialization and De-initialization functions
-
Configuration functions
-
Preload functions
-
Filter functions
-
X1 buffer write functions and Y buffer read functions
-
Callbacks functions
-
IRQ handler management
-
Peripheral State and Error functions
-
Set/Get user data
How to use the FMAC HAL module driver ¶
Initialization and de-initialization functions: ¶
-
Declare a hal_fmac_handle_t handle structure
-
Initialize the FMACx driver with an FMACx HW instance by calling the HAL_FMAC_Init() . The FMACx clock is enabled inside the HAL_FMAC_Init() if USE_HAL_FMAC_CLK_ENABLE_MODEL > HAL_CLK_ENABLE_NO.
-
Use HAL_FMAC_DeInit() to de-initialize the FMAC peripheral and restore the default configuration.
Configuration functions: ¶
-
Use HAL_FMAC_SetConfig() to configure the bases inside the FMAC internal 16-bit memory for the three FMAC buffers (X1, X2 and Y), and reset all thresholds.
-
Use HAL_FMAC_GetConfig() to retrieve the bases inside the FMAC internal 16-bit memory for the three FMAC buffers (X1, X2 and Y).
-
Configure the FMAC X1 full watermark threshold by calling HAL_FMAC_SetX1FullWatermark() , and retrieve the watermark threshold by calling HAL_FMAC_GetX1FullWatermark() .
-
Configure the FMAC Y empty watermark threshold by calling HAL_FMAC_SetYEmptyWatermark() , and retrieve the watermark threshold by calling HAL_FMAC_GetYEmptyWatermark() .
-
Use HAL_FMAC_SetX2BaseAddress() to Configure the FMAC X2 base address.
-
Enable, disable, and Check the FMAC clip status by using the following functions:
-
Use HAL_FMAC_GetX1Address() or HAL_FMAC_GetYAddress() to directly write or read the X1 and Y by a periphal (Timer, ADC, DAC, etc).
-
Link the Write X1 DMA handle to the FMAC handle by calling HAL_FMAC_SetWriteX1DMA() .
-
Link the Read Y DMA handle to the FMAC handle by calling HAL_FMAC_SetReadYDMA() .
Preload functions: ¶
-
Use HAL_FMAC_PreloadX1() and HAL_FMAC_PreloadX1_DMA() to preload the X1 buffer without and with DMA.
-
Use HAL_FMAC_PreloadY() and HAL_FMAC_PreloadY_DMA() to preload the Y buffer without and with DMA.
-
Use HAL_FMAC_PreloadX2() to preload X2 buffer with Coeff A and/or B.
Filter functions: ¶
-
Use HAL_FMAC_StartFilterFIR() to start a FIR filter process.
-
Use HAL_FMAC_StartFilterIIR() to start a IIR filter process.
-
Use HAL_FMAC_StopFilter() Stop the filter process, the X1 process and the Y process.
X1 buffer write functions and Y buffer read functions: ¶
-
Write data to X1 in polling mode, interrupt mode, DMA mode, and DMA mode with optional interrupts by calling the following functions:
-
Read data from Y in polling mode, interrupt mode, DMA mode, and DMA mode with optional interrupts by calling the following functions:
-
Use HAL_FMAC_LockX1WriteAccessForExternPeriph() to start Write data to X1 driven by another peripheral (Timer, ADC, DAC etc).
-
Use HAL_FMAC_UnockX1WriteAccessForExternPeriph() to stop Write data to X1 driven by another peripheral (Timer, ADC, DAC etc).
-
Use HAL_FMAC_LockYReadAccessForExternPeriph() to start Read data from Y driven by another peripheral (Timer, ADC, DAC etc).
-
Use HAL_FMAC_UnlockYReadAccessForExternPeriph() to stop Read data from Y driven by another peripheral (Timer, ADC, DAC etc).
Callbacks functions ¶
-
Use HAL_FMAC_RegisterWriteX1CpltCallback() function to register the FMAC Write X1 complete user callback.
-
Use HAL_FMAC_RegisterWriteX1HalfCpltCallback() function to register the FMAC Write X1 Half complete user callback.
-
Use HAL_FMAC_RegisterReadYCpltCallback() function to register the FMAC Read Y complete user callback.
-
Use HAL_FMAC_RegisterReadYHalfCpltCallback() function to register the FMAC Read Y Half complete user callback.
-
Use HAL_FMAC_RegisterPreloadCpltCallback() function to register the FMAC Preload complete user callback.
-
Use HAL_FMAC_RegisterErrorCallback() function to register the FMAC error user callback.
IRQ handler management ¶
-
Use HAL_FMAC_IRQHandler() function called under FMAC_IRQHandler interrupt subroutine to handle any FMAC interrupt.
-
Use HAL_FMAC_ERROR_IRQHandler() function to handle error FMAC interrupts.
Peripheral State and Error functions ¶
-
Use HAL_FMAC_GetState() function to get the FMAC filter process state
-
Use HAL_FMAC_GetX1State() function to get the FMAC X1 process state
-
Use HAL_FMAC_GetYState() function to get the FMAC Y process state
-
Use HAL_FMAC_GetLastErrorCodes() function to get the last error codes
Set/Get user data ¶
-
Use HAL_FMAC_SetUserData() function to set the FMAC user data
-
Use HAL_FMAC_GetUserData() function to get the FMAC user data
-