STM32H735xx HAL User Manual
Defines | Functions
stm32h7xx_hal_fmac.c File Reference

FMAC HAL module driver. This file provides firmware functions to manage the following functionalities of the FMAC peripheral: + Initialization and de-initialization functions + Peripheral Control functions + Callback functions + IRQ handler management + Peripheral State and Error functions. More...

#include "stm32h7xx_hal.h"

Go to the source code of this file.

Defines

#define MAX_FILTER_DATA_SIZE_TO_HANDLE   ((uint16_t) 0xFFU)
#define MAX_PRELOAD_INDEX   0xFFU
#define PRELOAD_ACCESS_DMA   0x00U
#define PRELOAD_ACCESS_POLLING   0x01U
#define POLLING_DISABLED   0U
#define POLLING_ENABLED   1U
#define POLLING_NOT_STOPPED   0U
#define POLLING_STOPPED   1U
#define HAL_FMAC_TIMEOUT_VALUE   1000U
#define HAL_FMAC_RESET_TIMEOUT_VALUE   500U
#define FMAC_DMA_REN   FMAC_CR_DMAREN
#define FMAC_DMA_WEN   FMAC_CR_DMAWEN
#define FMAC_START   FMAC_PARAM_START
#define FMAC_GET_X1_SIZE(__HANDLE__)   ((((__HANDLE__)->Instance->X1BUFCFG) & (FMAC_X1BUFCFG_X1_BUF_SIZE)) >> (FMAC_X1BUFCFG_X1_BUF_SIZE_Pos))
 Get the X1 memory area size.
#define FMAC_GET_X1_FULL_WM(__HANDLE__)   (((__HANDLE__)->Instance->X1BUFCFG) & (FMAC_X1BUFCFG_FULL_WM))
 Get the X1 watermark.
#define FMAC_GET_X2_SIZE(__HANDLE__)   ((((__HANDLE__)->Instance->X2BUFCFG) & (FMAC_X2BUFCFG_X2_BUF_SIZE)) >> (FMAC_X2BUFCFG_X2_BUF_SIZE_Pos))
 Get the X2 memory area size.
#define FMAC_GET_Y_SIZE(__HANDLE__)   ((((__HANDLE__)->Instance->YBUFCFG) & (FMAC_YBUFCFG_Y_BUF_SIZE)) >> (FMAC_YBUFCFG_Y_BUF_SIZE_Pos))
 Get the Y memory area size.
#define FMAC_GET_Y_EMPTY_WM(__HANDLE__)   (((__HANDLE__)->Instance->YBUFCFG) & (FMAC_YBUFCFG_EMPTY_WM))
 Get the Y watermark.
#define FMAC_GET_START_BIT(__HANDLE__)   ((((__HANDLE__)->Instance->PARAM) & (FMAC_PARAM_START)) >> (FMAC_PARAM_START_Pos))
 Get the start bit state.
#define FMAC_GET_THRESHOLD_FROM_WM(__WM__)
 Get the threshold matching the watermark.

Functions

static HAL_StatusTypeDef FMAC_Reset (FMAC_HandleTypeDef *hfmac)
 ============================================================================== ##### FMAC Private Functions ##### ==============================================================================
static void FMAC_ResetDataPointers (FMAC_HandleTypeDef *hfmac)
 Reset the data pointers of the FMAC unit.
static void FMAC_ResetOutputStateAndDataPointers (FMAC_HandleTypeDef *hfmac)
 Reset the output data pointers of the FMAC unit.
static void FMAC_ResetInputStateAndDataPointers (FMAC_HandleTypeDef *hfmac)
 Reset the input data pointers of the FMAC unit.
static HAL_StatusTypeDef FMAC_FilterConfig (FMAC_HandleTypeDef *hfmac, FMAC_FilterConfigTypeDef *pConfig, uint8_t PreloadAccess)
 Configure the FMAC filter.
static HAL_StatusTypeDef FMAC_FilterPreload (FMAC_HandleTypeDef *hfmac, int16_t *pInput, uint8_t InputSize, int16_t *pOutput, uint8_t OutputSize, uint8_t PreloadAccess)
 Preload the input (FIR, IIR) and output data (IIR) of the FMAC filter.
static void FMAC_WritePreloadDataIncrementPtr (FMAC_HandleTypeDef *hfmac, int16_t **ppData, uint8_t Size)
 Write data into FMAC internal memory through WDATA and increment input buffer pointer.
static HAL_StatusTypeDef FMAC_WaitOnStartUntilTimeout (FMAC_HandleTypeDef *hfmac, uint32_t Tickstart, uint32_t Timeout)
 Handle FMAC Function Timeout.
static HAL_StatusTypeDef FMAC_AppendFilterDataUpdateState (FMAC_HandleTypeDef *hfmac, int16_t *pInput, uint16_t *pInputSize)
 Register the new input buffer, update DMA configuration if needed and change the FMAC state.
static HAL_StatusTypeDef FMAC_ConfigFilterOutputBufferUpdateState (FMAC_HandleTypeDef *hfmac, int16_t *pOutput, uint16_t *pOutputSize)
 Register the new output buffer, update DMA configuration if needed and change the FMAC state.
static void FMAC_WriteDataIncrementPtr (FMAC_HandleTypeDef *hfmac, uint16_t MaxSizeToWrite)
 Write available input data until X1 FULL is set.
static void FMAC_ReadDataIncrementPtr (FMAC_HandleTypeDef *hfmac, uint16_t MaxSizeToRead)
 Read available output data until Y EMPTY is set.
static void FMAC_DMAHalfGetData (DMA_HandleTypeDef *hdma)
 DMA FMAC Input Data process half complete callback.
static void FMAC_DMAGetData (DMA_HandleTypeDef *hdma)
 DMA FMAC Input Data process complete callback.
static void FMAC_DMAHalfOutputDataReady (DMA_HandleTypeDef *hdma)
 DMA FMAC Output Data process half complete callback.
static void FMAC_DMAOutputDataReady (DMA_HandleTypeDef *hdma)
 DMA FMAC Output Data process complete callback.
static void FMAC_DMAFilterConfig (DMA_HandleTypeDef *hdma)
 DMA FMAC Filter Configuration process complete callback.
static void FMAC_DMAFilterPreload (DMA_HandleTypeDef *hdma)
 DMA FMAC Filter Configuration process complete callback.
static void FMAC_DMAError (DMA_HandleTypeDef *hdma)
 DMA FMAC communication error callback.
HAL_StatusTypeDef HAL_FMAC_Init (FMAC_HandleTypeDef *hfmac)
 Initialize the FMAC peripheral and the associated handle.
HAL_StatusTypeDef HAL_FMAC_DeInit (FMAC_HandleTypeDef *hfmac)
 De-initialize the FMAC peripheral.
__weak void HAL_FMAC_MspInit (FMAC_HandleTypeDef *hfmac)
 Initialize the FMAC MSP.
__weak void HAL_FMAC_MspDeInit (FMAC_HandleTypeDef *hfmac)
 De-initialize the FMAC MSP.
HAL_StatusTypeDef HAL_FMAC_RegisterCallback (FMAC_HandleTypeDef *hfmac, HAL_FMAC_CallbackIDTypeDef CallbackID, pFMAC_CallbackTypeDef pCallback)
 Register a User FMAC Callback.
HAL_StatusTypeDef HAL_FMAC_UnRegisterCallback (FMAC_HandleTypeDef *hfmac, HAL_FMAC_CallbackIDTypeDef CallbackID)
 Unregister a FMAC CallBack.
HAL_StatusTypeDef HAL_FMAC_FilterConfig (FMAC_HandleTypeDef *hfmac, FMAC_FilterConfigTypeDef *pConfig)
 Configure the FMAC filter.
HAL_StatusTypeDef HAL_FMAC_FilterConfig_DMA (FMAC_HandleTypeDef *hfmac, FMAC_FilterConfigTypeDef *pConfig)
 Configure the FMAC filter.
HAL_StatusTypeDef HAL_FMAC_FilterPreload (FMAC_HandleTypeDef *hfmac, int16_t *pInput, uint8_t InputSize, int16_t *pOutput, uint8_t OutputSize)
 Preload the input (FIR, IIR) and output data (IIR) of the FMAC filter.
HAL_StatusTypeDef HAL_FMAC_FilterPreload_DMA (FMAC_HandleTypeDef *hfmac, int16_t *pInput, uint8_t InputSize, int16_t *pOutput, uint8_t OutputSize)
 Preload the input (FIR, IIR) and output data (IIR) of the FMAC filter.
HAL_StatusTypeDef HAL_FMAC_FilterStart (FMAC_HandleTypeDef *hfmac, int16_t *pOutput, uint16_t *pOutputSize)
 Start the FMAC processing according to the existing FMAC configuration.
HAL_StatusTypeDef HAL_FMAC_AppendFilterData (FMAC_HandleTypeDef *hfmac, int16_t *pInput, uint16_t *pInputSize)
 Provide a new input buffer that will be loaded into the FMAC input memory area.
HAL_StatusTypeDef HAL_FMAC_ConfigFilterOutputBuffer (FMAC_HandleTypeDef *hfmac, int16_t *pOutput, uint16_t *pOutputSize)
 Provide a new output buffer to be filled with the data computed by FMAC unit.
HAL_StatusTypeDef HAL_FMAC_PollFilterData (FMAC_HandleTypeDef *hfmac, uint32_t Timeout)
 Handle the input and/or output data in polling mode.
HAL_StatusTypeDef HAL_FMAC_FilterStop (FMAC_HandleTypeDef *hfmac)
 Stop the FMAC processing.
__weak void HAL_FMAC_ErrorCallback (FMAC_HandleTypeDef *hfmac)
 FMAC error callback.
__weak void HAL_FMAC_HalfGetDataCallback (FMAC_HandleTypeDef *hfmac)
 FMAC get half data callback.
__weak void HAL_FMAC_GetDataCallback (FMAC_HandleTypeDef *hfmac)
 FMAC get data callback.
__weak void HAL_FMAC_HalfOutputDataReadyCallback (FMAC_HandleTypeDef *hfmac)
 FMAC half output data ready callback.
__weak void HAL_FMAC_OutputDataReadyCallback (FMAC_HandleTypeDef *hfmac)
 FMAC output data ready callback.
__weak void HAL_FMAC_FilterConfigCallback (FMAC_HandleTypeDef *hfmac)
 FMAC filter configuration callback.
__weak void HAL_FMAC_FilterPreloadCallback (FMAC_HandleTypeDef *hfmac)
 FMAC filter preload callback.
void HAL_FMAC_IRQHandler (FMAC_HandleTypeDef *hfmac)
 Handle FMAC interrupt request.
HAL_FMAC_StateTypeDef HAL_FMAC_GetState (FMAC_HandleTypeDef *hfmac)
 Return the FMAC state.
uint32_t HAL_FMAC_GetError (FMAC_HandleTypeDef *hfmac)
 Return the FMAC peripheral error.

Detailed Description

FMAC HAL module driver. This file provides firmware functions to manage the following functionalities of the FMAC peripheral: + Initialization and de-initialization functions + Peripheral Control functions + Callback functions + IRQ handler management + Peripheral State and Error functions.

Author:
MCD Application Team
Attention:

Copyright (c) 2017 STMicroelectronics. All rights reserved.

This software is licensed under terms that can be found in the LICENSE file in the root directory of this software component. If no LICENSE file comes with this software, it is provided AS-IS.

================================================================================
            ##### How to use this driver #####
================================================================================
    [..]
      The FMAC HAL driver can be used as follows:

      (#) Initialize the FMAC low level resources by implementing the HAL_FMAC_MspInit():
          (++) Enable the FMAC interface clock using __HAL_RCC_FMAC_CLK_ENABLE().
          (++) In case of using interrupts (e.g. access configured as FMAC_BUFFER_ACCESS_IT):
               (+++) Configure the FMAC interrupt priority using HAL_NVIC_SetPriority().
               (+++) Enable the FMAC IRQ handler using HAL_NVIC_EnableIRQ().
               (+++) In FMAC IRQ handler, call HAL_FMAC_IRQHandler().
          (++) In case of using DMA to control data transfer (e.g. access configured
               as FMAC_BUFFER_ACCESS_DMA):
               (+++) Enable the DMA interface clock using __HAL_RCC_DMA1_CLK_ENABLE()
                     or __HAL_RCC_DMA2_CLK_ENABLE() depending on the used DMA instance.
               (+++) Enable the DMAMUX1 interface clock using __HAL_RCC_DMAMUX1_CLK_ENABLE().
               (+++) If the initialization of the internal buffers (coefficients, input,
                     output) is done via DMA, configure and enable one DMA channel for
                     managing data transfer from memory to memory (preload channel).
               (+++) If the input buffer is accessed via DMA, configure and enable one
                     DMA channel for managing data transfer from memory to peripheral
                     (input channel).
               (+++) If the output buffer is accessed via DMA, configure and enable
                     one DMA channel for managing data transfer from peripheral to
                     memory (output channel).
               (+++) Associate the initialized DMA handle(s) to the FMAC DMA handle(s)
                     using __HAL_LINKDMA().
               (+++) Configure the priority and enable the NVIC for the transfer complete
                     interrupt on the enabled DMA channel(s) using HAL_NVIC_SetPriority()
                     and HAL_NVIC_EnableIRQ().

      (#) Initialize the FMAC HAL using HAL_FMAC_Init(). This function
          resorts to HAL_FMAC_MspInit() for low-level initialization.

      (#) Configure the FMAC processing (filter) using HAL_FMAC_FilterConfig()
          or HAL_FMAC_FilterConfig_DMA().
          This function:
          (++) Defines the memory area within the FMAC internal memory
               (input, coefficients, output) and the associated threshold (input, output).
          (++) Configures the filter and its parameters:
               (+++) Finite Impulse Response (FIR) filter (also known as convolution).
               (+++) Infinite Impulse Response (IIR) filter (direct form 1).
          (++) Choose the way to access to the input and output buffers: none, polling,
               DMA, IT. "none" means the input and/or output data will be handled by
               another IP (ADC, DAC, etc.).
          (++) Enable the error interruptions in the input access and/or the output
               access is done through IT/DMA. If an error occurs, the interruption
               will be triggered in loop. In order to recover, the user will have
               to reset the IP with the sequence HAL_FMAC_DeInit / HAL_FMAC_Init.
               Optionally, he can also disable the interrupt using __HAL_FMAC_DISABLE_IT;
               the error status will be kept, but no more interrupt will be triggered.
          (++) Write the provided coefficients into the internal memory using polling
               mode ( HAL_FMAC_FilterConfig() ) or DMA ( HAL_FMAC_FilterConfig_DMA() ).
               In the DMA case, HAL_FMAC_FilterConfigCallback() is called when
               the handling is over.

       (#) Optionally, the user can enable the error interruption related to
           saturation by calling __HAL_FMAC_ENABLE_IT. This helps in debugging the
           filter. If a saturation occurs, the interruption will be triggered in loop.
           In order to recover, the user will have to:
           (++) Disable the interruption by calling __HAL_FMAC_DISABLE_IT if
                the user wishes to continue all the same.
           (++) Reset the IP with the sequence HAL_FMAC_DeInit / HAL_FMAC_Init.

       (#) Optionally, preload input (FIR, IIR) and output (IIR) data using
           HAL_FMAC_FilterPreload() or HAL_FMAC_FilterPreload_DMA().
           In the DMA case, HAL_FMAC_FilterPreloadCallback() is called when
           the handling is over.
           This step is optional as the filter can be started without preloaded
           data.

       (#) Start the FMAC processing (filter) using HAL_FMAC_FilterStart().
           This function also configures the output buffer that will be filled from
           the circular internal output buffer. The function returns immediately
           without updating the provided buffer. The IP processing will be active until
           HAL_FMAC_FilterStop() is called.

       (#) If the input internal buffer is accessed via DMA, HAL_FMAC_HalfGetDataCallback()
           will be called to indicate that half of the input buffer has been handled.

       (#) If the input internal buffer is accessed via DMA or interrupt, HAL_FMAC_GetDataCallback()
           will be called to require new input data. It will be provided through
           HAL_FMAC_AppendFilterData() if the DMA isn't in circular mode.

       (#) If the output internal buffer is accessed via DMA, HAL_FMAC_HalfOutputDataReadyCallback()
           will be called to indicate that half of the output buffer has been handled.

       (#) If the output internal buffer is accessed via DMA or interrupt,
           HAL_FMAC_OutputDataReadyCallback() will be called to require a new output
           buffer. It will be provided through HAL_FMAC_ConfigFilterOutputBuffer()
           if the DMA isn't in circular mode.

       (#) In all modes except none, provide new input data to be processed via HAL_FMAC_AppendFilterData().
           This function should only be called once the previous input data has been handled
           (the preloaded input data isn't concerned).

       (#) In all modes except none, provide a new output buffer to be filled via
           HAL_FMAC_ConfigFilterOutputBuffer(). This function should only be called once the previous
           user's output buffer has been filled.

       (#) In polling mode, handle the input and output data using HAL_FMAC_PollFilterData().
           This function:
           (++) Write the user's input data (provided via HAL_FMAC_AppendFilterData())
                into the FMAC input memory area.
           (++) Read the FMAC output memory area and write it into the user's output buffer.
           It will return either when:
           (++) the user's output buffer is filled.
           (++) the user's input buffer has been handled.
           The unused data (unread input data or free output data) will not be saved.
           The user will have to use the updated input and output sizes to keep track
           of them.

       (#) Stop the FMAC processing (filter) using HAL_FMAC_FilterStop().

       (#) Call HAL_FMAC_DeInit() to de-initialize the FMAC peripheral. This function
           resorts to HAL_FMAC_MspDeInit() for low-level de-initialization.

  ##### Callback registration #####
  ==================================

    [..]
      The compilation define USE_HAL_FMAC_REGISTER_CALLBACKS when set to 1
      allows the user to configure dynamically the driver callbacks.

    [..]
      Use Function HAL_FMAC_RegisterCallback() to register a user callback.
      Function HAL_FMAC_RegisterCallback() allows to register following callbacks:
      (+) ErrorCallback               : Error Callback.
      (+) HalfGetDataCallback         : Get Half Data Callback.
      (+) GetDataCallback             : Get Data Callback.
      (+) HalfOutputDataReadyCallback : Half Output Data Ready Callback.
      (+) OutputDataReadyCallback     : Output Data Ready Callback.
      (+) FilterConfigCallback        : Filter Configuration Callback.
      (+) FilterPreloadCallback       : Filter Preload Callback.
      (+) MspInitCallback             : FMAC MspInit.
      (+) MspDeInitCallback           : FMAC MspDeInit.
      This function takes as parameters the HAL peripheral handle, the Callback ID
      and a pointer to the user callback function.

    [..]
      Use function HAL_FMAC_UnRegisterCallback() to reset a callback to the default
      weak (surcharged) function.
      HAL_FMAC_UnRegisterCallback() takes as parameters the HAL peripheral handle
      and the Callback ID.
      This function allows to reset following callbacks:
      (+) ErrorCallback               : Error Callback.
      (+) HalfGetDataCallback         : Get Half Data Callback.
      (+) GetDataCallback             : Get Data Callback.
      (+) HalfOutputDataReadyCallback : Half Output Data Ready Callback.
      (+) OutputDataReadyCallback     : Output Data Ready Callback.
      (+) FilterConfigCallback        : Filter Configuration Callback.
      (+) FilterPreloadCallback       : Filter Preload Callback.
      (+) MspInitCallback             : FMAC MspInit.
      (+) MspDeInitCallback           : FMAC MspDeInit.

    [..]
      By default, after the HAL_FMAC_Init() and when the state is HAL_FMAC_STATE_RESET
      all callbacks are set to the corresponding weak (surcharged) functions:
      examples GetDataCallback(), OutputDataReadyCallback().
      Exception done for MspInit and MspDeInit functions that are respectively
      reset to the legacy weak (surcharged) functions in the HAL_FMAC_Init()
      and HAL_FMAC_DeInit() only when these callbacks are null (not registered beforehand).
      If not, MspInit or MspDeInit are not null, the HAL_FMAC_Init() and HAL_FMAC_DeInit()
      keep and use the user MspInit/MspDeInit callbacks (registered beforehand).

    [..]
      Callbacks can be registered/unregistered in HAL_FMAC_STATE_READY state only.
      Exception done MspInit/MspDeInit that can be registered/unregistered
      in HAL_FMAC_STATE_READY or HAL_FMAC_STATE_RESET state, thus registered (user)
      MspInit/DeInit callbacks can be used during the Init/DeInit.
      In that case first register the MspInit/MspDeInit user callbacks
      using HAL_FMAC_RegisterCallback() before calling HAL_FMAC_DeInit()
      or HAL_FMAC_Init() function.

    [..]
      When the compilation define USE_HAL_FMAC_REGISTER_CALLBACKS is set to 0 or
      not defined, the callback registration feature is not available
      and weak (surcharged) callbacks are used.


  

Definition in file stm32h7xx_hal_fmac.c.