HARMcksL: ARM HAL toolbox (yet STM32 oriented) 1.6
SMFSW collection of HAL hacks for STM32
Loading...
Searching...
No Matches
tick_utils.h File Reference

Core ticks related utilities. More...

#include "sarmfsw.h"
Include dependency graph for tick_utils.h:
This graph shows which files directly or indirectly include this file:

Functions

float get_TicksPerMicrosecond (void)
 Get number of ticks per microsecond (for reference)
 
FctERR init_Delay_Generator (void)
 Delay generator initialization function.
 
void Delay_us (const uint32_t us)
 Microseconds delay generator (blocking)
 
void Delay_ms (const uint32_t ms)
 Milliseconds delay generator (blocking)
 

Detailed Description

Core ticks related utilities.

Author
SMFSW
Warning
Of course, these blocking delays are not designed to be used in an RTOS environment where they wouldn't work properly.
M0/M0+ cores doesn't have core debug trace peripheral, delay shall be generated using a dedicated TIM peripheral.
Note
With cores other than M0/M0+, core debug trace timer is used by default.
In case of M0/M0+ core or willing to use a TIM peripheral on purpose, DELAY_TIM_INST symbol has to be defined with proper TIM instance at project level.

Function Documentation

◆ Delay_ms()

void Delay_ms ( const uint32_t ms)

Milliseconds delay generator (blocking)

Note
Please keep in mind Delay_ms is blocking code execution for the given amount of time (except interrupts).
Parameters
[in]ms- delay (in ms)
Warning
ms is 32b type parameter for consistency, yet if using DWT as delay source, value must be kept below ULONG_MAX / (prescaler * 1000)

◆ Delay_us()

void Delay_us ( const uint32_t us)

Microseconds delay generator (blocking)

Note
Please keep in mind Delay_us is blocking code execution for the given amount of time (except interrupts).
Parameters
[in]us- delay (in µs)
Warning
us is 32b type parameter for consistency, yet only DWT & 32b TIM instances can handle us parameter more than USHRT_MAX (65535)

◆ get_TicksPerMicrosecond()

float get_TicksPerMicrosecond ( void )

Get number of ticks per microsecond (for reference)

Note
Only relevant after call to init_Delay_Generator
Returns
Number of tick per microsecond
Here is the caller graph for this function:

◆ init_Delay_Generator()

FctERR init_Delay_Generator ( void )

Delay generator initialization function.

Note
In case of system core clock frequency change during execution (calls to SystemCoreClockUpdate, HAL_RCC_ClockConfig), init_Delay_us shall be called to update tick ratio.
Debug Trace peripheral timer only: On some Cortex cores, need to enable access to DWT prior to init and use of delays (automatically done only for M7 core).
Returns
FctERR - Error code
Here is the caller graph for this function: