STM32F103xB HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32f1xx_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) 2016 STMicroelectronics. 00022 * All rights reserved.</center></h2> 00023 * 00024 * This software component is licensed by ST under BSD 3-Clause license, 00025 * the "License"; You may not use this file except in compliance with the 00026 * License. You may obtain a copy of the License at: 00027 * opensource.org/licenses/BSD-3-Clause 00028 * 00029 ****************************************************************************** 00030 */ 00031 00032 /* Define to prevent recursive inclusion -------------------------------------*/ 00033 #ifndef __STM32F1xx_LL_UTILS_H 00034 #define __STM32F1xx_LL_UTILS_H 00035 00036 #ifdef __cplusplus 00037 extern "C" { 00038 #endif 00039 00040 /* Includes ------------------------------------------------------------------*/ 00041 #include "stm32f1xx.h" 00042 00043 /** @addtogroup STM32F1xx_LL_Driver 00044 * @{ 00045 */ 00046 00047 /** @defgroup UTILS_LL UTILS 00048 * @{ 00049 */ 00050 00051 /* Private types -------------------------------------------------------------*/ 00052 /* Private variables ---------------------------------------------------------*/ 00053 00054 /* Private constants ---------------------------------------------------------*/ 00055 /** @defgroup UTILS_LL_Private_Constants UTILS Private Constants 00056 * @{ 00057 */ 00058 00059 /* Max delay can be used in LL_mDelay */ 00060 #define LL_MAX_DELAY 0xFFFFFFFFU 00061 00062 /** 00063 * @brief Unique device ID register base address 00064 */ 00065 #define UID_BASE_ADDRESS UID_BASE 00066 00067 /** 00068 * @brief Flash size data register base address 00069 */ 00070 #define FLASHSIZE_BASE_ADDRESS FLASHSIZE_BASE 00071 00072 /** 00073 * @} 00074 */ 00075 00076 /* Private macros ------------------------------------------------------------*/ 00077 /** @defgroup UTILS_LL_Private_Macros UTILS Private Macros 00078 * @{ 00079 */ 00080 /** 00081 * @} 00082 */ 00083 /* Exported types ------------------------------------------------------------*/ 00084 /** @defgroup UTILS_LL_ES_INIT UTILS Exported structures 00085 * @{ 00086 */ 00087 /** 00088 * @brief UTILS PLL structure definition 00089 */ 00090 typedef struct 00091 { 00092 uint32_t PLLMul; /*!< Multiplication factor for PLL VCO input clock. 00093 This parameter can be a value of @ref RCC_LL_EC_PLL_MUL 00094 00095 This feature can be modified afterwards using unitary function 00096 @ref LL_RCC_PLL_ConfigDomain_SYS(). */ 00097 00098 uint32_t Prediv; /*!< Division factor for HSE used as PLL clock source. 00099 This parameter can be a value of @ref RCC_LL_EC_PREDIV_DIV 00100 00101 This feature can be modified afterwards using unitary function 00102 @ref LL_RCC_PLL_ConfigDomain_SYS(). */ 00103 } LL_UTILS_PLLInitTypeDef; 00104 00105 /** 00106 * @brief UTILS System, AHB and APB buses clock configuration structure definition 00107 */ 00108 typedef struct 00109 { 00110 uint32_t AHBCLKDivider; /*!< The AHB clock (HCLK) divider. This clock is derived from the system clock (SYSCLK). 00111 This parameter can be a value of @ref RCC_LL_EC_SYSCLK_DIV 00112 00113 This feature can be modified afterwards using unitary function 00114 @ref LL_RCC_SetAHBPrescaler(). */ 00115 00116 uint32_t APB1CLKDivider; /*!< The APB1 clock (PCLK1) divider. This clock is derived from the AHB clock (HCLK). 00117 This parameter can be a value of @ref RCC_LL_EC_APB1_DIV 00118 00119 This feature can be modified afterwards using unitary function 00120 @ref LL_RCC_SetAPB1Prescaler(). */ 00121 00122 uint32_t APB2CLKDivider; /*!< The APB2 clock (PCLK2) divider. This clock is derived from the AHB clock (HCLK). 00123 This parameter can be a value of @ref RCC_LL_EC_APB2_DIV 00124 00125 This feature can be modified afterwards using unitary function 00126 @ref LL_RCC_SetAPB2Prescaler(). */ 00127 00128 } LL_UTILS_ClkInitTypeDef; 00129 00130 /** 00131 * @} 00132 */ 00133 00134 /* Exported constants --------------------------------------------------------*/ 00135 /** @defgroup UTILS_LL_Exported_Constants UTILS Exported Constants 00136 * @{ 00137 */ 00138 00139 /** @defgroup UTILS_EC_HSE_BYPASS HSE Bypass activation 00140 * @{ 00141 */ 00142 #define LL_UTILS_HSEBYPASS_OFF 0x00000000U /*!< HSE Bypass is not enabled */ 00143 #define LL_UTILS_HSEBYPASS_ON 0x00000001U /*!< HSE Bypass is enabled */ 00144 /** 00145 * @} 00146 */ 00147 00148 /** 00149 * @} 00150 */ 00151 00152 /* Exported macro ------------------------------------------------------------*/ 00153 00154 /* Exported functions --------------------------------------------------------*/ 00155 /** @defgroup UTILS_LL_Exported_Functions UTILS Exported Functions 00156 * @{ 00157 */ 00158 00159 /** @defgroup UTILS_EF_DEVICE_ELECTRONIC_SIGNATURE DEVICE ELECTRONIC SIGNATURE 00160 * @{ 00161 */ 00162 00163 /** 00164 * @brief Get Word0 of the unique device identifier (UID based on 96 bits) 00165 * @retval UID[31:0] 00166 */ 00167 __STATIC_INLINE uint32_t LL_GetUID_Word0(void) 00168 { 00169 return (uint32_t)(READ_REG(*((uint32_t *)UID_BASE_ADDRESS))); 00170 } 00171 00172 /** 00173 * @brief Get Word1 of the unique device identifier (UID based on 96 bits) 00174 * @retval UID[63:32] 00175 */ 00176 __STATIC_INLINE uint32_t LL_GetUID_Word1(void) 00177 { 00178 return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS + 4U)))); 00179 } 00180 00181 /** 00182 * @brief Get Word2 of the unique device identifier (UID based on 96 bits) 00183 * @retval UID[95:64] 00184 */ 00185 __STATIC_INLINE uint32_t LL_GetUID_Word2(void) 00186 { 00187 return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS + 8U)))); 00188 } 00189 00190 /** 00191 * @brief Get Flash memory size 00192 * @note This bitfield indicates the size of the device Flash memory expressed in 00193 * Kbytes. As an example, 0x040 corresponds to 64 Kbytes. 00194 * @retval FLASH_SIZE[15:0]: Flash memory size 00195 */ 00196 __STATIC_INLINE uint32_t LL_GetFlashSize(void) 00197 { 00198 return (uint16_t)(READ_REG(*((uint32_t *)FLASHSIZE_BASE_ADDRESS))); 00199 } 00200 00201 00202 /** 00203 * @} 00204 */ 00205 00206 /** @defgroup UTILS_LL_EF_DELAY DELAY 00207 * @{ 00208 */ 00209 00210 /** 00211 * @brief This function configures the Cortex-M SysTick source of the time base. 00212 * @param HCLKFrequency HCLK frequency in Hz (can be calculated thanks to RCC helper macro) 00213 * @note When a RTOS is used, it is recommended to avoid changing the SysTick 00214 * configuration by calling this function, for a delay use rather osDelay RTOS service. 00215 * @param Ticks Number of ticks 00216 * @retval None 00217 */ 00218 __STATIC_INLINE void LL_InitTick(uint32_t HCLKFrequency, uint32_t Ticks) 00219 { 00220 /* Configure the SysTick to have interrupt in 1ms time base */ 00221 SysTick->LOAD = (uint32_t)((HCLKFrequency / Ticks) - 1UL); /* set reload register */ 00222 SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ 00223 SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | 00224 SysTick_CTRL_ENABLE_Msk; /* Enable the Systick Timer */ 00225 } 00226 00227 void LL_Init1msTick(uint32_t HCLKFrequency); 00228 void LL_mDelay(uint32_t Delay); 00229 00230 /** 00231 * @} 00232 */ 00233 00234 /** @defgroup UTILS_EF_SYSTEM SYSTEM 00235 * @{ 00236 */ 00237 00238 void LL_SetSystemCoreClock(uint32_t HCLKFrequency); 00239 #if defined(FLASH_ACR_LATENCY) 00240 ErrorStatus LL_SetFlashLatency(uint32_t Frequency); 00241 #endif /* FLASH_ACR_LATENCY */ 00242 ErrorStatus LL_PLL_ConfigSystemClock_HSI(LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, 00243 LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct); 00244 ErrorStatus LL_PLL_ConfigSystemClock_HSE(uint32_t HSEFrequency, uint32_t HSEBypass, 00245 LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct); 00246 #if defined(RCC_PLL2_SUPPORT) 00247 ErrorStatus LL_PLL_ConfigSystemClock_PLL2(uint32_t HSEFrequency, uint32_t HSEBypass, LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, 00248 LL_UTILS_PLLInitTypeDef *UTILS_PLL2InitStruct, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct); 00249 #endif /* RCC_PLL2_SUPPORT */ 00250 /** 00251 * @} 00252 */ 00253 00254 /** 00255 * @} 00256 */ 00257 00258 /** 00259 * @} 00260 */ 00261 00262 /** 00263 * @} 00264 */ 00265 00266 #ifdef __cplusplus 00267 } 00268 #endif 00269 00270 #endif /* __STM32F1xx_LL_UTILS_H */ 00271 00272 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/