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