stm32f1xx_hal.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. /**
  2. ******************************************************************************
  3. * @file stm32f1xx_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) 2016 STMicroelectronics</center></h2>
  24. *
  25. * Redistribution and use in source and binary forms, with or without modification,
  26. * are permitted provided that the following conditions are met:
  27. * 1. Redistributions of source code must retain the above copyright notice,
  28. * this list of conditions and the following disclaimer.
  29. * 2. Redistributions in binary form must reproduce the above copyright notice,
  30. * this list of conditions and the following disclaimer in the documentation
  31. * and/or other materials provided with the distribution.
  32. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  33. * may be used to endorse or promote products derived from this software
  34. * without specific prior written permission.
  35. *
  36. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  37. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  38. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  39. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  40. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  41. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  42. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  43. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  45. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  46. *
  47. ******************************************************************************
  48. */
  49. /* Includes ------------------------------------------------------------------*/
  50. #include "stm32f1xx_hal.h"
  51. /** @addtogroup STM32F1xx_HAL_Driver
  52. * @{
  53. */
  54. /** @defgroup HAL HAL
  55. * @brief HAL module driver.
  56. * @{
  57. */
  58. #ifdef HAL_MODULE_ENABLED
  59. /* Private typedef -----------------------------------------------------------*/
  60. /* Private define ------------------------------------------------------------*/
  61. /** @defgroup HAL_Private_Constants HAL Private Constants
  62. * @{
  63. */
  64. /**
  65. * @brief STM32F1xx HAL Driver version number V1.1.3
  66. */
  67. #define __STM32F1xx_HAL_VERSION_MAIN (0x01U) /*!< [31:24] main version */
  68. #define __STM32F1xx_HAL_VERSION_SUB1 (0x01U) /*!< [23:16] sub1 version */
  69. #define __STM32F1xx_HAL_VERSION_SUB2 (0x03U) /*!< [15:8] sub2 version */
  70. #define __STM32F1xx_HAL_VERSION_RC (0x00U) /*!< [7:0] release candidate */
  71. #define __STM32F1xx_HAL_VERSION ((__STM32F1xx_HAL_VERSION_MAIN << 24)\
  72. |(__STM32F1xx_HAL_VERSION_SUB1 << 16)\
  73. |(__STM32F1xx_HAL_VERSION_SUB2 << 8 )\
  74. |(__STM32F1xx_HAL_VERSION_RC))
  75. #define IDCODE_DEVID_MASK 0x00000FFFU
  76. /**
  77. * @}
  78. */
  79. /* Private macro -------------------------------------------------------------*/
  80. /* Private variables ---------------------------------------------------------*/
  81. /** @defgroup HAL_Private_Variables HAL Private Variables
  82. * @{
  83. */
  84. __IO uint32_t uwTick;
  85. uint32_t uwTickPrio = (1UL << __NVIC_PRIO_BITS); /* Invalid PRIO */
  86. HAL_TickFreqTypeDef uwTickFreq = HAL_TICK_FREQ_DEFAULT; /* 1KHz */
  87. /**
  88. * @}
  89. */
  90. /* Private function prototypes -----------------------------------------------*/
  91. /* Exported functions ---------------------------------------------------------*/
  92. /** @defgroup HAL_Exported_Functions HAL Exported Functions
  93. * @{
  94. */
  95. /** @defgroup HAL_Exported_Functions_Group1 Initialization and de-initialization Functions
  96. * @brief Initialization and de-initialization functions
  97. *
  98. @verbatim
  99. ===============================================================================
  100. ##### Initialization and de-initialization functions #####
  101. ===============================================================================
  102. [..] This section provides functions allowing to:
  103. (+) Initializes the Flash interface, the NVIC allocation and initial clock
  104. configuration. It initializes the systick also when timeout is needed
  105. and the backup domain when enabled.
  106. (+) de-Initializes common part of the HAL.
  107. (+) Configure The time base source to have 1ms time base with a dedicated
  108. Tick interrupt priority.
  109. (++) SysTick timer is used by default as source of time base, but user
  110. can eventually implement his proper time base source (a general purpose
  111. timer for example or other time source), keeping in mind that Time base
  112. duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
  113. handled in milliseconds basis.
  114. (++) Time base configuration function (HAL_InitTick ()) is called automatically
  115. at the beginning of the program after reset by HAL_Init() or at any time
  116. when clock is configured, by HAL_RCC_ClockConfig().
  117. (++) Source of time base is configured to generate interrupts at regular
  118. time intervals. Care must be taken if HAL_Delay() is called from a
  119. peripheral ISR process, the Tick interrupt line must have higher priority
  120. (numerically lower) than the peripheral interrupt. Otherwise the caller
  121. ISR process will be blocked.
  122. (++) functions affecting time base configurations are declared as __weak
  123. to make override possible in case of other implementations in user file.
  124. @endverbatim
  125. * @{
  126. */
  127. /**
  128. * @brief This function is used to initialize the HAL Library; it must be the first
  129. * instruction to be executed in the main program (before to call any other
  130. * HAL function), it performs the following:
  131. * Configure the Flash prefetch.
  132. * Configures the SysTick to generate an interrupt each 1 millisecond,
  133. * which is clocked by the HSI (at this stage, the clock is not yet
  134. * configured and thus the system is running from the internal HSI at 16 MHz).
  135. * Set NVIC Group Priority to 4.
  136. * Calls the HAL_MspInit() callback function defined in user file
  137. * "stm32f1xx_hal_msp.c" to do the global low level hardware initialization
  138. *
  139. * @note SysTick is used as time base for the HAL_Delay() function, the application
  140. * need to ensure that the SysTick time base is always set to 1 millisecond
  141. * to have correct HAL operation.
  142. * @retval HAL status
  143. */
  144. HAL_StatusTypeDef HAL_Init(void)
  145. {
  146. /* Configure Flash prefetch */
  147. #if (PREFETCH_ENABLE != 0)
  148. #if defined(STM32F101x6) || defined(STM32F101xB) || defined(STM32F101xE) || defined(STM32F101xG) || \
  149. defined(STM32F102x6) || defined(STM32F102xB) || \
  150. defined(STM32F103x6) || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG) || \
  151. defined(STM32F105xC) || defined(STM32F107xC)
  152. /* Prefetch buffer is not available on value line devices */
  153. __HAL_FLASH_PREFETCH_BUFFER_ENABLE();
  154. #endif
  155. #endif /* PREFETCH_ENABLE */
  156. /* Set Interrupt Group Priority */
  157. HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
  158. /* Use systick as time base source and configure 1ms tick (default clock after Reset is HSI) */
  159. HAL_InitTick(TICK_INT_PRIORITY);
  160. /* Init the low level hardware */
  161. HAL_MspInit();
  162. /* Return function status */
  163. return HAL_OK;
  164. }
  165. /**
  166. * @brief This function de-Initializes common part of the HAL and stops the systick.
  167. * of time base.
  168. * @note This function is optional.
  169. * @retval HAL status
  170. */
  171. HAL_StatusTypeDef HAL_DeInit(void)
  172. {
  173. /* Reset of all peripherals */
  174. __HAL_RCC_APB1_FORCE_RESET();
  175. __HAL_RCC_APB1_RELEASE_RESET();
  176. __HAL_RCC_APB2_FORCE_RESET();
  177. __HAL_RCC_APB2_RELEASE_RESET();
  178. #if defined(STM32F105xC) || defined(STM32F107xC)
  179. __HAL_RCC_AHB_FORCE_RESET();
  180. __HAL_RCC_AHB_RELEASE_RESET();
  181. #endif
  182. /* De-Init the low level hardware */
  183. HAL_MspDeInit();
  184. /* Return function status */
  185. return HAL_OK;
  186. }
  187. /**
  188. * @brief Initialize the MSP.
  189. * @retval None
  190. */
  191. __weak void HAL_MspInit(void)
  192. {
  193. /* NOTE : This function should not be modified, when the callback is needed,
  194. the HAL_MspInit could be implemented in the user file
  195. */
  196. }
  197. /**
  198. * @brief DeInitializes the MSP.
  199. * @retval None
  200. */
  201. __weak void HAL_MspDeInit(void)
  202. {
  203. /* NOTE : This function should not be modified, when the callback is needed,
  204. the HAL_MspDeInit could be implemented in the user file
  205. */
  206. }
  207. /**
  208. * @brief This function configures the source of the time base.
  209. * The time source is configured to have 1ms time base with a dedicated
  210. * Tick interrupt priority.
  211. * @note This function is called automatically at the beginning of program after
  212. * reset by HAL_Init() or at any time when clock is reconfigured by HAL_RCC_ClockConfig().
  213. * @note In the default implementation, SysTick timer is the source of time base.
  214. * It is used to generate interrupts at regular time intervals.
  215. * Care must be taken if HAL_Delay() is called from a peripheral ISR process,
  216. * The SysTick interrupt must have higher priority (numerically lower)
  217. * than the peripheral interrupt. Otherwise the caller ISR process will be blocked.
  218. * The function is declared as __weak to be overwritten in case of other
  219. * implementation in user file.
  220. * @param TickPriority Tick interrupt priority.
  221. * @retval HAL status
  222. */
  223. __weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
  224. {
  225. /* Configure the SysTick to have interrupt in 1ms time basis*/
  226. if (HAL_SYSTICK_Config(SystemCoreClock / (1000U / uwTickFreq)) > 0U)
  227. {
  228. return HAL_ERROR;
  229. }
  230. /* Configure the SysTick IRQ priority */
  231. if (TickPriority < (1UL << __NVIC_PRIO_BITS))
  232. {
  233. HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority, 0U);
  234. uwTickPrio = TickPriority;
  235. }
  236. else
  237. {
  238. return HAL_ERROR;
  239. }
  240. /* Return function status */
  241. return HAL_OK;
  242. }
  243. /**
  244. * @}
  245. */
  246. /** @defgroup HAL_Exported_Functions_Group2 HAL Control functions
  247. * @brief HAL Control functions
  248. *
  249. @verbatim
  250. ===============================================================================
  251. ##### HAL Control functions #####
  252. ===============================================================================
  253. [..] This section provides functions allowing to:
  254. (+) Provide a tick value in millisecond
  255. (+) Provide a blocking delay in millisecond
  256. (+) Suspend the time base source interrupt
  257. (+) Resume the time base source interrupt
  258. (+) Get the HAL API driver version
  259. (+) Get the device identifier
  260. (+) Get the device revision identifier
  261. (+) Enable/Disable Debug module during SLEEP mode
  262. (+) Enable/Disable Debug module during STOP mode
  263. (+) Enable/Disable Debug module during STANDBY mode
  264. @endverbatim
  265. * @{
  266. */
  267. /**
  268. * @brief This function is called to increment a global variable "uwTick"
  269. * used as application time base.
  270. * @note In the default implementation, this variable is incremented each 1ms
  271. * in SysTick ISR.
  272. * @note This function is declared as __weak to be overwritten in case of other
  273. * implementations in user file.
  274. * @retval None
  275. */
  276. __weak void HAL_IncTick(void)
  277. {
  278. uwTick += uwTickFreq;
  279. }
  280. /**
  281. * @brief Provides a tick value in millisecond.
  282. * @note This function is declared as __weak to be overwritten in case of other
  283. * implementations in user file.
  284. * @retval tick value
  285. */
  286. __weak uint32_t HAL_GetTick(void)
  287. {
  288. return uwTick;
  289. }
  290. /**
  291. * @brief This function returns a tick priority.
  292. * @retval tick priority
  293. */
  294. uint32_t HAL_GetTickPrio(void)
  295. {
  296. return uwTickPrio;
  297. }
  298. /**
  299. * @brief Set new tick Freq.
  300. * @retval Status
  301. */
  302. HAL_StatusTypeDef HAL_SetTickFreq(HAL_TickFreqTypeDef Freq)
  303. {
  304. HAL_StatusTypeDef status = HAL_OK;
  305. assert_param(IS_TICKFREQ(Freq));
  306. if (uwTickFreq != Freq)
  307. {
  308. uwTickFreq = Freq;
  309. /* Apply the new tick Freq */
  310. status = HAL_InitTick(uwTickPrio);
  311. }
  312. return status;
  313. }
  314. /**
  315. * @brief Return tick frequency.
  316. * @retval tick period in Hz
  317. */
  318. HAL_TickFreqTypeDef HAL_GetTickFreq(void)
  319. {
  320. return uwTickFreq;
  321. }
  322. /**
  323. * @brief This function provides minimum delay (in milliseconds) based
  324. * on variable incremented.
  325. * @note In the default implementation , SysTick timer is the source of time base.
  326. * It is used to generate interrupts at regular time intervals where uwTick
  327. * is incremented.
  328. * @note This function is declared as __weak to be overwritten in case of other
  329. * implementations in user file.
  330. * @param Delay specifies the delay time length, in milliseconds.
  331. * @retval None
  332. */
  333. __weak void HAL_Delay(uint32_t Delay)
  334. {
  335. uint32_t tickstart = HAL_GetTick();
  336. uint32_t wait = Delay;
  337. /* Add a freq to guarantee minimum wait */
  338. if (wait < HAL_MAX_DELAY)
  339. {
  340. wait += (uint32_t)(uwTickFreq);
  341. }
  342. while ((HAL_GetTick() - tickstart) < wait)
  343. {
  344. }
  345. }
  346. /**
  347. * @brief Suspend Tick increment.
  348. * @note In the default implementation , SysTick timer is the source of time base. It is
  349. * used to generate interrupts at regular time intervals. Once HAL_SuspendTick()
  350. * is called, the SysTick interrupt will be disabled and so Tick increment
  351. * is suspended.
  352. * @note This function is declared as __weak to be overwritten in case of other
  353. * implementations in user file.
  354. * @retval None
  355. */
  356. __weak void HAL_SuspendTick(void)
  357. {
  358. /* Disable SysTick Interrupt */
  359. CLEAR_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk);
  360. }
  361. /**
  362. * @brief Resume Tick increment.
  363. * @note In the default implementation , SysTick timer is the source of time base. It is
  364. * used to generate interrupts at regular time intervals. Once HAL_ResumeTick()
  365. * is called, the SysTick interrupt will be enabled and so Tick increment
  366. * is resumed.
  367. * @note This function is declared as __weak to be overwritten in case of other
  368. * implementations in user file.
  369. * @retval None
  370. */
  371. __weak void HAL_ResumeTick(void)
  372. {
  373. /* Enable SysTick Interrupt */
  374. SET_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk);
  375. }
  376. /**
  377. * @brief Returns the HAL revision
  378. * @retval version 0xXYZR (8bits for each decimal, R for RC)
  379. */
  380. uint32_t HAL_GetHalVersion(void)
  381. {
  382. return __STM32F1xx_HAL_VERSION;
  383. }
  384. /**
  385. * @brief Returns the device revision identifier.
  386. * Note: On devices STM32F10xx8 and STM32F10xxB,
  387. * STM32F101xC/D/E and STM32F103xC/D/E,
  388. * STM32F101xF/G and STM32F103xF/G
  389. * STM32F10xx4 and STM32F10xx6
  390. * Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
  391. * debug mode (not accessible by the user software in normal mode).
  392. * Refer to errata sheet of these devices for more details.
  393. * @retval Device revision identifier
  394. */
  395. uint32_t HAL_GetREVID(void)
  396. {
  397. return ((DBGMCU->IDCODE) >> DBGMCU_IDCODE_REV_ID_Pos);
  398. }
  399. /**
  400. * @brief Returns the device identifier.
  401. * Note: On devices STM32F10xx8 and STM32F10xxB,
  402. * STM32F101xC/D/E and STM32F103xC/D/E,
  403. * STM32F101xF/G and STM32F103xF/G
  404. * STM32F10xx4 and STM32F10xx6
  405. * Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
  406. * debug mode (not accessible by the user software in normal mode).
  407. * Refer to errata sheet of these devices for more details.
  408. * @retval Device identifier
  409. */
  410. uint32_t HAL_GetDEVID(void)
  411. {
  412. return ((DBGMCU->IDCODE) & IDCODE_DEVID_MASK);
  413. }
  414. /**
  415. * @brief Enable the Debug Module during SLEEP mode
  416. * @retval None
  417. */
  418. void HAL_DBGMCU_EnableDBGSleepMode(void)
  419. {
  420. SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP);
  421. }
  422. /**
  423. * @brief Disable the Debug Module during SLEEP mode
  424. * Note: On devices STM32F10xx8 and STM32F10xxB,
  425. * STM32F101xC/D/E and STM32F103xC/D/E,
  426. * STM32F101xF/G and STM32F103xF/G
  427. * STM32F10xx4 and STM32F10xx6
  428. * Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
  429. * debug mode (not accessible by the user software in normal mode).
  430. * Refer to errata sheet of these devices for more details.
  431. * @retval None
  432. */
  433. void HAL_DBGMCU_DisableDBGSleepMode(void)
  434. {
  435. CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP);
  436. }
  437. /**
  438. * @brief Enable the Debug Module during STOP mode
  439. * Note: On devices STM32F10xx8 and STM32F10xxB,
  440. * STM32F101xC/D/E and STM32F103xC/D/E,
  441. * STM32F101xF/G and STM32F103xF/G
  442. * STM32F10xx4 and STM32F10xx6
  443. * Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
  444. * debug mode (not accessible by the user software in normal mode).
  445. * Refer to errata sheet of these devices for more details.
  446. * Note: On all STM32F1 devices:
  447. * If the system tick timer interrupt is enabled during the Stop mode
  448. * debug (DBG_STOP bit set in the DBGMCU_CR register ), it will wakeup
  449. * the system from Stop mode.
  450. * Workaround: To debug the Stop mode, disable the system tick timer
  451. * interrupt.
  452. * Refer to errata sheet of these devices for more details.
  453. * Note: On all STM32F1 devices:
  454. * If the system tick timer interrupt is enabled during the Stop mode
  455. * debug (DBG_STOP bit set in the DBGMCU_CR register ), it will wakeup
  456. * the system from Stop mode.
  457. * Workaround: To debug the Stop mode, disable the system tick timer
  458. * interrupt.
  459. * Refer to errata sheet of these devices for more details.
  460. * @retval None
  461. */
  462. void HAL_DBGMCU_EnableDBGStopMode(void)
  463. {
  464. SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
  465. }
  466. /**
  467. * @brief Disable the Debug Module during STOP mode
  468. * Note: On devices STM32F10xx8 and STM32F10xxB,
  469. * STM32F101xC/D/E and STM32F103xC/D/E,
  470. * STM32F101xF/G and STM32F103xF/G
  471. * STM32F10xx4 and STM32F10xx6
  472. * Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
  473. * debug mode (not accessible by the user software in normal mode).
  474. * Refer to errata sheet of these devices for more details.
  475. * @retval None
  476. */
  477. void HAL_DBGMCU_DisableDBGStopMode(void)
  478. {
  479. CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
  480. }
  481. /**
  482. * @brief Enable the Debug Module during STANDBY mode
  483. * Note: On devices STM32F10xx8 and STM32F10xxB,
  484. * STM32F101xC/D/E and STM32F103xC/D/E,
  485. * STM32F101xF/G and STM32F103xF/G
  486. * STM32F10xx4 and STM32F10xx6
  487. * Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
  488. * debug mode (not accessible by the user software in normal mode).
  489. * Refer to errata sheet of these devices for more details.
  490. * @retval None
  491. */
  492. void HAL_DBGMCU_EnableDBGStandbyMode(void)
  493. {
  494. SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
  495. }
  496. /**
  497. * @brief Disable the Debug Module during STANDBY mode
  498. * Note: On devices STM32F10xx8 and STM32F10xxB,
  499. * STM32F101xC/D/E and STM32F103xC/D/E,
  500. * STM32F101xF/G and STM32F103xF/G
  501. * STM32F10xx4 and STM32F10xx6
  502. * Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
  503. * debug mode (not accessible by the user software in normal mode).
  504. * Refer to errata sheet of these devices for more details.
  505. * @retval None
  506. */
  507. void HAL_DBGMCU_DisableDBGStandbyMode(void)
  508. {
  509. CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
  510. }
  511. /**
  512. * @brief Return the unique device identifier (UID based on 96 bits)
  513. * @param UID pointer to 3 words array.
  514. * @retval Device identifier
  515. */
  516. void HAL_GetUID(uint32_t *UID)
  517. {
  518. UID[0] = (uint32_t)(READ_REG(*((uint32_t *)UID_BASE)));
  519. UID[1] = (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE + 4U))));
  520. UID[2] = (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE + 8U))));
  521. }
  522. /**
  523. * @}
  524. */
  525. /**
  526. * @}
  527. */
  528. #endif /* HAL_MODULE_ENABLED */
  529. /**
  530. * @}
  531. */
  532. /**
  533. * @}
  534. */
  535. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/