Line |
Branch |
Decision |
Exec |
Source |
1 |
|
|
|
// |
2 |
|
|
|
// Created by FDSoftware on 23/04/25. |
3 |
|
|
|
// Note: keep this controller separated from main_loop.h, |
4 |
|
|
|
// otherwise a circular dependency is generated between pch.h / mpu_watchdog.h / mpu_util.h |
5 |
|
|
|
// |
6 |
|
|
|
#pragma once |
7 |
|
|
|
#include "pch.h" |
8 |
|
|
|
#include "periodic_thread_controller.h" |
9 |
|
|
|
#include "main_loop.h" |
10 |
|
|
|
|
11 |
|
|
|
template <LoopPeriod flag> |
12 |
|
|
|
static constexpr int loopCounts() { |
13 |
|
|
|
constexpr auto hz = hzForPeriod(flag); |
14 |
|
|
|
|
15 |
|
|
|
// check that this cleanly divides |
16 |
|
|
|
static_assert(MAIN_LOOP_RATE % hz == 0); |
17 |
|
|
|
|
18 |
|
|
|
return MAIN_LOOP_RATE / hz; |
19 |
|
|
|
} |
20 |
|
|
|
|
21 |
|
|
|
class MainLoop : public PeriodicController<1024> { |
22 |
|
|
|
public: |
23 |
|
|
|
MainLoop(); |
24 |
|
|
|
void PeriodicTask(efitick_t nowNt) override; |
25 |
|
|
|
|
26 |
|
|
|
#if ! EFI_UNIT_TEST |
27 |
|
|
|
private: |
28 |
|
|
|
#endif |
29 |
|
|
|
|
30 |
|
|
|
template <LoopPeriod TFlag> |
31 |
|
|
|
LoopPeriod makePeriodFlag() const; |
32 |
|
|
|
|
33 |
|
|
|
LoopPeriod makePeriodFlags(); |
34 |
|
|
|
|
35 |
|
|
|
int m_cycleCounter = 0; |
36 |
|
|
|
}; |
37 |
|
|
|
|
38 |
|
|
|
static MainLoop mainLoop CCM_OPTIONAL; |
39 |
|
|
|
|