stm32f7xx_hal.c
Go to the documentation of this file.
1 
35 /* Includes ------------------------------------------------------------------*/
36 #include "stm32f7xx_hal.h"
37 
47 /* Private typedef -----------------------------------------------------------*/
48 /* Private define ------------------------------------------------------------*/
55 #define __STM32F7xx_HAL_VERSION_MAIN (0x01)
56 #define __STM32F7xx_HAL_VERSION_SUB1 (0x02)
57 #define __STM32F7xx_HAL_VERSION_SUB2 (0x08)
58 #define __STM32F7xx_HAL_VERSION_RC (0x00)
59 #define __STM32F7xx_HAL_VERSION ((__STM32F7xx_HAL_VERSION_MAIN << 24)\
60  |(__STM32F7xx_HAL_VERSION_SUB1 << 16)\
61  |(__STM32F7xx_HAL_VERSION_SUB2 << 8 )\
62  |(__STM32F7xx_HAL_VERSION_RC))
63 
64 #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF)
65 
69 /* Private macro -------------------------------------------------------------*/
70 /* Exported variables ---------------------------------------------------------*/
74 __IO uint32_t uwTick;
75 uint32_t uwTickPrio = (1UL << __NVIC_PRIO_BITS); /* Invalid PRIO */
81 /* Private function prototypes -----------------------------------------------*/
82 /* Private functions ---------------------------------------------------------*/
83 
139 {
140  /* Configure Instruction cache through ART accelerator */
141 #if (ART_ACCLERATOR_ENABLE != 0)
143 #endif /* ART_ACCLERATOR_ENABLE */
144 
145  /* Configure Flash prefetch */
146 #if (PREFETCH_ENABLE != 0U)
148 #endif /* PREFETCH_ENABLE */
149 
150  /* Set Interrupt Group Priority */
152 
153  /* Use systick as time base source and configure 1ms tick (default clock after Reset is HSI) */
155 
156  /* Init the low level hardware */
157  HAL_MspInit();
158 
159  /* Return function status */
160  return HAL_OK;
161 }
162 
169 {
170  /* Reset of all peripherals */
173 
176 
179 
182 
185 
186  /* De-Init the low level hardware */
187  HAL_MspDeInit();
188 
189  /* Return function status */
190  return HAL_OK;
191 }
192 
197 __weak void HAL_MspInit(void)
198 {
199  /* NOTE : This function should not be modified, when the callback is needed,
200  the HAL_MspInit could be implemented in the user file
201  */
202 }
203 
208 __weak void HAL_MspDeInit(void)
209 {
210  /* NOTE : This function should not be modified, when the callback is needed,
211  the HAL_MspDeInit could be implemented in the user file
212  */
213 }
214 
231 __weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
232 {
233  /* Configure the SysTick to have interrupt in 1ms time basis*/
234  if (HAL_SYSTICK_Config(SystemCoreClock / (1000U / uwTickFreq)) > 0U)
235  {
236  return HAL_ERROR;
237  }
238 
239  /* Configure the SysTick IRQ priority */
240  if (TickPriority < (1UL << __NVIC_PRIO_BITS))
241  {
242  HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority, 0U);
243  uwTickPrio = TickPriority;
244  }
245  else
246  {
247  return HAL_ERROR;
248  }
249 
250  /* Return function status */
251  return HAL_OK;
252 }
253 
290 __weak void HAL_IncTick(void)
291 {
292  uwTick += uwTickFreq;
293 }
294 
301 __weak uint32_t HAL_GetTick(void)
302 {
303  return uwTick;
304 }
305 
310 uint32_t HAL_GetTickPrio(void)
311 {
312  return uwTickPrio;
313 }
314 
320 {
321  HAL_StatusTypeDef status = HAL_OK;
322  HAL_TickFreqTypeDef prevTickFreq;
323 
324  assert_param(IS_TICKFREQ(Freq));
325 
326  if (uwTickFreq != Freq)
327  {
328  /* Back up uwTickFreq frequency */
329  prevTickFreq = uwTickFreq;
330 
331  /* Update uwTickFreq global variable used by HAL_InitTick() */
332  uwTickFreq = Freq;
333 
334  /* Apply the new tick Freq */
335  status = HAL_InitTick(uwTickPrio);
336 
337  if (status != HAL_OK)
338  {
339  /* Restore previous tick frequency */
340  uwTickFreq = prevTickFreq;
341  }
342  }
343 
344  return status;
345 }
346 
352 {
353  return uwTickFreq;
354 }
355 
367 __weak void HAL_Delay(uint32_t Delay)
368 {
369  uint32_t tickstart = HAL_GetTick();
370  uint32_t wait = Delay;
371 
372  /* Add a freq to guarantee minimum wait */
373  if (wait < HAL_MAX_DELAY)
374  {
375  wait += (uint32_t)(uwTickFreq);
376  }
377 
378  while ((HAL_GetTick() - tickstart) < wait)
379  {
380  }
381 }
382 
393 __weak void HAL_SuspendTick(void)
394 {
395  /* Disable SysTick Interrupt */
397 }
398 
409 __weak void HAL_ResumeTick(void)
410 {
411  /* Enable SysTick Interrupt */
413 }
414 
419 uint32_t HAL_GetHalVersion(void)
420 {
422 }
423 
428 uint32_t HAL_GetREVID(void)
429 {
430  return((DBGMCU->IDCODE) >> 16U);
431 }
432 
437 uint32_t HAL_GetDEVID(void)
438 {
439  return((DBGMCU->IDCODE) & IDCODE_DEVID_MASK);
440 }
441 
446 uint32_t HAL_GetUIDw0(void)
447 {
448  return(READ_REG(*((uint32_t *)UID_BASE)));
449 }
450 
455 uint32_t HAL_GetUIDw1(void)
456 {
457  return(READ_REG(*((uint32_t *)(UID_BASE + 4U))));
458 }
459 
464 uint32_t HAL_GetUIDw2(void)
465 {
466  return(READ_REG(*((uint32_t *)(UID_BASE + 8U))));
467 }
468 
474 {
476 }
477 
483 {
485 }
486 
492 {
494 }
495 
501 {
503 }
504 
510 {
512 }
513 
519 {
521 }
522 
530 {
531  SYSCFG->CMPCR |= SYSCFG_CMPCR_CMP_PD;
532 }
533 
541 {
542  SYSCFG->CMPCR &= (uint32_t)~((uint32_t)SYSCFG_CMPCR_CMP_PD);
543 }
544 
554 {
555  SYSCFG->MEMRMP |= SYSCFG_MEMRMP_SWP_FMC_0;
556 }
557 
567 {
568 
569  SYSCFG->MEMRMP &= (uint32_t)~((uint32_t)SYSCFG_MEMRMP_SWP_FMC);
570 }
571 
572 #if defined (STM32F765xx) || defined (STM32F767xx) || defined (STM32F769xx) || defined (STM32F777xx) || defined (STM32F779xx)
573 
583 void HAL_EnableMemorySwappingBank(void)
584 {
586 }
587 
598 void HAL_DisableMemorySwappingBank(void)
599 {
601 }
602 #endif /* STM32F767xx || STM32F769xx || STM32F777xx || STM32F779xx */
603 
620 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
assert_param
#define assert_param(expr)
Include module's header file.
Definition: stm32f407/stm32f407g-disc1/Inc/stm32f4xx_hal_conf.h:353
DBGMCU_CR_DBG_SLEEP
#define DBGMCU_CR_DBG_SLEEP
Definition: stm32f407xx.h:12721
HAL_DBGMCU_EnableDBGStopMode
void HAL_DBGMCU_EnableDBGStopMode(void)
Enable the Debug Module during STOP mode.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:486
HAL_MspDeInit
void HAL_MspDeInit(void)
DeInitializes the MSP.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:230
__IO
#define __IO
Definition: imxrt1050/imxrt1050-evkb/CMSIS/core_cm7.h:237
SYSCFG_MEMRMP_SWP_FMC_0
#define SYSCFG_MEMRMP_SWP_FMC_0
Definition: stm32f469xx.h:16143
HAL_StatusTypeDef
HAL_StatusTypeDef
HAL Status structures definition
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:40
__HAL_FLASH_PREFETCH_BUFFER_ENABLE
#define __HAL_FLASH_PREFETCH_BUFFER_ENABLE()
Enable the FLASH prefetch buffer.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash.h:191
HAL_GetTickPrio
uint32_t HAL_GetTickPrio(void)
This function returns a tick priority.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:332
HAL_GetTickFreq
HAL_TickFreqTypeDef HAL_GetTickFreq(void)
Return tick frequency.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:373
HAL_EnableFMCMemorySwapping
void HAL_EnableFMCMemorySwapping(void)
Enables the FMC Memory Mapping Swapping.
Definition: stm32f7xx_hal.c:553
DBGMCU
#define DBGMCU
Definition: stm32f407xx.h:1140
__STM32F7xx_HAL_VERSION
#define __STM32F7xx_HAL_VERSION
Definition: stm32f7xx_hal.c:59
HAL_DBGMCU_EnableDBGStandbyMode
void HAL_DBGMCU_EnableDBGStandbyMode(void)
Enable the Debug Module during STANDBY mode.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:504
HAL_ERROR
@ HAL_ERROR
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:43
SysTick_IRQn
@ SysTick_IRQn
Definition: MIMXRT1052.h:91
CLEAR_BIT
#define CLEAR_BIT(REG, BIT)
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:214
HAL_GetTick
uint32_t HAL_GetTick(void)
Provides a tick value in millisecond.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:323
__HAL_RCC_AHB2_FORCE_RESET
#define __HAL_RCC_AHB2_FORCE_RESET()
Force or release AHB2 peripheral reset.
Definition: stm32f7xx_hal_rcc_ex.h:1776
wait
void wait(int seconds)
HAL_TICK_FREQ_DEFAULT
@ HAL_TICK_FREQ_DEFAULT
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h:55
uwTickPrio
uint32_t uwTickPrio
Definition: stm32f7xx_hal.c:75
HAL_Delay
void HAL_Delay(uint32_t Delay)
This function provides minimum delay (in milliseconds) based on variable incremented.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:389
HAL_DBGMCU_DisableDBGStopMode
void HAL_DBGMCU_DisableDBGStopMode(void)
Disable the Debug Module during STOP mode.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:495
HAL_SuspendTick
void HAL_SuspendTick(void)
Suspend Tick increment.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:415
__HAL_RCC_AHB1_RELEASE_RESET
#define __HAL_RCC_AHB1_RELEASE_RESET()
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:673
HAL_DBGMCU_EnableDBGSleepMode
void HAL_DBGMCU_EnableDBGSleepMode(void)
Enable the Debug Module during SLEEP mode.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:468
HAL_OK
@ HAL_OK
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:42
SysTick_CTRL_TICKINT_Msk
#define SysTick_CTRL_TICKINT_Msk
Definition: imxrt1050/imxrt1050-evkb/CMSIS/core_cm7.h:995
HAL_DeInit
HAL_StatusTypeDef HAL_DeInit(void)
This function de-Initializes common part of the HAL and stops the systick. This function is optional.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:190
HAL_GetUIDw2
uint32_t HAL_GetUIDw2(void)
Returns third word of the unique device identifier (UID based on 96 bits)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:562
HAL_NVIC_SetPriorityGrouping
void HAL_NVIC_SetPriorityGrouping(uint32_t PriorityGroup)
HAL_GetHalVersion
uint32_t HAL_GetHalVersion(void)
Returns the HAL revision.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:441
HAL_SYSTICK_Config
uint32_t HAL_SYSTICK_Config(uint32_t TicksNumb)
DBGMCU_CR_DBG_STANDBY
#define DBGMCU_CR_DBG_STANDBY
Definition: stm32f407xx.h:12727
__HAL_RCC_AHB2_RELEASE_RESET
#define __HAL_RCC_AHB2_RELEASE_RESET()
Definition: stm32f7xx_hal_rcc_ex.h:1780
SYSCFG_MEMRMP_SWP_FB
#define SYSCFG_MEMRMP_SWP_FB
Definition: stm32f769xx.h:13953
HAL_MspInit
void HAL_MspInit(void)
Initialize the MSP.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:219
SYSCFG_MEMRMP_SWP_FMC
#define SYSCFG_MEMRMP_SWP_FMC
Definition: stm32f469xx.h:16142
HAL_GetREVID
uint32_t HAL_GetREVID(void)
Returns the device revision identifier.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:450
SystemCoreClock
uint32_t SystemCoreClock
Definition: system_MIMXRT1052.c:69
DBGMCU_CR_DBG_STOP
#define DBGMCU_CR_DBG_STOP
Definition: stm32f407xx.h:12724
__HAL_RCC_APB1_RELEASE_RESET
#define __HAL_RCC_APB1_RELEASE_RESET()
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:697
HAL_DBGMCU_DisableDBGStandbyMode
void HAL_DBGMCU_DisableDBGStandbyMode(void)
Disable the Debug Module during STANDBY mode.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:513
IDCODE_DEVID_MASK
#define IDCODE_DEVID_MASK
Definition: stm32f7xx_hal.c:64
HAL_DBGMCU_DisableDBGSleepMode
void HAL_DBGMCU_DisableDBGSleepMode(void)
Disable the Debug Module during SLEEP mode.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:477
uwTickFreq
HAL_TickFreqTypeDef uwTickFreq
Definition: stm32f7xx_hal.c:76
SYSCFG
#define SYSCFG
Definition: stm32f407xx.h:1098
HAL_MAX_DELAY
#define HAL_MAX_DELAY
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:61
__HAL_RCC_APB2_RELEASE_RESET
#define __HAL_RCC_APB2_RELEASE_RESET()
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:723
__HAL_RCC_APB1_FORCE_RESET
#define __HAL_RCC_APB1_FORCE_RESET()
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:688
__HAL_RCC_AHB3_RELEASE_RESET
#define __HAL_RCC_AHB3_RELEASE_RESET()
Definition: stm32f7xx_hal_rcc_ex.h:1814
__HAL_RCC_AHB3_FORCE_RESET
#define __HAL_RCC_AHB3_FORCE_RESET()
Force or release AHB3 peripheral reset.
Definition: stm32f7xx_hal_rcc_ex.h:1810
SYSCFG_CMPCR_CMP_PD
#define SYSCFG_CMPCR_CMP_PD
Definition: stm32f407xx.h:11889
HAL_IncTick
void HAL_IncTick(void)
This function is called to increment a global variable "uwTick" used as application time base.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:312
HAL_Init
HAL_StatusTypeDef HAL_Init(void)
This function is used to initialize the HAL Library; it must be the first instruction to be executed ...
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:157
HAL_GetDEVID
uint32_t HAL_GetDEVID(void)
Returns the device identifier.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:459
__HAL_RCC_APB2_FORCE_RESET
#define __HAL_RCC_APB2_FORCE_RESET()
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:713
HAL_InitTick
HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
This function configures the source of the time base. The time source is configured to have 1ms time ...
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:253
HAL_ResumeTick
void HAL_ResumeTick(void)
Resume Tick increment.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:431
HAL_GetUIDw1
uint32_t HAL_GetUIDw1(void)
Returns second word of the unique device identifier (UID based on 96 bits)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:553
uwTick
__IO uint32_t uwTick
Definition: stm32f7xx_hal.c:74
NVIC_PRIORITYGROUP_4
#define NVIC_PRIORITYGROUP_4
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cortex.h:98
HAL_DisableCompensationCell
void HAL_DisableCompensationCell(void)
Power-down the I/O Compensation Cell.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:535
HAL_GetUIDw0
uint32_t HAL_GetUIDw0(void)
Returns first word of the unique device identifier (UID based on 96 bits)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:544
SysTick
#define SysTick
Definition: imxrt1050/imxrt1050-evkb/CMSIS/core_cm7.h:1779
__HAL_FLASH_ART_ENABLE
#define __HAL_FLASH_ART_ENABLE()
Enable the FLASH Adaptive Real-Time memory accelerator.
Definition: stm32f7xx_hal_flash.h:235
UID_BASE
#define UID_BASE
Definition: stm32f407xx.h:1048
HAL_NVIC_SetPriority
void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority)
HAL_EnableCompensationCell
void HAL_EnableCompensationCell(void)
Enables the I/O Compensation Cell.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:524
READ_REG
#define READ_REG(REG)
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:222
SET_BIT
#define SET_BIT(REG, BIT)
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:212
HAL_TickFreqTypeDef
HAL_TickFreqTypeDef
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h:50
HAL_SetTickFreq
HAL_StatusTypeDef HAL_SetTickFreq(HAL_TickFreqTypeDef Freq)
Set new tick Freq.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:341
__HAL_RCC_AHB1_FORCE_RESET
#define __HAL_RCC_AHB1_FORCE_RESET()
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:665
TICK_INT_PRIORITY
#define TICK_INT_PRIORITY
Definition: stm32f407/stm32f407g-disc1/Inc/stm32f4xx_hal_conf.h:121
HAL_DisableFMCMemorySwapping
void HAL_DisableFMCMemorySwapping(void)
Disables the FMC Memory Mapping Swapping.
Definition: stm32f7xx_hal.c:566
__NVIC_PRIO_BITS
#define __NVIC_PRIO_BITS
Definition: MIMXRT1052.h:266
stm32f7xx_hal.h
This file contains all the functions prototypes for the HAL module driver.
IS_TICKFREQ
#define IS_TICKFREQ(FREQ)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h:193


picovoice_driver
Author(s):
autogenerated on Fri Apr 1 2022 02:14:53