HAL Common Functions

HAL initialization and de-initialization functions

group HAL_Exported_Functions_Group1

This subsection provides a set of functions allowing to initialize and deinitialize the HAL module:

  • Call HAL_Init() to configure the HAL timebase with default parameters and sytene generic features.

  • Call HAL_DeInit() to revert HAL configuration.

Functions

hal_status_t HAL_Init ( void )

Initialize the HAL module and make device ready to use the various HAL modules.

Note

HAL_Init() function is called at the beginning of program after reset and before the clock configuration.

Note

In the default implementation the System Timer (Systick) is used as source of time base. The Systick configuration is based on MSI clock, as MSI is the clock used after a system Reset and the NVIC configuration is set to Priority group 4. Once done, time base tick starts incrementing: the tick variable counter is incremented each 1ms in the SysTick_Handler() interrupt handler.

Return values :
  • HAL_OK – HAL correctly initialized

  • HAL_ERROR – Error occurred during HAL initialization process (refer to HAL services called in this function)

hal_status_t HAL_DeInit ( void )

DeInitialize the HAL module.

Note

Call of this function is optional

Return values :

HAL_OK

hal_status_t HAL_InitTick ( hal_tick_freq_t tick_freq , uint32_t tick_priority )

This function configures the time base frequency and interrupt priority.

Note

This function is called at the beginning of program by HAL_Init() or at any time when system core clock is modified (for instance, called by HAL RCC driver when needed).

Note

This function is declared as __WEAK to be overridden in case of other implementations in user file.

Warning

HAL tick is updated from interrupts at regular time intervals. Care must be taken if HAL_Delay() is called from a peripheral interrupt process: the tick interrupt line must have higher priority (numerically lower) than the peripheral interrupt, otherwise the caller interrupt process will be blocked.

Parameters :
  • tick_freq – Tick frequency with a hal_tick_freq_t type (to keep current value, use global variable uwTickFreq)

  • tick_priority – Tick interrupt priority (to keep current value, use global variable uwTickPrio)

Return values :
  • HAL_OK – HAL time base correctly configured

  • HAL_ERROR – Error occurred during HAL time base configuration (refer to HAL services called in this function)

HAL time base control functions

group HAL_Exported_Functions_Group2

This subsection provides a set of functions allowing to control and use HAL tick:

Warning

HAL tick is updated from interrupts at regular time intervals. Care must be taken if HAL_Delay() is called from a peripheral interrupt process: the tick interrupt line must have higher priority (numerically lower) than the peripheral interrupt, otherwise the caller interrupt process will be blocked.

Functions

void HAL_IncTick ( void )

This function is called to increment a global variable uwTick used as application time base.

Note

In the default implementation, this function is called within Systick ISR.

Note

This function is declared as __WEAK to be overridden in case of other implementations in user file.

uint32_t HAL_GetTick ( void )

Provides a tick value in milliseconds.

Note

This function is declared as __WEAK to be overridden in case of other implementations in user file.

Return values :

uint32_t – HAL tick current value (unit: milliseconds)

uint32_t HAL_GetTickPrio ( void )

This function returns a tick priority.

Return values :

uint32_t – HAL tick priority

hal_tick_freq_t HAL_GetTickFreq ( void )

Return tick frequency.

Return values :

hal_tick_freq_t – HAL tick frequency setting

void HAL_Delay ( uint32_t delay_ms )

This function provides minimum delay (in milliseconds) based on variable incremented.

Note

In the default implementation, SysTick timer is the source of time base. It is used to generate interrupts at regular time intervals where HAL_IncTick() is called to increment the uwTick variable.

Note

This function is declared as __WEAK to be overridden in case of other implementations in user file.

Parameters :

delay_ms – delay duration, value range in 32 bit value capacity (unit: milliseconds)

void HAL_Delay_NoISR ( uint32_t delay_ms )

This function provides minimum delay (in milliseconds) based on variable incremented without Systick interrupt.

Note

In the default implementation, SysTick timer is the source of time base. This function is designed to allow users to insert delays without interrupt management, avoiding constraints related to interrupt priorities.

Note

This function is declared as __WEAK to be overridden in case of other implementations in user file.

Parameters :

delay_ms – delay duration, value range in 32 bit value capacity (unit: milliseconds)

void HAL_SuspendTick ( void )

Suspend Tick increment.

Note

In the default implementation , SysTick timer is the source of time base. It is used to generate interrupts at regular time intervals. Once HAL_SuspendTick() is called, the SysTick interrupt will be disabled and so Tick increment is suspended.

Note

This function is declared as __WEAK to be overridden in case of other implementations in user file.

void HAL_ResumeTick ( void )

Resume Tick increment.

Note

In the default implementation , SysTick timer is the source of time base. It is used to generate interrupts at regular time intervals. Once HAL_ResumeTick() is called, the SysTick interrupt will be enabled and so Tick increment is resumed.

Note

This function is declared as __WEAK to be overridden in case of other implementations in user file.

HAL driver version

group HAL_Exported_Functions_Group3

This subsection provides a set of functions allowing to get HAL driver version:

Functions

uint32_t HAL_GetVersion ( void )

Returns the HAL revision.

Return values :

uint32_t – HAL driver version: 0xXYZR (8bits for each decimal, R for release candidate)

HAL device identification

group HAL_Exported_Functions_Group4

This subsection provides a set of functions allowing to get device identification data:

Functions

hal_status_t HAL_GetDeviceUniqueID ( hal_device_uid_t * p_uid )

Return the device unique identification data.

Parameters :

p_uid – Pointer to hal_device_uid_t structure containing identification data

Return values :
  • HAL_OK – Clock configuration successfully done

  • HAL_INVALID_PARAM – Input parameter not valid (USE_HAL_CHECK_PARAM enabled)