Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:35

0001 /**
0002   ******************************************************************************
0003   * @file    stm32h7xx_hal_cordic.h
0004   * @author  MCD Application Team
0005   * @brief   This file contains all the functions prototypes for the CORDIC firmware
0006   *          library.
0007   ******************************************************************************
0008   * @attention
0009   *
0010   * Copyright (c) 2017 STMicroelectronics.
0011   * All rights reserved.
0012   *
0013   * This software is licensed under terms that can be found in the LICENSE file
0014   * in the root directory of this software component.
0015   * If no LICENSE file comes with this software, it is provided AS-IS.
0016   *
0017   ******************************************************************************
0018   */
0019 
0020 /* Define to prevent recursive inclusion -------------------------------------*/
0021 #ifndef STM32H7xx_HAL_CORDIC_H
0022 #define STM32H7xx_HAL_CORDIC_H
0023 
0024 #ifdef __cplusplus
0025 extern "C" {
0026 #endif
0027 
0028 /* Includes ------------------------------------------------------------------*/
0029 #include "stm32h7xx_hal_def.h"
0030 
0031 #if defined(CORDIC)
0032 /** @addtogroup STM32H7xx_HAL_Driver
0033   * @{
0034   */
0035 
0036 /** @addtogroup CORDIC
0037   * @{
0038   */
0039 
0040 /* Exported types ------------------------------------------------------------*/
0041 /** @defgroup CORDIC_Exported_Types CORDIC Exported Types
0042   * @ingroup RTEMSBSPsARMSTM32H7
0043   * @{
0044   */
0045 
0046 /**
0047   * @brief  CORDIC HAL State Structure definition
0048   */
0049 typedef enum
0050 {
0051   HAL_CORDIC_STATE_RESET     = 0x00U,  /*!< CORDIC not yet initialized or disabled */
0052   HAL_CORDIC_STATE_READY     = 0x01U,  /*!< CORDIC initialized and ready for use   */
0053   HAL_CORDIC_STATE_BUSY      = 0x02U,  /*!< CORDIC internal process is ongoing     */
0054   HAL_CORDIC_STATE_ERROR     = 0x03U   /*!< CORDIC error state                     */
0055 } HAL_CORDIC_StateTypeDef;
0056 
0057 /**
0058   * @brief  CORDIC Handle Structure definition
0059   */
0060 #if USE_HAL_CORDIC_REGISTER_CALLBACKS == 1
0061 typedef struct __CORDIC_HandleTypeDef
0062 #else
0063 typedef struct
0064 #endif /* USE_HAL_CORDIC_REGISTER_CALLBACKS */
0065 {
0066   CORDIC_TypeDef                *Instance;   /*!< Register base address */
0067 
0068   const int32_t                 *pInBuff;    /*!< Pointer to CORDIC input data buffer */
0069 
0070   int32_t                       *pOutBuff;   /*!< Pointer to CORDIC output data buffer */
0071 
0072   uint32_t                      NbCalcToOrder; /*!< Remaining number of calculation to order */
0073 
0074   uint32_t                      NbCalcToGet; /*!< Remaining number of calculation result to get */
0075 
0076   uint32_t                      DMADirection; /*!< Direction of CORDIC DMA transfers */
0077 
0078   DMA_HandleTypeDef             *hdmaIn;     /*!< CORDIC peripheral input data DMA handle parameters */
0079 
0080   DMA_HandleTypeDef             *hdmaOut;    /*!< CORDIC peripheral output data DMA handle parameters */
0081 
0082   HAL_LockTypeDef               Lock;        /*!< CORDIC locking object */
0083 
0084   __IO HAL_CORDIC_StateTypeDef  State;       /*!< CORDIC state */
0085 
0086   __IO uint32_t                 ErrorCode;   /*!< CORDIC peripheral error code
0087                                                   This parameter can be a value of @ref CORDIC_Error_Code */
0088 
0089 #if USE_HAL_CORDIC_REGISTER_CALLBACKS == 1
0090   void (* ErrorCallback)(struct __CORDIC_HandleTypeDef *hcordic);          /*!< CORDIC error callback */
0091   void (* CalculateCpltCallback)(struct __CORDIC_HandleTypeDef *hcordic);  /*!< CORDIC calculate complete callback */
0092 
0093   void (* MspInitCallback)(struct __CORDIC_HandleTypeDef *hcordic);        /*!< CORDIC Msp Init callback */
0094   void (* MspDeInitCallback)(struct __CORDIC_HandleTypeDef *hcordic);      /*!< CORDIC Msp DeInit callback */
0095 
0096 #endif /* (USE_HAL_CORDIC_REGISTER_CALLBACKS) */
0097 
0098 } CORDIC_HandleTypeDef;
0099 
0100 /**
0101   * @brief  CORDIC Config Structure definition
0102   */
0103 typedef struct
0104 {
0105   uint32_t   Function;     /*!< Function
0106                                 This parameter can be a value of @ref CORDIC_Function */
0107 
0108   uint32_t   Scale;        /*!< Scaling factor
0109                                 This parameter can be a value of @ref CORDIC_Scale */
0110 
0111   uint32_t   InSize;       /*!< Width of input data
0112                                 This parameter can be a value of @ref CORDIC_In_Size */
0113 
0114   uint32_t   OutSize;      /*!< Width of output data
0115                                 This parameter can be a value of @ref CORDIC_Out_Size */
0116 
0117   uint32_t   NbWrite;      /*!< Number of 32-bit write expected for one calculation
0118                                 This parameter can be a value of @ref CORDIC_Nb_Write */
0119 
0120   uint32_t   NbRead;       /*!< Number of 32-bit read expected after one calculation
0121                                 This parameter can be a value of @ref CORDIC_Nb_Read */
0122 
0123   uint32_t   Precision;    /*!< Number of cycles for calculation
0124                                 This parameter can be a value of @ref CORDIC_Precision_In_Cycles_Number */
0125 
0126 } CORDIC_ConfigTypeDef;
0127 
0128 #if USE_HAL_CORDIC_REGISTER_CALLBACKS == 1
0129 /**
0130   * @brief  HAL CORDIC Callback ID enumeration definition
0131   */
0132 typedef enum
0133 {
0134   HAL_CORDIC_ERROR_CB_ID             = 0x00U,    /*!< CORDIC error callback ID */
0135   HAL_CORDIC_CALCULATE_CPLT_CB_ID    = 0x01U,    /*!< CORDIC calculate complete callback ID */
0136 
0137   HAL_CORDIC_MSPINIT_CB_ID           = 0x02U,    /*!< CORDIC MspInit callback ID */
0138   HAL_CORDIC_MSPDEINIT_CB_ID         = 0x03U,    /*!< CORDIC MspDeInit callback ID */
0139 
0140 } HAL_CORDIC_CallbackIDTypeDef;
0141 
0142 /**
0143   * @brief  HAL CORDIC Callback pointer definition
0144   */
0145 typedef  void (*pCORDIC_CallbackTypeDef)(CORDIC_HandleTypeDef *hcordic);  /*!< pointer to a CORDIC callback function */
0146 
0147 #endif /* USE_HAL_CORDIC_REGISTER_CALLBACKS */
0148 
0149 /**
0150   * @}
0151   */
0152 
0153 
0154 /* Exported constants --------------------------------------------------------*/
0155 /** @defgroup CORDIC_Exported_Constants CORDIC Exported Constants
0156   * @ingroup RTEMSBSPsARMSTM32H7
0157   * @{
0158   */
0159 
0160 /** @defgroup CORDIC_Error_Code CORDIC Error code
0161   * @ingroup RTEMSBSPsARMSTM32H7
0162   * @{
0163   */
0164 #define HAL_CORDIC_ERROR_NONE              ((uint32_t)0x00000000U)   /*!< No error                */
0165 #define HAL_CORDIC_ERROR_PARAM             ((uint32_t)0x00000001U)   /*!< Wrong parameter error   */
0166 #define HAL_CORDIC_ERROR_NOT_READY         ((uint32_t)0x00000002U)   /*!< Peripheral not ready    */
0167 #define HAL_CORDIC_ERROR_TIMEOUT           ((uint32_t)0x00000004U)   /*!< Timeout error           */
0168 #define HAL_CORDIC_ERROR_DMA               ((uint32_t)0x00000008U)   /*!< DMA error               */
0169 #if USE_HAL_CORDIC_REGISTER_CALLBACKS == 1
0170 #define HAL_CORDIC_ERROR_INVALID_CALLBACK  ((uint32_t)0x00000010U)   /*!< Invalid Callback error  */
0171 #endif /* USE_HAL_CORDIC_REGISTER_CALLBACKS */
0172 /**
0173   * @}
0174   */
0175 
0176 /** @defgroup CORDIC_Function CORDIC Function
0177   * @ingroup RTEMSBSPsARMSTM32H7
0178   * @{
0179   */
0180 #define CORDIC_FUNCTION_COSINE      (0x00000000U)                                                          /*!< Cosine */
0181 #define CORDIC_FUNCTION_SINE        ((uint32_t)(CORDIC_CSR_FUNC_0))                                        /*!< Sine */
0182 #define CORDIC_FUNCTION_PHASE       ((uint32_t)(CORDIC_CSR_FUNC_1))                                        /*!< Phase */
0183 #define CORDIC_FUNCTION_MODULUS     ((uint32_t)(CORDIC_CSR_FUNC_1 | CORDIC_CSR_FUNC_0))                    /*!< Modulus */
0184 #define CORDIC_FUNCTION_ARCTANGENT  ((uint32_t)(CORDIC_CSR_FUNC_2))                                        /*!< Arctangent */
0185 #define CORDIC_FUNCTION_HCOSINE     ((uint32_t)(CORDIC_CSR_FUNC_2 | CORDIC_CSR_FUNC_0))                    /*!< Hyperbolic Cosine */
0186 #define CORDIC_FUNCTION_HSINE       ((uint32_t)(CORDIC_CSR_FUNC_2 | CORDIC_CSR_FUNC_1))                    /*!< Hyperbolic Sine */
0187 #define CORDIC_FUNCTION_HARCTANGENT ((uint32_t)(CORDIC_CSR_FUNC_2 | CORDIC_CSR_FUNC_1 | CORDIC_CSR_FUNC_0))/*!< Hyperbolic Arctangent */
0188 #define CORDIC_FUNCTION_NATURALLOG  ((uint32_t)(CORDIC_CSR_FUNC_3))                                        /*!< Natural Logarithm */
0189 #define CORDIC_FUNCTION_SQUAREROOT  ((uint32_t)(CORDIC_CSR_FUNC_3 | CORDIC_CSR_FUNC_0))                    /*!< Square Root */
0190 /**
0191   * @}
0192   */
0193 
0194 /** @defgroup CORDIC_Precision_In_Cycles_Number CORDIC Precision in Cycles Number
0195   * @ingroup RTEMSBSPsARMSTM32H7
0196   * @{
0197   */
0198 /* Note: 1 cycle corresponds to 4 algorithm iterations */
0199 #define CORDIC_PRECISION_1CYCLE     ((uint32_t)(CORDIC_CSR_PRECISION_0))
0200 #define CORDIC_PRECISION_2CYCLES    ((uint32_t)(CORDIC_CSR_PRECISION_1))
0201 #define CORDIC_PRECISION_3CYCLES    ((uint32_t)(CORDIC_CSR_PRECISION_1 | CORDIC_CSR_PRECISION_0))
0202 #define CORDIC_PRECISION_4CYCLES    ((uint32_t)(CORDIC_CSR_PRECISION_2))
0203 #define CORDIC_PRECISION_5CYCLES    ((uint32_t)(CORDIC_CSR_PRECISION_2 | CORDIC_CSR_PRECISION_0))
0204 #define CORDIC_PRECISION_6CYCLES    ((uint32_t)(CORDIC_CSR_PRECISION_2 | CORDIC_CSR_PRECISION_1))
0205 #define CORDIC_PRECISION_7CYCLES    ((uint32_t)(CORDIC_CSR_PRECISION_2\
0206                                                 | CORDIC_CSR_PRECISION_1 | CORDIC_CSR_PRECISION_0))
0207 #define CORDIC_PRECISION_8CYCLES    ((uint32_t)(CORDIC_CSR_PRECISION_3))
0208 #define CORDIC_PRECISION_9CYCLES    ((uint32_t)(CORDIC_CSR_PRECISION_3 | CORDIC_CSR_PRECISION_0))
0209 #define CORDIC_PRECISION_10CYCLES   ((uint32_t)(CORDIC_CSR_PRECISION_3 | CORDIC_CSR_PRECISION_1))
0210 #define CORDIC_PRECISION_11CYCLES   ((uint32_t)(CORDIC_CSR_PRECISION_3\
0211                                                 | CORDIC_CSR_PRECISION_1 | CORDIC_CSR_PRECISION_0))
0212 #define CORDIC_PRECISION_12CYCLES   ((uint32_t)(CORDIC_CSR_PRECISION_3 | CORDIC_CSR_PRECISION_2))
0213 #define CORDIC_PRECISION_13CYCLES   ((uint32_t)(CORDIC_CSR_PRECISION_3\
0214                                                 | CORDIC_CSR_PRECISION_2 | CORDIC_CSR_PRECISION_0))
0215 #define CORDIC_PRECISION_14CYCLES   ((uint32_t)(CORDIC_CSR_PRECISION_3\
0216                                                 | CORDIC_CSR_PRECISION_2 | CORDIC_CSR_PRECISION_1))
0217 #define CORDIC_PRECISION_15CYCLES   ((uint32_t)(CORDIC_CSR_PRECISION_3\
0218                                                 | CORDIC_CSR_PRECISION_2 | CORDIC_CSR_PRECISION_1\
0219                                                 |CORDIC_CSR_PRECISION_0))
0220 /**
0221   * @}
0222   */
0223 
0224 /** @defgroup CORDIC_Scale CORDIC Scaling factor
0225   * @ingroup RTEMSBSPsARMSTM32H7
0226   * @{
0227   */
0228 /* Scale factor value 'n' implies that the input data have been multiplied
0229    by a factor 2exp(-n), and/or the output data need to be multiplied by 2exp(n). */
0230 #define CORDIC_SCALE_0              (0x00000000U)
0231 #define CORDIC_SCALE_1              ((uint32_t)(CORDIC_CSR_SCALE_0))
0232 #define CORDIC_SCALE_2              ((uint32_t)(CORDIC_CSR_SCALE_1))
0233 #define CORDIC_SCALE_3              ((uint32_t)(CORDIC_CSR_SCALE_1 | CORDIC_CSR_SCALE_0))
0234 #define CORDIC_SCALE_4              ((uint32_t)(CORDIC_CSR_SCALE_2))
0235 #define CORDIC_SCALE_5              ((uint32_t)(CORDIC_CSR_SCALE_2 | CORDIC_CSR_SCALE_0))
0236 #define CORDIC_SCALE_6              ((uint32_t)(CORDIC_CSR_SCALE_2 | CORDIC_CSR_SCALE_1))
0237 #define CORDIC_SCALE_7              ((uint32_t)(CORDIC_CSR_SCALE_2 | CORDIC_CSR_SCALE_1 | CORDIC_CSR_SCALE_0))
0238 /**
0239   * @}
0240   */
0241 
0242 /** @defgroup CORDIC_Interrupts_Enable CORDIC Interrupts Enable bit
0243   * @ingroup RTEMSBSPsARMSTM32H7
0244   * @{
0245   */
0246 #define CORDIC_IT_IEN              CORDIC_CSR_IEN            /*!< Result ready interrupt enable */
0247 /**
0248   * @}
0249   */
0250 
0251 /** @defgroup CORDIC_DMAR DMA Read Request Enable bit
0252   * @ingroup RTEMSBSPsARMSTM32H7
0253   * @{
0254   */
0255 #define CORDIC_DMA_REN             CORDIC_CSR_DMAREN         /*!< DMA Read requests enable */
0256 /**
0257   * @}
0258   */
0259 
0260 /** @defgroup CORDIC_DMAW DMA Write Request Enable bit
0261   * @ingroup RTEMSBSPsARMSTM32H7
0262   * @{
0263   */
0264 #define CORDIC_DMA_WEN             CORDIC_CSR_DMAWEN         /*!< DMA Write channel enable */
0265 /**
0266   * @}
0267   */
0268 
0269 /** @defgroup CORDIC_Nb_Write CORDIC Number of 32-bit write required for one calculation
0270   * @ingroup RTEMSBSPsARMSTM32H7
0271   * @{
0272   */
0273 #define CORDIC_NBWRITE_1           (0x00000000U)             /*!< One 32-bits write containing either only one
0274                                                                   32-bit data input (Q1.31 format), or two 16-bit
0275                                                                   data input (Q1.15 format) packed in one 32 bits
0276                                                                   Data */
0277 #define CORDIC_NBWRITE_2           CORDIC_CSR_NARGS          /*!< Two 32-bit write containing two 32-bits data input
0278                                                                   (Q1.31 format) */
0279 /**
0280   * @}
0281   */
0282 
0283 /** @defgroup CORDIC_Nb_Read CORDIC Number of 32-bit read required after one calculation
0284   * @ingroup RTEMSBSPsARMSTM32H7
0285   * @{
0286   */
0287 #define CORDIC_NBREAD_1            (0x00000000U)             /*!< One 32-bits read containing either only one
0288                                                                   32-bit data output (Q1.31 format), or two 16-bit
0289                                                                   data output (Q1.15 format) packed in one 32 bits
0290                                                                   Data */
0291 #define CORDIC_NBREAD_2            CORDIC_CSR_NRES           /*!< Two 32-bit Data containing two 32-bits data output
0292                                                                   (Q1.31 format) */
0293 /**
0294   * @}
0295   */
0296 
0297 /** @defgroup CORDIC_In_Size CORDIC input data size
0298   * @ingroup RTEMSBSPsARMSTM32H7
0299   * @{
0300   */
0301 #define CORDIC_INSIZE_32BITS       (0x00000000U)             /*!< 32 bits input data size (Q1.31 format) */
0302 #define CORDIC_INSIZE_16BITS       CORDIC_CSR_ARGSIZE        /*!< 16 bits input data size (Q1.15 format) */
0303 /**
0304   * @}
0305   */
0306 
0307 /** @defgroup CORDIC_Out_Size CORDIC Results Size
0308   * @ingroup RTEMSBSPsARMSTM32H7
0309   * @{
0310   */
0311 #define CORDIC_OUTSIZE_32BITS      (0x00000000U)             /*!< 32 bits output data size (Q1.31 format) */
0312 #define CORDIC_OUTSIZE_16BITS      CORDIC_CSR_RESSIZE        /*!< 16 bits output data size (Q1.15 format) */
0313 /**
0314   * @}
0315   */
0316 
0317 /** @defgroup CORDIC_Flags  CORDIC status flags
0318   * @ingroup RTEMSBSPsARMSTM32H7
0319   * @{
0320   */
0321 #define CORDIC_FLAG_RRDY           CORDIC_CSR_RRDY           /*!< Result Ready Flag */
0322 /**
0323   * @}
0324   */
0325 
0326 /** @defgroup CORDIC_DMA_Direction CORDIC DMA direction
0327   * @ingroup RTEMSBSPsARMSTM32H7
0328   * @{
0329   */
0330 #define CORDIC_DMA_DIR_NONE        ((uint32_t)0x00000000U)   /*!< DMA direction : none */
0331 #define CORDIC_DMA_DIR_IN          ((uint32_t)0x00000001U)   /*!< DMA direction : Input of CORDIC */
0332 #define CORDIC_DMA_DIR_OUT         ((uint32_t)0x00000002U)   /*!< DMA direction : Output of CORDIC */
0333 #define CORDIC_DMA_DIR_IN_OUT      ((uint32_t)0x00000003U)   /*!< DMA direction : Input and Output of CORDIC */
0334 /**
0335   * @}
0336   */
0337 
0338 /**
0339   * @}
0340   */
0341 
0342 
0343 /* Exported macro ------------------------------------------------------------*/
0344 /** @defgroup CORDIC_Exported_Macros CORDIC Exported Macros
0345   * @ingroup RTEMSBSPsARMSTM32H7
0346   * @{
0347   */
0348 
0349 /** @brief  Reset CORDIC handle state.
0350   * @param  __HANDLE__ CORDIC handle
0351   * @retval None
0352   */
0353 #if USE_HAL_CORDIC_REGISTER_CALLBACKS == 1
0354 #define __HAL_CORDIC_RESET_HANDLE_STATE(__HANDLE__) do{                                                \
0355                                                         (__HANDLE__)->State = HAL_CORDIC_STATE_RESET;   \
0356                                                         (__HANDLE__)->MspInitCallback = NULL;           \
0357                                                         (__HANDLE__)->MspDeInitCallback = NULL;         \
0358                                                       } while(0)
0359 #else
0360 #define __HAL_CORDIC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CORDIC_STATE_RESET)
0361 #endif /*USE_HAL_CORDIC_REGISTER_CALLBACKS */
0362 
0363 /**
0364   * @brief  Enable the CORDIC interrupt when result is ready
0365   * @param  __HANDLE__ CORDIC handle.
0366   * @param  __INTERRUPT__ CORDIC Interrupt.
0367   *         This parameter can be one of the following values:
0368   *            @arg @ref CORDIC_IT_IEN Enable Interrupt
0369   * @retval None
0370   */
0371 #define __HAL_CORDIC_ENABLE_IT(__HANDLE__, __INTERRUPT__)                     \
0372   (((__HANDLE__)->Instance->CSR) |= (__INTERRUPT__))
0373 
0374 /**
0375   * @brief  Disable the CORDIC interrupt
0376   * @param  __HANDLE__ CORDIC handle.
0377   * @param  __INTERRUPT__ CORDIC Interrupt.
0378   *         This parameter can be one of the following values:
0379   *            @arg @ref CORDIC_IT_IEN Enable Interrupt
0380   * @retval None
0381   */
0382 #define __HAL_CORDIC_DISABLE_IT(__HANDLE__, __INTERRUPT__)                    \
0383   (((__HANDLE__)->Instance->CSR) &= ~(__INTERRUPT__))
0384 
0385 /** @brief  Check whether the specified CORDIC interrupt occurred or not.
0386             Dummy macro as no interrupt status flag.
0387   * @param  __HANDLE__ CORDIC handle.
0388   * @param  __INTERRUPT__ CORDIC interrupt to check
0389   * @retval SET (interrupt occurred) or RESET (interrupt did not occurred)
0390   */
0391 #define __HAL_CORDIC_GET_IT(__HANDLE__, __INTERRUPT__)     /* Dummy macro */
0392 
0393 /** @brief  Clear specified CORDIC interrupt status. Dummy macro as no
0394             interrupt status flag.
0395   * @param  __HANDLE__ CORDIC handle.
0396   * @param  __INTERRUPT__ CORDIC interrupt to clear
0397   * @retval None
0398   */
0399 #define __HAL_CORDIC_CLEAR_IT(__HANDLE__, __INTERRUPT__)   /* Dummy macro */
0400 
0401 /** @brief  Check whether the specified CORDIC status flag is set or not.
0402   * @param  __HANDLE__ CORDIC handle.
0403   * @param  __FLAG__ CORDIC flag to check
0404   *         This parameter can be one of the following values:
0405   *            @arg @ref CORDIC_FLAG_RRDY Result Ready Flag
0406   * @retval SET (flag is set) or RESET (flag is reset)
0407   */
0408 #define __HAL_CORDIC_GET_FLAG(__HANDLE__, __FLAG__)                           \
0409   ((((__HANDLE__)->Instance->CSR) & (__FLAG__)) == (__FLAG__))
0410 
0411 /** @brief  Clear specified CORDIC status flag. Dummy macro as no
0412             flag can be cleared.
0413   * @param  __HANDLE__ CORDIC handle.
0414   * @param  __FLAG__ CORDIC flag to clear
0415   *         This parameter can be one of the following values:
0416   *            @arg @ref CORDIC_FLAG_RRDY Result Ready Flag
0417   * @retval None
0418   */
0419 #define __HAL_CORDIC_CLEAR_FLAG(__HANDLE__, __FLAG__)     /* Dummy macro */
0420 
0421 /** @brief  Check whether the specified CORDIC interrupt is enabled or not.
0422   * @param  __HANDLE__ CORDIC handle.
0423   * @param  __INTERRUPT__ CORDIC interrupt to check
0424   *         This parameter can be one of the following values:
0425   *            @arg @ref CORDIC_IT_IEN Enable Interrupt
0426   * @retval FlagStatus
0427   */
0428 #define __HAL_CORDIC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)                 \
0429   (((__HANDLE__)->Instance->CSR) & (__INTERRUPT__))
0430 
0431 /**
0432   * @}
0433   */
0434 
0435 /* Private macros --------------------------------------------------------*/
0436 /** @defgroup  CORDIC_Private_Macros   CORDIC Private Macros
0437   * @ingroup RTEMSBSPsARMSTM32H7
0438   * @{
0439   */
0440 
0441 /**
0442   * @brief  Verify the CORDIC function.
0443   * @param  __FUNCTION__ Name of the function.
0444   * @retval SET (__FUNCTION__ is a valid value) or RESET (__FUNCTION__ is invalid)
0445   */
0446 #define IS_CORDIC_FUNCTION(__FUNCTION__) (((__FUNCTION__) == CORDIC_FUNCTION_COSINE)       || \
0447                                           ((__FUNCTION__) == CORDIC_FUNCTION_SINE)         || \
0448                                           ((__FUNCTION__) == CORDIC_FUNCTION_PHASE)        || \
0449                                           ((__FUNCTION__) == CORDIC_FUNCTION_MODULUS)      || \
0450                                           ((__FUNCTION__) == CORDIC_FUNCTION_ARCTANGENT)   || \
0451                                           ((__FUNCTION__) == CORDIC_FUNCTION_HCOSINE)      || \
0452                                           ((__FUNCTION__) == CORDIC_FUNCTION_HSINE)        || \
0453                                           ((__FUNCTION__) == CORDIC_FUNCTION_HARCTANGENT)  || \
0454                                           ((__FUNCTION__) == CORDIC_FUNCTION_NATURALLOG)   || \
0455                                           ((__FUNCTION__) == CORDIC_FUNCTION_SQUAREROOT))
0456 
0457 
0458 /**
0459   * @brief  Verify the CORDIC precision.
0460   * @param  __PRECISION__ CORDIC Precision in Cycles Number.
0461   * @retval SET (__PRECISION__ is a valid value) or RESET (__PRECISION__ is invalid)
0462   */
0463 #define IS_CORDIC_PRECISION(__PRECISION__) (((__PRECISION__) == CORDIC_PRECISION_1CYCLE)   || \
0464                                             ((__PRECISION__) == CORDIC_PRECISION_2CYCLES)  || \
0465                                             ((__PRECISION__) == CORDIC_PRECISION_3CYCLES)  || \
0466                                             ((__PRECISION__) == CORDIC_PRECISION_4CYCLES)  || \
0467                                             ((__PRECISION__) == CORDIC_PRECISION_5CYCLES)  || \
0468                                             ((__PRECISION__) == CORDIC_PRECISION_6CYCLES)  || \
0469                                             ((__PRECISION__) == CORDIC_PRECISION_7CYCLES)  || \
0470                                             ((__PRECISION__) == CORDIC_PRECISION_8CYCLES)  || \
0471                                             ((__PRECISION__) == CORDIC_PRECISION_9CYCLES)  || \
0472                                             ((__PRECISION__) == CORDIC_PRECISION_10CYCLES) || \
0473                                             ((__PRECISION__) == CORDIC_PRECISION_11CYCLES) || \
0474                                             ((__PRECISION__) == CORDIC_PRECISION_12CYCLES) || \
0475                                             ((__PRECISION__) == CORDIC_PRECISION_13CYCLES) || \
0476                                             ((__PRECISION__) == CORDIC_PRECISION_14CYCLES) || \
0477                                             ((__PRECISION__) == CORDIC_PRECISION_15CYCLES))
0478 
0479 /**
0480   * @brief  Verify the CORDIC scaling factor.
0481   * @param  __SCALE__ Number of cycles for calculation, 1 cycle corresponding to 4 algorithm iterations.
0482   * @retval SET (__SCALE__ is a valid value) or RESET (__SCALE__ is invalid)
0483   */
0484 #define IS_CORDIC_SCALE(__SCALE__) (((__SCALE__) == CORDIC_SCALE_0)  || \
0485                                     ((__SCALE__) == CORDIC_SCALE_1)  || \
0486                                     ((__SCALE__) == CORDIC_SCALE_2)  || \
0487                                     ((__SCALE__) == CORDIC_SCALE_3)  || \
0488                                     ((__SCALE__) == CORDIC_SCALE_4)  || \
0489                                     ((__SCALE__) == CORDIC_SCALE_5)  || \
0490                                     ((__SCALE__) == CORDIC_SCALE_6)  || \
0491                                     ((__SCALE__) == CORDIC_SCALE_7))
0492 
0493 /**
0494   * @brief  Verify the CORDIC number of 32-bits write expected for one calculation.
0495   * @param  __NBWRITE__ Number of 32-bits write expected for one calculation.
0496   * @retval SET (__NBWRITE__ is a valid value) or RESET (__NBWRITE__ is invalid)
0497   */
0498 #define IS_CORDIC_NBWRITE(__NBWRITE__) (((__NBWRITE__) == CORDIC_NBWRITE_1)  || \
0499                                         ((__NBWRITE__) == CORDIC_NBWRITE_2))
0500 
0501 /**
0502   * @brief  Verify the CORDIC number of 32-bits read expected after one calculation.
0503   * @param  __NBREAD__ Number of 32-bits read expected after one calculation.
0504   * @retval SET (__NBREAD__ is a valid value) or RESET (__NBREAD__ is invalid)
0505   */
0506 #define IS_CORDIC_NBREAD(__NBREAD__) (((__NBREAD__) == CORDIC_NBREAD_1)  || \
0507                                       ((__NBREAD__) == CORDIC_NBREAD_2))
0508 
0509 /**
0510   * @brief  Verify the CORDIC input data size for one calculation.
0511   * @param  __INSIZE__ input data size for one calculation.
0512   * @retval SET (__INSIZE__ is a valid value) or RESET (__INSIZE__ is invalid)
0513   */
0514 #define IS_CORDIC_INSIZE(__INSIZE__) (((__INSIZE__) == CORDIC_INSIZE_32BITS)  || \
0515                                       ((__INSIZE__) == CORDIC_INSIZE_16BITS))
0516 
0517 /**
0518   * @brief  Verify the CORDIC output data size for one calculation.
0519   * @param  __OUTSIZE__ output data size for one calculation.
0520   * @retval SET (__OUTSIZE__ is a valid value) or RESET (__OUTSIZE__ is invalid)
0521   */
0522 #define IS_CORDIC_OUTSIZE(__OUTSIZE__) (((__OUTSIZE__) == CORDIC_OUTSIZE_32BITS)  || \
0523                                         ((__OUTSIZE__) == CORDIC_OUTSIZE_16BITS))
0524 
0525 /**
0526   * @brief  Verify the CORDIC DMA transfer Direction.
0527   * @param  __DMADIR__ DMA transfer direction.
0528   * @retval SET (__DMADIR__ is a valid value) or RESET (__DMADIR__ is invalid)
0529   */
0530 #define IS_CORDIC_DMA_DIRECTION(__DMADIR__) (((__DMADIR__) == CORDIC_DMA_DIR_IN)  || \
0531                                              ((__DMADIR__) == CORDIC_DMA_DIR_OUT) || \
0532                                              ((__DMADIR__) == CORDIC_DMA_DIR_IN_OUT))
0533 
0534 /**
0535   * @}
0536   */
0537 
0538 /** @addtogroup CORDIC_Exported_Functions
0539   * @{
0540   */
0541 /* Exported functions ------------------------------------------------------- */
0542 
0543 /** @addtogroup CORDIC_Exported_Functions_Group1
0544   * @{
0545   */
0546 /* Initialization and de-initialization functions ******************************/
0547 HAL_StatusTypeDef HAL_CORDIC_Init(CORDIC_HandleTypeDef *hcordic);
0548 HAL_StatusTypeDef HAL_CORDIC_DeInit(CORDIC_HandleTypeDef *hcordic);
0549 void HAL_CORDIC_MspInit(CORDIC_HandleTypeDef *hcordic);
0550 void HAL_CORDIC_MspDeInit(CORDIC_HandleTypeDef *hcordic);
0551 
0552 #if USE_HAL_CORDIC_REGISTER_CALLBACKS == 1
0553 /* Callbacks Register/UnRegister functions  ***********************************/
0554 HAL_StatusTypeDef HAL_CORDIC_RegisterCallback(CORDIC_HandleTypeDef *hcordic, HAL_CORDIC_CallbackIDTypeDef CallbackID,
0555                                               pCORDIC_CallbackTypeDef pCallback);
0556 HAL_StatusTypeDef HAL_CORDIC_UnRegisterCallback(CORDIC_HandleTypeDef *hcordic, HAL_CORDIC_CallbackIDTypeDef CallbackID);
0557 /**
0558   * @}
0559   */
0560 
0561 /** @addtogroup CORDIC_Exported_Functions_Group2
0562   * @{
0563   */
0564 #endif /* USE_HAL_CORDIC_REGISTER_CALLBACKS */
0565 /* Peripheral Control functions ***********************************************/
0566 HAL_StatusTypeDef HAL_CORDIC_Configure(CORDIC_HandleTypeDef *hcordic, const CORDIC_ConfigTypeDef *sConfig);
0567 HAL_StatusTypeDef HAL_CORDIC_Calculate(CORDIC_HandleTypeDef *hcordic, const int32_t *pInBuff, int32_t *pOutBuff,
0568                                        uint32_t NbCalc, uint32_t Timeout);
0569 HAL_StatusTypeDef HAL_CORDIC_CalculateZO(CORDIC_HandleTypeDef *hcordic, const int32_t *pInBuff, int32_t *pOutBuff,
0570                                          uint32_t NbCalc, uint32_t Timeout);
0571 HAL_StatusTypeDef HAL_CORDIC_Calculate_IT(CORDIC_HandleTypeDef *hcordic, const int32_t *pInBuff, int32_t *pOutBuff,
0572                                           uint32_t NbCalc);
0573 HAL_StatusTypeDef HAL_CORDIC_Calculate_DMA(CORDIC_HandleTypeDef *hcordic, const int32_t *pInBuff, int32_t *pOutBuff,
0574                                            uint32_t NbCalc, uint32_t DMADirection);
0575 /**
0576   * @}
0577   */
0578 
0579 /** @addtogroup CORDIC_Exported_Functions_Group3
0580   * @{
0581   */
0582 /* Callback functions *********************************************************/
0583 void HAL_CORDIC_ErrorCallback(CORDIC_HandleTypeDef *hcordic);
0584 void HAL_CORDIC_CalculateCpltCallback(CORDIC_HandleTypeDef *hcordic);
0585 /**
0586   * @}
0587   */
0588 
0589 /** @addtogroup CORDIC_Exported_Functions_Group4
0590   * @{
0591   */
0592 /* IRQ handler management *****************************************************/
0593 void HAL_CORDIC_IRQHandler(CORDIC_HandleTypeDef *hcordic);
0594 /**
0595   * @}
0596   */
0597 
0598 /** @addtogroup CORDIC_Exported_Functions_Group5
0599   * @{
0600   */
0601 /* Peripheral State functions *************************************************/
0602 HAL_CORDIC_StateTypeDef HAL_CORDIC_GetState(const CORDIC_HandleTypeDef *hcordic);
0603 uint32_t HAL_CORDIC_GetError(const CORDIC_HandleTypeDef *hcordic);
0604 /**
0605   * @}
0606   */
0607 
0608 /**
0609   * @}
0610   */
0611 
0612 /**
0613   * @}
0614   */
0615 
0616 /**
0617   * @}
0618   */
0619 
0620 #endif /* CORDIC */
0621 
0622 #ifdef __cplusplus
0623 }
0624 #endif
0625 
0626 #endif /* STM32H7xx_HAL_CORDIC_H */