23 lines
556 B
C
23 lines
556 B
C
//
|
|
// Created by epagris on 2022.12.21..
|
|
//
|
|
|
|
#include "timer.h"
|
|
#include "dynmem.h"
|
|
#include "utils.h"
|
|
|
|
Timer *timer_new(uint32_t maxSched) {
|
|
uint32_t tmrHdrSize = sizeof(TimePoint) + sizeof(AlarmAssignment *) + 2 * sizeof(uint32_t);
|
|
Timer * tmr = (Timer *) dynmem_alloc(tmrHdrSize + maxSched * sizeof(AlarmAssignment));
|
|
ASSERT_NULL(tmr);
|
|
|
|
tmr->maxSched = maxSched;
|
|
tmr->nSched = 0;
|
|
tmr->nextAlarm = NULL;
|
|
tmr->time.s = 0;
|
|
tmr->time.ns = 0;
|
|
memset(tmr->alarms, 0, maxSched * sizeof(AlarmAssignment));
|
|
|
|
return tmr;
|
|
}
|