Prusa MINI Firmware overview
Initialization and de-initialization Functions

Initialization and de-initialization functions. More...

Collaboration diagram for Initialization and de-initialization Functions:

Functions

HAL_StatusTypeDef HAL_Init (void)
 This function is used to initialize the HAL Library; it must be the first instruction to be executed in the main program (before to call any other HAL function), it performs the following: Configure the Flash prefetch, instruction and Data caches. Configures the SysTick to generate an interrupt each 1 millisecond, which is clocked by the HSI (at this stage, the clock is not yet configured and thus the system is running from the internal HSI at 16 MHz). Set NVIC Group Priority to 4. Calls the HAL_MspInit() callback function defined in user file "stm32f4xx_hal_msp.c" to do the global low level hardware initialization. More...
 
HAL_StatusTypeDef HAL_DeInit (void)
 This function de-Initializes common part of the HAL and stops the systick. This function is optional. More...
 
void HAL_MspInit (void)
 Initialize the MSP. More...
 
void HAL_MspDeInit (void)
 DeInitializes the MSP. More...
 
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 base with a dedicated Tick interrupt priority. More...
 

Detailed Description

Initialization and de-initialization functions.

 ===============================================================================
              ##### Initialization and Configuration functions #####
 ===============================================================================
    [..]  This section provides functions allowing to:
      (+) Initializes the Flash interface the NVIC allocation and initial clock
          configuration. It initializes the systick also when timeout is needed
          and the backup domain when enabled.
      (+) De-Initializes common part of the HAL.
      (+) Configure the time base source to have 1ms time base with a dedicated
          Tick interrupt priority.
        (++) SysTick timer is used by default as source of time base, but user
             can eventually implement his proper time base source (a general purpose
             timer for example or other time source), keeping in mind that Time base
             duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
             handled in milliseconds basis.
        (++) Time base configuration function (HAL_InitTick ()) is called automatically
             at the beginning of the program after reset by HAL_Init() or at any time
             when clock is configured, by HAL_RCC_ClockConfig().
        (++) Source of time base is configured  to generate interrupts at regular
             time intervals. Care must be taken if HAL_Delay() is called from a
             peripheral ISR process, the Tick interrupt line must have higher priority
            (numerically lower) than the peripheral interrupt. Otherwise the caller
            ISR process will be blocked.
       (++) functions affecting time base configurations are declared as __weak
             to make  override possible  in case of other  implementations in user file.

Function Documentation

◆ 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 in the main program (before to call any other HAL function), it performs the following: Configure the Flash prefetch, instruction and Data caches. Configures the SysTick to generate an interrupt each 1 millisecond, which is clocked by the HSI (at this stage, the clock is not yet configured and thus the system is running from the internal HSI at 16 MHz). Set NVIC Group Priority to 4. Calls the HAL_MspInit() callback function defined in user file "stm32f4xx_hal_msp.c" to do the global low level hardware initialization.

Note
SysTick is used as time base for the HAL_Delay() function, the application need to ensure that the SysTick time base is always set to 1 millisecond to have correct HAL operation.
Return values
HALstatus
174 {
175  /* Configure Flash prefetch, Instruction cache, Data cache */
176 #if (INSTRUCTION_CACHE_ENABLE != 0U)
178 #endif /* INSTRUCTION_CACHE_ENABLE */
179 
180 #if (DATA_CACHE_ENABLE != 0U)
182 #endif /* DATA_CACHE_ENABLE */
183 
184 #if (PREFETCH_ENABLE != 0U)
186 #endif /* PREFETCH_ENABLE */
187 
188  /* Set Interrupt Group Priority */
190 
191  /* Use systick as time base source and configure 1ms tick (default clock after Reset is HSI) */
193 
194  /* Init the low level hardware */
195  HAL_MspInit();
196 
197  /* Return function status */
198  return HAL_OK;
199 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HAL_DeInit()

HAL_StatusTypeDef HAL_DeInit ( void  )

This function de-Initializes common part of the HAL and stops the systick. This function is optional.

Return values
HALstatus
207 {
208  /* Reset of all peripherals */
211 
214 
217 
218  __HAL_RCC_AHB2_FORCE_RESET();
219  __HAL_RCC_AHB2_RELEASE_RESET();
220 
221  __HAL_RCC_AHB3_FORCE_RESET();
222  __HAL_RCC_AHB3_RELEASE_RESET();
223 
224  /* De-Init the low level hardware */
225  HAL_MspDeInit();
226 
227  /* Return function status */
228  return HAL_OK;
229 }
Here is the call graph for this function:

◆ HAL_MspInit()

__weak void HAL_MspInit ( void  )

Initialize the MSP.

Return values
None
236 {
237  /* NOTE : This function should not be modified, when the callback is needed,
238  the HAL_MspInit could be implemented in the user file
239  */
240 }
Here is the caller graph for this function:

◆ HAL_MspDeInit()

__weak void HAL_MspDeInit ( void  )

DeInitializes the MSP.

Return values
None
247 {
248  /* NOTE : This function should not be modified, when the callback is needed,
249  the HAL_MspDeInit could be implemented in the user file
250  */
251 }
Here is the caller graph for this function:

◆ HAL_InitTick()

__weak 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 base with a dedicated Tick interrupt priority.

Note
This function is called automatically at the beginning of program after reset by HAL_Init() or at any time when clock is reconfigured by HAL_RCC_ClockConfig().
In the default implementation, SysTick timer is the source of time base. It is used to generate interrupts at regular time intervals. Care must be taken if HAL_Delay() is called from a peripheral ISR process, The SysTick interrupt must have higher priority (numerically lower) than the peripheral interrupt. Otherwise the caller ISR process will be blocked. The function is declared as __weak to be overwritten in case of other implementation in user file.
Parameters
TickPriorityTick interrupt priority.
Return values
HALstatus
270 {
271  /* Configure the SysTick to have interrupt in 1ms time basis*/
272  if (HAL_SYSTICK_Config(SystemCoreClock / (1000U / uwTickFreq)) > 0U)
273  {
274  return HAL_ERROR;
275  }
276 
277  /* Configure the SysTick IRQ priority */
278  if (TickPriority < (1UL << __NVIC_PRIO_BITS))
279  {
280  HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority, 0U);
281  uwTickPrio = TickPriority;
282  }
283  else
284  {
285  return HAL_ERROR;
286  }
287 
288  /* Return function status */
289  return HAL_OK;
290 }
Here is the call graph for this function:
Here is the caller graph for this function:
HAL_MspInit
void HAL_MspInit(void)
Initialize the MSP.
Definition: stm32f4xx_hal.c:235
HAL_OK
Definition: stm32f4xx_hal_def.h:57
NVIC_PRIORITYGROUP_4
#define NVIC_PRIORITYGROUP_4
Definition: stm32f4xx_hal_cortex.h:118
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: stm32f4xx_hal.c:269
HAL_MspDeInit
void HAL_MspDeInit(void)
DeInitializes the MSP.
Definition: stm32f4xx_hal.c:246
__HAL_FLASH_PREFETCH_BUFFER_ENABLE
#define __HAL_FLASH_PREFETCH_BUFFER_ENABLE()
Enable the FLASH prefetch buffer.
Definition: stm32f4xx_hal_flash.h:207
__HAL_RCC_AHB1_RELEASE_RESET
#define __HAL_RCC_AHB1_RELEASE_RESET()
Definition: stm32f4xx_hal_rcc.h:689
HAL_ERROR
Definition: stm32f4xx_hal_def.h:58
uwTickPrio
uint32_t uwTickPrio
Definition: stm32f4xx_hal.c:111
uwTickFreq
HAL_TickFreqTypeDef uwTickFreq
Definition: stm32f4xx_hal.c:112
__HAL_RCC_APB2_FORCE_RESET
#define __HAL_RCC_APB2_FORCE_RESET()
Definition: stm32f4xx_hal_rcc.h:729
HAL_SYSTICK_Config
uint32_t HAL_SYSTICK_Config(uint32_t TicksNumb)
HAL_NVIC_SetPriority
void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority)
__HAL_RCC_APB2_RELEASE_RESET
#define __HAL_RCC_APB2_RELEASE_RESET()
Definition: stm32f4xx_hal_rcc.h:739
SystemCoreClock
#define SystemCoreClock
Definition: HAL.h:27
__HAL_RCC_AHB1_FORCE_RESET
#define __HAL_RCC_AHB1_FORCE_RESET()
Definition: stm32f4xx_hal_rcc.h:681
__HAL_RCC_APB1_FORCE_RESET
#define __HAL_RCC_APB1_FORCE_RESET()
Definition: stm32f4xx_hal_rcc.h:704
TICK_INT_PRIORITY
#define TICK_INT_PRIORITY
Definition: stm32f4xx_hal_conf.h:160
__HAL_FLASH_INSTRUCTION_CACHE_ENABLE
#define __HAL_FLASH_INSTRUCTION_CACHE_ENABLE()
Enable the FLASH instruction cache.
Definition: stm32f4xx_hal_flash.h:219
__HAL_FLASH_DATA_CACHE_ENABLE
#define __HAL_FLASH_DATA_CACHE_ENABLE()
Enable the FLASH data cache.
Definition: stm32f4xx_hal_flash.h:231
HAL_NVIC_SetPriorityGrouping
void HAL_NVIC_SetPriorityGrouping(uint32_t PriorityGroup)
__HAL_RCC_APB1_RELEASE_RESET
#define __HAL_RCC_APB1_RELEASE_RESET()
Definition: stm32f4xx_hal_rcc.h:713