DIY Logging Volt/Ampmeter

Functions

__STATIC_INLINE void LL_InitTick (uint32_t HCLKFrequency, uint32_t Ticks)
 This function configures the Cortex-M SysTick source of the time base. More...
 
void LL_Init1msTick (uint32_t HCLKFrequency)
 This function configures the Cortex-M SysTick source to have 1ms time base. More...
 
void LL_mDelay (uint32_t Delay)
 This function provides accurate delay (in milliseconds) based on SysTick counter flag. More...
 

Detailed Description

Function Documentation

◆ LL_Init1msTick()

void LL_Init1msTick ( uint32_t  HCLKFrequency)

This function configures the Cortex-M SysTick source to have 1ms time base.

Note
When a RTOS is used, it is recommended to avoid changing the Systick configuration by calling this function, for a delay use rather osDelay RTOS service.
Parameters
HCLKFrequencyHCLK frequency in Hz
Note
HCLK frequency can be calculated thanks to RCC helper macro or function LL_RCC_GetSystemClocksFreq
Return values
None

Definition at line 166 of file stm32f1xx_ll_utils.c.

167 {
168  /* Use frequency provided in argument */
169  LL_InitTick(HCLKFrequency, 1000U);
170 }

◆ LL_InitTick()

__STATIC_INLINE void LL_InitTick ( uint32_t  HCLKFrequency,
uint32_t  Ticks 
)

This function configures the Cortex-M SysTick source of the time base.

Parameters
HCLKFrequencyHCLK frequency in Hz (can be calculated thanks to RCC helper macro)
Note
When a RTOS is used, it is recommended to avoid changing the SysTick configuration by calling this function, for a delay use rather osDelay RTOS service.
Parameters
TicksNumber of ticks
Return values
None

Definition at line 218 of file stm32f1xx_ll_utils.h.

219 {
220  /* Configure the SysTick to have interrupt in 1ms time base */
221  SysTick->LOAD = (uint32_t)((HCLKFrequency / Ticks) - 1UL); /* set reload register */
222  SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
224  SysTick_CTRL_ENABLE_Msk; /* Enable the Systick Timer */
225 }

◆ LL_mDelay()

void LL_mDelay ( uint32_t  Delay)

This function provides accurate delay (in milliseconds) based on SysTick counter flag.

Note
When a RTOS is used, it is recommended to avoid using blocking delay and use rather osDelay service.
To respect 1ms timebase, user should call LL_Init1msTick function which will configure Systick to 1ms
Parameters
Delayspecifies the delay time length, in milliseconds.
Return values
None

Definition at line 182 of file stm32f1xx_ll_utils.c.

183 {
184  __IO uint32_t tmp = SysTick->CTRL; /* Clear the COUNTFLAG first */
185  /* Add this code to indicate that local variable is not used */
186  ((void)tmp);
187 
188  /* Add a period to guaranty minimum wait */
189  if (Delay < LL_MAX_DELAY)
190  {
191  Delay++;
192  }
193 
194  while (Delay)
195  {
196  if ((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) != 0U)
197  {
198  Delay--;
199  }
200  }
201 }
LL_MAX_DELAY
#define LL_MAX_DELAY
Definition: stm32f1xx_ll_utils.h:60
LL_InitTick
__STATIC_INLINE void LL_InitTick(uint32_t HCLKFrequency, uint32_t Ticks)
This function configures the Cortex-M SysTick source of the time base.
Definition: stm32f1xx_ll_utils.h:218
SysTick_CTRL_CLKSOURCE_Msk
#define SysTick_CTRL_CLKSOURCE_Msk
Definition: core_armv8mbl.h:571
SysTick_CTRL_COUNTFLAG_Msk
#define SysTick_CTRL_COUNTFLAG_Msk
Definition: core_armv8mbl.h:568
__IO
#define __IO
Definition: core_armv8mbl.h:196
SysTick_CTRL_ENABLE_Msk
#define SysTick_CTRL_ENABLE_Msk
Definition: core_armv8mbl.h:577
SysTick
#define SysTick
Definition: core_armv8mbl.h:1123