HAL Common Functions ¶
HAL initialization and de-initialization functions ¶
- group HAL_Exported_Functions_Group1
-
This subsection provides a set of functions allowing initialization and de-initialization of the HAL module:
Call HAL_Init() to configure the HAL time base with default parameters and system generic features.
Call HAL_DeInit() to revert HAL configuration.
Call HAL_InitTick() to configure the time base frequency and interrupt priority.
Call HAL_UpdateCoreClock() to update the SystemCoreClock global variable.
Functions
-
hal_status_t
HAL_Init
(
void
)
¶
-
Initialize the HAL module and make the device ready to use the various HAL modules.
Note
HAL_Init() is called at the beginning of the program after reset and before the clock configuration.
Note
In the default implementation the System Timer (SysTick) is used as a source of time base. The SysTick configuration is based on HSI clock, as HSI is the clock used after a system reset and the NVIC configuration is set to Priority group 4. Once done, the time base tick starts incrementing: the tick variable counter is incremented each 1 ms 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
)
¶
-
De-initialize the HAL module.
Note
Calling this function is optional.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_InitTick
(
hal_tick_freq_t
tick_freq
,
uint32_t
tick_priority
)
¶
-
Configure the time base frequency and interrupt priority.
Note
This function is called at the beginning of the program by HAL_Init() or at any time when the system core clock is modified (for instance, called by the HAL RCC driver when needed).
Note
This function is declared as __WEAK to be overridden in case of other implementations in the 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_status_t
HAL_UpdateCoreClock
(
void
)
¶
-
Update the SystemCoreClock.
Note
HAL_UpdateCoreClock() must be called at the end of the system clock configuration sequence to update SystemCoreClock and the HAL tick
- 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)
- group HAL_Exported_Functions_Group1
-
This subsection provides a set of functions allowing initialization and de-initialization of the HAL module:
Call HAL_Init() to configure the HAL time base with default parameters and system generic features.
Call HAL_DeInit() to revert HAL configuration.
Call HAL_InitTick() to configure the time base frequency and interrupt priority.
Call HAL_UpdateCoreClock() to update the SystemCoreClock global variable.
Functions
-
hal_status_t
HAL_Init
(
void
)
-
Initialize the HAL module and make the device ready to use the various HAL modules.
Note
HAL_Init() is called at the beginning of the program after reset and before the clock configuration.
Note
In the default implementation the System Timer (SysTick) is used as a source of time base. The SysTick configuration is based on HSI clock, as HSI is the clock used after a system reset and the NVIC configuration is set to Priority group 4. Once done, the time base tick starts incrementing: the tick variable counter is incremented each 1 ms 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
)
-
De-initialize the HAL module.
Note
Calling this function is optional.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_InitTick
(
hal_tick_freq_t
tick_freq
,
uint32_t
tick_priority
)
-
Configure the time base frequency and interrupt priority.
Note
This function is called at the beginning of the program by HAL_Init() or at any time when the system core clock is modified (for instance, called by the HAL RCC driver when needed).
Note
This function is declared as __WEAK to be overridden in case of other implementations in the 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_status_t
HAL_UpdateCoreClock
(
void
)
-
Update the SystemCoreClock.
Note
HAL_UpdateCoreClock() must be called at the end of the system clock configuration sequence to update SystemCoreClock and the HAL tick
- 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)
- group HAL_Exported_Functions_Group1
-
This subsection provides a set of functions allowing initialization and de-initialization of the HAL module:
Call HAL_Init() to configure the HAL time base with default parameters and system generic features.
Call HAL_DeInit() to revert HAL configuration.
Call HAL_InitTick() to configure the time base frequency and interrupt priority.
Call HAL_UpdateCoreClock() to update the SystemCoreClock global variable.
Functions
-
hal_status_t
HAL_Init
(
void
)
-
Initialize the HAL module and make the device ready to use the various HAL modules.
Note
HAL_Init() is called at the beginning of the program after reset and before the clock configuration.
Note
In the default implementation the System Timer (SysTick) is used as a source of time base. The SysTick configuration is based on HSI clock, as HSI is the clock used after a system reset and the NVIC configuration is set to Priority group 4. Once done, the time base tick starts incrementing: the tick variable counter is incremented each 1 ms 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
)
-
De-initialize the HAL module.
Note
Calling this function is optional.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_InitTick
(
hal_tick_freq_t
tick_freq
,
uint32_t
tick_priority
)
-
Configure the time base frequency and interrupt priority.
Note
This function is called at the beginning of the program by HAL_Init() or at any time when the system core clock is modified (for instance, called by the HAL RCC driver when needed).
Note
This function is declared as __WEAK to be overridden in case of other implementations in the 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_status_t
HAL_UpdateCoreClock
(
void
)
-
Update the SystemCoreClock.
Note
HAL_UpdateCoreClock() must be called at the end of the system clock configuration sequence to update SystemCoreClock and the HAL tick
- 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 control and use of the HAL tick:
Call HAL_IncTick() to increment the uwTick global variable value.
Call HAL_GetTick() to get the uwTick global variable value.
Call HAL_GetTickPrio() to get the tick interrupt priority.
Call HAL_GetTickFreq() to get the tick frequency.
Call HAL_Delay() to provide a delay in milliseconds.
Call HAL_Delay_NoISR() to provide a minimum delay in milliseconds without SysTick interrupt.
Call HAL_SuspendTick() to suspend the tick incrementation.
Call HAL_ResumeTick() to resume the tick incrementation.
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
)
¶
-
Increment the global variable uwTick used as the application time base.
Note
In the default implementation, this function is called within the SysTick ISR.
Note
This function is declared as __WEAK to be overridden in case of other implementations in the user file.
-
uint32_t
HAL_GetTick
(
void
)
¶
-
Provide a tick value in milliseconds.
Note
This function is declared as __WEAK to be overridden in case of other implementations in the user file.
- Return values :
-
uint32_t – HAL tick current value (unit: milliseconds)
-
uint32_t
HAL_GetTickPrio
(
void
)
¶
-
Return a tick priority.
- Return values :
-
uint32_t – HAL tick priority
-
hal_tick_freq_t
HAL_GetTickFreq
(
void
)
¶
-
Return the tick frequency.
- Return values :
-
hal_tick_freq_t – HAL tick frequency setting
-
void
HAL_Delay
(
uint32_t
delay_ms
)
¶
-
Provide a minimum delay (in milliseconds) based on the incremented variable.
Note
In the default implementation, the SysTick timer is the source of the 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 the user file.
- Parameters :
-
delay_ms – Delay duration, value range in 32-bit value capacity (unit: milliseconds)
-
void
HAL_Delay_NoISR
(
uint32_t
delay_ms
)
¶
-
Provide a minimum delay (in milliseconds) based on the incremented variable 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 the 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 the 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 the user file.
- group HAL_Exported_Functions_Group2
-
This subsection provides a set of functions allowing control and use of the HAL tick:
Call HAL_IncTick() to increment the uwTick global variable value.
Call HAL_GetTick() to get the uwTick global variable value.
Call HAL_GetTickPrio() to get the tick interrupt priority.
Call HAL_GetTickFreq() to get the tick frequency.
Call HAL_Delay() to provide a delay in milliseconds.
Call HAL_Delay_NoISR() to provide a minimum delay in milliseconds without SysTick interrupt.
Call HAL_SuspendTick() to suspend the tick incrementation.
Call HAL_ResumeTick() to resume the tick incrementation.
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
)
-
Increment the global variable uwTick used as the application time base.
Note
In the default implementation, this function is called within the SysTick ISR.
Note
This function is declared as __WEAK to be overridden in case of other implementations in the user file.
-
uint32_t
HAL_GetTick
(
void
)
-
Provide a tick value in milliseconds.
Note
This function is declared as __WEAK to be overridden in case of other implementations in the user file.
- Return values :
-
uint32_t – HAL tick current value (unit: milliseconds)
-
uint32_t
HAL_GetTickPrio
(
void
)
-
Return a tick priority.
- Return values :
-
uint32_t – HAL tick priority
-
hal_tick_freq_t
HAL_GetTickFreq
(
void
)
-
Return the tick frequency.
- Return values :
-
hal_tick_freq_t – HAL tick frequency setting
-
void
HAL_Delay
(
uint32_t
delay_ms
)
-
Provide a minimum delay (in milliseconds) based on the incremented variable.
Note
In the default implementation, the SysTick timer is the source of the 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 the user file.
- Parameters :
-
delay_ms – Delay duration, value range in 32-bit value capacity (unit: milliseconds)
-
void
HAL_Delay_NoISR
(
uint32_t
delay_ms
)
-
Provide a minimum delay (in milliseconds) based on the incremented variable 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 the 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 the 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 the user file.
- group HAL_Exported_Functions_Group2
-
This subsection provides a set of functions allowing control and use of the HAL tick:
Call HAL_IncTick() to increment the uwTick global variable value.
Call HAL_GetTick() to get the uwTick global variable value.
Call HAL_GetTickPrio() to get the tick interrupt priority.
Call HAL_GetTickFreq() to get the tick frequency.
Call HAL_Delay() to provide a delay in milliseconds.
Call HAL_Delay_NoISR() to provide a minimum delay in milliseconds without SysTick interrupt.
Call HAL_SuspendTick() to suspend the tick incrementation.
Call HAL_ResumeTick() to resume the tick incrementation.
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
)
-
Increment the global variable uwTick used as the application time base.
Note
In the default implementation, this function is called within the SysTick ISR.
Note
This function is declared as __WEAK to be overridden in case of other implementations in the user file.
-
uint32_t
HAL_GetTick
(
void
)
-
Provide a tick value in milliseconds.
Note
This function is declared as __WEAK to be overridden in case of other implementations in the user file.
- Return values :
-
uint32_t – HAL tick current value (unit: milliseconds)
-
uint32_t
HAL_GetTickPrio
(
void
)
-
Return a tick priority.
- Return values :
-
uint32_t – HAL tick priority
-
hal_tick_freq_t
HAL_GetTickFreq
(
void
)
-
Return the tick frequency.
- Return values :
-
hal_tick_freq_t – HAL tick frequency setting
-
void
HAL_Delay
(
uint32_t
delay_ms
)
-
Provide a minimum delay (in milliseconds) based on the incremented variable.
Note
In the default implementation, the SysTick timer is the source of the 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 the user file.
- Parameters :
-
delay_ms – Delay duration, value range in 32-bit value capacity (unit: milliseconds)
-
void
HAL_Delay_NoISR
(
uint32_t
delay_ms
)
-
Provide a minimum delay (in milliseconds) based on the incremented variable 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 the 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 the 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 the user file.
HAL driver version ¶
- group HAL_Exported_Functions_Group3
-
This subsection provides a set of functions allowing retrieval of the HAL driver version:
Call HAL_GetDeviceUniqueID() to get the HAL driver version.
Functions
-
uint32_t
HAL_GetVersion
(
void
)
¶
-
Return the HAL revision.
- Return values :
-
uint32_t – HAL driver version: 0xXYZR (8 bits for each decimal, R for release candidate)
- group HAL_Exported_Functions_Group3
-
This subsection provides a set of functions allowing retrieval of the HAL driver version:
Call HAL_GetDeviceUniqueID() to get the HAL driver version.
Functions
-
uint32_t
HAL_GetVersion
(
void
)
-
Return the HAL revision.
- Return values :
-
uint32_t – HAL driver version: 0xXYZR (8 bits for each decimal, R for release candidate)
- group HAL_Exported_Functions_Group3
-
This subsection provides a set of functions allowing retrieval of the HAL driver version:
Call HAL_GetDeviceUniqueID() to get the HAL driver version.
Functions
-
uint32_t
HAL_GetVersion
(
void
)
-
Return the HAL revision.
- Return values :
-
uint32_t – HAL driver version: 0xXYZR (8 bits for each decimal, R for release candidate)
HAL device identification ¶
- group HAL_Exported_Functions_Group4
-
This subsection provides a set of functions allowing retrieval of device identification data:
Call HAL_GetDeviceUniqueID() to get the device unique identification.
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)
- group HAL_Exported_Functions_Group4
-
This subsection provides a set of functions allowing retrieval of device identification data:
Call HAL_GetDeviceUniqueID() to get the device unique identification.
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)
- group HAL_Exported_Functions_Group4
-
This subsection provides a set of functions allowing retrieval of device identification data:
Call HAL_GetDeviceUniqueID() to get the device unique identification.
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)