|
1.使用std庫
2.移植了contiki
3.運行兩個thread正常
單片機(jī)源程序如下:
- #include "contiki.h"
- unsigned int idle_count = 0;
- static struct etimer et_on;
- PROCESS(led_on, "led_on");
- PROCESS_THREAD(led_on, ev, data)
- {
- static int on = 0;
- PROCESS_BEGIN();
- while(1)
- {
- on++;
- etimer_set(&et_on, CLOCK_SECOND); // etimer溢出時間為5s
- PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et_on)); // 等待定時器溢出
- }
- PROCESS_END();
- }
- static struct etimer et_off;
- PROCESS(led_off, "led_off");
- PROCESS_THREAD(led_off, ev, data)
- {
- static int off = 0;
- PROCESS_BEGIN();
- while(1)
- {
- off++;
- etimer_set(&et_off, CLOCK_SECOND); // etimer溢出時間為5s
- PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et_off)); // 等待定時器溢出
- }
- PROCESS_END();
- }
- AUTOSTART_PROCESSES(&led_on,&led_off);
- int main(void*arg)
- {
- clock_init();
- process_init();
- process_start(&etimer_process,NULL);
- autostart_start(autostart_processes);
- while(1){
- while(process_run()> 0);
- idle_count++;
- }
- }
復(fù)制代碼
所有資料51hei提供下載:
stm32-contiki-master.zip
(350.96 KB, 下載次數(shù): 11)
2019-7-8 22:06 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|
評分
-
查看全部評分
|