标题: stm32f10x 移植contiki源程序 [打印本页]

作者: kaihua.yang    时间: 2019-7-8 22:07
标题: stm32f10x 移植contiki源程序
1.使用std库
2.移植了contiki
3.运行两个thread正常

单片机源程序如下:
  1. #include "contiki.h"
  2. unsigned int idle_count = 0;

  3. static struct etimer et_on;
  4. PROCESS(led_on, "led_on");
  5. PROCESS_THREAD(led_on, ev, data)  
  6. {
  7.     static int on = 0;
  8.         PROCESS_BEGIN();

  9.         while(1)
  10.         {
  11.            on++;
  12.            etimer_set(&et_on, CLOCK_SECOND);              // etimer溢出时间为5s
  13.        PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et_on));  // 等待定时器溢出
  14.         }

  15.         PROCESS_END();
  16. }


  17. static struct etimer et_off;
  18. PROCESS(led_off, "led_off");
  19. PROCESS_THREAD(led_off, ev, data)  
  20. {
  21.     static int off = 0;
  22.         PROCESS_BEGIN();

  23.         while(1)
  24.         {
  25.            off++;
  26.            etimer_set(&et_off, CLOCK_SECOND);              // etimer溢出时间为5s
  27.        PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et_off));  // 等待定时器溢出
  28.         }

  29.         PROCESS_END();
  30. }

  31. AUTOSTART_PROCESSES(&led_on,&led_off);  

  32. int main(void*arg)
  33. {
  34.         clock_init();  
  35.         process_init();  
  36.         process_start(&etimer_process,NULL);  
  37.         autostart_start(autostart_processes);
  38.         while(1){
  39.                 while(process_run()> 0);  
  40.                 idle_count++;  
  41.         }
  42. }
复制代码

所有资料51hei提供下载:
stm32-contiki-master.zip (350.96 KB, 下载次数: 11)







欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1