You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

813 lines
24 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32wbxx_hal.c
  4. * @author MCD Application Team
  5. * @brief HAL module driver.
  6. * This is the common part of the HAL initialization
  7. *
  8. @verbatim
  9. ==============================================================================
  10. ##### How to use this driver #####
  11. ==============================================================================
  12. [..]
  13. The common HAL driver contains a set of generic and common APIs that can be
  14. used by the PPP peripheral drivers and the user to start using the HAL.
  15. [..]
  16. The HAL contains two APIs' categories:
  17. (+) Common HAL APIs
  18. (+) Services HAL APIs
  19. @endverbatim
  20. ******************************************************************************
  21. * @attention
  22. *
  23. * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
  24. * All rights reserved.</center></h2>
  25. *
  26. * This software component is licensed by ST under BSD 3-Clause license,
  27. * the "License"; You may not use this file except in compliance with the
  28. * License. You may obtain a copy of the License at:
  29. * opensource.org/licenses/BSD-3-Clause
  30. *
  31. ******************************************************************************
  32. */
  33. /* Includes ------------------------------------------------------------------*/
  34. #include "stm32wbxx_hal.h"
  35. /** @addtogroup STM32WBxx_HAL_Driver
  36. * @{
  37. */
  38. /** @addtogroup HAL
  39. * @brief HAL module driver
  40. * @{
  41. */
  42. #ifdef HAL_MODULE_ENABLED
  43. /* Private typedef -----------------------------------------------------------*/
  44. /* Private define ------------------------------------------------------------*/
  45. /** @defgroup HAL_Private_Constants HAL Private Constants
  46. * @{
  47. */
  48. /**
  49. * @brief STM32WBxx HAL Driver version number
  50. */
  51. #define __STM32WBxx_HAL_VERSION_MAIN (0x01U) /*!< [31:24] main version */
  52. #define __STM32WBxx_HAL_VERSION_SUB1 (0x01U) /*!< [23:16] sub1 version */
  53. #define __STM32WBxx_HAL_VERSION_SUB2 (0x00U) /*!< [15:8] sub2 version */
  54. #define __STM32WBxx_HAL_VERSION_RC (0x00U) /*!< [7:0] release candidate */
  55. #define __STM32WBxx_HAL_VERSION ((__STM32WBxx_HAL_VERSION_MAIN << 24U)\
  56. |(__STM32WBxx_HAL_VERSION_SUB1 << 16U)\
  57. |(__STM32WBxx_HAL_VERSION_SUB2 << 8U )\
  58. |(__STM32WBxx_HAL_VERSION_RC))
  59. #define VREFBUF_TIMEOUT_VALUE 10U /* 10 ms */
  60. /**
  61. * @}
  62. */
  63. /* Private macro -------------------------------------------------------------*/
  64. /* Exported variables ---------------------------------------------------------*/
  65. /** @defgroup HAL_Exported_Variables HAL Exported Variables
  66. * @{
  67. */
  68. __IO uint32_t uwTick;
  69. uint32_t uwTickPrio = (1UL << __NVIC_PRIO_BITS); /* Invalid PRIO */
  70. uint32_t uwTickFreq = HAL_TICK_FREQ_DEFAULT; /* 1KHz */
  71. /**
  72. * @}
  73. */
  74. /* Private function prototypes -----------------------------------------------*/
  75. /* Exported functions --------------------------------------------------------*/
  76. /** @addtogroup HAL_Exported_Functions
  77. * @{
  78. */
  79. /** @addtogroup HAL_Exported_Functions_Group1
  80. * @brief HAL Initialization and Configuration functions
  81. *
  82. @verbatim
  83. ===============================================================================
  84. ##### HAL Initialization and Configuration functions #####
  85. ===============================================================================
  86. [..] This section provides functions allowing to:
  87. (+) Initialize the Flash interface the NVIC allocation and initial time base
  88. clock configuration.
  89. (+) De-initialize common part of the HAL.
  90. (+) Configure the time base source to have 1ms time base with a dedicated
  91. Tick interrupt priority.
  92. (++) SysTick timer is used by default as source of time base, but user
  93. can eventually implement his proper time base source (a general purpose
  94. timer for example or other time source), keeping in mind that Time base
  95. duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
  96. handled in milliseconds basis.
  97. (++) Time base configuration function (HAL_InitTick ()) is called automatically
  98. at the beginning of the program after reset by HAL_Init() or at any time
  99. when clock is configured, by HAL_RCC_ClockConfig().
  100. (++) Source of time base is configured to generate interrupts at regular
  101. time intervals. Care must be taken if HAL_Delay() is called from a
  102. peripheral ISR process, the Tick interrupt line must have higher priority
  103. (numerically lower) than the peripheral interrupt. Otherwise the caller
  104. ISR process will be blocked.
  105. (++) functions affecting time base configurations are declared as __weak
  106. to make override possible in case of other implementations in user file.
  107. @endverbatim
  108. * @{
  109. */
  110. /**
  111. * @brief This function is used to initialize the HAL Library; it must be the first
  112. * instruction to be executed in the main program (before to call any other
  113. * HAL function), it performs the following:
  114. * Configure the Flash prefetch, instruction and Data caches.
  115. * Configures the SysTick to generate an interrupt each 1 millisecond,
  116. * which is clocked by the MSI (at this stage, the clock is not yet
  117. * configured and thus the system is running from the internal MSI at 4 MHz).
  118. * Set NVIC Group Priority to 4.
  119. * Calls the HAL_MspInit() callback function defined in user file
  120. * "stm32wbxx_hal_msp.c" to do the global low level hardware initialization
  121. *
  122. * @note SysTick is used as time base for the HAL_Delay() function, the application
  123. * need to ensure that the SysTick time base is always set to 1 millisecond
  124. * to have correct HAL operation.
  125. * @retval HAL status
  126. */
  127. HAL_StatusTypeDef HAL_Init(void)
  128. {
  129. HAL_StatusTypeDef status = HAL_OK;
  130. /* Configure Flash prefetch, Instruction cache, Data cache */
  131. /* Default configuration at reset is: */
  132. /* - Prefetch disabled */
  133. /* - Instruction cache enabled */
  134. /* - Data cache enabled */
  135. #if (INSTRUCTION_CACHE_ENABLE == 0U)
  136. __HAL_FLASH_INSTRUCTION_CACHE_DISABLE();
  137. #endif /* INSTRUCTION_CACHE_ENABLE */
  138. #if (DATA_CACHE_ENABLE == 0U)
  139. __HAL_FLASH_DATA_CACHE_DISABLE();
  140. #endif /* DATA_CACHE_ENABLE */
  141. #if (PREFETCH_ENABLE != 0U)
  142. __HAL_FLASH_PREFETCH_BUFFER_ENABLE();
  143. #endif /* PREFETCH_ENABLE */
  144. /* Set Interrupt Group Priority */
  145. HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
  146. /* Use SysTick as time base source and configure 1ms tick (default clock after Reset is MSI) */
  147. if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK)
  148. {
  149. status = HAL_ERROR;
  150. }
  151. else
  152. {
  153. /* Init the low level hardware */
  154. HAL_MspInit();
  155. }
  156. /* Return function status */
  157. return status;
  158. }
  159. /**
  160. * @brief This function de-Initializes common part of the HAL and stops the source of time base.
  161. * @note This function is optional.
  162. * @retval HAL status
  163. */
  164. HAL_StatusTypeDef HAL_DeInit(void)
  165. {
  166. /* Reset of all peripherals */
  167. __HAL_RCC_APB1_FORCE_RESET();
  168. __HAL_RCC_APB1_RELEASE_RESET();
  169. __HAL_RCC_APB2_FORCE_RESET();
  170. __HAL_RCC_APB2_RELEASE_RESET();
  171. __HAL_RCC_APB3_FORCE_RESET();
  172. __HAL_RCC_APB3_RELEASE_RESET();
  173. __HAL_RCC_AHB1_FORCE_RESET();
  174. __HAL_RCC_AHB1_RELEASE_RESET();
  175. __HAL_RCC_AHB2_FORCE_RESET();
  176. __HAL_RCC_AHB2_RELEASE_RESET();
  177. __HAL_RCC_AHB3_FORCE_RESET();
  178. __HAL_RCC_AHB3_RELEASE_RESET();
  179. /* De-Init the low level hardware */
  180. HAL_MspDeInit();
  181. /* Return function status */
  182. return HAL_OK;
  183. }
  184. /**
  185. * @brief Initialize the MSP.
  186. * @retval None
  187. */
  188. __weak void HAL_MspInit(void)
  189. {
  190. /* NOTE : This function should not be modified, when the callback is needed,
  191. the HAL_MspInit could be implemented in the user file
  192. */
  193. }
  194. /**
  195. * @brief DeInitializes the MSP.
  196. * @retval None
  197. */
  198. __weak void HAL_MspDeInit(void)
  199. {
  200. /* NOTE : This function should not be modified, when the callback is needed,
  201. the HAL_MspDeInit could be implemented in the user file
  202. */
  203. }
  204. /**
  205. * @brief This function configures the source of the time base:
  206. * The time source is configured to have 1ms time base with a dedicated
  207. * Tick interrupt priority.
  208. * @note This function is called automatically at the beginning of program after
  209. * reset by HAL_Init() or at any time when clock is reconfigured by HAL_RCC_ClockConfig().
  210. * @note In the default implementation, SysTick timer is the source of time base.
  211. * It is used to generate interrupts at regular time intervals.
  212. * Care must be taken if HAL_Delay() is called from a peripheral ISR process,
  213. * The SysTick interrupt must have higher priority (numerically lower)
  214. * than the peripheral interrupt. Otherwise the caller ISR process will be blocked.
  215. * The function is declared as __weak to be overwritten in case of other
  216. * implementation in user file.
  217. * @param TickPriority Tick interrupt priority.
  218. * @retval HAL status
  219. */
  220. __weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
  221. {
  222. HAL_StatusTypeDef status = HAL_OK;
  223. if (uwTickFreq != 0U)
  224. {
  225. /*Configure the SysTick to have interrupt in 1ms time basis*/
  226. if (HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/ (1000U /uwTickFreq)) == 0U)
  227. {
  228. /* Configure the SysTick IRQ priority */
  229. if (TickPriority < (1UL << __NVIC_PRIO_BITS))
  230. {
  231. HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority, 0U);
  232. uwTickPrio = TickPriority;
  233. }
  234. else
  235. {
  236. status = HAL_ERROR;
  237. }
  238. }
  239. else
  240. {
  241. status = HAL_ERROR;
  242. }
  243. }
  244. else
  245. {
  246. status = HAL_ERROR;
  247. }
  248. /* Return function status */
  249. return status;
  250. }
  251. /**
  252. * @}
  253. */
  254. /** @addtogroup HAL_Exported_Functions_Group2
  255. * @brief HAL Control functions
  256. *
  257. @verbatim
  258. ===============================================================================
  259. ##### HAL Control functions #####
  260. ===============================================================================
  261. [..] This section provides functions allowing to:
  262. (+) Provide a tick value in millisecond
  263. (+) Provide a blocking delay in millisecond
  264. (+) Suspend the time base source interrupt
  265. (+) Resume the time base source interrupt
  266. (+) Get the HAL API driver version
  267. (+) Get the device revision identifier
  268. (+) Get the device identifier
  269. (+) Get the unique device identifier
  270. @endverbatim
  271. * @{
  272. */
  273. /**
  274. * @brief This function is called to increment a global variable "uwTick"
  275. * used as application time base.
  276. * @note In the default implementation, this variable is incremented each 1ms
  277. * in SysTick ISR.
  278. * @note This function is declared as __weak to be overwritten in case of other
  279. * implementations in user file.
  280. * @retval None
  281. */
  282. __weak void HAL_IncTick(void)
  283. {
  284. uwTick += (uint32_t)uwTickFreq;
  285. }
  286. /**
  287. * @brief Provides a tick value in millisecond.
  288. * @note This function is declared as __weak to be overwritten in case of other
  289. * implementations in user file.
  290. * @retval tick value
  291. */
  292. __weak uint32_t HAL_GetTick(void)
  293. {
  294. return uwTick;
  295. }
  296. /**
  297. * @brief This function returns a tick priority.
  298. * @retval tick priority
  299. */
  300. uint32_t HAL_GetTickPrio(void)
  301. {
  302. return uwTickPrio;
  303. }
  304. /**
  305. * @brief Set new tick Freq.
  306. * @retval Status
  307. */
  308. HAL_StatusTypeDef HAL_SetTickFreq(uint32_t Freq)
  309. {
  310. HAL_StatusTypeDef status = HAL_OK;
  311. assert_param(IS_TICKFREQ(Freq));
  312. if (uwTickFreq != Freq)
  313. {
  314. uwTickFreq = Freq;
  315. /* Apply the new tick Freq */
  316. status = HAL_InitTick(uwTickPrio);
  317. }
  318. return status;
  319. }
  320. /**
  321. * @brief Return tick frequency.
  322. * @retval tick period in Hz
  323. */
  324. uint32_t HAL_GetTickFreq(void)
  325. {
  326. return uwTickFreq;
  327. }
  328. /**
  329. * @brief This function provides minimum delay (in milliseconds) based
  330. * on variable incremented.
  331. * @note In the default implementation , SysTick timer is the source of time base.
  332. * It is used to generate interrupts at regular time intervals where uwTick
  333. * is incremented.
  334. * @note This function is declared as __weak to be overwritten in case of other
  335. * implementations in user file.
  336. * @param Delay specifies the delay time length, in milliseconds.
  337. * @retval None
  338. */
  339. __weak void HAL_Delay(uint32_t Delay)
  340. {
  341. uint32_t tickstart = HAL_GetTick();
  342. uint32_t wait = Delay;
  343. /* Add a freq to guarantee minimum wait */
  344. if (wait < HAL_MAX_DELAY)
  345. {
  346. wait += (uint32_t)(uwTickFreq);
  347. }
  348. while ((HAL_GetTick() - tickstart) < wait)
  349. {
  350. }
  351. }
  352. /**
  353. * @brief Suspend Tick increment.
  354. * @note In the default implementation , SysTick timer is the source of time base. It is
  355. * used to generate interrupts at regular time intervals. Once HAL_SuspendTick()
  356. * is called, the SysTick interrupt will be disabled and so Tick increment
  357. * is suspended.
  358. * @note This function is declared as __weak to be overwritten in case of other
  359. * implementations in user file.
  360. * @retval None
  361. */
  362. __weak void HAL_SuspendTick(void)
  363. {
  364. /* Disable SysTick Interrupt */
  365. CLEAR_BIT(SysTick->CTRL,SysTick_CTRL_TICKINT_Msk);
  366. }
  367. /**
  368. * @brief Resume Tick increment.
  369. * @note In the default implementation , SysTick timer is the source of time base. It is
  370. * used to generate interrupts at regular time intervals. Once HAL_ResumeTick()
  371. * is called, the SysTick interrupt will be enabled and so Tick increment
  372. * is resumed.
  373. * @note This function is declared as __weak to be overwritten in case of other
  374. * implementations in user file.
  375. * @retval None
  376. */
  377. __weak void HAL_ResumeTick(void)
  378. {
  379. /* Enable SysTick Interrupt */
  380. SET_BIT(SysTick->CTRL,SysTick_CTRL_TICKINT_Msk);
  381. }
  382. /**
  383. * @brief Returns the HAL revision
  384. * @retval version : 0xXYZR (8bits for each decimal, R for RC)
  385. */
  386. uint32_t HAL_GetHalVersion(void)
  387. {
  388. return __STM32WBxx_HAL_VERSION;
  389. }
  390. /**
  391. * @brief Returns the device revision identifier.
  392. * @retval Device revision identifier
  393. */
  394. uint32_t HAL_GetREVID(void)
  395. {
  396. return(LL_DBGMCU_GetRevisionID());
  397. }
  398. /**
  399. * @brief Returns the device identifier.
  400. * @retval Device identifier
  401. */
  402. uint32_t HAL_GetDEVID(void)
  403. {
  404. return(LL_DBGMCU_GetDeviceID());
  405. }
  406. /**
  407. * @brief Return the first word of the unique device identifier (UID based on 96 bits)
  408. * @retval Device identifier
  409. */
  410. uint32_t HAL_GetUIDw0(void)
  411. {
  412. return(READ_REG(*((uint32_t *)UID_BASE)));
  413. }
  414. /**
  415. * @brief Return the second word of the unique device identifier (UID based on 96 bits)
  416. * @retval Device identifier
  417. */
  418. uint32_t HAL_GetUIDw1(void)
  419. {
  420. return(READ_REG(*((uint32_t *)(UID_BASE + 4U))));
  421. }
  422. /**
  423. * @brief Return the third word of the unique device identifier (UID based on 96 bits)
  424. * @retval Device identifier
  425. */
  426. uint32_t HAL_GetUIDw2(void)
  427. {
  428. return(READ_REG(*((uint32_t *)(UID_BASE + 8U))));
  429. }
  430. /**
  431. * @}
  432. */
  433. /** @addtogroup HAL_Exported_Functions_Group3
  434. * @brief HAL Debug functions
  435. *
  436. @verbatim
  437. ===============================================================================
  438. ##### HAL Debug functions #####
  439. ===============================================================================
  440. [..] This section provides functions allowing to:
  441. (+) Enable/Disable Debug module during SLEEP mode
  442. (+) Enable/Disable Debug module during STOP mode
  443. (+) Enable/Disable Debug module during STANDBY mode
  444. @endverbatim
  445. * @{
  446. */
  447. /**
  448. * @brief Enable the Debug Module during SLEEP mode
  449. * @retval None
  450. */
  451. void HAL_DBGMCU_EnableDBGSleepMode(void)
  452. {
  453. LL_DBGMCU_EnableDBGSleepMode();
  454. }
  455. /**
  456. * @brief Disable the Debug Module during SLEEP mode
  457. * @retval None
  458. */
  459. void HAL_DBGMCU_DisableDBGSleepMode(void)
  460. {
  461. LL_DBGMCU_DisableDBGSleepMode();
  462. }
  463. /**
  464. * @brief Enable the Debug Module during STOP mode
  465. * @retval None
  466. */
  467. void HAL_DBGMCU_EnableDBGStopMode(void)
  468. {
  469. LL_DBGMCU_EnableDBGStopMode();
  470. }
  471. /**
  472. * @brief Disable the Debug Module during STOP mode
  473. * @retval None
  474. */
  475. void HAL_DBGMCU_DisableDBGStopMode(void)
  476. {
  477. LL_DBGMCU_DisableDBGStopMode();
  478. }
  479. /**
  480. * @brief Enable the Debug Module during STANDBY mode
  481. * @retval None
  482. */
  483. void HAL_DBGMCU_EnableDBGStandbyMode(void)
  484. {
  485. LL_DBGMCU_EnableDBGStandbyMode();
  486. }
  487. /**
  488. * @brief Disable the Debug Module during STANDBY mode
  489. * @retval None
  490. */
  491. void HAL_DBGMCU_DisableDBGStandbyMode(void)
  492. {
  493. LL_DBGMCU_DisableDBGStandbyMode();
  494. }
  495. /**
  496. * @}
  497. */
  498. /** @defgroup HAL_Exported_Functions_Group4 HAL System Configuration functions
  499. * @brief HAL System Configuration functions
  500. *
  501. @verbatim
  502. ===============================================================================
  503. ##### HAL system configuration functions #####
  504. ===============================================================================
  505. [..] This section provides functions allowing to:
  506. (+) Start a hardware SRAM2 erase operation
  507. (+) Disable CPU2 SRAM fetch (execution)
  508. (+) Configure the Voltage reference buffer
  509. (+) Enable/Disable the Voltage reference buffer
  510. (+) Enable/Disable the I/O analog switch voltage booster
  511. (+) Enable/Disable the access for security IP (AES1, AES2, PKA, RNG)
  512. @endverbatim
  513. * @{
  514. */
  515. /**
  516. * @brief Start a hardware SRAM2 erase operation.
  517. * @note As long as SRAM2 is not erased the SRAM2ER bit will be set.
  518. * This bit is automatically reset at the end of the SRAM2 erase operation.
  519. * @retval None
  520. */
  521. void HAL_SYSCFG_SRAM2Erase(void)
  522. {
  523. /* unlock the write protection of the SRAM2ER bit */
  524. __HAL_SYSCFG_SRAM2_WRP_UNLOCK();
  525. /* Starts a hardware SRAM2 erase operation*/
  526. __HAL_SYSCFG_SRAM2_ERASE();
  527. }
  528. /**
  529. * @brief Disable CPU2 SRAM fetch (execution) (This bit can be set by Firmware
  530. * and will only be reset by a Hardware reset, including a reset after Standby.)
  531. * @note Firmware writing 0 has no effect.
  532. * @retval None
  533. */
  534. void HAL_SYSCFG_DisableSRAMFetch(void)
  535. {
  536. LL_SYSCFG_DisableSRAMFetch();
  537. }
  538. /**
  539. * @brief Check if CPU2 SRAM fetch is enabled
  540. * @retval State of bit (1 or 0).
  541. */
  542. uint32_t HAL_SYSCFG_IsEnabledSRAMFetch(void)
  543. {
  544. return (LL_SYSCFG_IsEnabledSRAMFetch());
  545. }
  546. /**
  547. * @brief Configure the internal voltage reference buffer voltage scale.
  548. * @param VoltageScaling specifies the output voltage to achieve
  549. * This parameter can be one of the following values:
  550. * @arg @ref SYSCFG_VREFBUF_VOLTAGE_SCALE0 : VREF_OUT1 around 2.048 V.
  551. * This requires VDDA equal to or higher than 2.4 V.
  552. * @arg @ref SYSCFG_VREFBUF_VOLTAGE_SCALE1 : VREF_OUT1 around 2.5 V.
  553. * This requires VDDA equal to or higher than 2.8 V.
  554. * @retval None
  555. */
  556. void HAL_SYSCFG_VREFBUF_VoltageScalingConfig(uint32_t VoltageScaling)
  557. {
  558. /* Check the parameters */
  559. assert_param(IS_SYSCFG_VREFBUF_VOLTAGE_SCALE(VoltageScaling));
  560. LL_VREFBUF_SetVoltageScaling(VoltageScaling);
  561. }
  562. /**
  563. * @brief Configure the internal voltage reference buffer high impedance mode.
  564. * @param Mode specifies the high impedance mode
  565. * This parameter can be one of the following values:
  566. * @arg @ref SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE : VREF+ pin is internally connect to VREFINT output.
  567. * @arg @ref SYSCFG_VREFBUF_HIGH_IMPEDANCE_ENABLE : VREF+ pin is high impedance.
  568. * @retval HAL_OK/HAL_TIMEOUT
  569. */
  570. void HAL_SYSCFG_VREFBUF_HighImpedanceConfig(uint32_t Mode)
  571. {
  572. /* Check the parameters */
  573. assert_param(IS_SYSCFG_VREFBUF_HIGH_IMPEDANCE(Mode));
  574. MODIFY_REG(VREFBUF->CSR, VREFBUF_CSR_HIZ, Mode);
  575. }
  576. /**
  577. * @brief Tune the Internal Voltage Reference buffer (VREFBUF).
  578. * @param TrimmingValue specifies trimming code for VREFBUF calibration
  579. * This parameter can be a number between Min_Data = 0x00 and Max_Data = 0x3F
  580. * @retval None
  581. */
  582. void HAL_SYSCFG_VREFBUF_TrimmingConfig(uint32_t TrimmingValue)
  583. {
  584. /* Check the parameters */
  585. assert_param(IS_SYSCFG_VREFBUF_TRIMMING(TrimmingValue));
  586. LL_VREFBUF_SetTrimming(TrimmingValue);
  587. }
  588. /**
  589. * @brief Enable the Internal Voltage Reference buffer (VREFBUF).
  590. * @retval HAL_OK/HAL_TIMEOUT
  591. */
  592. HAL_StatusTypeDef HAL_SYSCFG_EnableVREFBUF(void)
  593. {
  594. uint32_t tickstart;
  595. LL_VREFBUF_Enable();
  596. /* Get Start Tick*/
  597. tickstart = HAL_GetTick();
  598. /* Wait for VRR bit */
  599. while(READ_BIT(VREFBUF->CSR, VREFBUF_CSR_VRR) == 0U)
  600. {
  601. if((HAL_GetTick() - tickstart) > VREFBUF_TIMEOUT_VALUE)
  602. {
  603. return HAL_TIMEOUT;
  604. }
  605. }
  606. return HAL_OK;
  607. }
  608. /**
  609. * @brief Disable the Internal Voltage Reference buffer (VREFBUF).
  610. *
  611. * @retval None
  612. */
  613. void HAL_SYSCFG_DisableVREFBUF(void)
  614. {
  615. LL_VREFBUF_Disable();
  616. }
  617. /**
  618. * @brief Enable the I/O analog switch voltage booster
  619. *
  620. * @retval None
  621. */
  622. void HAL_SYSCFG_EnableIOBooster(void)
  623. {
  624. LL_SYSCFG_EnableAnalogBooster();
  625. }
  626. /**
  627. * @brief Disable the I/O analog switch voltage booster
  628. *
  629. * @retval None
  630. */
  631. void HAL_SYSCFG_DisableIOBooster(void)
  632. {
  633. LL_SYSCFG_DisableAnalogBooster();
  634. }
  635. /**
  636. * @brief Enable the I/O analog switch supplied by VDD
  637. * @note To be used when I/O analog switch voltage booster is not enabled
  638. * @retval None
  639. */
  640. void HAL_SYSCFG_EnableIOVdd(void)
  641. {
  642. LL_SYSCFG_EnableAnalogGpioSwitch();
  643. }
  644. /**
  645. * @brief Disable the I/O analog switch supplied by VDD
  646. *
  647. * @retval None
  648. */
  649. void HAL_SYSCFG_DisableIOVdd(void)
  650. {
  651. LL_SYSCFG_DisableAnalogGpioSwitch();
  652. }
  653. /**
  654. * @brief Enable the access for security IP
  655. * @note When the system is secure (ESE = 1), this register provides write access security and can
  656. * only be written by the CPU2. A write access from the CPU1 will be ignored and a bus error
  657. * is generated.
  658. * @param SecurityAccess This parameter can be a combination of the following values:
  659. * @arg @ref HAL_SYSCFG_SECURE_ACCESS_AES1
  660. * @arg @ref HAL_SYSCFG_SECURE_ACCESS_AES2
  661. * @arg @ref HAL_SYSCFG_SECURE_ACCESS_PKA
  662. * @arg @ref HAL_SYSCFG_SECURE_ACCESS_RNG
  663. * @retval None
  664. */
  665. void HAL_SYSCFG_EnableSecurityAccess(uint32_t SecurityAccess)
  666. {
  667. /* Check the parameters */
  668. assert_param(IS_SYSCFG_SECURITY_ACCESS(SecurityAccess));
  669. LL_SYSCFG_EnableSecurityAccess(SecurityAccess);
  670. }
  671. /**
  672. * @brief Disable the access for security IP
  673. * @note When the system is secure (ESE = 1), this register provides write access security and can
  674. * only be written by the CPU2. A write access from the CPU1 will be ignored and a bus error
  675. * is generated.
  676. * @param SecurityAccess This parameter can be a combination of the following values:
  677. * @arg @ref HAL_SYSCFG_SECURE_ACCESS_AES1
  678. * @arg @ref HAL_SYSCFG_SECURE_ACCESS_AES2
  679. * @arg @ref HAL_SYSCFG_SECURE_ACCESS_PKA
  680. * @arg @ref HAL_SYSCFG_SECURE_ACCESS_RNG
  681. * @retval None
  682. */
  683. void HAL_SYSCFG_DisableSecurityAccess(uint32_t SecurityAccess)
  684. {
  685. /* Check the parameters */
  686. assert_param(IS_SYSCFG_SECURITY_ACCESS(SecurityAccess));
  687. LL_SYSCFG_DisableSecurityAccess(SecurityAccess);
  688. }
  689. /**
  690. * @brief Indicate if access for security IP is enabled
  691. * @param SecurityAccess This parameter can be one of the following values:
  692. * @arg @ref HAL_SYSCFG_SECURE_ACCESS_AES1
  693. * @arg @ref HAL_SYSCFG_SECURE_ACCESS_AES2
  694. * @arg @ref HAL_SYSCFG_SECURE_ACCESS_PKA
  695. * @arg @ref HAL_SYSCFG_SECURE_ACCESS_RNG
  696. * @retval State of bit (1 or 0).
  697. */
  698. uint32_t HAL_SYSCFG_IsEnabledSecurityAccess(uint32_t SecurityAccess)
  699. {
  700. return (LL_SYSCFG_IsEnabledSecurityAccess(SecurityAccess));
  701. }
  702. /**
  703. * @}
  704. */
  705. /**
  706. * @}
  707. */
  708. #endif /* HAL_MODULE_ENABLED */
  709. /**
  710. * @}
  711. */
  712. /**
  713. * @}
  714. */
  715. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/