27 lines
530 B
C
27 lines
530 B
C
#include <time.h>
|
|
#include "clock.h"
|
|
|
|
#define MILISECONDS_IN_DAY 86400000
|
|
|
|
volatile TimeSystem _internal_time;
|
|
uint32 _internal_frequency_hz;
|
|
|
|
extern void TaskingScheduler();
|
|
|
|
void TimeHandler(_RegsStack32* UNUSED(r))
|
|
{
|
|
// Make sure it is initialised
|
|
if (_internal_frequency_hz == 0) return;
|
|
|
|
// Timer tick
|
|
_internal_time.Time += 1000/_internal_frequency_hz;
|
|
if (_internal_time.Time >= MILISECONDS_IN_DAY)
|
|
{
|
|
_internal_time.Date++;
|
|
_internal_time.Time-=MILISECONDS_IN_DAY;
|
|
}
|
|
|
|
// Launch scheduler
|
|
TaskingScheduler();
|
|
}
|