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

Workload estimation utilities. More...

#include <stdio.h>
#include "sarmfsw.h"
#include "TIM_ex.h"
#include "tick_utils.h"
#include "workload.h"
Include dependency graph for workload.c:

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 = 0
 
volatile uint32_t it_ticks_start
 
volatile bool it_counts_ongoing = false
 

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

Warning
M0/M0+ cores doesn't have core debug trace peripheral, time count 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, WORKLOAD_TIM_INST symbol has to be defined with proper TIM instance at project level.

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 = false

◆ it_ticks_accumulator

volatile uint32_t it_ticks_accumulator = 0

◆ it_ticks_start

volatile uint32_t it_ticks_start