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

Workload estimation utilities. More...

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

Macros

#define GET_COUNT()   DWT->CYCCNT
 
#define WORKLOAD_IT_IN()
 
#define WORKLOAD_IT_OUT()
 

Typedefs

typedef enum eWorkload_val eWorkload_val
 

Enumerations

enum  eWorkload_val { Workload_average = 0 , Workload_worst , Workload_best }
 Workload type value enum. More...
 

Functions

float get_Workload_load_perc (const eWorkload_val type)
 Get interrupts load percentage.
 
uint32_t get_Workload_loop_period (const eWorkload_val type)
 Get main loop period.
 
FctERR Workload_init (void)
 Init Workload functionalities.
 
void set_Workload_ticks_us (const float ticks)
 Set number of timer ticks in a µs.
 
void set_Workload_window (const uint32_t per)
 Set workload estimation time window (in ms)
 
void Workload_handler (void)
 Workload handler.
 
void Workload_show_results (void)
 Print workload results.
 

Variables

volatile uint32_t it_ticks_accumulator
 
volatile uint32_t it_ticks_start
 
volatile bool it_counts_ongoing
 

Detailed Description

Workload estimation utilities.

Author
SMFSW
Note
Define IT_WORKLOAD symbol at project level to use workload estimation module functionalities
Loop period values will only be relevant in case of sequential code (you will get task period for RTOS based code)

Handler has to be called in the main sequential loop (or in a periodic task). Init function has to be called prior to main loop. WORLOAD_IT_IN macro has to be put at the start of every interrupt, WORLOAD_IT_OUT macro before return of every interrupt

Macro Definition Documentation

◆ GET_COUNT

#define GET_COUNT ( )    DWT->CYCCNT

◆ WORKLOAD_IT_IN

#define WORKLOAD_IT_IN ( )
Value:
bool already_counting = it_counts_ongoing ? true : false; \
if (!already_counting) { it_ticks_start = GET_COUNT(); }
volatile uint32_t it_ticks_start
Definition workload.h:31
volatile bool it_counts_ongoing
Definition workload.c:27
#define GET_COUNT()
Definition workload.h:26

◆ WORKLOAD_IT_OUT

#define WORKLOAD_IT_OUT ( )
Value:
if (!already_counting) { \
it_counts_ongoing = false; }
volatile uint32_t it_ticks_accumulator
Definition workload.c:26

Typedef Documentation

◆ eWorkload_val

Enumeration Type Documentation

◆ eWorkload_val

Workload type value enum.

Enumerator
Workload_average 

Average value.

Workload_worst 

Worst value.

Workload_best 

Best value.

Function Documentation

◆ get_Workload_load_perc()

float get_Workload_load_perc ( const eWorkload_val type)

Get interrupts load percentage.

Parameters
[in]type- Type to get
Returns
Interrupts load percentage

◆ get_Workload_loop_period()

uint32_t get_Workload_loop_period ( const eWorkload_val type)

Get main loop period.

Note
Loop period values will only be relevant in case of sequential code (you will get task period for RTOS based code)
Parameters
[in]type- Type to get
Returns
Loop period

◆ set_Workload_ticks_us()

void set_Workload_ticks_us ( const float ticks)

Set number of timer ticks in a µs.

Weak Functions
Function declared as weak, can be customly implemented in project if special timer is required
Note
Useful in case of Workload_init custom implementation
Parameters
[in]ticks- Ticks in a µs
Here is the caller graph for this function:

◆ set_Workload_window()

void set_Workload_window ( const uint32_t per)

Set workload estimation time window (in ms)

Parameters
[in]per- Time window in ms
Here is the caller graph for this function:

◆ Workload_handler()

void Workload_handler ( void )

Workload handler.

Note
This function shall be called in main loop or periodic task

◆ Workload_init()

FctERR Workload_init ( void )

Init Workload functionalities.

Weak Functions
Function declared as weak, can be customly implemented in project if special timer is required
Returns
FctERR - Error code
Here is the call graph for this function:

◆ Workload_show_results()

void Workload_show_results ( void )

Print workload results.

Variable Documentation

◆ it_counts_ongoing

volatile bool it_counts_ongoing
extern

◆ it_ticks_accumulator

volatile uint32_t it_ticks_accumulator
extern

◆ it_ticks_start

volatile uint32_t it_ticks_start