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