|
STM32F439xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32f4xx_ll_utils.h 00004 * @author MCD Application Team 00005 * @brief Header file of UTILS LL module. 00006 @verbatim 00007 ============================================================================== 00008 ##### How to use this driver ##### 00009 ============================================================================== 00010 [..] 00011 The LL UTILS driver contains a set of generic APIs that can be 00012 used by user: 00013 (+) Device electronic signature 00014 (+) Timing functions 00015 (+) PLL configuration functions 00016 00017 @endverbatim 00018 ****************************************************************************** 00019 * @attention 00020 * 00021 * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> 00022 * 00023 * Redistribution and use in source and binary forms, with or without modification, 00024 * are permitted provided that the following conditions are met: 00025 * 1. Redistributions of source code must retain the above copyright notice, 00026 * this list of conditions and the following disclaimer. 00027 * 2. Redistributions in binary form must reproduce the above copyright notice, 00028 * this list of conditions and the following disclaimer in the documentation 00029 * and/or other materials provided with the distribution. 00030 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00031 * may be used to endorse or promote products derived from this software 00032 * without specific prior written permission. 00033 * 00034 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00035 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00036 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00037 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00038 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00039 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00040 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00041 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00042 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00043 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00044 * 00045 ****************************************************************************** 00046 */ 00047 00048 /* Define to prevent recursive inclusion -------------------------------------*/ 00049 #ifndef __STM32F4xx_LL_UTILS_H 00050 #define __STM32F4xx_LL_UTILS_H 00051 00052 #ifdef __cplusplus 00053 extern "C" { 00054 #endif 00055 00056 /* Includes ------------------------------------------------------------------*/ 00057 #include "stm32f4xx.h" 00058 00059 /** @addtogroup STM32F4xx_LL_Driver 00060 * @{ 00061 */ 00062 00063 /** @defgroup UTILS_LL UTILS 00064 * @{ 00065 */ 00066 00067 /* Private types -------------------------------------------------------------*/ 00068 /* Private variables ---------------------------------------------------------*/ 00069 00070 /* Private constants ---------------------------------------------------------*/ 00071 /** @defgroup UTILS_LL_Private_Constants UTILS Private Constants 00072 * @{ 00073 */ 00074 00075 /* Max delay can be used in LL_mDelay */ 00076 #define LL_MAX_DELAY 0xFFFFFFFFU 00077 00078 /** 00079 * @brief Unique device ID register base address 00080 */ 00081 #define UID_BASE_ADDRESS UID_BASE 00082 00083 /** 00084 * @brief Flash size data register base address 00085 */ 00086 #define FLASHSIZE_BASE_ADDRESS FLASHSIZE_BASE 00087 00088 /** 00089 * @brief Package data register base address 00090 */ 00091 #define PACKAGE_BASE_ADDRESS PACKAGE_BASE 00092 00093 /** 00094 * @} 00095 */ 00096 00097 /* Private macros ------------------------------------------------------------*/ 00098 /** @defgroup UTILS_LL_Private_Macros UTILS Private Macros 00099 * @{ 00100 */ 00101 /** 00102 * @} 00103 */ 00104 /* Exported types ------------------------------------------------------------*/ 00105 /** @defgroup UTILS_LL_ES_INIT UTILS Exported structures 00106 * @{ 00107 */ 00108 /** 00109 * @brief UTILS PLL structure definition 00110 */ 00111 typedef struct 00112 { 00113 uint32_t PLLM; /*!< Division factor for PLL VCO input clock. 00114 This parameter can be a value of @ref RCC_LL_EC_PLLM_DIV 00115 00116 This feature can be modified afterwards using unitary function 00117 @ref LL_RCC_PLL_ConfigDomain_SYS(). */ 00118 00119 uint32_t PLLN; /*!< Multiplication factor for PLL VCO output clock. 00120 This parameter must be a number between Min_Data = @ref RCC_PLLN_MIN_VALUE 00121 and Max_Data = @ref RCC_PLLN_MIN_VALUE 00122 00123 This feature can be modified afterwards using unitary function 00124 @ref LL_RCC_PLL_ConfigDomain_SYS(). */ 00125 00126 uint32_t PLLP; /*!< Division for the main system clock. 00127 This parameter can be a value of @ref RCC_LL_EC_PLLP_DIV 00128 00129 This feature can be modified afterwards using unitary function 00130 @ref LL_RCC_PLL_ConfigDomain_SYS(). */ 00131 } LL_UTILS_PLLInitTypeDef; 00132 00133 /** 00134 * @brief UTILS System, AHB and APB buses clock configuration structure definition 00135 */ 00136 typedef struct 00137 { 00138 uint32_t AHBCLKDivider; /*!< The AHB clock (HCLK) divider. This clock is derived from the system clock (SYSCLK). 00139 This parameter can be a value of @ref RCC_LL_EC_SYSCLK_DIV 00140 00141 This feature can be modified afterwards using unitary function 00142 @ref LL_RCC_SetAHBPrescaler(). */ 00143 00144 uint32_t APB1CLKDivider; /*!< The APB1 clock (PCLK1) divider. This clock is derived from the AHB clock (HCLK). 00145 This parameter can be a value of @ref RCC_LL_EC_APB1_DIV 00146 00147 This feature can be modified afterwards using unitary function 00148 @ref LL_RCC_SetAPB1Prescaler(). */ 00149 00150 uint32_t APB2CLKDivider; /*!< The APB2 clock (PCLK2) divider. This clock is derived from the AHB clock (HCLK). 00151 This parameter can be a value of @ref RCC_LL_EC_APB2_DIV 00152 00153 This feature can be modified afterwards using unitary function 00154 @ref LL_RCC_SetAPB2Prescaler(). */ 00155 00156 } LL_UTILS_ClkInitTypeDef; 00157 00158 /** 00159 * @} 00160 */ 00161 00162 /* Exported constants --------------------------------------------------------*/ 00163 /** @defgroup UTILS_LL_Exported_Constants UTILS Exported Constants 00164 * @{ 00165 */ 00166 00167 /** @defgroup UTILS_EC_HSE_BYPASS HSE Bypass activation 00168 * @{ 00169 */ 00170 #define LL_UTILS_HSEBYPASS_OFF 0x00000000U /*!< HSE Bypass is not enabled */ 00171 #define LL_UTILS_HSEBYPASS_ON 0x00000001U /*!< HSE Bypass is enabled */ 00172 /** 00173 * @} 00174 */ 00175 00176 /** @defgroup UTILS_EC_PACKAGETYPE PACKAGE TYPE 00177 * @{ 00178 */ 00179 #define LL_UTILS_PACKAGETYPE_WLCSP36_UFQFPN48_LQFP64 0x00000000U /*!< WLCSP36 or UFQFPN48 or LQFP64 package type */ 00180 #define LL_UTILS_PACKAGETYPE_WLCSP168_FBGA169_LQFP100_LQFP64_UFQFPN48 0x00000100U /*!< WLCSP168 or FBGA169 or LQFP100 or LQFP64 or UFQFPN48 package type */ 00181 #define LL_UTILS_PACKAGETYPE_WLCSP64_WLCSP81_LQFP176_UFBGA176 0x00000200U /*!< WLCSP64 or WLCSP81 or LQFP176 or UFBGA176 package type */ 00182 #define LL_UTILS_PACKAGETYPE_LQFP144_UFBGA144_UFBGA144_UFBGA100 0x00000300U /*!< LQFP144 or UFBGA144 or UFBGA144 or UFBGA100 package type */ 00183 #define LL_UTILS_PACKAGETYPE_LQFP100_LQFP208_TFBGA216 0x00000400U /*!< LQFP100 or LQFP208 or TFBGA216 package type */ 00184 #define LL_UTILS_PACKAGETYPE_LQFP208_TFBGA216 0x00000500U /*!< LQFP208 or TFBGA216 package type */ 00185 #define LL_UTILS_PACKAGETYPE_TQFP64_UFBGA144_LQFP144 0x00000700U /*!< TQFP64 or UFBGA144 or LQFP144 package type */ 00186 /** 00187 * @} 00188 */ 00189 00190 /** 00191 * @} 00192 */ 00193 00194 /* Exported macro ------------------------------------------------------------*/ 00195 00196 /* Exported functions --------------------------------------------------------*/ 00197 /** @defgroup UTILS_LL_Exported_Functions UTILS Exported Functions 00198 * @{ 00199 */ 00200 00201 /** @defgroup UTILS_EF_DEVICE_ELECTRONIC_SIGNATURE DEVICE ELECTRONIC SIGNATURE 00202 * @{ 00203 */ 00204 00205 /** 00206 * @brief Get Word0 of the unique device identifier (UID based on 96 bits) 00207 * @retval UID[31:0] 00208 */ 00209 __STATIC_INLINE uint32_t LL_GetUID_Word0(void) 00210 { 00211 return (uint32_t)(READ_REG(*((uint32_t *)UID_BASE_ADDRESS))); 00212 } 00213 00214 /** 00215 * @brief Get Word1 of the unique device identifier (UID based on 96 bits) 00216 * @retval UID[63:32] 00217 */ 00218 __STATIC_INLINE uint32_t LL_GetUID_Word1(void) 00219 { 00220 return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS + 4U)))); 00221 } 00222 00223 /** 00224 * @brief Get Word2 of the unique device identifier (UID based on 96 bits) 00225 * @retval UID[95:64] 00226 */ 00227 __STATIC_INLINE uint32_t LL_GetUID_Word2(void) 00228 { 00229 return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS + 8U)))); 00230 } 00231 00232 /** 00233 * @brief Get Flash memory size 00234 * @note This bitfield indicates the size of the device Flash memory expressed in 00235 * Kbytes. As an example, 0x040 corresponds to 64 Kbytes. 00236 * @retval FLASH_SIZE[15:0]: Flash memory size 00237 */ 00238 __STATIC_INLINE uint32_t LL_GetFlashSize(void) 00239 { 00240 return (uint16_t)(READ_REG(*((uint32_t *)FLASHSIZE_BASE_ADDRESS))); 00241 } 00242 00243 /** 00244 * @brief Get Package type 00245 * @retval Returned value can be one of the following values: 00246 * @arg @ref LL_UTILS_PACKAGETYPE_WLCSP36_UFQFPN48_LQFP64 (*) 00247 * @arg @ref LL_UTILS_PACKAGETYPE_WLCSP168_FBGA169_LQFP100_LQFP64_UFQFPN48 (*) 00248 * @arg @ref LL_UTILS_PACKAGETYPE_WLCSP64_WLCSP81_LQFP176_UFBGA176 (*) 00249 * @arg @ref LL_UTILS_PACKAGETYPE_LQFP144_UFBGA144_UFBGA144_UFBGA100 (*) 00250 * @arg @ref LL_UTILS_PACKAGETYPE_LQFP100_LQFP208_TFBGA216 (*) 00251 * @arg @ref LL_UTILS_PACKAGETYPE_LQFP208_TFBGA216 (*) 00252 * @arg @ref LL_UTILS_PACKAGETYPE_TQFP64_UFBGA144_LQFP144 (*) 00253 * 00254 * (*) value not defined in all devices. 00255 */ 00256 __STATIC_INLINE uint32_t LL_GetPackageType(void) 00257 { 00258 return (uint8_t)(READ_REG(*((uint32_t *)PACKAGE_BASE_ADDRESS)) & 0x0700U); 00259 } 00260 00261 /** 00262 * @} 00263 */ 00264 00265 /** @defgroup UTILS_LL_EF_DELAY DELAY 00266 * @{ 00267 */ 00268 00269 /** 00270 * @brief This function configures the Cortex-M SysTick source of the time base. 00271 * @param HCLKFrequency HCLK frequency in Hz (can be calculated thanks to RCC helper macro) 00272 * @note When a RTOS is used, it is recommended to avoid changing the SysTick 00273 * configuration by calling this function, for a delay use rather osDelay RTOS service. 00274 * @param Ticks Number of ticks 00275 * @retval None 00276 */ 00277 __STATIC_INLINE void LL_InitTick(uint32_t HCLKFrequency, uint32_t Ticks) 00278 { 00279 /* Configure the SysTick to have interrupt in 1ms time base */ 00280 SysTick->LOAD = (uint32_t)((HCLKFrequency / Ticks) - 1UL); /* set reload register */ 00281 SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ 00282 SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | 00283 SysTick_CTRL_ENABLE_Msk; /* Enable the Systick Timer */ 00284 } 00285 00286 void LL_Init1msTick(uint32_t HCLKFrequency); 00287 void LL_mDelay(uint32_t Delay); 00288 00289 /** 00290 * @} 00291 */ 00292 00293 /** @defgroup UTILS_EF_SYSTEM SYSTEM 00294 * @{ 00295 */ 00296 00297 void LL_SetSystemCoreClock(uint32_t HCLKFrequency); 00298 ErrorStatus LL_PLL_ConfigSystemClock_HSI(LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, 00299 LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct); 00300 ErrorStatus LL_PLL_ConfigSystemClock_HSE(uint32_t HSEFrequency, uint32_t HSEBypass, 00301 LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct); 00302 00303 /** 00304 * @} 00305 */ 00306 00307 /** 00308 * @} 00309 */ 00310 00311 /** 00312 * @} 00313 */ 00314 00315 /** 00316 * @} 00317 */ 00318 00319 #ifdef __cplusplus 00320 } 00321 #endif 00322 00323 #endif /* __STM32F4xx_LL_UTILS_H */ 00324 00325 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
1.7.6.1