STM32L4xx_HAL_Driver  1.14.0

HAL Control functions. More...

Functions

void HAL_IncTick (void)
 This function is called to increment a global variable "uwTick" used as application time base. More...
 
void HAL_Delay (uint32_t Delay)
 This function provides minimum delay (in milliseconds) based on variable incremented. More...
 
uint32_t HAL_GetTick (void)
 Provide a tick value in millisecond. More...
 
uint32_t HAL_GetTickPrio (void)
 This function returns a tick priority. More...
 
HAL_StatusTypeDef HAL_SetTickFreq (uint32_t Freq)
 Set new tick Freq. More...
 
uint32_t HAL_GetTickFreq (void)
 Return tick frequency. More...
 
void HAL_SuspendTick (void)
 Suspend Tick increment. More...
 
void HAL_ResumeTick (void)
 Resume Tick increment. More...
 
uint32_t HAL_GetHalVersion (void)
 Return the HAL revision. More...
 
uint32_t HAL_GetREVID (void)
 Return the device revision identifier. More...
 
uint32_t HAL_GetDEVID (void)
 Return the device identifier. More...
 
uint32_t HAL_GetUIDw0 (void)
 Return the first word of the unique device identifier (UID based on 96 bits) More...
 
uint32_t HAL_GetUIDw1 (void)
 Return the second word of the unique device identifier (UID based on 96 bits) More...
 
uint32_t HAL_GetUIDw2 (void)
 Return the third word of the unique device identifier (UID based on 96 bits) More...
 

Detailed Description

HAL Control functions.

 ===============================================================================
                      ##### HAL Control functions #####
 ===============================================================================
    [..]  This section provides functions allowing to:
      (+) Provide a tick value in millisecond
      (+) Provide a blocking delay in millisecond
      (+) Suspend the time base source interrupt
      (+) Resume the time base source interrupt
      (+) Get the HAL API driver version
      (+) Get the device identifier
      (+) Get the device revision identifier

Function Documentation

◆ HAL_Delay()

__weak void HAL_Delay ( uint32_t  Delay)

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 uwTick is incremented.
This function is declared as __weak to be overwritten in case of other implementations in user file.
Parameters
Delayspecifies the delay time length, in milliseconds.
Return values
None

Definition at line 394 of file stm32l4xx_hal.c.

395 {
396  uint32_t tickstart = HAL_GetTick();
397  uint32_t wait = Delay;
398 
399  /* Add a period to guaranty minimum wait */
400  if (wait < HAL_MAX_DELAY)
401  {
402  wait += (uint32_t)(uwTickFreq);
403  }
404 
405  while((HAL_GetTick() - tickstart) < wait)
406  {
407  }
408 }
uint32_t HAL_GetTick(void)
Provide a tick value in millisecond.
uint32_t uwTickFreq
Definition: stm32l4xx_hal.c:92

◆ HAL_GetDEVID()

uint32_t HAL_GetDEVID ( void  )

Return the device identifier.

Return values
Deviceidentifier

Definition at line 464 of file stm32l4xx_hal.c.

465 {
466  return(DBGMCU->IDCODE & DBGMCU_IDCODE_DEV_ID);
467 }

◆ HAL_GetHalVersion()

uint32_t HAL_GetHalVersion ( void  )

Return the HAL revision.

Return values
version: 0xXYZR (8bits for each decimal, R for RC)

Definition at line 446 of file stm32l4xx_hal.c.

447 {
448  return STM32L4XX_HAL_VERSION;
449 }

◆ HAL_GetREVID()

uint32_t HAL_GetREVID ( void  )

Return the device revision identifier.

Return values
Devicerevision identifier

Definition at line 455 of file stm32l4xx_hal.c.

456 {
457  return((DBGMCU->IDCODE & DBGMCU_IDCODE_REV_ID) >> 16);
458 }

◆ HAL_GetTick()

__weak uint32_t HAL_GetTick ( void  )

Provide a tick value in millisecond.

Note
This function is declared as __weak to be overwritten in case of other implementations in user file.
Return values
tickvalue

Definition at line 337 of file stm32l4xx_hal.c.

338 {
339  return uwTick;
340 }
__IO uint32_t uwTick
Definition: stm32l4xx_hal.c:90

◆ HAL_GetTickFreq()

uint32_t HAL_GetTickFreq ( void  )

Return tick frequency.

Return values
tickperiod in Hz

Definition at line 378 of file stm32l4xx_hal.c.

379 {
380  return uwTickFreq;
381 }
uint32_t uwTickFreq
Definition: stm32l4xx_hal.c:92

◆ HAL_GetTickPrio()

uint32_t HAL_GetTickPrio ( void  )

This function returns a tick priority.

Return values
tickpriority

Definition at line 346 of file stm32l4xx_hal.c.

347 {
348  return uwTickPrio;
349 }
uint32_t uwTickPrio
Definition: stm32l4xx_hal.c:91

◆ HAL_GetUIDw0()

uint32_t HAL_GetUIDw0 ( void  )

Return the first word of the unique device identifier (UID based on 96 bits)

Return values
Deviceidentifier

Definition at line 473 of file stm32l4xx_hal.c.

474 {
475  return(READ_REG(*((uint32_t *)UID_BASE)));
476 }

◆ HAL_GetUIDw1()

uint32_t HAL_GetUIDw1 ( void  )

Return the second word of the unique device identifier (UID based on 96 bits)

Return values
Deviceidentifier

Definition at line 482 of file stm32l4xx_hal.c.

483 {
484  return(READ_REG(*((uint32_t *)(UID_BASE + 4U))));
485 }

◆ HAL_GetUIDw2()

uint32_t HAL_GetUIDw2 ( void  )

Return the third word of the unique device identifier (UID based on 96 bits)

Return values
Deviceidentifier

Definition at line 491 of file stm32l4xx_hal.c.

492 {
493  return(READ_REG(*((uint32_t *)(UID_BASE + 8U))));
494 }

◆ HAL_IncTick()

__weak 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 variable is incremented each 1ms in SysTick ISR.
This function is declared as __weak to be overwritten in case of other implementations in user file.
Return values
None

Definition at line 326 of file stm32l4xx_hal.c.

327 {
328  uwTick += uwTickFreq;
329 }
__IO uint32_t uwTick
Definition: stm32l4xx_hal.c:90
uint32_t uwTickFreq
Definition: stm32l4xx_hal.c:92

◆ HAL_ResumeTick()

__weak 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.
This function is declared as __weak to be overwritten in case of other implementations in user file.
Return values
None

Definition at line 436 of file stm32l4xx_hal.c.

437 {
438  /* Enable SysTick Interrupt */
439  SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk;
440 }

◆ HAL_SetTickFreq()

HAL_StatusTypeDef HAL_SetTickFreq ( uint32_t  Freq)

Set new tick Freq.

Parameters
Freqtick frequency
Return values
HALstatus

Definition at line 356 of file stm32l4xx_hal.c.

357 {
358  HAL_StatusTypeDef status = HAL_OK;
359  assert_param(IS_TICKFREQ(Freq));
360 
361  if (uwTickFreq != Freq)
362  {
363  /* Apply the new tick Freq */
364  status = HAL_InitTick(uwTickPrio);
365  if (status == HAL_OK)
366  {
367  uwTickFreq = Freq;
368  }
369  }
370 
371  return status;
372 }
return HAL_OK
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 ...
uint32_t uwTickFreq
Definition: stm32l4xx_hal.c:92
uint32_t uwTickPrio
Definition: stm32l4xx_hal.c:91
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_SuspendTick()

__weak 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.
This function is declared as __weak to be overwritten in case of other implementations in user file.
Return values
None

Definition at line 420 of file stm32l4xx_hal.c.

421 {
422  /* Disable SysTick Interrupt */
423  SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;
424 }