MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / timer_alloc

Function timer_alloc

TactilityKernel/source/concurrent/timer.c:20–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18}
19
20struct Timer* timer_alloc(enum TimerType type, TickType_t ticks, timer_callback_t callback, void* context) {
21 check(xPortInIsrContext() == pdFALSE);
22 check(callback != NULL);
23
24 struct Timer* timer = (struct Timer*)malloc(sizeof(struct Timer));
25 if (timer == NULL) {
26 return NULL;
27 }
28
29 timer->callback = callback;
30 timer->context = context;
31
32 BaseType_t auto_reload = (type == TIMER_TYPE_ONCE) ? pdFALSE : pdTRUE;
33 timer->handle = xTimerCreate(NULL, ticks, auto_reload, timer, timer_callback_internal);
34
35 if (timer->handle == NULL) {
36 free(timer);
37 return NULL;
38 }
39
40 return timer;
41}
42
43void timer_free(struct Timer* timer) {
44 check(xPortInIsrContext() == pdFALSE);

Callers 1

TimerTest.cppFile · 0.85

Calls 1

checkFunction · 0.50

Tested by

no test coverage detected