Road STM32 learning function --HAL_Init

 

Function definition:

 1 HAL_StatusTypeDef HAL_Init(void)
 2 {
 3   /* Configure Flash prefetch, Instruction cache, Data cache */ 
 4 #if (INSTRUCTION_CACHE_ENABLE != 0U)
 5    __HAL_FLASH_INSTRUCTION_CACHE_ENABLE();
 6 #endif /* INSTRUCTION_CACHE_ENABLE */
 7 
 8 #if (DATA_CACHE_ENABLE != 0U)
 9    __HAL_FLASH_DATA_CACHE_ENABLE();
10 #endif /* DATA_CACHE_ENABLE */
11 
12 #if (PREFETCH_ENABLE != 0U)
13   __HAL_FLASH_PREFETCH_BUFFER_ENABLE();
14 #endif /* PREFETCH_ENABLE */
15 
16   /* Set Interrupt Group Priority */
17   HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
18 
19   /* Use systick as time base source and configure 1ms tick (default clock after Reset is HSI) */
20   HAL_InitTick(TICK_INT_PRIORITY);
21   
22   /* Init the low level hardware */
23   HAL_MspInit();
24   
25   /* Return function status */
26   return HAL_OK;
27 }

1. Configure Flash prefetching, instruction cache, data cache

 1   /* Configure Flash prefetch, Instruction cache, Data cache */ 
 2 #if (INSTRUCTION_CACHE_ENABLE != 0U)
 3    __HAL_FLASH_INSTRUCTION_CACHE_ENABLE();
 4 #endif /* INSTRUCTION_CACHE_ENABLE */
 5 
 6 #if (DATA_CACHE_ENABLE != 0U)
 7    __HAL_FLASH_DATA_CACHE_ENABLE();
 8 #endif /* DATA_CACHE_ENABLE */
 9 
10 #if (PREFETCH_ENABLE != 0U)
11   __HAL_FLASH_PREFETCH_BUFFER_ENABLE();
12 #endif /* PREFETCH_ENABLE */

2. Set Interrupt Priority Grouping

1   /* Set Interrupt Group Priority */
2   HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);

 

STM32F429 interrupt divided . 5 groups, groups 0-4 . The packet is provided SCB-> AIRCR register bit10 ~ 8 defined. Interrupt priority grouping is 4, showing four preemption priority, in response to priority 0.

 

 

 3. Set Systick interrupt priority, TICK_INT_PRIORITY parameters defined in the "stm32f4xx_hal_conf.h" file, the default value is 0x0F, the lowest priority

1   /* Use systick as time base source and configure 1ms tick (default clock after Reset is HSI) */
2   HAL_InitTick(TICK_INT_PRIORITY);

4. Perform Msp callback function, which is defined as a weak function, may be implemented in the user file

1   /* Init the low level hardware */
2   HAL_MspInit();

 

Guess you like

Origin www.cnblogs.com/sysedoc/p/11576776.html