6fc685bc2a
Split the board specific code into a HAL API. Added a POSIX HAL and hacked everything over to it.
31 lines
598 B
C++
31 lines
598 B
C++
#include "timer.h"
|
|
#include "debug.h"
|
|
|
|
struct Binding;
|
|
|
|
struct Binding
|
|
{
|
|
Timer* ptimer;
|
|
const Timer::Fixed* pfixed;
|
|
};
|
|
|
|
Binding _bindings[50];
|
|
|
|
void Timer::tick_all()
|
|
{
|
|
for (Binding* pbinding = _bindings; pbinding->ptimer != nullptr; pbinding++) {
|
|
pbinding->ptimer->tick(*pbinding->pfixed);
|
|
}
|
|
}
|
|
|
|
void Timer::bind(Timer& timer, const Timer::Fixed& fixed)
|
|
{
|
|
for (Binding* pbinding = _bindings; true; pbinding++) {
|
|
if (pbinding->ptimer == nullptr) {
|
|
pbinding->ptimer = &timer;
|
|
pbinding->pfixed = &fixed;
|
|
break;
|
|
}
|
|
}
|
|
}
|