1 /**
2   ******************************************************************************
3   * @file    stm32h7xx_hal_cordic.h
4   * @author  MCD Application Team
5   * @brief   This file contains all the functions prototypes for the CORDIC firmware
6   *          library.
7   ******************************************************************************
8   * @attention
9   *
10   * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
11   * All rights reserved.</center></h2>
12   *
13   * This software component is licensed by ST under BSD 3-Clause license,
14   * the "License"; You may not use this file except in compliance with the
15   * License. You may obtain a copy of the License at:
16   *                        opensource.org/licenses/BSD-3-Clause
17   *
18   ******************************************************************************
19   */
20 
21 /* Define to prevent recursive inclusion -------------------------------------*/
22 #ifndef STM32H7xx_HAL_CORDIC_H
23 #define STM32H7xx_HAL_CORDIC_H
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 /* Includes ------------------------------------------------------------------*/
30 #include "stm32h7xx_hal_def.h"
31 
32 #if defined(CORDIC)
33 /** @addtogroup STM32H7xx_HAL_Driver
34   * @{
35   */
36 
37 /** @addtogroup CORDIC
38   * @{
39   */
40 
41 /* Exported types ------------------------------------------------------------*/
42 /** @defgroup CORDIC_Exported_Types CORDIC Exported Types
43   * @{
44   */
45 
46 /**
47   * @brief  CORDIC HAL State Structure definition
48   */
49 typedef enum
50 {
51   HAL_CORDIC_STATE_RESET     = 0x00U,  /*!< CORDIC not yet initialized or disabled */
52   HAL_CORDIC_STATE_READY     = 0x01U,  /*!< CORDIC initialized and ready for use   */
53   HAL_CORDIC_STATE_BUSY      = 0x02U,  /*!< CORDIC internal process is ongoing     */
54   HAL_CORDIC_STATE_ERROR     = 0x03U   /*!< CORDIC error state                     */
55 } HAL_CORDIC_StateTypeDef;
56 
57 /**
58   * @brief  CORDIC Handle Structure definition
59   */
60 #if USE_HAL_CORDIC_REGISTER_CALLBACKS == 1
61 typedef struct __CORDIC_HandleTypeDef
62 #else
63 typedef struct
64 #endif /* USE_HAL_CORDIC_REGISTER_CALLBACKS */
65 {
66   CORDIC_TypeDef                *Instance;   /*!< Register base address */
67 
68   int32_t                       *pInBuff;    /*!< Pointer to CORDIC input data buffer */
69 
70   int32_t                       *pOutBuff;   /*!< Pointer to CORDIC output data buffer */
71 
72   uint32_t                      NbCalcToOrder; /*!< Remaining number of calculation to order */
73 
74   uint32_t                      NbCalcToGet; /*!< Remaining number of calculation result to get */
75 
76   uint32_t                      DMADirection; /*!< Direction of CORDIC DMA transfers */
77 
78   DMA_HandleTypeDef             *hdmaIn;     /*!< CORDIC peripheral input data DMA handle parameters */
79 
80   DMA_HandleTypeDef             *hdmaOut;    /*!< CORDIC peripheral output data DMA handle parameters */
81 
82   HAL_LockTypeDef               Lock;        /*!< CORDIC locking object */
83 
84   __IO HAL_CORDIC_StateTypeDef  State;       /*!< CORDIC state */
85 
86   __IO uint32_t                 ErrorCode;   /*!< CORDIC peripheral error code
87                                                   This parameter can be a value of @ref CORDIC_Error_Code */
88 
89 #if USE_HAL_CORDIC_REGISTER_CALLBACKS == 1
90   void (* ErrorCallback)(struct __CORDIC_HandleTypeDef *hcordic);          /*!< CORDIC error callback */
91   void (* CalculateCpltCallback)(struct __CORDIC_HandleTypeDef *hcordic);  /*!< CORDIC calculate complete callback */
92 
93   void (* MspInitCallback)(struct __CORDIC_HandleTypeDef *hcordic);        /*!< CORDIC Msp Init callback */
94   void (* MspDeInitCallback)(struct __CORDIC_HandleTypeDef *hcordic);      /*!< CORDIC Msp DeInit callback */
95 
96 #endif /* (USE_HAL_CORDIC_REGISTER_CALLBACKS) */
97 
98 } CORDIC_HandleTypeDef;
99 
100 /**
101   * @brief  CORDIC Config Structure definition
102   */
103 typedef struct
104 {
105   uint32_t   Function;     /*!< Function
106                                 This parameter can be a value of @ref CORDIC_Function */
107 
108   uint32_t   Scale;        /*!< Scaling factor
109                                 This parameter can be a value of @ref CORDIC_Scale */
110 
111   uint32_t   InSize;       /*!< Width of input data
112                                 This parameter can be a value of @ref CORDIC_In_Size */
113 
114   uint32_t   OutSize;      /*!< Width of output data
115                                 This parameter can be a value of @ref CORDIC_Out_Size */
116 
117   uint32_t   NbWrite;      /*!< Number of 32-bit write expected for one calculation
118                                 This parameter can be a value of @ref CORDIC_Nb_Write */
119 
120   uint32_t   NbRead;       /*!< Number of 32-bit read expected after one calculation
121                                 This parameter can be a value of @ref CORDIC_Nb_Read */
122 
123   uint32_t   Precision;    /*!< Number of cycles for calculation
124                                 This parameter can be a value of @ref CORDIC_Precision_In_Cycles_Number */
125 
126 } CORDIC_ConfigTypeDef;
127 
128 #if USE_HAL_CORDIC_REGISTER_CALLBACKS == 1
129 /**
130   * @brief  HAL CORDIC Callback ID enumeration definition
131   */
132 typedef enum
133 {
134   HAL_CORDIC_ERROR_CB_ID             = 0x00U,    /*!< CORDIC error callback ID */
135   HAL_CORDIC_CALCULATE_CPLT_CB_ID    = 0x01U,    /*!< CORDIC calculate complete callback ID */
136 
137   HAL_CORDIC_MSPINIT_CB_ID           = 0x02U,    /*!< CORDIC MspInit callback ID */
138   HAL_CORDIC_MSPDEINIT_CB_ID         = 0x03U,    /*!< CORDIC MspDeInit callback ID */
139 
140 } HAL_CORDIC_CallbackIDTypeDef;
141 
142 /**
143   * @brief  HAL CORDIC Callback pointer definition
144   */
145 typedef  void (*pCORDIC_CallbackTypeDef)(CORDIC_HandleTypeDef *hcordic);  /*!< pointer to a CORDIC callback function */
146 
147 #endif /* USE_HAL_CORDIC_REGISTER_CALLBACKS */
148 
149 /**
150   * @}
151   */
152 
153 
154 /* Exported constants --------------------------------------------------------*/
155 /** @defgroup CORDIC_Exported_Constants CORDIC Exported Constants
156   * @{
157   */
158 
159 /** @defgroup CORDIC_Error_Code CORDIC Error code
160   * @{
161   */
162 #define HAL_CORDIC_ERROR_NONE              ((uint32_t)0x00000000U)   /*!< No error                */
163 #define HAL_CORDIC_ERROR_PARAM             ((uint32_t)0x00000001U)   /*!< Wrong parameter error   */
164 #define HAL_CORDIC_ERROR_NOT_READY         ((uint32_t)0x00000002U)   /*!< Peripheral not ready    */
165 #define HAL_CORDIC_ERROR_TIMEOUT           ((uint32_t)0x00000004U)   /*!< Timeout error           */
166 #define HAL_CORDIC_ERROR_DMA               ((uint32_t)0x00000008U)   /*!< DMA error               */
167 #if USE_HAL_CORDIC_REGISTER_CALLBACKS == 1
168 #define HAL_CORDIC_ERROR_INVALID_CALLBACK  ((uint32_t)0x00000010U)   /*!< Invalid Callback error  */
169 #endif /* USE_HAL_CORDIC_REGISTER_CALLBACKS */
170 /**
171   * @}
172   */
173 
174 /** @defgroup CORDIC_Function CORDIC Function
175   * @{
176   */
177 #define CORDIC_FUNCTION_COSINE      (0x00000000U)                                                          /*!< Cosine */
178 #define CORDIC_FUNCTION_SINE        ((uint32_t)(CORDIC_CSR_FUNC_0))                                        /*!< Sine */
179 #define CORDIC_FUNCTION_PHASE       ((uint32_t)(CORDIC_CSR_FUNC_1))                                        /*!< Phase */
180 #define CORDIC_FUNCTION_MODULUS     ((uint32_t)(CORDIC_CSR_FUNC_1 | CORDIC_CSR_FUNC_0))                    /*!< Modulus */
181 #define CORDIC_FUNCTION_ARCTANGENT  ((uint32_t)(CORDIC_CSR_FUNC_2))                                        /*!< Arctangent */
182 #define CORDIC_FUNCTION_HCOSINE     ((uint32_t)(CORDIC_CSR_FUNC_2 | CORDIC_CSR_FUNC_0))                    /*!< Hyperbolic Cosine */
183 #define CORDIC_FUNCTION_HSINE       ((uint32_t)(CORDIC_CSR_FUNC_2 | CORDIC_CSR_FUNC_1))                    /*!< Hyperbolic Sine */
184 #define CORDIC_FUNCTION_HARCTANGENT ((uint32_t)(CORDIC_CSR_FUNC_2 | CORDIC_CSR_FUNC_1 | CORDIC_CSR_FUNC_0))/*!< Hyperbolic Arctangent */
185 #define CORDIC_FUNCTION_NATURALLOG  ((uint32_t)(CORDIC_CSR_FUNC_3))                                        /*!< Natural Logarithm */
186 #define CORDIC_FUNCTION_SQUAREROOT  ((uint32_t)(CORDIC_CSR_FUNC_3 | CORDIC_CSR_FUNC_0))                    /*!< Square Root */
187 /**
188   * @}
189   */
190 
191 /** @defgroup CORDIC_Precision_In_Cycles_Number CORDIC Precision in Cycles Number
192   * @{
193   */
194 /* Note: 1 cycle corresponds to 4 algorithm iterations */
195 #define CORDIC_PRECISION_1CYCLE     ((uint32_t)(CORDIC_CSR_PRECISION_0))
196 #define CORDIC_PRECISION_2CYCLES    ((uint32_t)(CORDIC_CSR_PRECISION_1))
197 #define CORDIC_PRECISION_3CYCLES    ((uint32_t)(CORDIC_CSR_PRECISION_1 | CORDIC_CSR_PRECISION_0))
198 #define CORDIC_PRECISION_4CYCLES    ((uint32_t)(CORDIC_CSR_PRECISION_2))
199 #define CORDIC_PRECISION_5CYCLES    ((uint32_t)(CORDIC_CSR_PRECISION_2 | CORDIC_CSR_PRECISION_0))
200 #define CORDIC_PRECISION_6CYCLES    ((uint32_t)(CORDIC_CSR_PRECISION_2 | CORDIC_CSR_PRECISION_1))
201 #define CORDIC_PRECISION_7CYCLES    ((uint32_t)(CORDIC_CSR_PRECISION_2\
202                                                 | CORDIC_CSR_PRECISION_1 | CORDIC_CSR_PRECISION_0))
203 #define CORDIC_PRECISION_8CYCLES    ((uint32_t)(CORDIC_CSR_PRECISION_3))
204 #define CORDIC_PRECISION_9CYCLES    ((uint32_t)(CORDIC_CSR_PRECISION_3 | CORDIC_CSR_PRECISION_0))
205 #define CORDIC_PRECISION_10CYCLES   ((uint32_t)(CORDIC_CSR_PRECISION_3 | CORDIC_CSR_PRECISION_1))
206 #define CORDIC_PRECISION_11CYCLES   ((uint32_t)(CORDIC_CSR_PRECISION_3\
207                                                 | CORDIC_CSR_PRECISION_1 | CORDIC_CSR_PRECISION_0))
208 #define CORDIC_PRECISION_12CYCLES   ((uint32_t)(CORDIC_CSR_PRECISION_3 | CORDIC_CSR_PRECISION_2))
209 #define CORDIC_PRECISION_13CYCLES   ((uint32_t)(CORDIC_CSR_PRECISION_3\
210                                                 | CORDIC_CSR_PRECISION_2 | CORDIC_CSR_PRECISION_0))
211 #define CORDIC_PRECISION_14CYCLES   ((uint32_t)(CORDIC_CSR_PRECISION_3\
212                                                 | CORDIC_CSR_PRECISION_2 | CORDIC_CSR_PRECISION_1))
213 #define CORDIC_PRECISION_15CYCLES   ((uint32_t)(CORDIC_CSR_PRECISION_3\
214                                                 | CORDIC_CSR_PRECISION_2 | CORDIC_CSR_PRECISION_1\
215                                                 |CORDIC_CSR_PRECISION_0))
216 /**
217   * @}
218   */
219 
220 /** @defgroup CORDIC_Scale CORDIC Scaling factor
221   * @{
222   */
223 /* Scale factor value 'n' implies that the input data have been multiplied
224    by a factor 2exp(-n), and/or the output data need to be multiplied by 2exp(n). */
225 #define CORDIC_SCALE_0              (0x00000000U)
226 #define CORDIC_SCALE_1              ((uint32_t)(CORDIC_CSR_SCALE_0))
227 #define CORDIC_SCALE_2              ((uint32_t)(CORDIC_CSR_SCALE_1))
228 #define CORDIC_SCALE_3              ((uint32_t)(CORDIC_CSR_SCALE_1 | CORDIC_CSR_SCALE_0))
229 #define CORDIC_SCALE_4              ((uint32_t)(CORDIC_CSR_SCALE_2))
230 #define CORDIC_SCALE_5              ((uint32_t)(CORDIC_CSR_SCALE_2 | CORDIC_CSR_SCALE_0))
231 #define CORDIC_SCALE_6              ((uint32_t)(CORDIC_CSR_SCALE_2 | CORDIC_CSR_SCALE_1))
232 #define CORDIC_SCALE_7              ((uint32_t)(CORDIC_CSR_SCALE_2 | CORDIC_CSR_SCALE_1 | CORDIC_CSR_SCALE_0))
233 /**
234   * @}
235   */
236 
237 /** @defgroup CORDIC_Interrupts_Enable CORDIC Interrupts Enable bit
238   * @{
239   */
240 #define CORDIC_IT_IEN              CORDIC_CSR_IEN            /*!< Result ready interrupt enable */
241 /**
242   * @}
243   */
244 
245 /** @defgroup CORDIC_DMAR DMA Read Request Enable bit
246   * @{
247   */
248 #define CORDIC_DMA_REN             CORDIC_CSR_DMAREN         /*!< DMA Read requests enable */
249 /**
250   * @}
251   */
252 
253 /** @defgroup CORDIC_DMAW DMA Write Request Enable bit
254   * @{
255   */
256 #define CORDIC_DMA_WEN             CORDIC_CSR_DMAWEN         /*!< DMA Write channel enable */
257 /**
258   * @}
259   */
260 
261 /** @defgroup CORDIC_Nb_Write CORDIC Number of 32-bit write required for one calculation
262   * @{
263   */
264 #define CORDIC_NBWRITE_1           (0x00000000U)             /*!< One 32-bits write containing either only one
265                                                                   32-bit data input (Q1.31 format), or two 16-bit
266                                                                   data input (Q1.15 format) packed in one 32 bits
267                                                                   Data */
268 #define CORDIC_NBWRITE_2           CORDIC_CSR_NARGS          /*!< Two 32-bit write containing two 32-bits data input
269                                                                   (Q1.31 format) */
270 /**
271   * @}
272   */
273 
274 /** @defgroup CORDIC_Nb_Read CORDIC Number of 32-bit read required after one calculation
275   * @{
276   */
277 #define CORDIC_NBREAD_1            (0x00000000U)             /*!< One 32-bits read containing either only one
278                                                                   32-bit data output (Q1.31 format), or two 16-bit
279                                                                   data output (Q1.15 format) packed in one 32 bits
280                                                                   Data */
281 #define CORDIC_NBREAD_2            CORDIC_CSR_NRES           /*!< Two 32-bit Data containing two 32-bits data output
282                                                                   (Q1.31 format) */
283 /**
284   * @}
285   */
286 
287 /** @defgroup CORDIC_In_Size CORDIC input data size
288   * @{
289   */
290 #define CORDIC_INSIZE_32BITS       (0x00000000U)             /*!< 32 bits input data size (Q1.31 format) */
291 #define CORDIC_INSIZE_16BITS       CORDIC_CSR_ARGSIZE        /*!< 16 bits input data size (Q1.15 format) */
292 /**
293   * @}
294   */
295 
296 /** @defgroup CORDIC_Out_Size CORDIC Results Size
297   * @{
298   */
299 #define CORDIC_OUTSIZE_32BITS      (0x00000000U)             /*!< 32 bits output data size (Q1.31 format) */
300 #define CORDIC_OUTSIZE_16BITS      CORDIC_CSR_RESSIZE        /*!< 16 bits output data size (Q1.15 format) */
301 /**
302   * @}
303   */
304 
305 /** @defgroup CORDIC_Flags  CORDIC status flags
306   * @{
307   */
308 #define CORDIC_FLAG_RRDY           CORDIC_CSR_RRDY           /*!< Result Ready Flag */
309 /**
310   * @}
311   */
312 
313 /** @defgroup CORDIC_DMA_Direction CORDIC DMA direction
314   * @{
315   */
316 #define CORDIC_DMA_DIR_NONE        ((uint32_t)0x00000000U)   /*!< DMA direction : none */
317 #define CORDIC_DMA_DIR_IN          ((uint32_t)0x00000001U)   /*!< DMA direction : Input of CORDIC */
318 #define CORDIC_DMA_DIR_OUT         ((uint32_t)0x00000002U)   /*!< DMA direction : Output of CORDIC */
319 #define CORDIC_DMA_DIR_IN_OUT      ((uint32_t)0x00000003U)   /*!< DMA direction : Input and Output of CORDIC */
320 /**
321   * @}
322   */
323 
324 /**
325   * @}
326   */
327 
328 
329 /* Exported macro ------------------------------------------------------------*/
330 /** @defgroup CORDIC_Exported_Macros CORDIC Exported Macros
331   * @{
332   */
333 
334 /** @brief  Reset CORDIC handle state.
335   * @param  __HANDLE__ CORDIC handle
336   * @retval None
337   */
338 #if USE_HAL_CORDIC_REGISTER_CALLBACKS == 1
339 #define __HAL_CORDIC_RESET_HANDLE_STATE(__HANDLE__) do{                                                \
340                                                         (__HANDLE__)->State = HAL_CORDIC_STATE_RESET;   \
341                                                         (__HANDLE__)->MspInitCallback = NULL;           \
342                                                         (__HANDLE__)->MspDeInitCallback = NULL;         \
343                                                       } while(0)
344 #else
345 #define __HAL_CORDIC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CORDIC_STATE_RESET)
346 #endif /*USE_HAL_CORDIC_REGISTER_CALLBACKS */
347 
348 /**
349   * @brief  Enable the CORDIC interrupt when result is ready
350   * @param  __HANDLE__ CORDIC handle.
351   * @param  __INTERRUPT__ CORDIC Interrupt.
352   *         This parameter can be one of the following values:
353   *            @arg @ref CORDIC_IT_IEN Enable Interrupt
354   * @retval None
355   */
356 #define __HAL_CORDIC_ENABLE_IT(__HANDLE__, __INTERRUPT__)                     \
357   (((__HANDLE__)->Instance->CSR) |= (__INTERRUPT__))
358 
359 /**
360   * @brief  Disable the CORDIC interrupt
361   * @param  __HANDLE__ CORDIC handle.
362   * @param  __INTERRUPT__ CORDIC Interrupt.
363   *         This parameter can be one of the following values:
364   *            @arg @ref CORDIC_IT_IEN Enable Interrupt
365   * @retval None
366   */
367 #define __HAL_CORDIC_DISABLE_IT(__HANDLE__, __INTERRUPT__)                    \
368   (((__HANDLE__)->Instance->CSR) &= ~(__INTERRUPT__))
369 
370 /** @brief  Check whether the specified CORDIC interrupt occurred or not.
371             Dummy macro as no interrupt status flag.
372   * @param  __HANDLE__ CORDIC handle.
373   * @param  __INTERRUPT__ CORDIC interrupt to check
374   * @retval SET (interrupt occurred) or RESET (interrupt did not occurred)
375   */
376 #define __HAL_CORDIC_GET_IT(__HANDLE__, __INTERRUPT__)     /* Dummy macro */
377 
378 /** @brief  Clear specified CORDIC interrupt status. Dummy macro as no
379             interrupt status flag.
380   * @param  __HANDLE__ CORDIC handle.
381   * @param  __INTERRUPT__ CORDIC interrupt to clear
382   * @retval None
383   */
384 #define __HAL_CORDIC_CLEAR_IT(__HANDLE__, __INTERRUPT__)   /* Dummy macro */
385 
386 /** @brief  Check whether the specified CORDIC status flag is set or not.
387   * @param  __HANDLE__ CORDIC handle.
388   * @param  __FLAG__ CORDIC flag to check
389   *         This parameter can be one of the following values:
390   *            @arg @ref CORDIC_FLAG_RRDY Result Ready Flag
391   * @retval SET (flag is set) or RESET (flag is reset)
392   */
393 #define __HAL_CORDIC_GET_FLAG(__HANDLE__, __FLAG__)                           \
394   ((((__HANDLE__)->Instance->CSR) & (__FLAG__)) == (__FLAG__))
395 
396 /** @brief  Clear specified CORDIC status flag. Dummy macro as no
397             flag can be cleared.
398   * @param  __HANDLE__ CORDIC handle.
399   * @param  __FLAG__ CORDIC flag to clear
400   *         This parameter can be one of the following values:
401   *            @arg @ref CORDIC_FLAG_RRDY Result Ready Flag
402   * @retval None
403   */
404 #define __HAL_CORDIC_CLEAR_FLAG(__HANDLE__, __FLAG__)     /* Dummy macro */
405 
406 /** @brief  Check whether the specified CORDIC interrupt is enabled or not.
407   * @param  __HANDLE__ CORDIC handle.
408   * @param  __INTERRUPT__ CORDIC interrupt to check
409   *         This parameter can be one of the following values:
410   *            @arg @ref CORDIC_IT_IEN Enable Interrupt
411   * @retval FlagStatus
412   */
413 #define __HAL_CORDIC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)                 \
414   (((__HANDLE__)->Instance->CSR) & (__INTERRUPT__))
415 
416 /**
417   * @}
418   */
419 
420 /* Private macros --------------------------------------------------------*/
421 /** @defgroup  CORDIC_Private_Macros   CORDIC Private Macros
422   * @{
423   */
424 
425 /**
426   * @brief  Verify the CORDIC function.
427   * @param  __FUNCTION__ Name of the function.
428   * @retval SET (__FUNCTION__ is a valid value) or RESET (__FUNCTION__ is invalid)
429   */
430 #define IS_CORDIC_FUNCTION(__FUNCTION__) (((__FUNCTION__) == CORDIC_FUNCTION_COSINE)       || \
431                                           ((__FUNCTION__) == CORDIC_FUNCTION_SINE)         || \
432                                           ((__FUNCTION__) == CORDIC_FUNCTION_PHASE)        || \
433                                           ((__FUNCTION__) == CORDIC_FUNCTION_MODULUS)      || \
434                                           ((__FUNCTION__) == CORDIC_FUNCTION_ARCTANGENT)   || \
435                                           ((__FUNCTION__) == CORDIC_FUNCTION_HCOSINE)      || \
436                                           ((__FUNCTION__) == CORDIC_FUNCTION_HSINE)        || \
437                                           ((__FUNCTION__) == CORDIC_FUNCTION_HARCTANGENT)  || \
438                                           ((__FUNCTION__) == CORDIC_FUNCTION_NATURALLOG)   || \
439                                           ((__FUNCTION__) == CORDIC_FUNCTION_SQUAREROOT))
440 
441 
442 /**
443   * @brief  Verify the CORDIC precision.
444   * @param  __PRECISION__ CORDIC Precision in Cycles Number.
445   * @retval SET (__PRECISION__ is a valid value) or RESET (__PRECISION__ is invalid)
446   */
447 #define IS_CORDIC_PRECISION(__PRECISION__) (((__PRECISION__) == CORDIC_PRECISION_1CYCLE)   || \
448                                             ((__PRECISION__) == CORDIC_PRECISION_2CYCLES)  || \
449                                             ((__PRECISION__) == CORDIC_PRECISION_3CYCLES)  || \
450                                             ((__PRECISION__) == CORDIC_PRECISION_4CYCLES)  || \
451                                             ((__PRECISION__) == CORDIC_PRECISION_5CYCLES)  || \
452                                             ((__PRECISION__) == CORDIC_PRECISION_6CYCLES)  || \
453                                             ((__PRECISION__) == CORDIC_PRECISION_7CYCLES)  || \
454                                             ((__PRECISION__) == CORDIC_PRECISION_8CYCLES)  || \
455                                             ((__PRECISION__) == CORDIC_PRECISION_9CYCLES)  || \
456                                             ((__PRECISION__) == CORDIC_PRECISION_10CYCLES) || \
457                                             ((__PRECISION__) == CORDIC_PRECISION_11CYCLES) || \
458                                             ((__PRECISION__) == CORDIC_PRECISION_12CYCLES) || \
459                                             ((__PRECISION__) == CORDIC_PRECISION_13CYCLES) || \
460                                             ((__PRECISION__) == CORDIC_PRECISION_14CYCLES) || \
461                                             ((__PRECISION__) == CORDIC_PRECISION_15CYCLES))
462 
463 /**
464   * @brief  Verify the CORDIC scaling factor.
465   * @param  __SCALE__ Number of cycles for calculation, 1 cycle corresponding to 4 algorithm iterations.
466   * @retval SET (__SCALE__ is a valid value) or RESET (__SCALE__ is invalid)
467   */
468 #define IS_CORDIC_SCALE(__SCALE__) (((__SCALE__) == CORDIC_SCALE_0)  || \
469                                     ((__SCALE__) == CORDIC_SCALE_1)  || \
470                                     ((__SCALE__) == CORDIC_SCALE_2)  || \
471                                     ((__SCALE__) == CORDIC_SCALE_3)  || \
472                                     ((__SCALE__) == CORDIC_SCALE_4)  || \
473                                     ((__SCALE__) == CORDIC_SCALE_5)  || \
474                                     ((__SCALE__) == CORDIC_SCALE_6)  || \
475                                     ((__SCALE__) == CORDIC_SCALE_7))
476 
477 /**
478   * @brief  Verify the CORDIC number of 32-bits write expected for one calculation.
479   * @param  __NBWRITE__ Number of 32-bits write expected for one calculation.
480   * @retval SET (__NBWRITE__ is a valid value) or RESET (__NBWRITE__ is invalid)
481   */
482 #define IS_CORDIC_NBWRITE(__NBWRITE__) (((__NBWRITE__) == CORDIC_NBWRITE_1)  || \
483                                         ((__NBWRITE__) == CORDIC_NBWRITE_2))
484 
485 /**
486   * @brief  Verify the CORDIC number of 32-bits read expected after one calculation.
487   * @param  __NBREAD__ Number of 32-bits read expected after one calculation.
488   * @retval SET (__NBREAD__ is a valid value) or RESET (__NBREAD__ is invalid)
489   */
490 #define IS_CORDIC_NBREAD(__NBREAD__) (((__NBREAD__) == CORDIC_NBREAD_1)  || \
491                                       ((__NBREAD__) == CORDIC_NBREAD_2))
492 
493 /**
494   * @brief  Verify the CORDIC input data size for one calculation.
495   * @param  __INSIZE__ input data size for one calculation.
496   * @retval SET (__INSIZE__ is a valid value) or RESET (__INSIZE__ is invalid)
497   */
498 #define IS_CORDIC_INSIZE(__INSIZE__) (((__INSIZE__) == CORDIC_INSIZE_32BITS)  || \
499                                       ((__INSIZE__) == CORDIC_INSIZE_16BITS))
500 
501 /**
502   * @brief  Verify the CORDIC output data size for one calculation.
503   * @param  __OUTSIZE__ output data size for one calculation.
504   * @retval SET (__OUTSIZE__ is a valid value) or RESET (__OUTSIZE__ is invalid)
505   */
506 #define IS_CORDIC_OUTSIZE(__OUTSIZE__) (((__OUTSIZE__) == CORDIC_OUTSIZE_32BITS)  || \
507                                         ((__OUTSIZE__) == CORDIC_OUTSIZE_16BITS))
508 
509 /**
510   * @brief  Verify the CORDIC DMA transfer Direction.
511   * @param  __DMADIR__ DMA transfer direction.
512   * @retval SET (__DMADIR__ is a valid value) or RESET (__DMADIR__ is invalid)
513   */
514 #define IS_CORDIC_DMA_DIRECTION(__DMADIR__) (((__DMADIR__) == CORDIC_DMA_DIR_IN)  || \
515                                              ((__DMADIR__) == CORDIC_DMA_DIR_OUT) || \
516                                              ((__DMADIR__) == CORDIC_DMA_DIR_IN_OUT))
517 
518 /**
519   * @}
520   */
521 
522 /** @addtogroup CORDIC_Exported_Functions
523   * @{
524   */
525 /* Exported functions ------------------------------------------------------- */
526 
527 /** @addtogroup CORDIC_Exported_Functions_Group1
528   * @{
529   */
530 /* Initialization and de-initialization functions ******************************/
531 HAL_StatusTypeDef HAL_CORDIC_Init(CORDIC_HandleTypeDef *hcordic);
532 HAL_StatusTypeDef HAL_CORDIC_DeInit(CORDIC_HandleTypeDef *hcordic);
533 void HAL_CORDIC_MspInit(CORDIC_HandleTypeDef *hcordic);
534 void HAL_CORDIC_MspDeInit(CORDIC_HandleTypeDef *hcordic);
535 
536 #if USE_HAL_CORDIC_REGISTER_CALLBACKS == 1
537 /* Callbacks Register/UnRegister functions  ***********************************/
538 HAL_StatusTypeDef HAL_CORDIC_RegisterCallback(CORDIC_HandleTypeDef *hcordic, HAL_CORDIC_CallbackIDTypeDef CallbackID,
539                                               pCORDIC_CallbackTypeDef pCallback);
540 HAL_StatusTypeDef HAL_CORDIC_UnRegisterCallback(CORDIC_HandleTypeDef *hcordic, HAL_CORDIC_CallbackIDTypeDef CallbackID);
541 /**
542   * @}
543   */
544 
545 /** @addtogroup CORDIC_Exported_Functions_Group2
546   * @{
547   */
548 #endif /* USE_HAL_CORDIC_REGISTER_CALLBACKS */
549 /* Peripheral Control functions ***********************************************/
550 HAL_StatusTypeDef HAL_CORDIC_Configure(CORDIC_HandleTypeDef *hcordic, CORDIC_ConfigTypeDef *sConfig);
551 HAL_StatusTypeDef HAL_CORDIC_Calculate(CORDIC_HandleTypeDef *hcordic, int32_t *pInBuff, int32_t *pOutBuff,
552                                        uint32_t NbCalc, uint32_t Timeout);
553 HAL_StatusTypeDef HAL_CORDIC_CalculateZO(CORDIC_HandleTypeDef *hcordic, int32_t *pInBuff, int32_t *pOutBuff,
554                                          uint32_t NbCalc, uint32_t Timeout);
555 HAL_StatusTypeDef HAL_CORDIC_Calculate_IT(CORDIC_HandleTypeDef *hcordic, int32_t *pInBuff, int32_t *pOutBuff,
556                                           uint32_t NbCalc);
557 HAL_StatusTypeDef HAL_CORDIC_Calculate_DMA(CORDIC_HandleTypeDef *hcordic, int32_t *pInBuff, int32_t *pOutBuff,
558                                            uint32_t NbCalc, uint32_t DMADirection);
559 /**
560   * @}
561   */
562 
563 /** @addtogroup CORDIC_Exported_Functions_Group3
564   * @{
565   */
566 /* Callback functions *********************************************************/
567 void HAL_CORDIC_ErrorCallback(CORDIC_HandleTypeDef *hcordic);
568 void HAL_CORDIC_CalculateCpltCallback(CORDIC_HandleTypeDef *hcordic);
569 /**
570   * @}
571   */
572 
573 /** @addtogroup CORDIC_Exported_Functions_Group4
574   * @{
575   */
576 /* IRQ handler management *****************************************************/
577 void HAL_CORDIC_IRQHandler(CORDIC_HandleTypeDef *hcordic);
578 /**
579   * @}
580   */
581 
582 /** @addtogroup CORDIC_Exported_Functions_Group5
583   * @{
584   */
585 /* Peripheral State functions *************************************************/
586 HAL_CORDIC_StateTypeDef HAL_CORDIC_GetState(CORDIC_HandleTypeDef *hcordic);
587 uint32_t HAL_CORDIC_GetError(CORDIC_HandleTypeDef *hcordic);
588 /**
589   * @}
590   */
591 
592 /**
593   * @}
594   */
595 
596 /**
597   * @}
598   */
599 
600 /**
601   * @}
602   */
603 
604 #endif /* CORDIC */
605 
606 #ifdef __cplusplus
607 }
608 #endif
609 
610 #endif /* STM32H7xx_HAL_CORDIC_H */
611 
612 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
613