2 ******************************************************************************
3 * @file stm32f3xx_ll_utils.h
4 * @author MCD Application Team
5 * @brief Header file of UTILS LL module.
7 ==============================================================================
8 ##### How to use this driver #####
9 ==============================================================================
11 The LL UTILS driver contains a set of generic APIs that can be
13 (+) Device electronic signature
15 (+) PLL configuration functions
18 ******************************************************************************
21 * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
23 * Redistribution and use in source and binary forms, with or without modification,
24 * are permitted provided that the following conditions are met:
25 * 1. Redistributions of source code must retain the above copyright notice,
26 * this list of conditions and the following disclaimer.
27 * 2. Redistributions in binary form must reproduce the above copyright notice,
28 * this list of conditions and the following disclaimer in the documentation
29 * and/or other materials provided with the distribution.
30 * 3. Neither the name of STMicroelectronics nor the names of its contributors
31 * may be used to endorse or promote products derived from this software
32 * without specific prior written permission.
34 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
35 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
36 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
37 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
38 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
39 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
40 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
41 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
42 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
43 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 ******************************************************************************
48 /* Define to prevent recursive inclusion -------------------------------------*/
49 #ifndef __STM32F3xx_LL_UTILS_H
50 #define __STM32F3xx_LL_UTILS_H
56 /* Includes ------------------------------------------------------------------*/
57 #include "stm32f3xx.h"
59 /** @addtogroup STM32F3xx_LL_Driver
63 /** @defgroup UTILS_LL UTILS
67 /* Private types -------------------------------------------------------------*/
68 /* Private variables ---------------------------------------------------------*/
70 /* Private constants ---------------------------------------------------------*/
71 /** @defgroup UTILS_LL_Private_Constants UTILS Private Constants
75 /* Max delay can be used in LL_mDelay */
76 #define LL_MAX_DELAY 0xFFFFFFFFU
79 * @brief Unique device ID register base address
81 #define UID_BASE_ADDRESS UID_BASE
84 * @brief Flash size data register base address
86 #define FLASHSIZE_BASE_ADDRESS FLASHSIZE_BASE
89 * @brief Package data register base address
91 #define PACKAGE_BASE_ADDRESS PACKAGE_BASE
97 /* Private macros ------------------------------------------------------------*/
98 /** @defgroup UTILS_LL_Private_Macros UTILS Private Macros
104 /* Exported types ------------------------------------------------------------*/
105 /** @defgroup UTILS_LL_ES_INIT UTILS Exported structures
109 * @brief UTILS PLL structure definition
113 uint32_t PLLMul
; /*!< Multiplication factor for PLL VCO input clock.
114 This parameter can be a value of @ref RCC_LL_EC_PLL_MUL
116 This feature can be modified afterwards using unitary function
117 @ref LL_RCC_PLL_ConfigDomain_SYS(). */
119 #if defined(RCC_PLLSRC_PREDIV1_SUPPORT)
120 uint32_t PLLDiv
; /*!< Division factor for PLL VCO output clock.
121 This parameter can be a value of @ref RCC_LL_EC_PREDIV_DIV
123 This feature can be modified afterwards using unitary function
124 @ref LL_RCC_PLL_ConfigDomain_SYS(). */
126 uint32_t Prediv
; /*!< Division factor for HSE used as PLL clock source.
127 This parameter can be a value of @ref RCC_LL_EC_PREDIV_DIV
129 This feature can be modified afterwards using unitary function
130 @ref LL_RCC_PLL_ConfigDomain_SYS(). */
131 #endif /* RCC_PLLSRC_PREDIV1_SUPPORT */
132 } LL_UTILS_PLLInitTypeDef
;
135 * @brief UTILS System, AHB and APB buses clock configuration structure definition
139 uint32_t AHBCLKDivider
; /*!< The AHB clock (HCLK) divider. This clock is derived from the system clock (SYSCLK).
140 This parameter can be a value of @ref RCC_LL_EC_SYSCLK_DIV
142 This feature can be modified afterwards using unitary function
143 @ref LL_RCC_SetAHBPrescaler(). */
145 uint32_t APB1CLKDivider
; /*!< The APB1 clock (PCLK1) divider. This clock is derived from the AHB clock (HCLK).
146 This parameter can be a value of @ref RCC_LL_EC_APB1_DIV
148 This feature can be modified afterwards using unitary function
149 @ref LL_RCC_SetAPB1Prescaler(). */
151 uint32_t APB2CLKDivider
; /*!< The APB2 clock (PCLK2) divider. This clock is derived from the AHB clock (HCLK).
152 This parameter can be a value of @ref RCC_LL_EC_APB2_DIV
154 This feature can be modified afterwards using unitary function
155 @ref LL_RCC_SetAPB2Prescaler(). */
157 } LL_UTILS_ClkInitTypeDef
;
163 /* Exported constants --------------------------------------------------------*/
164 /** @defgroup UTILS_LL_Exported_Constants UTILS Exported Constants
168 /** @defgroup UTILS_EC_HSE_BYPASS HSE Bypass activation
171 #define LL_UTILS_HSEBYPASS_OFF 0x00000000U /*!< HSE Bypass is not enabled */
172 #define LL_UTILS_HSEBYPASS_ON 0x00000001U /*!< HSE Bypass is enabled */
181 /* Exported macro ------------------------------------------------------------*/
183 /* Exported functions --------------------------------------------------------*/
184 /** @defgroup UTILS_LL_Exported_Functions UTILS Exported Functions
188 /** @defgroup UTILS_EF_DEVICE_ELECTRONIC_SIGNATURE DEVICE ELECTRONIC SIGNATURE
193 * @brief Get Word0 of the unique device identifier (UID based on 96 bits)
194 * @retval UID[31:0]: X and Y coordinates on the wafer expressed in BCD format
196 __STATIC_INLINE
uint32_t LL_GetUID_Word0(void)
198 return (uint32_t)(READ_REG(*((uint32_t *)UID_BASE_ADDRESS
)));
202 * @brief Get Word1 of the unique device identifier (UID based on 96 bits)
203 * @retval UID[63:32]: Wafer number (UID[39:32]) & LOT_NUM[23:0] (UID[63:40])
205 __STATIC_INLINE
uint32_t LL_GetUID_Word1(void)
207 return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS
+ 4U))));
211 * @brief Get Word2 of the unique device identifier (UID based on 96 bits)
212 * @retval UID[95:64]: Lot number (ASCII encoded) - LOT_NUM[55:24]
214 __STATIC_INLINE
uint32_t LL_GetUID_Word2(void)
216 return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS
+ 8U))));
220 * @brief Get Flash memory size
221 * @note This bitfield indicates the size of the device Flash memory expressed in
222 * Kbytes. As an example, 0x040 corresponds to 64 Kbytes.
223 * @retval FLASH_SIZE[15:0]: Flash memory size
225 __STATIC_INLINE
uint32_t LL_GetFlashSize(void)
227 return (uint16_t)(READ_REG(*((uint32_t *)FLASHSIZE_BASE_ADDRESS
)));
235 /** @defgroup UTILS_LL_EF_DELAY DELAY
240 * @brief This function configures the Cortex-M SysTick source of the time base.
241 * @param HCLKFrequency HCLK frequency in Hz (can be calculated thanks to RCC helper macro)
242 * @note When a RTOS is used, it is recommended to avoid changing the SysTick
243 * configuration by calling this function, for a delay use rather osDelay RTOS service.
244 * @param Ticks Number of ticks
247 __STATIC_INLINE
void LL_InitTick(uint32_t HCLKFrequency
, uint32_t Ticks
)
249 /* Configure the SysTick to have interrupt in 1ms time base */
250 SysTick
->LOAD
= (uint32_t)((HCLKFrequency
/ Ticks
) - 1UL); /* set reload register */
251 SysTick
->VAL
= 0UL; /* Load the SysTick Counter Value */
252 SysTick
->CTRL
= SysTick_CTRL_CLKSOURCE_Msk
|
253 SysTick_CTRL_ENABLE_Msk
; /* Enable the Systick Timer */
256 void LL_Init1msTick(uint32_t HCLKFrequency
);
257 void LL_mDelay(uint32_t Delay
);
263 /** @defgroup UTILS_EF_SYSTEM SYSTEM
267 void LL_SetSystemCoreClock(uint32_t HCLKFrequency
);
268 ErrorStatus
LL_PLL_ConfigSystemClock_HSI(LL_UTILS_PLLInitTypeDef
*UTILS_PLLInitStruct
,
269 LL_UTILS_ClkInitTypeDef
*UTILS_ClkInitStruct
);
270 ErrorStatus
LL_PLL_ConfigSystemClock_HSE(uint32_t HSEFrequency
, uint32_t HSEBypass
,
271 LL_UTILS_PLLInitTypeDef
*UTILS_PLLInitStruct
, LL_UTILS_ClkInitTypeDef
*UTILS_ClkInitStruct
);
293 #endif /* __STM32F3xx_LL_UTILS_H */
295 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/