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