1 | /**
|
---|
2 | ******************************************************************************
|
---|
3 | * @file stm32f4xx_hal.c
|
---|
4 | * @author MCD Application Team
|
---|
5 | * @version V1.4.1
|
---|
6 | * @date 09-October-2015
|
---|
7 | * @brief HAL module driver.
|
---|
8 | * This is the common part of the HAL initialization
|
---|
9 | *
|
---|
10 | @verbatim
|
---|
11 | ==============================================================================
|
---|
12 | ##### How to use this driver #####
|
---|
13 | ==============================================================================
|
---|
14 | [..]
|
---|
15 | The common HAL driver contains a set of generic and common APIs that can be
|
---|
16 | used by the PPP peripheral drivers and the user to start using the HAL.
|
---|
17 | [..]
|
---|
18 | The HAL contains two APIs' categories:
|
---|
19 | (+) Common HAL APIs
|
---|
20 | (+) Services HAL APIs
|
---|
21 |
|
---|
22 | @endverbatim
|
---|
23 | ******************************************************************************
|
---|
24 | * @attention
|
---|
25 | *
|
---|
26 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
|
---|
27 | *
|
---|
28 | * Redistribution and use in source and binary forms, with or without modification,
|
---|
29 | * are permitted provided that the following conditions are met:
|
---|
30 | * 1. Redistributions of source code must retain the above copyright notice,
|
---|
31 | * this list of conditions and the following disclaimer.
|
---|
32 | * 2. Redistributions in binary form must reproduce the above copyright notice,
|
---|
33 | * this list of conditions and the following disclaimer in the documentation
|
---|
34 | * and/or other materials provided with the distribution.
|
---|
35 | * 3. Neither the name of STMicroelectronics nor the names of its contributors
|
---|
36 | * may be used to endorse or promote products derived from this software
|
---|
37 | * without specific prior written permission.
|
---|
38 | *
|
---|
39 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
---|
40 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
---|
41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
42 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
---|
43 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
---|
44 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
---|
45 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
---|
46 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
---|
47 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
---|
48 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
49 | *
|
---|
50 | ******************************************************************************
|
---|
51 | */
|
---|
52 |
|
---|
53 | /* Includes ------------------------------------------------------------------*/
|
---|
54 | #include "stm32f4xx_hal.h"
|
---|
55 |
|
---|
56 | /** @addtogroup STM32F4xx_HAL_Driver
|
---|
57 | * @{
|
---|
58 | */
|
---|
59 |
|
---|
60 | /** @defgroup HAL HAL
|
---|
61 | * @brief HAL module driver.
|
---|
62 | * @{
|
---|
63 | */
|
---|
64 |
|
---|
65 | /* Private typedef -----------------------------------------------------------*/
|
---|
66 | /* Private define ------------------------------------------------------------*/
|
---|
67 | /** @addtogroup HAL_Private_Constants
|
---|
68 | * @{
|
---|
69 | */
|
---|
70 | /**
|
---|
71 | * @brief STM32F4xx HAL Driver version number V1.4.1
|
---|
72 | */
|
---|
73 | #define __STM32F4xx_HAL_VERSION_MAIN (0x01) /*!< [31:24] main version */
|
---|
74 | #define __STM32F4xx_HAL_VERSION_SUB1 (0x04) /*!< [23:16] sub1 version */
|
---|
75 | #define __STM32F4xx_HAL_VERSION_SUB2 (0x01) /*!< [15:8] sub2 version */
|
---|
76 | #define __STM32F4xx_HAL_VERSION_RC (0x00) /*!< [7:0] release candidate */
|
---|
77 | #define __STM32F4xx_HAL_VERSION ((__STM32F4xx_HAL_VERSION_MAIN << 24)\
|
---|
78 | |(__STM32F4xx_HAL_VERSION_SUB1 << 16)\
|
---|
79 | |(__STM32F4xx_HAL_VERSION_SUB2 << 8 )\
|
---|
80 | |(__STM32F4xx_HAL_VERSION_RC))
|
---|
81 |
|
---|
82 | #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF)
|
---|
83 |
|
---|
84 | /* ------------ RCC registers bit address in the alias region ----------- */
|
---|
85 | #define SYSCFG_OFFSET (SYSCFG_BASE - PERIPH_BASE)
|
---|
86 | /* --- MEMRMP Register ---*/
|
---|
87 | /* Alias word address of UFB_MODE bit */
|
---|
88 | #define MEMRMP_OFFSET SYSCFG_OFFSET
|
---|
89 | #define UFB_MODE_BIT_NUMBER POSITION_VAL(SYSCFG_MEMRMP_UFB_MODE)
|
---|
90 | #define UFB_MODE_BB (uint32_t)(PERIPH_BB_BASE + (MEMRMP_OFFSET * 32) + (UFB_MODE_BIT_NUMBER * 4))
|
---|
91 |
|
---|
92 | /* --- CMPCR Register ---*/
|
---|
93 | /* Alias word address of CMP_PD bit */
|
---|
94 | #define CMPCR_OFFSET (SYSCFG_OFFSET + 0x20)
|
---|
95 | #define CMP_PD_BIT_NUMBER POSITION_VAL(SYSCFG_CMPCR_CMP_PD)
|
---|
96 | #define CMPCR_CMP_PD_BB (uint32_t)(PERIPH_BB_BASE + (CMPCR_OFFSET * 32) + (CMP_PD_BIT_NUMBER * 4))
|
---|
97 | /**
|
---|
98 | * @}
|
---|
99 | */
|
---|
100 |
|
---|
101 | /* Private macro -------------------------------------------------------------*/
|
---|
102 | /* Private variables ---------------------------------------------------------*/
|
---|
103 | /** @addtogroup HAL_Private_Variables
|
---|
104 | * @{
|
---|
105 | */
|
---|
106 | static __IO uint32_t uwTick;
|
---|
107 | /**
|
---|
108 | * @}
|
---|
109 | */
|
---|
110 | /* Private function prototypes -----------------------------------------------*/
|
---|
111 | /* Private functions ---------------------------------------------------------*/
|
---|
112 |
|
---|
113 | /** @defgroup HAL_Exported_Functions HAL Exported Functions
|
---|
114 | * @{
|
---|
115 | */
|
---|
116 |
|
---|
117 | /** @defgroup HAL_Exported_Functions_Group1 Initialization and de-initialization Functions
|
---|
118 | * @brief Initialization and de-initialization functions
|
---|
119 | *
|
---|
120 | @verbatim
|
---|
121 | ===============================================================================
|
---|
122 | ##### Initialization and de-initialization functions #####
|
---|
123 | ===============================================================================
|
---|
124 | [..] This section provides functions allowing to:
|
---|
125 | (+) Initializes the Flash interface the NVIC allocation and initial clock
|
---|
126 | configuration. It initializes the systick also when timeout is needed
|
---|
127 | and the backup domain when enabled.
|
---|
128 | (+) de-Initializes common part of the HAL
|
---|
129 | (+) Configure The time base source to have 1ms time base with a dedicated
|
---|
130 | Tick interrupt priority.
|
---|
131 | (++) Systick timer is used by default as source of time base, but user
|
---|
132 | can eventually implement his proper time base source (a general purpose
|
---|
133 | timer for example or other time source), keeping in mind that Time base
|
---|
134 | duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
|
---|
135 | handled in milliseconds basis.
|
---|
136 | (++) Time base configuration function (HAL_InitTick ()) is called automatically
|
---|
137 | at the beginning of the program after reset by HAL_Init() or at any time
|
---|
138 | when clock is configured, by HAL_RCC_ClockConfig().
|
---|
139 | (++) Source of time base is configured to generate interrupts at regular
|
---|
140 | time intervals. Care must be taken if HAL_Delay() is called from a
|
---|
141 | peripheral ISR process, the Tick interrupt line must have higher priority
|
---|
142 | (numerically lower) than the peripheral interrupt. Otherwise the caller
|
---|
143 | ISR process will be blocked.
|
---|
144 | (++) functions affecting time base configurations are declared as __weak
|
---|
145 | to make override possible in case of other implementations in user file.
|
---|
146 | @endverbatim
|
---|
147 | * @{
|
---|
148 | */
|
---|
149 |
|
---|
150 | /**
|
---|
151 | * @brief This function is used to initialize the HAL Library; it must be the first
|
---|
152 | * instruction to be executed in the main program (before to call any other
|
---|
153 | * HAL function), it performs the following:
|
---|
154 | * Configure the Flash prefetch, instruction and Data caches.
|
---|
155 | * Configures the SysTick to generate an interrupt each 1 millisecond,
|
---|
156 | * which is clocked by the HSI (at this stage, the clock is not yet
|
---|
157 | * configured and thus the system is running from the internal HSI at 16 MHz).
|
---|
158 | * Set NVIC Group Priority to 4.
|
---|
159 | * Calls the HAL_MspInit() callback function defined in user file
|
---|
160 | * "stm32f4xx_hal_msp.c" to do the global low level hardware initialization
|
---|
161 | *
|
---|
162 | * @note SysTick is used as time base for the HAL_Delay() function, the application
|
---|
163 | * need to ensure that the SysTick time base is always set to 1 millisecond
|
---|
164 | * to have correct HAL operation.
|
---|
165 | * @retval HAL status
|
---|
166 | */
|
---|
167 | HAL_StatusTypeDef HAL_Init(void)
|
---|
168 | {
|
---|
169 | /* Configure Flash prefetch, Instruction cache, Data cache */
|
---|
170 | #if (INSTRUCTION_CACHE_ENABLE != 0)
|
---|
171 | __HAL_FLASH_INSTRUCTION_CACHE_ENABLE();
|
---|
172 | #endif /* INSTRUCTION_CACHE_ENABLE */
|
---|
173 |
|
---|
174 | #if (DATA_CACHE_ENABLE != 0)
|
---|
175 | __HAL_FLASH_DATA_CACHE_ENABLE();
|
---|
176 | #endif /* DATA_CACHE_ENABLE */
|
---|
177 |
|
---|
178 | #if (PREFETCH_ENABLE != 0)
|
---|
179 | __HAL_FLASH_PREFETCH_BUFFER_ENABLE();
|
---|
180 | #endif /* PREFETCH_ENABLE */
|
---|
181 |
|
---|
182 | /* Set Interrupt Group Priority */
|
---|
183 | HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
|
---|
184 |
|
---|
185 | /* Use systick as time base source and configure 1ms tick (default clock after Reset is HSI) */
|
---|
186 | HAL_InitTick(TICK_INT_PRIORITY);
|
---|
187 |
|
---|
188 | /* Init the low level hardware */
|
---|
189 | HAL_MspInit();
|
---|
190 |
|
---|
191 | /* Return function status */
|
---|
192 | return HAL_OK;
|
---|
193 | }
|
---|
194 |
|
---|
195 | /**
|
---|
196 | * @brief This function de-Initializes common part of the HAL and stops the systick.
|
---|
197 | * This function is optional.
|
---|
198 | * @retval HAL status
|
---|
199 | */
|
---|
200 | HAL_StatusTypeDef HAL_DeInit(void)
|
---|
201 | {
|
---|
202 | /* Reset of all peripherals */
|
---|
203 | __HAL_RCC_APB1_FORCE_RESET();
|
---|
204 | __HAL_RCC_APB1_RELEASE_RESET();
|
---|
205 |
|
---|
206 | __HAL_RCC_APB2_FORCE_RESET();
|
---|
207 | __HAL_RCC_APB2_RELEASE_RESET();
|
---|
208 |
|
---|
209 | __HAL_RCC_AHB1_FORCE_RESET();
|
---|
210 | __HAL_RCC_AHB1_RELEASE_RESET();
|
---|
211 |
|
---|
212 | __HAL_RCC_AHB2_FORCE_RESET();
|
---|
213 | __HAL_RCC_AHB2_RELEASE_RESET();
|
---|
214 |
|
---|
215 | __HAL_RCC_AHB3_FORCE_RESET();
|
---|
216 | __HAL_RCC_AHB3_RELEASE_RESET();
|
---|
217 |
|
---|
218 | /* De-Init the low level hardware */
|
---|
219 | HAL_MspDeInit();
|
---|
220 |
|
---|
221 | /* Return function status */
|
---|
222 | return HAL_OK;
|
---|
223 | }
|
---|
224 |
|
---|
225 | /**
|
---|
226 | * @brief Initializes the MSP.
|
---|
227 | * @retval None
|
---|
228 | */
|
---|
229 | __weak void HAL_MspInit(void)
|
---|
230 | {
|
---|
231 | /* NOTE : This function Should not be modified, when the callback is needed,
|
---|
232 | the HAL_MspInit could be implemented in the user file
|
---|
233 | */
|
---|
234 | }
|
---|
235 |
|
---|
236 | /**
|
---|
237 | * @brief DeInitializes the MSP.
|
---|
238 | * @retval None
|
---|
239 | */
|
---|
240 | __weak void HAL_MspDeInit(void)
|
---|
241 | {
|
---|
242 | /* NOTE : This function Should not be modified, when the callback is needed,
|
---|
243 | the HAL_MspDeInit could be implemented in the user file
|
---|
244 | */
|
---|
245 | }
|
---|
246 |
|
---|
247 | /**
|
---|
248 | * @brief This function configures the source of the time base.
|
---|
249 | * The time source is configured to have 1ms time base with a dedicated
|
---|
250 | * Tick interrupt priority.
|
---|
251 | * @note This function is called automatically at the beginning of program after
|
---|
252 | * reset by HAL_Init() or at any time when clock is reconfigured by HAL_RCC_ClockConfig().
|
---|
253 | * @note In the default implementation, SysTick timer is the source of time base.
|
---|
254 | * It is used to generate interrupts at regular time intervals.
|
---|
255 | * Care must be taken if HAL_Delay() is called from a peripheral ISR process,
|
---|
256 | * The the SysTick interrupt must have higher priority (numerically lower)
|
---|
257 | * than the peripheral interrupt. Otherwise the caller ISR process will be blocked.
|
---|
258 | * The function is declared as __weak to be overwritten in case of other
|
---|
259 | * implementation in user file.
|
---|
260 | * @param TickPriority: Tick interrupt priority.
|
---|
261 | * @retval HAL status
|
---|
262 | */
|
---|
263 | __weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
|
---|
264 | {
|
---|
265 | /*Configure the SysTick to have interrupt in 1ms time basis*/
|
---|
266 | HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
|
---|
267 |
|
---|
268 | /*Configure the SysTick IRQ priority */
|
---|
269 | HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority ,0);
|
---|
270 |
|
---|
271 | /* Return function status */
|
---|
272 | return HAL_OK;
|
---|
273 | }
|
---|
274 |
|
---|
275 | /**
|
---|
276 | * @}
|
---|
277 | */
|
---|
278 |
|
---|
279 | /** @defgroup HAL_Exported_Functions_Group2 HAL Control functions
|
---|
280 | * @brief HAL Control functions
|
---|
281 | *
|
---|
282 | @verbatim
|
---|
283 | ===============================================================================
|
---|
284 | ##### HAL Control functions #####
|
---|
285 | ===============================================================================
|
---|
286 | [..] This section provides functions allowing to:
|
---|
287 | (+) Provide a tick value in millisecond
|
---|
288 | (+) Provide a blocking delay in millisecond
|
---|
289 | (+) Suspend the time base source interrupt
|
---|
290 | (+) Resume the time base source interrupt
|
---|
291 | (+) Get the HAL API driver version
|
---|
292 | (+) Get the device identifier
|
---|
293 | (+) Get the device revision identifier
|
---|
294 | (+) Enable/Disable Debug module during SLEEP mode
|
---|
295 | (+) Enable/Disable Debug module during STOP mode
|
---|
296 | (+) Enable/Disable Debug module during STANDBY mode
|
---|
297 |
|
---|
298 | @endverbatim
|
---|
299 | * @{
|
---|
300 | */
|
---|
301 |
|
---|
302 | /**
|
---|
303 | * @brief This function is called to increment a global variable "uwTick"
|
---|
304 | * used as application time base.
|
---|
305 | * @note In the default implementation, this variable is incremented each 1ms
|
---|
306 | * in Systick ISR.
|
---|
307 | * @note This function is declared as __weak to be overwritten in case of other
|
---|
308 | * implementations in user file.
|
---|
309 | * @retval None
|
---|
310 | */
|
---|
311 | __weak void HAL_IncTick(void)
|
---|
312 | {
|
---|
313 | uwTick++;
|
---|
314 | }
|
---|
315 |
|
---|
316 | /**
|
---|
317 | * @brief Provides a tick value in millisecond.
|
---|
318 | * @note This function is declared as __weak to be overwritten in case of other
|
---|
319 | * implementations in user file.
|
---|
320 | * @retval tick value
|
---|
321 | */
|
---|
322 | __weak uint32_t HAL_GetTick(void)
|
---|
323 | {
|
---|
324 | return uwTick;
|
---|
325 | }
|
---|
326 |
|
---|
327 | /**
|
---|
328 | * @brief This function provides accurate delay (in milliseconds) based
|
---|
329 | * on variable incremented.
|
---|
330 | * @note In the default implementation , SysTick timer is the source of time base.
|
---|
331 | * It is used to generate interrupts at regular time intervals where uwTick
|
---|
332 | * is incremented.
|
---|
333 | * @note This function is declared as __weak to be overwritten in case of other
|
---|
334 | * implementations in user file.
|
---|
335 | * @param Delay: specifies the delay time length, in milliseconds.
|
---|
336 | * @retval None
|
---|
337 | */
|
---|
338 | __weak void HAL_Delay(__IO uint32_t Delay)
|
---|
339 | {
|
---|
340 | uint32_t tickstart = 0;
|
---|
341 | tickstart = HAL_GetTick();
|
---|
342 | while((HAL_GetTick() - tickstart) < Delay)
|
---|
343 | {
|
---|
344 | }
|
---|
345 | }
|
---|
346 |
|
---|
347 | /**
|
---|
348 | * @brief Suspend Tick increment.
|
---|
349 | * @note In the default implementation , SysTick timer is the source of time base. It is
|
---|
350 | * used to generate interrupts at regular time intervals. Once HAL_SuspendTick()
|
---|
351 | * is called, the SysTick interrupt will be disabled and so Tick increment
|
---|
352 | * is suspended.
|
---|
353 | * @note This function is declared as __weak to be overwritten in case of other
|
---|
354 | * implementations in user file.
|
---|
355 | * @retval None
|
---|
356 | */
|
---|
357 | __weak void HAL_SuspendTick(void)
|
---|
358 | {
|
---|
359 | /* Disable SysTick Interrupt */
|
---|
360 | SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;
|
---|
361 | }
|
---|
362 |
|
---|
363 | /**
|
---|
364 | * @brief Resume Tick increment.
|
---|
365 | * @note In the default implementation , SysTick timer is the source of time base. It is
|
---|
366 | * used to generate interrupts at regular time intervals. Once HAL_ResumeTick()
|
---|
367 | * is called, the SysTick interrupt will be enabled and so Tick increment
|
---|
368 | * is resumed.
|
---|
369 | * @note This function is declared as __weak to be overwritten in case of other
|
---|
370 | * implementations in user file.
|
---|
371 | * @retval None
|
---|
372 | */
|
---|
373 | __weak void HAL_ResumeTick(void)
|
---|
374 | {
|
---|
375 | /* Enable SysTick Interrupt */
|
---|
376 | SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk;
|
---|
377 | }
|
---|
378 |
|
---|
379 | /**
|
---|
380 | * @brief Returns the HAL revision
|
---|
381 | * @retval version : 0xXYZR (8bits for each decimal, R for RC)
|
---|
382 | */
|
---|
383 | uint32_t HAL_GetHalVersion(void)
|
---|
384 | {
|
---|
385 | return __STM32F4xx_HAL_VERSION;
|
---|
386 | }
|
---|
387 |
|
---|
388 | /**
|
---|
389 | * @brief Returns the device revision identifier.
|
---|
390 | * @retval Device revision identifier
|
---|
391 | */
|
---|
392 | uint32_t HAL_GetREVID(void)
|
---|
393 | {
|
---|
394 | return((DBGMCU->IDCODE) >> 16);
|
---|
395 | }
|
---|
396 |
|
---|
397 | /**
|
---|
398 | * @brief Returns the device identifier.
|
---|
399 | * @retval Device identifier
|
---|
400 | */
|
---|
401 | uint32_t HAL_GetDEVID(void)
|
---|
402 | {
|
---|
403 | return((DBGMCU->IDCODE) & IDCODE_DEVID_MASK);
|
---|
404 | }
|
---|
405 |
|
---|
406 | /**
|
---|
407 | * @brief Enable the Debug Module during SLEEP mode
|
---|
408 | * @retval None
|
---|
409 | */
|
---|
410 | void HAL_DBGMCU_EnableDBGSleepMode(void)
|
---|
411 | {
|
---|
412 | SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP);
|
---|
413 | }
|
---|
414 |
|
---|
415 | /**
|
---|
416 | * @brief Disable the Debug Module during SLEEP mode
|
---|
417 | * @retval None
|
---|
418 | */
|
---|
419 | void HAL_DBGMCU_DisableDBGSleepMode(void)
|
---|
420 | {
|
---|
421 | CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP);
|
---|
422 | }
|
---|
423 |
|
---|
424 | /**
|
---|
425 | * @brief Enable the Debug Module during STOP mode
|
---|
426 | * @retval None
|
---|
427 | */
|
---|
428 | void HAL_DBGMCU_EnableDBGStopMode(void)
|
---|
429 | {
|
---|
430 | SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
|
---|
431 | }
|
---|
432 |
|
---|
433 | /**
|
---|
434 | * @brief Disable the Debug Module during STOP mode
|
---|
435 | * @retval None
|
---|
436 | */
|
---|
437 | void HAL_DBGMCU_DisableDBGStopMode(void)
|
---|
438 | {
|
---|
439 | CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
|
---|
440 | }
|
---|
441 |
|
---|
442 | /**
|
---|
443 | * @brief Enable the Debug Module during STANDBY mode
|
---|
444 | * @retval None
|
---|
445 | */
|
---|
446 | void HAL_DBGMCU_EnableDBGStandbyMode(void)
|
---|
447 | {
|
---|
448 | SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
|
---|
449 | }
|
---|
450 |
|
---|
451 | /**
|
---|
452 | * @brief Disable the Debug Module during STANDBY mode
|
---|
453 | * @retval None
|
---|
454 | */
|
---|
455 | void HAL_DBGMCU_DisableDBGStandbyMode(void)
|
---|
456 | {
|
---|
457 | CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
|
---|
458 | }
|
---|
459 |
|
---|
460 | /**
|
---|
461 | * @brief Enables the I/O Compensation Cell.
|
---|
462 | * @note The I/O compensation cell can be used only when the device supply
|
---|
463 | * voltage ranges from 2.4 to 3.6 V.
|
---|
464 | * @retval None
|
---|
465 | */
|
---|
466 | void HAL_EnableCompensationCell(void)
|
---|
467 | {
|
---|
468 | *(__IO uint32_t *)CMPCR_CMP_PD_BB = (uint32_t)ENABLE;
|
---|
469 | }
|
---|
470 |
|
---|
471 | /**
|
---|
472 | * @brief Power-down the I/O Compensation Cell.
|
---|
473 | * @note The I/O compensation cell can be used only when the device supply
|
---|
474 | * voltage ranges from 2.4 to 3.6 V.
|
---|
475 | * @retval None
|
---|
476 | */
|
---|
477 | void HAL_DisableCompensationCell(void)
|
---|
478 | {
|
---|
479 | *(__IO uint32_t *)CMPCR_CMP_PD_BB = (uint32_t)DISABLE;
|
---|
480 | }
|
---|
481 |
|
---|
482 | #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
|
---|
483 | defined(STM32F469xx) || defined(STM32F479xx)
|
---|
484 | /**
|
---|
485 | * @brief Enables the Internal FLASH Bank Swapping.
|
---|
486 | *
|
---|
487 | * @note This function can be used only for STM32F42xxx/43xxx devices.
|
---|
488 | *
|
---|
489 | * @note Flash Bank2 mapped at 0x08000000 (and aliased @0x00000000)
|
---|
490 | * and Flash Bank1 mapped at 0x08100000 (and aliased at 0x00100000)
|
---|
491 | *
|
---|
492 | * @retval None
|
---|
493 | */
|
---|
494 | void HAL_EnableMemorySwappingBank(void)
|
---|
495 | {
|
---|
496 | *(__IO uint32_t *)UFB_MODE_BB = (uint32_t)ENABLE;
|
---|
497 | }
|
---|
498 |
|
---|
499 | /**
|
---|
500 | * @brief Disables the Internal FLASH Bank Swapping.
|
---|
501 | *
|
---|
502 | * @note This function can be used only for STM32F42xxx/43xxx devices.
|
---|
503 | *
|
---|
504 | * @note The default state : Flash Bank1 mapped at 0x08000000 (and aliased @0x0000 0000)
|
---|
505 | * and Flash Bank2 mapped at 0x08100000 (and aliased at 0x00100000)
|
---|
506 | *
|
---|
507 | * @retval None
|
---|
508 | */
|
---|
509 | void HAL_DisableMemorySwappingBank(void)
|
---|
510 | {
|
---|
511 |
|
---|
512 | *(__IO uint32_t *)UFB_MODE_BB = (uint32_t)DISABLE;
|
---|
513 | }
|
---|
514 | #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
|
---|
515 |
|
---|
516 | /**
|
---|
517 | * @}
|
---|
518 | */
|
---|
519 |
|
---|
520 | /**
|
---|
521 | * @}
|
---|
522 | */
|
---|
523 |
|
---|
524 | /**
|
---|
525 | * @}
|
---|
526 | */
|
---|
527 |
|
---|
528 | /**
|
---|
529 | * @}
|
---|
530 | */
|
---|
531 |
|
---|
532 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
---|