rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
main_loop_controller.h
Go to the documentation of this file.
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"
9#include "main_loop.h"
10
11template <LoopPeriod flag>
12static 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
21class MainLoop : public PeriodicController<1024> {
22public:
23 MainLoop();
24 void PeriodicTask(efitick_t nowNt) override;
25
26#if ! EFI_UNIT_TEST
27private:
28#endif
29
30 template <LoopPeriod TFlag>
32
34
36};
37
38static MainLoop mainLoop CCM_OPTIONAL;
LoopPeriod makePeriodFlag() const
Definition main_loop.cpp:16
LoopPeriod makePeriodFlags()
Definition main_loop.cpp:24
void PeriodicTask(efitick_t nowNt) override
Called periodically. Override this method to do work for your controller.
Definition main_loop.cpp:41
Base class for a controller that needs to run periodically to perform work.
LoopPeriod
Definition main_loop.h:7
constexpr int hzForPeriod(LoopPeriod p)
Definition main_loop.h:25
static constexpr int loopCounts()
static MainLoop mainLoop CCM_OPTIONAL