/*---------------------------------------------------------------------------*/ bool timer_stop(struct timer *t) { if (!t->started) { return false; } switch (sys_execution_context_type_get()) { case NANO_CTX_FIBER: nano_fiber_timer_stop(&t->nano_timer); break; case NANO_CTX_TASK: nano_task_timer_stop(&t->nano_timer); break; default: return false; } PRINTF("%s():%d timer %p stopped\n", __FUNCTION__, __LINE__, t); t->started = false; t->triggered = false; return true; }
/** * Signal g_TimerSem to wake-up timer_task. * */ static void signal_timer_task (void) { T_EXEC_LEVEL execLvl; execLvl = _getExecLevel(); /* call the nanoK service that corresponds to the current execution level */ switch ( execLvl ) { case E_EXEC_LVL_ISR: #ifdef CONFIG_NANOKERNEL nano_fiber_timer_stop (&g_NanoTimer); #else /* -> CONFIG_MICROKERNEL */ isr_sem_give ( g_TimerSem, NULL ) ; #endif break; case E_EXEC_LVL_FIBER: #ifdef CONFIG_NANOKERNEL nano_fiber_timer_stop (&g_NanoTimer); #else /* -> CONFIG_MICROKERNEL */ fiber_sem_give ( g_TimerSem, NULL ) ; #endif break; case E_EXEC_LVL_TASK: #ifdef CONFIG_NANOKERNEL nano_task_timer_stop (&g_NanoTimer); #else /* -> CONFIG_MICROKERNEL */ task_sem_give ( g_TimerSem ) ; #endif break; default: /* will not do that from unknown context */ panic (E_OS_ERR_NOT_SUPPORTED) ; break; } }