43template <u
int8_t NUM_TASKS, u
int8_t NUM_MCP2515>
50 Scheduler(uint32_t period_us_, uint32_t spin_threshold_us_,
unsigned long (*
const current_time_us)());
54 void synchronize(
unsigned long (*
const current_time_us)());
Enumeration definitions for the VCU.
McpIndex
MCP2515 instance indices.
Implementation of the Scheduler class template.
Scheduler class template for scheduling tasks on multiple MCP2515 instances Takes in function pointer...
bool removeTask(const McpIndex mcp_index, const TaskFn task)
Remove a task from the scheduler for a specific MCP2515 instance.
uint8_t task_cnt[NUM_MCP2515]
void synchronize(unsigned long(*const current_time_us)())
Synchonize the scheduler to the current time, resetting all task counters, used when starting multipl...
uint8_t task_counters[NUM_MCP2515][NUM_TASKS]
constexpr uint32_t getPeriodUs() const
Returns the period of the scheduler in microseconds.
bool addTask(const McpIndex mcp_index, const TaskFn task, const uint8_t tick_interval)
Add a task to the scheduler for a specific MCP2515 index.
TaskFn tasks[NUM_MCP2515][NUM_TASKS]
constexpr uint32_t cyclesNeeded(const uint32_t interval_us) const
Returns the number of cycles needed for a given interval in microseconds.
uint8_t task_ticks[NUM_MCP2515][NUM_TASKS]
void update()
Update the scheduler, checking if tasks need to be run based on the current time.
void runTasks()
Helper function to run scheduled tasks.
unsigned long(*const CURRENT_TIME_US)()