2021-09-14 15:48:57 +00:00
|
|
|
#include <time.h>
|
|
|
|
#include "clock.h"
|
|
|
|
|
|
|
|
#define MILISECONDS_IN_DAY 86400000
|
|
|
|
|
|
|
|
volatile TimeSystem _internal_time;
|
|
|
|
uint32 _internal_frequency_hz;
|
|
|
|
|
2021-09-14 15:58:06 +00:00
|
|
|
extern void TaskSwitch (_RegsStack32* regs);
|
2021-09-14 15:57:06 +00:00
|
|
|
|
2021-09-14 15:58:06 +00:00
|
|
|
void TimeHandler(_RegsStack32* r)
|
2021-09-14 15:48:57 +00:00
|
|
|
{
|
|
|
|
if (_internal_frequency_hz == 0) return;
|
|
|
|
|
|
|
|
_internal_time.Time += 1000/_internal_frequency_hz;
|
|
|
|
if (_internal_time.Time >= MILISECONDS_IN_DAY)
|
|
|
|
{
|
|
|
|
_internal_time.Date++;
|
|
|
|
_internal_time.Time-=MILISECONDS_IN_DAY;
|
|
|
|
}
|
2021-09-14 15:57:06 +00:00
|
|
|
|
2021-09-14 15:58:06 +00:00
|
|
|
TaskSwitch(r);
|
2021-09-14 15:48:57 +00:00
|
|
|
}
|