Set blackbox file handler to NULL after closing file
[inav.git] / lib / main / STM32H7 / Drivers / STM32H7xx_HAL_Driver / Inc / stm32h7xx_ll_utils.h
blob63912648df35341d8039e5b149e20b7ce6c542ae
1 /**
2 ******************************************************************************
3 * @file stm32h7xx_ll_utils.h
4 * @author MCD Application Team
5 * @brief Header file of UTILS LL module.
6 @verbatim
7 ==============================================================================
8 ##### How to use this driver #####
9 ==============================================================================
10 [..]
11 The LL UTILS driver contains a set of generic APIs that can be
12 used by user:
13 (+) Device electronic signature
14 (+) Timing functions
15 (+) PLL configuration functions
17 @endverbatim
18 ******************************************************************************
19 * @attention
21 * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
22 * All rights reserved.</center></h2>
24 * This software component is licensed by ST under BSD 3-Clause license,
25 * the "License"; You may not use this file except in compliance with the
26 * License. You may obtain a copy of the License at:
27 * opensource.org/licenses/BSD-3-Clause
29 ******************************************************************************
32 /* Define to prevent recursive inclusion -------------------------------------*/
33 #ifndef STM32H7xx_LL_UTILS_H
34 #define STM32H7xx_LL_UTILS_H
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
40 /* Includes ------------------------------------------------------------------*/
41 #include "stm32h7xx.h"
42 #include "stm32h7xx_ll_system.h"
43 #include "stm32h7xx_ll_bus.h"
45 /** @addtogroup STM32H7xx_LL_Driver
46 * @{
49 /** @defgroup UTILS_LL UTILS
50 * @{
53 /* Private types -------------------------------------------------------------*/
54 /* Private variables ---------------------------------------------------------*/
56 /* Private constants ---------------------------------------------------------*/
57 /** @defgroup UTILS_LL_Private_Constants UTILS Private Constants
58 * @{
61 /* Max delay can be used in LL_mDelay */
62 #define LL_MAX_DELAY 0xFFFFFFFFU
64 /**
65 * @brief Unique device ID register base address
67 #define UID_BASE_ADDRESS UID_BASE
69 /**
70 * @brief Flash size data register base address
72 #define FLASHSIZE_BASE_ADDRESS FLASHSIZE_BASE
74 /**
75 * @brief Package data register base address
77 #define PACKAGE_BASE_ADDRESS PACKAGE_BASE
79 /**
80 * @}
83 /* Private macros ------------------------------------------------------------*/
84 /** @defgroup UTILS_LL_Private_Macros UTILS Private Macros
85 * @{
87 /**
88 * @}
90 /* Exported types ------------------------------------------------------------*/
91 /** @defgroup UTILS_LL_ES_INIT UTILS Exported structures
92 * @{
94 /**
95 * @brief UTILS PLL structure definition
97 typedef struct
99 uint32_t PLLM; /*!< Division factor for PLL VCO input clock.
100 This parameter must be a number between Min_Data = 0 and Max_Data = 63
102 This feature can be modified afterwards using unitary function
103 @ref LL_RCC_PLL1_SetM(). */
105 uint32_t PLLN; /*!< Multiplication factor for PLL VCO output clock.
106 This parameter must be a number between Min_Data = 4 and Max_Data = 512
108 This feature can be modified afterwards using unitary function
109 @ref LL_RCC_PLL1_SetN(). */
111 uint32_t PLLP; /*!< Division for the main system clock.
112 This parameter must be a number between Min_Data = 2 and Max_Data = 128
113 odd division factors are not allowed
115 This feature can be modified afterwards using unitary function
116 @ref LL_RCC_PLL1_SetP(). */
118 uint32_t FRACN; /*!< Fractional part of the multiplication factor for PLL VCO.
119 This parameter can be a value between 0 and 8191
121 This feature can be modified afterwards using unitary function
122 @ref LL_RCC_PLL1_SetFRACN(). */
124 uint32_t VCO_Input; /*!< Fractional part of the multiplication factor for PLL VCO.
125 This parameter can be a value of @ref RCC_LL_EC_PLLINPUTRANGE
127 This feature can be modified afterwards using unitary function
128 @ref LL_RCC_PLL1_SetVCOInputRange(). */
130 uint32_t VCO_Output; /*!< Fractional part of the multiplication factor for PLL VCO.
131 This parameter can be a value of @ref RCC_LL_EC_PLLVCORANGE
133 This feature can be modified afterwards using unitary function
134 @ref LL_RCC_PLL1_SetVCOOutputRange(). */
136 } LL_UTILS_PLLInitTypeDef;
139 * @brief UTILS System, AHB and APB buses clock configuration structure definition
141 typedef struct
143 uint32_t SYSCLKDivider; /*!< The System clock (SYSCLK) divider. This clock is derived from the PLL output.
144 This parameter can be a value of @ref RCC_LL_EC_SYSCLK_DIV
146 This feature can be modified afterwards using unitary function
147 @ref LL_RCC_SetSysPrescaler(). */
149 uint32_t AHBCLKDivider; /*!< The AHB clock (HCLK) divider. This clock is derived from the system clock (SYSCLK).
150 This parameter can be a value of @ref RCC_LL_EC_AHB_DIV
152 This feature can be modified afterwards using unitary function
153 @ref LL_RCC_SetAHBPrescaler(). */
155 uint32_t APB1CLKDivider; /*!< The APB1 clock (PCLK1) divider. This clock is derived from the AHB clock (HCLK).
156 This parameter can be a value of @ref RCC_LL_EC_APB1_DIV
158 This feature can be modified afterwards using unitary function
159 @ref LL_RCC_SetAPB1Prescaler(). */
161 uint32_t APB2CLKDivider; /*!< The APB2 clock (PCLK2) divider. This clock is derived from the AHB clock (HCLK).
162 This parameter can be a value of @ref RCC_LL_EC_APB2_DIV
164 This feature can be modified afterwards using unitary function
165 @ref LL_RCC_SetAPB2Prescaler(). */
167 uint32_t APB3CLKDivider; /*!< The APB2 clock (PCLK3) divider. This clock is derived from the AHB clock (HCLK).
168 This parameter can be a value of @ref RCC_LL_EC_APB3_DIV
170 This feature can be modified afterwards using unitary function
171 @ref LL_RCC_SetAPB3Prescaler(). */
173 uint32_t APB4CLKDivider; /*!< The APB4 clock (PCLK4) divider. This clock is derived from the AHB clock (HCLK).
174 This parameter can be a value of @ref RCC_LL_EC_APB4_DIV
176 This feature can be modified afterwards using unitary function
177 @ref LL_RCC_SetAPB4Prescaler(). */
179 } LL_UTILS_ClkInitTypeDef;
182 * @}
185 /* Exported constants --------------------------------------------------------*/
186 /** @defgroup UTILS_LL_Exported_Constants UTILS Exported Constants
187 * @{
190 /** @defgroup UTILS_EC_HSE_BYPASS HSE Bypass activation
191 * @{
193 #define LL_UTILS_HSEBYPASS_OFF 0x00000000U /*!< HSE Bypass is not enabled */
194 #define LL_UTILS_HSEBYPASS_ON 0x00000001U /*!< HSE Bypass is enabled */
196 * @}
199 /** @defgroup UTILS_EC_PACKAGETYPE PACKAGE TYPE
200 * @{
202 #if defined(SYSCFG_PKGR_PKG)
203 #define LL_UTILS_PACKAGETYPE_LQFP100 LL_SYSCFG_LQFP100_PACKAGE /*!< LQFP100 package type */
204 #define LL_UTILS_PACKAGETYPE_TQFP144 LL_SYSCFG_TQFP144_PACKAGE /*!< TQFP144 package type */
205 #define LL_UTILS_PACKAGETYPE_TQFP176_UFBGA176 LL_SYSCFG_TQFP176_UFBGA176_PACKAGE /*!< TQFP176 or UFBGA176 package type */
206 #define LL_UTILS_PACKAGETYPE_LQFP208_TFBGA240 LL_SYSCFG_LQFP208_TFBGA240_PACKAGE /*!< LQFP208 or TFBGA240 package type */
207 #else
208 #define LL_UTILS_PACKAGETYPE_LQFP64 0x00000000UL /*!< LQFP64 package type */
209 #define LL_UTILS_PACKAGETYPE_TFBGA100_LQFP100 0x00000001UL /*!< TFBGA100 or LQFP100 package type */
210 #define LL_UTILS_PACKAGETYPE_LQFP100_SMPS 0x00000002UL /*!< LQFP100 with SMPS package type */
211 #define LL_UTILS_PACKAGETYPE_TFBGA100_SMPS 0x00000003UL /*!< TFBGA100 with SMPS package type */
212 #define LL_UTILS_PACKAGETYPE_WLCSP132_SMPS 0x00000004UL /*!< WLCSP132 package type */
213 #define LL_UTILS_PACKAGETYPE_LQFP144 0x00000005UL /*!< LQFP144 package type */
214 #define LL_UTILS_PACKAGETYPE_LQFP144_SMPS 0x00000006UL /*!< LQFP144 with SMPS package type */
215 #define LL_UTILS_PACKAGETYPE_UFBGA169 0x00000007UL /*!< UFBGA169 package type */
216 #define LL_UTILS_PACKAGETYPE_UFBGA176_LQFP176 0x00000010UL /*!< UFBGA176 or LQFP176 package type */
217 #define LL_UTILS_PACKAGETYPE_LQFP176_SMPS 0x00000011UL /*!< LQFP176 with SMPS package type */
218 #define LL_UTILS_PACKAGETYPE_UFBGA176_SMPS 0x00000012UL /*!< UFBGA176 with SMPS package type */
219 #define LL_UTILS_PACKAGETYPE_TFBGA216 0x00000014UL /*!< TFBGA216 package type */
220 #define LL_UTILS_PACKAGETYPE_TFBGA225 0x00000016UL /*!< TFBGA225 package type */
221 #endif /* SYSCFG_PKGR_PKG */
223 * @}
227 * @}
230 /* Exported macro ------------------------------------------------------------*/
232 /* Exported functions --------------------------------------------------------*/
233 /** @defgroup UTILS_LL_Exported_Functions UTILS Exported Functions
234 * @{
237 /** @defgroup UTILS_EF_DEVICE_ELECTRONIC_SIGNATURE DEVICE ELECTRONIC SIGNATURE
238 * @{
242 * @brief Get Word0 of the unique device identifier (UID based on 96 bits)
243 * @retval UID[31:0]
245 __STATIC_INLINE uint32_t LL_GetUID_Word0(void)
247 return (uint32_t)(READ_REG(*((uint32_t *)UID_BASE_ADDRESS)));
251 * @brief Get Word1 of the unique device identifier (UID based on 96 bits)
252 * @retval UID[63:32]
254 __STATIC_INLINE uint32_t LL_GetUID_Word1(void)
256 return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS + 4U))));
260 * @brief Get Word2 of the unique device identifier (UID based on 96 bits)
261 * @retval UID[95:64]
263 __STATIC_INLINE uint32_t LL_GetUID_Word2(void)
265 return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS + 8U))));
269 * @brief Get Flash memory size
270 * @note This bitfield indicates the size of the device Flash memory expressed in
271 * Kbytes. As an example, 0x040 corresponds to 64 Kbytes.
272 * @retval FLASH_SIZE[15:0]: Flash memory size
274 __STATIC_INLINE uint32_t LL_GetFlashSize(void)
276 return (uint16_t)(READ_REG(*((uint32_t *)FLASHSIZE_BASE_ADDRESS)));
280 * @brief Get Package type
281 * @retval Returned value can be one of the following values:
282 * @arg @ref LL_UTILS_PACKAGETYPE_LQFP100
283 * @arg @ref LL_UTILS_PACKAGETYPE_TQFP144
284 * @arg @ref LL_UTILS_PACKAGETYPE_TQFP176_UFBGA176
285 * @arg @ref LL_UTILS_PACKAGETYPE_LQFP208_TFBGA240
286 * @arg @ref LL_UTILS_PACKAGETYPE_LQFP64 (*)
287 * @arg @ref LL_UTILS_PACKAGETYPE_TFBGA100_LQFP100 (*)
288 * @arg @ref LL_UTILS_PACKAGETYPE_LQFP100_SMPS (*)
289 * @arg @ref LL_UTILS_PACKAGETYPE_TFBGA100_SMPS (*)
290 * @arg @ref LL_UTILS_PACKAGETYPE_WLCSP132_SMPS (*)
291 * @arg @ref LL_UTILS_PACKAGETYPE_LQFP144 (*)
292 * @arg @ref LL_UTILS_PACKAGETYPE_LQFP144_SMPS (*)
293 * @arg @ref LL_UTILS_PACKAGETYPE_UFBGA169 (*)
294 * @arg @ref LL_UTILS_PACKAGETYPE_UFBGA176_LQFP176 (*)
295 * @arg @ref LL_UTILS_PACKAGETYPE_LQFP176_SMPS (*)
296 * @arg @ref LL_UTILS_PACKAGETYPE_UFBGA176_SMPS (*)
297 * @arg @ref LL_UTILS_PACKAGETYPE_TFBGA216 (*)
298 * @arg @ref LL_UTILS_PACKAGETYPE_TFBGA225 (*)
300 * (*) Packages available on some STM32H7 lines only.
301 * @note For some SM32H7 lines, enabling the SYSCFG clock is mandatory.
302 the SYSCFG clock enabling is ensured by LL_APB4_GRP1_EnableClock
304 __STATIC_INLINE uint32_t LL_GetPackageType(void)
306 #if defined(SYSCFG_PKGR_PKG)
308 return LL_SYSCFG_GetPackage();
309 #else
310 return (uint16_t)(READ_REG(*((uint32_t *)PACKAGE_BASE_ADDRESS)));
312 #endif /* SYSCFG_PKGR_PKG */
316 * @}
319 /** @defgroup UTILS_LL_EF_DELAY DELAY
320 * @{
324 * @brief This function configures the Cortex-M SysTick source of the time base.
325 * @param HCLKFrequency HCLK frequency in Hz (can be calculated thanks to RCC helper macro)
326 * @note When a RTOS is used, it is recommended to avoid changing the SysTick
327 * configuration by calling this function, for a delay use rather osDelay RTOS service.
328 * @param Ticks Number of ticks
329 * @retval None
331 __STATIC_INLINE void LL_InitTick(uint32_t HCLKFrequency, uint32_t Ticks)
333 /* Configure the SysTick to have interrupt in 1ms time base */
334 SysTick->LOAD = (uint32_t)((HCLKFrequency / Ticks) - 1UL); /* set reload register */
335 SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
336 SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
337 SysTick_CTRL_ENABLE_Msk; /* Enable the Systick Timer */
340 void LL_Init1msTick(uint32_t CPU_Frequency);
341 void LL_mDelay(uint32_t Delay);
344 * @}
347 /** @defgroup UTILS_EF_SYSTEM SYSTEM
348 * @{
351 void LL_SetSystemCoreClock(uint32_t CPU_Frequency);
352 ErrorStatus LL_PLL_ConfigSystemClock_HSI(LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct,
353 LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct);
354 ErrorStatus LL_PLL_ConfigSystemClock_HSE(uint32_t HSEFrequency,
355 uint32_t HSEBypass,
356 LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct,
357 LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct);
360 * @}
364 * @}
368 * @}
372 * @}
375 #ifdef __cplusplus
377 #endif
379 #endif /* STM32H7xx_LL_UTILS_H */
381 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/