![]() |
|
|||
File indexing completed on 2025-05-11 08:23:37
0001 /** 0002 ****************************************************************************** 0003 * @file stm32h7xx_ll_cordic.h 0004 * @author MCD Application Team 0005 * @brief Header file of CORDIC LL module. 0006 ****************************************************************************** 0007 * @attention 0008 * 0009 * Copyright (c) 2017 STMicroelectronics. 0010 * All rights reserved. 0011 * 0012 * This software is licensed under terms that can be found in the LICENSE file 0013 * in the root directory of this software component. 0014 * If no LICENSE file comes with this software, it is provided AS-IS. 0015 * 0016 ****************************************************************************** 0017 */ 0018 0019 /* Define to prevent recursive inclusion -------------------------------------*/ 0020 #ifndef STM32H7xx_LL_CORDIC_H 0021 #define STM32H7xx_LL_CORDIC_H 0022 0023 #ifdef __cplusplus 0024 extern "C" { 0025 #endif 0026 0027 /* Includes ------------------------------------------------------------------*/ 0028 #include "stm32h7xx.h" 0029 0030 /** @addtogroup STM32H7xx_LL_Driver 0031 * @{ 0032 */ 0033 0034 #if defined(CORDIC) 0035 0036 /** @defgroup CORDIC_LL CORDIC 0037 * @ingroup RTEMSBSPsARMSTM32H7 0038 * @{ 0039 */ 0040 0041 /* Private variables ---------------------------------------------------------*/ 0042 0043 /* Private constants ---------------------------------------------------------*/ 0044 0045 /* Private macros ------------------------------------------------------------*/ 0046 0047 /* Exported types ------------------------------------------------------------*/ 0048 0049 /* Exported constants --------------------------------------------------------*/ 0050 /** @defgroup CORDIC_LL_Exported_Constants CORDIC Exported Constants 0051 * @ingroup RTEMSBSPsARMSTM32H7 0052 * @{ 0053 */ 0054 0055 /** @defgroup CORDIC_LL_EC_GET_FLAG Get Flags Defines 0056 * @ingroup RTEMSBSPsARMSTM32H7 0057 * @brief Flags defines which can be used with LL_CORDIC_ReadReg function. 0058 * @{ 0059 */ 0060 #define LL_CORDIC_FLAG_RRDY CORDIC_CSR_RRDY 0061 /** 0062 * @} 0063 */ 0064 0065 /** @defgroup CORDIC_LL_EC_IT IT Defines 0066 * @ingroup RTEMSBSPsARMSTM32H7 0067 * @brief IT defines which can be used with LL_CORDIC_ReadReg and LL_CORDIC_WriteReg functions. 0068 * @{ 0069 */ 0070 #define LL_CORDIC_IT_IEN CORDIC_CSR_IEN /*!< Result Ready interrupt enable */ 0071 /** 0072 * @} 0073 */ 0074 0075 /** @defgroup CORDIC_LL_EC_FUNCTION FUNCTION 0076 * @ingroup RTEMSBSPsARMSTM32H7 0077 * @{ 0078 */ 0079 #define LL_CORDIC_FUNCTION_COSINE (0x00000000U) /*!< Cosine */ 0080 #define LL_CORDIC_FUNCTION_SINE ((uint32_t)(CORDIC_CSR_FUNC_0)) /*!< Sine */ 0081 #define LL_CORDIC_FUNCTION_PHASE ((uint32_t)(CORDIC_CSR_FUNC_1)) /*!< Phase */ 0082 #define LL_CORDIC_FUNCTION_MODULUS ((uint32_t)(CORDIC_CSR_FUNC_1 | CORDIC_CSR_FUNC_0)) /*!< Modulus */ 0083 #define LL_CORDIC_FUNCTION_ARCTANGENT ((uint32_t)(CORDIC_CSR_FUNC_2)) /*!< Arctangent */ 0084 #define LL_CORDIC_FUNCTION_HCOSINE ((uint32_t)(CORDIC_CSR_FUNC_2 | CORDIC_CSR_FUNC_0)) /*!< Hyperbolic Cosine */ 0085 #define LL_CORDIC_FUNCTION_HSINE ((uint32_t)(CORDIC_CSR_FUNC_2 | CORDIC_CSR_FUNC_1)) /*!< Hyperbolic Sine */ 0086 #define LL_CORDIC_FUNCTION_HARCTANGENT ((uint32_t)(CORDIC_CSR_FUNC_2 | CORDIC_CSR_FUNC_1 | CORDIC_CSR_FUNC_0))/*!< Hyperbolic Arctangent */ 0087 #define LL_CORDIC_FUNCTION_NATURALLOG ((uint32_t)(CORDIC_CSR_FUNC_3)) /*!< Natural Logarithm */ 0088 #define LL_CORDIC_FUNCTION_SQUAREROOT ((uint32_t)(CORDIC_CSR_FUNC_3 | CORDIC_CSR_FUNC_0)) /*!< Square Root */ 0089 /** 0090 * @} 0091 */ 0092 0093 /** @defgroup CORDIC_LL_EC_PRECISION PRECISION 0094 * @ingroup RTEMSBSPsARMSTM32H7 0095 * @{ 0096 */ 0097 #define LL_CORDIC_PRECISION_1CYCLE ((uint32_t)(CORDIC_CSR_PRECISION_0)) 0098 #define LL_CORDIC_PRECISION_2CYCLES ((uint32_t)(CORDIC_CSR_PRECISION_1)) 0099 #define LL_CORDIC_PRECISION_3CYCLES ((uint32_t)(CORDIC_CSR_PRECISION_1 | CORDIC_CSR_PRECISION_0)) 0100 #define LL_CORDIC_PRECISION_4CYCLES ((uint32_t)(CORDIC_CSR_PRECISION_2)) 0101 #define LL_CORDIC_PRECISION_5CYCLES ((uint32_t)(CORDIC_CSR_PRECISION_2 | CORDIC_CSR_PRECISION_0)) 0102 #define LL_CORDIC_PRECISION_6CYCLES ((uint32_t)(CORDIC_CSR_PRECISION_2 | CORDIC_CSR_PRECISION_1)) 0103 #define LL_CORDIC_PRECISION_7CYCLES ((uint32_t)(CORDIC_CSR_PRECISION_2\ 0104 | CORDIC_CSR_PRECISION_1 | CORDIC_CSR_PRECISION_0)) 0105 #define LL_CORDIC_PRECISION_8CYCLES ((uint32_t)(CORDIC_CSR_PRECISION_3)) 0106 #define LL_CORDIC_PRECISION_9CYCLES ((uint32_t)(CORDIC_CSR_PRECISION_3 | CORDIC_CSR_PRECISION_0)) 0107 #define LL_CORDIC_PRECISION_10CYCLES ((uint32_t)(CORDIC_CSR_PRECISION_3 | CORDIC_CSR_PRECISION_1)) 0108 #define LL_CORDIC_PRECISION_11CYCLES ((uint32_t)(CORDIC_CSR_PRECISION_3\ 0109 | CORDIC_CSR_PRECISION_1 | CORDIC_CSR_PRECISION_0)) 0110 #define LL_CORDIC_PRECISION_12CYCLES ((uint32_t)(CORDIC_CSR_PRECISION_3 | CORDIC_CSR_PRECISION_2)) 0111 #define LL_CORDIC_PRECISION_13CYCLES ((uint32_t)(CORDIC_CSR_PRECISION_3\ 0112 | CORDIC_CSR_PRECISION_2 | CORDIC_CSR_PRECISION_0)) 0113 #define LL_CORDIC_PRECISION_14CYCLES ((uint32_t)(CORDIC_CSR_PRECISION_3\ 0114 | CORDIC_CSR_PRECISION_2 | CORDIC_CSR_PRECISION_1)) 0115 #define LL_CORDIC_PRECISION_15CYCLES ((uint32_t)(CORDIC_CSR_PRECISION_3\ 0116 | CORDIC_CSR_PRECISION_2 | CORDIC_CSR_PRECISION_1\ 0117 | CORDIC_CSR_PRECISION_0)) 0118 /** 0119 * @} 0120 */ 0121 0122 /** @defgroup CORDIC_LL_EC_SCALE SCALE 0123 * @ingroup RTEMSBSPsARMSTM32H7 0124 * @{ 0125 */ 0126 #define LL_CORDIC_SCALE_0 (0x00000000U) 0127 #define LL_CORDIC_SCALE_1 ((uint32_t)(CORDIC_CSR_SCALE_0)) 0128 #define LL_CORDIC_SCALE_2 ((uint32_t)(CORDIC_CSR_SCALE_1)) 0129 #define LL_CORDIC_SCALE_3 ((uint32_t)(CORDIC_CSR_SCALE_1 | CORDIC_CSR_SCALE_0)) 0130 #define LL_CORDIC_SCALE_4 ((uint32_t)(CORDIC_CSR_SCALE_2)) 0131 #define LL_CORDIC_SCALE_5 ((uint32_t)(CORDIC_CSR_SCALE_2 | CORDIC_CSR_SCALE_0)) 0132 #define LL_CORDIC_SCALE_6 ((uint32_t)(CORDIC_CSR_SCALE_2 | CORDIC_CSR_SCALE_1)) 0133 #define LL_CORDIC_SCALE_7 ((uint32_t)(CORDIC_CSR_SCALE_2 | CORDIC_CSR_SCALE_1 | CORDIC_CSR_SCALE_0)) 0134 /** 0135 * @} 0136 */ 0137 0138 /** @defgroup CORDIC_LL_EC_NBWRITE NBWRITE 0139 * @ingroup RTEMSBSPsARMSTM32H7 0140 * @{ 0141 */ 0142 #define LL_CORDIC_NBWRITE_1 (0x00000000U) /*!< One 32-bits write containing either only one 0143 32-bit data input (Q1.31 format), or two 0144 16-bit data input (Q1.15 format) packed 0145 in one 32 bits Data */ 0146 #define LL_CORDIC_NBWRITE_2 CORDIC_CSR_NARGS /*!< Two 32-bit write containing two 32-bits data input 0147 (Q1.31 format) */ 0148 /** 0149 * @} 0150 */ 0151 0152 /** @defgroup CORDIC_LL_EC_NBREAD NBREAD 0153 * @ingroup RTEMSBSPsARMSTM32H7 0154 * @{ 0155 */ 0156 #define LL_CORDIC_NBREAD_1 (0x00000000U) /*!< One 32-bits read containing either only one 0157 32-bit data output (Q1.31 format), or two 0158 16-bit data output (Q1.15 format) packed 0159 in one 32 bits Data */ 0160 #define LL_CORDIC_NBREAD_2 CORDIC_CSR_NRES /*!< Two 32-bit Data containing two 32-bits data output 0161 (Q1.31 format) */ 0162 /** 0163 * @} 0164 */ 0165 0166 /** @defgroup CORDIC_LL_EC_INSIZE INSIZE 0167 * @ingroup RTEMSBSPsARMSTM32H7 0168 * @{ 0169 */ 0170 #define LL_CORDIC_INSIZE_32BITS (0x00000000U) /*!< 32 bits input data size (Q1.31 format) */ 0171 #define LL_CORDIC_INSIZE_16BITS CORDIC_CSR_ARGSIZE /*!< 16 bits input data size (Q1.15 format) */ 0172 /** 0173 * @} 0174 */ 0175 0176 /** @defgroup CORDIC_LL_EC_OUTSIZE OUTSIZE 0177 * @ingroup RTEMSBSPsARMSTM32H7 0178 * @{ 0179 */ 0180 #define LL_CORDIC_OUTSIZE_32BITS (0x00000000U) /*!< 32 bits output data size (Q1.31 format) */ 0181 #define LL_CORDIC_OUTSIZE_16BITS CORDIC_CSR_RESSIZE /*!< 16 bits output data size (Q1.15 format) */ 0182 /** 0183 * @} 0184 */ 0185 0186 /** @defgroup CORDIC_LL_EC_DMA_REG_DATA DMA register data 0187 * @ingroup RTEMSBSPsARMSTM32H7 0188 * @{ 0189 */ 0190 #define LL_CORDIC_DMA_REG_DATA_IN (0x00000000U) /*!< Get address of input data register */ 0191 #define LL_CORDIC_DMA_REG_DATA_OUT (0x00000001U) /*!< Get address of output data register */ 0192 /** 0193 * @} 0194 */ 0195 0196 /** 0197 * @} 0198 */ 0199 0200 /* Exported macro ------------------------------------------------------------*/ 0201 /** @defgroup CORDIC_LL_Exported_Macros CORDIC Exported Macros 0202 * @ingroup RTEMSBSPsARMSTM32H7 0203 * @{ 0204 */ 0205 0206 /** @defgroup CORDIC_LL_EM_WRITE_READ Common Write and read registers Macros 0207 * @ingroup RTEMSBSPsARMSTM32H7 0208 * @{ 0209 */ 0210 0211 /** 0212 * @brief Write a value in CORDIC register. 0213 * @param __INSTANCE__ CORDIC Instance 0214 * @param __REG__ Register to be written 0215 * @param __VALUE__ Value to be written in the register 0216 * @retval None 0217 */ 0218 #define LL_CORDIC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) 0219 0220 /** 0221 * @brief Read a value in CORDIC register. 0222 * @param __INSTANCE__ CORDIC Instance 0223 * @param __REG__ Register to be read 0224 * @retval Register value 0225 */ 0226 #define LL_CORDIC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) 0227 /** 0228 * @} 0229 */ 0230 0231 /** 0232 * @} 0233 */ 0234 0235 0236 /* Exported functions --------------------------------------------------------*/ 0237 0238 /** @defgroup CORDIC_LL_Exported_Functions CORDIC Exported Functions 0239 * @ingroup RTEMSBSPsARMSTM32H7 0240 * @{ 0241 */ 0242 0243 /** @defgroup CORDIC_LL_EF_Configuration CORDIC Configuration functions 0244 * @ingroup RTEMSBSPsARMSTM32H7 0245 * @{ 0246 */ 0247 0248 /** 0249 * @brief Configure the CORDIC processing. 0250 * @note This function set all parameters of CORDIC processing. 0251 * These parameters can also be set individually using 0252 * dedicated functions: 0253 * - @ref LL_CORDIC_SetFunction() 0254 * - @ref LL_CORDIC_SetPrecision() 0255 * - @ref LL_CORDIC_SetScale() 0256 * - @ref LL_CORDIC_SetNbWrite() 0257 * - @ref LL_CORDIC_SetNbRead() 0258 * - @ref LL_CORDIC_SetInSize() 0259 * - @ref LL_CORDIC_SetOutSize() 0260 * @rmtoll CSR FUNC LL_CORDIC_Config\n 0261 * CSR PRECISION LL_CORDIC_Config\n 0262 * CSR SCALE LL_CORDIC_Config\n 0263 * CSR NARGS LL_CORDIC_Config\n 0264 * CSR NRES LL_CORDIC_Config\n 0265 * CSR ARGSIZE LL_CORDIC_Config\n 0266 * CSR RESIZE LL_CORDIC_Config 0267 * @param CORDICx CORDIC instance 0268 * @param Function parameter can be one of the following values: 0269 * @arg @ref LL_CORDIC_FUNCTION_COSINE 0270 * @arg @ref LL_CORDIC_FUNCTION_SINE 0271 * @arg @ref LL_CORDIC_FUNCTION_PHASE 0272 * @arg @ref LL_CORDIC_FUNCTION_MODULUS 0273 * @arg @ref LL_CORDIC_FUNCTION_ARCTANGENT 0274 * @arg @ref LL_CORDIC_FUNCTION_HCOSINE 0275 * @arg @ref LL_CORDIC_FUNCTION_HSINE 0276 * @arg @ref LL_CORDIC_FUNCTION_HARCTANGENT 0277 * @arg @ref LL_CORDIC_FUNCTION_NATURALLOG 0278 * @arg @ref LL_CORDIC_FUNCTION_SQUAREROOT 0279 * @param Precision parameter can be one of the following values: 0280 * @arg @ref LL_CORDIC_PRECISION_1CYCLE 0281 * @arg @ref LL_CORDIC_PRECISION_2CYCLES 0282 * @arg @ref LL_CORDIC_PRECISION_3CYCLES 0283 * @arg @ref LL_CORDIC_PRECISION_4CYCLES 0284 * @arg @ref LL_CORDIC_PRECISION_5CYCLES 0285 * @arg @ref LL_CORDIC_PRECISION_6CYCLES 0286 * @arg @ref LL_CORDIC_PRECISION_7CYCLES 0287 * @arg @ref LL_CORDIC_PRECISION_8CYCLES 0288 * @arg @ref LL_CORDIC_PRECISION_9CYCLES 0289 * @arg @ref LL_CORDIC_PRECISION_10CYCLES 0290 * @arg @ref LL_CORDIC_PRECISION_11CYCLES 0291 * @arg @ref LL_CORDIC_PRECISION_12CYCLES 0292 * @arg @ref LL_CORDIC_PRECISION_13CYCLES 0293 * @arg @ref LL_CORDIC_PRECISION_14CYCLES 0294 * @arg @ref LL_CORDIC_PRECISION_15CYCLES 0295 * @param Scale parameter can be one of the following values: 0296 * @arg @ref LL_CORDIC_SCALE_0 0297 * @arg @ref LL_CORDIC_SCALE_1 0298 * @arg @ref LL_CORDIC_SCALE_2 0299 * @arg @ref LL_CORDIC_SCALE_3 0300 * @arg @ref LL_CORDIC_SCALE_4 0301 * @arg @ref LL_CORDIC_SCALE_5 0302 * @arg @ref LL_CORDIC_SCALE_6 0303 * @arg @ref LL_CORDIC_SCALE_7 0304 * @param NbWrite parameter can be one of the following values: 0305 * @arg @ref LL_CORDIC_NBWRITE_1 0306 * @arg @ref LL_CORDIC_NBWRITE_2 0307 * @param NbRead parameter can be one of the following values: 0308 * @arg @ref LL_CORDIC_NBREAD_1 0309 * @arg @ref LL_CORDIC_NBREAD_2 0310 * @param InSize parameter can be one of the following values: 0311 * @arg @ref LL_CORDIC_INSIZE_32BITS 0312 * @arg @ref LL_CORDIC_INSIZE_16BITS 0313 * @param OutSize parameter can be one of the following values: 0314 * @arg @ref LL_CORDIC_OUTSIZE_32BITS 0315 * @arg @ref LL_CORDIC_OUTSIZE_16BITS 0316 * @retval None 0317 */ 0318 __STATIC_INLINE void LL_CORDIC_Config(CORDIC_TypeDef *CORDICx, uint32_t Function, uint32_t Precision, uint32_t Scale, 0319 uint32_t NbWrite, uint32_t NbRead, uint32_t InSize, uint32_t OutSize) 0320 { 0321 MODIFY_REG(CORDICx->CSR, 0322 CORDIC_CSR_FUNC | CORDIC_CSR_PRECISION | CORDIC_CSR_SCALE | 0323 CORDIC_CSR_NARGS | CORDIC_CSR_NRES | CORDIC_CSR_ARGSIZE | CORDIC_CSR_RESSIZE, 0324 Function | Precision | Scale | 0325 NbWrite | NbRead | InSize | OutSize); 0326 } 0327 0328 /** 0329 * @brief Configure function. 0330 * @rmtoll CSR FUNC LL_CORDIC_SetFunction 0331 * @param CORDICx CORDIC Instance 0332 * @param Function parameter can be one of the following values: 0333 * @arg @ref LL_CORDIC_FUNCTION_COSINE 0334 * @arg @ref LL_CORDIC_FUNCTION_SINE 0335 * @arg @ref LL_CORDIC_FUNCTION_PHASE 0336 * @arg @ref LL_CORDIC_FUNCTION_MODULUS 0337 * @arg @ref LL_CORDIC_FUNCTION_ARCTANGENT 0338 * @arg @ref LL_CORDIC_FUNCTION_HCOSINE 0339 * @arg @ref LL_CORDIC_FUNCTION_HSINE 0340 * @arg @ref LL_CORDIC_FUNCTION_HARCTANGENT 0341 * @arg @ref LL_CORDIC_FUNCTION_NATURALLOG 0342 * @arg @ref LL_CORDIC_FUNCTION_SQUAREROOT 0343 * @retval None 0344 */ 0345 __STATIC_INLINE void LL_CORDIC_SetFunction(CORDIC_TypeDef *CORDICx, uint32_t Function) 0346 { 0347 MODIFY_REG(CORDICx->CSR, CORDIC_CSR_FUNC, Function); 0348 } 0349 0350 /** 0351 * @brief Return function. 0352 * @rmtoll CSR FUNC LL_CORDIC_GetFunction 0353 * @param CORDICx CORDIC Instance 0354 * @retval Returned value can be one of the following values: 0355 * @arg @ref LL_CORDIC_FUNCTION_COSINE 0356 * @arg @ref LL_CORDIC_FUNCTION_SINE 0357 * @arg @ref LL_CORDIC_FUNCTION_PHASE 0358 * @arg @ref LL_CORDIC_FUNCTION_MODULUS 0359 * @arg @ref LL_CORDIC_FUNCTION_ARCTANGENT 0360 * @arg @ref LL_CORDIC_FUNCTION_HCOSINE 0361 * @arg @ref LL_CORDIC_FUNCTION_HSINE 0362 * @arg @ref LL_CORDIC_FUNCTION_HARCTANGENT 0363 * @arg @ref LL_CORDIC_FUNCTION_NATURALLOG 0364 * @arg @ref LL_CORDIC_FUNCTION_SQUAREROOT 0365 */ 0366 __STATIC_INLINE uint32_t LL_CORDIC_GetFunction(const CORDIC_TypeDef *CORDICx) 0367 { 0368 return (uint32_t)(READ_BIT(CORDICx->CSR, CORDIC_CSR_FUNC)); 0369 } 0370 0371 /** 0372 * @brief Configure precision in cycles number. 0373 * @rmtoll CSR PRECISION LL_CORDIC_SetPrecision 0374 * @param CORDICx CORDIC Instance 0375 * @param Precision parameter can be one of the following values: 0376 * @arg @ref LL_CORDIC_PRECISION_1CYCLE 0377 * @arg @ref LL_CORDIC_PRECISION_2CYCLES 0378 * @arg @ref LL_CORDIC_PRECISION_3CYCLES 0379 * @arg @ref LL_CORDIC_PRECISION_4CYCLES 0380 * @arg @ref LL_CORDIC_PRECISION_5CYCLES 0381 * @arg @ref LL_CORDIC_PRECISION_6CYCLES 0382 * @arg @ref LL_CORDIC_PRECISION_7CYCLES 0383 * @arg @ref LL_CORDIC_PRECISION_8CYCLES 0384 * @arg @ref LL_CORDIC_PRECISION_9CYCLES 0385 * @arg @ref LL_CORDIC_PRECISION_10CYCLES 0386 * @arg @ref LL_CORDIC_PRECISION_11CYCLES 0387 * @arg @ref LL_CORDIC_PRECISION_12CYCLES 0388 * @arg @ref LL_CORDIC_PRECISION_13CYCLES 0389 * @arg @ref LL_CORDIC_PRECISION_14CYCLES 0390 * @arg @ref LL_CORDIC_PRECISION_15CYCLES 0391 * @retval None 0392 */ 0393 __STATIC_INLINE void LL_CORDIC_SetPrecision(CORDIC_TypeDef *CORDICx, uint32_t Precision) 0394 { 0395 MODIFY_REG(CORDICx->CSR, CORDIC_CSR_PRECISION, Precision); 0396 } 0397 0398 /** 0399 * @brief Return precision in cycles number. 0400 * @rmtoll CSR PRECISION LL_CORDIC_GetPrecision 0401 * @param CORDICx CORDIC Instance 0402 * @retval Returned value can be one of the following values: 0403 * @arg @ref LL_CORDIC_PRECISION_1CYCLE 0404 * @arg @ref LL_CORDIC_PRECISION_2CYCLES 0405 * @arg @ref LL_CORDIC_PRECISION_3CYCLES 0406 * @arg @ref LL_CORDIC_PRECISION_4CYCLES 0407 * @arg @ref LL_CORDIC_PRECISION_5CYCLES 0408 * @arg @ref LL_CORDIC_PRECISION_6CYCLES 0409 * @arg @ref LL_CORDIC_PRECISION_7CYCLES 0410 * @arg @ref LL_CORDIC_PRECISION_8CYCLES 0411 * @arg @ref LL_CORDIC_PRECISION_9CYCLES 0412 * @arg @ref LL_CORDIC_PRECISION_10CYCLES 0413 * @arg @ref LL_CORDIC_PRECISION_11CYCLES 0414 * @arg @ref LL_CORDIC_PRECISION_12CYCLES 0415 * @arg @ref LL_CORDIC_PRECISION_13CYCLES 0416 * @arg @ref LL_CORDIC_PRECISION_14CYCLES 0417 * @arg @ref LL_CORDIC_PRECISION_15CYCLES 0418 */ 0419 __STATIC_INLINE uint32_t LL_CORDIC_GetPrecision(const CORDIC_TypeDef *CORDICx) 0420 { 0421 return (uint32_t)(READ_BIT(CORDICx->CSR, CORDIC_CSR_PRECISION)); 0422 } 0423 0424 /** 0425 * @brief Configure scaling factor. 0426 * @rmtoll CSR SCALE LL_CORDIC_SetScale 0427 * @param CORDICx CORDIC Instance 0428 * @param Scale parameter can be one of the following values: 0429 * @arg @ref LL_CORDIC_SCALE_0 0430 * @arg @ref LL_CORDIC_SCALE_1 0431 * @arg @ref LL_CORDIC_SCALE_2 0432 * @arg @ref LL_CORDIC_SCALE_3 0433 * @arg @ref LL_CORDIC_SCALE_4 0434 * @arg @ref LL_CORDIC_SCALE_5 0435 * @arg @ref LL_CORDIC_SCALE_6 0436 * @arg @ref LL_CORDIC_SCALE_7 0437 * @retval None 0438 */ 0439 __STATIC_INLINE void LL_CORDIC_SetScale(CORDIC_TypeDef *CORDICx, uint32_t Scale) 0440 { 0441 MODIFY_REG(CORDICx->CSR, CORDIC_CSR_SCALE, Scale); 0442 } 0443 0444 /** 0445 * @brief Return scaling factor. 0446 * @rmtoll CSR SCALE LL_CORDIC_GetScale 0447 * @param CORDICx CORDIC Instance 0448 * @retval Returned value can be one of the following values: 0449 * @arg @ref LL_CORDIC_SCALE_0 0450 * @arg @ref LL_CORDIC_SCALE_1 0451 * @arg @ref LL_CORDIC_SCALE_2 0452 * @arg @ref LL_CORDIC_SCALE_3 0453 * @arg @ref LL_CORDIC_SCALE_4 0454 * @arg @ref LL_CORDIC_SCALE_5 0455 * @arg @ref LL_CORDIC_SCALE_6 0456 * @arg @ref LL_CORDIC_SCALE_7 0457 */ 0458 __STATIC_INLINE uint32_t LL_CORDIC_GetScale(const CORDIC_TypeDef *CORDICx) 0459 { 0460 return (uint32_t)(READ_BIT(CORDICx->CSR, CORDIC_CSR_SCALE)); 0461 } 0462 0463 /** 0464 * @brief Configure number of 32-bit write expected for one calculation. 0465 * @rmtoll CSR NARGS LL_CORDIC_SetNbWrite 0466 * @param CORDICx CORDIC Instance 0467 * @param NbWrite parameter can be one of the following values: 0468 * @arg @ref LL_CORDIC_NBWRITE_1 0469 * @arg @ref LL_CORDIC_NBWRITE_2 0470 * @retval None 0471 */ 0472 __STATIC_INLINE void LL_CORDIC_SetNbWrite(CORDIC_TypeDef *CORDICx, uint32_t NbWrite) 0473 { 0474 MODIFY_REG(CORDICx->CSR, CORDIC_CSR_NARGS, NbWrite); 0475 } 0476 0477 /** 0478 * @brief Return number of 32-bit write expected for one calculation. 0479 * @rmtoll CSR NARGS LL_CORDIC_GetNbWrite 0480 * @param CORDICx CORDIC Instance 0481 * @retval Returned value can be one of the following values: 0482 * @arg @ref LL_CORDIC_NBWRITE_1 0483 * @arg @ref LL_CORDIC_NBWRITE_2 0484 */ 0485 __STATIC_INLINE uint32_t LL_CORDIC_GetNbWrite(const CORDIC_TypeDef *CORDICx) 0486 { 0487 return (uint32_t)(READ_BIT(CORDICx->CSR, CORDIC_CSR_NARGS)); 0488 } 0489 0490 /** 0491 * @brief Configure number of 32-bit read expected after one calculation. 0492 * @rmtoll CSR NRES LL_CORDIC_SetNbRead 0493 * @param CORDICx CORDIC Instance 0494 * @param NbRead parameter can be one of the following values: 0495 * @arg @ref LL_CORDIC_NBREAD_1 0496 * @arg @ref LL_CORDIC_NBREAD_2 0497 * @retval None 0498 */ 0499 __STATIC_INLINE void LL_CORDIC_SetNbRead(CORDIC_TypeDef *CORDICx, uint32_t NbRead) 0500 { 0501 MODIFY_REG(CORDICx->CSR, CORDIC_CSR_NRES, NbRead); 0502 } 0503 0504 /** 0505 * @brief Return number of 32-bit read expected after one calculation. 0506 * @rmtoll CSR NRES LL_CORDIC_GetNbRead 0507 * @param CORDICx CORDIC Instance 0508 * @retval Returned value can be one of the following values: 0509 * @arg @ref LL_CORDIC_NBREAD_1 0510 * @arg @ref LL_CORDIC_NBREAD_2 0511 */ 0512 __STATIC_INLINE uint32_t LL_CORDIC_GetNbRead(const CORDIC_TypeDef *CORDICx) 0513 { 0514 return (uint32_t)(READ_BIT(CORDICx->CSR, CORDIC_CSR_NRES)); 0515 } 0516 0517 /** 0518 * @brief Configure width of input data. 0519 * @rmtoll CSR ARGSIZE LL_CORDIC_SetInSize 0520 * @param CORDICx CORDIC Instance 0521 * @param InSize parameter can be one of the following values: 0522 * @arg @ref LL_CORDIC_INSIZE_32BITS 0523 * @arg @ref LL_CORDIC_INSIZE_16BITS 0524 * @retval None 0525 */ 0526 __STATIC_INLINE void LL_CORDIC_SetInSize(CORDIC_TypeDef *CORDICx, uint32_t InSize) 0527 { 0528 MODIFY_REG(CORDICx->CSR, CORDIC_CSR_ARGSIZE, InSize); 0529 } 0530 0531 /** 0532 * @brief Return width of input data. 0533 * @rmtoll CSR ARGSIZE LL_CORDIC_GetInSize 0534 * @param CORDICx CORDIC Instance 0535 * @retval Returned value can be one of the following values: 0536 * @arg @ref LL_CORDIC_INSIZE_32BITS 0537 * @arg @ref LL_CORDIC_INSIZE_16BITS 0538 */ 0539 __STATIC_INLINE uint32_t LL_CORDIC_GetInSize(const CORDIC_TypeDef *CORDICx) 0540 { 0541 return (uint32_t)(READ_BIT(CORDICx->CSR, CORDIC_CSR_ARGSIZE)); 0542 } 0543 0544 /** 0545 * @brief Configure width of output data. 0546 * @rmtoll CSR RESIZE LL_CORDIC_SetOutSize 0547 * @param CORDICx CORDIC Instance 0548 * @param OutSize parameter can be one of the following values: 0549 * @arg @ref LL_CORDIC_OUTSIZE_32BITS 0550 * @arg @ref LL_CORDIC_OUTSIZE_16BITS 0551 * @retval None 0552 */ 0553 __STATIC_INLINE void LL_CORDIC_SetOutSize(CORDIC_TypeDef *CORDICx, uint32_t OutSize) 0554 { 0555 MODIFY_REG(CORDICx->CSR, CORDIC_CSR_RESSIZE, OutSize); 0556 } 0557 0558 /** 0559 * @brief Return width of output data. 0560 * @rmtoll CSR RESIZE LL_CORDIC_GetOutSize 0561 * @param CORDICx CORDIC Instance 0562 * @retval Returned value can be one of the following values: 0563 * @arg @ref LL_CORDIC_OUTSIZE_32BITS 0564 * @arg @ref LL_CORDIC_OUTSIZE_16BITS 0565 */ 0566 __STATIC_INLINE uint32_t LL_CORDIC_GetOutSize(const CORDIC_TypeDef *CORDICx) 0567 { 0568 return (uint32_t)(READ_BIT(CORDICx->CSR, CORDIC_CSR_RESSIZE)); 0569 } 0570 0571 /** 0572 * @} 0573 */ 0574 0575 /** @defgroup CORDIC_LL_EF_IT_Management IT_Management 0576 * @ingroup RTEMSBSPsARMSTM32H7 0577 * @{ 0578 */ 0579 0580 /** 0581 * @brief Enable CORDIC result ready interrupt 0582 * @rmtoll CSR IEN LL_CORDIC_EnableIT 0583 * @param CORDICx CORDIC Instance 0584 * @retval None 0585 */ 0586 __STATIC_INLINE void LL_CORDIC_EnableIT(CORDIC_TypeDef *CORDICx) 0587 { 0588 SET_BIT(CORDICx->CSR, CORDIC_CSR_IEN); 0589 } 0590 0591 /** 0592 * @brief Disable CORDIC result ready interrupt 0593 * @rmtoll CSR IEN LL_CORDIC_DisableIT 0594 * @param CORDICx CORDIC Instance 0595 * @retval None 0596 */ 0597 __STATIC_INLINE void LL_CORDIC_DisableIT(CORDIC_TypeDef *CORDICx) 0598 { 0599 CLEAR_BIT(CORDICx->CSR, CORDIC_CSR_IEN); 0600 } 0601 0602 /** 0603 * @brief Check CORDIC result ready interrupt state. 0604 * @rmtoll CSR IEN LL_CORDIC_IsEnabledIT 0605 * @param CORDICx CORDIC Instance 0606 * @retval State of bit (1 or 0). 0607 */ 0608 __STATIC_INLINE uint32_t LL_CORDIC_IsEnabledIT(const CORDIC_TypeDef *CORDICx) 0609 { 0610 return ((READ_BIT(CORDICx->CSR, CORDIC_CSR_IEN) == (CORDIC_CSR_IEN)) ? 1U : 0U); 0611 } 0612 0613 /** 0614 * @} 0615 */ 0616 0617 /** @defgroup CORDIC_LL_EF_DMA_Management DMA_Management 0618 * @ingroup RTEMSBSPsARMSTM32H7 0619 * @{ 0620 */ 0621 0622 /** 0623 * @brief Enable CORDIC DMA read channel request. 0624 * @rmtoll CSR DMAREN LL_CORDIC_EnableDMAReq_RD 0625 * @param CORDICx CORDIC Instance 0626 * @retval None 0627 */ 0628 __STATIC_INLINE void LL_CORDIC_EnableDMAReq_RD(CORDIC_TypeDef *CORDICx) 0629 { 0630 SET_BIT(CORDICx->CSR, CORDIC_CSR_DMAREN); 0631 } 0632 0633 /** 0634 * @brief Disable CORDIC DMA read channel request. 0635 * @rmtoll CSR DMAREN LL_CORDIC_DisableDMAReq_RD 0636 * @param CORDICx CORDIC Instance 0637 * @retval None 0638 */ 0639 __STATIC_INLINE void LL_CORDIC_DisableDMAReq_RD(CORDIC_TypeDef *CORDICx) 0640 { 0641 CLEAR_BIT(CORDICx->CSR, CORDIC_CSR_DMAREN); 0642 } 0643 0644 /** 0645 * @brief Check CORDIC DMA read channel request state. 0646 * @rmtoll CSR DMAREN LL_CORDIC_IsEnabledDMAReq_RD 0647 * @param CORDICx CORDIC Instance 0648 * @retval State of bit (1 or 0). 0649 */ 0650 __STATIC_INLINE uint32_t LL_CORDIC_IsEnabledDMAReq_RD(const CORDIC_TypeDef *CORDICx) 0651 { 0652 return ((READ_BIT(CORDICx->CSR, CORDIC_CSR_DMAREN) == (CORDIC_CSR_DMAREN)) ? 1U : 0U); 0653 } 0654 0655 /** 0656 * @brief Enable CORDIC DMA write channel request. 0657 * @rmtoll CSR DMAWEN LL_CORDIC_EnableDMAReq_WR 0658 * @param CORDICx CORDIC Instance 0659 * @retval None 0660 */ 0661 __STATIC_INLINE void LL_CORDIC_EnableDMAReq_WR(CORDIC_TypeDef *CORDICx) 0662 { 0663 SET_BIT(CORDICx->CSR, CORDIC_CSR_DMAWEN); 0664 } 0665 0666 /** 0667 * @brief Disable CORDIC DMA write channel request. 0668 * @rmtoll CSR DMAWEN LL_CORDIC_DisableDMAReq_WR 0669 * @param CORDICx CORDIC Instance 0670 * @retval None 0671 */ 0672 __STATIC_INLINE void LL_CORDIC_DisableDMAReq_WR(CORDIC_TypeDef *CORDICx) 0673 { 0674 CLEAR_BIT(CORDICx->CSR, CORDIC_CSR_DMAWEN); 0675 } 0676 0677 /** 0678 * @brief Check CORDIC DMA write channel request state. 0679 * @rmtoll CSR DMAWEN LL_CORDIC_IsEnabledDMAReq_WR 0680 * @param CORDICx CORDIC Instance 0681 * @retval State of bit (1 or 0). 0682 */ 0683 __STATIC_INLINE uint32_t LL_CORDIC_IsEnabledDMAReq_WR(const CORDIC_TypeDef *CORDICx) 0684 { 0685 return ((READ_BIT(CORDICx->CSR, CORDIC_CSR_DMAWEN) == (CORDIC_CSR_DMAWEN)) ? 1U : 0U); 0686 } 0687 0688 /** 0689 * @brief Get the CORDIC data register address used for DMA transfer. 0690 * @rmtoll RDATA RES LL_CORDIC_DMA_GetRegAddr\n 0691 * @rmtoll WDATA ARG LL_CORDIC_DMA_GetRegAddr 0692 * @param CORDICx CORDIC Instance 0693 * @param Direction parameter can be one of the following values: 0694 * @arg @ref LL_CORDIC_DMA_REG_DATA_IN 0695 * @arg @ref LL_CORDIC_DMA_REG_DATA_OUT 0696 * @retval Address of data register 0697 */ 0698 __STATIC_INLINE uint32_t LL_CORDIC_DMA_GetRegAddr(const CORDIC_TypeDef *CORDICx, uint32_t Direction) 0699 { 0700 uint32_t data_reg_addr; 0701 0702 if (Direction == LL_CORDIC_DMA_REG_DATA_OUT) 0703 { 0704 /* return address of RDATA register */ 0705 data_reg_addr = (uint32_t) &(CORDICx->RDATA); 0706 } 0707 else 0708 { 0709 /* return address of WDATA register */ 0710 data_reg_addr = (uint32_t) &(CORDICx->WDATA); 0711 } 0712 0713 return data_reg_addr; 0714 } 0715 0716 /** 0717 * @} 0718 */ 0719 0720 /** @defgroup CORDIC_LL_EF_FLAG_Management FLAG_Management 0721 * @ingroup RTEMSBSPsARMSTM32H7 0722 * @{ 0723 */ 0724 0725 /** 0726 * @brief Check CORDIC result ready flag state. 0727 * @rmtoll CSR RRDY LL_CORDIC_IsActiveFlag_RRDY 0728 * @param CORDICx CORDIC Instance 0729 * @retval State of bit (1 or 0). 0730 */ 0731 __STATIC_INLINE uint32_t LL_CORDIC_IsActiveFlag_RRDY(const CORDIC_TypeDef *CORDICx) 0732 { 0733 return ((READ_BIT(CORDICx->CSR, CORDIC_CSR_RRDY) == (CORDIC_CSR_RRDY)) ? 1U : 0U); 0734 } 0735 0736 /** 0737 * @} 0738 */ 0739 0740 /** @defgroup CORDIC_LL_EF_Data_Management Data_Management 0741 * @ingroup RTEMSBSPsARMSTM32H7 0742 * @{ 0743 */ 0744 0745 /** 0746 * @brief Write 32-bit input data for the CORDIC processing. 0747 * @rmtoll WDATA ARG LL_CORDIC_WriteData 0748 * @param CORDICx CORDIC Instance 0749 * @param InData 0 .. 0xFFFFFFFF : 32-bit value to be provided as input data for CORDIC processing. 0750 * @retval None 0751 */ 0752 __STATIC_INLINE void LL_CORDIC_WriteData(CORDIC_TypeDef *CORDICx, uint32_t InData) 0753 { 0754 WRITE_REG(CORDICx->WDATA, InData); 0755 } 0756 0757 /** 0758 * @brief Return 32-bit output data of CORDIC processing. 0759 * @rmtoll RDATA RES LL_CORDIC_ReadData 0760 * @param CORDICx CORDIC Instance 0761 * @retval 32-bit output data of CORDIC processing. 0762 */ 0763 __STATIC_INLINE uint32_t LL_CORDIC_ReadData(const CORDIC_TypeDef *CORDICx) 0764 { 0765 return (uint32_t)(READ_REG(CORDICx->RDATA)); 0766 } 0767 0768 /** 0769 * @} 0770 */ 0771 0772 0773 0774 #if defined(USE_FULL_LL_DRIVER) || defined(__rtems__) 0775 /** @defgroup CORDIC_LL_EF_Init Initialization and de-initialization functions 0776 * @ingroup RTEMSBSPsARMSTM32H7 0777 * @{ 0778 */ 0779 ErrorStatus LL_CORDIC_DeInit(const CORDIC_TypeDef *CORDICx); 0780 0781 /** 0782 * @} 0783 */ 0784 #endif /* USE_FULL_LL_DRIVER */ 0785 0786 /** 0787 * @} 0788 */ 0789 0790 /** 0791 * @} 0792 */ 0793 0794 #endif /* defined(CORDIC) */ 0795 0796 /** 0797 * @} 0798 */ 0799 0800 #ifdef __cplusplus 0801 } 0802 #endif 0803 0804 #endif /* STM32H7xx_LL_CORDIC_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |