STM32H735xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32h7xx_hal_cordic.h 00004 * @author MCD Application Team 00005 * @brief This file contains all the functions prototypes for the CORDIC firmware 00006 * library. 00007 ****************************************************************************** 00008 * @attention 00009 * 00010 * Copyright (c) 2017 STMicroelectronics. 00011 * All rights reserved. 00012 * 00013 * This software is licensed under terms that can be found in the LICENSE file 00014 * in the root directory of this software component. 00015 * If no LICENSE file comes with this software, it is provided AS-IS. 00016 * 00017 ****************************************************************************** 00018 */ 00019 00020 /* Define to prevent recursive inclusion -------------------------------------*/ 00021 #ifndef STM32H7xx_HAL_CORDIC_H 00022 #define STM32H7xx_HAL_CORDIC_H 00023 00024 #ifdef __cplusplus 00025 extern "C" { 00026 #endif 00027 00028 /* Includes ------------------------------------------------------------------*/ 00029 #include "stm32h7xx_hal_def.h" 00030 00031 #if defined(CORDIC) 00032 /** @addtogroup STM32H7xx_HAL_Driver 00033 * @{ 00034 */ 00035 00036 /** @addtogroup CORDIC 00037 * @{ 00038 */ 00039 00040 /* Exported types ------------------------------------------------------------*/ 00041 /** @defgroup CORDIC_Exported_Types CORDIC Exported Types 00042 * @{ 00043 */ 00044 00045 /** 00046 * @brief CORDIC HAL State Structure definition 00047 */ 00048 typedef enum 00049 { 00050 HAL_CORDIC_STATE_RESET = 0x00U, /*!< CORDIC not yet initialized or disabled */ 00051 HAL_CORDIC_STATE_READY = 0x01U, /*!< CORDIC initialized and ready for use */ 00052 HAL_CORDIC_STATE_BUSY = 0x02U, /*!< CORDIC internal process is ongoing */ 00053 HAL_CORDIC_STATE_ERROR = 0x03U /*!< CORDIC error state */ 00054 } HAL_CORDIC_StateTypeDef; 00055 00056 /** 00057 * @brief CORDIC Handle Structure definition 00058 */ 00059 #if USE_HAL_CORDIC_REGISTER_CALLBACKS == 1 00060 typedef struct __CORDIC_HandleTypeDef 00061 #else 00062 typedef struct 00063 #endif /* USE_HAL_CORDIC_REGISTER_CALLBACKS */ 00064 { 00065 CORDIC_TypeDef *Instance; /*!< Register base address */ 00066 00067 int32_t *pInBuff; /*!< Pointer to CORDIC input data buffer */ 00068 00069 int32_t *pOutBuff; /*!< Pointer to CORDIC output data buffer */ 00070 00071 uint32_t NbCalcToOrder; /*!< Remaining number of calculation to order */ 00072 00073 uint32_t NbCalcToGet; /*!< Remaining number of calculation result to get */ 00074 00075 uint32_t DMADirection; /*!< Direction of CORDIC DMA transfers */ 00076 00077 DMA_HandleTypeDef *hdmaIn; /*!< CORDIC peripheral input data DMA handle parameters */ 00078 00079 DMA_HandleTypeDef *hdmaOut; /*!< CORDIC peripheral output data DMA handle parameters */ 00080 00081 HAL_LockTypeDef Lock; /*!< CORDIC locking object */ 00082 00083 __IO HAL_CORDIC_StateTypeDef State; /*!< CORDIC state */ 00084 00085 __IO uint32_t ErrorCode; /*!< CORDIC peripheral error code 00086 This parameter can be a value of @ref CORDIC_Error_Code */ 00087 00088 #if USE_HAL_CORDIC_REGISTER_CALLBACKS == 1 00089 void (* ErrorCallback)(struct __CORDIC_HandleTypeDef *hcordic); /*!< CORDIC error callback */ 00090 void (* CalculateCpltCallback)(struct __CORDIC_HandleTypeDef *hcordic); /*!< CORDIC calculate complete callback */ 00091 00092 void (* MspInitCallback)(struct __CORDIC_HandleTypeDef *hcordic); /*!< CORDIC Msp Init callback */ 00093 void (* MspDeInitCallback)(struct __CORDIC_HandleTypeDef *hcordic); /*!< CORDIC Msp DeInit callback */ 00094 00095 #endif /* (USE_HAL_CORDIC_REGISTER_CALLBACKS) */ 00096 00097 } CORDIC_HandleTypeDef; 00098 00099 /** 00100 * @brief CORDIC Config Structure definition 00101 */ 00102 typedef struct 00103 { 00104 uint32_t Function; /*!< Function 00105 This parameter can be a value of @ref CORDIC_Function */ 00106 00107 uint32_t Scale; /*!< Scaling factor 00108 This parameter can be a value of @ref CORDIC_Scale */ 00109 00110 uint32_t InSize; /*!< Width of input data 00111 This parameter can be a value of @ref CORDIC_In_Size */ 00112 00113 uint32_t OutSize; /*!< Width of output data 00114 This parameter can be a value of @ref CORDIC_Out_Size */ 00115 00116 uint32_t NbWrite; /*!< Number of 32-bit write expected for one calculation 00117 This parameter can be a value of @ref CORDIC_Nb_Write */ 00118 00119 uint32_t NbRead; /*!< Number of 32-bit read expected after one calculation 00120 This parameter can be a value of @ref CORDIC_Nb_Read */ 00121 00122 uint32_t Precision; /*!< Number of cycles for calculation 00123 This parameter can be a value of @ref CORDIC_Precision_In_Cycles_Number */ 00124 00125 } CORDIC_ConfigTypeDef; 00126 00127 #if USE_HAL_CORDIC_REGISTER_CALLBACKS == 1 00128 /** 00129 * @brief HAL CORDIC Callback ID enumeration definition 00130 */ 00131 typedef enum 00132 { 00133 HAL_CORDIC_ERROR_CB_ID = 0x00U, /*!< CORDIC error callback ID */ 00134 HAL_CORDIC_CALCULATE_CPLT_CB_ID = 0x01U, /*!< CORDIC calculate complete callback ID */ 00135 00136 HAL_CORDIC_MSPINIT_CB_ID = 0x02U, /*!< CORDIC MspInit callback ID */ 00137 HAL_CORDIC_MSPDEINIT_CB_ID = 0x03U, /*!< CORDIC MspDeInit callback ID */ 00138 00139 } HAL_CORDIC_CallbackIDTypeDef; 00140 00141 /** 00142 * @brief HAL CORDIC Callback pointer definition 00143 */ 00144 typedef void (*pCORDIC_CallbackTypeDef)(CORDIC_HandleTypeDef *hcordic); /*!< pointer to a CORDIC callback function */ 00145 00146 #endif /* USE_HAL_CORDIC_REGISTER_CALLBACKS */ 00147 00148 /** 00149 * @} 00150 */ 00151 00152 00153 /* Exported constants --------------------------------------------------------*/ 00154 /** @defgroup CORDIC_Exported_Constants CORDIC Exported Constants 00155 * @{ 00156 */ 00157 00158 /** @defgroup CORDIC_Error_Code CORDIC Error code 00159 * @{ 00160 */ 00161 #define HAL_CORDIC_ERROR_NONE ((uint32_t)0x00000000U) /*!< No error */ 00162 #define HAL_CORDIC_ERROR_PARAM ((uint32_t)0x00000001U) /*!< Wrong parameter error */ 00163 #define HAL_CORDIC_ERROR_NOT_READY ((uint32_t)0x00000002U) /*!< Peripheral not ready */ 00164 #define HAL_CORDIC_ERROR_TIMEOUT ((uint32_t)0x00000004U) /*!< Timeout error */ 00165 #define HAL_CORDIC_ERROR_DMA ((uint32_t)0x00000008U) /*!< DMA error */ 00166 #if USE_HAL_CORDIC_REGISTER_CALLBACKS == 1 00167 #define HAL_CORDIC_ERROR_INVALID_CALLBACK ((uint32_t)0x00000010U) /*!< Invalid Callback error */ 00168 #endif /* USE_HAL_CORDIC_REGISTER_CALLBACKS */ 00169 /** 00170 * @} 00171 */ 00172 00173 /** @defgroup CORDIC_Function CORDIC Function 00174 * @{ 00175 */ 00176 #define CORDIC_FUNCTION_COSINE (0x00000000U) /*!< Cosine */ 00177 #define CORDIC_FUNCTION_SINE ((uint32_t)(CORDIC_CSR_FUNC_0)) /*!< Sine */ 00178 #define CORDIC_FUNCTION_PHASE ((uint32_t)(CORDIC_CSR_FUNC_1)) /*!< Phase */ 00179 #define CORDIC_FUNCTION_MODULUS ((uint32_t)(CORDIC_CSR_FUNC_1 | CORDIC_CSR_FUNC_0)) /*!< Modulus */ 00180 #define CORDIC_FUNCTION_ARCTANGENT ((uint32_t)(CORDIC_CSR_FUNC_2)) /*!< Arctangent */ 00181 #define CORDIC_FUNCTION_HCOSINE ((uint32_t)(CORDIC_CSR_FUNC_2 | CORDIC_CSR_FUNC_0)) /*!< Hyperbolic Cosine */ 00182 #define CORDIC_FUNCTION_HSINE ((uint32_t)(CORDIC_CSR_FUNC_2 | CORDIC_CSR_FUNC_1)) /*!< Hyperbolic Sine */ 00183 #define CORDIC_FUNCTION_HARCTANGENT ((uint32_t)(CORDIC_CSR_FUNC_2 | CORDIC_CSR_FUNC_1 | CORDIC_CSR_FUNC_0))/*!< Hyperbolic Arctangent */ 00184 #define CORDIC_FUNCTION_NATURALLOG ((uint32_t)(CORDIC_CSR_FUNC_3)) /*!< Natural Logarithm */ 00185 #define CORDIC_FUNCTION_SQUAREROOT ((uint32_t)(CORDIC_CSR_FUNC_3 | CORDIC_CSR_FUNC_0)) /*!< Square Root */ 00186 /** 00187 * @} 00188 */ 00189 00190 /** @defgroup CORDIC_Precision_In_Cycles_Number CORDIC Precision in Cycles Number 00191 * @{ 00192 */ 00193 /* Note: 1 cycle corresponds to 4 algorithm iterations */ 00194 #define CORDIC_PRECISION_1CYCLE ((uint32_t)(CORDIC_CSR_PRECISION_0)) 00195 #define CORDIC_PRECISION_2CYCLES ((uint32_t)(CORDIC_CSR_PRECISION_1)) 00196 #define CORDIC_PRECISION_3CYCLES ((uint32_t)(CORDIC_CSR_PRECISION_1 | CORDIC_CSR_PRECISION_0)) 00197 #define CORDIC_PRECISION_4CYCLES ((uint32_t)(CORDIC_CSR_PRECISION_2)) 00198 #define CORDIC_PRECISION_5CYCLES ((uint32_t)(CORDIC_CSR_PRECISION_2 | CORDIC_CSR_PRECISION_0)) 00199 #define CORDIC_PRECISION_6CYCLES ((uint32_t)(CORDIC_CSR_PRECISION_2 | CORDIC_CSR_PRECISION_1)) 00200 #define CORDIC_PRECISION_7CYCLES ((uint32_t)(CORDIC_CSR_PRECISION_2\ 00201 | CORDIC_CSR_PRECISION_1 | CORDIC_CSR_PRECISION_0)) 00202 #define CORDIC_PRECISION_8CYCLES ((uint32_t)(CORDIC_CSR_PRECISION_3)) 00203 #define CORDIC_PRECISION_9CYCLES ((uint32_t)(CORDIC_CSR_PRECISION_3 | CORDIC_CSR_PRECISION_0)) 00204 #define CORDIC_PRECISION_10CYCLES ((uint32_t)(CORDIC_CSR_PRECISION_3 | CORDIC_CSR_PRECISION_1)) 00205 #define CORDIC_PRECISION_11CYCLES ((uint32_t)(CORDIC_CSR_PRECISION_3\ 00206 | CORDIC_CSR_PRECISION_1 | CORDIC_CSR_PRECISION_0)) 00207 #define CORDIC_PRECISION_12CYCLES ((uint32_t)(CORDIC_CSR_PRECISION_3 | CORDIC_CSR_PRECISION_2)) 00208 #define CORDIC_PRECISION_13CYCLES ((uint32_t)(CORDIC_CSR_PRECISION_3\ 00209 | CORDIC_CSR_PRECISION_2 | CORDIC_CSR_PRECISION_0)) 00210 #define CORDIC_PRECISION_14CYCLES ((uint32_t)(CORDIC_CSR_PRECISION_3\ 00211 | CORDIC_CSR_PRECISION_2 | CORDIC_CSR_PRECISION_1)) 00212 #define CORDIC_PRECISION_15CYCLES ((uint32_t)(CORDIC_CSR_PRECISION_3\ 00213 | CORDIC_CSR_PRECISION_2 | CORDIC_CSR_PRECISION_1\ 00214 |CORDIC_CSR_PRECISION_0)) 00215 /** 00216 * @} 00217 */ 00218 00219 /** @defgroup CORDIC_Scale CORDIC Scaling factor 00220 * @{ 00221 */ 00222 /* Scale factor value 'n' implies that the input data have been multiplied 00223 by a factor 2exp(-n), and/or the output data need to be multiplied by 2exp(n). */ 00224 #define CORDIC_SCALE_0 (0x00000000U) 00225 #define CORDIC_SCALE_1 ((uint32_t)(CORDIC_CSR_SCALE_0)) 00226 #define CORDIC_SCALE_2 ((uint32_t)(CORDIC_CSR_SCALE_1)) 00227 #define CORDIC_SCALE_3 ((uint32_t)(CORDIC_CSR_SCALE_1 | CORDIC_CSR_SCALE_0)) 00228 #define CORDIC_SCALE_4 ((uint32_t)(CORDIC_CSR_SCALE_2)) 00229 #define CORDIC_SCALE_5 ((uint32_t)(CORDIC_CSR_SCALE_2 | CORDIC_CSR_SCALE_0)) 00230 #define CORDIC_SCALE_6 ((uint32_t)(CORDIC_CSR_SCALE_2 | CORDIC_CSR_SCALE_1)) 00231 #define CORDIC_SCALE_7 ((uint32_t)(CORDIC_CSR_SCALE_2 | CORDIC_CSR_SCALE_1 | CORDIC_CSR_SCALE_0)) 00232 /** 00233 * @} 00234 */ 00235 00236 /** @defgroup CORDIC_Interrupts_Enable CORDIC Interrupts Enable bit 00237 * @{ 00238 */ 00239 #define CORDIC_IT_IEN CORDIC_CSR_IEN /*!< Result ready interrupt enable */ 00240 /** 00241 * @} 00242 */ 00243 00244 /** @defgroup CORDIC_DMAR DMA Read Request Enable bit 00245 * @{ 00246 */ 00247 #define CORDIC_DMA_REN CORDIC_CSR_DMAREN /*!< DMA Read requests enable */ 00248 /** 00249 * @} 00250 */ 00251 00252 /** @defgroup CORDIC_DMAW DMA Write Request Enable bit 00253 * @{ 00254 */ 00255 #define CORDIC_DMA_WEN CORDIC_CSR_DMAWEN /*!< DMA Write channel enable */ 00256 /** 00257 * @} 00258 */ 00259 00260 /** @defgroup CORDIC_Nb_Write CORDIC Number of 32-bit write required for one calculation 00261 * @{ 00262 */ 00263 #define CORDIC_NBWRITE_1 (0x00000000U) /*!< One 32-bits write containing either only one 00264 32-bit data input (Q1.31 format), or two 16-bit 00265 data input (Q1.15 format) packed in one 32 bits 00266 Data */ 00267 #define CORDIC_NBWRITE_2 CORDIC_CSR_NARGS /*!< Two 32-bit write containing two 32-bits data input 00268 (Q1.31 format) */ 00269 /** 00270 * @} 00271 */ 00272 00273 /** @defgroup CORDIC_Nb_Read CORDIC Number of 32-bit read required after one calculation 00274 * @{ 00275 */ 00276 #define CORDIC_NBREAD_1 (0x00000000U) /*!< One 32-bits read containing either only one 00277 32-bit data output (Q1.31 format), or two 16-bit 00278 data output (Q1.15 format) packed in one 32 bits 00279 Data */ 00280 #define CORDIC_NBREAD_2 CORDIC_CSR_NRES /*!< Two 32-bit Data containing two 32-bits data output 00281 (Q1.31 format) */ 00282 /** 00283 * @} 00284 */ 00285 00286 /** @defgroup CORDIC_In_Size CORDIC input data size 00287 * @{ 00288 */ 00289 #define CORDIC_INSIZE_32BITS (0x00000000U) /*!< 32 bits input data size (Q1.31 format) */ 00290 #define CORDIC_INSIZE_16BITS CORDIC_CSR_ARGSIZE /*!< 16 bits input data size (Q1.15 format) */ 00291 /** 00292 * @} 00293 */ 00294 00295 /** @defgroup CORDIC_Out_Size CORDIC Results Size 00296 * @{ 00297 */ 00298 #define CORDIC_OUTSIZE_32BITS (0x00000000U) /*!< 32 bits output data size (Q1.31 format) */ 00299 #define CORDIC_OUTSIZE_16BITS CORDIC_CSR_RESSIZE /*!< 16 bits output data size (Q1.15 format) */ 00300 /** 00301 * @} 00302 */ 00303 00304 /** @defgroup CORDIC_Flags CORDIC status flags 00305 * @{ 00306 */ 00307 #define CORDIC_FLAG_RRDY CORDIC_CSR_RRDY /*!< Result Ready Flag */ 00308 /** 00309 * @} 00310 */ 00311 00312 /** @defgroup CORDIC_DMA_Direction CORDIC DMA direction 00313 * @{ 00314 */ 00315 #define CORDIC_DMA_DIR_NONE ((uint32_t)0x00000000U) /*!< DMA direction : none */ 00316 #define CORDIC_DMA_DIR_IN ((uint32_t)0x00000001U) /*!< DMA direction : Input of CORDIC */ 00317 #define CORDIC_DMA_DIR_OUT ((uint32_t)0x00000002U) /*!< DMA direction : Output of CORDIC */ 00318 #define CORDIC_DMA_DIR_IN_OUT ((uint32_t)0x00000003U) /*!< DMA direction : Input and Output of CORDIC */ 00319 /** 00320 * @} 00321 */ 00322 00323 /** 00324 * @} 00325 */ 00326 00327 00328 /* Exported macro ------------------------------------------------------------*/ 00329 /** @defgroup CORDIC_Exported_Macros CORDIC Exported Macros 00330 * @{ 00331 */ 00332 00333 /** @brief Reset CORDIC handle state. 00334 * @param __HANDLE__ CORDIC handle 00335 * @retval None 00336 */ 00337 #if USE_HAL_CORDIC_REGISTER_CALLBACKS == 1 00338 #define __HAL_CORDIC_RESET_HANDLE_STATE(__HANDLE__) do{ \ 00339 (__HANDLE__)->State = HAL_CORDIC_STATE_RESET; \ 00340 (__HANDLE__)->MspInitCallback = NULL; \ 00341 (__HANDLE__)->MspDeInitCallback = NULL; \ 00342 } while(0) 00343 #else 00344 #define __HAL_CORDIC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CORDIC_STATE_RESET) 00345 #endif /*USE_HAL_CORDIC_REGISTER_CALLBACKS */ 00346 00347 /** 00348 * @brief Enable the CORDIC interrupt when result is ready 00349 * @param __HANDLE__ CORDIC handle. 00350 * @param __INTERRUPT__ CORDIC Interrupt. 00351 * This parameter can be one of the following values: 00352 * @arg @ref CORDIC_IT_IEN Enable Interrupt 00353 * @retval None 00354 */ 00355 #define __HAL_CORDIC_ENABLE_IT(__HANDLE__, __INTERRUPT__) \ 00356 (((__HANDLE__)->Instance->CSR) |= (__INTERRUPT__)) 00357 00358 /** 00359 * @brief Disable the CORDIC interrupt 00360 * @param __HANDLE__ CORDIC handle. 00361 * @param __INTERRUPT__ CORDIC Interrupt. 00362 * This parameter can be one of the following values: 00363 * @arg @ref CORDIC_IT_IEN Enable Interrupt 00364 * @retval None 00365 */ 00366 #define __HAL_CORDIC_DISABLE_IT(__HANDLE__, __INTERRUPT__) \ 00367 (((__HANDLE__)->Instance->CSR) &= ~(__INTERRUPT__)) 00368 00369 /** @brief Check whether the specified CORDIC interrupt occurred or not. 00370 Dummy macro as no interrupt status flag. 00371 * @param __HANDLE__ CORDIC handle. 00372 * @param __INTERRUPT__ CORDIC interrupt to check 00373 * @retval SET (interrupt occurred) or RESET (interrupt did not occurred) 00374 */ 00375 #define __HAL_CORDIC_GET_IT(__HANDLE__, __INTERRUPT__) /* Dummy macro */ 00376 00377 /** @brief Clear specified CORDIC interrupt status. Dummy macro as no 00378 interrupt status flag. 00379 * @param __HANDLE__ CORDIC handle. 00380 * @param __INTERRUPT__ CORDIC interrupt to clear 00381 * @retval None 00382 */ 00383 #define __HAL_CORDIC_CLEAR_IT(__HANDLE__, __INTERRUPT__) /* Dummy macro */ 00384 00385 /** @brief Check whether the specified CORDIC status flag is set or not. 00386 * @param __HANDLE__ CORDIC handle. 00387 * @param __FLAG__ CORDIC flag to check 00388 * This parameter can be one of the following values: 00389 * @arg @ref CORDIC_FLAG_RRDY Result Ready Flag 00390 * @retval SET (flag is set) or RESET (flag is reset) 00391 */ 00392 #define __HAL_CORDIC_GET_FLAG(__HANDLE__, __FLAG__) \ 00393 ((((__HANDLE__)->Instance->CSR) & (__FLAG__)) == (__FLAG__)) 00394 00395 /** @brief Clear specified CORDIC status flag. Dummy macro as no 00396 flag can be cleared. 00397 * @param __HANDLE__ CORDIC handle. 00398 * @param __FLAG__ CORDIC flag to clear 00399 * This parameter can be one of the following values: 00400 * @arg @ref CORDIC_FLAG_RRDY Result Ready Flag 00401 * @retval None 00402 */ 00403 #define __HAL_CORDIC_CLEAR_FLAG(__HANDLE__, __FLAG__) /* Dummy macro */ 00404 00405 /** @brief Check whether the specified CORDIC interrupt is enabled or not. 00406 * @param __HANDLE__ CORDIC handle. 00407 * @param __INTERRUPT__ CORDIC interrupt to check 00408 * This parameter can be one of the following values: 00409 * @arg @ref CORDIC_IT_IEN Enable Interrupt 00410 * @retval FlagStatus 00411 */ 00412 #define __HAL_CORDIC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) \ 00413 (((__HANDLE__)->Instance->CSR) & (__INTERRUPT__)) 00414 00415 /** 00416 * @} 00417 */ 00418 00419 /* Private macros --------------------------------------------------------*/ 00420 /** @defgroup CORDIC_Private_Macros CORDIC Private Macros 00421 * @{ 00422 */ 00423 00424 /** 00425 * @brief Verify the CORDIC function. 00426 * @param __FUNCTION__ Name of the function. 00427 * @retval SET (__FUNCTION__ is a valid value) or RESET (__FUNCTION__ is invalid) 00428 */ 00429 #define IS_CORDIC_FUNCTION(__FUNCTION__) (((__FUNCTION__) == CORDIC_FUNCTION_COSINE) || \ 00430 ((__FUNCTION__) == CORDIC_FUNCTION_SINE) || \ 00431 ((__FUNCTION__) == CORDIC_FUNCTION_PHASE) || \ 00432 ((__FUNCTION__) == CORDIC_FUNCTION_MODULUS) || \ 00433 ((__FUNCTION__) == CORDIC_FUNCTION_ARCTANGENT) || \ 00434 ((__FUNCTION__) == CORDIC_FUNCTION_HCOSINE) || \ 00435 ((__FUNCTION__) == CORDIC_FUNCTION_HSINE) || \ 00436 ((__FUNCTION__) == CORDIC_FUNCTION_HARCTANGENT) || \ 00437 ((__FUNCTION__) == CORDIC_FUNCTION_NATURALLOG) || \ 00438 ((__FUNCTION__) == CORDIC_FUNCTION_SQUAREROOT)) 00439 00440 00441 /** 00442 * @brief Verify the CORDIC precision. 00443 * @param __PRECISION__ CORDIC Precision in Cycles Number. 00444 * @retval SET (__PRECISION__ is a valid value) or RESET (__PRECISION__ is invalid) 00445 */ 00446 #define IS_CORDIC_PRECISION(__PRECISION__) (((__PRECISION__) == CORDIC_PRECISION_1CYCLE) || \ 00447 ((__PRECISION__) == CORDIC_PRECISION_2CYCLES) || \ 00448 ((__PRECISION__) == CORDIC_PRECISION_3CYCLES) || \ 00449 ((__PRECISION__) == CORDIC_PRECISION_4CYCLES) || \ 00450 ((__PRECISION__) == CORDIC_PRECISION_5CYCLES) || \ 00451 ((__PRECISION__) == CORDIC_PRECISION_6CYCLES) || \ 00452 ((__PRECISION__) == CORDIC_PRECISION_7CYCLES) || \ 00453 ((__PRECISION__) == CORDIC_PRECISION_8CYCLES) || \ 00454 ((__PRECISION__) == CORDIC_PRECISION_9CYCLES) || \ 00455 ((__PRECISION__) == CORDIC_PRECISION_10CYCLES) || \ 00456 ((__PRECISION__) == CORDIC_PRECISION_11CYCLES) || \ 00457 ((__PRECISION__) == CORDIC_PRECISION_12CYCLES) || \ 00458 ((__PRECISION__) == CORDIC_PRECISION_13CYCLES) || \ 00459 ((__PRECISION__) == CORDIC_PRECISION_14CYCLES) || \ 00460 ((__PRECISION__) == CORDIC_PRECISION_15CYCLES)) 00461 00462 /** 00463 * @brief Verify the CORDIC scaling factor. 00464 * @param __SCALE__ Number of cycles for calculation, 1 cycle corresponding to 4 algorithm iterations. 00465 * @retval SET (__SCALE__ is a valid value) or RESET (__SCALE__ is invalid) 00466 */ 00467 #define IS_CORDIC_SCALE(__SCALE__) (((__SCALE__) == CORDIC_SCALE_0) || \ 00468 ((__SCALE__) == CORDIC_SCALE_1) || \ 00469 ((__SCALE__) == CORDIC_SCALE_2) || \ 00470 ((__SCALE__) == CORDIC_SCALE_3) || \ 00471 ((__SCALE__) == CORDIC_SCALE_4) || \ 00472 ((__SCALE__) == CORDIC_SCALE_5) || \ 00473 ((__SCALE__) == CORDIC_SCALE_6) || \ 00474 ((__SCALE__) == CORDIC_SCALE_7)) 00475 00476 /** 00477 * @brief Verify the CORDIC number of 32-bits write expected for one calculation. 00478 * @param __NBWRITE__ Number of 32-bits write expected for one calculation. 00479 * @retval SET (__NBWRITE__ is a valid value) or RESET (__NBWRITE__ is invalid) 00480 */ 00481 #define IS_CORDIC_NBWRITE(__NBWRITE__) (((__NBWRITE__) == CORDIC_NBWRITE_1) || \ 00482 ((__NBWRITE__) == CORDIC_NBWRITE_2)) 00483 00484 /** 00485 * @brief Verify the CORDIC number of 32-bits read expected after one calculation. 00486 * @param __NBREAD__ Number of 32-bits read expected after one calculation. 00487 * @retval SET (__NBREAD__ is a valid value) or RESET (__NBREAD__ is invalid) 00488 */ 00489 #define IS_CORDIC_NBREAD(__NBREAD__) (((__NBREAD__) == CORDIC_NBREAD_1) || \ 00490 ((__NBREAD__) == CORDIC_NBREAD_2)) 00491 00492 /** 00493 * @brief Verify the CORDIC input data size for one calculation. 00494 * @param __INSIZE__ input data size for one calculation. 00495 * @retval SET (__INSIZE__ is a valid value) or RESET (__INSIZE__ is invalid) 00496 */ 00497 #define IS_CORDIC_INSIZE(__INSIZE__) (((__INSIZE__) == CORDIC_INSIZE_32BITS) || \ 00498 ((__INSIZE__) == CORDIC_INSIZE_16BITS)) 00499 00500 /** 00501 * @brief Verify the CORDIC output data size for one calculation. 00502 * @param __OUTSIZE__ output data size for one calculation. 00503 * @retval SET (__OUTSIZE__ is a valid value) or RESET (__OUTSIZE__ is invalid) 00504 */ 00505 #define IS_CORDIC_OUTSIZE(__OUTSIZE__) (((__OUTSIZE__) == CORDIC_OUTSIZE_32BITS) || \ 00506 ((__OUTSIZE__) == CORDIC_OUTSIZE_16BITS)) 00507 00508 /** 00509 * @brief Verify the CORDIC DMA transfer Direction. 00510 * @param __DMADIR__ DMA transfer direction. 00511 * @retval SET (__DMADIR__ is a valid value) or RESET (__DMADIR__ is invalid) 00512 */ 00513 #define IS_CORDIC_DMA_DIRECTION(__DMADIR__) (((__DMADIR__) == CORDIC_DMA_DIR_IN) || \ 00514 ((__DMADIR__) == CORDIC_DMA_DIR_OUT) || \ 00515 ((__DMADIR__) == CORDIC_DMA_DIR_IN_OUT)) 00516 00517 /** 00518 * @} 00519 */ 00520 00521 /** @addtogroup CORDIC_Exported_Functions 00522 * @{ 00523 */ 00524 /* Exported functions ------------------------------------------------------- */ 00525 00526 /** @addtogroup CORDIC_Exported_Functions_Group1 00527 * @{ 00528 */ 00529 /* Initialization and de-initialization functions ******************************/ 00530 HAL_StatusTypeDef HAL_CORDIC_Init(CORDIC_HandleTypeDef *hcordic); 00531 HAL_StatusTypeDef HAL_CORDIC_DeInit(CORDIC_HandleTypeDef *hcordic); 00532 void HAL_CORDIC_MspInit(CORDIC_HandleTypeDef *hcordic); 00533 void HAL_CORDIC_MspDeInit(CORDIC_HandleTypeDef *hcordic); 00534 00535 #if USE_HAL_CORDIC_REGISTER_CALLBACKS == 1 00536 /* Callbacks Register/UnRegister functions ***********************************/ 00537 HAL_StatusTypeDef HAL_CORDIC_RegisterCallback(CORDIC_HandleTypeDef *hcordic, HAL_CORDIC_CallbackIDTypeDef CallbackID, 00538 pCORDIC_CallbackTypeDef pCallback); 00539 HAL_StatusTypeDef HAL_CORDIC_UnRegisterCallback(CORDIC_HandleTypeDef *hcordic, HAL_CORDIC_CallbackIDTypeDef CallbackID); 00540 /** 00541 * @} 00542 */ 00543 00544 /** @addtogroup CORDIC_Exported_Functions_Group2 00545 * @{ 00546 */ 00547 #endif /* USE_HAL_CORDIC_REGISTER_CALLBACKS */ 00548 /* Peripheral Control functions ***********************************************/ 00549 HAL_StatusTypeDef HAL_CORDIC_Configure(CORDIC_HandleTypeDef *hcordic, CORDIC_ConfigTypeDef *sConfig); 00550 HAL_StatusTypeDef HAL_CORDIC_Calculate(CORDIC_HandleTypeDef *hcordic, int32_t *pInBuff, int32_t *pOutBuff, 00551 uint32_t NbCalc, uint32_t Timeout); 00552 HAL_StatusTypeDef HAL_CORDIC_CalculateZO(CORDIC_HandleTypeDef *hcordic, int32_t *pInBuff, int32_t *pOutBuff, 00553 uint32_t NbCalc, uint32_t Timeout); 00554 HAL_StatusTypeDef HAL_CORDIC_Calculate_IT(CORDIC_HandleTypeDef *hcordic, int32_t *pInBuff, int32_t *pOutBuff, 00555 uint32_t NbCalc); 00556 HAL_StatusTypeDef HAL_CORDIC_Calculate_DMA(CORDIC_HandleTypeDef *hcordic, int32_t *pInBuff, int32_t *pOutBuff, 00557 uint32_t NbCalc, uint32_t DMADirection); 00558 /** 00559 * @} 00560 */ 00561 00562 /** @addtogroup CORDIC_Exported_Functions_Group3 00563 * @{ 00564 */ 00565 /* Callback functions *********************************************************/ 00566 void HAL_CORDIC_ErrorCallback(CORDIC_HandleTypeDef *hcordic); 00567 void HAL_CORDIC_CalculateCpltCallback(CORDIC_HandleTypeDef *hcordic); 00568 /** 00569 * @} 00570 */ 00571 00572 /** @addtogroup CORDIC_Exported_Functions_Group4 00573 * @{ 00574 */ 00575 /* IRQ handler management *****************************************************/ 00576 void HAL_CORDIC_IRQHandler(CORDIC_HandleTypeDef *hcordic); 00577 /** 00578 * @} 00579 */ 00580 00581 /** @addtogroup CORDIC_Exported_Functions_Group5 00582 * @{ 00583 */ 00584 /* Peripheral State functions *************************************************/ 00585 HAL_CORDIC_StateTypeDef HAL_CORDIC_GetState(CORDIC_HandleTypeDef *hcordic); 00586 uint32_t HAL_CORDIC_GetError(CORDIC_HandleTypeDef *hcordic); 00587 /** 00588 * @} 00589 */ 00590 00591 /** 00592 * @} 00593 */ 00594 00595 /** 00596 * @} 00597 */ 00598 00599 /** 00600 * @} 00601 */ 00602 00603 #endif /* CORDIC */ 00604 00605 #ifdef __cplusplus 00606 } 00607 #endif 00608 00609 #endif /* STM32H7xx_HAL_CORDIC_H */