STM32G474xx HAL User Manual
stm32g4xx_ll_fmac.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32g4xx_ll_fmac.h
00004   * @author  MCD Application Team
00005   * @brief   Header file of FMAC LL module.
00006   ******************************************************************************
00007   * @attention
00008 
00009   * Copyright (c) 2019 STMicroelectronics.
00010   * All rights reserved.
00011 
00012   * This software is licensed under terms that can be found in the LICENSE file
00013   * in the root directory of this software component.
00014   * If no LICENSE file comes with this software, it is provided AS-IS.
00015 
00016   ******************************************************************************
00017   */
00018 
00019 /* Define to prevent recursive inclusion -------------------------------------*/
00020 #ifndef STM32G4xx_LL_FMAC_H
00021 #define STM32G4xx_LL_FMAC_H
00022 
00023 #ifdef __cplusplus
00024 extern "C" {
00025 #endif
00026 
00027 /* Includes ------------------------------------------------------------------*/
00028 #include "stm32g4xx.h"
00029 
00030 /** @addtogroup STM32G4xx_LL_Driver
00031   * @{
00032   */
00033 
00034 #if defined(FMAC)
00035 
00036 /** @defgroup FMAC_LL FMAC
00037   * @{
00038   */
00039 
00040 /* Exported types ------------------------------------------------------------*/
00041 /* Exported constants --------------------------------------------------------*/
00042 /** @defgroup FMAC_LL_Exported_Constants FMAC Exported Constants
00043   * @{
00044   */
00045 
00046 /** @defgroup FMAC_LL_EC_GET_FLAG Get Flag Defines
00047   * @brief    Flag defines which can be used with LL_FMAC_ReadReg function
00048   * @{
00049   */
00050 #define LL_FMAC_SR_SAT                     FMAC_SR_SAT    /*!< Saturation Error Flag
00051                                                                (this helps in debugging a filter)                     */
00052 #define LL_FMAC_SR_UNFL                    FMAC_SR_UNFL   /*!< Underflow Error Flag                                   */
00053 #define LL_FMAC_SR_OVFL                    FMAC_SR_OVFL   /*!< Overflow Error Flag                                    */
00054 #define LL_FMAC_SR_X1FULL                  FMAC_SR_X1FULL /*!< X1 Buffer Full Flag                                    */
00055 #define LL_FMAC_SR_YEMPTY                  FMAC_SR_YEMPTY /*!< Y Buffer Empty Flag                                    */
00056 /**
00057   * @}
00058   */
00059 
00060 /** @defgroup FMAC_LL_EC_IT IT Defines
00061   * @brief    IT defines which can be used with LL_FMAC_ReadReg and LL_FMAC_WriteReg functions
00062   * @{
00063   */
00064 #define LL_FMAC_CR_SATIEN                  FMAC_CR_SATIEN  /*!< Saturation Error Interrupt Enable
00065                                                                 (this helps in debugging a filter)                    */
00066 #define LL_FMAC_CR_UNFLIEN                 FMAC_CR_UNFLIEN /*!< Underflow Error Interrupt Enable                      */
00067 #define LL_FMAC_CR_OVFLIEN                 FMAC_CR_OVFLIEN /*!< Overflow Error Interrupt Enable                       */
00068 #define LL_FMAC_CR_WIEN                    FMAC_CR_WIEN    /*!< Write Interrupt Enable                                */
00069 #define LL_FMAC_CR_RIEN                    FMAC_CR_RIEN    /*!< Read Interrupt Enable                                 */
00070 /**
00071   * @}
00072   */
00073 
00074 /** @defgroup FMAC_LL_EC_WM FMAC watermarks
00075   * @brief    Watermark defines that can be used for buffer full (input) or buffer empty (output)
00076   * @{
00077   */
00078 #define LL_FMAC_WM_0_THRESHOLD_1           0x00000000U /*!< Buffer full/empty flag set if there
00079                                                             is less than 1 free/unread space.                         */
00080 #define LL_FMAC_WM_1_THRESHOLD_2           0x01000000U /*!< Buffer full/empty flag set if there
00081                                                             are less than 2 free/unread spaces.                       */
00082 #define LL_FMAC_WM_2_THRESHOLD_4           0x02000000U /*!< Buffer full/empty flag set if there
00083                                                             are less than 4 free/unread spaces.                       */
00084 #define LL_FMAC_WM_3_THRESHOLD_8           0x03000000U /*!< Buffer full/empty flag set if there
00085                                                             are less than 8 free/empty spaces.                        */
00086 /**
00087   * @}
00088   */
00089 
00090 /** @defgroup FMAC_LL_EC_FUNC FMAC functions
00091   * @{
00092   */
00093 #define LL_FMAC_FUNC_LOAD_X1               (FMAC_PARAM_FUNC_0)                        /*!< Load X1 buffer             */
00094 #define LL_FMAC_FUNC_LOAD_X2               (FMAC_PARAM_FUNC_1)                        /*!< Load X2 buffer             */
00095 #define LL_FMAC_FUNC_LOAD_Y                (FMAC_PARAM_FUNC_1 | FMAC_PARAM_FUNC_0)    /*!< Load Y buffer              */
00096 #define LL_FMAC_FUNC_CONVO_FIR             (FMAC_PARAM_FUNC_3)                        /*!< Convolution (FIR filter)   */
00097 #define LL_FMAC_FUNC_IIR_DIRECT_FORM_1     (FMAC_PARAM_FUNC_3 | FMAC_PARAM_FUNC_0)    /*!< IIR filter (direct form 1) */
00098 /**
00099   * @}
00100   */
00101 
00102 /** @defgroup FMAC_LL_EC_PROCESSING FMAC processing
00103   * @{
00104   */
00105 #define LL_FMAC_PROCESSING_STOP            0x00U /*!< Stop FMAC Processing                                            */
00106 #define LL_FMAC_PROCESSING_START           0x01U /*!< Start FMAC Processing                                           */
00107 /**
00108   * @}
00109   */
00110 
00111 /**
00112   * @}
00113   */
00114 
00115 /* External variables --------------------------------------------------------*/
00116 /* Exported macros -----------------------------------------------------------*/
00117 /** @defgroup FMAC_LL_Exported_Macros FMAC Exported Macros
00118   * @{
00119   */
00120 
00121 /** @defgroup FMAC_LL_EM_WRITE_READ Common Write and read registers Macros
00122   * @{
00123   */
00124 
00125 /**
00126   * @brief  Write a value in FMAC register
00127   * @param  __INSTANCE__ FMAC Instance
00128   * @param  __REG__ Register to be written
00129   * @param  __VALUE__ Value to be written in the register
00130   * @retval None
00131   */
00132 #define LL_FMAC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
00133 
00134 /**
00135   * @brief  Read a value in FMAC register
00136   * @param  __INSTANCE__ FMAC Instance
00137   * @param  __REG__ Register to be read
00138   * @retval Register value
00139   */
00140 #define LL_FMAC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
00141 /**
00142   * @}
00143   */
00144 
00145 /**
00146   * @}
00147   */
00148 
00149 /* Exported functions --------------------------------------------------------*/
00150 /** @defgroup FMAC_LL_Exported_Functions FMAC Exported Functions
00151   * @{
00152   */
00153 
00154 /** @defgroup FMAC_LL_EF_Configuration FMAC Configuration functions
00155   * @{
00156   */
00157 
00158 /**
00159   * @brief  Configure X1 full watermark.
00160   * @rmtoll X1BUFCFG     FULL_WM       LL_FMAC_SetX1FullWatermark
00161   * @param  FMACx FMAC instance
00162   * @param  Watermark This parameter can be one of the following values:
00163   *         @arg @ref LL_FMAC_WM_0_THRESHOLD_1
00164   *         @arg @ref LL_FMAC_WM_1_THRESHOLD_2
00165   *         @arg @ref LL_FMAC_WM_2_THRESHOLD_4
00166   *         @arg @ref LL_FMAC_WM_3_THRESHOLD_8
00167   * @retval None
00168   */
00169 __STATIC_INLINE void LL_FMAC_SetX1FullWatermark(FMAC_TypeDef *FMACx, uint32_t Watermark)
00170 {
00171   MODIFY_REG(FMACx->X1BUFCFG, FMAC_X1BUFCFG_FULL_WM, Watermark);
00172 }
00173 
00174 /**
00175   * @brief  Return X1 full watermark.
00176   * @rmtoll X1BUFCFG     FULL_WM       LL_FMAC_GetX1FullWatermark
00177   * @param  FMACx FMAC instance
00178   * @retval uint32_t Returned value can be one of the following values:
00179   *         @arg @ref LL_FMAC_WM_0_THRESHOLD_1
00180   *         @arg @ref LL_FMAC_WM_1_THRESHOLD_2
00181   *         @arg @ref LL_FMAC_WM_2_THRESHOLD_4
00182   *         @arg @ref LL_FMAC_WM_3_THRESHOLD_8
00183   */
00184 __STATIC_INLINE uint32_t LL_FMAC_GetX1FullWatermark(const FMAC_TypeDef *FMACx)
00185 {
00186   return (uint32_t)(READ_BIT(FMACx->X1BUFCFG, FMAC_X1BUFCFG_FULL_WM));
00187 }
00188 
00189 /**
00190   * @brief  Configure X1 buffer size.
00191   * @rmtoll X1BUFCFG     X1_BUF_SIZE   LL_FMAC_SetX1BufferSize
00192   * @param  FMACx FMAC instance
00193   * @param  BufferSize Number of 16-bit words allocated to the input buffer (including the optional "headroom").
00194   *                    This parameter must be a number between Min_Data=0x01 and Max_Data=0xFF.
00195   * @retval None
00196   */