当前位置: 首页>>代码示例>>C++>>正文


C++ ctimer_set函数代码示例

本文整理汇总了C++中ctimer_set函数的典型用法代码示例。如果您正苦于以下问题:C++ ctimer_set函数的具体用法?C++ ctimer_set怎么用?C++ ctimer_set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ctimer_set函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: backlight_on

void backlight_on(uint8_t level, clock_time_t length)
{
  if (level > 8) level = 8;

  level *= 2;
  if (level == 0)
  {
    LIGHTCONTROL = OUTMOD_0;
  }
  else
  {
    LIGHTCONTROL = OUTMOD_7;
    LIGHTLEVEL = level * 2;
    if (length > 0)
      ctimer_set(&light_timer, length, light_stop, (void*)(CLOCK_SECOND/8));
  }
}
开发者ID:Echoskope,项目名称:KreyosFirmware,代码行数:17,代码来源:backlight.c

示例2: motor_on

void motor_on(uint8_t level, clock_time_t length)
{
  if (level > 16) level = 16;
  level *= 2;

  if (level == 0)
  {
    motor_stop(NULL);
  }
  else
  {
    MOTORCONTROL = OUTMOD_7;
    MOTORLEVEL = level;
    if (length > 0)
      ctimer_set(&motor_timer, length, motor_stop, NULL);
  }
}
开发者ID:Echoskope,项目名称:KreyosFirmware,代码行数:17,代码来源:backlight.c

示例3: new_dio_interval

static void
new_dio_interval(rpl_instance_t *instance)
{
  uint32_t time;

  /* TODO: too small timer intervals for many cases */
  time = 1UL << instance->dio_intcurrent;

  /* Convert from milliseconds to CLOCK_TICKS. */
  time = (time * CLOCK_SECOND) / 1000;

  instance->dio_next_delay = time;

  /* random number between I/2 and I */
  time = time >> 1;
  time += (time * random_rand()) / RANDOM_RAND_MAX;

  /*
   * The intervals must be equally long among the nodes for Trickle to
   * operate efficiently. Therefore we need to calculate the delay between
   * the randomized time and the start time of the next interval.
   */
  instance->dio_next_delay -= time;
  instance->dio_send = 1;

#if RPL_CONF_STATS
  /* keep some stats */
  instance->dio_totint++;
  instance->dio_totrecv += instance->dio_counter;
  ANNOTATE("#A rank=%u.%u(%u),stats=%d %d %d %d,color=%s\n",
	   DAG_RANK(instance->current_dag->rank, instance),
           (10 * (instance->current_dag->rank % instance->min_hoprankinc)) / instance->min_hoprankinc,
           instance->current_dag->version,
           instance->dio_totint, instance->dio_totsend,
           instance->dio_totrecv,instance->dio_intcurrent,
	   instance->current_dag->rank == ROOT_RANK(instance) ? "BLUE" : "ORANGE");
#endif /* RPL_CONF_STATS */

  /* reset the redundancy counter */
  instance->dio_counter = 0;

  /* schedule the timer */
  PRINTF("RPL: Scheduling DIO timer %lu ticks in future (Interval)\n", time);
  ctimer_set(&instance->dio_timer, time, &handle_dio_timer, instance);
}
开发者ID:Sowhat2112,项目名称:KreyosFirmware,代码行数:45,代码来源:rpl-timers.c

示例4: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(scheduler_process, ev, data)
{
  PROCESS_BEGIN();	

#ifdef TESTLIST
	test_list();
	//PROCESS_YIELD_SCH();
#else

printf("<-init -> runqueues\n");	
	init_runqueues();
printf("<-begin-> scheduler process - [%s]\n", process_current->name);
printf("<-init -> sch process\n")	;
	sch_process_init(example_process1);
	sch_process_init(example_process2);
	sch_process_init(example_process3);
	sch_process_init(example_process4);
	sch_process_init(example_process5);
	sch_process_init(example_process6);
	sch_process_init(end_process);
//	sch_process_current = NULL;
#if (0)
//e test to see if it really push into the list!
printf("after push\n");
p = (struct sch_process	*)list_head(run_queues->arrays[0].queue[10].list);
printf("after get\n");
printf("example_process3 fuc[%s] [%s]\n", example_process3.name, sch_example_process3.old->name);
printf("<-test -> name - [%d][%d]\n", p->add->prio, p->old->thread);
#endif

printf("<-timer-> set\n");
	ctimer_set(&ct_sch_tick, QUANTUM_DURATION, ct_callback_sch_tick, NULL);

	while (1) {
		//printf("<-in   -> scheduler_process before yield\n");
		PROCESS_YIELD_SCH();
		//printf("<-in   -> scheduler_process after  yield\n");
	}

	printf("<-end  -> scheduler process - [%s] - should not reach here\n", 
					process_current->name);

#endif
  PROCESS_END();
}
开发者ID:hsylx1992,项目名称:ctk_sch,代码行数:46,代码来源:ctk_sch.c

示例5: handle_dao_timer

static void
handle_dao_timer(void *ptr)
{
  rpl_instance_t *instance;

  instance = (rpl_instance_t *)ptr;

  if(!dio_send_ok && uip_ds6_get_link_local(ADDR_PREFERRED) == NULL) {
    PRINTF("RPL: Postpone DAO transmission\n");
    ctimer_set(&instance->dao_timer, CLOCK_SECOND, handle_dao_timer, instance);
    return;
  }

  /* Send the DAO to the DAO parent set -- the preferred parent in our case. */
  if(instance->current_dag->preferred_parent != NULL) {
    PRINTF("RPL: handle_dao_timer - sending DAO\n");
    /* Set the route lifetime to the default value. */
    dao_output(instance->current_dag->preferred_parent, instance->default_lifetime, NULL);
#if UIP_IPV6_MULTICAST_RPL
    if(instance->mop == RPL_MOP_STORING_MULTICAST) {
      /* Send a DAO for own multicast addresses */
      for(i = 0; i < UIP_DS6_MADDR_NB; i++) {
        if(uip_ds6_if.maddr_list[i].isused
            && uip_is_addr_mcast_global(&uip_ds6_if.maddr_list[i].ipaddr)) {
          dao_output(instance->current_dag->preferred_parent, RPL_MCAST_LIFETIME,
              &uip_ds6_if.maddr_list[i].ipaddr);
        }
      }
      /* Iterate multicast routes and send DAOs */
      for(i = 0; i < UIP_DS6_MCAST_ROUTES; i++) {
        /* Don't send if it's also our own address, done that already */
        if(uip_ds6_mcast_table[i].isused) {
          if(uip_ds6_maddr_lookup(&uip_ds6_mcast_table[i].group) == NULL) {
            dao_output(instance->current_dag->preferred_parent, RPL_MCAST_LIFETIME,
                &uip_ds6_mcast_table[i].group);
          }
        }
      }
    }
#endif
  } else {
    PRINTF("RPL: No suitable DAO parent\n");
  }
  ctimer_stop(&instance->dao_timer);
}
开发者ID:kfathallah,项目名称:contiki-mcast,代码行数:45,代码来源:rpl-timers.c

示例6: PROCESS_THREAD

PROCESS_THREAD(blinker_test_loop, ev, data)
{
  PROCESS_BEGIN();

  //	(1)	UART Output
  printf("OTA Image Example: Starting\n");
#if PLATFORM_HAS_LEDS
  //	(2)	Start blinking green LED
  leds_init();
  leds_on(BLINKER_PIN);
#else
  printf("Platform does not support LED. Unique ID: %u\n", OTA_EXAMPLE_UNIQUE_ID);
#endif

  ctimer_set( &blink_timer, (CLOCK_SECOND/2), blink_looper, NULL);

  //  (3) Get metadata about the current firmware version
  OTAMetadata_t current_firmware;
  get_current_metadata( &current_firmware );
  printf("\nCurrent Firmware\n");
  print_metadata( &current_firmware );

  ext_flash_init();

  int ota_slot;
  OTAMetadata_t ota_metadata;

  printf("\nNewest Firmware:\n");
  ota_slot = find_newest_ota_image();
  while( get_ota_slot_metadata( ota_slot, &ota_metadata ) );
  print_metadata( &ota_metadata );

  printf("\nOldest Firmware:\n");
  ota_slot = find_oldest_ota_image();
  while( get_ota_slot_metadata( ota_slot, &ota_metadata ) );
  print_metadata( &ota_metadata );

  int empty_slot = find_empty_ota_slot();
  printf("\nEmpty OTA slot: #%u\n", empty_slot);

  //  (4) OTA Download!
  process_start(ota_download_th_p, NULL);

  PROCESS_END();
}
开发者ID:msolters,项目名称:contiki,代码行数:45,代码来源:ota-image-example.c

示例7: create_dag_callback

/*---------------------------------------------------------------------------*/
static void
create_dag_callback(void *ptr)
{
  const uip_ipaddr_t *root, *ipaddr;
  printf("\r\nCtimer timer callback for dag root");
  root = simple_rpl_root();
  ipaddr = simple_rpl_global_address();

  if(root == NULL || uip_ipaddr_cmp(root, ipaddr)) {
    /* The RPL network we are joining is one that we created, so we
       become root. */
	printf("\r\n No root available, we'll make ourself as root ");
    if(to_become_root) {
      simple_rpl_init_dag_immediately();
      to_become_root = 0;
    }
  } else {
    rpl_dag_t *dag;

    dag = rpl_get_any_dag();
#if 1
    printf("\r\nFound a network we did not create, ");
    printf("version %d grounded %d preference %d used %d joined %d rank %d\n\r",
           dag->version, dag->grounded,
           dag->preference, dag->used,
           dag->joined, dag->rank);
#endif /* DEBUG */

    /* We found a RPL network that we did not create so we just join
       it without becoming root. But if the network has an infinite
       rank, we assume the network has broken, and we become the new
       root of the network. */

    if(dag->rank == INFINITE_RANK) {
      if(to_become_root) {
		printf("\r\n The dag rank is infinite, so we'll become the root");
        simple_rpl_init_dag_immediately();
        to_become_root = 0;
      }
    }

    /* Try again after the grace period */
    ctimer_set(&c, RPL_DAG_GRACE_PERIOD, create_dag_callback, NULL);
  }
}
开发者ID:AWGES,项目名称:StormSAMR21,代码行数:46,代码来源:simple-rpl.c

示例8: recv_uc

// Handlers for unicast
static void recv_uc(struct unicast_conn *c, const rimeaddr_t *from)
{ 
 if((from->u8[0] == RECEIVER) && (from->u8[1] == 0)){	 
 	 // Receive message
	 leds_on(LEDS_GREEN);
	 struct message mesg;
	 memcpy(&mesg, packetbuf_dataptr(), sizeof(mesg));
	 total_to_be_sent = mesg.seqno;
	 printf("Total to be sent: %d\n",total_to_be_sent);
	 leds_off(LEDS_GREEN); 	 
	 // Starting sending
	 //clock_delay(353*50);
	 ctimer_set(&timer1, 2*PACKETS_TIME, ctimer1_callback, NULL);
 }
 else{
	printf("ERROR: received an unexpected unicast from host (%d:%d)!\n",from->u8[0],from->u8[1]);  
 }
}
开发者ID:vaibhav90,项目名称:NES_Project,代码行数:19,代码来源:sensys_tx.c

示例9: handler_802154_active_scan

/*
 * active scan - will scan all 16 channels in the 802.15.4 network
 * NOTE: this assumes 16 channels, starting from 11. Needs to be changed
 * if running on other than 2.4 GHz
 */
int
handler_802154_active_scan(scan_callback_t cb)
{
  /* if no scan is active - start one */
  if(!scan) {
    callback = cb;
    current_channel = 0;
#if (DISABLE_NETSELECT_RANDOM_CHANNEL == 0)
    channel_index = 0;
#endif /* (DISABLE_NETSELECT_RANDOM_CHANNEL == 0) */
    scan = 1;
    chseqno = framer_802154_next_seqno();
    NETSTACK_RADIO.set_value(RADIO_PARAM_RX_MODE, 0);
    ctimer_set(NULL, &scan_timer, (CLOCK_SECOND * 6) / 10, &handle_scan_timer, callback);
    return 1;
  }
  return 0;
}
开发者ID:CurieBSP,项目名称:zephyr,代码行数:23,代码来源:handler-802154.c

示例10: rudolph2_send

/*---------------------------------------------------------------------------*/
void
rudolph2_send(struct rudolph2_conn *c, clock_time_t send_interval)
{
  int len;

  c->hops_from_base = 0;
  c->version++;
  c->snd_nxt = 0;
  len = RUDOLPH2_DATASIZE;
  packetbuf_clear();
  for(c->rcv_nxt = 0; len == RUDOLPH2_DATASIZE; c->rcv_nxt++) {
    len = read_data(c, packetbuf_dataptr(), c->rcv_nxt);
  }
  c->flags = FLAG_LAST_RECEIVED;
  /*  printf("Highest chunk %d\n", c->rcv_nxt);*/
  send_data(c, SEND_INTERVAL);
  ctimer_set(&c->t, SEND_INTERVAL, timed_send, c);
}
开发者ID:kincki,项目名称:contiki,代码行数:19,代码来源:rudolph2.c

示例11: PROCESS_THREAD

PROCESS_THREAD(simple_process, ev, data)
{
	PROCESS_BEGIN();

	cc2420_set_txpower(12);
	init_router(&message_received);

	static struct ctimer ct;
	ctimer_set(&ct, CLOCK_SECOND * 60 * 5, send_message_after_5_minutes, NULL);

	process_start(&neighbor_discovery_process, NULL);

	printf("K = %d, MAX_NODES = %d, MAX_EDGES = %d, LINKADDR = %d.%d\n", (int) K, (int) MAX_NODES, (int) MAX_EDGES, linkaddr_node_addr.u8[0], linkaddr_node_addr.u8[1]);
	printf("NODE_MEM = %dB, EDGE_MEM = %dB\n", (int)(sizeof(p_node_t) * MAX_NODES), (int)(sizeof(p_edge_t) * MAX_EDGES));
	printf("PACKETBUF_SIZE = %d, TXPOWER = %d, INTERVAL = %d - %d\n", PACKETBUF_SIZE, cc2420_get_txpower(), DISCOVERY_INTERVAL_MIN, DISCOVERY_INTERVAL_MAX);

	PROCESS_END();
}
开发者ID:tud-bp-sensornet,项目名称:sensornet,代码行数:18,代码来源:firmware-multiple-senders.c

示例12: motor_on

void motor_on(uint8_t level, clock_time_t length)
{	
	CMU_ClockEnable(cmuClock_TIMER2, true);  	
	TIMER_Enable(TIMER2,true);	
  	
  	if (level > 16) level = 16;
  	if (level == 0)
  	{
    		motor_stop(NULL);
  	}
  	else
  	{
  		TIMER_CompareBufSet(TIMER2, 0, level*200);

    		if (length > 0)
      			ctimer_set(&motor_timer, length, motor_stop, NULL);
  	}
}
开发者ID:Sowhat2112,项目名称:KreyosFirmware,代码行数:18,代码来源:backlight.c

示例13: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(gpio_output_process, ev, data)
{
    PROCESS_BEGIN();

    quarkX1000_gpio_init();
    quarkX1000_gpio_config(PIN, QUARKX1000_GPIO_OUT);

    quarkX1000_gpio_clock_enable();

    ctimer_set(&timer, CLOCK_SECOND / 2, timeout, NULL);

    printf("GPIO output example is running\n");
    PROCESS_YIELD();

    quarkX1000_gpio_clock_disable();

    PROCESS_END();
}
开发者ID:oliverbunting,项目名称:contiki,代码行数:19,代码来源:gpio-output.c

示例14: rpl_schedule_dao

void
rpl_schedule_dao(rpl_instance_t *instance)
{
  clock_time_t expiration_time;

  expiration_time = etimer_expiration_time(&instance->dao_timer.etimer);

  if(!etimer_expired(&instance->dao_timer.etimer)) {
    PRINTF("RPL: DAO timer already scheduled\n");
  } else {
    expiration_time = RPL_DAO_LATENCY / 2 +
      (random_rand() % (RPL_DAO_LATENCY));
    PRINTF("RPL: Scheduling DAO timer %u ticks in the future\n",
           (unsigned)expiration_time);
    ctimer_set(&instance->dao_timer, expiration_time,
               handle_dao_timer, instance);
  }
}
开发者ID:Sowhat2112,项目名称:KreyosFirmware,代码行数:18,代码来源:rpl-timers.c

示例15: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(virtualsense_shell_process, ev, data)
{
  PROCESS_BEGIN();

#if WITH_PERIODIC_DEBUG
  ctimer_set(&debug_timer, 20 * CLOCK_SECOND, periodic_debug, NULL);
#endif /* WITH_PERIODIC_DEBUG */

  serial_shell_init();
  shell_reboot_init();
  shell_gateway_init(NULL);

#if DEBUG_SNIFFERS
  rime_sniffer_add(&s);
#endif /* DEBUG_SNIFFERS */
  
  PROCESS_END();
}
开发者ID:mikewen,项目名称:virtual-sense,代码行数:19,代码来源:virtualsense-shell.c


注:本文中的ctimer_set函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。