software:firmware
MakAir Firmware
cpu_load.h File Reference

A CPU load estimation. More...

#include <stdint.h>

Go to the source code of this file.

Macros

#define TIME_CPU_CYCLE_RESET   1000u
 Duration in ms after which the CPU cycle count is reset and the result is stored. More...
 
#define COUNT_IDLE_CYCLE   idleCyclesCount++
 Increment the idle cycles counter. More...
 

Functions

uint8_t readCpuLoadPercent (void)
 Get the value of the CPU load. More...
 

Variables

volatile uint32_t idleCyclesCount
 Access to idleCyclesCount needed by the COUNT_IDLE_CYCLE macro. More...
 

Detailed Description

A CPU load estimation.

Author
Makers For Life

Definition in file cpu_load.h.

Macro Definition Documentation

◆ COUNT_IDLE_CYCLE

#define COUNT_IDLE_CYCLE   idleCyclesCount++

Increment the idle cycles counter.

Note
This must be called in the main loop() with nothing else in the loop

Definition at line 26 of file cpu_load.h.

◆ TIME_CPU_CYCLE_RESET

#define TIME_CPU_CYCLE_RESET   1000u

Duration in ms after which the CPU cycle count is reset and the result is stored.

Definition at line 17 of file cpu_load.h.

Function Documentation

◆ readCpuLoadPercent()

uint8_t readCpuLoadPercent ( void  )

Get the value of the CPU load.

Returns
CPU load in percent
Note
If this raises to 100%, there is some blocking code somewhere

Definition at line 39 of file cpu_load.cpp.

39 { return cpuLoadPercent; }
volatile uint8_t cpuLoadPercent
Definition: cpu_load.cpp:25

Variable Documentation

◆ idleCyclesCount

volatile uint32_t idleCyclesCount
extern

Access to idleCyclesCount needed by the COUNT_IDLE_CYCLE macro.

Definition at line 22 of file cpu_load.cpp.