• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PROCESS_WAIT_EVENT_UNTIL函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(border_router_process, ev, data)
{
  static struct etimer et;

  PROCESS_BEGIN();

/* While waiting for the prefix to be sent through the SLIP connection, the future
 * border router can join an existing DAG as a parent or child, or acquire a default
 * router that will later take precedence over the SLIP fallback interface.
 * Prevent that by turning the radio off until we are initialized as a DAG root.
 */
  prefix_set = 0;

  PROCESS_PAUSE();

  PRINTF("RPL-Border router started\n");

  
  /* Request prefix until it has been received */
  while(!prefix_set) {
    etimer_set(&et, CLOCK_SECOND);
    request_prefix();
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
    PRINTF("Waiting for prefix\n");
  }

  PRINTF("Obtained prefix: ");
  uip_debug_ipaddr_print(&prefix);
  PRINTF("\n");

  rpl_tools_init(&prefix);

  etimer_set(&et, CLOCK_SECOND * 60);
  while(1) {
    print_network_status();
    PROCESS_YIELD_UNTIL(etimer_expired(&et));
    etimer_reset(&et);
  }
  PROCESS_END();
}
开发者ID:13416795,项目名称:contiki,代码行数:41,代码来源:border-router.c


示例2: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(p_inputs, ev, data)
  {
  //déclaration des variables
  static terraZooData_s* theDataStruct;
  static int16_t aTemperature;
  static int16_t aLight;


  PROCESS_BEGIN();
  PRINTF("[p_inputs] Process Begin\r\n");

  //Initialisations
  theDataStruct=NULL;
  aTemperature=0;
  aLight=0;


  while (1)
    {
    PROCESS_WAIT_EVENT_UNTIL(ev==P_IN_START);
    PRINTF("[p_inputs] Restart\r\n");
  
    theDataStruct=(terraZooData_s*)data;

    //Get temp
    aTemperature=gettmp();
    theDataStruct->theTemp=aTemperature;

    PRINTF("[p_inputs] Temp : %d\r\n", theDataStruct->theTemp);

    //Get light
    aLight=500;//getlight();
    theDataStruct->theLight=aLight;

    PRINTF("[p_inputs] Light : %d\r\n", aLight);
    }

    PROCESS_END();
  }
开发者ID:miiicmueller,项目名称:TerraZoo,代码行数:40,代码来源:in_out.c


示例3: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_senseconv_process, ev, data)
{
    struct shell_input *input;
    struct sense_msg *msg;
    PROCESS_BEGIN();
    while(1) {
        PROCESS_WAIT_EVENT_UNTIL(ev == shell_event_input);
        input = data;

        if(input->len1 + input->len2 == 0) {
            PROCESS_EXIT();
        }
        msg = (struct sense_msg *)input->data1;

        if(msg != NULL) {
            char buf[40];
            snprintf(buf, sizeof(buf),
                     "%d", 10 * msg->light1 / 7);
            shell_output_str(&senseconv_command, "Light 1 ", buf);
            snprintf(buf, sizeof(buf),
                     "%d", 46 * msg->light2 / 10);
            shell_output_str(&senseconv_command, "Light 2 ", buf);
            snprintf(buf, sizeof(buf),
                     "%d.%d", (msg->temp / 10 - 396) / 10,
                     (msg->temp / 10 - 396) % 10);
            shell_output_str(&senseconv_command, "Temperature ", buf);
            snprintf(buf, sizeof(buf),
                     "%d", (int)(-4L + 405L * msg->humidity / 10000L));
            shell_output_str(&senseconv_command, "Relative humidity ", buf);
            snprintf(buf, sizeof(buf),
                     "%d", msg->rssi);
            shell_output_str(&senseconv_command, "RSSI ", buf);
            snprintf(buf, sizeof(buf), /* 819 = 4096 / 5 */
                     "%d.%d", (msg->voltage / 819), (10 * msg->voltage / 819) % 10);
            shell_output_str(&senseconv_command, "Voltage ", buf);
        }
    }
    PROCESS_END();
}
开发者ID:Veldmonster,项目名称:contiki-mirror,代码行数:40,代码来源:shell-sky.c


示例4: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(enc_watchdog_process, ev, data)
{
  static struct etimer et;

  PROCESS_BEGIN();

  while(1) {
#define RESET_PERIOD (30*CLOCK_SECOND)
    etimer_set(&et, RESET_PERIOD);
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));

    PRINTF("enc28j60: test received_packet %d > sent_packets %d\n", received_packets, sent_packets);
    if(received_packets <= sent_packets) {
      PRINTF("enc28j60: resetting chip\n");
      reset();
    }
    received_packets = 0;
    sent_packets = 0;
  }

  PROCESS_END();
}
开发者ID:ADVANSEE,项目名称:mist,代码行数:23,代码来源:enc28j60.c


示例5: PROCESS_THREAD

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

	tcp_listen(UIP_HTONS(8080));

	while(1) {
		PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event);
		printf("TCP server: receive TCP event\n");

		if(uip_closed() || uip_aborted() || uip_timedout()) {
			printf("TCP server: connection closed\n");
		} else if(uip_connected()) {
			printf("TCP server: connected\n");
		}

		if(uip_newdata()) {
			printf("TCP server: receive new data\n");
			uint16_t len = uip_datalen();
			uint8_t *ptr = uip_appdata;
			while(len--){
				printf("%c", *ptr++);
			}
			printf("\n");

			printf("TCP server: send echo message\n");
			uip_send(uip_appdata, uip_datalen());
		}
		if(uip_rexmit() ||
				uip_newdata() ||
				uip_acked() ||
				uip_connected() ||
				uip_poll()) {
			//senddata();
		}
	}
  
  PROCESS_END();
}
开发者ID:ShidoShinji,项目名称:uipv6-6lowpan,代码行数:40,代码来源:main.c


示例6: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(sender_process, ev, data)
{

  PROCESS_BEGIN();
  static uip_ipaddr_t ipaddr, unicastaddr;
  int i;
  uint8_t state;
  static struct etimer timer;
  static struct simple_udp_connection connection;
  static char *packet = "Supertest";

  uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
  uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
  uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF); 

  uip_ip6addr(&unicastaddr, 0xfe80, 0, 0, 0, 0xc30c, 0, 0, 2);

  simple_udp_register(&connection, UDP_PORT, NULL, UDP_PORT, NULL);

  printf("IPv6 addresses: ");
  for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
    state = uip_ds6_if.addr_list[i].state;
    if(uip_ds6_if.addr_list[i].isused &&
       (state == ADDR_TENTATIVE 
       || state == ADDR_PREFERRED)) {
            uip_debug_ipaddr_print(
               &uip_ds6_if.addr_list[i].ipaddr);
            printf("\n");
    }
  }
  etimer_set(&timer, CLOCK_SECOND);
  while(1) {
    printf("STO MANDANDO UNICAST\n");
    simple_udp_sendto(&connection, packet, strlen(packet)+1, &unicastaddr);
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&timer));
    etimer_restart(&timer);
  }
  PROCESS_END();
}
开发者ID:Cremesis,项目名称:IoT,代码行数:40,代码来源:sender.c


示例7: PROCESS_THREAD

PROCESS_THREAD(led_on, ev, data)
{
  static struct etimer etmr;
  
  WDTE=0xac;
  
  PROCESS_BEGIN();
  
  etimer_set(&etmr, CLOCK_CONF_SECOND);
  event_led_on = process_alloc_event();
  
  while(1)
  {
    PROCESS_WAIT_EVENT_UNTIL(ev==PROCESS_EVENT_TIMER);
 //   offled = (~offled);
 //   BELL = 0;
    process_post(&led_off, event_led_on, NULL);
    etimer_reset(&etmr);
  }
  
  PROCESS_END();
}
开发者ID:azengzz,项目名称:contiki_on_78k0,代码行数:22,代码来源:main.c


示例8: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(data_process, ev, data)
{
  static struct etimer et;
  //uint32_t transmit, listen, all_transmit, all_listen;
  //static uint32_t last_transmit, last_listen;

  PROCESS_BEGIN();
  
  PRINTF("Energy process started\n");


  while(1) {
    /*
    all_transmit = energest_type_time(ENERGEST_TYPE_TRANSMIT);
    all_listen = energest_type_time(ENERGEST_TYPE_LISTEN);

    transmit = all_transmit - last_transmit;
    listen = all_listen - last_listen;

    last_transmit = all_transmit;
    last_listen = all_listen;
    */

    printf("%d %d %d %d \n", uip_stat.ip.sent, uip_stat.ip.forwarded, uip_stat.ip.recv, uip_stat.ip.drop);
    
      /* Delay 2-4 seconds */
    
    etimer_set(&et, CLOCK_SECOND * 30);

    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
    
   // printf(" %d %d %d\n",uip_stat.ip.sent, uip_stat.ip.forwarded, uip_stat.ip.recv);
   // rpl_print_neighbor_list();
   // print_local_addresses();
   
  }

  PROCESS_END();
}
开发者ID:brunoliveira8,项目名称:contiki,代码行数:40,代码来源:udp-client.c


示例9: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(http_example_process, ev, data)
{
  static struct etimer et;
  uip_ip4addr_t ip4addr;
  uip_ip6addr_t ip6addr;

  PROCESS_BEGIN();

  uip_ipaddr(&ip4addr, 8, 8, 8, 8);
  ip64_addr_4to6(&ip4addr, &ip6addr);
  uip_nameserver_update(&ip6addr, UIP_NAMESERVER_INFINITE_LIFETIME);

  etimer_set(&et, CLOCK_SECOND * 20);
  PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));

  memset(url_buffer, 0, HTTP_CLIENT_BUFFER_LEN);
  snprintf(url_buffer, HTTP_CLIENT_BUFFER_LEN,
           "http://maker.ifttt.com/trigger/%s/with/key/%s",
           IFTTT_EVENT, IFTTT_KEY);

  http_socket_init(&s);

  restarts = 0;

  while(1) {
    PROCESS_YIELD();
    if((ev == sensors_event) && (data == &button_sensor)) {
      if(button_sensor.value(BUTTON_SENSOR_VALUE_TYPE_LEVEL) ==
        BUTTON_SENSOR_PRESSED_LEVEL) {
        leds_on(LEDS_GREEN);
        printf("Button pressed! sending a POST to IFTTT\n");
        http_socket_post(&s, url_buffer, NULL, 0, NULL, callback, NULL);
      }
    }
  }

  PROCESS_END();
}
开发者ID:1847123212,项目名称:contiki,代码行数:39,代码来源:ifttt-client.c


示例10: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(sample_mag_process, ev, data)
{
  static struct etimer et;

  PROCESS_BEGIN();
  SENSORS_ACTIVATE(hmc5883l_sensor);

  /* Sample every 2 seconds */
  etimer_set(&et, 2*CLOCK_SECOND);

  while(1) {
    struct mag_msg msg;

    /* Wait for timer */
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
    /* Reset timer:
     * It will expire exactly 2 seconds after last expiration */
    etimer_reset(&et);

    msg.type = TYPE_MAG;

    /* Our position */
    msg.pos_x = 0; /* TODO Estimate X coordinate [1-100] */
    msg.pos_y = 0; /* TODO Estimate Y coordinate [1-100] */

    // Must latch the data first before getting mag_x, y, z
    hmc5883l_sensor.value(HMC5883L_LATCH_DATA);
    msg.mag_x = hmc5883l_sensor.value(HMC5883L_MAG_X_RAW);
    msg.mag_y = hmc5883l_sensor.value(HMC5883L_MAG_Y_RAW);
    msg.mag_z = hmc5883l_sensor.value(HMC5883L_MAG_Z_RAW);

    /* Print position and mag */
    printf("pos=(%u,%u) mag=[%4d, %4d, %4d]\n", msg.pos_x, msg.pos_y, msg.mag_x, msg.mag_y, msg.mag_z);
    FLASH_LED(LEDS_GREEN);
  }

  PROCESS_END();
}
开发者ID:andrewgrex,项目名称:MethHardware,代码行数:39,代码来源:ex-mag.c


示例11: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_size_process, ev, data)
{
  static unsigned long size;
  struct shell_input *input;
  char buf[10];
  
  PROCESS_BEGIN();
  size = 0;
  
  while(1) {
    PROCESS_WAIT_EVENT_UNTIL(ev == shell_event_input);
    input = data;

    size += input->len1 + input->len2;
    
    if(input->len1 + input->len2 == 0) {
      snprintf(buf, sizeof(buf), "%lu", size);
      shell_output_str(&size_command, buf, "");
      PROCESS_EXIT();
    }
  }
  PROCESS_END();
}
开发者ID:AWRyder,项目名称:contiki,代码行数:24,代码来源:shell-text.c


示例12: PROCESS_THREAD

PROCESS_THREAD(UDP_echo_process, ev, data)
{
    static uip_ipaddr_t localaddr;
    static struct uip_udp_conn *localconn;

    PROCESS_BEGIN();

    /* Create the local listener */
    localconn = udp_new(&uip_all_zeroes_addr, 0, NULL);
    udp_bind(localconn,uip_htons(local_port));
    while (1)
    {
        PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event);
        /* If there is new uIP data, display it */
        if(uip_newdata()) {
            /* Add the end of string. */
            ((char *)uip_appdata)[uip_datalen()] = 0;
            printf("New uIP data: '%s'\n", uip_appdata);
        }
    }

    PROCESS_END();
}
开发者ID:anthonygelibert,项目名称:WiSMote-Contiki,代码行数:23,代码来源:udpTest.c


示例13: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_timestamp_process, ev, data)
{
  struct shell_input *input;
  struct msg {
    uint16_t len;
    uint16_t time[2];
    uint16_t timesynch;
    uint8_t data[MAX_COMMANDLENGTH];
  } msg;
  
  PROCESS_BEGIN();

  while(1) {
    PROCESS_WAIT_EVENT_UNTIL(ev == shell_event_input);
    input = data;
    if(input->len1 + input->len2 == 0) {
      PROCESS_EXIT();
    }
    
    msg.len = 3 + *(uint16_t *)input->data1;
    msg.time[0] = (uint16_t)(shell_time() >> 16);
    msg.time[1] = (uint16_t)(shell_time());
#if TIMESYNCH_CONF_ENABLED
    msg.timesynch = timesynch_time();
#else /* TIMESYNCH_CONF_ENABLED */
    msg.timesynch = 0;
#endif /* TIMESYNCH_CONF_ENABLED */
    memcpy(msg.data, input->data1 + 2,
	   input->len1 - 2 > MAX_COMMANDLENGTH?
	   MAX_COMMANDLENGTH: input->len1 - 2);
    
    shell_output(&timestamp_command, &msg, 6 + input->len1,
		 input->data2, input->len2);
  }

  PROCESS_END();
}
开发者ID:200018171,项目名称:contiki,代码行数:38,代码来源:shell-time.c


示例14: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(ds18b20_poll_process, ev, data)
{
  static struct etimer et;
  static uint8_t scratchpad[DS18B20_SCRATCHPAD_SIZE];
  static ow_rom_code_t id;

  PROCESS_BEGIN();

  printf("\nDS18B20 test\n");

  printf("VSEC ON\n");
  power_control_vsec_set(1);

  /* initialize the DS18B20 hardware */
  printf("Initialize 1-wire\n");
  ow_init();
  printf("1-wire READ ROM\n");
  id = ow_read_rom();
  printf("Initialize DS18B20\n");
  ds18b20_init();
  printf("DS18B20 init done\n");

  /* Poll at 1Hz */
  etimer_set(&et, CLOCK_SECOND);

  while(1) {
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));

    /* Reset the etimer to trig again */
    etimer_reset(&et);

    ds18b20_read_scratchpad(id, scratchpad);
    ds18b20_convert_temperature(id);
  }

  PROCESS_END();
}
开发者ID:punyal,项目名称:Contiki_3-IPsec,代码行数:38,代码来源:ds18b20-poll.c


示例15: PROCESS_THREAD

PROCESS_THREAD(schedule_task, ev, data)
{	
  static int i;
  static int min;
  static int min_slot;
  static int flag;
  static struct application_struct  new_task;

  PROCESS_BEGIN();
  
  new_task.load=((struct application_struct *)data)->load;
  new_task.lower_slot=((struct application_struct *)data)->lower_slot;
  new_task.upper_slot=((struct application_struct *)data)->upper_slot;
  flag=0;
  do{	
  	min=hourly_load[new_task.lower_slot];
	min_slot=new_task.lower_slot;
	for(i=(new_task.lower_slot+1);i<=new_task.upper_slot;i++){
		if (hourly_load[i]<min){
			min_slot=i;
			min=hourly_load[i];
		}
	}
 	Shared_Comp_and_Swap(min_slot,min,min+new_task.load);
  	PROCESS_WAIT_EVENT_UNTIL(ev == event_2pc_to_comm );
  	if(!(strcmp(data,"BCAST_S"))){
 		printf("Comp and Swap was succ\n");
		flag=1;
  	}
  	else{
 		printf("Comp and Swap was not succ\n");
  	}
  }     
  while(flag==0);

  PROCESS_END();
}
开发者ID:mpastyl,项目名称:load_scheduling,代码行数:37,代码来源:peristent.c


示例16: PROCESS_THREAD

PROCESS_THREAD(test, ev, data)
{

	static struct etimer et;

	PROCESS_BEGIN();
		myaddr = init_l2addr_154_char("45:67");

		l2 = startL2_154( myaddr, CHANNEL, PANID); 
		ca = initCasan(l2, MTU, slaveid);

		r1 = initResource (R1_name, R1_title, R1_rt) ;
		setHandlerResource(r1, COAP_CODE_GET, process_temp );
		register_resource(ca, r1);

		r2 = initResource (R2_name, R2_title, R2_rt) ;
		setHandlerResource(r2, COAP_CODE_GET, process_temp );
		register_resource(ca, r2);

		while(1) {    

			if (n % NTAB (resname) == 0)
	    		print_resources (ca) ;
	    	test_resource (ca, l2, resname [n++ % NTAB (resname)]) ;
			
	    	printf("\n");
	    	printf("*************************************************************************");
	    	printf("\n");

	        etimer_set(&et,5*CLOCK_SECOND); 
        	PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
	    }



   	PROCESS_END();
}
开发者ID:kyanhNG,项目名称:casan-contiki,代码行数:37,代码来源:test-res.c


示例17: PROCESS_THREAD

/* Process to get ht sensor value.
   ht sensor is sampled. Sampling stopped when sensor is de-activated.
   Event is generated if temp and/or hum value changed at least the value DELTA_TEMP_SENSOR_VALUE
   or DELTA_HUM_SENSOR_VALUE since last event. */
PROCESS_THREAD(HTSensorSampling, ev, data)
{
  PROCESS_BEGIN();
  static struct etimer et;

  etimer_set(&et, CLOCK_SECOND);
  while(1) {
    PROCESS_WAIT_EVENT_UNTIL((ev == PROCESS_EVENT_TIMER) || (ev == PROCESS_EVENT_MSG));
    if(ev == PROCESS_EVENT_TIMER) {
      /* Handle sensor reading. */
      vHTSstartReadTemp();
      temp_sensor_value = u16HTSreadTempResult();
      PRINTF("Temperature sample: %d\n", temp_sensor_value);
      vHTSstartReadHumidity();
      hum_sensor_value = u16HTSreadHumidityResult();
      PRINTF("Humidity sample: %d\n", hum_sensor_value);
      if((abs(temp_sensor_value - prev_temp_event_val) > DELTA_TEMP_SENSOR_VALUE) ||
         (abs(hum_sensor_value - prev_hum_event_val) > DELTA_HUM_SENSOR_VALUE)) {
        prev_temp_event_val = temp_sensor_value;
        prev_hum_event_val = hum_sensor_value;
        sensors_changed(&ht_sensor);
      }
      etimer_reset(&et);
    } else {
      /* ev == PROCESS_EVENT_MSG */
      if(*(int *)data == HT_SENSOR_STATUS_NOT_ACTIVE) {
        /* Stop sampling */
        etimer_stop(&et);
      } else if((*(int *)data == HT_SENSOR_STATUS_ACTIVE)) {
        /* restart sampling */
        etimer_restart(&et);
      }
    }
  }
  PROCESS_END();
}
开发者ID:13416795,项目名称:contiki,代码行数:40,代码来源:ht-sensor.c


示例18: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(sensors_process, ev, data)
{
  static int i;
  static int events;

  PROCESS_BEGIN();

  sensors_event = process_alloc_event();

  
  for(i = 0; sensors[i] != NULL; ++i) {
    sensors_flags[i] = 0;
    sensors[i]->configure(SENSORS_HW_INIT, 0);
  }
  num_sensors = i;

  while(1) {

    PROCESS_WAIT_EVENT();

    do {
      events = 0;
      for(i = 0; i < num_sensors; ++i) {
	if(sensors_flags[i] & FLAG_CHANGED) {
	  if(process_post(PROCESS_BROADCAST, sensors_event, (void *)sensors[i]) == PROCESS_ERR_OK) {
	    PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event);
	  }
	  sensors_flags[i] &= ~FLAG_CHANGED;
	  events++;
	}
      }
    } while(events);
  }

  PROCESS_END();
}
开发者ID:AWGES,项目名称:StormSAMR21,代码行数:37,代码来源:sensors.c


示例19: PROCESS_THREAD

PROCESS_THREAD(accel_process, ev, data) {
  PROCESS_BEGIN();
  {
    int16_t x, y, z;

    serial_shell_init();
    shell_ps_init();
    shell_file_init();  // for printing out files
    shell_text_init();  // for binprint

    /* Register the event used for lighting up an LED when interrupt strikes. */
    ledOff_event = process_alloc_event();

    /* Start and setup the accelerometer with default values, eg no interrupts enabled. */
    accm_init();

    /* Register the callback functions for each interrupt */
    ACCM_REGISTER_INT1_CB(accm_ff_cb);
    ACCM_REGISTER_INT2_CB(accm_tap_cb);

    /* Set what strikes the corresponding interrupts. Several interrupts per pin is 
      possible. For the eight possible interrupts, see adxl345.h and adxl345 datasheet. */
    accm_set_irq(ADXL345_INT_FREEFALL, ADXL345_INT_TAP + ADXL345_INT_DOUBLETAP);

    while (1) {
	    x = accm_read_axis(X_AXIS);
	    y = accm_read_axis(Y_AXIS);
	    z = accm_read_axis(Z_AXIS);
	    printf("x: %d y: %d z: %d\n", x, y, z);

      etimer_set(&et, ACCM_READ_INTERVAL);
      PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
    }
  }
  PROCESS_END();
}
开发者ID:chanhemow,项目名称:contiki-fork,代码行数:36,代码来源:test-adxl345.c


示例20: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(sensor_output_process, ev, data)
{
  struct sensors_sensor *s;

  PROCESS_BEGIN();

  /* Activate some sensors to get sensor events */
  button_sensor.configure(SENSORS_ACTIVE, 1);
  pir_sensor.configure(SENSORS_ACTIVE, 1);
  vib_sensor.configure(SENSORS_ACTIVE, 1);

  while(1) {
    PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event);

    s = (struct sensors_sensor *)data;
    printf("%s %d\n", s->type, s->value(0));

    if (data == &button_sensor) leds_invert(LEDS_YELLOW);
    if (data == &pir_sensor) leds_invert(LEDS_GREEN);
    if (data == &vib_sensor) leds_invert(LEDS_RED);
  }

  PROCESS_END();
}
开发者ID:Ammar-85,项目名称:contiki-arduino,代码行数:25,代码来源:sensor-output.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PROCESS_WAIT_UNTIL函数代码示例发布时间:2022-05-30
下一篇:
C++ PROCESS_WAIT_EVENT函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap