STM32H735xx HAL User Manual
stm32h7xx_ll_cordic.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32h7xx_ll_cordic.h
00004   * @author  MCD Application Team
00005   * @brief   Header file of CORDIC LL module.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * Copyright (c) 2017 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 STM32H7xx_LL_CORDIC_H
00021 #define STM32H7xx_LL_CORDIC_H
00022 
00023 #ifdef __cplusplus
00024 extern "C" {
00025 #endif
00026 
00027 /* Includes ------------------------------------------------------------------*/
00028 #include "stm32h7xx.h"
00029 
00030 /** @addtogroup STM32H7xx_LL_Driver
00031   * @{
00032   */
00033 
00034 #if defined(CORDIC)
00035 
00036 /** @defgroup CORDIC_LL CORDIC
00037   * @{
00038   */
00039 
00040 /* Private variables ---------------------------------------------------------*/
00041 
00042 /* Private constants ---------------------------------------------------------*/
00043 
00044 /* Private macros ------------------------------------------------------------*/
00045 
00046 /* Exported types ------------------------------------------------------------*/
00047 
00048 /* Exported constants --------------------------------------------------------*/
00049 /** @defgroup CORDIC_LL_Exported_Constants CORDIC Exported Constants
00050   * @{
00051   */
00052 
00053 /** @defgroup CORDIC_LL_EC_GET_FLAG Get Flags Defines
00054   * @brief    Flags defines which can be used with LL_CORDIC_ReadReg function.
00055   * @{
00056   */
00057 #define LL_CORDIC_FLAG_RRDY                CORDIC_CSR_RRDY
00058 /**
00059   * @}
00060   */
00061 
00062 /** @defgroup CORDIC_LL_EC_IT IT Defines
00063   * @brief    IT defines which can be used with LL_CORDIC_ReadReg and LL_CORDIC_WriteReg functions.
00064   * @{
00065   */
00066 #define LL_CORDIC_IT_IEN                   CORDIC_CSR_IEN            /*!< Result Ready interrupt enable */
00067 /**
00068   * @}
00069   */
00070 
00071 /** @defgroup CORDIC_LL_EC_FUNCTION FUNCTION
00072   * @{
00073   */
00074 #define LL_CORDIC_FUNCTION_COSINE          (0x00000000U)                                                          /*!< Cosine */
00075 #define LL_CORDIC_FUNCTION_SINE            ((uint32_t)(CORDIC_CSR_FUNC_0))                                        /*!< Sine */
00076 #define LL_CORDIC_FUNCTION_PHASE           ((uint32_t)(CORDIC_CSR_FUNC_1))                                        /*!< Phase */
00077 #define LL_CORDIC_FUNCTION_MODULUS         ((uint32_t)(CORDIC_CSR_FUNC_1 | CORDIC_CSR_FUNC_0))                    /*!< Modulus */
00078 #define LL_CORDIC_FUNCTION_ARCTANGENT      ((uint32_t)(CORDIC_CSR_FUNC_2))                                        /*!< Arctangent */
00079 #define LL_CORDIC_FUNCTION_HCOSINE         ((uint32_t)(CORDIC_CSR_FUNC_2 | CORDIC_CSR_FUNC_0))                    /*!< Hyperbolic Cosine */
00080 #define LL_CORDIC_FUNCTION_HSINE           ((uint32_t)(CORDIC_CSR_FUNC_2 | CORDIC_CSR_FUNC_1))                    /*!< Hyperbolic Sine */
00081 #define LL_CORDIC_FUNCTION_HARCTANGENT     ((uint32_t)(CORDIC_CSR_FUNC_2 | CORDIC_CSR_FUNC_1 | CORDIC_CSR_FUNC_0))/*!< Hyperbolic Arctangent */
00082 #define LL_CORDIC_FUNCTION_NATURALLOG      ((uint32_t)(CORDIC_CSR_FUNC_3))                                        /*!< Natural Logarithm */
00083 #define LL_CORDIC_FUNCTION_SQUAREROOT      ((uint32_t)(CORDIC_CSR_FUNC_3 | CORDIC_CSR_FUNC_0))                    /*!< Square Root */
00084 /**
00085   * @}
00086   */
00087 
00088 /** @defgroup CORDIC_LL_EC_PRECISION PRECISION
00089   * @{
00090   */
00091 #define LL_CORDIC_PRECISION_1CYCLE         ((uint32_t)(CORDIC_CSR_PRECISION_0))
00092 #define LL_CORDIC_PRECISION_2CYCLES        ((uint32_t)(CORDIC_CSR_PRECISION_1))
00093 #define LL_CORDIC_PRECISION_3CYCLES        ((uint32_t)(CORDIC_CSR_PRECISION_1 | CORDIC_CSR_PRECISION_0))
00094 #define LL_CORDIC_PRECISION_4CYCLES        ((uint32_t)(CORDIC_CSR_PRECISION_2))
00095 #define LL_CORDIC_PRECISION_5CYCLES        ((uint32_t)(CORDIC_CSR_PRECISION_2 | CORDIC_CSR_PRECISION_0))
00096 #define LL_CORDIC_PRECISION_6CYCLES        ((uint32_t)(CORDIC_CSR_PRECISION_2 | CORDIC_CSR_PRECISION_1))
00097 #define LL_CORDIC_PRECISION_7CYCLES        ((uint32_t)(CORDIC_CSR_PRECISION_2\
00098                                                        | CORDIC_CSR_PRECISION_1 | CORDIC_CSR_PRECISION_0))
00099 #define LL_CORDIC_PRECISION_8CYCLES        ((uint32_t)(CORDIC_CSR_PRECISION_3))
00100 #define LL_CORDIC_PRECISION_9CYCLES        ((uint32_t)(CORDIC_CSR_PRECISION_3 | CORDIC_CSR_PRECISION_0))
00101 #define LL_CORDIC_PRECISION_10CYCLES       ((uint32_t)(CORDIC_CSR_PRECISION_3 | CORDIC_CSR_PRECISION_1))
00102 #define LL_CORDIC_PRECISION_11CYCLES       ((uint32_t)(CORDIC_CSR_PRECISION_3\
00103                                                        | CORDIC_CSR_PRECISION_1 | CORDIC_CSR_PRECISION_0))
00104 #define LL_CORDIC_PRECISION_12CYCLES       ((uint32_t)(CORDIC_CSR_PRECISION_3 | CORDIC_CSR_PRECISION_2))
00105 #define LL_CORDIC_PRECISION_13CYCLES       ((uint32_t)(CORDIC_CSR_PRECISION_3\
00106                                                        | CORDIC_CSR_PRECISION_2 | CORDIC_CSR_PRECISION_0))
00107 #define LL_CORDIC_PRECISION_14CYCLES       ((uint32_t)(CORDIC_CSR_PRECISION_3\
00108                                                        | CORDIC_CSR_PRECISION_2 | CORDIC_CSR_PRECISION_1))
00109 #define LL_CORDIC_PRECISION_15CYCLES       ((uint32_t)(CORDIC_CSR_PRECISION_3\
00110                                                        | CORDIC_CSR_PRECISION_2 | CORDIC_CSR_PRECISION_1\
00111                                                        | CORDIC_CSR_PRECISION_0))
00112 /**
00113   * @}
00114   */
00115 
00116 /** @defgroup CORDIC_LL_EC_SCALE SCALE
00117   * @{
00118   */
00119 #define LL_CORDIC_SCALE_0                  (0x00000000U)
00120 #define LL_CORDIC_SCALE_1                  ((uint32_t)(CORDIC_CSR_SCALE_0))
00121 #define LL_CORDIC_SCALE_2                  ((uint32_t)(CORDIC_CSR_SCALE_1))
00122 #define LL_CORDIC_SCALE_3                  ((uint32_t)(CORDIC_CSR_SCALE_1 | CORDIC_CSR_SCALE_0))
00123 #define LL_CORDIC_SCALE_4                  ((uint32_t)(CORDIC_CSR_SCALE_2))
00124 #define LL_CORDIC_SCALE_5                  ((uint32_t)(CORDIC_CSR_SCALE_2 | CORDIC_CSR_SCALE_0))
00125 #define LL_CORDIC_SCALE_6                  ((uint32_t)(CORDIC_CSR_SCALE_2 | CORDIC_CSR_SCALE_1))
00126 #define LL_CORDIC_SCALE_7                  ((uint32_t)(CORDIC_CSR_SCALE_2 | CORDIC_CSR_SCALE_1 | CORDIC_CSR_SCALE_0))
00127 /**
00128   * @}
00129   */
00130 
00131 /** @defgroup CORDIC_LL_EC_NBWRITE NBWRITE
00132   * @{
00133   */
00134 #define LL_CORDIC_NBWRITE_1                (0x00000000U)             /*!< One 32-bits write containing either only one
00135                                                                           32-bit data input (Q1.31 format), or two
00136                                                                           16-bit data input (Q1.15 format) packed
00137                                                                           in one 32 bits Data */
00138 #define LL_CORDIC_NBWRITE_2                CORDIC_CSR_NARGS          /*!< Two 32-bit write containing two 32-bits data input
00139                                                                           (Q1.31 format) */
00140 /**
00141   * @}
00142   */
00143 
00144 /** @defgroup CORDIC_LL_EC_NBREAD NBREAD
00145   * @{
00146   */
00147 #define LL_CORDIC_NBREAD_1                 (0x00000000U)             /*!< One 32-bits read containing either only one
00148                                                                           32-bit data output (Q1.31 format), or two
00149                                                                           16-bit data output (Q1.15 format) packed
00150                                                                           in one 32 bits Data */
00151 #define LL_CORDIC_NBREAD_2                 CORDIC_CSR_NRES           /*!< Two 32-bit Data containing two 32-bits data output
00152                                                                           (Q1.31 format) */
00153 /**
00154   * @}
00155   */
00156 
00157 /** @defgroup CORDIC_LL_EC_INSIZE INSIZE
00158   * @{
00159   */
00160 #define LL_CORDIC_INSIZE_32BITS            (0x00000000U)             /*!< 32 bits input data size (Q1.31 format) */
00161 #define LL_CORDIC_INSIZE_16BITS            CORDIC_CSR_ARGSIZE        /*!< 16 bits input data size (Q1.15 format) */
00162 /**
00163   * @}
00164   */
00165 
00166 /** @defgroup CORDIC_LL_EC_OUTSIZE OUTSIZE
00167   * @{
00168   */
00169 #define LL_CORDIC_OUTSIZE_32BITS           (0x00000000U)             /*!< 32 bits output data size (Q1.31 format) */
00170 #define LL_CORDIC_OUTSIZE_16BITS           CORDIC_CSR_RESSIZE        /*!< 16 bits output data size (Q1.15 format) */
00171 /**
00172   * @}
00173   */
00174 
00175 /** @defgroup CORDIC_LL_EC_DMA_REG_DATA DMA register data
00176   * @{
00177   */
00178 #define LL_CORDIC_DMA_REG_DATA_IN          (0x00000000U)             /*!< Get address of input data register */
00179 #define LL_CORDIC_DMA_REG_DATA_OUT         (0x00000001U)             /*!< Get address of output data register */
00180 /**
00181   * @}
00182   */
00183 
00184 /**
00185   * @}
00186   */
00187 
00188 /* Exported macro ------------------------------------------------------------*/
00189 /** @defgroup CORDIC_LL_Exported_Macros CORDIC Exported Macros
00190   * @{
00191   */
00192 
00193 /** @defgroup CORDIC_LL_EM_WRITE_READ Common Write and read registers Macros
00194   * @{
00195   */
00196 
00197 /**
00198   * @brief  Write a value in CORDIC register.
00199   * @param  __INSTANCE__ CORDIC Instance
00200   * @param  __REG__ Register to be written
00201   * @param  __VALUE__ Value to be written in the register
00202   * @retval None
00203   */
00204 #define LL_CORDIC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
00205 
00206 /**
00207   * @brief  Read a value in CORDIC register.
00208   * @param  __INSTANCE__ CORDIC Instance
00209   * @param  __REG__ Register to be read
00210   * @retval Register value
00211   */
00212 #define LL_CORDIC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
00213 /**
00214   * @}
00215   */
00216 
00217 /**
00218   * @}
00219   */
00220 
00221 
00222 /* Exported functions --------------------------------------------------------*/
00223 
00224 /** @defgroup CORDIC_LL_Exported_Functions CORDIC Exported Functions
00225   * @{
00226   */
00227 
00228 /** @defgroup CORDIC_LL_EF_Configuration CORDIC Configuration functions
00229   * @{
00230   */
00231 
00232 /**
00233   * @brief  Configure the CORDIC processing.
00234   * @note   This function set all parameters of CORDIC processing.
00235   *         These parameters can also be set individually using
00236   *         dedicated functions:
00237   *         - @ref LL_CORDIC_SetFunction()
00238   *         - @ref LL_CORDIC_SetPrecision()
00239   *         - @ref LL_CORDIC_SetScale()
00240   *         - @ref LL_CORDIC_SetNbWrite()
00241   *         - @ref LL_CORDIC_SetNbRead()
00242   *         - @ref LL_CORDIC_SetInSize()
00243   *         - @ref LL_CORDIC_SetOutSize()
00244   * @rmtoll CSR          FUNC          LL_CORDIC_Configure\n
00245   *         CSR          PRECISION     LL_CORDIC_Configure\n
00246   *         CSR          SCALE         LL_CORDIC_Configure\n
00247   *         CSR          NARGS         LL_CORDIC_Configure\n
00248   *         CSR          NRES          LL_CORDIC_Configure\n
00249   *         CSR          ARGSIZE       LL_CORDIC_Configure\n
00250   *         CSR          RESIZE        LL_CORDIC_Configure
00251   * @param  CORDICx CORDIC instance
00252   * @param  Function parameter can be one of the following values:
00253   *         @arg @ref LL_CORDIC_FUNCTION_COSINE
00254   *         @arg @ref LL_CORDIC_FUNCTION_SINE
00255   *         @arg @ref LL_CORDIC_FUNCTION_PHASE
00256   *         @arg @ref LL_CORDIC_FUNCTION_MODULUS
00257   *         @arg @ref LL_CORDIC_FUNCTION_ARCTANGENT
00258   *         @arg @ref LL_CORDIC_FUNCTION_HCOSINE
00259   *         @arg @ref LL_CORDIC_FUNCTION_HSINE
00260   *         @arg @ref LL_CORDIC_FUNCTION_HARCTANGENT
00261   *         @arg @ref LL_CORDIC_FUNCTION_NATURALLOG
00262   *         @arg @ref LL_CORDIC_FUNCTION_SQUAREROOT
00263   * @param  Precision parameter can be one of the following values:
00264   *         @arg @ref LL_CORDIC_PRECISION_1CYCLE
00265   *         @arg @ref LL_CORDIC_PRECISION_2CYCLES
00266   *         @arg @ref LL_CORDIC_PRECISION_3CYCLES
00267   *         @arg @ref LL_CORDIC_PRECISION_4CYCLES
00268   *         @arg @ref LL_CORDIC_PRECISION_5CYCLES
00269   *         @arg @ref LL_CORDIC_PRECISION_6CYCLES
00270   *         @arg @ref LL_CORDIC_PRECISION_7CYCLES
00271   *         @arg @ref LL_CORDIC_PRECISION_8CYCLES
00272   *         @arg @ref LL_CORDIC_PRECISION_9CYCLES
00273   *         @arg @ref LL_CORDIC_PRECISION_10CYCLES
00274   *         @arg @ref LL_CORDIC_PRECISION_11CYCLES
00275   *         @arg @ref LL_CORDIC_PRECISION_12CYCLES
00276   *         @arg @ref LL_CORDIC_PRECISION_13CYCLES
00277   *         @arg @ref LL_CORDIC_PRECISION_14CYCLES
00278   *         @arg @ref LL_CORDIC_PRECISION_15CYCLES
00279   * @param  Scale parameter can be one of the following values:
00280   *         @arg @ref LL_CORDIC_SCALE_0
00281   *         @arg @ref LL_CORDIC_SCALE_1
00282   *         @arg @ref LL_CORDIC_SCALE_2
00283   *         @arg @ref LL_CORDIC_SCALE_3
00284   *         @arg @ref LL_CORDIC_SCALE_4
00285   *         @arg @ref LL_CORDIC_SCALE_5
00286   *         @arg @ref LL_CORDIC_SCALE_6
00287   *         @arg @ref LL_CORDIC_SCALE_7
00288   * @param  NbWrite parameter can be one of the following values:
00289   *         @arg @ref LL_CORDIC_NBWRITE_1
00290   *         @arg @ref LL_CORDIC_NBWRITE_2
00291   * @param  NbRead parameter can be one of the following values:
00292   *         @arg @ref LL_CORDIC_NBREAD_1
00293   *         @arg @ref LL_CORDIC_NBREAD_2
00294   * @param  InSize parameter can be one of the following values:
00295   *         @arg @ref LL_CORDIC_INSIZE_32BITS
00296   *         @arg @ref LL_CORDIC_INSIZE_16BITS
00297   * @param  OutSize parameter can be one of the following values:
00298   *         @arg @ref LL_CORDIC_OUTSIZE_32BITS
00299   *         @arg @ref LL_CORDIC_OUTSIZE_16BITS
00300   * @retval None
00301   */
00302 __STATIC_INLINE void LL_CORDIC_Config(CORDIC_TypeDef *CORDICx, uint32_t Function, uint32_t Precision, uint32_t Scale,
00303                                       uint32_t NbWrite, uint32_t NbRead, uint32_t InSize, uint32_t OutSize)
00304 {
00305   MODIFY_REG(CORDICx->CSR,
00306              CORDIC_CSR_FUNC | CORDIC_CSR_PRECISION | CORDIC_CSR_SCALE |
00307              CORDIC_CSR_NARGS | CORDIC_CSR_NRES | CORDIC_CSR_ARGSIZE | CORDIC_CSR_RESSIZE,
00308              Function | Precision | Scale |
00309              NbWrite | NbRead | InSize | OutSize);
00310 }
00311 
00312 /**
00313   * @brief  Configure function.
00314   * @rmtoll CSR          FUNC          LL_CORDIC_SetFunction
00315   * @param  CORDICx CORDIC Instance
00316   * @param  Function parameter can be one of the following values:
00317   *         @arg @ref LL_CORDIC_FUNCTION_COSINE
00318   *         @arg @ref LL_CORDIC_FUNCTION_SINE
00319   *         @arg @ref LL_CORDIC_FUNCTION_PHASE
00320   *         @arg @ref LL_CORDIC_FUNCTION_MODULUS
00321   *         @arg @ref LL_CORDIC_FUNCTION_ARCTANGENT
00322   *         @arg @ref LL_CORDIC_FUNCTION_HCOSINE
00323   *         @arg @ref LL_CORDIC_FUNCTION_HSINE
00324   *         @arg @ref LL_CORDIC_FUNCTION_HARCTANGENT
00325   *         @arg @ref LL_CORDIC_FUNCTION_NATURALLOG
00326   *         @arg @ref LL_CORDIC_FUNCTION_SQUAREROOT
00327   * @retval None
00328   */
00329 __STATIC_INLINE void LL_CORDIC_SetFunction(CORDIC_TypeDef *CORDICx, uint32_t Function)
00330 {
00331   MODIFY_REG(CORDICx->CSR, CORDIC_CSR_FUNC, Function);
00332 }
00333 
00334 /**
00335   * @brief  Return function.
00336   * @rmtoll CSR          FUNC          LL_CORDIC_GetFunction
00337   * @param  CORDICx CORDIC Instance
00338   * @retval Returned value can be one of the following values:
00339   *         @arg @ref LL_CORDIC_FUNCTION_COSINE
00340   *         @arg @ref LL_CORDIC_FUNCTION_SINE
00341   *         @arg @ref LL_CORDIC_FUNCTION_PHASE
00342   *         @arg @ref LL_CORDIC_FUNCTION_MODULUS
00343   *         @arg @ref LL_CORDIC_FUNCTION_ARCTANGENT
00344   *         @arg @ref LL_CORDIC_FUNCTION_HCOSINE
00345   *         @arg @ref LL_CORDIC_FUNCTION_HSINE
00346   *         @arg @ref LL_CORDIC_FUNCTION_HARCTANGENT
00347   *         @arg @ref LL_CORDIC_FUNCTION_NATURALLOG
00348   *         @arg @ref LL_CORDIC_FUNCTION_SQUAREROOT
00349   */
00350 __STATIC_INLINE uint32_t LL_CORDIC_GetFunction(CORDIC_TypeDef *CORDICx)
00351 {
00352   return (uint32_t)(READ_BIT(CORDICx->CSR, CORDIC_CSR_FUNC));
00353 }
00354 
00355 /**
00356   * @brief  Configure precision in cycles number.
00357   * @rmtoll CSR          PRECISION     LL_CORDIC_SetPrecision
00358   * @param  CORDICx CORDIC Instance
00359   * @param  Precision parameter can be one of the following values:
00360   *         @arg @ref LL_CORDIC_PRECISION_1CYCLE
00361   *         @arg @ref LL_CORDIC_PRECISION_2CYCLES
00362   *         @arg @ref LL_CORDIC_PRECISION_3CYCLES
00363   *         @arg @ref LL_CORDIC_PRECISION_4CYCLES
00364   *         @arg @ref LL_CORDIC_PRECISION_5CYCLES
00365   *         @arg @ref LL_CORDIC_PRECISION_6CYCLES
00366   *         @arg @ref LL_CORDIC_PRECISION_7CYCLES
00367   *         @arg @ref LL_CORDIC_PRECISION_8CYCLES
00368   *         @arg @ref LL_CORDIC_PRECISION_9CYCLES
00369   *         @arg @ref LL_CORDIC_PRECISION_10CYCLES
00370   *         @arg @ref LL_CORDIC_PRECISION_11CYCLES
00371   *         @arg @ref LL_CORDIC_PRECISION_12CYCLES
00372   *         @arg @ref LL_CORDIC_PRECISION_13CYCLES
00373   *         @arg @ref LL_CORDIC_PRECISION_14CYCLES
00374   *         @arg @ref LL_CORDIC_PRECISION_15CYCLES
00375   * @retval None
00376   */
00377 __STATIC_INLINE void LL_CORDIC_SetPrecision(CORDIC_TypeDef *CORDICx, uint32_t Precision)
00378 {
00379   MODIFY_REG(CORDICx->CSR, CORDIC_CSR_PRECISION, Precision);
00380 }
00381 
00382 /**
00383   * @brief  Return precision in cycles number.
00384   * @rmtoll CSR          PRECISION     LL_CORDIC_GetPrecision
00385   * @param  CORDICx CORDIC Instance
00386   * @retval Returned value can be one of the following values:
00387   *         @arg @ref LL_CORDIC_PRECISION_1CYCLE
00388   *         @arg @ref LL_CORDIC_PRECISION_2CYCLES
00389   *         @arg @ref LL_CORDIC_PRECISION_3CYCLES
00390   *         @arg @ref LL_CORDIC_PRECISION_4CYCLES
00391   *         @arg @ref LL_CORDIC_PRECISION_5CYCLES
00392   *         @arg @ref LL_CORDIC_PRECISION_6CYCLES
00393   *         @arg @ref LL_CORDIC_PRECISION_7CYCLES
00394   *         @arg @ref LL_CORDIC_PRECISION_8CYCLES
00395   *         @arg @ref LL_CORDIC_PRECISION_9CYCLES
00396   *         @arg @ref LL_CORDIC_PRECISION_10CYCLES
00397   *         @arg @ref LL_CORDIC_PRECISION_11CYCLES
00398   *         @arg @ref LL_CORDIC_PRECISION_12CYCLES
00399   *         @arg @ref LL_CORDIC_PRECISION_13CYCLES
00400   *         @arg @ref LL_CORDIC_PRECISION_14CYCLES
00401   *         @arg @ref LL_CORDIC_PRECISION_15CYCLES
00402   */
00403 __STATIC_INLINE uint32_t LL_CORDIC_GetPrecision(CORDIC_TypeDef *CORDICx)
00404 {
00405   return (uint32_t)(READ_BIT(CORDICx->CSR, CORDIC_CSR_PRECISION));
00406 }
00407 
00408 /**
00409   * @brief  Configure scaling factor.
00410   * @rmtoll CSR          SCALE         LL_CORDIC_SetScale
00411   * @param  CORDICx CORDIC Instance
00412   * @param  Scale parameter can be one of the following values:
00413   *         @arg @ref LL_CORDIC_SCALE_0
00414   *         @arg @ref LL_CORDIC_SCALE_1
00415   *         @arg @ref LL_CORDIC_SCALE_2
00416   *         @arg @ref LL_CORDIC_SCALE_3
00417   *         @arg @ref LL_CORDIC_SCALE_4
00418   *         @arg @ref LL_CORDIC_SCALE_5
00419   *         @arg @ref LL_CORDIC_SCALE_6
00420   *         @arg @ref LL_CORDIC_SCALE_7
00421   * @retval None
00422   */
00423 __STATIC_INLINE void LL_CORDIC_SetScale(CORDIC_TypeDef *CORDICx, uint32_t Scale)
00424 {
00425   MODIFY_REG(CORDICx->CSR, CORDIC_CSR_SCALE, Scale);
00426 }
00427 
00428 /**
00429   * @brief  Return scaling factor.
00430   * @rmtoll CSR          SCALE         LL_CORDIC_GetScale
00431   * @param  CORDICx CORDIC Instance
00432   * @retval Returned value can be one of the following values:
00433   *         @arg @ref LL_CORDIC_SCALE_0
00434   *         @arg @ref LL_CORDIC_SCALE_1
00435   *         @arg @ref LL_CORDIC_SCALE_2
00436   *         @arg @ref LL_CORDIC_SCALE_3
00437   *         @arg @ref LL_CORDIC_SCALE_4
00438   *         @arg @ref LL_CORDIC_SCALE_5
00439   *         @arg @ref LL_CORDIC_SCALE_6
00440   *         @arg @ref LL_CORDIC_SCALE_7
00441   */
00442 __STATIC_INLINE uint32_t LL_CORDIC_GetScale(CORDIC_TypeDef *CORDICx)
00443 {
00444   return (uint32_t)(READ_BIT(CORDICx->CSR, CORDIC_CSR_SCALE));
00445 }
00446 
00447 /**
00448   * @brief  Configure number of 32-bit write expected for one calculation.
00449   * @rmtoll CSR          NARGS         LL_CORDIC_SetNbWrite
00450   * @param  CORDICx CORDIC Instance
00451   * @param  NbWrite parameter can be one of the following values:
00452   *         @arg @ref LL_CORDIC_NBWRITE_1
00453   *         @arg @ref LL_CORDIC_NBWRITE_2
00454   * @retval None
00455   */
00456 __STATIC_INLINE void LL_CORDIC_SetNbWrite(CORDIC_TypeDef *CORDICx, uint32_t NbWrite)
00457 {
00458   MODIFY_REG(CORDICx->CSR, CORDIC_CSR_NARGS, NbWrite);
00459 }
00460 
00461 /**
00462   * @brief  Return number of 32-bit write expected for one calculation.
00463   * @rmtoll CSR          NARGS         LL_CORDIC_GetNbWrite
00464   * @param  CORDICx CORDIC Instance
00465   * @retval Returned value can be one of the following values:
00466   *         @arg @ref LL_CORDIC_NBWRITE_1
00467   *         @arg @ref LL_CORDIC_NBWRITE_2
00468   */
00469 __STATIC_INLINE uint32_t LL_CORDIC_GetNbWrite(CORDIC_TypeDef *CORDICx)
00470 {
00471   return (uint32_t)(READ_BIT(CORDICx->CSR, CORDIC_CSR_NARGS));
00472 }
00473 
00474 /**
00475   * @brief  Configure number of 32-bit read expected after one calculation.
00476   * @rmtoll CSR          NRES          LL_CORDIC_SetNbRead
00477   * @param  CORDICx CORDIC Instance
00478   * @param  NbRead parameter can be one of the following values:
00479   *         @arg @ref LL_CORDIC_NBREAD_1
00480   *         @arg @ref LL_CORDIC_NBREAD_2
00481   * @retval None
00482   */
00483 __STATIC_INLINE void LL_CORDIC_SetNbRead(CORDIC_TypeDef *CORDICx, uint32_t NbRead)
00484 {
00485   MODIFY_REG(CORDICx->CSR, CORDIC_CSR_NRES, NbRead);
00486 }
00487 
00488 /**
00489   * @brief  Return number of 32-bit read expected after one calculation.
00490   * @rmtoll CSR          NRES          LL_CORDIC_GetNbRead
00491   * @param  CORDICx CORDIC Instance
00492   * @retval Returned value can be one of the following values:
00493   *         @arg @ref LL_CORDIC_NBREAD_1
00494   *         @arg @ref LL_CORDIC_NBREAD_2
00495   */
00496 __STATIC_INLINE uint32_t LL_CORDIC_GetNbRead(CORDIC_TypeDef *CORDICx)
00497 {
00498   return (uint32_t)(READ_BIT(CORDICx->CSR, CORDIC_CSR_NRES));
00499 }
00500 
00501 /**
00502   * @brief  Configure width of input data.
00503   * @rmtoll CSR          ARGSIZE       LL_CORDIC_SetInSize
00504   * @param  CORDICx CORDIC Instance
00505   * @param  InSize parameter can be one of the following values:
00506   *         @arg @ref LL_CORDIC_INSIZE_32BITS
00507   *         @arg @ref LL_CORDIC_INSIZE_16BITS
00508   * @retval None
00509   */
00510 __STATIC_INLINE void LL_CORDIC_SetInSize(CORDIC_TypeDef *CORDICx, uint32_t InSize)
00511 {
00512   MODIFY_REG(CORDICx->CSR, CORDIC_CSR_ARGSIZE, InSize);
00513 }
00514 
00515 /**
00516   * @brief  Return width of input data.
00517   * @rmtoll CSR          ARGSIZE       LL_CORDIC_GetInSize
00518   * @param  CORDICx CORDIC Instance
00519   * @retval Returned value can be one of the following values:
00520   *         @arg @ref LL_CORDIC_INSIZE_32BITS
00521   *         @arg @ref LL_CORDIC_INSIZE_16BITS
00522   */
00523 __STATIC_INLINE uint32_t LL_CORDIC_GetInSize(CORDIC_TypeDef *CORDICx)
00524 {
00525   return (uint32_t)(READ_BIT(CORDICx->CSR, CORDIC_CSR_ARGSIZE));
00526 }
00527 
00528 /**
00529   * @brief  Configure width of output data.
00530   * @rmtoll CSR          RESIZE       LL_CORDIC_SetOutSize
00531   * @param  CORDICx CORDIC Instance
00532   * @param  OutSize parameter can be one of the following values:
00533   *         @arg @ref LL_CORDIC_OUTSIZE_32BITS
00534   *         @arg @ref LL_CORDIC_OUTSIZE_16BITS
00535   * @retval None
00536   */
00537 __STATIC_INLINE void LL_CORDIC_SetOutSize(CORDIC_TypeDef *CORDICx, uint32_t OutSize)
00538 {
00539   MODIFY_REG(CORDICx->CSR, CORDIC_CSR_RESSIZE, OutSize);
00540 }
00541 
00542 /**
00543   * @brief  Return width of output data.
00544   * @rmtoll CSR          RESIZE       LL_CORDIC_GetOutSize
00545   * @param  CORDICx CORDIC Instance
00546   * @retval Returned value can be one of the following values:
00547   *         @arg @ref LL_CORDIC_OUTSIZE_32BITS
00548   *         @arg @ref LL_CORDIC_OUTSIZE_16BITS
00549   */
00550 __STATIC_INLINE uint32_t LL_CORDIC_GetOutSize(CORDIC_TypeDef *CORDICx)
00551 {
00552   return (uint32_t)(READ_BIT(CORDICx->CSR, CORDIC_CSR_RESSIZE));
00553 }
00554 
00555 /**
00556   * @}
00557   */
00558 
00559 /** @defgroup CORDIC_LL_EF_IT_Management IT_Management
00560   * @{
00561   */
00562 
00563 /**
00564   * @brief  Enable CORDIC result ready interrupt
00565   * @rmtoll CSR          IEN           LL_CORDIC_EnableIT
00566   * @param  CORDICx CORDIC Instance
00567   * @retval None
00568   */
00569 __STATIC_INLINE void LL_CORDIC_EnableIT(CORDIC_TypeDef *CORDICx)
00570 {
00571   SET_BIT(CORDICx->CSR, CORDIC_CSR_IEN);
00572 }
00573 
00574 /**
00575   * @brief  Disable CORDIC result ready interrupt
00576   * @rmtoll CSR          IEN           LL_CORDIC_DisableIT
00577   * @param  CORDICx CORDIC Instance
00578   * @retval None
00579   */
00580 __STATIC_INLINE void LL_CORDIC_DisableIT(CORDIC_TypeDef *CORDICx)
00581 {
00582   CLEAR_BIT(CORDICx->CSR, CORDIC_CSR_IEN);
00583 }
00584 
00585 /**
00586   * @brief  Check CORDIC result ready interrupt state.
00587   * @rmtoll CSR          IEN           LL_CORDIC_IsEnabledIT
00588   * @param  CORDICx CORDIC Instance
00589   * @retval State of bit (1 or 0).
00590   */
00591 __STATIC_INLINE uint32_t LL_CORDIC_IsEnabledIT(CORDIC_TypeDef *CORDICx)
00592 {
00593   return ((READ_BIT(CORDICx->CSR, CORDIC_CSR_IEN) == (CORDIC_CSR_IEN)) ? 1U : 0U);
00594 }
00595 
00596 /**
00597   * @}
00598   */
00599 
00600 /** @defgroup CORDIC_LL_EF_DMA_Management DMA_Management
00601   * @{
00602   */
00603 
00604 /**
00605   * @brief  Enable CORDIC DMA read channel request.
00606   * @rmtoll CSR          DMAREN        LL_CORDIC_EnableDMAReq_RD
00607   * @param  CORDICx CORDIC Instance
00608   * @retval None
00609   */
00610 __STATIC_INLINE void LL_CORDIC_EnableDMAReq_RD(CORDIC_TypeDef *CORDICx)
00611 {
00612   SET_BIT(CORDICx->CSR, CORDIC_CSR_DMAREN);
00613 }
00614 
00615 /**
00616   * @brief  Disable CORDIC DMA read channel request.
00617   * @rmtoll CSR          DMAREN        LL_CORDIC_DisableDMAReq_RD
00618   * @param  CORDICx CORDIC Instance
00619   * @retval None
00620   */
00621 __STATIC_INLINE void LL_CORDIC_DisableDMAReq_RD(CORDIC_TypeDef *CORDICx)
00622 {
00623   CLEAR_BIT(CORDICx->CSR, CORDIC_CSR_DMAREN);
00624 }
00625 
00626 /**
00627   * @brief  Check CORDIC DMA read channel request state.
00628   * @rmtoll CSR          DMAREN        LL_CORDIC_IsEnabledDMAReq_RD
00629   * @param  CORDICx CORDIC Instance
00630   * @retval State of bit (1 or 0).
00631   */
00632 __STATIC_INLINE uint32_t LL_CORDIC_IsEnabledDMAReq_RD(CORDIC_TypeDef *CORDICx)
00633 {
00634   return ((READ_BIT(CORDICx->CSR, CORDIC_CSR_DMAREN) == (CORDIC_CSR_DMAREN)) ? 1U : 0U);
00635 }
00636 
00637 /**
00638   * @brief  Enable CORDIC DMA write channel request.
00639   * @rmtoll CSR          DMAWEN        LL_CORDIC_EnableDMAReq_WR
00640   * @param  CORDICx CORDIC Instance
00641   * @retval None
00642   */
00643 __STATIC_INLINE void LL_CORDIC_EnableDMAReq_WR(CORDIC_TypeDef *CORDICx)
00644 {
00645   SET_BIT(CORDICx->CSR, CORDIC_CSR_DMAWEN);
00646 }
00647 
00648 /**
00649   * @brief  Disable CORDIC DMA write channel request.
00650   * @rmtoll CSR          DMAWEN        LL_CORDIC_DisableDMAReq_WR
00651   * @param  CORDICx CORDIC Instance
00652   * @retval None
00653   */
00654 __STATIC_INLINE void LL_CORDIC_DisableDMAReq_WR(CORDIC_TypeDef *CORDICx)
00655 {
00656   CLEAR_BIT(CORDICx->CSR, CORDIC_CSR_DMAWEN);
00657 }
00658 
00659 /**
00660   * @brief  Check CORDIC DMA write channel request state.
00661   * @rmtoll CSR          DMAWEN        LL_CORDIC_IsEnabledDMAReq_WR
00662   * @param  CORDICx CORDIC Instance
00663   * @retval State of bit (1 or 0).
00664   */
00665 __STATIC_INLINE uint32_t LL_CORDIC_IsEnabledDMAReq_WR(CORDIC_TypeDef *CORDICx)
00666 {
00667   return ((READ_BIT(CORDICx->CSR, CORDIC_CSR_DMAWEN) == (CORDIC_CSR_DMAWEN)) ? 1U : 0U);
00668 }
00669 
00670 /**
00671   * @brief  Get the CORDIC data register address used for DMA transfer.
00672   * @rmtoll RDATA        RES           LL_CORDIC_DMA_GetRegAddr\n
00673   * @rmtoll WDATA        ARG           LL_CORDIC_DMA_GetRegAddr
00674   * @param  CORDICx CORDIC Instance
00675   * @param  Direction parameter can be one of the following values:
00676   *         @arg @ref LL_CORDIC_DMA_REG_DATA_IN
00677   *         @arg @ref LL_CORDIC_DMA_REG_DATA_OUT
00678   * @retval Address of data register
00679   */
00680 __STATIC_INLINE uint32_t LL_CORDIC_DMA_GetRegAddr(CORDIC_TypeDef *CORDICx, uint32_t Direction)
00681 {
00682   uint32_t data_reg_addr;
00683 
00684   if (Direction == LL_CORDIC_DMA_REG_DATA_OUT)
00685   {
00686     /* return address of RDATA register */
00687     data_reg_addr = (uint32_t) &(CORDICx->RDATA);
00688   }
00689   else
00690   {
00691     /* return address of WDATA register */
00692     data_reg_addr = (uint32_t) &(CORDICx->WDATA);
00693   }
00694 
00695   return data_reg_addr;
00696 }
00697 
00698 /**
00699   * @}
00700   */
00701 
00702 /** @defgroup CORDIC_LL_EF_FLAG_Management FLAG_Management
00703   * @{
00704   */
00705 
00706 /**
00707   * @brief  Check CORDIC result ready flag state.
00708   * @rmtoll CSR          RRDY          LL_CORDIC_IsActiveFlag_RRDY
00709   * @param  CORDICx CORDIC Instance
00710   * @retval State of bit (1 or 0).
00711   */
00712 __STATIC_INLINE uint32_t LL_CORDIC_IsActiveFlag_RRDY(CORDIC_TypeDef *CORDICx)
00713 {
00714   return ((READ_BIT(CORDICx->CSR, CORDIC_CSR_RRDY) == (CORDIC_CSR_RRDY)) ? 1U : 0U);
00715 }
00716 
00717 /**
00718   * @}
00719   */
00720 
00721 /** @defgroup CORDIC_LL_EF_Data_Management Data_Management
00722   * @{
00723   */
00724 
00725 /**
00726   * @brief  Write 32-bit input data for the CORDIC processing.
00727   * @rmtoll WDATA        ARG           LL_CORDIC_WriteData
00728   * @param  CORDICx CORDIC Instance
00729   * @param  InData 0 .. 0xFFFFFFFF : 32-bit value to be provided as input data for CORDIC processing.
00730   * @retval None
00731   */
00732 __STATIC_INLINE void LL_CORDIC_WriteData(CORDIC_TypeDef *CORDICx, uint32_t InData)
00733 {
00734   WRITE_REG(CORDICx->WDATA, InData);
00735 }
00736 
00737 /**
00738   * @brief  Return 32-bit output data of CORDIC processing.
00739   * @rmtoll RDATA        RES           LL_CORDIC_ReadData
00740   * @param  CORDICx CORDIC Instance
00741   * @retval 32-bit output data of CORDIC processing.
00742   */
00743 __STATIC_INLINE uint32_t LL_CORDIC_ReadData(CORDIC_TypeDef *CORDICx)
00744 {
00745   return (uint32_t)(READ_REG(CORDICx->RDATA));
00746 }
00747 
00748 /**
00749   * @}
00750   */
00751 
00752 
00753 
00754 #if defined(USE_FULL_LL_DRIVER)
00755 /** @defgroup CORDIC_LL_EF_Init Initialization and de-initialization functions
00756   * @{
00757   */
00758 ErrorStatus LL_CORDIC_DeInit(CORDIC_TypeDef *CORDICx);
00759 
00760 /**
00761   * @}
00762   */
00763 #endif /* USE_FULL_LL_DRIVER */
00764 
00765 /**
00766   * @}
00767   */
00768 
00769 /**
00770   * @}
00771   */
00772 
00773 #endif /* defined(CORDIC) */
00774 
00775 /**
00776   * @}
00777   */
00778 
00779 #ifdef __cplusplus
00780 }
00781 #endif
00782 
00783 #endif /* STM32H7xx_LL_CORDIC_H */