GCC Code Coverage Report


Directory: ./
File: firmware/controllers/core/main_loop.h
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 81.2% 13 0 16
Functions: 100.0% 4 0 4
Branches: 57.1% 4 0 7
Decisions: 50.0% 3 - 6

Line Branch Decision Exec Source
1 #pragma once
2
3 #define MAIN_LOOP_RATE 1000
4
5 void initMainLoop();
6
7 enum class LoopPeriod : uint8_t {
8 None = 0,
9 Period1000hz = 1 << 0,
10 Period500hz = 1 << 1,
11 Period250hz = 1 << 2,
12 Period200hz = 1 << 3,
13 Period20hz = 1 << 4,
14 };
15
16 25 inline constexpr LoopPeriod& operator|=(LoopPeriod& a, const LoopPeriod& b) {
17 25 a = static_cast<LoopPeriod>(static_cast<uint8_t>(a) | static_cast<uint8_t>(b));
18 25 return a;
19 }
20
21 25 inline constexpr bool operator&(LoopPeriod a, LoopPeriod b) {
22 25 return 0 != (static_cast<uint8_t>(a) & static_cast<uint8_t>(b));
23 }
24
25 61137 constexpr int hzForPeriod(LoopPeriod p) {
26
4/7
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 60050 times.
✓ Branch 5 taken 1085 times.
✓ Branch 6 taken 1 time.
61137 switch (p) {
27 case LoopPeriod::None: return 0;
28 case LoopPeriod::Period1000hz: return 1000;
29
1/1
✓ Decision 'true' taken 1 time.
1 case LoopPeriod::Period500hz: return 500;
30 case LoopPeriod::Period250hz: return 250;
31
1/1
✓ Decision 'true' taken 60050 times.
60050 case LoopPeriod::Period200hz: return 200;
32
1/1
✓ Decision 'true' taken 1085 times.
1085 case LoopPeriod::Period20hz: return 20;
33 }
34
35 1 return 0;
36 }
37
38 61135 constexpr float loopPeriodMs(LoopPeriod p) {
39 61135 return 1000.0f / hzForPeriod(p);
40 }
41
42 #ifndef ADC_UPDATE_RATE
43 #define ADC_UPDATE_RATE LoopPeriod::Period500hz
44 #endif
45
46 #define ETB_UPDATE_RATE LoopPeriod::Period500hz
47 #define FAST_CALLBACK_RATE LoopPeriod::Period200hz
48 #define SLOW_CALLBACK_RATE LoopPeriod::Period20hz
49
50 #define FAST_CALLBACK_PERIOD_MS loopPeriodMs(FAST_CALLBACK_RATE)
51 #define SLOW_CALLBACK_PERIOD_MS loopPeriodMs(SLOW_CALLBACK_RATE)
52