Ejemplo n.º 1
0
void fiber_sending(void)
{
	struct nano_timer timer;
	uint32_t data[2] = {0, 0};
	struct net_context *ctx;
	int i = 0;

	ctx = get_context(&loopback_addr, DEST_PORT, &any_addr, SRC_PORT);
	if (!ctx) {
		PRINT("Cannot get network context\n");
		return;
	}

	nano_timer_init(&timer, data);

	while (1) {
		if (CONFIG_NET_15_4_LOOPBACK_NUM != 0 &&
					i >= CONFIG_NET_15_4_LOOPBACK_NUM) {
			nano_fiber_timer_stop(&timer);
			return;
		}

		send_data("sendFiber", ctx);

		nano_fiber_timer_start(&timer, SLEEPTICKS);
		nano_fiber_timer_test(&timer, TICKS_UNLIMITED);
		i++;
	}
}
Ejemplo n.º 2
0
/**
 * 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;
    }
}
Ejemplo n.º 3
0
/*---------------------------------------------------------------------------*/
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;
}