找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

搜索
查看: 1753|回復(fù): 0
收起左側(cè)

stm32f10x 移植contiki源程序

[復(fù)制鏈接]
ID:337456 發(fā)表于 2019-7-8 22:07 | 顯示全部樓層 |閱讀模式
1.使用std庫(kù)
2.移植了contiki
3.運(yùn)行兩個(gè)thread正常

單片機(jī)源程序如下:
  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溢出時(shí)間為5s
  13.        PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et_on));  // 等待定時(shí)器溢出
  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溢出時(shí)間為5s
  27.        PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et_off));  // 等待定時(shí)器溢出
  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. }
復(fù)制代碼

所有資料51hei提供下載:
stm32-contiki-master.zip (350.96 KB, 下載次數(shù): 11)


評(píng)分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎(jiǎng)勵(lì)!

查看全部評(píng)分

回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表