STM32L443xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32l4xx_ll_utils.h 00004 * @author MCD Application Team 00005 * @brief Header file of UTILS LL module. 00006 * 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 @verbatim 00019 ============================================================================== 00020 ##### How to use this driver ##### 00021 ============================================================================== 00022 [..] 00023 The LL UTILS driver contains a set of generic APIs that can be 00024 used by user: 00025 (+) Device electronic signature 00026 (+) Timing functions 00027 (+) PLL configuration functions 00028 00029 @endverbatim 00030 ****************************************************************************** 00031 */ 00032 00033 /* Define to prevent recursive inclusion -------------------------------------*/ 00034 #ifndef STM32L4xx_LL_UTILS_H 00035 #define STM32L4xx_LL_UTILS_H 00036 00037 #ifdef __cplusplus 00038 extern "C" { 00039 #endif 00040 00041 /* Includes ------------------------------------------------------------------*/ 00042 #include "stm32l4xx.h" 00043 00044 /** @addtogroup STM32L4xx_LL_Driver 00045 * @{ 00046 */ 00047 00048 /** @defgroup UTILS_LL UTILS 00049 * @{ 00050 */ 00051 00052 /* Private types -------------------------------------------------------------*/ 00053 /* Private variables ---------------------------------------------------------*/ 00054 00055 /* Private constants ---------------------------------------------------------*/ 00056 /** @defgroup UTILS_LL_Private_Constants UTILS Private Constants 00057 * @{ 00058 */ 00059 00060 /* Max delay can be used in LL_mDelay */ 00061 #define LL_MAX_DELAY 0xFFFFFFFFU 00062 00063 /** 00064 * @brief Unique device ID register base address 00065 */ 00066 #define UID_BASE_ADDRESS UID_BASE 00067 00068 /** 00069 * @brief Flash size data register base address 00070 */ 00071 #define FLASHSIZE_BASE_ADDRESS FLASHSIZE_BASE 00072 00073 /** 00074 * @brief Package data register base address 00075 */ 00076 #define PACKAGE_BASE_ADDRESS PACKAGE_BASE 00077 00078 /** 00079 * @} 00080 */ 00081 00082 /* Private macros ------------------------------------------------------------*/ 00083 /** @defgroup UTILS_LL_Private_Macros UTILS Private Macros 00084 * @{ 00085 */ 00086 /** 00087 * @} 00088 */ 00089 /* Exported types ------------------------------------------------------------*/ 00090 /** @defgroup UTILS_LL_ES_INIT UTILS Exported structures 00091 * @{ 00092 */ 00093 /** 00094 * @brief UTILS PLL structure definition 00095 */ 00096 typedef struct 00097 { 00098 uint32_t PLLM; /*!< Division factor for PLL VCO input clock. 00099 This parameter can be a value of @ref RCC_LL_EC_PLLM_DIV 00100 00101 This feature can be modified afterwards using unitary function 00102 @ref LL_RCC_PLL_ConfigDomain_SYS(). */ 00103 00104 uint32_t PLLN; /*!< Multiplication factor for PLL VCO output clock. 00105 This parameter must be a number between Min_Data = 8 and Max_Data = 86 00106 00107 This feature can be modified afterwards using unitary function 00108 @ref LL_RCC_PLL_ConfigDomain_SYS(). */ 00109 00110 uint32_t PLLR; /*!< Division for the main system clock. 00111 This parameter can be a value of @ref RCC_LL_EC_PLLR_DIV 00112 00113 This feature can be modified afterwards using unitary function 00114 @ref LL_RCC_PLL_ConfigDomain_SYS(). */ 00115 } LL_UTILS_PLLInitTypeDef; 00116 00117 /** 00118 * @brief UTILS System, AHB and APB buses clock configuration structure definition 00119 */ 00120 typedef struct 00121 { 00122 uint32_t AHBCLKDivider; /*!< The AHB clock (HCLK) divider. This clock is derived from the system clock (SYSCLK). 00123 This parameter can be a value of @ref RCC_LL_EC_SYSCLK_DIV 00124 00125 This feature can be modified afterwards using unitary function 00126 @ref LL_RCC_SetAHBPrescaler(). */ 00127 00128 uint32_t APB1CLKDivider; /*!< The APB1 clock (PCLK1) divider. This clock is derived from the AHB clock (HCLK). 00129 This parameter can be a value of @ref RCC_LL_EC_APB1_DIV 00130 00131 This feature can be modified afterwards using unitary function 00132 @ref LL_RCC_SetAPB1Prescaler(). */ 00133 00134 uint32_t APB2CLKDivider; /*!< The APB2 clock (PCLK2) divider. This clock is derived from the AHB clock (HCLK). 00135 This parameter can be a value of @ref RCC_LL_EC_APB2_DIV 00136 00137 This feature can be modified afterwards using unitary function 00138 @ref LL_RCC_SetAPB2Prescaler(). */ 00139 00140 } LL_UTILS_ClkInitTypeDef; 00141 00142 /** 00143 * @} 00144 */ 00145 00146 /* Exported constants --------------------------------------------------------*/ 00147 /** @defgroup UTILS_LL_Exported_Constants UTILS Exported Constants 00148 * @{ 00149 */ 00150 00151 /** @defgroup UTILS_EC_HSE_BYPASS HSE Bypass activation 00152 * @{ 00153 */ 00154 #define LL_UTILS_HSEBYPASS_OFF 0x00000000U /*!< HSE Bypass is not enabled */ 00155 #define LL_UTILS_HSEBYPASS_ON 0x00000001U /*!< HSE Bypass is enabled */ 00156 /** 00157 * @} 00158 */ 00159 00160 /** @defgroup UTILS_EC_PACKAGETYPE PACKAGE TYPE 00161 * @{ 00162 */ 00163 #define LL_UTILS_PACKAGETYPE_LQFP64 0x00000000U /*!< LQFP64 package type */ 00164 #define LL_UTILS_PACKAGETYPE_WLCSP64 0x00000001U /*!< WLCSP64 package type */ 00165 #define LL_UTILS_PACKAGETYPE_LQFP100 0x00000002U /*!< LQFP100 package type */ 00166 #define LL_UTILS_PACKAGETYPE_BGA132 0x00000003U /*!< BGA132 package type */ 00167 #define LL_UTILS_PACKAGETYPE_LQFP144_CSP72 0x00000004U /*!< LQFP144, WLCSP81 or WLCSP72 package type */ 00168 #define LL_UTILS_PACKAGETYPE_UFQFPN32 0x00000008U /*!< UFQFPN32 package type */ 00169 #define LL_UTILS_PACKAGETYPE_UFQFPN48 0x0000000AU /*!< UFQFPN48 package type */ 00170 #define LL_UTILS_PACKAGETYPE_LQFP48 0x0000000BU /*!< LQFP48 package type */ 00171 #define LL_UTILS_PACKAGETYPE_WLCSP49 0x0000000CU /*!< WLCSP49 package type */ 00172 #define LL_UTILS_PACKAGETYPE_UFBGA64 0x0000000DU /*!< UFBGA64 package type */ 00173 #define LL_UTILS_PACKAGETYPE_UFBGA100 0x0000000EU /*!< UFBGA100 package type */ 00174 #define LL_UTILS_PACKAGETYPE_UFBGA169_CSP115 0x00000010U /*!< UFBGA169 or WLCSP115 package type */ 00175 #define LL_UTILS_PACKAGETYPE_LQFP100_DSI 0x00000012U /*!< LQFP100 with DSI package type */ 00176 #define LL_UTILS_PACKAGETYPE_WLCSP144_DSI 0x00000013U /*!< WLCSP144 with DSI package type */ 00177 #define LL_UTILS_PACKAGETYPE_UFBGA144_DSI 0x00000013U /*!< UFBGA144 with DSI package type */ 00178 #define LL_UTILS_PACKAGETYPE_UFBGA169_DSI 0x00000014U /*!< UFBGA169 with DSI package type */ 00179 #define LL_UTILS_PACKAGETYPE_LQFP144_DSI 0x00000015U /*!< LQFP144 with DSI package type */ 00180 /** 00181 * @} 00182 */ 00183 00184 /** 00185 * @} 00186 */ 00187 00188 /* Exported macro ------------------------------------------------------------*/ 00189 00190 /* Exported functions --------------------------------------------------------*/ 00191 /** @defgroup UTILS_LL_Exported_Functions UTILS Exported Functions 00192 * @{ 00193 */ 00194 00195 /** @defgroup UTILS_EF_DEVICE_ELECTRONIC_SIGNATURE DEVICE ELECTRONIC SIGNATURE 00196 * @{ 00197 */ 00198 00199 /** 00200 * @brief Get Word0 of the unique device identifier (UID based on 96 bits) 00201 * @retval UID[31:0]: X and Y coordinates on the wafer expressed in BCD format 00202 */ 00203 __STATIC_INLINE uint32_t LL_GetUID_Word0(void) 00204 { 00205 return (uint32_t)(READ_REG(*((uint32_t *)UID_BASE_ADDRESS))); 00206 } 00207 00208 /** 00209 * @brief Get Word1 of the unique device identifier (UID based on 96 bits) 00210 * @retval UID[63:32]: Wafer number (UID[39:32]) & LOT_NUM[23:0] (UID[63:40]) 00211 */ 00212 __STATIC_INLINE uint32_t LL_GetUID_Word1(void) 00213 { 00214 return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS + 4U)))); 00215 } 00216 00217 /** 00218 * @brief Get Word2 of the unique device identifier (UID based on 96 bits) 00219 * @retval UID[95:64]: Lot number (ASCII encoded) - LOT_NUM[55:24] 00220 */ 00221 __STATIC_INLINE uint32_t LL_GetUID_Word2(void) 00222 { 00223 return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS + 8U)))); 00224 } 00225 00226 /** 00227 * @brief Get Flash memory size 00228 * @note This bitfield indicates the size of the device Flash memory expressed in 00229 * Kbytes. As an example, 0x040 corresponds to 64 Kbytes. 00230 * @retval FLASH_SIZE[15:0]: Flash memory size 00231 */ 00232 __STATIC_INLINE uint32_t LL_GetFlashSize(void) 00233 { 00234 return (uint32_t)(READ_REG(*((uint32_t *)FLASHSIZE_BASE_ADDRESS)) & 0xFFFFU); 00235 } 00236 00237 /** 00238 * @brief Get Package type 00239 * @retval Returned value can be one of the following values: 00240 * @arg @ref LL_UTILS_PACKAGETYPE_LQFP64 (*) 00241 * @arg @ref LL_UTILS_PACKAGETYPE_LQFP100 (*) 00242 * @arg @ref LL_UTILS_PACKAGETYPE_BGA132 (*) 00243 * @arg @ref LL_UTILS_PACKAGETYPE_LQFP144_CSP72 (*) 00244 * @arg @ref LL_UTILS_PACKAGETYPE_UFQFPN32 (*) 00245 * @arg @ref LL_UTILS_PACKAGETYPE_UFQFPN48 (*) 00246 * @arg @ref LL_UTILS_PACKAGETYPE_LQFP48 (*) 00247 * @arg @ref LL_UTILS_PACKAGETYPE_WLCSP49 (*) 00248 * @arg @ref LL_UTILS_PACKAGETYPE_UFBGA64 (*) 00249 * @arg @ref LL_UTILS_PACKAGETYPE_UFBGA100 (*) 00250 * @arg @ref LL_UTILS_PACKAGETYPE_UFBGA169 (*) 00251 * @arg @ref LL_UTILS_PACKAGETYPE_LQFP100_DSI (*) 00252 * @arg @ref LL_UTILS_PACKAGETYPE_WLCSP144_DSI (*) 00253 * @arg @ref LL_UTILS_PACKAGETYPE_UFBGA144_DSI (*) 00254 * @arg @ref LL_UTILS_PACKAGETYPE_UFBGA169_DSI (*) 00255 * @arg @ref LL_UTILS_PACKAGETYPE_LQFP144_DSI (*) 00256 * 00257 * (*) value not defined in all devices. 00258 */ 00259 __STATIC_INLINE uint32_t LL_GetPackageType(void) 00260 { 00261 return (uint32_t)(READ_REG(*((uint32_t *)PACKAGE_BASE_ADDRESS)) & 0x1FU); 00262 } 00263 00264 /** 00265 * @} 00266 */ 00267 00268 /** @defgroup UTILS_LL_EF_DELAY DELAY 00269 * @{ 00270 */ 00271 00272 /** 00273 * @brief This function configures the Cortex-M SysTick source of the time base. 00274 * @param HCLKFrequency HCLK frequency in Hz (can be calculated thanks to RCC helper macro) 00275 * @note When a RTOS is used, it is recommended to avoid changing the SysTick 00276 * configuration by calling this function, for a delay use rather osDelay RTOS service. 00277 * @param Ticks Number of ticks 00278 * @retval None 00279 */ 00280 __STATIC_INLINE void LL_InitTick(uint32_t HCLKFrequency, uint32_t Ticks) 00281 { 00282 /* Configure the SysTick to have interrupt in 1ms time base */ 00283 SysTick->LOAD = (uint32_t)((HCLKFrequency / Ticks) - 1UL); /* set reload register */ 00284 SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ 00285 SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | 00286 SysTick_CTRL_ENABLE_Msk; /* Enable the Systick Timer */ 00287 } 00288 00289 void LL_Init1msTick(uint32_t HCLKFrequency); 00290 void LL_mDelay(uint32_t Delay); 00291 00292 /** 00293 * @} 00294 */ 00295 00296 /** @defgroup UTILS_EF_SYSTEM SYSTEM 00297 * @{ 00298 */ 00299 00300 void LL_SetSystemCoreClock(uint32_t HCLKFrequency); 00301 ErrorStatus LL_SetFlashLatency(uint32_t HCLKFrequency); 00302 ErrorStatus LL_PLL_ConfigSystemClock_MSI(LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, 00303 LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct); 00304 ErrorStatus LL_PLL_ConfigSystemClock_HSI(LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, 00305 LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct); 00306 ErrorStatus LL_PLL_ConfigSystemClock_HSE(uint32_t HSEFrequency, uint32_t HSEBypass, 00307 LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct); 00308 00309 /** 00310 * @} 00311 */ 00312 00313 /** 00314 * @} 00315 */ 00316 00317 /** 00318 * @} 00319 */ 00320 00321 /** 00322 * @} 00323 */ 00324 00325 #ifdef __cplusplus 00326 } 00327 #endif 00328 00329 #endif /* STM32L4xx_LL_UTILS_H */